{"problem_id": "p03040", "p_user": "u683134447", "n_user": "u683134447", "pos": "q = int(input())\nans = [0, 0]\nimport heapq\np1 = []\np2 = []\nheapq.heapify(p1)\nheapq.heapify(p2)\nsum_b = 0\nsum_p1 = 0\nsum_p2 = 0\nfor _ in range(q):\n ql = list(map(int,input().split()))\n if ql[0] == 2:\n if len(p1) == len(p2):\n print(-p2[0], sum_p1 - len(p1) * -p2[0] + len(p2) * -p2[0] - sum_p2 + sum_b)\n else:\n print(p1[0], sum_p1 - len(p1) * p1[0] + len(p2) * p1[0] - sum_p2 + sum_b)\n else:\n sum_b += ql[2]\n if len(p1) == 0:\n heapq.heappush(p1, ql[1])\n sum_p1 += ql[1]\n elif p1[0] <= ql[1]:\n heapq.heappush(p1, ql[1])\n sum_p1 += ql[1]\n else:\n heapq.heappush(p2, -ql[1])\n sum_p2 += ql[1]\n if len(p1) < len(p2):\n k = heapq.heappop(p2)\n heapq.heappush(p1, -k)\n sum_p2 += k\n sum_p1 -= k\n if len(p1) - 1 > len(p2):\n k = heapq.heappop(p1)\n heapq.heappush(p2, -k)\n sum_p1 -= k\n sum_p2 += k\n\n", "neg": "q = int(input())\nans = [0, 0]\nimport heapq\np1 = []\np2 = []\nheapq.heapify(p1)\nheapq.heapify(p2)\nsum_b = 0\nsum_p1 = 0\nsum_p2 = 0\nfor _ in range(q):\n ql = list(map(int,input().split()))\n if ql[0] == 2:\n print(p1[0], sum_p1 - len(p1) * p1[0] + len(p2) * p1[0] - sum_p2 + sum_b)\n else:\n sum_b += ql[2]\n if len(p1) == 0:\n heapq.heappush(p1, ql[1])\n sum_p1 += ql[1]\n elif p1[0] <= ql[1]:\n heapq.heappush(p1, ql[1])\n sum_p1 += ql[1]\n else:\n heapq.heappush(p2, -ql[1])\n sum_p2 += ql[1]\n if len(p1) < len(p2):\n k = heapq.heappop(p2)\n heapq.heappush(p1, -k)\n sum_p2 -= k\n sum_p1 += k\n if len(p1) - 1 > len(p2):\n k = heapq.heappop(p1)\n heapq.heappush(p2, -k)\n sum_p1 -= k\n sum_p2 += k\n\n", "jacc_sim": 1.0, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [470, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u816872429", "n_user": "u816872429", "pos": "import heapq\n\nq = int(input())\ninf = 10000000000\nleft = [inf]\nright = [inf]\nminval = 0\nfor _ in range(q):\n query = list(map(int, input().split()))\n if query[0] == 1:\n _, a, b = query\n if a < -left[0]:\n v = -heapq.heappop(left)\n heapq.heappush(right, v)\n heapq.heappush(left, -a)\n heapq.heappush(left, -a)\n minval += abs(v - a) + b\n elif a > right[0]:\n v = heapq.heappop(right)\n heapq.heappush(left, -v)\n heapq.heappush(right, a)\n heapq.heappush(right, a)\n minval += abs(v - a) + b\n else:\n heapq.heappush(left, -a)\n heapq.heappush(right, a)\n minval += b\n else:\n print(-left[0], minval)", "neg": "import heapq\n\nq = int(input())\ninf = 10000000000\nleft = [inf]\nright = [inf]\nminval = 0\nfor _ in range(q):\n query = list(map(int, input().split()))\n if query[0] == 1:\n _, a, b = query\n if a < -left[0]:\n v = -heapq.heappop(left)\n heapq.heappush(right, v)\n heapq.heappush(left, -a)\n heapq.heappush(left, -a)\n minval += abs(v - a) + b\n elif a > right[0]:\n v = heapq.heappop(roght)\n heapq.heappush(left, -v)\n heapq.heappush(right, a)\n heapq.heappush(right, a)\n minval += abs(v - a) + b\n else:\n heapq.heappush(left, -a)\n heapq.heappush(right, a)\n minval += b\n else:\n print(right[0], minval)", "jacc_sim": 0.9767441860465116, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [280, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u159335277", "n_user": "u159335277", "pos": "import heapq\n\nq = int(input())\n\nminheap = [] # right\nmaxheap = [] # left\nheapq.heapify(minheap)\nheapq.heapify(maxheap)\n\ns = 0\nm = 0\n\nfor _ in range(0, q):\n token = input().split()\n if len(token) > 1:\n a = int(token[1])\n b = int(token[2])\n s += b\n heapq.heappush(minheap, a)\n heapq.heappush(maxheap, -a)\n if -maxheap[0] > minheap[0]:\n maxv = -heapq.heappop(maxheap)\n minv = heapq.heappop(minheap)\n m += abs(maxv - minv)\n heapq.heappush(minheap, maxv)\n heapq.heappush(maxheap, -minv)\n else:\n print('{} {}'.format(-maxheap[0], s + m))\n", "neg": "import heapq\n\nq = int(input())\n\nminheap = [] # right\nmaxheap = [] # left\nheapq.heapify(minheap)\nheapq.heapify(maxheap)\n\ns = 0\nm = 0\n\nfor _ in range(0, q):\n token = input().split()\n if len(token) > 1:\n a = int(token[1])\n b = int(token[2])\n print(a, b)\n s += b\n heapq.heappush(minheap, a)\n heapq.heappush(maxheap, -a)\n if -maxheap[0] > minheap[0]:\n maxv = -heapq.heappop(maxheap)\n minv = heapq.heappop(minheap)\n m += abs(maxv - minv)\n heapq.heappush(minheap, maxv)\n heapq.heappush(maxheap, -minv)\n else:\n print('{} {}'.format(-maxheap[0], s + m))\n", "jacc_sim": 1.0, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [250, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u562935282", "n_user": "u562935282", "pos": "from heapq import heappop, heappush, heappushpop\n\nQ = int(input())\n\nb = 0\nla = []\nsl = 0\nra = []\nsr = 0\n\ncnt = 0\nfor _ in range(Q):\n q = input().split()\n # print(la, ra)\n if q[0] == '2':\n # \u6c42\u5024\n x = -la[0]\n print(x, ((cnt + 1) // 2 * x - sl) + (sr - cnt // 2 * x) + b)\n else:\n # \u66f4\u65b0\n x, y = map(int, q[1:])\n b += y\n cnt += 1\n if cnt % 2 == 1:\n sr += x\n x = heappushpop(ra, x)\n sr -= x\n sl += x\n heappush(la, -x)\n else:\n sl += x\n x = heappushpop(la, -x)\n x *= -1\n sl -= x\n sr += x\n heappush(ra, x)\n", "neg": "from heapq import heappush, heappushpop\n\nQ = int(input())\n\nb = 0\nla = []\nsl = 0\nra = []\nsr = 0\n\ncnt = 0\nfor _ in range(Q):\n q = map(int, input().split())\n # print(la, ra)\n if q[0] == 2:\n # \u6c42\u5024\n x = -la[0]\n cl = (cnt + 1) // 2\n cr = cnt - cl\n print(x, (cl * x - sl) + (sr - cr * x) + b)\n else:\n # \u66f4\u65b0\n b += q[2]\n cnt += 1\n if cnt % 2 == 1:\n sr += q[1]\n x = heappushpop(ra, q[1])\n sr -= x\n sl += x\n heappush(la, -x)\n else:\n sl += q[1]\n x = heappushpop(la, -q[1])\n x *= -1\n sl -= x\n sr += x\n heappush(ra, x)\n", "jacc_sim": 0.9019607843137255, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [273, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u075012704", "n_user": "u075012704", "pos": "import heapq\nimport sys\n\ninp = sys.stdin.readline\n\nQ = int(input())\nB = 0\n\nq, a, b = map(int, inp().split())\nL, R = [-a], [a]\nL_sum, R_sum = a, a\nB = b\n\nfor i in range(Q - 1):\n q = list(map(int, inp().split()))\n if len(q) == 3:\n A = q[1]\n B += q[2]\n\n if A <= -L[0]:\n heapq.heappush(L, -A)\n M = -heapq.heappushpop(L, -A)\n heapq.heappush(R, M)\n\n L_sum += (2 * A - M)\n R_sum += M\n else:\n heapq.heappush(R, A)\n M = heapq.heappushpop(R, A)\n heapq.heappush(L, -M)\n\n R_sum += (2 * A - M)\n L_sum += M\n else:\n N = len(L)\n X = -L[0]\n print(X, (abs(L_sum - X * N) + abs(R_sum - X * N)) // 2 + B)\n", "neg": "import heapq\n\nQ = int(input())\nB = 0\n\nq, a, b = map(int, input().split())\nL, R = [-a], [a]\nL_sum, R_sum = a, a\nB = b\n\nfor i in range(Q - 1):\n q = list(map(int, input().split()))\n if len(q) == 3:\n print(L, R)\n A = q[1]\n B += q[2]\n\n if A <= -L[0]:\n heapq.heappush(L, -A)\n M = -heapq.heappushpop(L, -A)\n heapq.heappush(R, M)\n\n L_sum += (2 * A - M)\n R_sum += M\n else:\n heapq.heappush(R, A)\n M = heapq.heappushpop(R, A)\n heapq.heappush(L, -A)\n\n R_sum += (2 * A - M)\n L_sum += M\n else:\n N = len(L)\n X = -L[0]\n print(X, (abs(L_sum - X * N) + abs(R_sum - X * N)) // 2 + B)\n", "jacc_sim": 0.9230769230769231, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [323, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u327466606", "n_user": "u327466606", "pos": "\nimport heapq as hq\n\nQ = int(input())\n\n\n\nlow = []\nhigh = []\n\n_,mid,val = map(int,input().split())\n\nfor _ in range(Q-1):\n s = input()\n if s[0] == '1':\n _,a,b = map(int,s.split())\n if mid is None:\n if a < -low[0]:\n mid = -hq.heapreplace(low, -a)\n elif a > high[0]:\n mid = hq.heapreplace(high, a)\n else:\n mid = a\n val += abs(mid-a)+b\n else:\n val += abs(mid-a)+b\n x,y = sorted((a,mid))\n hq.heappush(high, y)\n hq.heappush(low, -x)\n mid = None\n\n else:\n print(-low[0] if mid is None else mid, val)", "neg": "\nimport heapq as hq\n\nQ = int(input())\n\n\n\nlow = []\nhigh = []\n\n_,mid,val = map(int,input().split())\n\nfor _ in range(Q-1):\n s = input()\n if s[0] == '1':\n _,a,b = map(int,s.split())\n if mid is None:\n if a < -low[0]:\n mid = hq.heapreplace(low, -a)\n elif a > high[0]:\n mid = hq.heapreplace(high, a)\n else:\n mid = a\n val += abs(mid-a)+b\n else:\n val += abs(mid-a)+b\n x,y = sorted((a,mid))\n hq.heappush(high, y)\n hq.heappush(low, -x)\n mid = None\n\n else:\n print(high[0] if mid is None else mid, val)", "jacc_sim": 1.0, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [243, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u677267454", "n_user": "u677267454", "pos": "# -*- coding: utf-8 -*-\nfrom heapq import heappush, heappop\n\nqn = int(input())\n\nlow = []\nhigh = []\nans = 0\n\nfor i in range(qn):\n q = [int(i) for i in input().split()]\n if q[0] == 1:\n ans += q[2]\n a = q[1]\n\n if len(low) >= 1:\n if a < -low[0]:\n ans += -low[0] - a\n elif a > high[0]:\n ans += a - high[0]\n\n # low\u306f\u964d\u9806\u306b\u4e26\u3079\u305f\u3044\u306e\u3067-a\u3092\u5165\u308c\u308b\n heappush(low, -a)\n heappush(high, a)\n if -low[0] > high[0]:\n low0 = heappop(low)\n high0 = heappop(high)\n # low\u3068high\u3067\u6b63\u8ca0\u304c\u9006\u306a\u306e\u3067\u6ce8\u610f\u3059\u308b\n heappush(low, -high0)\n heappush(high, -low0)\n\n elif q[0] == 2:\n print(-low[0], ans)\n", "neg": "# -*- coding: utf-8 -*-\nfrom heapq import heappush, heappop\n\nqn = int(input())\n\nlow = []\nhigh = []\nans = 0\nnum = 0\n\nfor i in range(qn):\n q = [int(i) for i in input().split()]\n if q[0] == 1:\n ans += q[2]\n a = q[1]\n # low\u306f\u964d\u9806\u306b\u4e26\u3079\u305f\u3044\u306e\u3067-a\u3092\u5165\u308c\u308b\n heappush(low, -a)\n heappush(high, a)\n if -low[0] > high[0]:\n low0 = heappop(low)\n high0 = heappop(high)\n # low\u3068high\u3067\u6b63\u8ca0\u304c\u9006\u306a\u306e\u3067\u6ce8\u610f\u3059\u308b\n heappush(low, -high0)\n heappush(high, -low0)\n ans += high[0] + low[0]\n if q[0] == 2:\n print(high[0], ans)\n\nprint(high)\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [343, 313], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u777923818", "n_user": "u777923818", "pos": "from heapq import heappush, heappop\ndef inpl(): return list(map(int, input().split()))\n\nQ = int(input())\nL = []\nR = []\n\nB = 0\nM = 0\n\nfor _ in range(Q):\n q = inpl()\n if len(q) == 3:\n B += q[2]\n if len(R) == 0:\n L.append(-q[1])\n R.append(q[1])\n continue\n\n M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))\n if q[1] < R[0]:\n heappush(L, -q[1])\n heappush(L, -q[1])\n heappush(R, -heappop(L))\n else:\n heappush(R, q[1])\n heappush(R, q[1])\n heappush(L, -heappop(R))\n else:\n print(-L[0], B+M)\n", "neg": "from heapq import heappush, heappop, heappushpop\ndef inpl(): return list(map(int, input().split()))\n\nQ = int(input())\nL = []\nR = []\n\nB = 0\nM = 0\n\nfor _ in range(Q):\n q = inpl()\n if len(q) == 3:\n B += q[2]\n if len(R) == 0:\n L.append(-q[1])\n R.append(q[1])\n continue\n\n M += min(abs(-L[0] - q[1]), abs(R[0] - q[1])) * (not (-L[0] <= q[1] <= R[0]))\n if q[1] < R[0]:\n heappush(L, -q[1])\n heappush(R, -heappushpop(L, -q[1]))\n else:\n heappush(R, q[1])\n heappush(L, -heappushpop(R, Q[1]))\n else:\n print(-L[0], B+M)", "jacc_sim": 0.9795918367346939, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [281, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u197300773", "n_user": "u197300773", "pos": "import bisect\nimport heapq \n\nQ=int(input())\n\nque=list(map(int,input().split()))\nb=que[2]\nl,r=[-que[1]],[que[1]]\nheapq.heapify(l)\nheapq.heapify(r)\na=0\ntmp=que[1]\nj=1\nfor i in range(Q-1):\n que=list(map(int,input().split()))\n if que[0]==1:\n j+=1\n b+=que[2]\n q1=que[1]\n if j%2==0:\n if q1<-l[0]:\n heapq.heappushpop(l,-q1)\n else:\n heapq.heappushpop(r,q1)\n\n else:\n if q1<-l[0]:\n heapq.heappush(l,-q1)\n heapq.heappush(r,-l[0])\n else:\n heapq.heappush(r,q1)\n heapq.heappush(l,-r[0])\n \n\n if -l[0]!=r[0]: a+=abs(tmp-q1)\n else: a+=abs(tmp-q1)-abs(-l[0]-tmp)\n tmp=-l[0]\n\n elif que[0]==2:\n print(tmp,a+b)", "neg": "import bisect\nimport heapq\n\nQ=int(input())\n\nque=list(map(int,input().split()))\nb=que[2]\na=[que[1]]\nl,r=[-que[1]],[que[1]]\nmin=0\nj=1\ntmp=que[1]\nfor i in range(Q-1):\n que=list(map(int,input().split()))\n if que[0]==1:\n j+=1\n b+=que[2]\n tmp=-l[0]\n if j%2==0:\n if que[1]<=-l[0]:\n heapq.heappushpop(l,-que[1])\n else:\n heapq.heappushpop(l,que[1])\n\n else:\n if que[1]<=-l[0]:\n heapq.heappush(r, -heapq.heappushpop(l,-que[1]))\n else:\n heapq.heappush(l, -heapq.heappushpop(r,que[1]))\n \n if -l[0]!=r[0]: min+=abs(tmp-que[1])\n else: min+=abs(tmp-que[1])-abs(l[0]-tmp)\n tmp=-l[0]\n\n elif que[0]==2:\n print(tmp,min+b)", "jacc_sim": 0.9347826086956522, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [359, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u657913472", "n_user": "u657913472", "pos": "from heapq import*\nL,R=[],[]\nB=t=0\nQ,*E=open(0)\nfor e in E:\n\tif' 'in e:_,a,b=map(int,e.split());t=1-t;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c\n\telse:w=-L[0];print(w,B+w*t)", "neg": "from heapq import*\nL,R=[]*2\nB=t=0\nQ,*E=open(0)\nfor e in E:\n\tif' 'in e:_,a,b=map(int,e.split());t=1-t;a*=2*t-1;c=heappushpop([L,R][t],a);heappush([R,L][t],-c);B+=b+a-c-c\n\telse:print(-L[0],B-L[0]*t)", "jacc_sim": 0.9761904761904762, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [129, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u808427016", "n_user": "u222207357", "pos": "Q = int(input())\n\nfrom heapq import *\n\nlows = []\nhighs = []\n\na = []\nb = 0\nr = 0\n\nfor i in range(Q):\n vs = [int(_) for _ in input().split()]\n if vs[0] == 1:\n b += vs[2]\n if not lows:\n x = vs[1]\n heappush(lows, -x)\n else:\n r += abs(vs[1] + lows[0])\n if vs[1] <= -lows[0]:\n heappush(lows, -vs[1])\n else:\n heappush(highs, vs[1])\n\n if len(lows) < len(highs):\n x = heappop(highs)\n y = -lows[0]\n r += y - x\n heappush(lows, -x)\n elif len(lows) > len(highs) + 1:\n x = -heappop(lows)\n y = highs[0] if len(highs) else 0\n heappush(highs, x)\n # r += x - y\n\n # print(\"center\", -lows[0], r, lows, highs)\n\n else:\n print(-lows[0], r + b)\n", "neg": "from heapq import *\n\nQ = int(input())\n\nlows = []\nhighs = []\n\na = []\nb = 0\nr = 0\n\nfor i in range(Q):\n vs = [int(_) for _ in input().split()]\n if vs[0] == 1:\n b = +vs[2]\n if not lows:\n heappush(lows, -vs[1])\n else:\n r += abs(vs[1] + lows[0])\n if vs[1] <= -lows[0]:\n heappush(lows, -vs[1])\n else:\n heappush(highs, vs[1])\n \n if len(lows) < len(highs):\n x = heappop(highs)\n y = -lows[0]\n r += y - x\n heappush(lows, -x)\n \n elif len(lows) > len(highs) + 1:\n x = -heappush(lows)\n if len(highs):\n y = highs[0]\n else:\n y = 0\n heappush(highs,x)\n else:\n print(-lows[0], r+b)", "jacc_sim": 0.9375, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [333, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03040", "p_user": "u119714109", "n_user": "u119714109", "pos": "import sys\nimport heapq\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nq = ni()\n\nlh = []\nhh = []\nln = 0\nhn = 0\nls = 0\nhs = 0\noff = 0\nfor z in range(q):\n line = na()\n if line[0] == 1:\n _, a, b = line\n off += b\n\n if len(lh) > 0:\n mid = -lh[0]\n if a <= mid:\n heapq.heappush(lh, -a)\n ls += a\n ln += 1\n else:\n heapq.heappush(hh, a)\n hs += a\n hn += 1\n else:\n heapq.heappush(lh, -a)\n ls += a\n ln += 1\n\n while ln < hn:\n mx = heapq.heappop(hh)\n hs -= mx\n hn -= 1\n ls += mx\n ln += 1\n heapq.heappush(lh, -mx)\n\n while ln > hn + (ln+hn)%2:\n mx = -heapq.heappop(lh)\n ls -= mx\n ln -= 1\n heapq.heappush(hh, mx)\n hs += mx\n hn += 1\n else:\n lls = -lh[0]*ln - ls\n hhs = hs - (-lh[0]*hn)\n print(-lh[0], lls+hhs+off)", "neg": "import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nq = ni()\n\nlh = []\nhh = []\nln = 0\nhn = 0\nls = 0\nhs = 0\noff = 0\nfor z in range(q):\n line = na()\n if line[0] == 1:\n _, a, b = line\n off += b\n\n if len(lh) > 0:\n mid = -lh[0]\n if a <= mid:\n heapq.heappush(lh, -a)\n ls += a\n ln += 1\n else:\n heapq.heappush(hh, a)\n hs += a\n hn += 1\n else:\n heapq.heappush(lh, -a)\n ls += a\n ln += 1\n\n while ln < hn:\n mx = heapq.heappop(hh)\n hs -= mx\n hn -= 1\n ls += mx\n ln += 1\n heapq.heappush(lh, -mx)\n\n while ln > hn + (ln+hn)%2:\n mx = -heapq.heappop(lh)\n ls -= mx\n ln -= 1\n heapq.heappush(hh, mx)\n hs += mx\n hn += 1\n else:\n lls = -lh[0]*ln - ls\n hhs = hs - (-lh[0]*hn)\n print(-lh[0], lls+hhs+off)", "jacc_sim": 1.0, "nl": "You are given a function f(x), initially f(x) = 0. Process Q queries in order: update queries and evaluation queries. An update query 1 a b: g(x) = f(x) + |x - a| + b, replace f(x) with g(x). An evaluation query 2: Print x that minimizes f(x) and the minimum value of f(x). All input values are integers. 1 \u2264 Q \u2264 2 \u00d7 10^5, -10^9 \u2264 a, b \u2264 10^9. Input format: Q, Query_1, ..., Query_Q. Output: For each evaluation query, print the minimum value of x that minimizes f(x) and the minimum value of f(x).", "before_after_length": [422, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u662762430", "n_user": "u662762430", "pos": "def L():\n return list(map(int, input().split()))\n\n[N,K]=L()\n\n\nprint(N-K+1)\n", "neg": "[N,K]=L()\n\ndef L():\n return list(map(int, input().split()))\nprint(N-K+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [39, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n, k = LI()\n print(n-k+1)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n, k = LI()\n print(math.factorial(n) // math.factorial(k) // math.factorial(n - k))\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 0.9759036144578314, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [355, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u164474813", "n_user": "u164474813", "pos": "#n = int(input())\n#m = int(input())\n#k = int(input())\n#n, m = map(int, input().split())\nn, k = map(int, input().split())\n#a = list(map(int, input().split()))\n#table = []\n'''\nfor i in range h:\n temp = list(map(int, input().split()))\n table.append(temp)\n'''\nprint(n-k+1)", "neg": "n = int(input())\n#m = int(input())\nk = int(input())\n#n, m = map(int, input().split())\n#n, m, k = map(int, input().split())\n#a = list(map(int, input().split()))\n#table = []\n'''\nfor i in range h:\n temp = list(map(int, input().split()))\n table.append(temp)\n'''\nprint(n-k+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [114, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u766766413", "n_user": "u766766413", "pos": "list = [int(x) for x in input().split()]\nprint(list[0] - list[1] + 1)", "neg": "list = [int(x) for x in input().split()]\nprint(list[0] - list[1] + 1]", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [30, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u833997299", "n_user": "u833997299", "pos": "a,b = map(int, input().split())\nprint(\"{}\".format(a-b+1))", "neg": "a,b = map(int, input(),split())\nprint(\"{}\".format(a-b+1))", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [25, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u050698451", "n_user": "u646130340", "pos": "# N = int(input())\n\nN, K = map(int, input().split())\n\nans = N - (K - 1)\n\nprint (ans)\n", "neg": "N, K = map(int, input().split())\nans = K - (N - 1)\nprint(ans)", "jacc_sim": 0.9375, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [39, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u839953865", "n_user": "u839953865", "pos": "[a,b]=map(int,input().split())\nprint(a-b+1)", "neg": "[a,b]=map(int,input().split())\nprint(b-a+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [23, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u300532214", "n_user": "u025463382", "pos": "n,k=input().split()\n\nn = int(n)\nk = int(k)\n\nans = n - k + 1\nprint (ans)\n", "neg": "n , k = imap ( int , input ().split())\nans = n - k + 1\nprint ( ans)", "jacc_sim": 0.9375, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [38, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u251075661", "n_user": "u251075661", "pos": "N, K = [int(x) for x in input().split(' ')]\n\noutput = N - K + 1\n\nprint(int(output))", "neg": "N, K = [int(x) for x in input().split(' ')]\n\noutput = N - K + 1", "jacc_sim": 0.9523809523809523, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [35, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u779602548", "n_user": "u779602548", "pos": "#https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a\n# -*- coding: utf-8 -*-\n\nn,k = map(int,input().split())\n\nanswer = n-k+1\nif n < k :\n answer = 0\nprint( answer )", "neg": "#https://atcoder.jp/contests/diverta2019/tasks/diverta2019_a\n# -*- coding: utf-8 -*-\n\nn,k = map(int,input().split())\n\nanswer = n-k+1\nif n > k :\n answer = 0\nprint( answer )", "jacc_sim": 0.9411764705882353, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [78, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_ user": "u196697332", "n_user": "u196697332", "pos": "def combinations(N, K):\n N = int(N)\n K = int(K)\n if N == K:\n return 1\n else:\n return N - K + 1\n \nN, K = input().split(' ')\n\nprint(combinations(N, K))", "neg": "def combinations(N, K):\n N = int(N)\n K = int(K)\n elif N == K:\n return 1\n else:\n return N - K + 1\n \nN, K = input().split(' ')\n\nprint(combinations(N, K))", "jacc_sim": 0.9090909090909091, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [70, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u820839927", "n_user": "u820839927", "pos": "import os, sys, re, math\n\nn,k = input().split(' ')\nprint(int(n)-int(k)+1)\n", "neg": "import os, sys, re, math\n\nn,k = input().split(',')\nprint(int(n)-int(k)+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [33, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u450270991", "n_user": "u471642439", "pos": "a = input().split()\nprint(int(a[0])-int(a[1])+1)", "neg": "a =int(input().split())\n\nprint(a[0]-a[1]+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [25, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u503394633", "n_user": "u503394633", "pos": "nk = input()\n\nn = int(nk.split(' ')[0])\nk = int(nk.split(' ')[1])\n\nanswer = n - k + 1\nprint(answer)", "neg": "nk = input()\n\nn = nk.split(' ')[0]\nk = nk.split(' ')[1]\n\nanswer = n - k + 1\nprint(answer)", "jacc_sim": 0.9473684210526315, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [45, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u848654125", "n_user": "u848654125", "pos": "h = list(map(int, input().split()))\n\n\n\nprint(h[0]-h[1]+1)", "neg": "h = list(map(int, input().split()))\n\n\n\nprint(h[0]-h[1])", "jacc_sim": 0.9444444444444444, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u138013242", "n_user": "u155236040", "pos": "n, k=map(int, input().split())\nresult=n-(k-1)\nprint(result)\n", "neg": "n,k = map(int,input().split())\nprint(n-k-1)", "jacc_sim": 0.9333333333333333, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [28, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u960783046", "n_user": "u514299323", "pos": "N, K = map(int, input().split(\" \"))\n\nans = N - K + 1\n\n\nprint(ans)", "neg": "N,K = map(int,input().split())\nans = K-N+1\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [30, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u008134456", "n_user": "u528807020", "pos": "n, k = [ int(i) for i in input().split()]\n\nprint(n-k+1)\n", "neg": "n,k = [int() for i in input().split]\nprint(n-k+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [28, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u962197874", "n_user": "u664373116", "pos": "A,B = map(int,input().split())\nprint(A-B+1)", "neg": "A,B=map(int,input().map)\nprint(A-B+1)\n", "jacc_sim": 0.9333333333333333, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [21, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u548384403", "n_user": "u522726434", "pos": "N,K=[int(x) for x in input().split()]\nprint(N-K+1)", "neg": "N, K = [int(x) for x input().split()]\n\nprint(N - K + 1)", "jacc_sim": 0.9473684210526315, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [25, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u036493199", "n_user": "u094534632", "pos": "n, k = list(map(int, input().split(' ')))\nprint(n - k + 1)", "neg": "n, k = map(int, input().split(','))\nprint(n-k+1)", "jacc_sim": 0.9411764705882353, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [25, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u832039789", "n_user": "u702582248", "pos": "n,k = map(int,input().split())\nprint(n - (k - 1))\n", "neg": "n,k=map(int, input().split())\nprint(n-k)", "jacc_sim": 0.9285714285714286, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [23, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u949414593", "n_user": "u723554767", "pos": "n,k,=map(int,input().split())\nprint(n-k+1)", "neg": "n,k==map(int,input().split())\nprint(n-k+1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [22, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u303059352", "n_user": "u853900545", "pos": "a, b = list(map(int, input().split()))\nprint(a - b + 1)", "neg": "a,b = map(int(input().split()))\nprint(a-b+1)", "jacc_sim": 0.9375, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [24, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03047", "p_user": "u201234972", "n_user": "u792078574", "pos": "N, K = map( int, input().split())\nprint( N-K+1)\n", "neg": "N, K = map(int, input().split())\nprint(K - N + 1)", "jacc_sim": 1.0, "nl": "Snuke has N integers from 1 to N. He will choose K of them and give those to Takahashi. How many ways are there to choose K consecutive integers? \n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 K \u2264 N \u2264 50\n\nInput:\nInput is given from Standard Input in the following format:\nN K\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 2\n\nSample Output 1:\n2\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\nSample Input 2:\n13 3\n\nSample Output 2:\n11", "before_after_length": [22, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03051", "p_user": "u310678820", "n_user": "u310678820", "pos": "from collections import defaultdict\nfrom bisect import bisect_left as bisect\nimport sys\nmod = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\nzeros = []\ncount = defaultdict(list)\nnow = -1\nfor i in range(N):\n S[i] = S[i-1]^A[i]\n if S[i] == 0:\n zeros.append(i)\n else:\n count[S[i]].append(i)\nif S[N-1] != 0:\n a = S[N-1]\n res = []\n cnt = 0\n for i in count[a]:\n res.append(bisect(zeros, i)-cnt)\n cnt+=res[-1]\n res0 = 1\n res1 = 0\n for c in res:\n res0 = res0+res1*c\n res1 = res1+res0\n res0%=mod\n res1%=mod\n print(res0)\n sys.exit()\nans = pow(2, len(zeros)-1, mod)\nfor a in count.keys():\n cnt = 0\n res = []\n for i in count[a]:\n res.append(bisect(zeros, i)-cnt)\n cnt+=res[-1]\n res0 = 1\n res1 = 0\n for c in res:\n res0 = res0+res1*c\n res1 = res1+res0\n res0%=mod\n res1%=mod\n ans+=res1\n ans%=mod\nprint(ans) ", "neg": "from collections import defaultdict\nfrom bisect import bisect_left as bisect\nimport sys\nmod = 10**9+7\nN = int(input())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\nzeros = []\ncount = defaultdict(list)\nnow = -1\nfor i in range(N):\n S[i] = S[i-1]^A[i]\n if S[i] == 0:\n zeros.append(i)\n else:\n count[S[i]].append(i)\nif S[N-1] != 0:\n a = S[N-1]\n res = []\n for i in count[a]:\n res.append(bisect(zeros, i)-cnt)\n cnt+=res[-1]\n res0 = 1\n res1 = 0\n for c in res:\n res0 = res0+res1*c\n res1 = res1+res0\n res0%=mod\n res1%=mod\n print(res0)\n sys.exit()\nans = pow(2, len(zeros)-1, mod)\nfor a in count.keys():\n cnt = 0\n res = []\n for i in count[a]:\n res.append(bisect(zeros, i)-cnt)\n cnt+=res[-1]\n res0 = 1\n res1 = 0\n for c in res:\n res0 = res0+res1*c\n res1 = res1+res0\n res0%=mod\n res1%=mod\n ans+=res1\nprint(ans) ", "jacc_sim": 1.0, "nl": "The beauty of a sequence \"a\" of length \"n\" is defined as the bitwise exclusive or (XOR) of all its elements. Given a sequence \"A\" of length \"N\", we need to find the number of ways to divide \"A\" into subsequences such that the beauty of each subsequence is equal. The task is to calculate this count modulo 10^9+7. The input consists of the length \"N\" followed by the elements of sequence \"A\". The output should be the count of ways to divide \"A\" as per the given condition.", "before_after_length": [407, 396], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03051", "p_user": "u777923818", "n_user": "u777923818", "pos": "from collections import defaultdict\nfrom math import sqrt\ndef inpl(): return list(map(int, input().split()))\nMOD = 10**9 + 7\nN = int(input())\nS = []\n\nx = 0\nfor a in map(int, input().split()):\n x ^= a\n S.append(x)\n\nA = defaultdict(int)\nB = defaultdict(int)\nL = defaultdict(int)\nZ = 0\n\nif S[-1] != 0:\n sr = S[-1]\n a, b = 0, 0\n for s in S:\n if s == sr:\n b = (b + a + 1)%MOD\n elif s == 0:\n a = (a + b)%MOD\n print(a+1)\nelse:\n for s in S:\n if s == 0:\n Z += 1\n else:\n A[s] = (A[s] + (Z - L[s])*B[s])%MOD\n B[s] = (A[s] + B[s] + 1)%MOD\n L[s] = Z\n print((sum(B.values()) + pow(2, Z-1, MOD))%MOD)", "neg": "from collections import defaultdict\nfrom math import sqrt\ndef inpl(): return list(map(int, input().split()))\nMOD = 10**9 + 7\nN = int(input())\nS = []\n\nx = 0\nfor a in map(int, input().split()):\n x ^= a\n S.append(x)\n\nA = defaultdict(int)\nB = defaultdict(int)\nL = defaultdict(int)\nZ = 0\n\nif S[-1] != 0:\n sr = S[-1]\n a, b = 0, 0\n for s in S:\n if s == sr:\n b = (b + a + 1)%MOD\n elif s == 0:\n a = (a + b)%MOD\n print(b)\nelse:\n for s in S:\n if s == 0:\n Z += 1\n else:\n A[s] = (A[s] + (Z - L[s])*B[s])%MOD\n B[s] = (A[s] + B[s] + 1)%MOD\n L[s] = Z\n print((sum(B.values()) + pow(2, Z-1, MOD))%MOD)", "jacc_sim": 1.0, "nl": "The beauty of a sequence \"a\" of length \"n\" is defined as the bitwise exclusive or (XOR) of all its elements. Given a sequence \"A\" of length \"N\", we need to find the number of ways to divide \"A\" into subsequences such that the beauty of each subsequence is equal. The task is to calculate this count modulo 10^9+7. The input consists of the length \"N\" followed by the elements of sequence \"A\". The output should be the count of ways to divide \"A\" as per the given condition.", "before_after_length": [290, 288], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03051", "p_user": "u104282757", "n_user": "u104282757", "pos": "N = int(input())\na_list = list(map(int, input().split()))\nLARGE = 10**9 + 7\n\n\n# cumsum\nb_list = [0] * N\nb = 0\n\nfor i in range(N):\n a = a_list[i]\n b = a ^ b\n b_list[i] = b\n\nv_all_dict = dict()\nfor b in b_list:\n v_all_dict[b] = [0, 0, 1]\n\nzeros = 0\n\n\n\nfor i in range(N):\n\n b = b_list[i]\n\n t = v_all_dict[b][0]\n\n # new b\n if t < zeros:\n v_all_dict[b][2] = (v_all_dict[b][2] + v_all_dict[b][1] * (zeros - t)) % LARGE\n v_all_dict[b][0] = zeros\n\n # up\n v_all_dict[b][1] = (v_all_dict[b][1] + v_all_dict[b][2]) % LARGE\n\n # zeros\n if b == 0:\n zeros += 1\n\n# res\nif b_list[-1] == 0:\n res = 0\n for v in v_all_dict.keys():\n if v != 0:\n res = (res + v_all_dict[v][1]) % LARGE\n else:\n res = (res + 2 ** (zeros - 1) - 1) % LARGE\n res += 1\n\nelse:\n v = b_list[-1]\n res = v_all_dict[v][2]\n\nprint(res % LARGE)\n", "neg": "N = int(input())\na_list = list(map(int, input().split()))\nLARGE = 10**9 + 7\n\n\n# cumsum\nb_list = [0] * N\nb = 0\n\nfor i in range(N):\n a = a_list[i]\n b = a ^ b\n b_list[i] = b\n\nv_all_dict = dict()\nfor b in b_list:\n v_all_dict[b] = [0, 0, 1]\n\nzeros = 0\n\nfor i in range(N):\n b = b_list[i]\n \n t = v_all_dict[b][0]\n \n # new b\n if t < zeros:\n v_all_dict[b][2] = (v_all_dict[b][2] + v_all_dict[b][1] * (zeros - t)) % LARGE\n v_all_dict[b][0] = zeros\n \n # up\n v_all_dict[b][1] = (v_all_dict[b][1] + v_all_dict[b][2]) % LARGE\n \n # zeros\n if b == 0:\n zeros += 1\n \nif b_list[-1] == 0:\n res = 0\n for v in v_all_dict.keys():\n if v != 0:\n res = (res + v_all_dict[v][1]) % LARGE\n else:\n res = (res + 2 ** (zeros - 1) - 1) % LARGE\n res += 1\nelse:\n print(1)\n", "jacc_sim": 1.0, "nl": "The beauty of a sequence \"a\" of length \"n\" is defined as the bitwise exclusive or (XOR) of all its elements. Given a sequence \"A\" of length \"N\", we need to find the number of ways to divide \"A\" into subsequences such that the beauty of each subsequence is equal. The task is to calculate this count modulo 10^9+7. The input consists of the length \"N\" followed by the elements of sequence \"A\". The output should be the count of ways to divide \"A\" as per the given condition.", "before_after_length": [422, 393], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u612975321", "n_user": "u612975321", "pos": "import numpy as np\n\nh , w = map(int, input().split())\nvisited = np.zeros((h,w),dtype=int)\n\nfor y in range(h):\n _in = input()\n for x, value in enumerate(_in):\n if value == '.':\n visited[y][x] = 10**9\n \nfor i in range(1,h):\n visited[i,:] = np.minimum(visited[i,:],visited[i-1,:]+1)\nfor i in reversed(range(h-1)):\n visited[i,:] = np.minimum(visited[i,:],visited[i+1,:]+1)\nfor j in range(1,w):\n visited[:,j] = np.minimum(visited[:,j],visited[:,j-1]+1)\nfor j in reversed(range(w-1)):\n visited[:,j] = np.minimum(visited[:,j],visited[:,j+1]+1)\nprint(np.max(visited))", "neg": "import numpy as np\n\nh , w = map(int, input().split())\nvisited = np.zeros((h,w))\n\nfor y in range(h):\n _in = input()\n for x, value in enumerate(_in):\n if value == '.':\n visited[y][x] = 10**9\nfor i in range(1,h):\n visited[i,:] = np.minimum(visited[i,:],visited[i-1,:]+1)\nfor i in reversed(range(h-1)):\n visited[i,:] = np.minimum(visited[i,:],visited[i+1,:]+1)\nfor j in range(1,h):\n visited[:,j] = np.minimum(visited[:,j],visited[:,j-1]+1)\nfor j in reversed(range(h-1)):\n visited[:,j] = np.minimum(visited[:,j],visited[:,j+1]+1)\nprint(np.max(visited))", "jacc_sim": 0.9767441860465116, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [244, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u612975321", "n_user": "u612975321", "pos": "import numpy as np\n\nH,W = map(int,input().split())\nuse = np.zeros((H,W),dtype=int)\nfor i in range(H):\n s = input()\n for j,st in enumerate(s):\n if st == \".\":\n use[i][j] = 10**10\n else:\n use[i][j] = 0\n\nfor i in range(1,H):\n use[i,:] = np.minimum(use[i,:],use[i-1,:]+1)\nfor i in reversed(range(H-1)):\n use[i,:] = np.minimum(use[i,:],use[i+1,:]+1)\nfor j in range(1,W):\n use[:,j] = np.minimum(use[:,j],use[:,j-1]+1)\nfor j in reversed(range(W-1)):\n use[:,j] = np.minimum(use[:,j],use[:,j+1]+1)\n\nprint(np.max(use))", "neg": "import numpy as np\n\nH,W = map(int,input().split())\nuse = np.zeros((H,W),dtype=int)\nfor i in range(H):\n s = input()\n for j,st in enumerate(s):\n if st == \".\":\n use[i][j] = 10**9\n else:\n\nfor i in range(1,H):\n use[i,:] = np.minimum(use[i,:],use[i-1,:]+1)\nfor i in reversed(range(H-1)):\n use[i,:] = np.minimum(use[i,:],use[i+1,:]+1)\nfor j in range(1,W):\n use[:,j] = np.minimum(use[:,j],use[:,j-1]+1)\nfor j in reversed(range(W-1)):\n use[:,j] = np.minimum(use[:,j],use[:,j+1]+1)\n\nprint(np.max(use))", "jacc_sim": 0.9534883720930233, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [256, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u591143370", "n_user": "u591143370", "pos": "from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nH ,W = map(int, input().split())#\u2193H\u884c\u6570 \u2192W\u5217\u6570\nList = [list(str(input())) for i in range(H)]\n#H=3\n#W=3\n#List=[['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.']]\ncheak=[['0' for i in range(W)] for j in range(H)]\n\nq = deque([])\n\nfor h in range(H):\n for w in range(W):\n if List[h][w]=='#':\n cheak[h][w]='1'\n q.append([h,w])\n#print(List)\n#print(cheak)\nmove=[[1,0],[-1,0],[0,1],[0,-1]]\nnum=-1\n#print(q)\nwhile q:\n for rt in range(len(q)):\n i=q.popleft()\n for u in move:\n if 0<=i[0]+u[0]<=H-1 and 0<=i[1]+u[1]<=W-1 and cheak[i[0]+u[0]][i[1]+u[1]]=='0':\n q.append([i[0]+u[0],i[1]+u[1]])\n cheak[i[0]+u[0]][i[1]+u[1]]='1'\n #print(cheak)\n num+=1\nprint(num) ", "neg": "from collections import deque\nH ,W = map(int, input().split())#\u2193H\u884c\u6570 \u2192W\u5217\u6570\nList = [list(str(input())) for i in range(H)]\n#H=3\n#W=3\n#List=[['.', '.', '.'], ['.', '#', '.'], ['.', '.', '.']]\ncheak=[['0' for i in range(W)] for j in range(H)]\n\nq = deque([])\n\nfor h in range(H):\n for w in range(W):\n if List[h][w]=='#':\n cheak[h][w]='1'\n q.append([h,w])\n#print(List)\n#print(cheak)\nmove=[[1,0],[-1,0],[0,1],[0,-1]]\nnum=-1\n#print(q)\nwhile q:\n for rt in range(len(q)):\n i=q.popleft()\n for u in move:\n if 0<=i[0]+u[0]<=H-1 and 0<=i[1]+u[1]<=W-1 and cheak[i[0]+u[0]][i[1]+u[1]]=='0':\n q.append([i[0]+u[0],i[1]+u[1]])\n cheak[i[0]+u[0]][i[1]+u[1]]='1'\n #print(cheak)\n num+=1\nprint(num) \n", "jacc_sim": 0.9473684210526315, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [392, 380], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u824237520", "n_user": "u824237520", "pos": "h, w = map(int, input().split())\na = [['*' for _ in range(w+2)]]\nfor _ in range(h):\n a.append(['*'] + list(input()) + ['*'])\na.append(['*' for _ in range(w+2)])\n\nq = set()\n\ndef encode(i, j):\n return i*w + j-1\n\ndef decode(x):\n i = x // w\n j = x % w + 1\n return [i, j]\n\nfor i in range(1, h+1):\n for j in range(1, w+1):\n if a[i][j] == '#':\n q.add(encode(i, j))\n\nfor ans in range(h+w):\n nq = set()\n for x in q:\n i, j = decode(x)\n for k in [-1,1]:\n if a[i+k][j] == '.':\n nq.add(encode(i+k, j))\n a[i+k][j] = '#'\n for k in [-1,1]:\n if a[i][j+k] == '.':\n nq.add(encode(i, j+k))\n a[i][j+k] = '#'\n if len(nq) == 0:\n print(ans)\n exit()\n else:\n q = set()\n q = q | nq\n", "neg": "h, w = map(int, input().split())\na = [['*' for _ in range(w+2)]]\nfor _ in range(h):\n a.append(['*'] + list(input()) + ['*'])\na.append(['*' for _ in range(w+2)])\n\nq = set()\n\ndef encode(i, j):\n return (i+1)*w + j\n\ndef decode(x):\n i = x // w - 1\n j = x % w\n return [i, j]\n\nfor i in range(1, h+1):\n for j in range(1, w+1):\n if a[i][j] == '#':\n q.add(encode(i, j))\n\nfor ans in range(h+w):\n nq = set()\n for x in q:\n i, j = decode(x)\n if a[i][j] == '#':\n for k in [-1,1]:\n if a[i+k][j] == '.':\n nq.add(encode(i+k, j))\n a[i+k][j] = '#'\n for k in [-1,1]:\n if a[i][j+k] == '.':\n nq.add(encode(i, j+k))\n a[i][j+k] = '#'\n if len(nq) == 0:\n print(ans)\n exit()\n else:\n q = set()\n q = q | nq\n", "jacc_sim": 1.0, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [354, 367], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u405660020", "n_user": "u405660020", "pos": "from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nh, w = map(int, input().split())\na = [list(input()) for _ in range(h)]\ndist = [[-1]*w for _ in range(h)] # \u9ed2\u306a\u3089dist[i][j]\u306f0\u3001\u767d\u306a\u3089-1\n\nblack_cells = deque()\n\nfor i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n black_cells.append((i, j))\n dist[i][j] = 0\n\ndef bfs(black_cells, dist):\n d = 0\n while black_cells:\n h_black, w_black = black_cells.popleft()\n d=dist[h_black][w_black]\n for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):\n new_h = h_black+dy\n new_w = w_black+dx\n if new_h < 0 or h <= new_h or new_w < 0 or w <= new_w:\n continue\n if dist[new_h][new_w] == -1:\n dist[new_h][new_w] = d+1\n black_cells.append((new_h, new_w))\n return d\n\nd = bfs(black_cells, dist)\nprint(d)\n", "neg": "from collections import deque\n\nh, w = map(int, input().split())\na = [list(input()) for _ in range(h)]\nprint(a)\ndist = [[-1]*w for _ in range(h)] # \u9ed2\u306a\u3089dist[i][j]\u306f0\u3001\u767d\u306a\u3089-1\n\nblack_cells = deque()\n\nfor i in range(h):\n for j in range(w):\n if a[i][j] == '#':\n black_cells.append([i, j])\n dist[i][j] = 0\n\ndef bfs(black_cells, dist):\n d = 0\n while black_cells:\n print(dist)\n h_black, w_black = black_cells.popleft()\n d=dist[h_black][w_black]\n for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):\n new_h = h_black+dy\n new_w = w_black+dx\n if new_h < 0 or h <= new_h or new_w < 0 or w <= new_w:\n continue\n if dist[new_h][new_w] == -1:\n dist[new_h][new_w] = d+1\n black_cells.append([new_h, new_w])\n return max(sum(dist,[]))\n\nd = bfs(black_cells, dist)\nprint(d)\n", "jacc_sim": 0.921875, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [364, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u340781749", "n_user": "u340781749", "pos": "from collections import deque\n\nh, w = list(map(int, input().split()))\nf = []\nq = deque()\nfor i in range(h):\n l = input()\n for j, c in enumerate(l):\n if c == '#':\n q.append((0, i, j))\n f.append(l)\n\nvisited = [[False] * w for _ in [0] * h]\nfor d, i, j in q:\n visited[i][j] = True\n\nans = 0\nmove = [(0, 1), (0, -1), (1, 0), (-1, 0)]\n\nwhile q:\n d, i, j = q.popleft()\n ans = d\n for di, dj in move:\n ni, nj = i + di, j + dj\n if ni < 0 or h <= ni or nj < 0 or w <= nj:\n continue\n if visited[ni][nj]:\n continue\n visited[ni][nj] = True\n q.append((d + 1, ni, nj))\n\nprint(ans)\n", "neg": "from collections import deque\n\nh, w = list(map(int, input().split()))\nf = []\nq = deque()\nfor i in range(h):\n l = input()\n for j, c in enumerate(l):\n if c == '#':\n q.append((0, i, j))\n f.append(l)\n\nvisited = [[False] * w for _ in [0] * h]\nfor d, i, j in q:\n visited[i][j] = True\n\nans = 0\nmove = [(0, 1), (0, -1), (1, 0), (-1, 0)]\n\nwhile q:\n d, i, j = q.popleft()\n ans = d\n for di, dj in move:\n ni, nj = i + di, j + dj\n if ni < 0 or h <= ni or nj < 0 or w <= nj:\n continue\n if visited[ni][nj]:\n continue\n visited[i][j] = True\n q.append((d + 1, ni, nj))\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [266, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u398846051", "n_user": "u398846051", "pos": "from collections import deque\n\nH, W = map(int, input().split())\ngrid = [input() for _ in range(H)]\n\ndxdy = [(-1,0), (1,0), (0,-1), (0,1)]\nINF = 999999\nque = deque()\n\ndist = [[INF] * W for _ in range(H)]\nfor i, row in enumerate(grid):\n for j, s in enumerate(row):\n if s == \"#\":\n dist[i][j] = 0\n que.append(i*W + j)\n\nans = 0\nwhile len(que) > 0:\n num = que.popleft()\n h = num // W\n w = num % W\n for dx, dy in dxdy:\n nx = w + dx\n ny = h + dy\n if ny<0 or ny>=H or nx<0 or nx>=W:\n continue\n if dist[ny][nx] == INF:\n que.append(ny * W + nx)\n dist[ny][nx] = min(dist[ny][nx], dist[h][w]+1)\n ans = max(ans, dist[ny][nx])\n\nprint(ans)", "neg": "from collections import deque\n\nH, W = map(int, input().split())\ngrid = [input() for _ in range(H)]\n\ndxdy = [(-1,0), (1,0), (0,-1), (0,1)]\nINF = 999999\nque = deque()\n\ndist = [[INF] * W for _ in range(H)]\nfor i in range(H):\n for j in range(W):\n if grid[i][j] == \"#\":\n dist[i][j] = 0\n que.append((i,j))\n\nans = 0\nwhile len(que) > 0:\n h, w = que.popleft()\n for dx, dy in dxdy:\n nx = w + dx\n ny = h + dy\n if ny<0 or ny>=H or nx<0 or nx>=W or dist[ny][nx] < INF:\n continue\n dist[ny][nx] = min(dist[ny][nx], dist[h][w]+1)\n ans = max(ans, dist[ny][nx])\n que.append((ny,nx))\n\nprint(ans)", "jacc_sim": 0.9032258064516129, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [289, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u371942102", "n_user": "u371942102", "pos": "import array\nimport itertools\nfrom collections import defaultdict, deque\n\n\ndef log(s):\n # print(\"| \" + str(s), file=sys.stderr)\n pass\n\n\ndef output(x):\n print(x, flush=True)\n\n\ndef input_ints():\n return map(int, input().split())\n\n\ndef solve():\n def fill(queue):\n footsteps = [[None] * width for _ in range(height)]\n\n for x, y in queue:\n footsteps[y][x] = 0\n\n s = 0\n while queue:\n queue2 = deque()\n s += 1\n while queue:\n x, y = queue.popleft()\n\n if x > 0 and footsteps[y][x - 1] is None:\n queue2.append((x - 1, y))\n footsteps[y][x - 1] = s\n if x < width - 1 and footsteps[y][x + 1] is None:\n queue2.append((x + 1, y))\n footsteps[y][x + 1] = s\n if y > 0 and footsteps[y - 1][x] is None:\n queue2.append((x, y - 1))\n footsteps[y - 1][x] = s\n if y < height - 1 and footsteps[y + 1][x] is None:\n queue2.append((x, y + 1))\n footsteps[y + 1][x] = s\n\n queue = queue2\n\n return s - 1\n\n height, width = tuple(input_ints())\n field = [input() for _ in range(height)]\n queue = deque()\n\n for y, line in enumerate(field):\n for x, c in enumerate(line):\n if c == '#':\n queue.append((x, y))\n # queue.append((10, 10))\n\n\n return fill(queue)\n\n\ndef main():\n print(solve())\n\n\nmain()\n", "neg": "import array\nimport itertools\nfrom collections import defaultdict, deque\n\n\ndef log(s):\n # print(\"| \" + str(s), file=sys.stderr)\n pass\n\n\ndef output(x):\n print(x, flush=True)\n\n\ndef input_ints():\n return map(int, input().split())\n\n\ndef solve():\n def fill(queue):\n footsteps = [[None] * width for _ in range(height)]\n for p, s in queue:\n footsteps[p[1]][p[0]] = -1\n\n while queue:\n p, s = queue.popleft()\n x, y = p\n footsteps[y][x] = s\n\n if x > 0 and footsteps[y][x - 1] is None:\n queue.append(((x - 1, y), s + 1))\n footsteps[y][x - 1] = -1\n if x < width - 1 and footsteps[y][x + 1] is None:\n queue.append(((x + 1, y), s + 1))\n footsteps[y][x + 1] = -1\n if y > 0 and footsteps[y - 1][x] is None:\n queue.append(((x, y - 1), s + 1))\n footsteps[y - 1][x] = -1\n if y < height - 1 and footsteps[y + 1][x] is None:\n queue.append(((x, y + 1), s + 1))\n footsteps[y + 1][x] = -1\n\n return s\n\n height, width = tuple(input_ints())\n # field = [input() for _ in range(height)]\n queue = deque()\n\n # for y, line in enumerate(field):\n # for x, c in enumerate(line):\n # if c == '#':\n # queue.append(((x, y), 0))\n queue.append(((10, 10), 0))\n\n return fill(queue)\n\n\ndef main():\n print(solve())\n\n\nmain()\n", "jacc_sim": 0.971830985915493, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [478, 502], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u830054172", "n_user": "u830054172", "pos": "from collections import deque\n\nH, W = map(int, input().split())\n\ngrid = [[-1]*W for _ in range(H)]\n\nqueue = deque([])\n\nans = 0\n\n# while True:\n# f = 0\nfor i in range(H):\n s = input()\n for j, ss in enumerate(s):\n if ss ==\"#\":\n queue.append((i, j))\n grid[i][j] = 0\n\n#\u9ed2\u70b9\u3092\u30b9\u30bf\u30fc\u30c8\u5730\u70b9\u3068\u3057\u3001\u4e0a\u4e0b\u5de6\u53f3\u306b\u79fb\u52d5\u3057\u305f\u6642\u306e\u79fb\u52d5\u8ddd\u96e2\u3092\u8a18\u9332\u3057\u3066\u3044\u304f\nwhile queue:\n h, w = queue.popleft()\n for i in [h-1, h+1]:\n if i >= 0 and i < H:\n if grid[i][w] == -1:\n grid[i][w] = grid[h][w]+1\n queue.append((i, w))\n for j in [w-1, w+1]:\n if j >= 0 and j < W:\n if grid[h][j] == -1:\n grid[h][j] = grid[h][w]+1\n queue.append((h, j))\n\n# print(grid)\nprint(max([max(b) for b in grid]))\n", "neg": "from collections import deque\n\nH, W = map(int, input().split())\n\ngrid = [[-1]*W for _ in range(H)]]\n\nqueue = deque([])\n\nans = 0\n\n# while True:\n# f = 0\nfor i in range(H):\n s = input()\n for j, ss in enumerate(s):\n if ss = =\"#\":\n queue.append((i, j))\n grid[i][j] = 0\n\n#\u9ed2\u70b9\u3092\u30b9\u30bf\u30fc\u30c8\u5730\u70b9\u3068\u3057\u3001\u4e0a\u4e0b\u5de6\u53f3\u306b\u79fb\u52d5\u3057\u305f\u6642\u306e\u79fb\u52d5\u8ddd\u96e2\u3092\u8a18\u9332\u3057\u3066\u3044\u304f\nwhile queue:\n h, w = queue.popleft()\n for i in [h-1, h+1]:\n if i >= 0 and i < H:\n if grid[i][w] == -1:\n grid[i][w] = grid[h][w]+1\n for j in [w-1, w+1]:\n if j >= 0 and j < W:\n if grid[h][j] == -1:\n grid[h][j] = grid[h][w]+1\n\nprint(max(max[(b) for b in grid]))\n", "jacc_sim": 1.0, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [381, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u562935282", "n_user": "u562935282", "pos": "import sys\n\ninput = sys.stdin.readline\n\nfrom collections import deque\n\nH, W = map(int, input().split())\na = [input() for _ in range(H)]\n\ndist = [[-1] * W for _ in range(H)]\ndq = deque()\n\nfor r in range(H):\n for c in range(W):\n if a[r][c] == '#':\n dist[r][c] = 0\n dq.append((r, c))\n\n\ndef in_range(r, c):\n return 0 <= r < H and 0 <= c < W\n\n\ndr_s = (0, 0, -1, 1)\ndc_s = (-1, 1, 0, 0)\n\nd = 0\nwhile dq:\n r, c = dq.popleft()\n d = dist[r][c]\n for dr, dc in zip(dr_s, dc_s):\n nr = r + dr\n nc = c + dc\n if not in_range(nr, nc): continue\n if dist[nr][nc] != -1: continue\n dist[nr][nc] = d + 1\n dq.append((nr, nc))\n\nprint(d)\n", "neg": "from collections import deque\nimport sys\n\ninput = sys.stdin.readline\n\nH, W = map(int, input().split())\na = [input() for _ in range(H)]\n\ndist = [[-1] * W for _ in range(H)]\ndq = deque((r, c) for r in range(H) for c in range(W) if a[r][c] == '#')\n\n\ndef out_of_range(r, c):\n return not (0 <= r < H and 0 <= c < W)\n\n\ndr_s = (0, 0, -1, 1)\ndc_s = (-1, 1, 0, 0)\n\nd = 0\nwhile dq:\n r, c = dq.popleft()\n d = dist[r][c]\n for dr, dc in zip(dr_s, dc_s):\n nr = r + dr\n nc = c + dc\n if out_of_range(nr, nc): continue\n if dist[nr][nc] != -1: continue\n dist[nr][nc] = d + 1\n dq.append((nr, nc))\n\nprint(d)\n", "jacc_sim": 0.9661016949152542, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [292, 275], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u346395915", "n_user": "u346395915", "pos": "from collections import deque\n\nh,w = map(int,input().split())\nmatrix = [[\"a\" for _ in range(w+2)]] + [list(\"a\" + input() + \"a\") for _ in range(h)] + [[\"a\" for _ in range(w+2)]]\n\nmatrix_list1 = deque()\ncnt = 0\n\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if matrix[i][j] == \"#\":\n matrix_list1.append([i,j])\n\nwhile len(matrix_list1) != 0: \n for _ in range(len(matrix_list1)):\n x,y = matrix_list1.popleft()\n if matrix[x+1][y] == \".\":\n matrix[x+1][y] = \"#\"\n matrix_list1.append([x+1,y])\n if matrix[x-1][y] == \".\":\n matrix[x-1][y] = \"#\"\n matrix_list1.append([x-1,y])\n if matrix[x][y+1] == \".\":\n matrix[x][y+1] = \"#\"\n matrix_list1.append([x,y+1])\n if matrix[x][y-1] == \".\":\n matrix[x][y-1] = \"#\"\n matrix_list1.append([x,y-1])\n else:\n if len(matrix_list1) > 0:\n cnt += 1\n \nprint(cnt)", "neg": "from collections import deque\n\nh,w = map(int,input().split())\nmatrix = [[1]*(w+2)] + [list(\"a\" + input() + \"a\") for _ in range(h)] + [[1]*(w+2)]\n\nmatrix_list1 = deque()\ncnt = -1\n\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if matrix[i][j] == \"#\":\n matrix[i][j] = 1\n matrix_list1.append([i,j])\n else:\n matrix[i][j] = 0\n\nwhile len(matrix_list1) != 0: \n for _ in range(len(matrix_list1)):\n x,y = matrix_list1.popleft()\n if not matrix[x+1][y]:\n matrix[x+1][y] = 1\n matrix_list1.append([x+1,y])\n if not matrix[x-1][y]:\n matrix[x-1][y] = 1\n matrix_list1.append([x-1,y])\n if not matrix[x][y+1]:\n matrix[x][y+1] = 1\n matrix_list1.append([x,y+1])\n if not matrix[x][y-1]:\n matrix[x][y-1] = 1\n matrix_list1.append([x,y-1])\n cnt += 1\n \nprint(cnt)", "jacc_sim": 0.9387755102040817, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [370, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u357949405", "n_user": "u357949405", "pos": "import sys\nfrom collections import deque\ninput = sys.stdin.readline\n\nH, W = map(int, input().split())\n\nm = [list(map(lambda x: 1 if x==\"#\" else 0, input())) for _ in range(H)]\nblack = [(i, j, 0) for i in range(H) for j in range(W) if m[i][j] == 1]\n\n# print(m)\n# print(black)\n\nqueue = deque(black)\nqueue_append = queue.append\nans = 0\nwhile queue:\n p = queue.popleft()\n if ans < p[2]:\n ans += 1\n for i, j in ((-1, 0), (1, 0), (0, 1), (0, -1)):\n next_p = (p[0] + i, p[1] + j)\n if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):\n if not m[next_p[0]][next_p[1]]:\n m[next_p[0]][next_p[1]] = 1\n queue_append((next_p[0], next_p[1], ans+1))\nprint(ans)\n", "neg": "import sys\nfrom collections import deque\ninput = sys.stdin.readline\n\nm = [list(map(lambda x: 1 if x==\"#\" else 0, input())) for _ in range(H)]\nblack = [(i, j, 0) for i in range(H) for j in range(W) if m[i][j] == 1]\n\n# print(m)\n# print(black)\n\nqueue = deque(black)\nqueue_append = queue.append\nans = 0\nwhile queue:\n p = queue.popleft()\n if ans < p[2]:\n ans += 1\n for i, j in ((-1, 0), (1, 0), (0, 1), (0, -1)):\n next_p = (p[0] + i, p[1] + j)\n if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):\n if not m[next_p[0]][next_p[1]]:\n m[next_p[0]][next_p[1]] = 1\n queue_append((next_p[0], next_p[1], ans+1))\nprint(ans)\n", "jacc_sim": 0.9622641509433962, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [301, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u794173881", "n_user": "u794173881", "pos": "import sys\nfrom collections import deque\n\n\ninput = sys.stdin.readline\nh, w = map(int, input().split())\na = [input() for i in range(h)]\n\nvisited = [[False]*w for i in range(h)]\nq = deque([])\nfor i in range(h):\n for j in range(w):\n if a[i][j] == \"#\":\n q.append((i, j, 0))\n visited[i][j] = True\nans = 0\nwhile q:\n i, j, times = q.popleft()\n ans = max(times, ans)\n for next_i, next_j in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:\n if 0 <= next_i < h and 0 <= next_j < w and not visited[next_i][next_j]:\n visited[next_i][next_j] = True\n q.append((next_i, next_j, times + 1))\nprint(ans)", "neg": "from collections import deque\n\n\nh, w = map(int, input().split())\na = [input() for i in range(h)]\n\nvisited = [[False]*w for i in range(h)]\nq = deque([])\nfor i in range(h):\n for j in range(w):\n if a[i][j] == \"#\":\n q.append((i, j, 0))\n visited[i][j] = True\nans = 0\nwhile q:\n i, j, times = q.popleft()\n ans = max(times, ans)\n\n for next_i, next_j in [(i+1, j), (i-1, j), (i, j+1), (i, j-1)]:\n if 0 <= next_i < h and 0 <= next_j < w and not visited[next_i][next_j]:\n visited[i][j] = True\n q.append((next_i, next_j, times + 1))\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [255, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u733866054", "n_user": "u733866054", "pos": "from collections import deque\nimport sys\ninput=sys.stdin.readline\n\n\n#-------------------------------------------------------------------------\n#\u767d\u304b\u3089\u9ed2\u306b\u5909\u3048\u3066\u3044\u304f\n\ndef search() :\n H,W=map(int,input().split())\n pos=deque([])\n\n D= [[True]*(W+2)] #True True True True\n D+=[[True]+[False]*W+[True] for i in range(H)] #True FalseFalseTrue\n D.append([True]*(W+2)) #True True True True\n\n for i in range(H) :\n maze=input()\n for j in range(W) :\n if maze[j]==\"#\" :\n pos.append([i+1,j+1,0])\n D[i+1][j+1]=True\n \n while len(pos)>0 : #for\u3067\u306f\u306a\u304f\u5404if\u69cb\u6587\u3060\u3068\u901a\u3063\u305f\u2026\n h,w,depth=pos.popleft()\n if not D[h+1][w] :\n pos.append([h+1,w,depth+1])\n D[h+1][w]=True\n\n if not D[h-1][w] :\n pos.append([h-1,w,depth+1])\n D[h-1][w]=True\n\n if not D[h][w+1] :\n pos.append([h,w+1,depth+1])\n D[h][w+1]=True\n\n if not D[h][w-1] :\n pos.append([h,w-1,depth+1])\n D[h][w-1]=True\n\n return depth \n\nprint(search())\n", "neg": "from collections import deque\nimport sys\n#input=sys.stdin.readline\nH,W=map(int,input().split())\nmaze=[list(input()) for i in range(H)]\n\n#-------------------------------------------------------------------------\n#\u767d\u304b\u3089\u9ed2\u306b\u5909\u3048\u3066\u3044\u304f\n\ndef search() :\n \n pos=deque([])\n\n D= [[True]*(W+2)] #True True True True\n D+=[[True]+[False]*W+[True] for i in range(H)] #True FalseFalseTrue\n D.append([True]*(W+2)) #True True True True\n\n for i in range(H) :\n for j in range(W) :\n if maze[i][j]==\"#\" :\n pos.append([i+1,j+1,0])\n D[i+1][j+1]=True\n \n while len(pos)>0 : #for\u3067\u306f\u306a\u304f\u5404if\u69cb\u6587\u3060\u3068\u901a\u3063\u305f\u2026\n h,w,depth=pos.popleft()\n if not D[h+1][w] :\n pos.append([h+1,w,depth+1])\n D[h+1][w]=True\n\n if not D[h-1][w] :\n pos.append([h-1,w,depth+1])\n D[h-1][w]=True\n\n if not D[h][w+1] :\n pos.append([h,w+1,depth+1])\n D[h][w+1]=True\n\n if not D[h][w-1] :\n pos.append([h,w-1,depth+1])\n D[h][w-1]=True\n\n return depth \n\nprint(search())\n", "jacc_sim": 0.9868421052631579, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [467, 478], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u905329882", "n_user": "u905329882", "pos": "import sys\ninput = sys.stdin.readline\nH, W = map(int, input().split())\nmap = [list(input()) for _ in range(H)]\nfrom collections import deque\n\nque = deque()\nseen = [[-1]*W for _ in range(H)]\nmax = 0\n\n\n\nfor i in range(H):\n for j in range(W):\n if map[i][j] == \"#\":\n que.append([i,j])\n seen[i][j] = 0\n\nwhile que:\n #print(que)\n y, x = que.popleft()\n for dy, dx in ([0,1],[0,-1],[1,0],[-1,0]):\n ny = y + dy\n nx = x + dx\n if 0<=ny -1:\n continue\n dist[w] = d + 1\n que.append(w)\n\nans = max(dist)\nprint(ans)\n", "neg": "from collections import deque\nr, c = list(map(int, input().split()))\nsy, sx = [0, 0]\ngy, gx = [r-1, c-1]\n\ns = [list(map(str, list(input()))) for i in range(r)]\n\nN = r*c\nG = [[] for _ in range(N)]\ndist = [-1]*N\nque = deque()\nfor i in range(r):\n for j in range(c):\n if s[i][j] == '#':\n que.append(i*c+j)\n dist[i*c+j] = 0\n for x, y in ([0, 1], [0, -1], [1, 0], [-1, 0]):\n if 0 <= i+y <= r-1 and 0 <= j+x <= c-1:\n G[i*c+j].append((i+y)*c+j+x)\n\nwhile que:\n v = que.popleft()\n d = dist[v]\n for w in G[v]:\n if dist[w] > -1:\n continue\n dist[w] = d + 1\n que.append(w)\n\nans = max(dist)\nprint(ans)\n", "jacc_sim": 0.9206349206349206, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [302, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u227082700", "n_user": "u227082700", "pos": "from collections import deque\nimport sys\ninput=sys.stdin.readline\nh,w=map(int,input().split())\nd=deque()\ndc=0\nb=[]\nfor i in range(h):\n t=[]\n s=input()\n for j in range(w):\n if s[j]==\"#\":d.append((i,j));dc+=1;t.append(1)\n else:t.append(0)\n b.append(t)\ncount=0\nwhile dc!=0:\n ld=dc\n dc=0\n for i in range(ld):\n x=d.popleft()\n if x[0]0:\n x,y=queue.popleft()\n for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:\n X,Y=x+a,y+b\n if 0<=X0:\n x,y=queue.popleft()\n for a,b in [[1,0],[-1,0],[0,1],[0,-1]]:\n X,Y=x+a,y+b\n if 0<=X 0:\n (x, y) = que.popleft()\n near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]\n for i, j in near: # \u79fb\u52d5\u5148\u306e\u5019\u88dc\n if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:\n dist[i][j] = dist[x][y] + 1\n que.append((i, j))\n return dist[x][y]\n\n\nh, w = map(int, input().split())\na = [input() for _ in range(h)]\nprint(bfs(a))\n", "neg": "from collections import deque\n\n\ndef bfs(S): # \u5e45\u512a\u5148\u63a2\u7d22 # \u30ad\u30e5\u30fc\n dist = [-1] * (w * h) # \u524d\u51e6\u7406\n que = deque()\n for i, Si in enumerate(S):\n for j, Sij in enumerate(Si):\n if Sij == '#':\n dist[i + (w * j)] = 0\n que.append((i, j))\n\n while len(que) > 0:\n (x, y) = que.popleft()\n near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]\n for i, j in near: # \u79fb\u52d5\u5148\u306e\u5019\u88dc\n if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:\n dist[i + (w * j)] = dist[x + (w * y)] + 1\n que.append((i, j))\n return dist[x][y]\n\n\nh, w = map(int, input().split())\na = [input() for _ in range(h)]\nprint(bfs(a))\n", "jacc_sim": 1.0, "nl": "You are given a grid of squares with H horizontal rows and W vertical columns, where each square is painted white or black. Characters from A11 to AHW represent the colors of the squares. Aij is \"#\" if the square at the i-th row from the top and the j-th column from the left is black, and Aij is \".\" if that square is white. We will repeatedly perform the following operation until all the squares are black: Every white square that shares a side with a black square becomes black. Find the number of operations that will be performed. The initial grid has at least one black square.\n\nConstraints:\n1 \u2264 H, W \u2264 1000\nAij is \"#\" or \".\"\nThe given grid has at least one black square.\n\nInput:\nInput is given from Standard Input in the following format:\nH W\nA11A12...A1W\n:\nAH1AH2...AHW\n\nOutput:\nPrint the number of operations that will be performed.\n\nSample Input 1:\n3 3\n...\n.#.\n...\n\nSample Output 1:\n2\nAfter one operation, all but the corners of the grid will be black. After one more operation, all the squares will be black.\n\nSample Input 2:\n6 6\n..#..#\n......\n#..#..\n......\n.#....\n....#.\n\nSample Output 2:\n3", "before_after_length": [314, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03053", "p_user": "u905582793", "n_user": "u905582793", "pos": "from collections import deque\nimport sys\ninput = sys.stdin.readline\nh,w=map(int, input().split(' '))\na = [input() for i in range(h)]\nnl = [[] for i in range(h)]\nq = deque()\nfor i in range(h):\n for j in range(w):\n if a[i][j] == \"#\":\n nl[i].append(0)\n q.append([i,j,0])\n else:\n nl[i].append(-1)\nwhile q:\n [s,t,cnt] = q.popleft()\n if s>0 and nl[s-1][t] == -1:\n q.append([s-1,t,cnt+1])\n nl[s-1][t] = cnt+1\n if s0 and nl[s][t-1] == -1:\n q.append([s,t-1,cnt+1])\n nl[s][t-1] = cnt+1\n if t0 and nl[s-1][t] == -1:\n q.append([s-1,t,cnt+1])\n nl[s-1][t] = cnt+1\n if s0 and nl[s][t-1] == -1:\n q.append([s,t-1,cnt+1])\n nl[s][t-1] = cnt+1\n if t= X[1] or Y[0] >= Y[1]:\n print(\"NO\")\n return\n\n if X[0] <= XP < X[1] and Y[0] <= YP < Y[1]:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n\n", "neg": "import functools\nimport sys\nfrom collections import deque\nimport bisect\nimport copy\nimport heapq\nimport itertools\nimport math\nimport random\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nmod = 10 ** 9 + 7\n\ndef read_values(): return map(int, input().split())\ndef read_index(): return map(lambda x: int(x) - 1, input().split())\ndef read_list(): return list(read_values())\ndef read_lists(N): return [read_list() for n in range(N)]\n\n\nH, W, N = read_values()\nYP, XP = tuple(read_index())\nS = input().strip()\nT = input().strip()\n\n\ndef main():\n X = [-1, W]\n Y = [-1, H]\n for t, s in zip(T[::-1], S[::-1]):\n if t == \"L\":\n X[1] = min(W, X[1] + 1)\n elif t == \"R\":\n X[0] = max(-1, X[0] - 1)\n elif t == \"D\":\n Y[1] = min(H, Y[1] + 1)\n elif t == \"U\":\n Y[0] = max(-1, Y[0] - 1)\n\n if s == \"L\":\n X[0] += 1\n elif s == \"R\":\n X[1] -= 1\n elif s == \"D\":\n Y[0] += 1\n elif s == \"U\":\n Y[1] -= 1\n\n # if X[0] + 1 >= X[1] or Y[0] + 1 >= Y[1]:\n # print(\"NO\")\n # return\n\n if X[0] < XP < X[1] and Y[0] < YP < Y[1]:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == \"__main__\":\n main()\n\n", "jacc_sim": 0.9764705882352941, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [477, 488], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u888337853", "n_user": "u888337853", "pos": "import sys\nimport re\nimport math\nimport collections\nimport bisect\nimport itertools\nimport fractions\nimport functools\nimport copy\nimport heapq\nimport decimal\nimport statistics\nimport queue\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n h, w, n = ns()\n y, x = ns()\n s = list(input())\n t = list(input())\n\n su, sd, sl, sr = 0, 0, 0, 0\n tu, td, tl, tr = 0, 0, 0, 0\n\n yes = True\n\n for si, ti in zip(s, t):\n if si == \"U\":\n su += 1\n elif si == \"D\":\n sd += 1\n elif si == \"L\":\n sl += 1\n else:\n sr += 1\n\n if y - (su - td) < 1:\n yes = False\n if y + sd - tu > h:\n yes = False\n if x - (sl - tr) < 1:\n yes = False\n if x + sr - tl > w:\n yes = False\n\n if ti == \"U\":\n tu = min(tu + 1, y - 1 + sd)\n elif ti == \"D\":\n td = min(td + 1, h - y + su)\n elif ti == \"L\":\n tl = min(tl + 1, x - 1 + sr)\n else:\n tr = min(tr + 1, w - x + sl)\n\n print(\"YES\" if yes else \"NO\")\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nimport re\nimport math\nimport collections\nimport bisect\nimport itertools\nimport fractions\nimport functools\nimport copy\nimport heapq\nimport decimal\nimport statistics\nimport queue\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\ndef main():\n h, w, n = ns()\n y, x = ns()\n s = list(input())\n t = list(input())\n\n su, sd, sl, sr = 0, 0, 0, 0\n tu, td, tl, tr = 0, 0, 0, 0\n\n yes = True\n\n for si, ti in zip(s, t):\n if si == \"U\":\n su += 1\n elif si == \"D\":\n sd += 1\n elif si == \"L\":\n sl += 1\n else:\n sr += 1\n\n if y - (su - td) < 1:\n yes = False\n if y + sd - tu > h:\n yes = False\n if x - (sl - tr) < 1:\n yes = False\n if x + sr - tl > w:\n yes = False\n\n if ti == \"U\":\n tu += 1\n elif ti == \"D\":\n td += 1\n elif ti == \"L\":\n tl += 1\n else:\n tr += 1\n\n print(\"YES\" if yes else \"NO\")\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9888888888888889, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [509, 464], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u489959379", "n_user": "u489959379", "pos": "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n H, W, N = map(int, input().split())\n sr, sc = map(int, input().split())\n sr = H + 1 - sr\n S = input()[::-1]\n T = input()[::-1]\n\n left, right = 1, W\n bottom, up = 1, H\n for s, t in zip(S, T):\n if t == \"R\":\n left -= 1\n left = max(1, left)\n elif t == \"L\":\n right += 1\n right = min(W, right)\n elif t == \"U\":\n bottom -= 1\n bottom = max(1, bottom)\n elif t == \"D\":\n up += 1\n up = min(H, up)\n\n if s == \"R\":\n right -= 1\n elif s == \"L\":\n left += 1\n elif s == \"U\":\n up -= 1\n elif s == \"D\":\n bottom += 1\n\n if left > right or bottom > up:\n print(\"NO\")\n exit()\n\n print(\"YES\" if left <= sc <= right and bottom <= sr <= up else \"NO\")\n\n\nif __name__ == '__main__':\n resolve()\n", "neg": "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n H, W, N = map(int, input().split())\n sr, sc = map(int, input().split())\n S = input()[::-1]\n T = input()[::-1]\n\n left, right = 1, W\n up, bottom = 1, H\n for s, t in zip(S, T):\n if t == \"R\":\n left -= 1\n left = max(1, left)\n elif t == \"L\":\n right += 1\n right = min(W, right)\n elif t == \"U\":\n up -= 1\n up = max(1, up)\n elif t == \"D\":\n bottom += 1\n bottom = min(H, bottom)\n\n if s == \"R\":\n right -= 1\n right = max(1, right)\n elif s == \"L\":\n left += 1\n left = min(H, left)\n elif s == \"U\":\n bottom -= 1\n bottom = max(1, bottom)\n elif s == \"D\":\n up += 1\n up = min(H, up)\n\n if left > right or up > bottom:\n print(\"NO\")\n exit()\n\n print(\"YES\" if left <= sc <= right and up <= sr <= bottom else \"NO\")\n\n\nif __name__ == '__main__':\n resolve()\n", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [337, 368], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u144913062", "n_user": "u144913062", "pos": "import sys\ninput = sys.stdin.readline\n\nH, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input().rstrip()\nT = input().rstrip()\n\nl, r = 1, W\nif S[-1] == 'L':\n l += 1\nif S[-1] == 'R':\n r -= 1\nfor i in range(N-1)[::-1]:\n if T[i] == 'L':\n r = min(r+1, W)\n if T[i] == 'R':\n l = max(l-1, 1)\n\n if S[i] == 'L':\n l += 1\n if S[i] == 'R':\n r -= 1\n \n if l > r:\n print('NO')\n exit()\n\nu, d = 1, H\nif S[-1] == 'U':\n u += 1\nif S[-1] == 'D':\n d -= 1\nfor i in range(N-1)[::-1]:\n if T[i] == 'U':\n d = min(d+1, H)\n if T[i] == 'D':\n u = max(u-1, 1)\n\n if S[i] == 'U':\n u += 1\n if S[i] == 'D':\n d -= 1\n\n if u > d:\n print('NO')\n exit()\n\nif l <= sc <= r and u <= sr <= d:\n print('YES')\nelse:\n print('NO')", "neg": "import sys\ninput = sys.stdin.readline\n\nH, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input().rstrip()\nT = input().rstrip()\n\nl, r = 1, W\nif S[-1] == 'L':\n l += 1\nif S[-1] == 'R':\n r -= 1\nfor i in range(N-1)[::-1]:\n if T[i] == 'L':\n r += 1\n if T[i] == 'R':\n l -= 1\n\n if S[i] == 'L':\n l += 1\n if S[i] == 'R':\n r -= 1\n\n if l > r:\n print('NO')\n exit()\n\nu, d = 1, H\nif S[-1] == 'U':\n u += 1\nif S[-1] == 'D':\n d -= 1\nfor i in range(N-1)[::-1]:\n if T[i] == 'U':\n d += 1\n if T[i] == 'D':\n u -= 1\n\n if S[i] == 'U':\n u += 1\n if S[i] == 'D':\n d -= 1\n\n if u > d:\n print('NO')\n exit()\n\nif l <= sc <= r and u <= sr <= d:\n print('YES')\nelse:\n print('NO')", "jacc_sim": 0.9607843137254902, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [387, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u670180528", "n_user": "u670180528", "pos": "h, w, n = map(int, input().split())\nsy, sx = map(int, input().split())\nl, r = 1, w\nd, u = 1, h\nfor a, b in zip(input()[::-1], input()[::-1]):\n\tr = min(r + (b == \"L\"), w) - (a == \"R\")\n\tl = max(l - (b == \"R\"), 1) + (a == \"L\")\n\tu = min(u + (b == \"D\"), h) - (a == \"U\")\n\td = max(d - (b == \"U\"), 1) + (a == \"D\")\n\tif l > r or d > u:break\nprint(\"YES\" if l <= sx <= r and d <= h - sy + 1 <= u else \"NO\")", "neg": "h, w, n = map(int, input().split())\nsy, sx = map(int, input().split())\nl, r = 1, w\nd, u = 1, h\nfor a, b in zip(input()[::-1], input()[::-1]):\n\tr = min(r + (b == \"L\"), w) - (a == \"R\")\n\tl = max(l - (b == \"R\"), 1) + (a == \"L\")\n\tu = min(u + (b == \"D\"), h) - (a == \"U\")\n\td = max(d - (b == \"U\"), 1) + (a == \"D\")\nprint(\"YES\" if l <= sx <= r and d <= h - sy - 1 <= u else \"NO\")", "jacc_sim": 0.9347826086956522, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [199, 187], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u415905784", "n_user": "u415905784", "pos": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nB = [1, W, 1, H]\nfor i in range(N - 1, -1, -1):\n if T[i] == 'L': B[1] = min(B[1] + 1, W)\n if T[i] == 'R': B[0] = max(B[0] - 1, 1)\n if T[i] == 'U': B[3] = min(B[3] + 1, H)\n if T[i] == 'D': B[2] = max(B[2] - 1, 1)\n if S[i] == 'L': B[0] += 1\n if S[i] == 'R': B[1] -= 1\n if S[i] == 'U': B[2] += 1\n if S[i] == 'D': B[3] -= 1\n if B[1] < B[0] or B[3] < B[2]:\n print('NO')\n break\nelse:\n print('YES' if B[0] <= sc <= B[1] and B[2] <= sr <= B[3] else 'NO')", "neg": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nB = [1, W, 1, H]\nfor i in range(N - 1, -1, -1):\n if T[i] == 'L': B[1] = min(B[1] + 1, W)\n if T[i] == 'R': B[0] = max(B[0] - 1, 1)\n if T[i] == 'U': B[3] = min(B[3] + 1, H)\n if T[i] == 'D': B[2] = max(B[2] - 1, 1)\n if S[i] == 'L': B[0] += 1\n if S[i] == 'R': B[1] -= 1\n if S[i] == 'U': B[2] += 1\n if S[i] == 'D': B[3] -= 1\n if B[1] < B[0] or B[3] < B[2]:\n print('NO')\n break\nelse:\n print('YES' if B[0] <= sc <= B[1] and B[3] <= sr <= B[2] else 'NO')", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [309, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u543954314", "n_user": "u543954314", "pos": "h,w,n = map(int,input().split())\nsr,sc = map(int,input().split())\nt = input()\ns = input()\nhei = [1,h]\nwid = [1,w]\nfor i in range(n-1,-1,-1):\n if s[i] == \"L\":\n wid[1] = min(wid[1]+1,w)\n elif s[i] == \"R\":\n wid[0] = max(wid[0]-1,1)\n elif s[i] == \"U\":\n hei[1] = min(hei[1]+1,h)\n elif s[i] == \"D\":\n hei[0] = max(hei[0]-1,1)\n if t[i] == \"L\":\n wid[0] += 1\n elif t[i] == \"R\":\n wid[1] -= 1\n elif t[i] == \"U\":\n hei[0] += 1\n elif t[i] == \"D\":\n hei[1] -= 1\n if wid[0]>wid[1] or hei[0]>hei[1]:\n print(\"NO\")\n exit(0)\nif hei[0] <= sr <= hei[1] and wid[0] <= sc <= wid[1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "neg": "h,w,n = map(int,input().split())\nsr,sc = map(int,input().split())\nt = input()\ns = input()\nhei = [1,h]\nwid = [1,w]\nfor i in range(n-1,-1,-1):\n if s[i] == \"L\":\n wid[1] = min(wid[1]+1,w)\n elif s[i] == \"R\":\n wid[0] = max(wid[0]-1,0)\n elif s[i] == \"U\":\n hei[1] = min(hei[1]+1,h)\n elif s[i] == \"D\":\n hei[0] = max(hei[0]-1,0)\n if t[i] == \"L\":\n wid[0] += 1\n elif t[i] == \"R\":\n wid[1] -= 1\n elif t[i] == \"U\":\n hei[0] += 1\n elif t[i] == \"D\":\n hei[1] -= 1\n if wid[0]==wid[1] or hei[0]==hei[1]:\n print(\"NO\")\n exit(0)\nif hei[0] <= sc <= hei[1] and wid[0] <= sr <= wid[1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 0.9787234042553191, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [344, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u643840641", "n_user": "u923270446", "pos": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\ns = input()\nt = input()\nl, u = 1, 1\nr = w\nd = h\nfor i in range(n-1, -1, -1):\n if t[i] == 'L':\n r = min(w, r+1)\n if t[i] == 'R':\n l = max(1, l-1)\n if t[i] == 'U':\n d = min(h, d+1)\n if t[i] == 'D':\n u = max(1, u-1)\n if s[i] == 'L':\n l += 1\n if s[i] == 'R':\n r -= 1\n if s[i] == 'U':\n u += 1\n if s[i] == 'D':\n d -= 1\n if l > r or u > d:\n print(\"NO\")\n quit()\nprint(\"YES\" if l<=sc<=r and u<=sr<=d else \"NO\")", "neg": "h,w,n=map(int,input().split())\nsr,sc=map(int,input().split())\ns=input()[::-1]\nt=input()[::-1]\nl,r,u,d=0,w+1,0,h+1\nfor i in range(n):\n si,ti=s[i],t[i]\n if l>r or u>d:break\n r=min(w+1,r+1)if ti==\"L\"else r\n l=max(0,l-1)if ti==\"R\"else l\n d=min(h+1,d+1)if ti==\"U\"else d\n u=max(0,u-1)if ti==\"D\"else u\n r-=1 if si==\"R\"else 0\n l+=1 if si==\"L\"else 0\n d-=1 if si==\"D\"else 0\n u+=1 if si==\"U\"else 0\nprint(\"YES\"if l down:\n print('NO')\n exit()\n \n# horizontal direction\nleft, right = 0, W-1\nfor i in range(N-1, -1, -1): \n if T[i] == 'L':\n right = min(W-1, right + 1)\n elif T[i] == 'R':\n left = max(0, left - 1)\n \n if S[i] == 'L':\n left += 1\n elif S[i] == 'R':\n right -= 1\n \n if left > right:\n print('NO')\n exit()\nif up <= s_r-1 <=down and left <= s_c-1 <= right:\n print('YES')\nelse:\n print('NO')", "neg": "import sys\n\nH, W, N = map(int, input().split())\ns_r, s_c = map(int, input().split())\nS = input()\nT = input()\n\n# vertical direction\nup, down = 0, H-1\nfor i in range(H, -1, -1):\n if T[i] == 'U':\n down = min(H, down + 1)\n elif T[i] == 'D':\n up = max(0, up - 1)\n \n if S[i] == 'U':\n up += 1\n elif S[i] == 'D':\n down -= 1\n \n if up >= down:\n print('NO')\n sys.exit()\n \n# horizontal direction\nleft, right = 0, W-1\nfor j in range(W-1, -1, -1): \n if T[j] == 'L':\n right = min(H, right + 1)\n elif T[j] == 'R':\n left = max(0, left - 1)\n \n if S[j] == 'L':\n left += 1\n elif S[j] == 'R':\n right -= 1\n \n if left >= right:\n print('NO')\n sys.exit()\nif up <= s_r <= down and left <= s_c <= right:\n print('YES')\nelse:\n print('NO')", "jacc_sim": 0.9454545454545454, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [344, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u118642796", "n_user": "u118642796", "pos": "H,W,N = map(int,input().split())\nsr,sc = map(int,input().split())\nS = input()\nT = input()\n\nL = 0\nR = W+1\nU = 0\nD = H+1\n\nfor i in range(N-1,-1,-1):\n if S[i] == \"L\":\n L += 1\n elif S[i] == \"R\":\n R -= 1\n elif S[i] == \"U\":\n U += 1\n elif S[i] == \"D\":\n D -= 1\n if L+1==R or U+1==D:\n print(\"NO\")\n break\n\n if i>0:\n if T[i-1] == \"L\":\n R = min(W+1,R+1)\n elif T[i-1] == \"R\":\n L = max(0,L-1)\n elif T[i-1] == \"U\":\n D = min(H+1,D+1)\n elif T[i-1] == \"D\":\n U = max(0,U-1)\nelse:\n if sr<=U or D<=sr or sc<=L or R<=sc:\n print(\"NO\")\n else:\n print(\"YES\")\n", "neg": "H,W,N = map(int,input().split())\nsr,sc = map(int,input().split())\nS = input()\nT = input()\n\nL = 0\nR = W+1\nU = 0\nD = H+1\n\nfor i in range(N-1,-1,-1):\n if S[i] == \"L\":\n L += 1\n elif S[i] == \"R\":\n R -= 1\n elif S[i] == \"U\":\n U += 1\n elif S[i] == \"D\":\n D -= 1\n if L+1==R or U+1==D:\n print(\"NO\")\n break\n\n if i>0:\n if T[i-1] == \"L\":\n R += 1\n elif T[i-1] == \"R\":\n L -= 1\n elif T[i-1] == \"U\":\n D += 1\n elif T[i-1] == \"D\":\n U -= 1\nelse:\n if sr<=U or D<=sr or sc<=L or R<=sc:\n print(\"NO\")\n else:\n print(\"YES\")\n", "jacc_sim": 0.9545454545454546, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [318, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u292810930", "n_user": "u292810930", "pos": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nl = 0\nr = W+1\nu = 0\nd = H+1\nflag = True\nfor s,t in zip(S[::-1],T[::-1]):\n if l+1==r or u+1==d:\n flag=False\n break\n if t == 'L':\n r = min(W+1, r+1)\n if t == 'R':\n l = max(0, l-1)\n if t == 'U':\n d = min(H+1, d+1)\n if t == 'D':\n u = max(0, u-1)\n if s == 'L':\n l += 1\n if s == 'R':\n r -= 1\n if s == 'U':\n u += 1\n if s == 'D':\n d -= 1\nif not(l < sc < r and u < sr < d):\n flag = False\nif flag:\n print('YES')\nelse:\n print('NO')", "neg": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nl = 0\nr = W+1\nu = 0\nd = H+1\nflag = True\nfor s,t in zip(S[::-1],T[::-1]):\n if l+1==r or u+1==d:\n flag=False\n break\n if t == 'L':\n r = min(0, r-1)\n if t == 'R':\n l = max(W+1, l+1)\n if t == 'U':\n d = min(0, d-1)\n if t == 'D':\n u = max(H+1, u+1)\n if s == 'L':\n l += 1\n if s == 'R':\n r -= 1\n if s == 'U':\n u += 1\n if s == 'D':\n d -= 1\nif not(l < sc < r and u < sr < d):\n flag = False\nif flag:\n print('YES')\nelse:\n print('NO')", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [281, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u310233294", "n_user": "u310233294", "pos": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\ns = list(input())\nt = list(input())\nr, l, u, d = w, 1, 1, h\nns = list(range(n))\nfor i in ns[::-1]:\n if t[i] == 'L' and r < w:\n r += 1\n elif t[i] == 'R' and l > 1:\n l -= 1\n elif t[i] == 'U' and d < h:\n d += 1\n elif t[i] == 'D' and u > 1:\n u -= 1\n if s[i] == 'L':\n l += 1\n elif s[i] == 'R':\n r -= 1\n elif s[i] == 'U':\n u += 1\n elif s[i] == 'D':\n d -= 1\n if (l > r) or (u > d):\n ans = 'NO'\n break\nif (l <= sc <= r) and (u <= sr <= d):\n ans = 'YES'\nelse:\n ans = 'NO'\nprint(ans)", "neg": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\ns = list(input())\nt = list(input())\nr, l, u, d = sr, 1, sc, 1\nns = list(range(n))\nfor i in ns[::-1]:\n if t[i] == 'L':\n r += 1\n elif t[i] == 'R':\n l -= 1\n elif t[i] == 'U':\n u += 1\n elif t[i] == 'D':\n d -= 1\n if s[i] == 'L':\n l += 1\n elif s[i] == 'R':\n r -= 1\n elif s[i] == 'U':\n d += 1\n elif s[i] == 'D':\n u -= 1\n if (l > r) or (u > d):\n ans = 'NO'\n break\nif (l <= w <= r) and (u <= h <= d):\n ans = 'YES'\nelse:\n ans = 'NO'\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [287, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u375616706", "n_user": "u375616706", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nH,W,N=map(int,input().split())\n\nsr,sc=map(int,input().split())\nS=input()[:-1]\nT=input()[:-1]\n\nleft=0\nright=W+1\nup=0\ndown=H+1\n\nans=\"YES\"\nfor i,(s,t) in enumerate(zip(reversed(S),reversed(T))):\n if i!=0:\n if t=='R':\n left=max(0,left-1)\n elif t==\"L\":\n right=min(W+1,right+1)\n elif t==\"D\":\n up = max(0,up-1)\n else:\n down=min(H+1,down+1)\n\n\n if s==\"R\":\n right-=1\n elif s==\"L\":\n left+=1\n elif s==\"D\":\n down-=1\n else:\n up+=1\n\n if right-left==1 or down-up==1:\n ans=\"NO\"\n break\n\nif not left r or u > d:\n print('NO')\n return\n\n if l <= x <= r and u <= y <= d:\n print('YES')\n return\n else:\n print('NO')\n return\n\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n h, w, n = map(int, input().split())\n y, x = map(int, input().split())\n y -= 1\n x -= 1\n s, t = input(), input()\n\n u, d, l, r = 0, h - 1, 0, w - 1\n\n for ss, tt in zip(s[::-1], t[::-1]):\n if tt == 'U':\n d = min(d + 1, h - 1)\n elif tt == 'D':\n u = max(u - 1, 0)\n elif tt == 'L':\n r = min(r + 1, w - 1)\n else:\n l = max(l - 1, 0) # tt == 'R'\n\n if ss == 'U':\n u += 1\n elif ss == 'D':\n d -= 1\n elif ss == 'L':\n l += 1\n else:\n r -= 1 # ss == 'R'\n\n if l > r or u > d:\n print('NO')\n return\n\n if l <= x <= r and u <= y <= d:\n print('YES')\n return\n else:\n print('NO')\n return\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9322033898305084, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [316, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u788137651", "n_user": "u788137651", "pos": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\n\nleft = 1\nright = W\nup = 1\ndown = H\n\nfor i in reversed(range(N)):\n if T[i] == \"U\":\n down = min(H, down+1)\n elif T[i] == \"D\":\n up = max(1, up-1)\n elif T[i] == \"L\":\n right = min(W, right+1)\n else:\n left = max(1, left-1)\n\n if S[i] == \"U\":\n up += 1\n elif S[i] == \"D\":\n down -= 1\n elif S[i] == \"L\":\n left += 1\n else:\n right -= 1\n\n #print(left, right, \" \", up, down)\n\n if left > right or up > down:\n print(\"NO\")\n exit()\n\n#print(left, right)\n#print(up, down)\nif left <= sc <= right and up <= sr <= down:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\n\nleft = 0\nright = W\nup = 0\ndown = H\n\nfor i in reversed(range(N)):\n if i != N - 1:\n if T[i] == \"U\":\n if down != H:\n down -= 1\n elif T[i] == \"D\":\n if up != 0:\n up += 1\n elif T[i] == \"L\":\n if right != W:\n right += 1\n else:\n if left != 0:\n left -= 1\n if S[i] == \"U\":\n up += 1\n elif S[i] == \"D\":\n down -= 1\n elif S[i] == \"L\":\n left += 1\n else:\n right -= 1\n if left > right or up > down:\n print(\"NO\")\n exit()\n#print(left, right)\n#print(up, down)\nif left <= sr <= right and up <= sc <= down:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 0.9215686274509803, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [294, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u001024152", "n_user": "u001024152", "pos": "H,W,N = map(int, input().split())\nsr,sc = map(int, input().split())\nS = input()\nT = input()\n\nleft, right = 0, W+1\nif S[-1] == \"R\":\n right -= 1\nelif S[-1] == \"L\":\n left += 1\nfor i in reversed(range(N-1)):\n si, ti = S[i], T[i]\n if ti == \"R\":\n left -= 1\n elif ti == \"L\":\n right += 1\n left = max(0, left)\n right = min(W+1, right)\n\n if si == \"R\":\n right -= 1\n elif si == \"L\":\n left += 1\n\n if right - left == 1:\n print(\"NO\")\n exit()\n\nif sc <= left or right <= sc:\n print(\"NO\")\n exit()\n\n\nleft, right = 0, H+1\nif S[-1] == \"U\":\n left += 1\nelif S[-1] == \"D\":\n right -= 1\n\nfor i in reversed(range(N-1)):\n si, ti = S[i], T[i]\n if ti == \"D\":\n left -= 1\n elif ti == \"U\":\n right += 1\n left = max(0, left)\n right = min(H+1, right)\n\n if si == \"D\":\n right -= 1\n elif si == \"U\":\n left += 1\n\n if right - left == 1:\n print(\"NO\")\n exit()\n\nif sr <= left or right <= sr:\n print(\"NO\")\n exit()\n\nprint(\"YES\")\n", "neg": "H,W,N = map(int, input().split())\nsr,sc = map(int, input().split())\nS = input()\nT = input()\n\nleft, right = 0, W+1\nif S[-1] == \"R\":\n right -= 1\nelif S[-1] == \"L\":\n left += 1\nfor i in reversed(range(N-1)):\n si, ti = S[i], T[i]\n if ti == \"R\":\n left -= 1\n elif ti == \"L\":\n right += 1\n left = max(0, left)\n right = min(W+1, right)\n\n if si == \"R\":\n right -= 1\n elif si == \"L\":\n left += 1\n\n if right - left == 1:\n print(\"NO\")\n exit()\n\nif sc <= left or right <= sc:\n print(\"NO\")\n exit()\n\n\nleft, right = 0, H+1\nif S[-1] == \"U\":\n left += 1\nelif S[-1] == \"D\":\n right -= 1\n\nfor i in reversed(range(N-1)):\n si, ti = S[i], T[i]\n if ti == \"D\":\n left -= 1\n elif ti == \"U\":\n right += 1\n down = max(0, down)\n up = min(H+1, up)\n\n if si == \"D\":\n right -= 1\n elif si == \"\":\n left += 1\n\n if right - left == 1:\n print(\"NO\")\n exit()\n\nif sr <= left or right <= sr:\n print(\"NO\")\n exit()\n\nprint(\"YES\")\n", "jacc_sim": 0.9591836734693877, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [416, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u227476288", "n_user": "u227476288", "pos": "H,W,N = map(int, input().split())\nst = [int(i) for i in input().split()]\nS = input()\nT = input()\n\n\ndef simu(dim1):\n now = [st[0],st[1]]\n\n if dim1 == 'U':\n dim2,L,step,dim = 'D',H,1,0\n if dim1 == 'D':\n dim2,L,step,dim = 'U',H,-1,0\n if dim1 == 'L':\n dim2,L,step,dim = 'R',W,1,1\n if dim1 == 'R':\n dim2,L,step,dim = 'L',W,-1,1\n\n for i in range(N):\n if S[i] == dim1:\n now[dim] -= step\n if now[dim] < 1 or now[dim] >= L+1:\n return True\n if T[i] == dim2:\n if step == 1:\n if now[dim] < L:\n now[dim] += step\n else:\n if now[dim] > 1:\n now[dim] += step\n return False\n \nDim = ['U','D','R','L']\nfor d in Dim:\n if simu(d):\n print('NO')\n exit()\nprint('YES')", "neg": "H,W,N = map(int, input().split())\nst = [int(i) for i in input().split()]\nS = input()\nT = input()\n\n\ndef simu(dim1):\n now = [st[0],st[1]]\n\n if dim1 == 'U':\n dim2,L,step,dim = 'D',H,-1,0\n if dim1 == 'D':\n dim2,L,step,dim = 'U',H,1,0\n if dim1 == 'R':\n dim2,L,step,dim = 'L',W,1,1\n if dim1 == 'L':\n dim2,L,step,dim = 'R',W,-1,1\n\n for i in range(N):\n if S[i] == dim1:\n now[dim] -= step\n if now[dim] < 1 or now[dim] >= L+1:\n return True\n if T[i] == dim2:\n if step == -1:\n if now[dim] < L:\n now[dim] += step\n else:\n if now[dim] > 0:\n now[dim] += step\n \nD = ['U','D','R','L']\nfor d in D:\n if simu(d):\n print('YES')\n exit()\nprint('NO')", "jacc_sim": 0.9615384615384616, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [336, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u813098295", "n_user": "u813098295", "pos": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\ns = input()\nt = input()\nsr -= 1; sc -= 1\n \nL=0; R=w-1; U=0; D=h-1;\nis_drop = False\nfor i in range(n)[::-1]:\n if t[i] == 'U': D = min(D+1, h-1)\n if t[i] == 'D': U = max(U-1, 0)\n if t[i] == 'L': R = min(R+1, w-1)\n if t[i] == 'R': L = max(L-1, 0)\n if s[i] == 'U': U += 1\n if s[i] == 'D': D -= 1\n if s[i] == 'L': L += 1\n if s[i] == 'R': R -= 1\n if R < L or D < U: is_drop = True\nif (not L <= sc <= R) or (not U <= sr <= D): is_drop = True\n\nprint( \"NO\" if is_drop else \"YES\" )\n", "neg": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\ns = input()\nt = input()\nsr -= 1; sc -= 1\n \nL=0; R=w-1; U=0; D=h-1;\nis_drop = False\nfor i in range(n)[::-1]:\n if t[i] == 'U': D = min(D+1, h-1)\n if t[i] == 'D': U = max(U-1, 0)\n if t[i] == 'L': R = min(R+1, w-1)\n if t[i] == 'R': L = max(L-1, 0)\n if s[i] == 'U': U++\n if s[i] == 'D': D--\n if s[i] == 'L': L++\n if s[i] == 'R': R--\n if R < L or D < U: is_drop = True\n if (not L <= sc <= R) or (not U <= sr <= D): is_drop = True\n\nprint( \"NO\" if is_drop else \"YES\" )\n", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [288, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u207707177", "n_user": "u207707177", "pos": "#!/usr/bin/env python3\nH, W, N = map(int, input().split())\nsr, sc = map(lambda x: int(x) - 1, input().split())\nS = input()\nT = input()\nl, r = 0, W\nu, d = 0, H\nfor i in range(N)[::-1]:\n if T[i] == 'L': r = min(W, r + 1)\n if T[i] == 'R': l = max(0, l - 1)\n if T[i] == 'U': d = min(H, d + 1)\n if T[i] == 'D': u = max(0, u - 1)\n if S[i] == 'L': l += 1\n if S[i] == 'R': r -= 1\n if S[i] == 'U': u += 1\n if S[i] == 'D': d -= 1\n if l == r or u == d: \n print(\"NO\")\n exit()\n\nprint((\"NO\", \"YES\")[l <= sc < r and u <= sr < d])\n\n", "neg": "#!/usr/bin/env python3\nH, W, N = map(int, input().split())\nsr, sc = map(lambda x: int(x) - 1, input().split())\nS = input()\nT = input()\nl, r = 0, W\nu, d = 0, H\nfor i in range(N)[::-1]:\n if T[i] == 'L': r = min(W, r + 1)\n if T[i] == 'R': l = max(0, l - 1)\n if T[i] == 'U': d = min(H, d + 1)\n if T[i] == 'D': u = max(0, u - 1)\n if S[i] == 'L': l += 1\n if S[i] == 'R': r -= 1\n if S[i] == 'U': u += 1\n if S[i] == 'D': d -= 1\n if l == r or u == d:\n print(\"NO\")\n exit()\n\nprint(\"YES\")\n\n", "jacc_sim": 0.9636363636363636, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [270, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u691018832", "n_user": "u691018832", "pos": "h, w, n = map(int, input().split())\nar, ac = map(int, input().split())\ns = input()\nt = input()\nr = ac\nl = ac\nu = ar\nd = ar\nans = False\n\nfor i in range(n):\n if s[i] == \"R\":\n r += 1\n if s[i] == \"L\":\n l -= 1\n if s[i] == \"U\":\n u -= 1\n if s[i] == \"D\":\n d += 1\n if l==0 or r==w+1 or u==0 or d==h+1:\n print(\"NO\")\n ans = True\n break\n \n if t[i] == \"R\" and l != w:\n l += 1\n if t[i] == \"L\" and r != 1:\n r -= 1\n if t[i] == \"U\" and d != 1:\n d -= 1\n if t[i] == \"D\" and u != h:\n u += 1\n \nif ans != True:\n print(\"YES\")", "neg": "h, w, n = map(int, input().split())\nar, ac = map(int, input().split())\ns = input()\nt = input()\nr = ac\nl = ac\nu = ar\nd = ar\n\nfor i in range(n):\n if s[i] == \"R\":\n r += 1\n if s[i] == \"L\":\n l -= 1\n if s[i] == \"U\":\n u -= 1\n if s[i] == \"D\":\n d += 1\n if l==0 or r==w+1 or u==0 or d==h+1:\n print(\"NO\")\n ans = True\n break\n \n if t[i] == \"R\" and l != w:\n l += 1\n if t[i] == \"L\" and r != 1:\n r -= 1\n if t[i] == \"U\" and d != 1:\n d -= 1\n if t[i] == \"D\" and u != h:\n u += 1\n \nif ans != True:\n print(\"YES\")", "jacc_sim": 0.9787234042553191, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [267, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u941753895", "n_user": "u941753895", "pos": "H,W,N=map(int,input().split())\nsr,sc=map(int,input().split())\nS=input()\nT=input()\n\nld=H-sr\nlu=sr-1\nlr=W-sc\nll=sc-1\n\nfor i in range(N):\n x=S[i]\n y=T[i]\n\n if x=='U':\n lu-=1\n elif x=='D':\n ld-=1\n elif x=='L':\n ll-=1\n elif x=='R':\n lr-=1\n\n # print(lu,ld,ll,lr)\n\n if lu<0 or ld<0 or ll<0 or lr<0:\n print('NO')\n exit()\n\n if y=='U' and ld= iit[j]+aoki[3-j]:\n print('NO')\n exit()\n if t[i] == 'L':\n aoki[0] += 1\n if t[i] == 'U':\n aoki[1] += 1\n if t[i] == 'D':\n aoki[2] += 1\n if t[i] == 'R':\n aoki[3] += 1\n for j in range(4):\n if aoki[j] >= iit[j]+tshi[3-j]:\n aoki[j] -= 1\n\nprint('YES')", "neg": "import sys\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nh,w,n = na()\nsh,sw = na()\ns = ns()\nt = ns()\n\niit = [sw,sh,h-sh+1,w-sw+1]\n\nprint(iit)\n#ludr\ntshi = [0,0,0,0]\naoki = [0,0,0,0]\n\nfor i in range(n):\n if s[i] == 'L':\n tshi[0] += 1\n if s[i] == 'U':\n tshi[1] += 1\n if s[i] == 'D':\n tshi[2] += 1\n if s[i] == 'R':\n tshi[3] += 1\n print(tshi)\n print(aoki)\n for j in range(4):\n if tshi[j] >= iit[j]+aoki[3-j]:\n print('NO')\n exit()\n if t[i] == 'L':\n aoki[0] += 1\n if t[i] == 'U':\n aoki[1] += 1\n if t[i] == 'D':\n aoki[2] += 1\n if t[i] == 'R':\n aoki[3] += 1\n for j in range(4):\n if aoki[j] >= iit[j]+tshi[3-j]:\n aoki[j] -= 1\n\nprint('YES')", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [415, 437], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u102126195", "n_user": "u102126195", "pos": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nwin = 0\n\nSR = sr\nSC = sc\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"L\":\n sc -= 1\n if sc <= 0:\n break\n if T[i] == \"R\" and sc < w:\n sc += 1\nif sc <= 0:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"R\":\n sc += 1\n if sc > w:\n break\n if T[i] == \"L\" and sc > 1:\n sc -= 1\nif sc > w:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"D\":\n sr += 1\n if sr > h:\n break\n if T[i] == \"U\" and sr > 1:\n sr -= 1\nif sr > h:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"U\":\n sr -= 1\n if sr <= 0:\n break\n if T[i] == \"D\" and sr < h:\n sr += 1\nif sr <= 0:\n win = 1\n\nif win:\n print(\"NO\")\nelse:\n print(\"YES\")", "neg": "h, w, n = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nwin = 0\n\nSR = sr\nSC = sc\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"L\":\n sc -= 1\n if sc <= 0:\n break\n if T[i] == \"R\" and sc < w:\n sc += 1\nif sc <= 0:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"R\":\n sc += 1\n if sc > w:\n break\n if T[i] == \"L\" and sc > 1:\n sc -= 1\nif sc > w:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"D\":\n sr += 1\n if sr > h:\n break\n if T[i] == \"U\" and sr > 1:\n sr -= 1\nif sr > h:\n win = 1\n\n\nsr = SR\nsc = SC\nfor i in range(n):\n if S[i] == \"U\":\n sr -= 1\n if sr <= 0:\n break\n if T[i] == \"D\" and sr < h:\n sr += 1\nif sr <= 0:\n win = 1\n\nif win:\n print(\"No\")\nelse:\n print(\"Yes\")", "jacc_sim": 0.9130434782608695, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [372, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u368780724", "n_user": "u368780724", "pos": "from sys import exit\nH, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nul = 1\ndl = H\nrl = W\nll = 1\nfor s, t in zip(S[1::][::-1], T[:-1:][::-1]):\n if s == 'U':\n ul += 1\n elif s == 'D':\n dl -= 1\n elif s == 'L':\n ll += 1\n else:\n rl -= 1\n if ul > dl or ll > rl or ul == H + 1 or dl == 0 or ll == W + 1 or rl == 0:\n print('NO')\n exit()\n if t == 'U':\n dl = min(H, dl+1)\n elif t == 'D':\n ul = max(1, ul-1)\n elif t == 'L':\n rl = min(W, rl+1)\n else:\n ll = max(1, ll-1)\ns = S[0]\nif s == 'U':\n ul += 1\nelif s == 'D':\n dl -= 1\nelif s == 'L':\n ll += 1\nelse:\n rl -= 1\n\nif ul <= sr <= dl and ll <= sc <= rl:\n print('YES')\nelse:\n print('NO')", "neg": "from sys import exit\nH, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\nul = 1\ndl = H\nrl = W\nll = 1\nfor s, t in zip(S[1::][::-1], T[::-1]):\n if t == 'U':\n dl = min(H, dl+1)\n elif t == 'D':\n ul = max(1, ul-1)\n elif t == 'L':\n rl = min(W, rl+1)\n else:\n ll = max(1, ll-1)\n if s == 'U':\n ul += 1\n elif s == 'D':\n dl -= 1\n elif s == 'L':\n ll += 1\n else:\n rl -= 1\n if ul > dl or ll > rl or ul == H + 1 or dl == 0 or ll == W + 1 or rl == 0:\n print('NO')\n exit()\ns = S[0]\nif s == 'U':\n ul += 1\nelif s == 'D':\n dl -= 1\nelif s == 'L':\n ll += 1\nelse:\n rl -= 1\n\nif ul <= sr <= dl and ll <= sc <= rl:\n print('YES')\nelse:\n print('NO')", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [334, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u467736898", "n_user": "u467736898", "pos": "H, W, N = map(int, input().split())\nSr, Sc = map(int, input().split())\nS = input()\nT = input()\n\n\nl = 1\nr = W\nu = 1\nd = H\n#print(l, r, u, d,)\nfor s, t in zip(S[::-1], T[::-1]):\n\n if t==\"L\":\n r = min(r+1, W)\n elif t==\"R\":\n l = max(l-1, 1)\n elif t==\"U\":\n d = min(d+1, H)\n else:\n u = max(u-1, 1)\n\n #print(d)\n if s==\"L\":\n l+=1\n elif s==\"R\":\n r-=1\n elif s==\"U\":\n u+=1\n else:\n d-=1\n\n if l > r or u > d:\n print(\"NO\")\n exit()\n #print(l, r, u, d, \" st\", s, t)\nif u<=Sr<=d and l<=Sc<=r:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "H, W, N = map(int, input().split())\nSr, Sc = map(int, input().split())\nS = input()\nT = input()\n\n\nl = 1\nr = W\nu = 1\nd = H\nfor s, t in zip(S[::-1], T[::-1]):\n\n if t==\"L\":\n r = min(r+1, W)\n elif t==\"R\":\n l = max(l-1, 1)\n elif t==\"U\":\n d = min(d+1, W)\n else:\n u = max(u-1, 1)\n\n if s==\"L\":\n l+=1\n elif s==\"R\":\n r-=1\n elif s==\"U\":\n u+=1\n else:\n d-=1\n\n if l > r or u > d:\n print(\"NO\")\n exit()\n #print(l, r, u, d)\nif d<=Sr<=u and l<=Sc<=r:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 0.98, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [298, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03054", "p_user": "u667084803", "n_user": "u667084803", "pos": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\n\nflag = 0\nhidari = sc\nmigi = sc\nue = sr\nshita = sr\nfor i in range(N):\n if S[i] == 'L':\n hidari -= 1\n if S[i] == 'R':\n migi += 1\n if S[i] == 'U':\n ue -= 1\n if S[i] == 'D':\n shita += 1\n if hidari == 0 or migi == W+1 or ue == 0 or shita == H+1 :\n flag = 1\n \n if T[i] == 'R' and hidari != W:\n hidari += 1\n if T[i] == 'L' and migi != 1:\n migi -= 1\n if T[i] == 'D' and ue != H:\n ue += 1\n if T[i] == 'U' and shita != 1:\n shita -= 1\n\nif flag :\n print(\"NO\")\nelse :\n print(\"YES\")\n ", "neg": "H, W, N = map(int, input().split())\nsr, sc = map(int, input().split())\nS = input()\nT = input()\n\nflag = 0\nhidari = sc\nmigi = sc\nue = sr\nshita = sr\nfor i in range(N):\n print(hidari,migi,ue,shita)\n if S[i] == 'L':\n hidari -= 1\n if S[i] == 'R':\n migi += 1\n if S[i] == 'U':\n ue -= 1\n if S[i] == 'D':\n shita += 1\n if hidari == 0 or migi == W+1 or ue == H+1 or shita == 0:\n flag = 1\n \n print(hidari,migi,ue,shita)\n if T[i] == 'R' and hidari != W:\n hidari += 1\n if T[i] == 'L' and migi != 0:\n migi -= 1\n if T[i] == 'D' and ue != 0:\n ue += 1\n if T[i] == 'U' and shita != H:\n shita -= 1\n\nif flag :\n print(\"NO\")\nelse :\n print(\"YES\")\n ", "jacc_sim": 1.0, "nl": "You are given a rectangular grid of squares with H horizontal rows and W vertical columns. There is a piece initially placed at square (s_r, s_c). Takahashi and Aoki play a game with strings of length N. Takahashi's string is S, and Aoki's string is T, both consisting of four kinds of letters: L, R, U, and D. The game consists of N steps, where each player moves the piece according to their respective strings. Takahashi aims to remove the piece from the grid in one of the N steps, while Aoki wants the piece to remain on the grid after N steps. Determine if the piece will remain on the grid at the end of the game when both players play optimally. Constraints: 2 \u2264 H, W, N \u2264 2 \u00d7 10^5, 1 \u2264 s_r \u2264 H, 1 \u2264 s_c \u2264 W, |S| = |T| = N, S and T consist of the letters L, R, U, and D. Input is given as H, W, N, s_r, s_c, S, and T. Output \"YES\" if the piece remains on the grid at the end of the game; otherwise, output \"NO\".", "before_after_length": [290, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u707124227", "n_user": "u707124227", "pos": "n=int(input())\ntr=[[] for _ in range(n)]\nfor _ in range(n-1):\n x,y=map(int,input().split())\n x,y=x-1,y-1\n tr[x].append(y)\n tr[y].append(x)\nfrom collections import deque\nseen=[-1]*n\ntodo=deque([0])\nwhile todo:\n v=todo.popleft()\n seen[v]=1\n for nv in tr[v]:\n if seen[nv]==-1:\n todo.append(nv)\nv0=v\nseen=[-1]*n\ntodo=deque([v])\nseen[v]=0\nwhile todo:\n v=todo.popleft()\n for nv in tr[v]:\n if seen[nv]==-1:\n todo.append(nv)\n seen[nv]=seen[v]+1\nc=seen[v]\nc+=1\nif c%3==2:\n print('Second')\nelse:\n print('First')\n", "neg": "n=int(input())\ntr=[[] for _ in range(n)]\nfor _ in range(n-1):\n x,y=map(int,input().split())\n x,y=x-1,y-1\n tr[x].append(y)\n tr[y].append(x)\nfrom collections import deque\nseen=[-1]*n\ntodo=deque([0])\nwhile todo:\n v=todo.popleft()\n seen[v]=1\n for nv in tr[v]:\n if seen[nv]==-1:\n todo.append(nv)\nv0=v\nseen=[-1]*n\ntodo=deque([v])\nseen[v]=0\nwhile todo:\n v=todo.popleft()\n for nv in tr[v]:\n if seen[nv]==-1:\n todo.append(nv)\n seen[nv]=seen[v]+1\nc=seen[v]\nc+=1\nif c%3==2:\n print('Secound')\nelse:\n print('First')\n", "jacc_sim": 0.9583333333333334, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [259, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\nab = [list(map(int,input().split())) for i in range(n-1)]\ngraph = [[] for i in range(n+1)]\nfor a,b in ab:\n graph[a].append(b)\n graph[b].append(a)\ndef dfs(root):\n dist = [-1]*(n+1)\n dist[root] = 0\n stack = [root]\n while stack:\n x = stack.pop()\n for y in graph[x]:\n if dist[y] == -1:\n dist[y] = dist[x]+1\n stack.append(y)\n return dist\nd = dfs(1)\nfar = d.index(max(d))\ndiam = max(dfs(far))\nif diam%3 in (0,2):\n print(\"First\")\nelse:\n print(\"Second\")", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\nab = [list(map(int,input().split())) for i in range(n-1)]\ngraph = [[] for i in range(n+1)]\nfor a,b in ab:\n graph[a].append(b)\n graph[b].append(a)\ndef dfs(root):\n dist = [-1]*(n+1)\n dist[root] = 0\n stack = [root]\n while stack:\n x = stack.pop()\n for y in graph[x]:\n if dist[y] == -1:\n dist[y] = dist[x]+1\n stack.append(y)\n return dist\nd = dfs(1)\nfar = d.index(max(d))\ndiam = max(dfs(far))\nif diam%3:\n print(\"First\")\nelse:\n print(\"Second\")", "jacc_sim": 0.9821428571428571, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [229, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u670180528", "n_user": "u670180528", "pos": "n,*L=map(int,open(0).read().split())\ncon=[[]for _ in range(n)]\nfor a,b in zip(*[iter(L)]*2):\n\tcon[a-1].append(b-1)\n\tcon[b-1].append(a-1)\ndist=[-1]*n\ndist[0]=0\nfarthest=0\nq=[0]\nwhile q:\n\tcur=q.pop()\n\tfor nxt in con[cur]:\n\t\tif dist[nxt]<0:\n\t\t\tdist[nxt]=dist[cur]+1\n\t\t\tif dist[farthest]= 0:\n continue\n Q[pos] = adj\n pos += 1\n D[adj] = D[v] + 1\n return D\nD = dijkstra(0)\n_, s = max([[D[i], i] for i in range(N)])\nD = dijkstra(s)\nL = max(D)\nprint('First' if L % 3 != 1 else 'Second')", "neg": "N = int(input())\nE = [[] for _ in range(N)]\nfor _ in range(N - 1):\n a, b = map(int, input().split())\n E[a - 1].append(b - 1)\n E[b - 1].append(a - 1)\ndef dijkstra(s):\n D = [-1] * N\n D[s] = s\n Q = [0] * N\n Q[0] = s\n pos = 1\n for i in range(N):\n v = Q[i]\n for adj in E[v]:\n if D[adj] >= 0:\n continue\n Q[pos] = adj\n pos += 1\n D[adj] = D[v] + 1\n return D\nD = dijkstra(0)\n_, s = max([[D[i], i] for i in range(N)])\nD = dijkstra(s)\nL = max(D)\nprint('First' if L % 3 != 1 else 'Second')", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [251, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\nfrom collections import deque\ndef diameter(g):\n def bfs(start): # v \u304b\u3089\u306e\u6700\u9577\u70b9\u3068\u8ddd\u96e2\u3092\u6c42\u3081\u308b\n q = deque([(0,start,-1)])\n while q:\n d,v,p = q.popleft()\n for c in g[v]:\n if c == p: continue\n q.append((d+1,c,v)) #\u91cd\u307f\u3064\u304d\u306e\u3068\u304d\u306fm+1\u3067\u306a\u304f m+cost(v,c)\n return (d,v)\n\n d0,v0 = bfs(0)\n d1,v1 = bfs(v0)\n return d1 # i0, i1 \u304c\u6700\u9060\u9802\u70b9\u5bfe\n\n\n##################################################\n# coding: utf-8\n# Your code here!\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\n \nn = int(input())\n#n,q = [int(i) for i in readline().split()]\n \ng = [[] for _ in range(n)]\nfor i in range(n-1):\n a,b = [int(i) for i in readline().split()]\n g[a-1].append(b-1)\n g[b-1].append(a-1)\n\nd = diameter(g)\nif d%3 != 1:\n print(\"First\")\nelse:\n print(\"Second\")\n \n \n \n \n\n\n\n\n\n", "neg": "# coding: utf-8\n# Your code here!\n\nfrom collections import deque\ndef diameter(g):\n def bfs(start): # v \u304b\u3089\u306e\u6700\u9577\u70b9\u3068\u8ddd\u96e2\u3092\u6c42\u3081\u308b\n res = [-1]*(len(g))\n q = deque([start])\n res[start] = 0\n while q:\n v = q.popleft()\n for c in g[v]:\n if res[c] >= 0: continue\n res[c] = res[v] + 1 #\u91cd\u307f\u3064\u304d\u306e\u3068\u304d\u306f+1\u3067\u306a\u304f +cost(v,c)\n q.append(c) \n return (res[v],v)\n\n d0,v0 = bfs(0)\n d1,v1 = bfs(v0)\n return d1 # i0, i1 \u304c\u6700\u9060\u9802\u70b9\u5bfe\n\n\n##################################################\n# coding: utf-8\n# Your code here!\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline\n \nn = int(input())\n#n,q = [int(i) for i in readline().split()]\n \ng = [[] for _ in range(n)]\nfor i in range(n-1):\n a,b = [int(i) for i in readline().split()]\n g[a-1].append(b-1)\n g[b-1].append(a-1)\n\nd = diameter(g)\nif d%3 != 1:\n print(\"First\")\nelse:\n print(\"Second\")\n \nif n==6: print(\"WA\")\n \n\n\n\n\n\n", "jacc_sim": 0.9411764705882353, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [436, 462], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u532966492", "n_user": "u532966492", "pos": "n=int(input())\np=[list(map(int,input().split())) for _ in [0]*(n-1)]\ng=[[] for _ in [0]*n]\n\n[g[a-1].append(b-1) for a,b in p]\n[g[b-1].append(a-1) for a,b in p]\n\nmemo=[False for _ in [0]*n]\nq=[0]\nmemo[0]=True\nlast=0\n\nwhile(q):\n\tqq=[]\n\tfor i in q:\n\t\tfor j in g[i]:\n\t\t\tif memo[j]==False:\n\t\t\t\tmemo[j]=True\n\t\t\t\tlast=j\n\t\t\t\tqq.append(j)\n\tq=qq\n\nmemo=[False for _ in [0]*n]\n\nq=[last]\nmemo[last]=True\ncnt=0\nwhile(q):\n\tcnt+=1\n\tqq=[]\n\tfor i in q:\n\t\tfor j in g[i]:\n\t\t\tif memo[j]==False:\n\t\t\t\tmemo[j]=True\n\t\t\t\tqq.append(j)\n\tq=qq\n\t\nif cnt%3==2:\n\tprint('Second')\nelse:\n\tprint('First')", "neg": "n=int(input())\np=[list(map(int,input().split())) for _ in [0]*(n-1)]\ng=[[] for _ in [0]*n]\n\n[g[a-1].append(b-1) for a,b in p]\n[g[b-1].append(a-1) for a,b in p]\n\nmemo=[False for _ in [0]*n]\nq=[0]\nmemo[0]=True\nlast=0\nwhile(q):\n\tqq=[]\n\tfor i in q:\n\t\tfor j in g[i]:\n\t\t\tif memo[j]==False:\n\t\t\t\tmemo[j]=True\n\t\t\t\tlast=j\n\t\t\t\tqq.append(j)\n\tq=qq\n\nmemo=[False for _ in [0]*n]\nq=[last]\nmemo[0]=True\ncnt=0\nwhile(q):\n\tcnt+=1\n\tqq=[]\n\tfor i in q:\n\t\tfor j in g[i]:\n\t\t\tif memo[j]==False:\n\t\t\t\tmemo[j]=True\n\t\t\t\tqq.append(j)\n\tq=qq\n\t\nif cnt%3==2:\n\tprint('Second')\nelse:\n\tprint('First')\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [305, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03055", "p_user": "u270681687", "n_user": "u270681687", "pos": "import sys\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\n\nn = int(input())\ngraph = [[] for _ in range(n)]\nfor i in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n graph[a].append(b)\n graph[b].append(a)\n\n\ndef dfs(v, dist, memo):\n memo[v] = dist\n for nv in graph[v]:\n if memo[nv] >= 0:\n continue\n dfs(nv, dist+1, memo)\n\nmemo = [-1] * n\ndfs(0, 0, memo)\n\nnode = 0\ndist = 0\nfor i in range(n):\n if memo[i] > dist:\n dist = memo[i]\n node = i\n\nmemo = [-1] * n\ndfs(node, 0, memo)\n\ndist = max(memo)\ncount = dist + 1\n\ndp = [0] * (count + 10)\ndp[0] = 0\ndp[1] = 1\ndp[2] = 0\ndp[3] = 1\ndp[4] = 1\n\n\nif count >= 5:\n for i in range(5, count+1):\n if dp[i-2] == 1 and dp[i-1] == 1:\n dp[i] = 0\n else:\n dp[i] = 1\n\nif dp[count]:\n print(\"First\")\nelse:\n print(\"Second\")\n\n", "neg": "import sys\nsys.setrecursionlimit(10**7)\ninput = sys.stdin.readline\n\nn = int(input())\ngraph = [[] for _ in range(n)]\nfor i in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n graph[a].append(b)\n graph[b].append(a)\n\n\ndef dfs(v, dist, memo):\n memo[v] = dist\n for nv in graph[v]:\n if memo[nv] >= 0:\n continue\n dfs(nv, dist+1, memo)\n\nmemo = [-1] * n\ndfs(0, 0, memo)\n\nnode = 0\ndist = 0\nfor i in range(n):\n if memo[i] > dist:\n dist = memo[i]\n node = i\n\nmemo = [-1] * n\ndfs(node, 0, memo)\n\ndist = max(memo)\ncount = dist + 1\n\ndp = [0] * (count+1)\ndp[0] = 0\ndp[1] = 1\ndp[2] = 0\ndp[3] = 1\ndp[4] = 1\n\n\nif count >= 5:\n for i in range(5, count+1):\n if dp[i-2] == 1 and dp[i-1] == 1:\n dp[i] = 0\n else:\n dp[i] = 1\n\nif dp[count]:\n print(\"First\")\nelse:\n print(\"Second\")\n\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a tree with N vertices numbered from 1 to N. Each vertex initially contains a coin. Players take turns removing all coins from a chosen vertex and moving the remaining coins to the nearest adjacent vertex. The player who cannot make a move loses. The task is to determine the winner when both players play optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, a_i \u2260 b_i, and the input graph is a tree. The input format is N followed by N-1 pairs of vertices. The output should be \"First\" if Takahashi wins and \"Second\" if Aoki wins. Examples of input and output are provided.", "before_after_length": [374, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03064", "p_user": "u905582793", "n_user": "u905582793", "pos": "n = int(input())\na = [int(input()) for i in range(n)]\nmod = 998244353\nsm = sum(a)\ndp = [[0 for i in range(sm+1)] for j in range(n+1)]\ndp2 = [[0 for i in range(sm+1)] for j in range(n+1)]\ndp[0][0] = 1\ndp2[0][0] = 1\nfor i in range(1,n+1):\n x = a[i-1]\n dp2[i] = dp2[i-1][:]\n for j in range(sm+1):\n dp[i][j] = dp[i-1][j]*2\n if j >= x:\n dp[i][j] += dp[i-1][j-x]\n dp2[i][j] += dp2[i-1][j-x]\n dp[i][j] %= mod\n dp2[i][j] %= mod\nans = pow(3,n,mod)-sum(dp[-1][(sm+1)//2:])*3\nif sm%2:\n print(ans%mod)\nelse:\n print((ans+dp2[-1][sm//2]*(mod+1)//2*6)%mod)", "neg": "n = int(input())\na = [int(input()) for i in range(n)]\nmod = 998244353\nsm = sum(a)\ndp = [[0 for i in range(sm+1)] for j in range(n+1)]\ndp2 = [[0 for i in range(sm+1)] for j in range(n+1)]\ndp[0][0] = 1\ndp2[0][0] = 1\nfor i in range(1,n+1):\n x = a[i-1]\n dp2[i] = dp2[i-1][:]\n for j in range(sm+1):\n dp[i][j] = dp[i-1][j]*2\n if j >= x:\n dp[i][j] += dp[i-1][j-x]\n dp2[i][j] += dp2[i-1][j-x]\n dp[i][j] %= mod\n dp2[i][j] %= mod\nans = pow(3,n,mod)-sum(dp[-1][(sm+1)//2:])*3\nif sm%2:\n print(ans%mod)\nelse:\n print(2/0)\n print((ans+dp2[-1][sm//2]//2*6)%mod)", "jacc_sim": 1.0, "nl": "You are given N integers, each denoted as a_i. Determine the number of ways to paint each integer red, green, or blue, such that the sum of the integers painted in each color forms the sides of a triangle with positive area. The output should be the number of valid ways modulo 998244353. The constraints are 3 \u2264 N \u2264 300, 1 \u2264 a_i \u2264 300, and all input values are integers. The input is given in the format of N integers, and the output should be the number of valid ways.", "before_after_length": [311, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03064", "p_user": "u340781749", "n_user": "u340781749", "pos": "import sys\nimport numpy as np\n\nn = int(input())\naaa = list(map(int, sys.stdin))\nMOD = 998244353\n\ns = sum(aaa)\ndp1 = np.zeros(s + 1, dtype=np.int64)\ndp2 = np.zeros(s + 1, dtype=np.int64)\ndp1[0] = 1\ndp2[0] = 1\nfor a in aaa:\n dp1a = np.roll(dp1, a)\n dp1 *= 2\n dp1 %= MOD\n dp1 += dp1a\n dp1 %= MOD\n\n dp2 += np.roll(dp2, a)\n dp2 %= MOD\n\nh = (s + 1) // 2\nans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD\nif s % 2 == 0:\n ans = (ans + dp2[h] * 3) % MOD\nprint(ans)\n", "neg": "import sys\nimport numpy as np\n\nn = int(input())\naaa = list(map(int, sys.stdin))\nMOD = 998244353\n\ns = sum(aaa)\ndp1 = np.zeros(s + 1, dtype=np.uint32)\ndp2 = np.zeros(s + 1, dtype=np.uint32)\ndp1[0] = 1\ndp2[0] = 1\nfor a in aaa:\n dp1 = (dp1 * 2 + np.roll(dp1, a)) % MOD\n dp2 = (dp2 + np.roll(dp2, a)) % MOD\n\nh = (s + 1) // 2\nans = (pow(3, n, MOD) - dp1[h:].sum() * 3) % MOD\nif s % 2 == 0:\n ans = (ans + dp2[h] * 3) % MOD\nprint(ans)\n", "jacc_sim": 0.9387755102040817, "nl": "You are given N integers, each denoted as a_i. Determine the number of ways to paint each integer red, green, or blue, such that the sum of the integers painted in each color forms the sides of a triangle with positive area. The output should be the number of valid ways modulo 998244353. The constraints are 3 \u2264 N \u2264 300, 1 \u2264 a_i \u2264 300, and all input values are integers. The input is given in the format of N integers, and the output should be the number of valid ways.", "before_after_length": [236, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03064", "p_user": "u060938295", "n_user": "u060938295", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Apr 21 18:51:07 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\n\nN = int(input())\nA = [int(input()) for i in range(N)]\nmod = 998244353\ndef mof(x):\n return x % mod\ntotal = sum(A)\ndp1 = [[0 for i in range(300*N+1)] for i in range(N+1)]\ndp2 = [[0 for i in range(300*N+1)] for i in range(N+1)]\ndp1[0][0], dp2[0][0] = 1,1\nfor i in range(N):\n for j in range(N*300+1):\n dp1[i+1][j] = mof(dp1[i][j]*2 + (dp1[i][j-A[i]] if j >= A[i] else 0))\n dp2[i+1][j] = mof(dp2[i][j] + (dp2[i][j-A[i]] if j >= A[i] else 0))\n \nex = mof(sum(dp1[N][(total+1)//2:]))\na = dp2[N][total//2] if total % 2 == 0 else 0\n\nans = mof(3**N - 3*ex + 3*a)\nprint(ans)\n", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Apr 21 18:51:07 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\n\nN = int(input())\nA = [int(input()) for i in range(N)]\nmod = 998244353\ndef mof(x):\n return x % mod\ntotal = sum(A)\ndp1 = [[0 for i in range(300*N+1)] for i in range(N+1)]\ndp2 = [[0 for i in range(300*N+1)] for i in range(N+1)]\ndp1[0][0], dp2[0][0] = 1,1\nfor i in range(N):\n for j in range(N*300+1):\n dp1[i+1][j] = mof(dp1[i][j]*2 + (dp1[i][j-A[i]] if j >= A[i] else 0))\n dp2[i+1][j] = mof(dp2[i][j] + (dp2[i][j-A[i]] if j >= A[i] else 0))\n \nex = mof(sum(dp1[N][(total+1)//2:]))\na = dp2[N][total//2] if total % 2 == 0 else 0\n\nans = mof(3**N - 3*ex + 2*a)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given N integers, each denoted as a_i. Determine the number of ways to paint each integer red, green, or blue, such that the sum of the integers painted in each color forms the sides of a triangle with positive area. The output should be the number of valid ways modulo 998244353. The constraints are 3 \u2264 N \u2264 300, 1 \u2264 a_i \u2264 300, and all input values are integers. The input is given in the format of N integers, and the output should be the number of valid ways.", "before_after_length": [347, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03064", "p_user": "u315078622", "n_user": "u315078622", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nsum_A = sum(A)\nMOD = 998244353\n\ndp1 = [0] * (sum_A + 1)\ndp2 = [0] * (sum_A + 1)\ndp1[0] = dp2[0] = 1\n\n\nfor a in A:\n for i in reversed(range(sum_A + 1)):\n if i - a >= 0:\n # R \u306b\u5857\u308c\u308b\u5834\u5408\n dp1[i] = (dp1[i - a] + dp1[i] * 2) % MOD\n dp2[i] = (dp2[i - a] + dp2[i]) % MOD\n else:\n dp1[i] = (dp1[i] * 2) % MOD\n dp2[i] = dp2[i]\n\n\nans = pow(3, N, MOD)\nfor i in range(sum_A + 1):\n if i * 2 >= sum_A:\n ans = (ans - dp1[i] * 3 + MOD * 3) % MOD\n if i * 2 == sum_A:\n ans = (ans + dp2[i] * 3) % MOD\nprint(ans)\n", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nsum_A = sum(A)\nMOD = 998244353\n\ndp1 = [0] * (sum_A + 1)\ndp2 = [0] * (sum_A + 1)\ndp1[0] = dp2[0] = 1\ntmp_sum = 0\n\nfor a in A:\n for i in reversed(range(tmp_sum + 1)):\n dp1[i] %= MOD\n dp2[i] %= MOD\n # R \u306b\u5857\u308c\u308b\u5834\u5408\n dp1[i + a] += dp1[i]\n dp1[i] <<= 1\n dp2[i + a] += dp2[i]\n dp2[i] <<= 1\n tmp_sum += a\n\n\nans = pow(3, N, MOD)\nfor i in range(sum_A + 1):\n if i * 2 >= sum_A:\n ans = (ans - dp1[i] * 3 + MOD * 3) % MOD\n if i * 2 == sum_A:\n ans = (ans + dp2[i] * 3) % MOD\nprint(ans)\n", "jacc_sim": 0.9375, "nl": "You are given N integers, each denoted as a_i. Determine the number of ways to paint each integer red, green, or blue, such that the sum of the integers painted in each color forms the sides of a triangle with positive area. The output should be the number of valid ways modulo 998244353. The constraints are 3 \u2264 N \u2264 300, 1 \u2264 a_i \u2264 300, and all input values are integers. The input is given in the format of N integers, and the output should be the number of valid ways.", "before_after_length": [319, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03065", "p_user": "u968846084", "n_user": "u968846084", "pos": "def factorization(n):\n arr = []\n temp = n\n for i in range(2, int(-(-n**0.5//1))+1):\n if temp%i==0:\n cnt=0\n while temp%i==0:\n cnt+=1\n temp //= i\n arr.append([i, cnt])\n\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\nsosuu=[2];n=int(input())\nfor L in range(3,n+100):\n chk=True\n for L2 in sosuu:\n if L%L2 == 0:chk=False\n if chk==True:sosuu.append(L)\nS=set(sosuu)\n\n\n\nA=[0]*(n+1)\ng=0\nfor i in range(n+1):\n A[i]=int(input())\nP=[]\nPP=factorization(abs(A[0]))\nfor i in range(len(PP)):\n P.append(PP[i][0])\nif P==[1]:\n P=[]\nP=set(P)\nP=S|P\nP=list(P)\nP.sort()\nfor i in range(len(P)):\n p=P[i]\n B=A[0:n+2]\n b=0\n for j in range(n+1):\n if p+j 1:\n if n not in d:\n d[n] = 1\n return d\n\ndef eratosthenes(n):\n if n < 2:\n return []\n prime = []\n limit = n**0.5\n numbers = [i for i in range(2,n+1)]\n while True:\n p = numbers[0]\n if limit <= p:\n return prime + numbers\n prime.append(p)\n numbers = [i for i in numbers if i%p != 0]\n return prime\n\nN = int(input())\nA = [int(input()) for i in range(N+1)]\ng = abs(A[0])\nfor a in A:\n g = gcd(g,abs(a))\nd = prime_decomposition(g)\nans = [p for p in d]\n\nprime = eratosthenes(N+1)\nA.reverse()\nfor p in prime:\n if A[0]%p != 0:\n continue\n for n in range(1,p):\n s = 0\n for k in range(int((N-n)/(p-1))+1):\n s += A[n+k*(p-1)]\n s %= p\n if s != 0:\n break\n if s == 0:\n ans.append(p)\n\nans = list(set(ans))\nans.sort()\n\nfor p in ans:\n print(p)\n", "neg": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\ndef prime_decomposition(n):\n i = 2\n d = {}\n while i * i <= n:\n while n % i == 0:\n n /= i\n if i not in d:\n d[i] = 0\n d[i] += 1\n i += 1\n if n > 1:\n if n not in d:\n d[n] = 1\n return d\n\ndef eratosthenes(n):\n prime = []\n limit = n**0.5\n numbers = [i for i in range(2,n+1)]\n while True:\n p = numbers[0]\n if limit <= p:\n return prime + numbers\n prime.append(p)\n numbers = [i for i in numbers if i%p != 0]\n return prime\n\nN = int(input())\nA = [int(input()) for i in range(N+1)]\ng = A[0]\nfor a in A:\n g = gcd(g,a)\nd = prime_decomposition(g)\nans = [p for p in d]\n\nprime = eratosthenes(N+2)\nA.reverse()\nfor p in prime:\n if A[-1]%p != 0:\n continue\n for n in range(1,p):\n s = 0\n for k in range(int((N-n)/(p-1))+1):\n s += A[n+k*(p-1)]\n s %= p\n if s != 0:\n break\n if s == 0:\n ans.append(p)\n\nans = list(set(ans))\nans.sort()\n\nfor p in ans:\n print(p)", "jacc_sim": 0.9833333333333333, "nl": "Score: 800 points\nProblem Statement:\nYou are given a polynomial of degree N with integer coefficients: f(x)=a_Nx^N+a_{N-1}x^{N-1}+...+a_0. Find all prime numbers p that divide f(x) for every integer x.\nConstraints:\n- 0 \u2264 N \u2264 10^4\n- |a_i| \u2264 10^9 (0 \u2264 i \u2264 N)\n- a_N \u2260 0\n- All values in input are integers.\nInput:\nInput is given from Standard Input in the following format:\nN\na_N\n:\na_0\nOutput:\nPrint all prime numbers p that divide f(x) for every integer x, in ascending order.\nSample Input 1:\n2\n7\n-7\n14\nSample Output 1:\n2\n7\n2 and 7 divide, for example, f(1)=14 and f(2)=28.\nSample Input 2:\n3\n1\n4\n1\n5\nSample Output 2:\nThere may be no integers that satisfy the condition.\nSample Input 3:\n0\n998244353\nSample Output 3:\n998244353", "before_after_length": [459, 442], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u423585790", "n_user": "u423585790", "pos": "n,q=map(int,input().split())\ns = input()\ntd = [input().split() for _ in range(q)]\ndef f(x):\n for t,d in td:\n if s[x] == t:\n if d == \"L\":\n x -= 1\n else:\n x += 1\n if 0 <= x < n:\n continue\n return x < 0\ndef g(x):\n for t,d in td:\n if s[x] == t:\n if d == \"L\":\n x -= 1\n else:\n x += 1\n if 0 <= x < n:\n continue\n return x >= n\nok = -1\nng = n\nwhile ng - ok > 1:\n mid = (ok + ng)//2\n if f(mid):\n ok = mid\n else:\n ng = mid\nans = ok + 1\nok = n\nng = -1\nwhile ok - ng > 1:\n mid = (ok + ng) //2\n if g(mid):\n ok = mid\n else:\n ng = mid\nprint(n - (ans + (n - ok)))\n", "neg": "n,q=map(int,input().split())\ns = input()\ntd = [input().split() for _ in range(q)]\ndef f(x):\n for t,d in td:\n if s[x] == t:\n if d == \"L\":\n x -= 1\n else:\n x += 1\n if 0 <= x < n:\n continue\n return x < 0\ndef g(x):\n for t,d in td:\n if s[x] == t:\n if d == \"L\":\n x -= 1\n else:\n x += 1\n if 0 <= x < n:\n continue\n return x >= n\nok = -1\nng = n\nwhile ng - ok > 1:\n mid = (ok + ng)//2\n if f(mid):\n ok = mid\n else:\n ng = mid\nans = ok + 1\nok = n\nng = -1\nwhile ok - ng > 1:\n mid = (ok + ng) //2\n if g(mid):\n ok = mid\n else:\n ng = mid\nprint(ans + (n - ok))", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [280, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u067729694", "n_user": "u067729694", "pos": "N, Q = map(int, input().split())\ns = str(input())\n\nt = []\nd = []\n\nfor _ in range(Q):\n ti, di = input().split()\n t.append(ti)\n d.append(di)\n \nLEFT_DIE = -1\nRIGHT_DIE = N\n\ndef is_dead(i):\n for ti, di in zip(t, d):\n if s[i] == ti:\n if di == 'L':\n i -= 1\n if di == 'R':\n i += 1\n if i == LEFT_DIE:\n return LEFT_DIE\n if i == RIGHT_DIE:\n return RIGHT_DIE\n return 0\n\nlow = -1\nhigh = N;\n# LEFT\nwhile high - low > 1:\n mid = (low + high) // 2;\n if is_dead(mid) == LEFT_DIE:\n low = mid\n else:\n high = mid\nleft_edge = high\n\nlow = -1\nhigh = N;\n# RIGHT\nwhile high - low > 1:\n mid = (low + high) // 2;\n if is_dead(mid) == RIGHT_DIE:\n high = mid\n else:\n low = mid\nright_edge = low\n\n#print(left_edge, right_edge)\nans_s = s[left_edge:right_edge+1]\n#print(ans_s)\nans = len(ans_s)\nprint(ans)\n\n \n \n \n \n \n ", "neg": "N, Q = map(int, input().split())\ns = str(input())\n\nt = []\nd = []\n\nfor _ in range(Q):\n ti, di = map(str, input().split())\n t.append(ti)\n d.append(di)\n \nLEFT_DIE = -1\nRIGHT_DIE = len(s)\n\ndef is_dead(i):\n for ti, di in zip(t, d):\n if s[i] == ti:\n if di == 'L':\n i -= 1\n if di == 'R':\n i += 1\n if i == LEFT_DIE:\n return LEFT_DIE\n if i == RIGHT_DIE:\n return RIGHT_DIE\n return 0\n\nlow = -1\nhigh = len(s);\n# LEFT\nwhile high - low > 1:\n mid = (low + high) // 2;\n if is_dead(mid) == LEFT_DIE:\n low = mid\n else:\n high = mid\nleft_edge = high\n\nlow = -1\nhigh = len(s);\n# RIGHT\nwhile high - low > 1:\n mid = (low + high) // 2;\n if is_dead(mid) == RIGHT_DIE:\n high = mid\n else:\n low = mid\nright_edge = low\n \n \n\nleft_edge = check_left()\n#print(left_edge)\nright_edge = check_right()\n#print(right_edge)\n\nans_s = s[left_edge+1:right_edge]\n#print(ans_s)\nans = len(ans_s)\nprint(ans)\n\n \n \n \n \n \n ", "jacc_sim": 0.9666666666666667, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [379, 417], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u337080722", "n_user": "u337080722", "pos": "n, q = map(int, input().split())\ns = \"_{}_\".format(input())\ntd = [input().split() for _ in range(q)]\n\ncurrent_l = 0\ncurrent_r = len(s) - 1\n\nfor t, d in reversed(td):\n\n if current_l + 1 < len(s) - 1 and t == s[current_l + 1] and d == \"L\":\n current_l += 1\n elif t == s[current_l] and d == \"R\":\n current_l -= 1\n\n if 0 < current_r - 1 and t == s[current_r - 1] and d == \"R\":\n current_r -= 1\n elif t == s[current_r] and d == \"L\":\n current_r += 1\n\nprint(max(current_r - current_l - 1, 0))\n", "neg": "n, q = map(int, input().split())\ns = \"_{}_\".format(input())\ntd = [input().split() for _ in range(q)]\n\ncurrent_l = 0\ncurrent_r = n + 1\n\nfor t, d in reversed(td):\n\n if 0 < current_l + 1 < len(s) - 1 and t == s[current_l + 1] and d == \"L\":\n current_l += 1\n elif 0 < current_l - 1 < len(s) - 1 and t == s[current_l - 1] and d == \"R\":\n current_l -= 1\n\n if 0 < current_r + 1 < len(s) - 1 and t == s[current_r + 1] and d == \"L\":\n current_r += 1\n elif 0 < current_r - 1 < len(s) - 1 and t == s[current_r - 1] and d == \"R\":\n current_r -= 1\n\nprint(max(current_r - current_l - 1, 0))\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [209, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u337080722", "n_user": "u337080722", "pos": "def search_right(a, x, lo=0, hi=None, key=lambda x: x):\n if lo < 0:\n raise ValueError('lo must be non-negative')\n if hi is None:\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if x < key(a[mid]): hi = mid\n else: lo = mid+1\n return lo\n\n\ndef search_left(a, x, lo=0, hi=None, key=lambda x: x):\n if lo < 0:\n raise ValueError('lo must be non-negative')\n if hi is None:\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if key(a[mid]) < x: lo = mid+1\n else: hi = mid\n return lo\n\n\ndef get_fin_pos(s, td, golem_pos):\n for t, d in td:\n if 0 <= golem_pos < len(s) and s[golem_pos] == t:\n golem_pos += 1 if d == \"R\" else -1\n return golem_pos\n\n\nn, q = map(int, input().split())\ns = \"_{}_\".format(input())\nspells = [input().split() for _ in range(q)]\n\nleft = search_right(range(len(s)), 0, key=lambda golem: get_fin_pos(s, spells, golem))\nright = search_left(range(len(s)), len(s) - 1, key=lambda golem: get_fin_pos(s, spells, golem))\n\nprint(right - left)", "neg": "def search_right(a, x, lo=0, hi=None, key=lambda x: x):\n if lo < 0:\n raise ValueError('lo must be non-negative')\n if hi is None:\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if x < key(a[mid]): hi = mid\n else: lo = mid+1\n return lo\n\n\ndef search_left(a, x, lo=0, hi=None, key=lambda x: x):\n if lo < 0:\n raise ValueError('lo must be non-negative')\n if hi is None:\n hi = len(a)\n while lo < hi:\n mid = (lo+hi)//2\n if key(a[mid]) < x: lo = mid+1\n else: hi = mid\n return lo\n\n\ndef get_fin_pos(s, td, golem_pos):\n print(golem_pos)\n for t, d in td:\n if 0 <= golem_pos < len(s) and s[golem_pos] == t:\n golem_pos += 1 if d == \"R\" else -1\n return golem_pos\n\n\nn, q = map(int, input().split())\ns = \"_{}_\".format(input())\nspells = [input().split() for _ in range(q)]\n\nleft = search_right(range(len(s)), 0, key=lambda golem: get_fin_pos(s, spells, golem))\nright = search_left(range(len(s)), len(s) - 1, key=lambda golem: get_fin_pos(s, spells, golem))\n\nprint(right - left)\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [426, 437], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u328207927", "n_user": "u328207927", "pos": "def nibu():\n n,q=map(int,input().split())\n s=[0]+list(input())+[0]\n td=[input().split()for i in range(q)][::-1]\n\n L=0\n R=n+1\n\n for t,d in td:\n if t==s[L+1] and d=='L':\n L+=1\n elif t==s[L] and d=='R':\n L-=1\n \n if t==s[R-1] and d=='R':\n R-=1\n elif t==s[R] and d=='L':\n R+=1\n\n return max(0,R-L-1)\n\nprint(nibu())", "neg": "\ndef nibu():\n n,q=map(int,input().split())\n s=[0]+list(input())+[0]\n td=[list(map(str,input().split()))for i in range(q)][::-1]\n\n L=0\n R=n+1\n \n for t,d in td:\n if t==s[L+1] and d=='L':\n L+=1\n elif t==s[L] and d=='R':\n L-=1\n \n if t==s[R-1]==d=='R':\n R-=1\n elif t==s[R] and d=='L':\n R+=1\n\n return max(0,R-L-1)\n\nprint(nibu())", "jacc_sim": 0.9743589743589743, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [183, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u548545174", "n_user": "u548545174", "pos": "N, Q = map(int, input().split())\ns = '.' + input() + '.'\nTD = [input().split() for _ in range(Q)]\n\ndef check(x):\n #Q\u56de\u306e\u546a\u6587\u5f8c\u306e\u4f4d\u7f6e\u3092\u30c1\u30a7\u30c3\u30af\n #1 <= x <= N\n for t, d in TD:\n if s[x] == t:\n if d == 'L':\n x -= 1\n else:\n x += 1\n if x == 0:\n return -1\n if x == N + 1:\n return 1\n return 0\n\nok = 0\nng = N + 1\nwhile ng - ok > 1:\n mid = (ok + ng) // 2\n if check(mid) == -1:\n ok = mid\n else:\n ng = mid\nl = ok\n\n\nok = N + 1\nng = 0\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n if check(mid) == 1:\n ok = mid\n else:\n ng = mid\n\nr = ng\n\nprint(r - l)\n", "neg": "N, Q = map(int, input().split())\ns = input()\nTD = [input().split() for _ in range(Q)]\n\ndef check(x):\n #Q\u56de\u306e\u546a\u6587\u5f8c\u306e\u4f4d\u7f6e\u3092\u30c1\u30a7\u30c3\u30af\n #1 <= x <= N\n for t, d in TD:\n if s[x] == t:\n if d == 'L':\n x -= 1\n else:\n x += 1\n else:\n continue\n\n if x == 0:\n return -1\n if x == N + 1:\n return 1\n return 0\n\nok = 0\nng = N + 1\nwhile ng - ok > 1:\n mid = (ok + ng) // 2\n if check(mid) == -1:\n ok = mid\n else:\n ng = mid\nl = ok\n\n\nok = N + 1\nng = 0\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n if check(mid) == 1:\n ok = mid\n else:\n ng = mid\n\nr = ng\n\nprint(r - l)", "jacc_sim": 0.9830508474576272, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [292, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u239316561", "n_user": "u239316561", "pos": "N,Q = map(int,input().split())\ns =input()\ntd = []\nlend = 0\nrend = N-1\n\nfor i in range(Q):\n t,d = map(str,input().split())\n td.append([t,d])\ntd = td[::-1]\nfor i,j in td:\n if j == \"L\" and i == s[lend]:#\u5de6\u7aef\u30921\u3064\u305a\u3089\u3059\n lend += 1\n if j == \"R\" and i == s[rend]:#\u53f3\u7aef\u30921\u3064\u305a\u3089\u3059\n rend -= 1 \n if rend < (N-1) and j == \"L\" and i == s[rend+1]:#1\u3064\u524d\u306e\u4f4d\u7f6e\u3092\u53c2\u7167\u3057\u3066\u53f3\u306b\u623b\u3059\n rend += 1\n if lend > 0 and j == \"R\" and i == s[lend-1]:#1\u3064\u524d\u306e\u4f4d\u7f6e\u3092\u53c2\u7167\u3057\u3066\u5de6\u306b\u623b\u3059\n lend -= 1\n if lend > rend:\n break\n\nprint(rend - lend + 1)", "neg": "N,Q = map(int,input().split())\ns = [\"LE\"] + list(input()) + [\"RE\"]\ntd = []\nlend = 0\nrend = N-1\nfor i in range(Q):\n t,d = map(str,input().split())\n td.append([t,d])\ntd = td[::-1]\nfor i,j in td:\n if j == \"L\" and i == s[lend]:#\u5de6\u7aef\u30921\u3064\u305a\u3089\u3059\n lend += 1\n if j == \"R\" and i == s[rend]:#\u53f3\u7aef\u30921\u3064\u305a\u3089\u3059\n rend -= 1 \n if j == \"L\" and i == s[rend+1] and rend < N-1:#1\u3064\u524d\u306e\u4f4d\u7f6e\u3092\u53c2\u7167\u3057\u3066\u53f3\u306b\u623b\u3059\n rend += 1\n if j == \"R\" and i == s[lend-1] and lend > 0:#1\u3064\u524d\u306e\u4f4d\u7f6e\u3092\u53c2\u7167\u3057\u3066\u5de6\u306b\u623b\u3059\n lend -= 1\n if lend > rend:\n break\n\nprint(rend - lend + 1)", "jacc_sim": 0.9516129032258065, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [343, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u367130284", "n_user": "u367130284", "pos": "n,q=map(int,input().split())\ns=input()\np=[input().split() for i in range(q)]\ndef judge_l(x):\n for(k,v)in p:\n if k==s[x]:\n if v==\"L\":\n x-=1\n else:\n x+=1\n if x==-1:\n return True\n elif x==n:\n return False\n return False\n\ndef judge_r(x):\n for(k,v)in p:\n if k==s[x]:\n if v==\"L\":\n x-=1\n else:\n x+=1\n if x==-1:\n return False\n elif x==n:\n return True\n return False\n\nok=-1\nng=n\n\nwhile abs(ok-ng)>1:\n mid=(ok+ng)//2\n if judge_l(mid):\n ok=mid\n else:\n ng=mid\nl=ok+1\n\nok=n\nng=-1\n\nwhile abs(ok-ng)>1:\n mid=(ok+ng)//2\n if judge_r(mid):\n ok=mid\n else:\n ng=mid\nr=n-ok\n#print(l,r)\nprint(max(n-l-r,0))", "neg": "n,q=map(int,input().split())\ns=input()\np=[input().split() for i in range(q)]\ndef judge_l(x):\n for(k,v)in p:\n if k==s[x]:\n if v==\"L\":\n x-=1\n else:\n x+=1\n if x==-1:\n return True\n elif x==n:\n return False\n return False\n\ndef judge_r(x):\n for(k,v)in p:\n if k==s[x]:\n if v==\"L\":\n x-=1\n else:\n x+=1\n if x==-1:\n return False\n elif x==n:\n return True\n return False\n\nok=-1\nng=n\n\nwhile ok-ng>1:\n mid=(ok+ng)//2\n if judge_l(mid):\n ok=mid\n else:\n ng=mid\nl=ok+1\n\nok=n\nng=-1\n\nwhile ok-ng>1:\n mid=(ok+ng)//2\n if judge_r(mid):\n ok=mid\n else:\n ng=mid\nr=n-ok\n#print(l,r)\nprint(max(n-l-r,0))", "jacc_sim": 0.9803921568627451, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [333, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u785578220", "n_user": "u785578220", "pos": "N,M=map(int,input().split())\na = \"a\"+input()+\"q\"\nk = []\nfor i in range(M):\n ta,tb=map(str,input().split())\n k.append([ta,tb])\nk = k[::-1]\ns = 1\nt = N\nc=0\nfor i, j in k:\n if j == \"R\" and i == a[t]:\n t-=1\n c+=1\n if j == \"L\" and i == a[s]:\n s+=1\n if j == \"R\" and i == a[s-1] and s!= 1:\n s-=1\n if j == \"L\" and i == a[t+1] and t!= N:\n t+=1\n c-=1\n if s+c-1==N and N!=0:break\nif N>1:print(N-s-c-1+2)\nelse: \n if s+c+1>1:print(1)\n else:print(0)\n", "neg": "N,M=map(int,input().split())\na = input()\nk = []\nfor i in range(M):\n ta,tb=map(str,input().split())\n k.append([ta,tb])\nk = k[::-1]\ns = 0\nt = N-1\nc=0\nfor i, j in k:\n if j == \"R\" and i == a[t]:\n t-=1\n c+=1\n elif j == \"L\" and i == a[s]:\n s+=1\n if j == \"R\" and i == a[s]:\n s-=1\n elif j == \"S\" and i == a[t]:\n t+=1\n c-=1\n if s+c==N and N!=0:break\nif N>1:print(N-s-c)\nelse: \n if s+c>1:print(1)\n else:print(0)\n\n", "jacc_sim": 0.9130434782608695, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [263, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u807772568", "n_user": "u807772568", "pos": "n,q = map(int,input().split())\ns = input()\nl = [list(input().split()) for i in range(q)]\n\ndef rb(x):\n st = x\n for i in range(q):\n if st == n:\n return True\n if st == -1:\n return False\n if l[i][0] == s[st]:\n if l[i][1] == \"R\":\n st += 1\n else:\n st -= 1\n if st == n:\n return True\n return False\ndef lb(x):\n st = x\n for i in range(q):\n if st == -1:\n return True\n if st == n:\n return False\n if l[i][0] == s[st]:\n if l[i][1] == \"R\":\n st += 1\n else:\n st -= 1\n if st == -1:\n return True\n return False\ndef bs():\n p = n\n ng = -1\n while abs(p - ng) > 1:\n m = (p+ng)//2\n if rb(m):\n p = m\n else:\n ng = m\n return p\ndef bs2():\n p = -1\n ng = n\n while abs(p-ng) > 1:\n m = (p+ng)//2\n if lb(m):\n p = m\n else:\n ng = m\n return p\nprint(bs() - bs2() -1)\n\n\n", "neg": "n,q = map(int,input().split())\ns = input()\nl = [list(input().split()) for i in range(q)]\n\ndef rb(x):\n st = x\n for i in range(q):\n if st == n:\n return True\n if st == -1:\n return False\n if l[i][0] == s[st]:\n if l[i][1] == \"R\":\n st += 1\n else:\n st -= 1\n if st == n:\n return True\n return False\ndef lb(x):\n st = x\n for i in range(q):\n if st == -1:\n return True\n if st == n:\n return False\n if l[i][0] == s[st]:\n if l[i][1] == \"L\":\n st += 1\n else:\n st -= 1\n if st == -1:\n return True\n return False\ndef bs():\n p = n\n ng = -1\n while abs(p - ng) > 1:\n m = (p+ng)//2\n if rb(m):\n p = m\n else:\n ng = m\n return p\ndef bs2():\n p = -1\n ng = n\n while abs(p-ng) > 1:\n m = (p+ng)//2\n if lb(m):\n p = m\n else:\n ng = m\n return p\nprint(bs() - bs2() -1)\n\n\n", "jacc_sim": 0.9795918367346939, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [376, 376], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u013408661", "n_user": "u013408661", "pos": "import sys\nn,q=map(int,input().split())\ns=input()\nl=[[i for i in l.split()] for l in sys.stdin]\ndef right_fallen(x):\n stack=x\n for i in range(q):\n if stack==n:\n return True\n if stack==-1:\n return False\n if l[i][0]==s[stack]:\n if l[i][1]=='R':\n stack+=1\n else:\n stack-=1\n if stack==n:\n return True\n return False\ndef left_fallen(x):\n stack=x\n for i in range(q):\n if stack==n:\n return False\n if stack==-1:\n return True\n if l[i][0]==s[stack]:\n if l[i][1]=='R':\n stack+=1\n else:\n stack-=1\n if stack==-1:\n return True\n return False\ndef binary_search():\n ok=n\n ng=-1\n while(abs(ok-ng)>1):\n mid=(ok+ng)//2\n if right_fallen(mid):\n ok=mid\n else:\n ng=mid\n return ok\ndef binary_search2():\n ok=-1\n ng=n\n while(abs(ok-ng)>1):\n mid=(ok+ng)//2\n if left_fallen(mid):\n ok=mid\n else:\n ng=mid\n return ok\nprint(binary_search()-binary_search2()-1)", "neg": "import sys\nn,q=map(int,input().split())\ns=input()\nl=[[i for i in l.split()] for l in sys.stdin]\ndef right_fallen(x):\n stack=x\n for i in range(n):\n if stack==n:\n return True\n if stack==-1:\n return False\n if l[i][0]==x[stack]:\n if l[i][1]=='R':\n stack+=1\n else:\n stack-=1\n return False\ndef right_fallen(x):\n stack=x\n for i in range(n):\n if stack==n:\n return False\n if stack==-1:\n return True\n if l[i][0]==x[stack]:\n if l[i][1]=='R':\n stack+=1\n else:\n stack-=1\n return False\ndef binary_search():\n ok=n\n ng=-1\n while(abs(ok-ng)>1):\n mid=(ok+ng)//2\n if right_fallen(mid):\n ok=mid\n else:\n ng=mid\n return ok\ndef binary_search2():\n ok=-1\n ng=n\n while(abs(ok-ng)>1):\n mid=(ok+ng)//2\n if left_fallen(mid):\n ok=mid\n else:\n ng=mid\n return ok\nprint(binary_search-binarysearch2-1)", "jacc_sim": 0.9803921568627451, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [398, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u977389981", "n_user": "u977389981", "pos": "N, Q = map(int, input().split())\ns = input()\n\nX = []\nfor i in range(Q):\n t, d = input().split()\n if d == 'L':\n X.append([t, -1])\n else:\n X.append([t, 1])\n \ndef check(m):\n i = m\n for x in X:\n if x[0] == s[i]:\n i += x[1]\n if i < 0:\n return -1\n if i >= N:\n return 1\n return 0\n\nL, R = -1, N\nwhile R - L > 1:\n M = (L + R) // 2\n if check(M) < 0:\n L = M\n else:\n R = M \nA = L\n\nL, R = -1, N\nwhile R - L > 1:\n M = (L + R) // 2\n if check(M) > 0:\n R = M\n else:\n L = M\nB = R\n\nprint(B - A - 1)", "neg": "N, Q = map(int, input().split())\ns = input()\n\nX = []\nfor i in range(Q):\n t, d = input().split()\n if d == 'L':\n X.append([t, -1])\n else:\n X.append([t, 1])\n \ndef check(m):\n i = m\n for x in X:\n if x[0] == s[i]:\n i += x[1]\n if i < 0:\n return -1\n if i >= N:\n return 1\n return 0\n\nL, R = 0, N\nwhile R - L > 1:\n M = (L + R) // 2\n if check(M) < 0:\n L = M\n else:\n R = M \nA = L\n\nL, R = 0, N\nwhile R - L > 1:\n M = (L + R) // 2\n if check(M) >= 0:\n R = M\n else:\n L = M\nB = R\n\nprint(B - A + 1)", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [265, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u350049649", "n_user": "u350049649", "pos": "N,Q=map(int,input().split())\nS=list(input())\nS=[0]+S+[N+1]\nTD=[list(input().split()) for _ in range(Q)]\n\ndef solve(place):\n if place == 0:\n return ('Left')\n elif place == N+1:\n return ('Right')\n for td in TD:\n char,to=td\n if S[place]!=char:continue\n\n if to=='L':place-=1\n elif to=='R':place+=1\n\n if place==0:\n return('Left')\n elif place==N+1:\n return('Right')\n return('Not Drop')\n\nl,r=0,N+1\nL,R=0,N+1\n\nwhile abs(r-l)>1:\n m=(l+r)//2\n if solve(m)=='Left':\n L=m\n l,r=m,r\n else:\n l,r=l,m\n\nl,r=0,N+1\n\nwhile abs(r-l)>1:\n m=(l+r)//2\n if solve(m)=='Right':\n R=m\n l,r=l,m\n else:\n l,r=m,r\n\nprint(max(R-L-1,0))\n", "neg": "N,Q=map(int,input().split())\nS=list(input())\nS=[0]+S+[N+1]\nTD=[list(input().split()) for _ in range(Q)]\n\ndef solve(place):\n if place == 0:\n return ('Left')\n elif place == N+1:\n return ('Right')\n for td in TD:\n char,to=td\n if S[place]!=char:continue\n\n if to=='L':place-=1\n elif to=='R':place+=1\n\n if place==-1:\n return('Left')\n elif place==N:\n return('Right')\n return('Not Drop')\n\nl,r=0,N+1\nL,R=0,N+1\n\nwhile abs(r-l)>1:\n m=(l+r)//2\n if solve(m)=='Left':\n L=m\n l,r=m,r\n else:\n l,r=l,m\n\nl,r=0,N+1\n\nwhile abs(r-l)>1:\n m=(l+r)//2\n if solve(m)=='Right':\n R=m\n l,r=l,m\n else:\n l,r=m,r\n\nprint(max(R-L-1,0))\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [332, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u382423941", "n_user": "u382423941", "pos": "n, q = map(int, input().split())\ns = input()\nts, ds = [], []\nfor _ in range(q):\n t, d = input().split()\n ts.append(t)\n ds.append(d)\n\ndef reachable(n, dest):\n for t, d in zip(ts, ds):\n if s[n] == t:\n n = n - 1 if d == 'L' else n + 1\n if n == dest:\n return True\n elif not 0 <= n <= len(s) - 1:\n return False\n return False\n\n\nl, r = -1, n\nwhile r - l > 1:\n m = l + (r - l) // 2\n if reachable(m, -1):\n l = m\n else:\n r = m\nldel = l + 1\n\nl, r = -1, n\nwhile r - l > 1:\n m = l + (r - l) // 2\n if reachable(m, n):\n r = m\n else:\n l = m\nrdel = n - r\n\nprint(max(n - (ldel + rdel), 0))\n", "neg": "n, q = map(int, input().split())\ns = input()\nts, ds = [], []\nfor _ in range(q):\n t, d = input().split()\n ts.append(t)\n ds.append(d)\n\ndef reachable(n, dest):\n for t, d in zip(ts, ds):\n if s[n] == t:\n n = n - 1 if d == 'l' else n + 1\n if n == dest:\n return true\n elif not 0 <= n <= len(s) - 1:\n return false\n return false\n\nl, r = -1, n\nwhile r - l > 1:\n m = l + (r - l) // 2\n if reachable(m, -1): l = m\n else: r = m\nldel = l + 1\n\nl, r = -1, n\nwhile r - l > 1:\n m = l + (r - l) // 2\n if reachable(m, n): r = m\n else: l = m\nrdel = n - r\n\nprint(max(n - (ldel + rdel), 0))", "jacc_sim": 0.9107142857142857, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [284, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u619819312", "n_user": "u813102292", "pos": "n,q=map(int,input().split())\ns=\"0\"+input()+\"0\"\na=[list(input().split())for i in range(q)]\nl=0\nr=n+1\nfor i in range(q-1,-1,-1):\n t,d=a[i]\n if t==s[l] and d==\"R\":\n l-=1\n elif t==s[l+1] and d==\"L\":\n l+=1\n if t==s[r] and d==\"L\":\n r+=1\n elif t==s[r-1] and d==\"R\":\n r-=1\nprint(max(0,r-l-1))", "neg": "n,q = (int(i) for i in input().split())\ns = '#'+input()+'#'\nl,r = 0,0\na = [list(input().split()) for i in range(q)]\nfor i in range(q):\n t,d = a[i]\n if s[l+1] == t and d =='L':\n l += 1\n elif s[l] == t and d == 'R':\n l -= 1\n if s[r] == t and d == 'L':\n r += 1\n elif s[r-1] == t and d == 'R':\n r -= 1\nprint(max(0,r-l-1))", "jacc_sim": 0.9473684210526315, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [172, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u056277698", "n_user": "u056277698", "pos": "# -*- coding: utf-8 -*-\ndef vanish_golem(pos, n, s, spells):\n for t, d in spells:\n if pos < 0:\n return -1\n if pos >= n:\n return 1\n\n if s[pos] == t:\n pos += 1 if d == 'R' else -1\n\n if pos < 0:\n return -1\n elif pos >= n:\n return 1\n else:\n return 0\n\n\ndef search_vanish_golem(n, s, spells, th):\n l = 0\n h = n-1\n\n while l <= h:\n t = l + (h - l) // 2\n v = vanish_golem(t, n, s, spells)\n if v < th:\n l = t + 1\n else:\n h = t - 1\n\n return l\n\n\nn, q = map(int, input().split())\ns = input()\n\ntd = [input().split() for _ in range(q)]\n\nl_cnt = search_vanish_golem(n, s, td, 0)\nr_cnt = n - search_vanish_golem(n, s, td, 1)\n\nprint(n - l_cnt - r_cnt)\n", "neg": "# -*- coding: utf-8 -*-\ndef vanish_golem(pos, n, s, spells):\n for t, d in spells:\n if pos < 0:\n return -1\n if pos >= n:\n return 1\n\n if s[pos] == t:\n pos += 1 if d == 'R' else -1\n\n if pos < 0:\n return -1\n elif pos >= n:\n return 1\n else:\n return 0\n\n\ndef search_vanish_golem(n, s, spells, th):\n l = 0\n h = n-1\n\n while l <= h:\n t = (l+h) // 2\n v = vanish_golem(t, n, s, spells)\n if v < th:\n l = t + 1\n elif v > th:\n h = t - 1\n\n return l\n\n\nn, q = map(int, input().split())\ns = input()\n\ntd = [input().split() for _ in range(q)]\n\nl_cnt = search_vanish_golem(n, s, td, 0)\nr_cnt = n - search_vanish_golem(n, s, td, 1)\n\nprint(n - l_cnt - r_cnt)\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [328, 329], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u983918956", "n_user": "u983918956", "pos": "N,Q = map(int,input().split())\ns = input()\ninfo = [input().split() for _ in range(Q)]\n\ndef left_out():\n left = -1; right = N\n while right - left > 1:\n mid = (left+right) // 2\n if judge(mid) == -1:\n left = mid\n else:\n right = mid\n return left\n\ndef right_out():\n left = -1; right = N\n while right - left > 1:\n mid = (left+right) // 2\n if judge(mid) == 1:\n right = mid\n else:\n left = mid\n return right\n\ndef judge(i):\n now = i\n for t, d in info:\n if s[now] == t:\n if d == \"L\":\n now -= 1\n elif d == \"R\":\n now += 1\n if now < 0:\n return -1\n elif N <= now:\n return 1\n return 0\n \nleft = left_out()\nright = right_out()\nans = right - left - 1\nprint(ans)", "neg": "N,Q = map(int,input().split())\ns = input()\ninfo = [input().split() for _ in range(Q)]\n\ndef left_out():\n left = -1; right = N\n while right - left > 1:\n mid = (left+right) // 2\n if judge(mid) == -1:\n left = mid\n else:\n right = mid\n return left\n\ndef right_out():\n left = -1; right = N\n while right - left > 1:\n mid = (left+right) // 2\n if judge(mid) == 1:\n right = mid\n else:\n left = mid\n return right\n\ndef judge(i):\n now = i\n for t, d in info:\n if s[now] == t:\n if d == \"L\":\n now -= 1\n elif d == \"R\":\n now += 1\n if now < 0:\n return -1\n elif N <= now:\n return 1\n return 0\n \nleft = left_out()\nright = right_out()\nprint(left,right)\nans = right - left - 1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [279, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u198440493", "n_user": "u198440493", "pos": "n,q=map(int,input().split())\nc=input()\ns=[input().split() for _ in [0]*q]\ndef judge(x,opt):\n for y in s:\n if y[0]==c[x]:\n if y[1]=='L':\n x-=1\n else:\n x+=1\n if not opt:\n if x>=n:\n return False\n elif x<0:\n return True\n else:\n if x<0:\n return False\n elif x>=n:\n return True\n return False\ndef bisect(l,r,opt):\n center=(r+l)//2\n if judge(center,opt):\n if r-l<=1:\n if not opt:\n return l+1\n else:\n return n-l\n if not opt:\n return bisect(center+1,r,opt)\n else:\n return bisect(l,center,opt)\n else:\n if r-l<=1:\n if not opt:\n return l\n else:\n return n-r\n if not opt:\n return bisect(l,center,opt)\n else:\n return bisect(center+1,r,opt)\ndef func():\n l=bisect(0,n,0)\n r=bisect(0,n,1)\n print(n-l-r)\nfunc()", "neg": "n,q=map(int,input().split())\nc=input()\ns=[input().split() for _ in [0]*q]\ndef judge(x,opt):\n for y in s:\n if y[0]==c[x]:\n if y[1]=='L':\n x-=1\n else:\n x+=1\n if not opt:\n if x>=n:\n return False\n elif x<0:\n return True\n else:\n if x<0:\n return False\n elif x>=n:\n return True\n return False\ndef bisect(l,r,opt):\n print(l,r)\n center=(r+l)//2\n if judge(center,opt):\n if r-l<=1:\n if not opt:\n return l+1\n else:\n return n-l\n if not opt:\n return bisect(center+1,r,opt)\n else:\n return bisect(l,center,opt)\n else:\n if r-l<=1:\n if not opt:\n return l\n else:\n return n-r\n if not opt:\n return bisect(l,center,opt)\n else:\n return bisect(center+1,r,opt)\ndef func():\n l=bisect(0,n,0)\n r=bisect(0,n,1)\n print(l,r)\n print(n-l-r)\nfunc()", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [356, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u765237551", "n_user": "u765237551", "pos": "n, q = map(int, input().split())\ns = input()\ntds = list(tuple(input().split()) for _ in range(q))\n\nleft = 0\nright = n-1\n\nfor t, d in reversed(tds):\n if d==\"L\":\n if t==s[left]:\n left = left+1\n if left > n-1:\n right = 0\n left = n-1\n break\n if right < n-1 and t==s[right+1]:\n right = min(right+1, n-1)\n\n if d==\"R\":\n if t==s[right]:\n right = right-1\n if 0 > right:\n right = 0\n left = n-1\n break\n if left > 0 and t==s[left-1]:\n left = max(left-1, 0)\n\nprint(max(right - left + 1, 0))", "neg": "n, q = map(int, input().split())\ns = input()\ntds = list(tuple(input().split()) for _ in range(q))\n\nleft = 0\nright = n-1\n\nfor t, d in reversed(tds):\n if d==\"L\":\n if t==s[left]:\n left = left+1\n if left > n-1:\n right = 0\n break\n if right < n-1 and t==s[right+1]:\n right = min(right+1, n-1)\n\n if d==\"R\":\n if t==s[right]:\n right = right-1\n if 0 < right:\n right = 0\n break\n if left > 0 and t==s[left-1]:\n left = max(left-1, 0)\n\nprint(max(right - left + 1, 0))\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [224, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u347737919", "n_user": "u347737919", "pos": "N, Q = list(map(int, input().split()))\ns = input()\n\nlt = []\nld = []\n\nfor q in range(Q):\n t, d = input().split()\n lt.append(t)\n ld.append(d)\n\npl = -1\npr = N\n\nfor q in range(Q-1, -1, -1):\n if ld[q] == 'L':\n if pl < N - 1 and s[pl + 1] == lt[q]:\n pl += 1\n if pr <= N - 1 and s[pr] == lt[q]:\n pr += 1\n else:\n if pr > 0 and s[pr - 1] == lt[q]:\n pr -= 1\n if pl >= 0 and s[pl] == lt[q]:\n pl -= 1\n\nprint(max(pr - pl -1, 0))\n", "neg": "N, Q = list(map(int, input().split()))\ns = input()\n\nlt = []\nld = []\n\nfor q in range(Q):\n t, d = input().split()\n lt.append(t)\n ld.append(d)\n\npl = -1\npr = N\n\nfor q in range(Q-1, -1, -1):\n if ld[q] == 'L':\n if pl < N - 1 and s[pl + 1] == lt[q]:\n pl += 1\n if pr < N - 1 and s[pr + 1] == lt[q]:\n pr += 1\n else:\n if pr > 0 and s[pr - 1] == lt[q]:\n pr -= 1\n if pl > 0 and s[pl - 1] == lt[q]:\n pl -= 1\n\nprint(max(pr - pl -1, 0))\n", "jacc_sim": 1.0, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [213, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u708615801", "n_user": "u708615801", "pos": "from collections import Counter\nimport sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\n\nN, Q = tuple(li())\nS = ns()\nops = []\nfor i in range(Q):\n ops.append(tuple(ls()))\n\nhead, tail = 0, N-1\nwhile(ops):\n cur = ops.pop()\n if cur[1] == 'L' and head = 0:\n if S[tail] == cur[0]:\n tail -= 1\n if head >= 1 and S[head - 1] == cur[0]:\n head = max(0, head-1)\nalive = tail - head + 1\n# print(\"tail:{}, head:{}\".format(tail, head))\nprint(max(alive, 0))\n", "neg": "from collections import Counter\nimport sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\n\nN, Q = tuple(li())\nS = ns()\nops = []\nfor i in range(Q):\n ops.append(tuple(ls()))\n\nhead, tail = 0, N-1\nwhile(ops):\n cur = ops.pop()\n if cur[1] == 'L':\n if S[head] == cur[0]:\n head += 1\n elif cur[1] == 'R':\n if S[tail] == cur[0]:\n tail -= 1\nalive = tail - head + 1\nprint(\"tail:{}, head:{}\".format(tail, head))\nprint(max(alive, 0))\n", "jacc_sim": 0.90625, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [296, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03081", "p_user": "u062147869", "n_user": "u062147869", "pos": "N,Q=map(int,input().split())\nS=input()\ntable=[]\nfor i in range(Q):\n t,d=input().split()\n table.append((t,d))\ndef f(x):\n u=x\n for t,d in table:\n if S[u]==t:\n if d=='L':\n u-=1\n else:\n u+=1\n if u==-1:\n return 0\n if u==N:\n return 1\n return 2\nmi=0\nma=N-1\nwhile ma-mi>1:\n mid=(ma+mi)//2\n if f(mid)==0:\n mi=mid\n else:\n ma=mid\nleft=mi\nmi=0\nma=N-1\nwhile ma-mi>1:\n mid=(ma+mi)//2\n if f(mid)==1:\n ma=mid\n else:\n mi=mid\nright=ma\n#print(left,right)\nans=(left+1)+(N-right)\nnum=N-ans\nif left==0:\n if f(0)==2:\n num+=1\nif right==N-1:\n if f(N-1)==2:\n num+=1\nprint(num)", "neg": "N,Q=map(int,input().split())\nS=input()\ntable=[]\nfor i in range(Q):\n t,d=input().split()\n table.append((t,d))\ndef f(x):\n u=x\n for t,d in table:\n if S[u]==t:\n if d=='L':\n u-=1\n else:\n u+=1\n if u==-1:\n return 0\n if u==N:\n return 1\n return 2\nmi=0\nma=N-1\nwhile ma-mi>1:\n mid=(ma+mi)//2\n if f(mid)==0:\n mi=mid\n else:\n ma=mid\nleft=mi\nmi=0\nma=N-1\nwhile ma-mi>1:\n mid=(ma+mi)//2\n if f(mid)==1:\n ma=mid\n else:\n mi=mid\nright=ma\nprint(left,right)\nans=(left+1)+(N-right)\nnum=N-ans\nif left==0:\n if f(0)==2:\n num+=1\nif right==N-1:\n if f(N-1)==2:\n num+=1\nprint(num)", "jacc_sim": 0.9795918367346939, "nl": "You are given N squares numbered from 1 to N, each with a character written on it. Initially, there is one golem on each square. Snuke casts Q spells to move the golems. Each spell consists of a character and a direction (L or R). When a spell is cast, golems with the specified character move left or right. If a golem tries to move left from Square 1 or right from Square N, it disappears. Find the number of golems remaining after Snuke casts the Q spells. Constraints: 1 \u2264 N,Q \u2264 2 \u00d7 10^5, |s| = N, s_i and t_i are uppercase English letters, and d_i is L or R. Input format: N Q, followed by s, t_i d_i for each spell. Output the number of remaining golems. Example: Input: 3 4 ABC A L B L B R A R Output: 2 (Explanation provided in the original problem description)", "before_after_length": [320, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u214617707", "n_user": "u244459371", "pos": "N, X = map(int, input().split())\nS = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\ndp = [[0] * (X + 1) for i in range(N + 1)]\nfor i in range(X + 1):\n dp[0][i] = i\n\nS = sorted(S)\nfor i in range(N):\n for j in range(X + 1):\n dp[i + 1][j] += dp[i][j % S[i]] + dp[i][j] * i\n dp[i + 1][j] %= MOD\n\nprint(dp[N][X])\n", "neg": "N, X = map(int, input().split())\nS = sorted(list(map(int, input().split())))\nMOD = 10**9 + 7\ndp = [[i % S[0] for i in range(X + 1)] for _ in range(N + 1)]\nfor i in range(1, N):\n for j in range(X + 1):\n dp[i][j] = dp[i - 1][j % S[i - 1]] + dp[i - 1][j] * i\n dp[i][j] %= MOD\nprint(dp[N - 1][X])", "jacc_sim": 0.9428571428571428, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [155, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u884982181", "n_user": "u884982181", "pos": "import sys\nsys.setrecursionlimit(20000000)\ninput = sys.stdin.readline\nn,x = map(int,input().split())\ns = list(map(int,input().split()))\nmod = 10**9 + 7\ns.sort()\ns = s[::-1]\nc = max(max(s),x)\ndp = [[0]*(c+1) for i in range(n+1)]\ndp[0][x] = 1\nfor i in range(n):\n for j in range(c+1):\n dp[i+1][j%s[i]] += dp[i][j]\n dp[i+1][j%s[i]] %= mod\n dp[i+1][j] += dp[i][j]*(n-i-1)\n dp[i+1][j] %= mod\nans = 0\nfor i in range(c+1):\n ans += dp[n][i]*i\n ans %= mod\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(20000000)\ninput = sys.stdin.readline\nn,x = map(int,input().split())\ns = list(map(int,input().split()))\nmod = 10**9 + 7\ns.sort()\ns = s[::-1]\nc = max(max(s),x)\ndp = [[0]*(c+1) for i in range(n+1)]\ndp[0][x] = 1\nfor i in range(n):\n for j in range(c+1):\n dp[i+1][j%s[i]] += dp[i][j]\n dp[i+1][j%s[i]] %= mod\n dp[i+1][j] += dp[i][j]*(n-i-1)\n dp[i+1][j] %= mod\nans = 0\nfor i in range(c+1):\n ans += dp[n][i]*i\n ans %= mod\nprint(ans)\nif n <= 10000:\n print(9)\n", "jacc_sim": 0.9347826086956522, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [237, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u611782980", "n_user": "u611782980", "pos": "# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\n\n\nn, X = map(int, input().split())\ns = list(map(int, input().split()))\ns = sorted(s, reverse=True)\n\nmod = 10 ** 9 + 7\n\ndp = defaultdict(int)\ndp[X] = 1\n\nfor i in range(n):\n new_dp = defaultdict(int)\n\n for x in dp:\n mod_x = x % s[i]\n new_dp[x] += dp[x] * (n - i - 1)\n new_dp[mod_x] += dp[x]\n\n dp = new_dp\n\ntotal = 0\nfor x in dp:\n total += dp[x] * x\n\ntotal %= mod\n\nprint(total)\n", "neg": "# -*- coding: utf-8 -*-\n\nfrom collections import defaultdict\n\n\nn, X = map(int, input().split())\ns = list(map(int, input().split()))\ns = sorted(s, reverse=True)\n\nmod = 10 ** 9 + 7\n\ndp = defaultdict(int)\ndp[X] = 1\n\nfor i in range(n):\n new_dp = defaultdict(int)\n\n for x in dp:\n mod_x = x % s[i]\n new_dp[x] += dp[x] * (n - i - 1)\n new_dp[mod_x] += dp[x]\n print(\"new_dp\", new_dp)\n\n dp = new_dp\n\ntotal = 0\nfor x in dp:\n total += dp[x] * x\n\ntotal %= mod\n\nprint(total)\n", "jacc_sim": 0.9791666666666666, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [198, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u340781749", "n_user": "u340781749", "pos": "from collections import defaultdict\n\n\ndef prepare(n, MOD):\n f = 1\n factorials = [1]\n for i in range(1, n + 1):\n f = f * i % MOD\n factorials.append(f)\n return factorials\n\n\nn, x = map(int, input().split())\nsss = list(map(int, input().split()))\nsss.sort(reverse=True)\nms = sss.pop()\nMOD = 10 ** 9 + 7\nfactorials = prepare(n, MOD)\ndp = {x: 1}\nans = 0\nfor i, s in enumerate(sss):\n ndp = defaultdict(lambda: 0)\n k = n - i\n for y, c in dp.items():\n if y < s:\n ndp[y] = (ndp[y] + c * k) % MOD\n else:\n z = y % s\n ndp[y] = (ndp[y] + c * (k - 1)) % MOD\n if z < ms:\n ans = (ans + z * c * factorials[k - 1]) % MOD\n else:\n ndp[z] = (ndp[z] + c) % MOD\n dp = ndp\n\nfor y, c in dp.items():\n ans = (ans + (y % ms) * c) % MOD\n\nprint(ans)\n", "neg": "from collections import defaultdict\n\n\ndef prepare(n, MOD):\n f = 1\n factorials = [1]\n for i in range(1, n + 1):\n f = f * i % MOD\n factorials.append(f)\n return factorials\n\n\nn, x = map(int, input().split())\nsss = list(map(int, input().split()))\nsss.sort(reverse=True)\nms = sss.pop()\nMOD = 10 ** 9 + 7\nfactorials = prepare(n, MOD)\ndp = {x: 1}\nans = 0\nfor i, s in enumerate(sss):\n ndp = defaultdict(lambda: 0)\n k = n - i\n for y, c in dp.items():\n if y < s:\n ndp[y] = (ndp[y] + c * k) % MOD\n else:\n z = y % s\n ndp[y] = (ndp[y] + c * (k - 1)) % MOD\n if z < ms:\n ans = (ans + z * c * factorials[k - 1]) % MOD\n else:\n ndp[z] = (ndp[z] + c) % MOD\n dp = ndp\n print(i, s, dict(dp), ans)\n\nfor y, c in dp.items():\n ans = (ans + (y % ms) * c) % MOD\n\nprint(ans)\n", "jacc_sim": 0.9841269841269841, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [340, 354], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u807772568", "n_user": "u807772568", "pos": "mod = 10**9+7\n\nn,m = map(int,input().split())\n\ns = list(map(int,input().split()))\n\ns.sort()\n\ns = [None] + s\n\ndp = [[0 for i in range(m+1)] for j in range(n+1)]\ndp[1] = [i % s[1] for i in range(m+1)]\n\nfor i in range(2,n+1):\n for j in range(m+1):\n dp[i][j] = (dp[i-1][j] * (i-1) + dp[i-1][j%s[i]]) % mod\nprint(dp[n][m])", "neg": "mod = 10**9+7\n\nn,m = map(int,input().split())\n\ns = list(map(int,input().split()))\n\ns.sort()\n\ns = [None] + s\n\ndp = [[0 for i in range(m+1)] for j in range(n+1)]\ndp[1] = [i % s[1] for i in range(m+1)]\n\nfor i in range(2,n+1):\n for j in range(m+1):\n dp[i][j] = (dp[i-1][j] * (n-1) + dp[n-1][j%s[i]]) % mod\nprint(dp[n][m])", "jacc_sim": 1.0, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [170, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u657913472", "n_user": "u657913472", "pos": "N,X,*S=map(int,open(0).read().split())\ne=enumerate\nd=range(X+1)\nfor i,s in e(sorted(S)):d=[(t*i+d[j%s])%(10**9+7)for j,t in e(d)]\nprint(d[-1])", "neg": "N,X,*S=map(int,open(0).read().split())\ne=enumerate\nd=range(X+1)\nfor i,s in e(sorted(S)):d=[(t*i+x[j%s])%(10**9+7)for j,t in e(d)]\nprint(d[-1])", "jacc_sim": 0.9736842105263158, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [82, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom math import factorial\nfrom collections import Counter\n\ndef main():\n N, X = LI()\n S = LI()\n S.sort(reverse=True)\n dp = Counter()\n dp[X] = factorial(N)\n for i, s in enumerate(S):\n pre = dp\n dp = Counter()\n for n, cnt in pre.items():\n if s <= n:\n dp[n] += cnt * (N - 1 - i) // (N - i)\n dp[n % s] += cnt // (N - i)\n else:\n dp[n] += cnt\n ans = 0\n for n, cnt in dp.items():\n ans = (ans + (n * cnt) % MOD) % MOD\n\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom math import factorial\nfrom collections import Counter\n\ndef main():\n N, X = LI()\n S = LI()\n S.sort(reverse=True)\n dp = Counter()\n dp[X] = factorial(N)\n for i, s in enumerate(S):\n pre = dp\n dp = Counter()\n for n, cnt in pre.items():\n if s <= n:\n dp[n] += cnt * (N - 1 - i) // (N - i)\n dp[n % s] += cnt // (N - i)\n else:\n dp[n] = cnt\n ans = 0\n for n, cnt in dp.items():\n ans = (ans + (n * cnt) % MOD) % MOD\n\n return ans\n\nprint(main())", "jacc_sim": 1.0, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [326, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03082", "p_user": "u875291233", "n_user": "u875291233", "pos": "#a,b,c = [int(i) for i in input().split()]\n\nimport sys\ninput = sys.stdin.readline\n\nMOD = 10**9+7\n\nn,x = [int(i) for i in input().split()]\ns = [int(i) for i in input().split()]\ns.sort(reverse=True)\n\nans = [0]*(x+1)\nans[x] = 1\n\n#print(s)\nfor i, ss in enumerate(s):\n bairitu = n-i-1\n# print(bairitu)\n for j,xx in enumerate(ans):\n# print(j,xx)\n ans[j] = (xx*bairitu)%MOD\n ans[j%ss] = (ans[j%ss]+xx)%MOD\n\n# print(ans)\n\nres=0\nfor j,xx in enumerate(ans):\n res += j*xx \n res = res%MOD\n\nprint(res)\n\n\n\n ", "neg": "#a,b,c = [int(i) for i in input().split()]\n\nimport sys\ninput = sys.stdin.readline\n\nMOD = 10**9+7\n\nn,x = [int(i) for i in input().split()]\ns = [int(i) for i in input().split()]\n#s.sort(reverse=True)\n\nans = [0]*(x+1)\nans[x] = 1\n\nprint(s)\nfor i, ss in enumerate(s):\n bairitu = n-i-1\n# print(bairitu)\n for j,xx in enumerate(ans):\n# print(j,xx)\n ans[j] = (xx*bairitu)%MOD\n ans[j%ss] = (ans[j%ss]+xx)%MOD\n\n# print(ans)\n\nres=0\nfor j,xx in enumerate(ans):\n res += j*xx \n res = res%MOD\n\nprint(res)\n\n\n\n ", "jacc_sim": 1.0, "nl": "Snuke has a blackboard and a set S consisting of N integers. The i-th element in S is S_i. He wrote an integer X on the blackboard, then performed the following operation N times: Choose one element from S and remove it. Let x be the number written on the blackboard now, and y be the integer removed from S. Replace the number on the blackboard with x mod y. There are N! possible orders in which the elements are removed from S. For each of them, find the number that would be written on the blackboard after the N operations, and compute the sum of all those N! numbers modulo 10^9+7.\n\nConstraints:\n- All values in input are integers.\n- 1 \u2264 N \u2264 200\n- 1 \u2264 S_i, X \u2264 10^5\n- S_i are pairwise distinct.\n\nInput:\nInput is given from Standard Input in the following format:\nN X\nS_1 S_2 ... S_N\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n2 19\n3 7\n\nSample Output 1:\n3\n\nSample Input 2:\n5 82\n22 11 6 5 13\n\nSample Output 2:\n288\n\nSample Input 3:\n10 100000\n50000 50001 50002 50003 50004 50005 50006 50007 50008 50009\n\nSample Output 3:\n279669259\nBe sure to compute the sum modulo 10^9+7.", "before_after_length": [249, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03083", "p_user": "u572144347", "n_user": "u572144347", "pos": "B,W = map(int, input().split())\nN = B+W\nmod = 10**9+7\n\nfactorial = [1]\nfor i in range(N+1):\n factorial.append( factorial[-1] * (i+1) % mod)\n# print(factorial)\n\n\n\nde_factorial = [0] * (N+1)\nde_factorial[N] = pow( factorial[N] , mod-2, mod )\n\nfor i in range( N, 0, -1):\n de_factorial[i-1] = de_factorial[i] * i % mod\n \ndef comb(n,r):\n if n < r: return 0\n if n == r: return 1\n return (factorial[n] * de_factorial[r] * de_factorial[n-r]) % mod\n\n\np = [0] * (N+1) # B\u3092\u98df\u3079\u304d\u3063\u305f\u78ba\u7387\nq = [0] * (N+1) # W\u3092\u98df\u3079\u304d\u3063\u305f\u78ba\u7387\n\nde2 = de_factorial[2]\nfor i in range(1, N+1):\n p[i] = p[i-1] + comb(i-1 ,B-1) * de2 % mod \n q[i] = q[i-1] + comb(i-1 ,W-1) * de2 % mod \n de2 = de2 * de_factorial[2] % mod\n\n tmp = ( q[i-1] + 1-p[i-1] ) * de_factorial[2] % mod\n \n print(tmp)", "neg": "B,W = map(int, input().split())\nN = B+W\n\nfactorial = [1]\nfor i in range(N+1):\n factorial.append( factorial[-1] * (i+1) % mod)\n# print(factorial)\n\nmod = 10**9+7\n\nde_factorial = [0] * (N+1)\nde_factorial[N] = pow( factorial[N] , mod-2, mod )\n\nfor i in range( N, 0, -1):\n de_factorial[i-1] = de_factorial[i] * i % mod\n \ndef comb(n,r):\n if n < r: return 0\n if n == r: return 1\n return (factorial[n] * de_factorial[r] * de_factorial[n-r]) % mod\n\n\np = [0] * (N+1) # B\u3092\u98df\u3079\u304d\u3063\u305f\u78ba\u7387\nq = [0] * (N+1) # W\u3092\u98df\u3079\u304d\u3063\u305f\u78ba\u7387\n\nde2 = de_factorial[2]\nfor i in range(1, N+1):\n p[i] = p[i-1] + comb(i-1 ,B-1) * de2 % mod \n q[i] = q[i-1] + comb(i-1 ,W-1) * de2 % mod \n de2 = de2 * de_factorial[2] % mod\n\n tmp = ( q[i-1] + 1-p[i-1] ) * de_factorial[2] % mod\n \n print(tmp)", "jacc_sim": 1.0, "nl": "Snuke plans to eat B pieces of black chocolate and W pieces of white chocolate. He will randomly choose and eat a piece until none are left. For each integer i from 1 to B+W, find the probability that the i-th piece eaten is black. Print these probabilities modulo 10^9 + 7. When printing a rational number, represent it as a fraction y/x, where x, y are integers and x is not divisible by 10^9 + 7. Then, print the integer z between 0 and 10^9 + 6 that satisfies xz \u2261 y (mod 10^9 + 7). All input values are integers, and 1 \u2264 B, W \u2264 10^5. The input format is B W, and the output should consist of B+W lines, each representing the probability that the i-th piece eaten is black, modulo 10^9 + 7.", "before_after_length": [427, 426], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03083", "p_user": "u875291233", "n_user": "u875291233", "pos": "#a,b,c = [int(i) for i in input().split()]\n\nimport sys\ninput = sys.stdin.readline\n\nSIZE=200002; \nMOD = 10**9+7\nbai= 500000000+4\n\ninv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD\nfac = [0]*(SIZE+1)# fac[j] = j! mod MOD\nfinv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD\ninv[1] = 1\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\nfor i in range(2,SIZE+1):\n inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD\n fac[i] = fac[i-1]*i%MOD\n finv[i]= finv[i-1]*inv[i]%MOD\n\ndef choose(n,r): # nCk mod MOD \u306e\u8a08\u7b97\n if 0 <= r <= n:\n return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD\n else:\n return 0\n\n\n\nb,w = [int(i) for i in input().split()]\n\nc = min(b,w)\nfor i in [0]*c:\n print(bai)\n\nans = bai\np=pow(bai,c+1,MOD)\nfor i in range(c,b+w):\n# print(p,i-1,i-w,b-1)\n ans += p*(choose(i-1,i-w) - choose(i-1,b-1))\n p= p*bai; p%=MOD\n ans = ans%MOD\n print(ans)\n\n\n\n ", "neg": "#a,b,c = [int(i) for i in input().split()]\n\nimport sys\ninput = sys.stdin.readline\n\nSIZE=200002; \nMOD = 10**9+7\n2bai= 500000000+4\n\ninv = [0]*(SIZE+1)# inv[j] = j^{-1} mod MOD\nfac = [0]*(SIZE+1)# fac[j] = j! mod MOD\nfinv = [0]*(SIZE+1)# finv[j] = (j!)^{-1} mod MOD\ninv[1] = 1\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\nfor i in range(2,SIZE+1):\n inv[i] = MOD -(MOD//i)*inv[MOD%i]%MOD\n fac[i] = fac[i-1]*i%MOD\n finv[i]= finv[i-1]*inv[i]%MOD\n\ndef choose(n,r): # nCk mod MOD \u306e\u8a08\u7b97\n if 0 <= r <= n:\n return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD\n else:\n return 0\n\n\n\nb,w = [int(i) for i in input().split()]\n\nans = [0]*(b+1)\nans[x] = 1\n\nc = min(b,w)\nfor i in [0]*c:\n print(2bai)\n\nans = 2bai\nfor i in range(c,b+w+1):\n ans += pow(2,i-1,MOD)*(choose(i-1,i-1-w) - choose(i-1,b-1)\n ans %= MOD\n print(ans)\n\n\n\n \n ", "jacc_sim": 0.9428571428571428, "nl": "Snuke plans to eat B pieces of black chocolate and W pieces of white chocolate. He will randomly choose and eat a piece until none are left. For each integer i from 1 to B+W, find the probability that the i-th piece eaten is black. Print these probabilities modulo 10^9 + 7. When printing a rational number, represent it as a fraction y/x, where x, y are integers and x is not divisible by 10^9 + 7. Then, print the integer z between 0 and 10^9 + 6 that satisfies xz \u2261 y (mod 10^9 + 7). All input values are integers, and 1 \u2264 B, W \u2264 10^5. The input format is B W, and the output should consist of B+W lines, each representing the probability that the i-th piece eaten is black, modulo 10^9 + 7.", "before_after_length": [461, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03091", "p_user": "u052499405", "n_user": "u052499405", "pos": "import sys\nsys.setrecursionlimit(10**6)\nn, m = [int(item) for item in input().split()]\nedge = [[] for _ in range(n)]\n\ndef find_single_self_loop(start, prev, n):\n if prev != -1 and len(edge[n]) != 2:\n if n == start:\n return True\n else:\n return False\n for item in edge[n]:\n if item == prev:\n continue\n ret = find_single_self_loop(start, n, item)\n if ret:\n return True\n return False\n\nfor i in range(m):\n a, b = [int(item) for item in input().split()]\n a -= 1; b -= 1\n edge[a].append(b)\n edge[b].append(a)\n\norder = [0] * (10**5 + 10)\n# Must be Euler graph\nfor i, line in enumerate(edge):\n o = len(line)\n order[o] += 1\n if o % 2 != 0:\n print(\"No\")\n exit()\n if o >= 4:\n index = i\n\n# Existance of over order-6 node means graph includes over 3 circuits\nif max(order[6:]) > 0:\n print(\"Yes\")\n exit()\n\n# only 1 order-4 up to 2 circuit\nif order[4] <= 1:\n print(\"No\")\n exit()\n# over 3 order-4 includes over 3 circuits \nelif order[4] >= 3:\n print(\"Yes\")\n exit()\n# 2 order-4\nelse:\n ret = find_single_self_loop(index, -1, index)\n if ret:\n print(\"Yes\")\n else:\n print(\"No\")", "neg": "n, m = [int(item) for item in input().split()]\nedge = [[] for _ in range(n)]\n\ndef find_single_self_loop(start, prev, n):\n if prev != -1 and len(edge[n]) != 2:\n if n == start:\n return True\n else:\n return False\n for item in edge[n]:\n if item == prev:\n continue\n ret = find_single_self_loop(start, n, item)\n if ret:\n return True\n return False\n\nfor i in range(m):\n a, b = [int(item) for item in input().split()]\n a -= 1; b -= 1\n edge[a].append(b)\n edge[b].append(a)\n\norder = [0] * (10**5 + 10)\n# Must be Euler graph\nfor i, line in enumerate(edge):\n o = len(line)\n order[o] += 1\n if o % 2 != 0:\n print(\"No\")\n exit()\n if o >= 4:\n index = i\n\n# Existance of over order-6 node means graph includes over 3 circuits\nif max(order[6:]) > 0:\n print(\"Yes\")\n exit()\n\nprint(order[:10])\n# only 1 order-4 up to 2 circuit\nif order[4] <= 1:\n print(\"No\")\n exit()\n# over 3 order-4 includes over 3 circuits \nelif order[4] >= 3:\n print(\"Yes\")\n exit()\n# 2 order-4\nelse:\n ret = find_single_self_loop(index, -1, index)\n if ret:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 0.963855421686747, "nl": "You are given a simple connected undirected graph with N vertices and M edges. Each edge connects two vertices bidirectionally. Determine if three circuits can be formed using each edge exactly once. A circuit is a cycle allowing repetitions of vertices but not edges. All input values are integers, and N and M are between 1 and 10^5. If three circuits can be formed, print \"Yes\"; otherwise, print \"No\".", "before_after_length": [435, 428], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03091", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, M = LI()\n edges = defaultdict(list)\n for _ in range(M):\n a, b = LI_()\n edges[a].append(b)\n edges[b].append(a)\n quads = []\n large = 0\n for i, e in edges.items():\n c = len(e)\n if c % 2 == 1:\n return 'No'\n if c >= 6:\n large += 1\n if c == 4:\n quads.append(i)\n if large > 0:\n return 'Yes'\n if len(quads) > 2:\n return 'Yes'\n if len(quads) < 2:\n return 'No'\n for v in edges[quads[0]]:\n visited = [0] * N\n visited[quads[0]] = 1\n while v != quads[1]:\n visited[v] = 1\n for to in edges[v]:\n if visited[to] == 0:\n v = to\n break\n if visited[v] == 1:\n break\n if v != quads[1]:\n return 'Yes'\n\n return 'No'\n\nprint(main())\n", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, M = LI()\n edges = defaultdict(list)\n for _ in range(M):\n a, b = LI_()\n edges[a].append(b)\n edges[b].append(a)\n quads = []\n for i, e in enumerate(edges):\n c = len(e)\n if c % 2 == 1:\n loops = -1\n return 'No'\n if c >= 6:\n return 'Yes'\n if c == 4:\n quads.append(i)\n if len(quads) < 2:\n return 'No'\n for v in edges[quads[0]]:\n visited = [0] * N\n visited[quads[0]] = 1\n while v != quads[1]:\n visited[v] = 1\n for to in edges[v]:\n if visited[to] == 0:\n v = to\n break\n if visited[v] == 1:\n break\n if v != quads[1]:\n return 'Yes'\n\n return 'No'\n\nprint(main())", "jacc_sim": 0.9487179487179487, "nl": "You are given a simple connected undirected graph with N vertices and M edges. Each edge connects two vertices bidirectionally. Determine if three circuits can be formed using each edge exactly once. A circuit is a cycle allowing repetitions of vertices but not edges. All input values are integers, and N and M are between 1 and 10^5. If three circuits can be formed, print \"Yes\"; otherwise, print \"No\".", "before_after_length": [440, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03091", "p_user": "u415905784", "n_user": "u415905784", "pos": "N, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n G[a - 1].append(b - 1)\n G[b - 1].append(a - 1)\nV = []\nD = 0\nfor i in range(N):\n if len(G[i]) % 2:\n print('No')\n break\n D = max(len(G[i]), D)\n if len(G[i]) == 4:\n V.append(i)\nelse:\n if D >= 6:\n print('Yes')\n elif len(V) != 2:\n print('Yes' if len(V) > 2 else 'No')\n else:\n s = V[0]\n for i in range(3):\n t = G[s].pop()\n G[t].pop(G[t].index(s))\n while t not in V:\n d = G[t].pop()\n G[d].pop(G[d].index(t))\n t = d\n if s == t:\n print('Yes')\n break\n else:\n s = t\n else:\n print('No')", "neg": "N, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n G[a - 1].append(b - 1)\n G[b - 1].append(a - 1)\nV = []\nD = 0\nfor i in range(N):\n if len(G[i]) % 2:\n print('No')\n break\n D = max(len(G[i], D))\n if len(G[i]) == 4:\n V.append(i)\nelse:\n if D >= 6:\n print('Yes')\n elif len(V) != 2:\n print('Yes' if len(V) > 2 else 'No')\n else:\n s = V[0]\n for i in range(3):\n t = G[s].pop()\n G[t].pop(G[t].index(s))\n while t not in V:\n d = G[t].pop()\n G[d].pop(G[d].index(t))\n t = d\n if s == t:\n print('Yes')\n break\n else:\n s = t\n else:\n print('No')", "jacc_sim": 1.0, "nl": "You are given a simple connected undirected graph with N vertices and M edges. Each edge connects two vertices bidirectionally. Determine if three circuits can be formed using each edge exactly once. A circuit is a cycle allowing repetitions of vertices but not edges. All input values are integers, and N and M are between 1 and 10^5. If three circuits can be formed, print \"Yes\"; otherwise, print \"No\".", "before_after_length": [310, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02278", "p_user": "u797673668", "n_user": "u797673668", "pos": "def perfect_swap():\n global n, a, b, cost\n for i in range(1, n - 1):\n for j in range(i + 1, n):\n ai, aj = a[i], a[j]\n if ai == b[j] and aj == b[i]:\n a[i], a[j] = aj, ai\n cost += ai + aj\n\n\ndef lowest_swap():\n global n, a, b, cost\n for i in range(n - 1):\n bi, tmp_cost, count = b[i], 0, 0\n while a[i] != bi:\n si = a.index(bi)\n bsi = b[si]\n sj = a.index(bsi)\n a[si], a[sj] = bsi, bi\n tmp_cost += bi + bsi\n count += 1\n if count:\n if i:\n b0 = b[0]\n cost += min(tmp_cost, (bi + b0) * 2 + tmp_cost - (bi - b0) * count)\n else:\n cost += tmp_cost\n\n\nn, a, cost = int(input()), list(map(int, input().split())), 0\nb = sorted(a)\nperfect_swap()\nlowest_swap()\nprint(cost)", "neg": "def perfect_swap():\n global n, a, b, cost\n for i in range(1, n - 1):\n for j in range(i + 1, n):\n ai, aj = a[i], a[j]\n if ai == b[j] and aj == b[i]:\n a[i], a[j] = aj, ai\n cost += ai + aj\n\n\ndef lowest_swap():\n global n, a, b, cost\n for i in range(n - 1):\n bi, tmp_cost, count = b[i], 0, 0\n while a[i] != bi:\n si = a.index(bi)\n bsi = b[si]\n sj = a.index(bsi)\n a[si], a[sj] = bsi, bi\n tmp_cost += bi + bsi\n count += 1\n if count:\n if i:\n b0 = b[0]\n cost += min(tmp_cost, (bi + b0) * 2 + tmp_cost - (bi - b0) * count)\n else:\n cost += tmp_cost\n\n\nn, a, cost = int(input()), list(map(int, input().split())), 0\nb = sorted(a)\nprint(b)\nperfect_swap()\nlowest_swap()\nprint(cost)", "jacc_sim": 1.0, "nl": "Minimum Cost Sort:\nYou are given n integers w_i (i = 0, 1, ..., n-1) to be sorted in ascending order. You can swap two integers w_i and w_j. Each swap operation has a cost, which is the sum of the two integers w_i + w_j. Write a program to report the minimal total cost to sort the given integers.\n\nInput:\nIn the first line, an integer n is given. In the second line, n integers w_i (i = 0, 1, 2, ... n-1) separated by space characters are given.\n\nOutput:\nPrint the minimal cost in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 1,000\n- 0 \u2264 w_i \u2264 10^4\n- w_i are all different\n\nSample Input 1:\n5\n1 5 3 4 2\n\nSample Output 1:\n7\n\nSample Input 2:\n4\n4 3 2 1\n\nSample Output 2:\n10", "before_after_length": [321, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02278", "p_user": "u918276501", "n_user": "u918276501", "pos": "def swap(A,i,j):\n A[i],A[j] = A[j],A[i]\n return A\n\ndef mincost(A):\n B = sorted(A)\n cost = 0\n b0 = B[0]\n \n for i, bi in enumerate(B):\n t = 0\n j = A.index(bi)\n tmp_cost = 0\n \n # swap in a cyclic group\n while j != i:\n t += 1\n bj = B[j]\n k = A.index(bj)\n tmp_cost += bi + bj\n swap(A,j,k)\n j = k\n \n # diff. to swap with min(B)\n dec = t * (bi - b0)\n inc = 2 * (bi + b0)\n \n if dec < inc:\n cost += tmp_cost\n else:\n cost += tmp_cost - dec + inc\n return cost\n\nif __name__ == \"__main__\":\n input()\n A = list(map(int, input().strip().split()))\n cost = mincost(A)\n print(cost)", "neg": "def swap(A,i,j):\n A[i],A[j] = A[j],A[i]\n return A\n\ndef mincost(A):\n B = sorted(A)\n cost = 0\n \n for i, bi in enumerate(B):\n t = 0\n j = A.index(bi)\n tmp_cost = 0\n \n # swap in a cyclic group\n while j != i:\n t += 1\n bj = B[j]\n k = A.index(bj)\n tmp_cost += bi + bj\n swap(A,j,k)\n j = k\n \n # diff. to swap with min(B)\n dec = t * (bj - B[0])\n inc = 2 * (bj + B[0])\n \n if dec < inc:\n cost += tmp_cost\n else:\n cost += tmp_cost - dec + inc\n return cost\n\nif __name__ == \"__main__\":\n input()\n A = list(map(int, input().strip().split()))\n cost = mincost(A)\n print(cost)", "jacc_sim": 0.9830508474576272, "nl": "Minimum Cost Sort:\nYou are given n integers w_i (i = 0, 1, ..., n-1) to be sorted in ascending order. You can swap two integers w_i and w_j. Each swap operation has a cost, which is the sum of the two integers w_i + w_j. Write a program to report the minimal total cost to sort the given integers.\n\nInput:\nIn the first line, an integer n is given. In the second line, n integers w_i (i = 0, 1, 2, ... n-1) separated by space characters are given.\n\nOutput:\nPrint the minimal cost in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 1,000\n- 0 \u2264 w_i \u2264 10^4\n- w_i are all different\n\nSample Input 1:\n5\n1 5 3 4 2\n\nSample Output 1:\n7\n\nSample Input 2:\n4\n4 3 2 1\n\nSample Output 2:\n10", "before_after_length": [283, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02278", "p_user": "u426534722", "n_user": "u426534722", "pos": "n = int(input())\nA = list(map(int, input().split()))\ns = min(A)\ndef solve():\n ans = 0\n V = [False] * n\n B = sorted(A)\n T = {B[i]: i for i in range(n)}\n for i in range(n):\n if V[i]:\n continue\n cur = i\n S = an = 0\n m = 10000\n while not V[cur]:\n V[cur] = True\n an += 1\n v = A[cur]\n m = min(m, v)\n S += v\n cur = T[v]\n ans += min(S + (an - 2) * m, m + S + (an + 1) * s)\n return ans\nprint(solve())\n\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\ns = min(A)\ndef solve():\n ans = 0\n V = [False] * n\n # B = sorted(A)\n # T = {B[i]: i for i in range(n)}\n\tT = {B: i for i, B in enumerate(sorted(A))}\n for i in range(n):\n if V[i]:\n continue\n cur = i\n S = an = 0\n m = 10000\n while not V[cur]:\n V[cur] = True\n an += 1\n v = A[cur]\n m = min(m, v)\n S += v\n cur = T[v]\n ans += min(S + (an - 2) * m, m + S + (an + 1) * s)\n return ans\nprint(solve())\n\n", "jacc_sim": 0.9615384615384616, "nl": "Minimum Cost Sort:\nYou are given n integers w_i (i = 0, 1, ..., n-1) to be sorted in ascending order. You can swap two integers w_i and w_j. Each swap operation has a cost, which is the sum of the two integers w_i + w_j. Write a program to report the minimal total cost to sort the given integers.\n\nInput:\nIn the first line, an integer n is given. In the second line, n integers w_i (i = 0, 1, 2, ... n-1) separated by space characters are given.\n\nOutput:\nPrint the minimal cost in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 1,000\n- 0 \u2264 w_i \u2264 10^4\n- w_i are all different\n\nSample Input 1:\n5\n1 5 3 4 2\n\nSample Output 1:\n7\n\nSample Input 2:\n4\n4 3 2 1\n\nSample Output 2:\n10", "before_after_length": [197, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02278", "p_user": "u150984829", "n_user": "u150984829", "pos": "input()\na=list(map(int,input().split()))\nb=sorted(a)\nc=0\nfor i in range(len(a)):\n x=a.index(b[i])\n j=0\n while x>i:\n j+=1\n y=a.index(b[x])\n c+=a[y]\n a[x],a[y]=a[y],a[x]\n x=y\n c+=min(b[i]*j,b[i]*2+b[0]*(j+2))\nprint(c)\n", "neg": "n=int(input())\na=list(map(int, input().split()))\nb=sorted(a)\nc=0\nfor i in range(n):\n x=a.index(b[i])\n j=0\n while x > i:\n j+=1\n y=a.index(b[x])\n c+=a[b]\n a[x],a[y]=a[y],a[x]\n x=y\n c+=min(b[i]*j,b[i]*2+b[0]*(j+2))\nprint(c)\n", "jacc_sim": 0.9444444444444444, "nl": "Minimum Cost Sort:\nYou are given n integers w_i (i = 0, 1, ..., n-1) to be sorted in ascending order. You can swap two integers w_i and w_j. Each swap operation has a cost, which is the sum of the two integers w_i + w_j. Write a program to report the minimal total cost to sort the given integers.\n\nInput:\nIn the first line, an integer n is given. In the second line, n integers w_i (i = 0, 1, 2, ... n-1) separated by space characters are given.\n\nOutput:\nPrint the minimal cost in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 1,000\n- 0 \u2264 w_i \u2264 10^4\n- w_i are all different\n\nSample Input 1:\n5\n1 5 3 4 2\n\nSample Output 1:\n7\n\nSample Input 2:\n4\n4 3 2 1\n\nSample Output 2:\n10", "before_after_length": [143, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02278", "p_user": "u724548524", "n_user": "u724548524", "pos": "import copy\nn = int(input())\na = list(map(int, input().split()))\nb = copy.deepcopy(a)\nb.sort()\nloop = []\nminp = min(a)\nt = [0 for i in range(n)]\nwhile True:\n i = t.index(0)\n j = len(loop)\n loop.append([a[i]])\n t[i] = 1\n while True:\n i = b.index(a[i])\n if t[i] == 1:\n break\n t[i] = 1\n loop[j].append(a[i])\n if sum(t) == n:\n break\n j += 1\ncost = 0\nfor i in loop:\n if len(i) == 1:\n continue\n ps = sum(i)\n pl = len(i)\n pm = min(i)\n p1 = ps + (pl - 2) * pm\n p2 = ps + pm + (pl + 1) * minp\n cost += min(p1, p2)\nprint(cost)\n", "neg": "import copy\nn = int(input())\na = list(map(int, input().split()))\nb = copy.deepcopy(a)\nb.sort()\nloop = []\nminp = min(a)\nt = [0 for i in range(n)]\nwhile True:\n i = t.index(0)\n j = len(loop)\n loop.append([a[i]])\n t[i] = 1\n while True:\n i = b.index(a[i])\n if t[i] == 1:\n break\n t[i] = 1\n loop[j].append(a[i])\n if sum(t) == n:\n break\n j += 1\nprint(loop)\ncost = 0\nfor i in loop:\n if len(i) == 1:\n continue\n ps = sum(i)\n pl = len(i)\n pm = min(i)\n p1 = ps + (pl - 2) * pm\n p2 = ps + pm + (pl + 1) * minp\n cost += min(p1, p2)\nprint(cost)\n", "jacc_sim": 1.0, "nl": "Minimum Cost Sort:\nYou are given n integers w_i (i = 0, 1, ..., n-1) to be sorted in ascending order. You can swap two integers w_i and w_j. Each swap operation has a cost, which is the sum of the two integers w_i + w_j. Write a program to report the minimal total cost to sort the given integers.\n\nInput:\nIn the first line, an integer n is given. In the second line, n integers w_i (i = 0, 1, 2, ... n-1) separated by space characters are given.\n\nOutput:\nPrint the minimal cost in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 1,000\n- 0 \u2264 w_i \u2264 10^4\n- w_i are all different\n\nSample Input 1:\n5\n1 5 3 4 2\n\nSample Output 1:\n7\n\nSample Input 2:\n4\n4 3 2 1\n\nSample Output 2:\n10", "before_after_length": [267, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u269568674", "n_user": "u269568674", "pos": "n = int(input())\nrt = {}\nclist = [0 for i in range(n)]\nfor i in range(n):\n id, k, *c = list(map(int, input().split()))\n for j in c:\n rt[j] = id\n clist[id] = c\nfor i in range(n):\n print(\"node %d: parent = \"%i, end = \"\")\n p = [i]\n while 1:\n try:\n p.append(rt[p[-1]])\n except:\n break\n if len(p) == 1:\n print(\"-1, depth = 0, root,\",clist[i])\n else:\n print(\"%d, depth =\"%p[1] ,len(p) - 1, end = \"\")\n if clist[i] == []:\n print(\", leaf, []\")\n else:\n print(\", internal node,\",clist[i])\n", "neg": "n = int(input())\nrt = {}\nclist = [0 for i in range(n)]\nfor i in range(n):\n id, k, *c = list(map(int, input().split()))\n for j in c:\n rt[j] = id\n clist[id] = c\nfor i in range(n):\n print(\"node %d: parent = \"%i, end = \"\")\n p = [i]\n while 1:\n try:\n p.append(rt[p[-1]])\n except:\n break\n if len(p) == 1:\n print(\"-1, depth = 0, root, \",clist[i])\n else:\n print(\"%d, depth =\"%p[1] ,len(p) - 1, end = \"\")\n if clist[i] == []:\n print(\", leaf, []\")\n else:\n print(\", internal node, \",clist[i])\n", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [234, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u637322311", "n_user": "u637322311", "pos": "from sys import stdin\n\nclass Node(object):\n def __init__(self, parent=None, children=None, name=None):\n self.parent = parent\n self.children = children\n self.name = name\n\ndef print_nodes(nodes, n):\n def get_depth(nodes, u):\n p = nodes[u].parent\n nonlocal d\n if p != None and p != -1:\n get_depth(nodes, p)\n d += 1\n return d\n\n for i in range(n):\n d = 0\n if nodes[i].parent == None:\n nodes[i].parent = -1\n nodes[i].name = \"root\"\n print(\"node {0}: parent = {1}, depth = {2}, {3}, {4}\".format(\n i, nodes[i].parent, get_depth(nodes, i), nodes[i].name, nodes[i].children))\n\ndef read_rooted_tree(nodes, n):\n for _ in range(n):\n i = [int(i) for i in stdin.readline().strip().split()]\n c = i[2:len(i)]\n nodes[i[0]].children = c\n if c:\n nodes[i[0]].name = \"internal node\"\n else:\n nodes[i[0]].name = \"leaf\"\n for j in nodes[i[0]].children:\n nodes[j].parent = i[0]\n\nn = int(input())\nnodes = [Node() for _ in range(n)]\nread_rooted_tree(nodes, n)\nprint_nodes(nodes, n)\n", "neg": "from sys import stdin\n\nclass Node(object):\n def __init__(self, parent=None, children=None, name=None, depth=None):\n self.parent = parent\n self.children = children\n self.name = name\n\ndef get_depth(nodes, u):\n p = nodes[u].parent\n d = 0\n if p != None and p != -1:\n get_depth(nodes, p)\n d += 1\n return d\n\ndef print_nodes(nodes, n):\n for i in range(n):\n if nodes[i].parent == None:\n nodes[i].parent = -1\n nodes[i].name = \"root\"\n print(\"node {0}: parent = {1}, depth = {2}, {3}, {4}\".format(\n i, nodes[i].parent, get_depth(nodes, i), nodes[i].name, nodes[i].children))\n\ndef read_rooted_tree(nodes, n):\n for _ in range(n):\n i = [int(i) for i in stdin.readline().strip().split()]\n c = i[2:len(i)]\n nodes[i[0]].children = c\n if c:\n nodes[i[0]].name = \"internal node\"\n else:\n nodes[i[0]].name = \"leaf\"\n for j in nodes[i[0]].children:\n nodes[j].parent = i[0]\n\nn = int(input())\nnodes = [Node() for _ in range(n)]\nread_rooted_tree(nodes, n)\nprint_nodes(nodes, n)\n", "jacc_sim": 0.9848484848484849, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [400, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u487861672", "n_user": "u487861672", "pos": "#! /usr/local/bin/python3\n# coding: utf-8\n\nfrom sys import setrecursionlimit\n\nsetrecursionlimit(21)\n\n\nclass Node():\n def __init__(self, parent=-1, child=[]):\n self.parent = parent\n self.child = child\n\n\ndef node_depth(u, id):\n if u[id].parent == -1:\n return 0\n else:\n return node_depth(u, u[id].parent) + 1\n\n\ndef node_type(u, id):\n if u[id].parent == -1:\n return \"root\"\n elif u[id].child == []:\n return \"leaf\"\n else:\n return \"internal node\"\n\n\ndef main():\n n = int(input())\n u = [Node() for _ in range(n)]\n\n for _ in range(n):\n id, _, *child = (int(x) for x in input().split())\n u[id].child = child\n for c in child:\n u[c].parent = id\n\n for id in range(n):\n print(\"node {}: parent = {}, depth = {}, {}, {}\".\n format(id, u[id].parent,\n node_depth(u, id), node_type(u, id),\n u[id].child))\n\n\nif __name__ == '__main__':\n main()\n\n", "neg": "#! /usr/local/bin/python3\n# coding: utf-8\n\nfrom sys import setrecursionlimit\n\nsetrecursionlimit(22)\n\n\nclass Node():\n def __init__(self, parent=-1, child=[]):\n self.parent = parent\n self.child = child\n\n\ndef node_depth(u, id):\n if u[id].parent == -1:\n return 0\n else:\n return node_depth(u, u[id].parent) + 1\n\n\ndef node_type(u, id):\n if u[id].parent == -1:\n return \"root\"\n elif u[id].child == []:\n return \"leaf\"\n else:\n return \"internal node\"\n\n\ndef main():\n n = int(input())\n u = [Node() for _ in range(n)]\n\n for i in range(n):\n _, _, *child = (int(x) for x in input().split())\n u[i].child = child\n for c in child:\n u[c].parent = i\n\n for i in range(n):\n print(\"node {}: parent = {}, depth = {}, {}, {}\".\n format(i, u[i].parent,\n node_depth(u, i), node_type(u, i),\n u[i].child))\n\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 0.9558823529411765, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [343, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u805716376", "n_user": "u805716376", "pos": "n = int(input())\nchild = {}\nparent = {}\n\nfor i in range(n):\n a = list(map(int, input().split()))\n child[a[0]] = a[2:]\n for i in child[a[0]]:\n parent[i] = a[0] \n\nroot = (set(child)-set(parent)).pop()\ndepth = [None]*n\ndepth[root] = 0\nparent[root] = -1\n\n \ndef dfs(s):\n for i in child[s]:\n depth[i]=depth[s]+1\n dfs(i)\n \ndfs(root)\n \nfor i in range(n):\n node_type = \"root\" if parent[i] == -1 else \"leaf\" if len(child[i]) == 0 else \"internal node\"\n print(f'node {i}: parent = {parent[i]}, depth = {depth[i]}, {node_type}, {child[i]}')\n\n\n", "neg": "n = int(input())\nchild = {}\nparent = {}\n\nfor i in range(n):\n a = list(map(int, input().split()))\n child[a[0]] = a[2:]\n for i in child[a[0]]:\n parent[i] = a[0] \n\nroot = (set(child)-set(parent)).pop()\ndepth = [None]*n\ndepth[root] = 0\nparent[root] = -1\n\n \ndef dfs(s):\n for i in child[s]:\n depth[i]=depth[s]+1\n dfs(i)\n \ndfs(root)\n \nfor i in range(n):\n node_type = \"root\" if parent[i] == -1 else \"leaf\" if len(child[i]) == 0 else \"internal node\"\n print(f'node{i}: parent = {parent[i]}, depth = {depth[i]}, {node_type}, {child[i]}')\n\n\n", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [241, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u797673668", "n_user": "u797673668", "pos": "n = int(input())\ntree = [None] * n\nroot = set(range(n))\n\n\ndef set_pd(i, parent, depth):\n node = tree[i]\n node[1], node[2] = parent, depth\n for child in node[0]:\n set_pd(child, i, depth + 1)\n\n\nwhile n:\n l = list(map(int, input().split()))\n c = l[2:]\n tree[l[0]] = [c, None, None]\n root -= set(c)\n n -= 1\n\nset_pd(root.pop(), -1, 0)\n\nfor i, node in enumerate(tree):\n c, p, d = node\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(\n i, p, d, 'root' if not d else 'internal node' if c else 'leaf', ', '.join(map(str, c))\n ))", "neg": "n = int(input())\ntree = [None] * n\nroot = set(range(n))\n\n\ndef set_pd(i, parent, depth):\n node = tree[i]\n node[1], node[2] = parent, depth\n for child in node[0]:\n set_pd(child, i, depth + 1)\n\n\nwhile n:\n l = list(map(int, input().split()))\n c = set(l[2:])\n tree[l[0]] = [c, None, None]\n root -= c\n n -= 1\n\nset_pd(root.pop(), -1, 0)\n\nfor i, node in enumerate(tree):\n c, p, d = node\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(\n i, p, d, 'root' if not d else 'internal node' if c else 'leaf', ', '.join(map(str, c))\n ))", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [231, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u072053884", "n_user": "u072053884", "pos": "class Node:\n def __init__(self, num, parent, children):\n self.id = num\n self.parent = -1\n self.children = children\n self.depth = 0\n \n def show_info(self):\n print('node {0}: '.format(self.id), end = '')\n print('parent = {0}, '.format(self.parent), end = '')\n print('depth = {0}, '.format(self.depth), end = '')\n if self.children and self.parent != -1:\n print('internal node, ', end = '')\n elif self.parent != -1:\n print('leaf, ', end = '')\n else:\n print('root, ', end = '')\n print(self.children)\n\n\ndef set_node(i_s):\n i_l = list(map(int, i_s.split()))\n num = i_l[0]\n children = i_l[2:]\n node = Node(num, -1, children)\n T[num] = node\n for n in children:\n T[-1] -= n\n\ndef set_pd(n_i, parent, depth):\n node = T[n_i]\n node.parent = parent\n node.depth = depth\n for n in node.children:\n set_pd(n, n_i, depth + 1)\n\n\nimport sys\n\nn = int(sys.stdin.readline())\n\nT = [None] * n\n\nT.append(int(n * (n - 1) / 2))\n\nfor x in sys.stdin.readlines():\n set_node(x)\n\nset_pd(T[-1], -1, 0)\n\nfor n in T[:-1]:\n n.show_info()", "neg": "class Node:\n def __init__(self, num, parent, children):\n self.id = num\n self.parent = -1\n self.children = children\n self.depth = 0\n \n def show_info(self):\n print('node {0}: '.format(self.id), end = '')\n print('parent = {0}, '.format(self.parent), end = '')\n print('depth = {0}, '.format(self.depth), end = '')\n if self.children and self.parent != -1:\n print('internal node, ', end = '')\n elif self.parent != -1:\n print('leaf, ', end = '')\n else:\n print('root, ', end = '')\n print(self.children)\n\n\ndef set_node(i_s):\n i_l = list(map(int, i_s.split()))\n num = i_l[0]\n children = i_l[2:]\n node = Node(num, -1, children)\n T[num] = node\n for n in children:\n T[-1] -= n\n\ndef set_pd(node, parent, depth):\n node.parent = parent\n node.depth = depth\n for n in node.children:\n set_pd(T[n], node.id, depth + 1)\n\n\nimport sys\n\nn = int(sys.stdin.readline())\n\nT = [None for i in range(n)]\n\nT.append(int(n * (n - 1) / 2))\n\nfor x in sys.stdin.readlines():\n set_node(x)\n\nprint(T[-1])\n\nset_pd(T[T[-1]], -1, 0)\n\nfor n in T[:-1]:\n n.show_info()", "jacc_sim": 0.953125, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [430, 435], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u777299405", "n_user": "u777299405", "pos": "class Tree():\n\n def __init__(self):\n self.parent = -1\n self.depth = 0\n self.child = []\n\nn = int(input())\ntree = [Tree() for i in range(n)]\nfor i in range(n):\n cmd = list(map(int, input().split()))\n node = tree[cmd[0]]\n node.child.extend(cmd[2:])\n for j in cmd[2:]:\n tree[j].parent = cmd[0]\n\nfor t in tree:\n d, p = 0, t.parent\n while p != -1:\n d += 1\n p = tree[p].parent\n t.depth = d\n\nfor i in range(n):\n t = tree[i]\n if t.parent == -1:\n state = \"root\"\n elif t.child:\n state = \"internal node\"\n else:\n state = \"leaf\"\n print(\"node {}: parent = {}\".format(i, t.parent), \"depth = {}\".format(\n t.depth), state, \"[{}]\".format(\", \".join(map(str, t.child))), sep=\", \")", "neg": "class Tree():\n\n def __init__(self):\n self.parent = -1\n self.depth = 0\n self.child = []\n\nn = int(input())\ntree = [Tree() for i in range(n)]\nfor i in range(n):\n cmd = list(map(int, input().split()))\n node = tree[cmd[0]]\n node.child.extend(cmd[2:])\n for j in cmd[2:]:\n tree[j].parent = cmd[0]\n\nfor t in tree:\n d, p = 0, t.parent\n while p != -1:\n d += 1\n p = tree[p].parent\n t.depth = d\n\nfor i in range(n):\n t = tree[i]\n if t.parent == -1:\n state = \"root\"\n elif t.child:\n state = \"internal node\"\n else:\n state = \"leaf\"\nprint(\"node {}: parent = {}\".format(i, t.parent), \"depth = {}\".format(\n t.depth), state, \"[{}]\".format(\", \".join(map(str, t.child))), sep=\", \")", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [287, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u963402991", "n_user": "u963402991", "pos": "\n\nclass Node:\n def __init__(self, num, children):\n self.num = num\n self.children = children\n self.parents = -1\n self.type = None\n self.depth = 0\n\n def output(self):\n print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.num,\n self.parents,\n self.depth,\n self.type,\n self.children))\n\n\ndef set_node(num, children):\n node = Node(num, children)\n T[num] = node\n for n in children:\n T[-1] -= n # ?????\u00a3???T[-1]???root???????????????????????????\n\n\ndef set_pdt(n_i, parent, depth):\n node = T[n_i]\n node.parents = parent\n node.depth = depth\n if node.children:\n node.type = 'internal node'\n for n in node.children:\n set_pdt(n, n_i, depth + 1)\n else:\n node.type = 'leaf'\n\n\nn = int(input())\ntree = [list(map(int, input().split())) for i in range(n)]\nT = [None] * n\nT += [n * (n - 1) // 2]\nfor j in tree:\n set_node(j[0], j[2:])\n\nset_pdt(T[-1], -1, 0)\n\nT[T[-1]].type = 'root'\n\nfor n in T[:-1]:\n n.output()", "neg": "\n\nclass Node:\n def __init__(self, num, children):\n self.num = num\n self.children = children\n self.parents = -1\n self.type = None\n self.depth = 0\n\n def output(self):\n print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.num,\n self.parents,\n self.depth,\n self.type,\n self.children))\n\n\ndef set_node(num, children):\n node = Node(num, children)\n T[num] = node\n\n\ndef set_pdt(n_i, parent, depth):\n node = T[n_i]\n node.parents = parent\n node.depth = depth\n if node.children:\n node.type = 'internal node'\n for n in node.children:\n set_pdt(n, n_i, depth + 1)\n else:\n node.type = 'leaf'\n\n\nn = int(input())\ntree = [list(map(int, input().split())) for i in range(n)]\nT = [None] * n\nfor j in tree:\n set_node(j[0], j[2:])\n\nset_pdt(0, -1, 0)\n\nT[0].type = 'root'\n\nfor n in T:\n n.output()", "jacc_sim": 0.9333333333333333, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [413, 346], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u564398841", "n_user": "u564398841", "pos": "\n\ndef main():\n N = int(input())\n A = [0] * N\n node_info = [[-1, 0, 'internal node', None] for _ in range(int(1E5 + 1))]\n for i in range(N):\n A[i] = [int(i) for i in input().strip().split()]\n for line in A:\n if line[1] != 0:\n node_info[line[0]][3] = line[2:]\n for c in line[2:]:\n node_info[c][0] = line[0]\n\n for line in A:\n pid = node_info[line[0]][0]\n if pid == -1:\n node_info[line[0]][2] = 'root'\n else:\n if node_info[line[0]][3] is None:\n node_info[line[0]][2] = 'leaf'\n if node_info[line[0]][3] is None:\n node_info[line[0]][3] = ['']\n\n depth = 0\n while pid != -1:\n depth += 1\n pid = node_info[pid][0]\n node_info[line[0]][1] = depth\n\n for line in sorted(A, key=lambda a: a[0]):\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(\n line[0], node_info[line[0]][0],\n node_info[line[0]][1], node_info[line[0]][2], ', '.join([str(i) for i in node_info[line[0]][3]]))\n )\n\n\nif __name__ == '__main__':\n main()", "neg": "fin = open('sample.txt')\ninput = fin.readline\n\n\ndef main():\n N = int(input())\n A = [0] * N\n node_info = [[-1, 0, 'internal node', None] for _ in range(int(1E5 + 1))]\n for i in range(N):\n A[i] = [int(i) for i in input().strip().split()]\n for line in A:\n if line[1] != 0:\n node_info[line[0]][3] = line[2:]\n for c in line[2:]:\n node_info[c][0] = line[0]\n\n for line in A:\n pid = node_info[line[0]][0]\n if pid == -1:\n node_info[line[0]][2] = 'root'\n else:\n if node_info[line[0]][3] is None:\n node_info[line[0]][2] = 'leaf'\n if node_info[line[0]][3] is None:\n node_info[line[0]][3] = ['']\n\n depth = 0\n while pid != -1:\n depth += 1\n pid = node_info[pid][0]\n node_info[line[0]][1] = depth\n\n for line in sorted(A, key=lambda a: a[0]):\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(\n line[0], node_info[line[0]][0],\n node_info[line[0]][1], node_info[line[0]][2], ', '.join([str(i) for i in node_info[line[0]][3]]))\n )\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9206349206349206, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [431, 447], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u564398841", "n_user": "u564398841", "pos": "N = int(input())\n\ntree = [{'p': -1, 'c': list(), 'd': 0} for _ in range(N)]\n\nfor _ in range(N):\n l = list(map(int, input().split()))\n tree[l[0]]['c'] = l[2:]\n for i in l[2:]:\n tree[i]['p'] = l[0]\n\n\ndef calcDepth(tree, root, curDepth=0):\n tree[root]['d'] = curDepth\n [calcDepth(tree, c, curDepth + 1) for c in tree[root]['c']]\n\n\nr = 0\nfor i, t in enumerate(tree):\n if t['p'] == -1:\n r = i\n break\ncalcDepth(tree, r)\n\nfor i in range(N):\n state = 'leaf'\n if tree[i]['p'] == -1:\n state = 'root'\n elif len(tree[i]['c']):\n state = 'internal node'\n print('node {i}: parent = {p}, depth = {d}, {state}, {ch}'.format(\n i=i, p=tree[i]['p'], d=tree[i]['d'], state=state, ch=tree[i]['c']\n ))", "neg": "N = int(input())\n\ntree = [{'p': -1, 'c': list(), 'd': 0} for _ in range(N)]\n\nfor _ in range(N):\n l = list(map(int, input().split()))\n tree[l[0]]['c'] = l[2:]\n for i in l[2:]:\n tree[i]['p'] = l[0]\n\n\ndef calcDepth(tree, root, curDepth=0):\n tree[root]['d'] = curDepth\n [calcDepth(tree, c, curDepth + 1) for c in tree[root]['c']]\n\n\ncalcDepth(tree, 0)\n\nfor i in range(N):\n state = 'leaf'\n if tree[i]['p'] == -1:\n state = 'root'\n elif len(tree[i]['c']):\n state = 'internal node'\n print('node {i}: parent = {p}, depth = {d}, {state}, {ch}'.format(\n i=i, p=tree[i]['p'], d=tree[i]['d'], state=state, ch=tree[i]['c']\n ))", "jacc_sim": 0.9245283018867925, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [312, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u603049633", "n_user": "u603049633", "pos": "class Node:\n def __init__(self, num, parent, children):\n self.id = num\n self.parent = -1\n self.depth = 0\n self.type = None\n self.children = children\n \n def show(self):\n print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,self.parent,self.depth,self.type,self.children))\n \n \ndef set_node(node_data):\n L = list(map(int, node_data.split()))\n num = L[0]\n children = L[2:]\n node = Node(num, -1, children)\n T[num] = node\n for n in children:\n T[-1] -= n\n \ndef set_pdt(n_i, parent, depth):\n node = T[n_i]\n node.parent = parent\n node.depth = depth\n if node.children:\n node.type = 'internal node'\n for n in node.children:\n set_pdt(n, n_i, depth + 1)\n else:\n node.type = 'leaf'\n \nn = int(input())\n \nT = [None] * n\n \nT.append(int(n * (n - 1) / 2))\n \nfor i in range(n):\n x = input()\n set_node(x)\n \nset_pdt(T[-1], -1, 0)\n \nT[T[-1]].type ='root'\n \nfor n in T[:-1]:\n n.show()", "neg": "class Node:\n def __init__(self, num, parent, children):\n self.id = num\n self.parent = -1\n self.depth = 0\n self.type = None\n self.children = children\n \n def show(self):\n print('node {0}: parent = {1}, depth = {2}, {3}, {4}'.format(self.id,self.parent,self.depth,self.type,self.children))\n \n \ndef set_node(node_data):\n L = list(map(int, node_data.split()))\n num = i_l[0]\n children = i_l[2:]\n node = Node(num, -1, children)\n T[num] = node\n for n in children:\n T[-1] -= n\n \ndef set_pdt(n_i, parent, depth):\n node = T[n_i]\n node.parent = parent\n node.depth = depth\n if node.children:\n node.type = 'internal node'\n for n in node.children:\n set_pdt(n, n_i, depth + 1)\n else:\n node.type = 'leaf'\n \nn = int(input())\n \nT = [None] * n\n \nT.append(int(n * (n - 1) / 2))\n \nfor i in range(n):\n x = input()\n set_node(x)\n \nset_pdt(T[-1], -1, 0)\n \nT[T[-1]].type ='root'\n \nfor n in T[:-1]:\n n.show()", "jacc_sim": 0.9833333333333333, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [400, 404], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u533883485", "n_user": "u533883485", "pos": "# coding=utf-8\n\nclass Node:\n def __init__(self, idx, degree, children=None):\n self.id = idx\n self.parent = -1 #??????\n self.depth = 0 #??????\n self.type = None #??????\n self.children = children\n\nn = int(input())\ndata = [list(map(int, input().split())) for x in range(n)]\nnode_list = [None for i in range(n)]\n\nfor data_row in data:\n idx, degree, *children = data_row\n node = Node(idx, degree, children)\n node_list[idx] = node\n\n### set parent & type ###\nfor node in node_list:\n i = node.id\n if node.children:\n node.type = \"internal node\"\n for child in node.children:\n node_list[child].parent = i\n else:\n node.type = \"leaf\"\n\n### calc depth ###\nfor i, node in enumerate(node_list):\n depth = 0\n parent = node.parent\n #?????\\???type\n if parent == -1:\n node.type = \"root\"\n while parent != -1:\n parent = node_list[parent].parent\n depth += 1\n node.depth = depth\n\nfor node in node_list:\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(node.id, node.parent, node.depth, node.type, node.children))", "neg": "# coding=utf-8\n\nclass Node:\n def __init__(self, idx, degree, children=None):\n self.id = idx\n self.parent = -1 #??????\n self.depth = 0 #??????\n self.type = None #??????\n self.children = children\n\nn = int(input())\ndata = [list(map(int, input().split())) for x in range(n)]\nnode_list = []\n\nfor data_row in data:\n idx, degree, *children = data_row\n node = Node(idx, degree, children)\n node_list.append(node)\n\n### set parent & type ###\nfor i, node in enumerate(node_list):\n if node.children:\n node.type = \"internal node\"\n for child in node.children:\n node_list[child].parent = i\n else:\n node.type = \"leaf\"\n\n### calc depth ###\nfor i, node in enumerate(node_list):\n depth = 0\n parent = node.parent\n #?????\\???type\n if parent == -1:\n node.type = \"root\"\n while parent != -1:\n parent = node_list[parent].parent\n depth += 1\n node.depth = depth\n\nfor node in node_list:\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(node.id, node.parent, node.depth, node.type, node.children))", "jacc_sim": 0.9846153846153847, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [369, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u091533407", "n_user": "u091533407", "pos": "import sys\n\n\ndef dep(u, p):\n D[u] = p\n for i in tree[u][3]:\n dep(i, p+1)\n\n\ndef print_ans():\n for i in range(n):\n print(\"node {}: parent = {}, depth = {}, {}, {}\"\n .format(i, tree[i][0], D[i],\n \"root\" if tree[i][0] == NIL else \"leaf\" if tree[i][1] == NIL else \"internal node\",\n tree[i][3]))\n\n\nif __name__ == \"__main__\":\n NIL = -1\n n = int(sys.stdin.readline())\n tree = [[NIL, NIL, NIL] for i in range(n)]\n D = [0 for i in range(n)]\n root = set(range(n))\n for a in sys.stdin.readlines():\n a = list(map(int, a.split()))\n tree[a[0]].append(a[2:])\n if a[1] > 0:\n tree[a[0]][1] = a[2] # ???????????????\n for i in range(a[1]):\n tree[a[i+2]][0] = a[0] # ????????????\n if i != a[1] - 1:\n tree[a[i+2]][2] = a[i+3] # ??????????????????\n root -= set(a[2:])\n dep(root.pop(), 0)\n print_ans()", "neg": "import sys\n\n\ndef dep(u, p):\n D[u] = p\n for i in tree[u][3]:\n print(\"a\")\n dep(i, p+1)\n\n\ndef print_ans():\n for i in range(n):\n print(\"node {}: parent = {}, depth = {}, {}, {}\"\n .format(i, tree[i][0], D[i],\n \"root\" if tree[i][0] == NIL else \"leaf\" if tree[i][1] == NIL else \"internal node\",\n tree[i][3]))\n\n\nif __name__ == \"__main__\":\n NIL = -1\n n = int(sys.stdin.readline())\n tree = [[NIL, NIL, NIL] for i in range(n)]\n D = [0 for i in range(n)]\n root = set(range(n))\n for a in sys.stdin.readlines():\n a = list(map(int, a.split()))\n tree[a[0]].append(a[2:])\n if a[1] > 0:\n tree[a[0]][1] = a[2] # ???????????????\n for i in range(a[1]):\n tree[a[i+2]][0] = a[0] # ????????????\n if i != a[1] - 1:\n tree[a[i+2]][2] = a[i+3] # ??????????????????\n root -= set(a[2:])\n dep(root.pop(), 0)\n print_ans()", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [392, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u510829608", "n_user": "u510829608", "pos": "import sys\n\nNIL = -1\n\ndef set_depth(v, depth):\n tree[v][2] = depth\n \n for child in tree[v][1]:\n set_depth(child, depth + 1)\n\nN = int(input())\ntree = [[NIL, [], 0, 'leaf'] for _ in range(N)]\n\nfor _ in range(N):\n line = [int(i) for i in sys.stdin.readline().split()]\n t_id = line[0]\n children = line[2:]\n tree[t_id][1] = children\n \n if children:\n tree[t_id][3] = 'internal node'\n \n for child in children:\n tree[child][0] = t_id\n \nfor t_id in range(N):\n if tree[t_id][0] == NIL:\n tree[t_id][3] = 'root'\n r = t_id\n break\n\nset_depth(r, 0)\n\nfor t_id in range(N):\n parent = tree[t_id][0]\n depth = tree[t_id][2]\n children = tree[t_id][1]\n type_t = tree[t_id][3]\n \n print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))", "neg": "import sys\n\nNIL = -1\n\ndef set_depth(v, depth):\n tree[v][2] = depth\n \n if child in tree[v][1]:\n set_depth(child, depth + 1)\n\nN = int(input())\ntree = [[NIL, [], 0, 'leaf'] for _ in range(N)]\n\nfor _ in range(N):\n line = [int(i) for i in sys.stdin.readline().split()]\n t_id = line[0]\n children = line[2:]\n tree[t_id][1] = children\n \n if children:\n tree[t_id][3] = 'internal node'\n \n for child in children:\n tree[child][0] = t_id\n \nfor t_id in range(N):\n if tree[t_id][0] == NIL:\n tree[t_id][3] = 'root'\n r = t_id\n break\n\nset_depth(r, 0)\n\nfor t_id in range(N):\n parent = tree[t_id][0]\n depth = tree[t_id][2]\n children = tree[t_id][1]\n type_t = tree[t_id][3]\n \n print('node {}: parent = {}, depth = {}, {}, {}'.format(t_id, parent, depth, type_t, children))", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [343, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u855199458", "n_user": "u855199458", "pos": "# -*- coding: utf-8 -*-\nN = int(input())\ntree = {n:{} for n in range(N)}\nchildren = set()\n\nfor n in range(N):\n inp = [int(m) for m in input().split()]\n tree[inp[0]][\"leaf\"] = inp[2:]\n children.update(inp[2:])\n\nparent = set([n for n in range(N)]).difference(children).pop()\ntree[parent][\"depth\"] = 0\ntree[parent][\"parent\"] = -1\n\nsiblings = tree[parent][\"leaf\"]\nfor c in siblings:\n tree[c][\"depth\"] = 1\n tree[c][\"parent\"] = parent\n\ndepth = 2\nwhile len(children):\n children = children.difference(siblings)\n next_gen = []\n for s in siblings:\n next_gen.extend(tree[s][\"leaf\"])\n for c in tree[s][\"leaf\"]:\n tree[c][\"depth\"] = depth\n tree[c][\"parent\"] = s\n siblings = next_gen\n depth += 1\n\n \nfor n in range(N):\n if tree[n][\"depth\"] == 0:\n tree[n][\"type\"] = \"root\"\n elif tree[n][\"leaf\"] == []:\n tree[n][\"type\"] = \"leaf\"\n else:\n tree[n][\"type\"] = \"internal node\"\n \n print(\"node {}: parent = {}, depth = {}, {}, {}\" \\\n .format(n, tree[n][\"parent\"], tree[n][\"depth\"], tree[n][\"type\"], tree[n][\"leaf\"]))", "neg": "# -*- coding: utf-8 -*-\nN = int(input())\ntree = {n:{} for n in range(N)}\nchildren = set()\n\nfor n in range(N):\n inp = [int(m) for m in input().split()]\n tree[n][\"leaf\"] = inp[2:]\n children.update(inp[2:])\n\nparent = set([n for n in range(N)]).difference(children).pop()\ntree[parent][\"depth\"] = 0\ntree[parent][\"parent\"] = -1\n\nsiblings = tree[parent][\"leaf\"]\nfor c in siblings:\n tree[c][\"depth\"] = 1\n tree[c][\"parent\"] = parent\n\ndepth = 2\nwhile len(children):\n children = children.difference(siblings)\n next_gen = []\n for s in siblings:\n next_gen.extend(tree[s][\"leaf\"])\n for c in tree[s][\"leaf\"]:\n tree[c][\"depth\"] = depth\n tree[c][\"parent\"] = s\n siblings = next_gen\n depth += 1\n\n \nfor n in range(N):\n if tree[n][\"depth\"] == 0:\n tree[n][\"type\"] = \"root\"\n elif tree[n][\"leaf\"] == []:\n tree[n][\"type\"] = \"leaf\"\n else:\n tree[n][\"type\"] = \"internal node\"\n \n print(\"node {}: parent = {}, depth = {}, {}, {}\" \\\n .format(n, tree[n][\"parent\"], tree[n][\"depth\"], tree[n][\"type\"], tree[n][\"leaf\"]))", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [409, 406], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u918276501", "n_user": "u918276501", "pos": "def set_pdt(i, p, d):\n u = tree[i]\n u[0], u[1] = p, d\n for c in u[3]:\n set_pdt(c, i, d+1)\n else:\n if u[0] == -1:\n u[2] = \"root\"\n elif u[3]:\n u[2] = \"internal node\"\n else:\n u[2] = \"leaf\"\n\nn = int(input())\ntree = [[-1,0,0,0] for _ in range(n)]\nroot = set(range(n))\n\nfor _ in range(n):\n i, k, *c = map(int, input().split())\n tree[i][3] = c\n root -= set(c)\n \nset_pdt(root.pop(), -1, 0)\n\nfor i in range(n):\n u = tree[i]\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(i, *u))", "neg": "def set_pdt(i, p, d):\n u = tree[i]\n u[0], u[1] = p, d\n for c in u[3]:\n set_pdt(c, i, d+1)\n else:\n if u[0] == -1:\n u[2] = \"root\"\n elif u[3]:\n u[2] = \"internal node\"\n else:\n u[2] = \"leaf\"\n\nn = int(input())\n# p d t ch\ntree = [[-1,0,0,0] for _ in range(n)]\nroot = set(range(n))\n\nfor _ in range(n):\n i, k, *c = map(int, input().split())\n tree[i][3] = c\n root -= set(c)\n \nset_pdt(root[0], -1, 0)\n\nfor i in range(n):\n u = tree[i]\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(i, *u))", "jacc_sim": 0.9230769230769231, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [252, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u024715419", "n_user": "u024715419", "pos": "def set_info(a, i, p, d):\n a[i][1], a[i][2] = p, d\n for b in a[i][0]:\n set_info(a, b, i, d + 1)\n\nn = int(input())\ntree = [[None] for i in range(n)]\nroot = set(range(n))\n\nfor i in range(n):\n l = list(map(int, input().split()))\n tree[l[0]] = [l[2:], None, None]\n root -= set(l[2:])\n\nset_info(tree, root.pop(), -1, 0)\n\nfor i in range(n):\n c, p, d = tree[i]\n if p == -1:\n t = \"root\"\n elif len(c) == 0:\n t = \"leaf\"\n else:\n t = \"internal node\"\n print(\"node \", i, \": parent = \", p, \", depth = \", d, \", \", t, \", \", c, sep=\"\")", "neg": "def set_info(a, i, p, d):\n a[i][1], a[i][2] = p, d\n for b in a[i][0]:\n set_info(a, b, i, d + 1)\n\nn = int(input())\ntree = [[None] for i in range(n)]\nroot = set(range(n))\n\nfor i in range(n):\n l = list(map(int, input().split()))\n tree[l[0]] = [l[2:], None, None]\n root -= set(l[2:])\n\nset_info(tree, root.pop(), -1, 0)\n\nfor i in range(n):\n c, p, d = tree[i]\n if p == -1:\n t = \"root\"\n elif len(c) == 0:\n t = \"leaf\"\n else:\n t = \"internal node\"\n print(\"node \", i, \": parent = \", p, \" depth = \", d, \", \", t, \", \", c, sep=\"\")", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [255, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u662418022", "n_user": "u662418022", "pos": "# -*- coding: utf-8 -*-\nimport sys\nsys.setrecursionlimit(200000)\n\nclass Node():\n def __init__(self, ID, parent=-1, left=-1, right=-1, depth=0, children=[]):\n self.id = ID\n self.parent = parent\n self.left = left\n self.right = right\n self.depth = depth\n self.children = children\n\n\nif __name__ == '__main__':\n\n n = int(input())\n tree = [Node(i) for i in range(n)]\n\n for _ in range(n):\n line = [int(l) for l in input().split(\" \")]\n ID = line[0]\n d = line[1]\n if d == 0:\n continue\n else:\n children = line[2:]\n tree[ID].children = children\n tree[ID].left = children[0]\n for j in range(0, d):\n tree[children[j]].parent = ID\n if j < d - 1:\n tree[children[j]].right = children[j + 1]\n\n def setDepth(u, p):\n tree[u].depth = p\n if tree[u].right != -1:\n setDepth(tree[u].right, p)\n if tree[u].left != -1:\n setDepth(tree[u].left, p + 1)\n\n for node in tree:\n if node.parent == -1:\n root = node.id\n\n setDepth(root, 0)\n\n for node in tree:\n if node.parent == -1:\n n_type = \"root\"\n elif node.left != -1:\n n_type = \"internal node\"\n else:\n n_type = \"leaf\"\n\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(\n node.id, node.parent, node.depth, n_type, node.children))\n \n", "neg": "# -*- coding: utf-8 -*-\n\n\nclass Node():\n def __init__(self, ID, parent=-1, left=-1, right=-1, depth=0, children=[]):\n self.id = ID\n self.parent = parent\n self.left = left\n self.right = right\n self.depth = depth\n self.children = children\n\n\nif __name__ == '__main__':\n\n n = int(input())\n tree = [Node(i) for i in range(n)]\n\n for _ in range(n):\n line = [int(l) for l in input().split(\" \")]\n ID = line[0]\n d = line[1]\n if d == 0:\n continue\n else:\n children = line[2:]\n tree[ID].children = children\n tree[ID].left = children[0]\n for j in range(0, d):\n tree[children[j]].parent = ID\n if j < d - 1:\n tree[children[j]].right = children[j + 1]\n\n def setDepth(u, p):\n tree[u].depth = p\n print(u, p)\n if tree[u].right != -1:\n setDepth(tree[u].right, p)\n if tree[u].left != -1:\n setDepth(tree[u].left, p + 1)\n\n for node in tree:\n if node.parent == -1:\n root = node.id\n\n setDepth(root, 0)\n\n for node in tree:\n if node.parent == -1:\n n_type = \"root\"\n elif node.left != -1:\n n_type = \"internal node\"\n else:\n n_type = \"leaf\"\n\n print(\"node {}: parent = {}, depth = {}, {}, {}\".format(\n node.id, node.parent, node.depth, n_type, node.children))\n \n", "jacc_sim": 0.9428571428571428, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [486, 482], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u996463517", "n_user": "u996463517", "pos": "class tree:\n def __init__(self,name,parent):\n self.name = name\n self.parent = parent\n \n \nn = int(input())\ntrees = {str(i):tree(str(i),'-1') for i in range(n)}\nchild = {}\n\nfor i in range(n):\n s = [i for i in input().split()]\n p = s[0]\n child[p] = s[2:]\n s_t = s[2:]\n for j in range(len(s_t)):\n trees[s_t[j]] = tree(s_t[j],p)\n\ndef getDepth(u):\n d = 0\n while trees[u].parent != '-1':\n u = trees[u].parent\n d += 1\n return d\n\ndef getChildren(u):\n c = []\n for i in trees.values():\n if i.parent == u:\n c.append(i.name)\n return c\n\nfor i in range(n):\n \n par = trees[str(i)].parent\n dep = getDepth(str(i))\n ch = [int(i) for i in child[str(i)]]\n \n if par == '-1':sit = 'root'\n elif len(ch) != 0:sit = 'internal node'\n else:sit = 'leaf'\n \n print('node {}: parent = {}, depth = {}, {}, {}'.format(i,par,dep,sit,ch))\n", "neg": "class tree:\n def __init__(self,name,parent):\n self.name = name\n self.parent = parent\n \n \nn = int(input())\ntrees = {str(i):tree(str(i),'-1') for i in range(n)}\n\n\nfor i in range(n):\n s = [i for i in input().split()]\n p = s[0]\n\n s_t = s[2:]\n for j in range(len(s_t)):\n trees[s_t[j]] = tree(s_t[j],p)\n\ndef getDepth(u):\n d = 0\n while trees[u].parent != '-1':\n u = trees[u].parent\n d += 1\n return d\n\ndef getChildren(u):\n c = []\n for i in trees.values():\n if i.parent == u:\n c.append(i.name)\n return c\n\nfor i in range(n):\n \n par = trees[str(i)].parent\n dep = getDepth(str(i))\n ch = sorted([int(i) for i in getChildren(str(i))])\n \n if par == '-1':sit = 'root'\n elif len(ch) != 0:sit = 'internal node'\n else:sit = 'leaf'\n \n print('node {}: parent = {}, depth = {}, {}, {}'.format(i,par,dep,sit,ch))\n\n", "jacc_sim": 0.9692307692307692, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [365, 354], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u177808190", "n_user": "u177808190", "pos": "import collections\n\ndef search(node, elems, tree, depth):\n elems[node].append(depth)\n if elems[node][0] == -1:\n state = 'root'\n elif not tree[node]:\n state = 'leaf'\n else:\n state = 'internal node'\n elems[node].append(state)\n elems[node].append(tree[node])\n depth += 1\n for c in tree[node]:\n search(c, elems, tree, depth)\n \nif __name__ == '__main__':\n n = int(input())\n tree = collections.defaultdict(list)\n elems = collections.defaultdict(list)\n #elems key:id, value: parent, depth, state, children\n parents = list()\n node_list = list()\n for _ in range(n):\n hoge = [int(x) for x in input().split()]\n node_list.append(hoge[0])\n tree[hoge[0]]\n for childs in range(hoge[1]):\n tree[hoge[0]].append(hoge[childs+2])\n \n for key, value in tree.items():\n for v in value:\n elems[v].append(key)\n for node in node_list:\n if not elems[node]:\n parents.append(node)\n elems[node].append(-1)\n \n for p in parents:\n search(p, elems, tree, 0)\n \n for key, value in sorted(elems.items()):\n print('node {0}: parent = {1[0]}, depth = {1[1]}, {1[2]}, '.format(key, value), end='')\n print (value[-1])\n", "neg": "import collections\n\ndef search(node, elems, tree, depth):\n elems[node].append(depth)\n if elems[node][0] == -1:\n state = 'root'\n elif not tree[node]:\n state = 'leaf'\n else:\n state = 'internal node'\n elems[node].append(state)\n elems[node].append(tree[node])\n depth += 1\n for c in tree[node]:\n search(c, elems, tree, depth)\n \nif __name__ == '__main__':\n n = int(input())\n tree = collections.defaultdict(list)\n elems = collections.defaultdict(list)\n #elems key:id, value: parent, depth, state, children\n parents = list()\n node_list = list()\n for _ in range(n):\n hoge = [int(x) for x in input().split()]\n node_list.append(hoge[0])\n tree[hoge[0]]\n for childs in range(hoge[1]):\n tree[hoge[0]].append(hoge[childs+2])\n \n for key, value in tree.items():\n for v in value:\n elems[v].append(key)\n for node in node_list:\n if not elems[node]:\n parents.append(node)\n elems[node].append(-1)\n \n for p in parents:\n search(p, elems, tree, 0)\n \n for key, value in elems.items():\n print('node {0}: parent = {1[0]}, depth = {1[1]}, {1[2]}, '.format(key, value), end='')\n print (value[-1])\n", "jacc_sim": 0.984375, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [434, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u150984829", "n_user": "u150984829", "pos": "def q(a,h):\n d[a]=str(h)\n for b in t[a]:q(b,h+1)\nt,p,d={},{},{}\nfor _ in[0]*int(input()):\n e=input().split()\n t[e[0]]=e[2:]\n for i in e[2:]:p[i]=e[0]\nr=(set(t)-set(p)).pop()\np[r]='-1'\nq(r,0)\nprint('\\n'.join(f\"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]\"for i in map(str,sorted(map(int,t)))))\n", "neg": "def q(a,h):\n d[a]=str(h)\n for b in t[a]:q(b,h+1)\nt,p,d={},{},{}\nfor _ in[0]*int(input()):\n e=input().split()\n t[e[0]]=e[2:]\n for i in e[2:]:p[i]=e[0]\nr=(set(t)-set(p)).pop()\np[r]='-1'\nq(r,0)\nprint('\\n'.join(\"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]\"for i in map(str,sorted(map(int,t)))))\n", "jacc_sim": 0.9807692307692307, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [207, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u912143677", "n_user": "u912143677", "pos": "NIL = -1\n\nclass Node:\n parent = NIL\n left = NIL\n right = NIL\n\nn = int(input())\nt = [Node() for i in range(n)]\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n id = tmp.pop(0)\n k = tmp.pop(0)\n c = tmp\n if k != 0:\n for j in c:\n t[j].parent = id\n t[id].left = c[0]\n for j in range(len(c)-1):\n t[c[j]].right = c[j+1]\n\ndef getdepth(u):\n d = 0\n while t[u].parent != NIL:\n u = t[u].parent\n d += 1\n return d\n\ndef getchildren(u):\n c = t[u].left\n result = []\n while c != NIL:\n result.append(c)\n c = t[c].right\n return result\n\nfor i in range(n):\n d = getdepth(i)\n c = getchildren(i)\n if d == 0:\n v = \"root\"\n elif c == []:\n v = \"leaf\"\n else:\n v = \"internal node\"\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, t[i].parent, d, v, ', '.join(map(str, c))))\n\n", "neg": "NIL = -1\n\nclass Node:\n parent = NIL\n left = NIL\n right = NIL\n\nn = int(input())\nt = [Node() for i in range(n)]\n\nfor i in range(n):\n tmp = list(map(int, input().split()))\n id = tmp.pop(0)\n k = tmp.pop(0)\n c = tmp\n if k != 0:\n for j in c:\n t[j].parent = id\n t[id].left = c[0]\n for j in range(len(c)-1):\n t[c[j]].right = c[j+1]\n\ndef getdepth(u):\n d = 0\n while t[u].parent != NIL:\n u = t[u].parent\n d += 1\n return d\n\ndef getchildren(u):\n c = t[u].left\n result = []\n while c != NIL:\n result.append(c)\n c = t[c].right\n return result\n\nfor i in range(n):\n d = getdepth(i)\n c = getchildren(i)\n if d == 0:\n v = \"root\"\n elif c == []:\n v = \"leaf\"\n else:\n v = \"internal node\"\nprint('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, t[i].parent, d, v, ', '.join(map(str, c))))\n", "jacc_sim": 1.0, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [367, 365], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02279", "p_user": "u793684078", "n_user": "u408260374", "pos": "class Node:\n def __init__(self):\n self.parent = -1\n self.children = []\n self.type = ''\n self.depth = 0\n\ndef walk_tree(v, d=0):\n Nodes[v].depth = d\n for child in Nodes[v].children:\n walk_tree(child, d+1)\n\nN = int(input())\nNodes = [Node() for _ in range(N)]\nfor _ in range(N):\n idx, k, *children = [int(x) for x in input().split()]\n Nodes[idx].children = children\n if k:\n Nodes[idx].type = 'internal node'\n else:\n Nodes[idx].type = 'leaf'\n for child in children:\n Nodes[child].parent = idx\nroot = [i for i, x in enumerate(Nodes) if x.parent == -1][0]\nNodes[root].type = 'root'\nwalk_tree(root)\nfor i, node in enumerate(Nodes):\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))\n", "neg": "class Node:\n def __init__(self):\n self.parent = -1\n\n\ndef dfs(v, d=0):\n G[v].depth = d\n for child in G[v].children:\n dfs(child, d+1)\n\n\nN = int(input())\nG = [Node() for _ in range(N)]\nfor _ in range(N):\n idx, k, *children = [int(x) for x in input().split()]\n G[idx].children = children\n if k:\n G[idx].type = 'internal node'\n else:\n G[idx].type = 'leaf'\n for child in children:\n G[child].parent = idx\nroot = [i for i, x in enumerate(G) if x.parent == -1][0]\nG[root].type = 'root'\ndfs(root)\nfor i, node in enumerate(G):\n print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ','.join(map(str, node.children))))", "jacc_sim": 0.9285714285714286, "nl": "Rooted Trees\n\nA graph G = (V, E) is a data structure where V is a finite set of vertices and E is a binary relation on V represented by a set of edges. Fig. 1 illustrates an example of a graph (or graphs).\n\nA free tree is a connected, acyclic, undirected graph. A rooted tree is a free tree in which one of the vertices is distinguished from the others. A vertex of a rooted tree is called \"node.\"\n\nYour task is to write a program which reports the following information for each node u of a given rooted tree T:\n\n- node ID of u\n- parent of u\n- depth of u\n- node type (root, internal node, or leaf)\n- a list of children of u\n\nIf the last edge on the path from the root r of a tree T to a node x is (p, x), then p is the parent of x, and x is a child of p. The root is the only node in T with no parent.\n\nA node with no children is an external node or leaf. A non-leaf node is an internal node.\n\nThe number of children of a node x in a rooted tree T is called the degree of x.\n\nThe length of the path from the root r to a node x is the depth of x in T.\n\nHere, the given tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nFig. 2 shows an example of rooted trees where ID of each node is indicated by a number in a circle (node). The example corresponds to the first sample input.\n\nInput\n\nThe first line of the input includes an integer n, the number of nodes of the tree.\n\nIn the next n lines, the information of each node u is given in the following format:\n\nid k c1 c2 ... ck\n\nwhere id is the node ID of u, k is the degree of u, c1 ... ck are node IDs of 1st, ... kth child of u. If the node does not have a child, k is 0.\n\nOutput\n\nPrint the information of each node in the following format ordered by IDs:\n\nnode id: parent = p, depth = d, type, [c1...ck]\n\np is ID of its parent. If the node does not have a parent, print -1.\n\nd is depth of the node.\n\ntype is a type of nodes represented by a string (root, internal node, or leaf). If the root can be considered as a leaf or an internal node, print root.\n\nc1...ck is the list of children as an ordered tree.\n\nPlease follow the format presented in a sample output below.\n\nConstraints\n\n1 \u2264 n \u2264 100000\n\nSample Input 1\n13\n0 3 1 4 10\n1 2 2 3\n2 0\n3 0\n4 3 5 6 7\n5 0\n6 0\n7 2 8 9\n8 0\n9 0\n10 2 11 12\n11 0\n12 0\n\nSample Output 1\nnode 0: parent = -1, depth = 0, root, [1, 4, 10]\nnode 1: parent = 0, depth = 1, internal node, [2, 3]\nnode 2: parent = 1, depth = 2, leaf, []\nnode 3: parent = 1, depth = 2, leaf, []\nnode 4: parent = 0, depth = 1, internal node, [5, 6, 7]\nnode 5: parent = 4, depth = 2, leaf, []\nnode 6: parent = 4, depth = 2, leaf, []\nnode 7: parent = 4, depth = 2, internal node, [8, 9]\nnode 8: parent = 7, depth = 3, leaf, []\nnode 9: parent = 7, depth = 3, leaf, []\nnode 10: parent = 0, depth = 1, internal node, [11, 12]\nnode 11: parent = 10, depth = 2, leaf, []\nnode 12: parent = 10, depth = 2, leaf, []\n\nSample Input 2\n4\n1 3 3 2 0\n0 0\n3 0\n2 0\n\nSample Output 2\nnode 0: parent = 1, depth = 1, leaf, []\nnode 1: parent = -1, depth = 0, root, [3, 2, 0]\nnode 2: parent = 1, depth = 1, leaf, []\nnode 3: parent = 1, depth = 1, leaf, []\n\nNote\nYou can use a left-child, right-sibling representation to implement a tree which has the following data:\n- the parent of u\n- the leftmost child of u\n- the immediate right sibling of u", "before_after_length": [291, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u637322311", "n_user": "u637322311", "pos": "from sys import stdin\n\nclass Node(object):\n def __init__(self, parent=None, left=None, right=None):\n self.parent = parent\n self.left = left\n self.right = right\n\ndef print_nodes(nodes, n):\n A = []\n B = []\n C = []\n def walk_tree(nodes, u):\n if u == -1:\n return\n r = nodes[u].right\n l = nodes[u].left\n A.append(u)\n walk_tree(nodes, l)\n B.append(u)\n walk_tree(nodes, r)\n C.append(u)\n\n for i in range(n):\n if nodes[i].parent == None:\n walk_tree(nodes, i)\n print(\"Preorder\", end=\"\\n \")\n print(*A, sep=\" \")\n print(\"Inorder\", end=\"\\n \")\n print(*B, sep=\" \")\n print(\"Postorder\", end=\"\\n \")\n print(*C, sep=\" \")\n\ndef read_binary_tree(nodes, n):\n for _ in range(n):\n i = [int(i) for i in stdin.readline().strip().split()]\n nodes[i[0]].left = i[1]\n nodes[i[0]].right = i[2]\n if i[1] != -1:\n nodes[i[1]].parent = i[0]\n if i[2] != -1:\n nodes[i[2]].parent = i[0]\n\nn = int(input())\nnodes = [Node() for _ in range(n)]\nread_binary_tree(nodes, n)\nprint_nodes(nodes, n)\n", "neg": "from sys import stdin\n\nclass Node(object):\n def __init__(self, parent=None, left=None, right=None):\n self.parent = parent\n self.left = left\n self.right = right\n\ndef print_nodes(nodes, n):\n A = []\n B = []\n C = []\n def walk_tree(nodes, u):\n if u == -1:\n return\n r = nodes[u].right\n l = nodes[u].left\n nonlocal A\n A.append(u)\n walk_tree(nodes, l)\n B.append(u)\n walk_tree(nodes, r)\n C.append(u)\n\n for i in range(n):\n if nodes[i].parent == None:\n walk_tree(nodes, i)\n print(\"Preorder\", end=\"\\n \")\n print(*A, sep=\" \")\n print(\"Ineorder\", end=\"\\n \")\n print(*B, sep=\" \")\n print(\"Postorder\", end=\"\\n \")\n print(*C, sep=\" \")\n\ndef read_binary_tree(nodes, n):\n for _ in range(n):\n i = [int(i) for i in stdin.readline().strip().split()]\n nodes[i[0]].left = i[1]\n nodes[i[0]].right = i[2]\n if i[1] != -1:\n nodes[i[1]].parent = i[0]\n if i[2] != -1:\n nodes[i[2]].parent = i[0]\n\nn = int(input())\nnodes = [Node() for _ in range(n)]\nread_binary_tree(nodes, n)\nprint_nodes(nodes, n)\n", "jacc_sim": 0.9516129032258065, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [425, 431], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u805716376", "n_user": "u805716376", "pos": "def s(x):\n print('',x,end='')\ndef p(u):\n if u+1:s(u);p(R[u]);p(L[u])\ndef i(u):\n if u+1:i(R[u]);s(u);i(L[u])\ndef o(u):\n if u+1:o(R[u]);o(L[u]);s(u)\n \nn = int(input())\nR, L = [0]*n, [0]*n\nfor _ in range(n):\n a, b, c = map(int, input().split())\n R[a] = b\n L[a] = c\n\nroot = (set(range(n))-set(R)-set(L)).pop()\nprint('Preorder');p(root)\nprint('\\nInorder');i(root)\nprint('\\nPostorder');o(root)\nprint()\n \n", "neg": "def s(x):\n print('',x,end='')\ndef p(u):\n if u+1:s(u);p(R[u]);p(L[u])\ndef i(u):\n if u+1:i(R[u]);s(u);i(L[u])\ndef o(u):\n if u+1:o(R[u]);o(L[u]);s(u)\n \nn = int(input())\nR, L = [0]*n, [0]*n\nfor _ in range(n):\n a, b, c = map(int, input().split())\n R[a] = b\n L[a] = c\nprint(R)\nprint(L)\nroot = (set(range(n))-set(R)-set(L)).pop()\nprint('Preorder');p(root)\nprint('\\nInorder');i(root)\nprint('\\nPostorder');o(root)\nprint()\n \n", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [228, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u357267874", "n_user": "u357267874", "pos": "class Node:\n def __init__(self, id):\n self.id = id\n self.parent = None\n self.left = None\n self.right = None\n\nroot = None\nn = int(input())\nnode_list = []\nfor i in range(n):\n node_list.append(Node(i))\n\nfor i in range(n):\n id, left, right = list(map(int, input().split()))\n node = node_list[id]\n if left > -1:\n node_list[left].parent = node\n node.left = node_list[left]\n if right > -1:\n node_list[right].parent = node\n node.right = node_list[right]\n\nroot = None\nfor node in node_list:\n if node.parent is None:\n root = node\n break\n\ndef preorder(node):\n if node is None:\n return\n print(' ' + str(node.id), end='')\n preorder(node.left)\n preorder(node.right)\n\ndef inorder(node):\n if node is None:\n return\n inorder(node.left)\n print(' ' + str(node.id), end='')\n inorder(node.right)\n\ndef postorder(node):\n if node is None:\n return\n postorder(node.left)\n postorder(node.right)\n print(' ' + str(node.id), end='')\n\nprint('Preorder')\npreorder(root)\nprint('')\n\nprint('Inorder')\ninorder(root)\nprint('')\n\nprint('Postorder')\npostorder(root)\nprint('')\n", "neg": "class Node:\n def __init__(self, id):\n self.id = id\n self.parent = None\n self.left = None\n self.right = None\n\nroot = None\nn = int(input())\nnode_list = []\nfor i in range(n):\n node_list.append(Node(i))\n\nfor i in range(n):\n id, left, right = list(map(int, input().split()))\n node = node_list[id]\n if left > -1:\n node_list[left].parent = node\n node.left = node_list[left]\n if right > -1:\n node_list[right].parent = node\n node.right = node_list[right]\n\nroot = None\nfor node in node_list:\n if node.parent is None:\n root = node\n break\n\ndef preorder(node):\n if node is None:\n return\n print(' ' + str(node.id), end='')\n preorder(node.left)\n preorder(node.right)\n\ndef inorder(node):\n if node is None:\n return\n \n inorder(node.left)\n print(' ' + str(node.id), end='')\n inorder(node.right)\n\ndef postorder(node):\n if node is None:\n return\n print(' ' + str(node.id), end='')\n postorder(node.left)\n postorder(node.right)\n\nprint('Preorder')\npreorder(root)\nprint('')\n\nprint('Inorder')\ninorder(root)\nprint('')\n\nprint('Postorder')\npostorder(root)\nprint('')\n", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [412, 414], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u247976584", "n_user": "u247976584", "pos": "from collections import namedtuple\n\nclass TreeWalk:\n def __init__(self, t):\n self.t = t\n\n def preParse(self, u):\n if u == -1:\n return \n print(\"\", str(u), end = \"\")\n self.preParse(self.t[u].l)\n self.preParse(self.t[u].r)\n\n def inParse(self, u):\n if u == -1:\n return \n self.inParse(self.t[u].l)\n print(\"\", str(u), end = \"\")\n self.inParse(self.t[u].r)\n\n def postParse(self, u):\n if u == -1:\n return \n self.postParse(self.t[u].l)\n self.postParse(self.t[u].r)\n print(\"\", str(u), end = \"\")\n \nif __name__ == '__main__':\n n = int(input().rstrip())\n Node = namedtuple('Node', ['p', 'l', 'r'])\n t = [Node(-1, -1, -1)] * n\n root = -1\n for i in range(n):\n v, l, r = [int(i) for i in input().rstrip().split(\" \")]\n t[v] = t[v]._replace(l = l, r = r)\n if l != -1:\n t[l] = t[l]._replace(p = v)\n if r != -1:\n t[r] = t[r]._replace(p = v)\n for i in range(n):\n if (t[i].p == -1):\n root = i\n\n x = TreeWalk(t)\n print(\"Preorder\")\n x.preParse(root)\n print()\n print(\"Inorder\")\n x.inParse(root)\n print()\n print(\"Postorder\")\n x.postParse(root)\n print()", "neg": "from collections import namedtuple\n\nclass TreeWalk:\n def __init__(self, t):\n self.t = t\n\n def preParse(self, u):\n if u == -1:\n return \n print(\" \", str(u), end = \"\")\n self.preParse(self.t[u].l)\n self.preParse(self.t[u].r)\n\n def inParse(self, u):\n if u == -1:\n return \n self.inParse(self.t[u].l)\n print(\" \", str(u), end = \"\")\n self.inParse(self.t[u].r)\n\n def postParse(self, u):\n if u == -1:\n return \n self.postParse(self.t[u].l)\n self.postParse(self.t[u].r)\n print(\" \", str(u), end = \"\")\n \nif __name__ == '__main__':\n n = int(input().rstrip())\n Node = namedtuple('Node', ['p', 'l', 'r'])\n t = [Node(-1, -1, -1)] * n\n root = -1\n for i in range(n):\n v, l, r = [int(i) for i in input().rstrip().split(\" \")]\n t[v] = t[v]._replace(l = l, r = r)\n if l != -1:\n t[l] = t[l]._replace(p = v)\n if r != -1:\n t[r] = t[r]._replace(p = v)\n for i in range(n):\n if (t[i].p == -1):\n root = i\n\n x = TreeWalk(t)\n print(\"Preorder\")\n x.preParse(root)\n print()\n print(\"Inorder\")\n x.inParse(root)\n print()\n print(\"Postorder\")\n x.postParse(root)", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [491, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u777299405", "n_user": "u777299405", "pos": "n = int(input())\ntree = [0] * n\nroot = set(range(n))\nfor i in range(n):\n node_id, left, right = map(int, input().split())\n tree[node_id] = (left, right)\n root -= {left, right}\nroot_node = root.pop()\n\n\ndef preorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield i\n yield from preorder(left)\n yield from preorder(right)\n\n\ndef inorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield from inorder(left)\n yield i\n yield from inorder(right)\n\n\ndef postorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield from postorder(left)\n yield from postorder(right)\n yield i\n\nprint(\"Preorder\\n \", end=\"\")\nprint(*preorder(root_node))\nprint(\"Inorder\\n \", end=\"\")\nprint(*inorder(root_node))\nprint(\"Postorder\\n \", end=\"\")\nprint(*postorder(root_node))", "neg": "n = int(input())\ntree = [0] * n\nroot = set(range(n))\nfor i in range(n):\n node_id, left, right = map(int, input().split())\n tree[node_id] = (left, right)\n root -= {left, right}\nroot_node = root.pop()\n\n\ndef preorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield i\n yield from preorder(left)\n yield from preorder(right)\n\n\ndef inorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield from inorder(left)\n yield i\n yield from inorder(right)\n\n\ndef postorder(i):\n if i == -1:\n return\n (left, right) = tree[i]\n yield from postorder(left)\n yield from postorder(right)\n yield i\n\nprint(\"preorder\\n \", end=\"\")\nprint(*preorder(root_node))\nprint(\"inorder\\n \", end=\"\")\nprint(*inorder(root_node))\nprint(\"postorder\\n \", end=\"\")\nprint(*postorder(root_node))", "jacc_sim": 0.9347826086956522, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [304, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u519227872", "n_user": "u519227872", "pos": "n = int(input())\nclass Node(object):\n def __init__(self, p, l, r):\n self.p = p\n self.l = l\n self.r = r\n\nnodes = [Node(None, None, None) for i in range(n)]\n\nfor i in range(n):\n id, left, right = map(int, input().split())\n nodes[id].l = left\n nodes[id].r = right\n if left != -1:\n nodes[left].p = i\n if right != -1:\n nodes[right].p = i\n\ndef pre(node,path):\n path.append(node)\n if nodes[node].l != -1:\n pre(nodes[node].l,path)\n if nodes[node].r != -1:\n pre(nodes[node].r,path)\n\ndef ino(node,path):\n if nodes[node].l != -1:\n ino(nodes[node].l,path)\n path.append(node)\n if nodes[node].r != -1:\n ino(nodes[node].r,path)\n\ndef post(node,path):\n if nodes[node].l != -1:\n post(nodes[node].l,path)\n if nodes[node].r != -1:\n post(nodes[node].r,path)\n path.append(node)\n\nfor ind, n in enumerate(nodes):\n if n.p == None:\n root = ind\n break\nprint('Preorder')\nl = []\npre(root, l)\nprint(' ' + ' '.join(map(str, l)))\nprint('Inorder')\nl = []\nino(root, l)\nprint(' ' + ' '.join(map(str, l)))\nprint('Postorder')\nl = []\npost(root,l)\nprint(' ' + ' '.join(map(str, l)))", "neg": "n = int(input())\nclass Node(object):\n def __init__(self, p, l, r):\n self.p = p\n self.l = l\n self.r = r\n\nnodes = [Node(None, None, None) for i in range(n)]\n\nfor i in range(n):\n id, left, right = map(int, input().split())\n nodes[id].l = left\n nodes[id].r = right\n if left != -1:\n nodes[left].p = i\n if right != -1:\n nodes[right].p = i\n\ndef pre(node,path):\n path.append(node)\n if nodes[node].l != -1:\n pre(nodes[node].l,path)\n if nodes[node].r != -1:\n pre(nodes[node].r,path)\n\ndef ino(node,path):\n if nodes[node].l != -1:\n ino(nodes[node].l,path)\n path.append(node)\n if nodes[node].r != -1:\n ino(nodes[node].r,path)\n\ndef post(node,path):\n if nodes[node].l != -1:\n post(nodes[node].l,path)\n if nodes[node].r != -1:\n post(nodes[node].r,path)\n path.append(node)\n\nfor ind, n in enumerate(nodes):\n if n.p == None:\n root = ind\n break\nprint('Preorder')\nl = []\npre(root, l)\nprint(' '.join(map(str, l)))\nprint('InOrder')\nl = []\nino(root, l)\nprint(' '.join(map(str, l)))\nprint('Postorder')\nl = []\npost(root,l)\nprint(' '.join(map(str, l)))", "jacc_sim": 0.9272727272727272, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [469, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u510829608", "n_user": "u510829608", "pos": "N = int(input())\ntree = [None for _ in range(N)]\nroot = set(range(N))\n\nfor i in range(N):\n i, l, r = map(int,input().split())\n tree[i] = (l, r)\n root -= {l, r}\n\nroot_node = root.pop()\n\ndef preorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n print(\" {}\".format(i), end = \"\")\n preorder(l)\n preorder(r)\n \ndef inorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n inorder(l)\n print(\" {}\".format(i), end = \"\")\n inorder(r)\n \ndef postorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n postorder(l)\n postorder(r)\n print(\" {}\".format(i), end = \"\")\n \nprint('Preorder')\npreorder(root_node)\nprint()\n\nprint('Inorder')\ninorder(root_node)\nprint()\n\nprint('Postorder')\npostorder(root_node)\nprint()", "neg": "N = int(input())\ntree = [None for _ in range(N)]\nroot = set(range(N))\n\nfor i in range(N):\n i, l, r = map(int,input().split())\n tree[i] = (l, r)\n root -= {l, r}\n\nroot_node = root.pop()\n\ndef preorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n print(\" {}\".format(i), end = \"\")\n preorder(l)\n preorder(r)\n \ndef inorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n inorder(l)\n print(\" {}\".format(i), end = \"\")\n inorder(r)\n \ndef postorder(i):\n if i == -1:\n return\n (l, r) = tree[i]\n inorder(l)\n inorder(r)\n print(\" {}\".format(i), end = \"\")\n \nprint('Preorder')\npreorder(root_node)\nprint()\n\nprint('Inorder')\ninorder(root_node)\nprint()\n\nprint('Postorder')\npostorder(root_node)\nprint()", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [314, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u024715419", "n_user": "u024715419", "pos": "class Node():\n def __init__(self, node_id, left, right):\n self.node_id = node_id\n self.left = left\n self.right = right\n\n def pre_order_search(self):\n l = self.left\n r = self.right\n print(\"\",self.node_id, end=\"\")\n if l != -1:\n tree[l].pre_order_search()\n if r != -1:\n tree[r].pre_order_search()\n\n def in_order_search(self):\n l = self.left\n r = self.right\n if l != -1:\n tree[l].in_order_search()\n print(\"\",self.node_id, end=\"\")\n if r != -1:\n tree[r].in_order_search()\n\n def post_order_search(self):\n l = self.left\n r = self.right\n if l != -1:\n tree[l].post_order_search()\n if r != -1:\n tree[r].post_order_search()\n print(\"\",self.node_id, end=\"\")\n\nn = int(input())\ntree = [None for i in range(n)]\nroot_set = set(range(n))\n\nfor i in range(n):\n node_id, left, right = map(int, input().split())\n tree[node_id] = Node(node_id, left, right)\n root_set -= set([left, right])\nroot = root_set.pop()\n\nprint(\"Preorder\")\ntree[root].pre_order_search()\nprint(\"\")\n\nprint(\"Inorder\")\ntree[root].in_order_search()\nprint(\"\")\n\nprint(\"Postorder\")\ntree[root].post_order_search()\nprint(\"\")", "neg": "class Node():\n def __init__(self, node_id, left, right):\n self.node_id = node_id\n self.left = left\n self.right = right\n\n def pre_order_search(self):\n l = self.left\n r = self.right\n print(\"\",self.node_id, end=\"\")\n if l != -1:\n tree[l].pre_order_search()\n if r != -1:\n tree[r].pre_order_search()\n\n def in_order_search(self):\n l = self.left\n r = self.right\n print(self.node_id, self.left, self.right)\n if l != -1:\n tree[l].in_order_search()\n print(\"\",self.node_id, end=\"\")\n if r != -1:\n tree[r].in_order_search()\n\n def post_order_search(self):\n l = self.left\n r = self.right\n if l != -1:\n tree[l].post_order_search()\n if r != -1:\n tree[r].post_order_search()\n print(\"\",self.node_id, end=\"\")\n\nn = int(input())\ntree = [None for i in range(n)]\nroot_set = set(range(n))\n\nfor i in range(n):\n node_id, left, right = map(int, input().split())\n tree[node_id] = Node(node_id, left, right)\n root_set -= set([left, right])\nroot = root_set.pop()\n\nprint(\"Preorder\")\ntree[root].pre_order_search()\nprint()\n\nprint(\"Inorder\")\ntree[root].in_order_search()\nprint()\n\nprint(\"Postorder\")\ntree[root].post_order_search()\nprint()", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [455, 470], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u798803522", "n_user": "u798803522", "pos": "from collections import defaultdict\ndef preorder(here, conn, chain):\n if here == -1:\n return\n chain.append(here)\n if conn[here]:\n preorder(conn[here][0], conn, chain)\n preorder(conn[here][1], conn, chain)\n\ndef inorder(here, conn, chain):\n if here == -1:\n return\n if conn[here]:\n inorder(conn[here][0], conn, chain)\n chain.append(here)\n inorder(conn[here][1], conn, chain)\n\ndef postorder(here, conn, chain):\n if here == -1:\n return\n if conn[here]:\n postorder(conn[here][0], conn, chain)\n postorder(conn[here][1], conn, chain)\n chain.append(here)\n\nquery = int(input())\nconnect = defaultdict(list)\nin_v = [0 for n in range(query + 1)]\nfor _ in range(query):\n here, left, right = (int(n) for n in input().split(\" \"))\n connect[here] = [left, right]\n in_v[left] += 1\n in_v[right] += 1\nfor i in range(query):\n if not in_v[i]:\n root = i\n break\npreo = []\nino = []\nposto = []\npreorder(root, connect, preo)\ninorder(root, connect, ino)\npostorder(root, connect, posto)\n\nprint(\"Preorder\")\nprint(\"\", end = \" \")\nprint(*preo)\nprint(\"Inorder\")\nprint(\"\", end = \" \")\nprint(*ino)\nprint(\"Postorder\")\nprint(\"\", end = \" \")\nprint(*posto)", "neg": "from collections import defaultdict\ndef preorder(here, conn, chain):\n if here == -1:\n return\n chain.append(here)\n if conn[here]:\n preorder(conn[here][0], conn, chain)\n preorder(conn[here][1], conn, chain)\n\ndef inorder(here, conn, chain):\n if here == -1:\n return\n if conn[here]:\n inorder(conn[here][0], conn, chain)\n chain.append(here)\n inorder(conn[here][1], conn, chain)\n\ndef postorder(here, conn, chain):\n if here == -1:\n return\n if conn[here]:\n postorder(conn[here][0], conn, chain)\n postorder(conn[here][1], conn, chain)\n chain.append(here)\n\nquery = int(input())\nconnect = defaultdict(list)\nin_v = [0 for n in range(query + 1)]\nfor _ in range(query):\n here, left, right = (int(n) for n in input().split(\" \"))\n connect[here] = [left, right]\n in_v[left] += 1\n in_v[right] += 1\nfor i in range(query):\n if not in_v[i]:\n root = i\n break\npreo = []\nino = []\nposto = []\npreorder(root, connect, preo)\ninorder(root, connect, ino)\npostorder(root, connect, posto)\n\nprint(\"Preorder\")\nprint(\" \" + *preo)\nprint(\"Inorder\")\nprint(\" \" + *ino)\nprint(\"Postorder\")\nprint(\" \" + *posto)", "jacc_sim": 0.9814814814814815, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [430, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u938045879", "n_user": "u938045879", "pos": "n = int(input())\nroot = set(range(n))\nnodes = [0 for i in range(n)]\nfor i in range(n):\n node = list(map(int, input().split()))\n children = node[1:3]\n root -= set(children)\n nodes[node[0]] = children\n\ndef preorder(id):\n if(id == -1):\n return\n order.append(id)\n preorder(nodes[id][0])\n preorder(nodes[id][1])\n\ndef inorder(id):\n if(id == -1):\n return\n inorder(nodes[id][0])\n order.append(id)\n inorder(nodes[id][1])\n\ndef postorder(id):\n if(id == -1):\n return\n postorder(nodes[id][0])\n postorder(nodes[id][1])\n order.append(id)\n\norder = []\npreorder(list(root)[0])\nprint('Preorder')\nprint(' ', end='')\nprint(*order)\norder = []\ninorder(list(root)[0])\nprint('Inorder')\nprint(' ', end='')\nprint(*order)\norder = []\npostorder(list(root)[0])\nprint('Postorder')\nprint(' ', end='')\nprint(*order)\n\n", "neg": "n = int(input())\nroot = set(range(n))\nnodes = [0 for i in range(n)]\nfor i in range(n):\n node = list(map(int, input().split()))\n children = node[1:3]\n root -= set(children)\n nodes[node[0]] = children\n\ndef preorder(id):\n if(id == -1):\n return\n order.append(id)\n preorder(nodes[id][0])\n preorder(nodes[id][1])\n\ndef inorder(id):\n if(id == -1):\n return\n inorder(nodes[id][0])\n order.append(id)\n inorder(nodes[id][1])\n\ndef postorder(id):\n if(id == -1):\n return\n postorder(nodes[id][0])\n postorder(nodes[id][1])\n order.append(id)\n\norder = []\npreorder(list(root)[0])\nprint('Preorder')\nprint(*order)\norder = []\ninorder(list(root)[0])\nprint('Inorder')\nprint(*order)\norder = []\npostorder(list(root)[0])\nprint('Postorder')\nprint(*order)\n\n", "jacc_sim": 0.9767441860465116, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [324, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u318430977", "n_user": "u318430977", "pos": "def preorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return [now] + preorder(tree, left) + preorder(tree, right)\n\n\ndef inorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return inorder(tree, left) + [now] + inorder(tree, right)\n\n\ndef postorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return postorder(tree, left) + postorder(tree, right) + [now]\n\n\ndef print_list_split_whitespace(a):\n print(\" \", end=\"\")\n for x in a[:-1]:\n print(x, end=\" \")\n print(a[-1])\n\n\nn = int(input())\ntree = [[] for _ in range(n)]\nps = [-1 for _ in range(n)]\nss = [-1 for _ in range(n)]\nfor _ in range(n):\n s = input().split()\n id = int(s[0])\n left = int(s[1])\n right = int(s[2])\n tree[id] = [left, right]\n if left >= 0:\n ps[left] = id\n ss[left] = right\n if right >= 0:\n ps[right] = id\n ss[right] = left\n\nroot = ps.index(-1)\n\nprint(\"Preorder\")\npre_list = preorder(tree, root)\nprint_list_split_whitespace(pre_list)\n\nprint(\"Inorder\")\nin_list = inorder(tree, root)\nprint_list_split_whitespace(in_list)\n\nprint(\"Postorder\")\npost_list = postorder(tree, root)\nprint_list_split_whitespace(post_list)\n", "neg": "def preorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return [now] + preorder(tree, left) + preorder(tree, right)\n\n\ndef inorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return inorder(tree, left) + [now] + inorder(tree, right)\n\n\ndef postorder(tree, now):\n if now == -1:\n return []\n else:\n left = tree[now][0]\n right = tree[now][1]\n return postorder(tree, left) + postorder(tree, right) + [now]\n\n\ndef print_list_split_whitespace(a):\n for x in a[:-1]:\n print(x, end=\" \")\n print(a[-1])\n\n\nn = int(input())\ntree = [[] for _ in range(n)]\nps = [-1 for _ in range(n)]\nss = [-1 for _ in range(n)]\nfor _ in range(n):\n s = input().split()\n id = int(s[0])\n left = int(s[1])\n right = int(s[2])\n tree[id] = [left, right]\n if left >= 0:\n ps[left] = id\n ss[left] = right\n if right >= 0:\n ps[right] = id\n ss[right] = left\n\nroot = ps.index(-1)\n\nprint(\"Preorder\")\npre_list = preorder(tree, root)\nprint_list_split_whitespace(pre_list)\n\nprint(\"Inorder\")\nin_list = inorder(tree, root)\nprint_list_split_whitespace(in_list)\n\nprint(\"Postorder\")\npost_list = postorder(tree, root)\nprint_list_split_whitespace(post_list)\n", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [505, 497], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u113295414", "n_user": "u113295414", "pos": "n = int(input())\ntree = [[-1, -1, True] for i in range(n)]\nfor i in range(n):\n id, left, right = map(int, input().split())\n if left != -1:\n tree[id][0] = left\n tree[left][2] = False\n if right != -1:\n tree[id][1] = right\n tree[right][2] = False\n\ndef preoder(id):\n if id == -1:\n return\n print(' ' + str(id), end='')\n preoder(tree[id][0])\n preoder(tree[id][1])\n\ndef inorder(id):\n if id == -1:\n return\n inorder(tree[id][0])\n print(' ' + str(id), end='')\n inorder(tree[id][1])\n\ndef postorder(id):\n if id == -1:\n return\n postorder(tree[id][0])\n postorder(tree[id][1])\n print(' ' + str(id), end='')\n\nroot = 0\nfor i, node in enumerate(tree):\n if node[2] == True:\n root = i\n\nprint('Preorder')\npreoder(root)\nprint('')\nprint('Inorder')\ninorder(root)\nprint('')\nprint('Postorder')\npostorder(root)\nprint('')\n\n", "neg": "n = int(input())\ntree = [[-1, -1, True] for i in range(n)]\nfor i in range(n):\n id, left, right = map(int, input().split())\n if left != -1:\n tree[id][0] = left\n tree[left][2] = False\n if right != -1:\n tree[id][1] = right\n tree[right][2] = False\n\ndef preoder(id):\n if id == -1:\n return\n print(' ' + str(id), end='')\n preoder(tree[id][0])\n preoder(tree[id][1])\n\ndef inorder(id):\n if id == -1:\n return\n inorder(tree[id][0])\n print(' ' + str(id), end='')\n inorder(tree[id][1])\n\ndef postorder(id):\n if id == -1:\n return\n postorder(tree[id][0])\n postorder(tree[id][1])\n print(' ' + str(id), end='')\n\nroot = 0\nfor i, node in enumerate(tree):\n if node[2] == True:\n root = i\n\nprint('Preoder')\npreoder(root)\nprint('')\nprint('Inorder')\ninorder(root)\nprint('')\nprint('Postorder')\npostorder(root)\n\n", "jacc_sim": 0.9565217391304348, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [348, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u782850731", "n_user": "u782850731", "pos": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\nclass Node(object):\n def __init__(self):\n self.id = None\n self.parent = -1\n self.childs = None\n\n\ndef preorder_walk(data, index, out):\n node = data[index]\n out.append(node.id)\n for cidx in node.childs:\n if cidx >= 0:\n preorder_walk(data, cidx, out)\n\n\ndef inorder_walk(data, index, out):\n cid = data[index].childs[0]\n if cid >= 0:\n inorder_walk(data, cid, out)\n out.append(data[index].id)\n cid = data[index].childs[1]\n if cid >= 0:\n inorder_walk(data, cid, out)\n\n\ndef postorder_wark(data, index, out):\n node = data[index]\n for cidx in node.childs:\n if cidx >= 0:\n postorder_wark(data, cidx, out)\n out.append(node.id)\n\n\nn = int(stdin.readline())\n#assert 1 <= n <= 25\ndata = [Node() for _ in range(n)]\nfor _ in range(n):\n idx, left, right = (int(s) for s in stdin.readline().split())\n data[idx].id = idx\n data[idx].childs = [left, right]\n for c in data[idx].childs:\n if c >= 0:\n data[c].parent = idx\n\nstart = None\nfor node in data:\n if node.parent == -1:\n start = node.id\n break\n\nfor name, func in (('Preorder\\n', preorder_walk),\n ('Inorder\\n', inorder_walk),\n ('Postorder\\n', postorder_wark)):\n out = []\n func(data, start, out)\n print(name, *out)", "neg": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\nclass Node(object):\n def __init__(self):\n self.id = None\n self.parent = -1\n self.childs = None\n\n\ndef preorder_walk(data, index, out):\n node = data[index]\n out.append(node.id)\n for cidx in node.childs:\n if cidx >= 0:\n preorder_walk(data, cidx, out)\n\n\ndef inorder_walk(data, index, out):\n node = data[index]\n for cidx in node.childs:\n if cidx >= 0:\n inorder_walk(data, cidx, out)\n if node.id not in out:\n out.append(node.id)\n if node.id not in out:\n out.append(node.id)\n\n\ndef postorder_wark(data, index, out):\n node = data[index]\n for cidx in node.childs:\n if cidx >= 0:\n postorder_wark(data, cidx, out)\n out.append(node.id)\n\n\nn = int(stdin.readline())\n#assert 1 <= n <= 25\ndata = [Node() for _ in range(n)]\nfor _ in range(n):\n idx, left, right = (int(s) for s in stdin.readline().split())\n data[idx].id = idx\n data[idx].childs = [left, right]\n for c in data[idx].childs:\n data[c].parent = idx\n\nfor name, func in (('Preorder', preorder_walk), ('Inoder', inorder_walk),\n ('Postorder', postorder_wark)):\n out = []\n func(data, 0, out)\n print(name)\n print(*out)", "jacc_sim": 0.9078947368421053, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [506, 466], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02281", "p_user": "u759561356", "n_user": "u150984829", "pos": "def s(x): print('', x, end = '')\n\ndef p(u):\n if u + 1: s(u); p(T[u]); p(T[u+N])\n \ndef i(u):\n if u + 1: i(T[u]); s(u); i(T[u+N])\n \ndef o(u):\n if u + 1: o(T[u]); o(T[u + N]); s(u)\n\nN = int(input())\n\nT = [0, 0] * N\n\nfor _ in[0] * N:\n a, b, c = map(int, input().split())\n T[a], T[a + N] = b, c\n\nr = (set(range(N)) - set(T)).pop()\n\nprint('Preorder'); p(r)\nprint('\\nInorder'); i(r)\nprint('\\nPostorder'); o(r)\nprint()\n", "neg": "def s(x):print(_,x,end='')\ndef p(u):\n if u+1:s(u);p(T[u]);p(T[u+N])\ndef i(u):\n if u+1:i(T[u]);s(u);i(T[u+N])\ndef o(u):\n if u+1:o(T[u]);o(T[u+N]);s(u)\nN=int(input())\nT=[0,0]*N\nfor _ in[0]*N:\n a,b,c=map(int,input().split())\n T[a],T[a+N]=b,c\nr=(set(range(N))-set(T)).pop()\nprint('Preorder');p(r)\nprint('\\nInorder');i(r)\nprint('\\nPostorder');o(r)\nprint()\n", "jacc_sim": 1.0, "nl": "Title: Tree Walk\n\nBinary trees are defined recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes or is composed of three disjoint sets of nodes: a root node, a binary tree called its left subtree, and a binary tree called its right subtree.\n\nYour task is to write a program that performs tree walks (systematically traverses all nodes in a tree) based on the following algorithms:\n\n1. Print the root, the left subtree, and the right subtree (preorder).\n2. Print the left subtree, the root, and the right subtree (inorder).\n3. Print the left subtree, the right subtree, and the root (postorder).\n\nThe given binary tree consists of n nodes, and every node has a unique ID from 0 to n-1.\n\nInput:\nThe first line of the input includes an integer n, the number of nodes of the tree. In the next n lines, the information of each node is given in the format: id left right. \"id\" is the node ID, \"left\" is the ID of the left child, and \"right\" is the ID of the right child. If the node does not have the left (right) child, the left (right) is indicated by -1.\n\nOutput:\nIn the 1st line, print \"Preorder\", and in the 2nd line print a list of node IDs obtained by the preorder tree walk. In the 3rd line, print \"Inorder\", and in the 4th line print a list of node IDs obtained by the inorder tree walk. In the 5th line, print \"Postorder\", and in the 6th line print a list of node IDs obtained by the postorder tree walk. Print a space character before each node ID.\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input 1:\n9\n0 1 4\n1 2 3\n2 -1 -1\n3 -1 -1\n4 5 8\n5 6 7\n6 -1 -1\n7 -1 -1\n8 -1 -1\n\nSample Output 1:\nPreorder\n 0 1 2 3 4 5 6 7 8\nInorder\n 2 1 3 0 6 5 7 4 8\nPostorder\n 2 3 1 6 7 5 8 4 0\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [231, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02282", "p_user": "u805716376", "n_user": "u805716376", "pos": "n = int(input())\npre = list(map(int, input().split()))\nino = list(map(int, input().split()))\n\nd = []\nroot = pre[0]\npre = iter(pre).__next__\n\ndef dfs(l, r):\n global d\n if l >= r:\n return\n c = pre()\n m = ino.index(c)\n dfs(l, m)\n dfs(m+1, r)\n d += [c]\n \ndfs(0, len(ino))\nprint(*d)\n\n", "neg": "n = int(input())\npre = list(map(int, input().split()))\nino = list(map(int, input().split()))\n\nd = []\nroot = pre[1]\npre = iter(pre).__next__\n\ndef dfs(l, r):\n if l >= r:\n return\n c = pre()\n m = ino.index(c)\n dfs(l, m)\n dfs(m+1, r)\n d += [c]\n \ndfs(0, len(ino))\nprint(*d)\n\n", "jacc_sim": 0.972972972972973, "nl": "Reconstruction of a Tree\n\nWrite a program that takes two sequences of nodes obtained by the preorder and inorder tree walks on a binary tree, and outputs a sequence of nodes obtained by the postorder tree walk on the binary tree.\n\nInput:\n- An integer n, the number of nodes in the binary tree.\n- The sequence of node IDs obtained by the preorder tree walk, separated by spaces.\n- The sequence of node IDs obtained by the inorder tree walk, separated by spaces.\n\nOutput:\n- Print the sequence of node IDs obtained by the postorder tree walk in a single line, with a single space character between adjacent IDs.\n\nConstraints:\n- 1 \u2264 n \u2264 40\n\nSample Input 1:\n5\n1 2 3 4 5\n3 2 4 1 5\n\nSample Output 1:\n3 4 2 5 1\n\nSample Input 2:\n4\n1 2 3 4\n1 2 3 4\n\nSample Output 2:\n4 3 2 1", "before_after_length": [139, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02282", "p_user": "u159356473", "n_user": "u159356473", "pos": "#coding:UTF-8\n\ndef RoT(A,B,ans):\n if A:\n root=A[0]\n rindex=B.index(root)\n Aleft=A[1:rindex+1]\n Aright=A[rindex+1:]\n Bleft=B[:rindex]\n Bright=B[rindex+1:]\n RoT(Aleft,Bleft,ans)\n RoT(Aright,Bright,ans)\n ans.append(root)\n \n \n\n\nif __name__==\"__main__\":\n n=int(input())\n A=input().split(\" \")\n B=input().split(\" \")\n ans=[]\n RoT(A,B,ans)\n print(\" \".join(ans))", "neg": "#coding:UTF-8\n\ndef RoT(A,B,ans):\n if A:\n root=A[0]\n rindex=B.index(root)\n Aleft=A[1:rindex+1]\n Aright=A[rindex+1:]\n Bleft=B[:rindex]\n Bright=B[rindex:]\n RoT(Aleft,Bleft,ans)\n RoT(Aright,Bright,ans)\n ans.append(root)\n \n \n\n\nif __name__==\"__main__\":\n n=int(input())\n A=input().split(\" \")\n B=input().split(\" \")\n ans=[]\n RoT(A,B,ans)\n print(\" \".join(ans))", "jacc_sim": 1.0, "nl": "Reconstruction of a Tree\n\nWrite a program that takes two sequences of nodes obtained by the preorder and inorder tree walks on a binary tree, and outputs a sequence of nodes obtained by the postorder tree walk on the binary tree.\n\nInput:\n- An integer n, the number of nodes in the binary tree.\n- The sequence of node IDs obtained by the preorder tree walk, separated by spaces.\n- The sequence of node IDs obtained by the inorder tree walk, separated by spaces.\n\nOutput:\n- Print the sequence of node IDs obtained by the postorder tree walk in a single line, with a single space character between adjacent IDs.\n\nConstraints:\n- 1 \u2264 n \u2264 40\n\nSample Input 1:\n5\n1 2 3 4 5\n3 2 4 1 5\n\nSample Output 1:\n3 4 2 5 1\n\nSample Input 2:\n4\n1 2 3 4\n1 2 3 4\n\nSample Output 2:\n4 3 2 1", "before_after_length": [195, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02282", "p_user": "u947762778", "n_user": "u947762778", "pos": "def getPostorder(preorder, inorder):\n if not preorder:\n return []\n postorder = []\n root = preorder[0]\n rootIndex = inorder.index(root)\n\n postorder.extend(getPostorder(preorder[1:rootIndex + 1], inorder[:rootIndex]))\n postorder.extend(getPostorder(preorder[rootIndex + 1:], inorder[rootIndex + 1:]))\n postorder.append(root)\n\n return postorder \n\nif __name__ == '__main__':\n n = int(input())\n preorder = list(map(int, input().split()))\n inorder = list(map(int, input().split()))\n print(*getPostorder(preorder, inorder))", "neg": "def getPostorder(preorder, inorder):\n if not preorder:\n return []\n postorder = []\n root = preorder[0]\n rootIndex = inorder.index(root)\n\n postorder.extend(getPostorder(preorder[1:rootIndex + 1], inorder[:rootIndex]))\n postorder.extend(getPostorder(preorder[rootIndex + 1:], inorder[rootIndex + 1:]))\n postorder.append(root)\n\n return postorder \n\nif __name__ == '__main__':\n n = int(input())\n preorder = list(map(int, input().split()))\n inorder = list(map(int, input().split()))\n print(getPostorder(preorder, inorder))", "jacc_sim": 0.9722222222222222, "nl": "Reconstruction of a Tree\n\nWrite a program that takes two sequences of nodes obtained by the preorder and inorder tree walks on a binary tree, and outputs a sequence of nodes obtained by the postorder tree walk on the binary tree.\n\nInput:\n- An integer n, the number of nodes in the binary tree.\n- The sequence of node IDs obtained by the preorder tree walk, separated by spaces.\n- The sequence of node IDs obtained by the inorder tree walk, separated by spaces.\n\nOutput:\n- Print the sequence of node IDs obtained by the postorder tree walk in a single line, with a single space character between adjacent IDs.\n\nConstraints:\n- 1 \u2264 n \u2264 40\n\nSample Input 1:\n5\n1 2 3 4 5\n3 2 4 1 5\n\nSample Output 1:\n3 4 2 5 1\n\nSample Input 2:\n4\n1 2 3 4\n1 2 3 4\n\nSample Output 2:\n4 3 2 1", "before_after_length": [182, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02282", "p_user": "u024715419", "n_user": "u024715419", "pos": "n = int(input())\ntree = [None for i in range(n +1)]\nlist_pre = list(map(int, input().split()))\nlist_in = list(map(int, input().split()))\n \n \ndef solve(tree_pre, tree_in):\n if not tree_pre:\n return -1\n root = tree_pre[0]\n idx = tree_in.index(root)\n tree[root] = (solve(tree_pre[1:idx + 1], tree_in[:idx]), \n solve(tree_pre[idx + 1:], tree_in[idx + 1:]))\n return root\n\n\ndef post_order_search(i):\n if i == -1:\n return\n l, r = tree[i]\n for j in post_order_search(l):\n yield j\n for j in post_order_search(r):\n yield j\n yield i\n\n\nsolve(list_pre, list_in)\n\nprint(*post_order_search(list_pre[0]))", "neg": "n = int(input())\ntree = [None for i in range(n +1)]\nlist_pre = list(map(int, input().split()))\nlist_in = list(map(int, input().split()))\n \n \ndef reconstruct(tree_pre, tree_in):\n if not tree_pre:\n return -1\n root = tree_pre[0]\n idx = tree_in.index(root)\n tree[root] = (reconstruct(tree_pre[1:i + 1], tree_in[:i]), \n reconstruct(tree_pre[i + 1:], tree_in[i + 1:]))\n return root\n\n\ndef post_order_search(i):\n if i == -1:\n return\n l, r = tree[i]\n for j in post_order_search(l):\n yield j\n for j in post_order_search(r):\n yield j\n yield i\n\n\nsolve(list_pre, list_in)\n\nprint(*postorder(list_pre[0]))", "jacc_sim": 0.9555555555555556, "nl": "Reconstruction of a Tree\n\nWrite a program that takes two sequences of nodes obtained by the preorder and inorder tree walks on a binary tree, and outputs a sequence of nodes obtained by the postorder tree walk on the binary tree.\n\nInput:\n- An integer n, the number of nodes in the binary tree.\n- The sequence of node IDs obtained by the preorder tree walk, separated by spaces.\n- The sequence of node IDs obtained by the inorder tree walk, separated by spaces.\n\nOutput:\n- Print the sequence of node IDs obtained by the postorder tree walk in a single line, with a single space character between adjacent IDs.\n\nConstraints:\n- 1 \u2264 n \u2264 40\n\nSample Input 1:\n5\n1 2 3 4 5\n3 2 4 1 5\n\nSample Output 1:\n3 4 2 5 1\n\nSample Input 2:\n4\n1 2 3 4\n1 2 3 4\n\nSample Output 2:\n4 3 2 1", "before_after_length": [256, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02282", "p_user": "u613534067", "n_user": "u613534067", "pos": "def reconstruct(pre, in_):\n if not pre:\n return -1\n root = pre[0]\n i = in_.index(root)\n tree[root] = (reconstruct(pre[1 : i+1], in_[:i]), reconstruct(pre[i+1:], in_[i+1:]))\n return root\n\ndef postorder(i):\n if i == -1:\n return\n l, r = tree[i]\n for v in postorder(l):\n yield v\n for v in postorder(r):\n yield v\n yield i\n\nn = int(input())\ntree = [None for i in range(n+1)]\npre_tree = list(map(int, input().split()))\nin_tree = list(map(int, input().split()))\nreconstruct(pre_tree, in_tree)\nprint(*postorder(pre_tree[0]))\n", "neg": "def reconstruct(pre, in_):\n if not pre:\n return -1\n root = pre[0]\n i = in_.index(root)\n tree[root] = (reconstruct(pre[1 : i+1], in_[:i]), reconstruct(pre[i+1:], in_[i+1:]))\n return root\n\ndef postorder(i):\n if i == -1:\n return\n l, r = tree[i]\n for v in postorder(l):\n yield v\n for v in postorder(r):\n yield v\n yield i\n\nn = int(input())\ntree = [None for i in range(n+1)]\npre_tree = list(map(int, input().split()))\nin_tree = list(map(int, input().split()))\nreconstruct(pre_tree, in_tree)\nprint(tree)\nprint(*postorder(pre_tree[0]))\n", "jacc_sim": 1.0, "nl": "Reconstruction of a Tree\n\nWrite a program that takes two sequences of nodes obtained by the preorder and inorder tree walks on a binary tree, and outputs a sequence of nodes obtained by the postorder tree walk on the binary tree.\n\nInput:\n- An integer n, the number of nodes in the binary tree.\n- The sequence of node IDs obtained by the preorder tree walk, separated by spaces.\n- The sequence of node IDs obtained by the inorder tree walk, separated by spaces.\n\nOutput:\n- Print the sequence of node IDs obtained by the postorder tree walk in a single line, with a single space character between adjacent IDs.\n\nConstraints:\n- 1 \u2264 n \u2264 40\n\nSample Input 1:\n5\n1 2 3 4 5\n3 2 4 1 5\n\nSample Output 1:\n3 4 2 5 1\n\nSample Input 2:\n4\n1 2 3 4\n1 2 3 4\n\nSample Output 2:\n4 3 2 1", "before_after_length": [223, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u269568674", "n_user": "u269568674", "pos": "class binaryTree:\n def __init__(self,key,p=None,l=None,r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n\nN = int(input())\ntreelist = [list(input().split()) for i in range(N)]\nroot = None\n\ndef inorder(root):\n x = root\n if x == None:\n return\n inorder(x.l)\n \n global inlist\n inlist.append(x.key)\n \n inorder(x.r)\n\ndef insert(root,z):\n y = None\n x = root\n while x != None:\n y = x\n if z.key < x.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n \ndef outorder(root):\n x = root\n if x == None:\n return\n global outlist\n outlist.append(x.key)\n \n outorder(x.l)\n outorder(x.r)\n\nfor data in treelist:\n if data[0] == \"insert\":\n z = binaryTree(int(data[1]))\n root = insert(root,z)\n \n if data[0] == \"print\":\n inlist = []\n outlist = []\n \n inorder(root)\n indata = \" \" + \" \".join([str(num) for num in inlist])\n print(indata)\n \n outorder(root)\n outdata = \" \" + \" \".join([str(num) for num in outlist])\n print(outdata)\n", "neg": "class binaryTree:\n def __init__(self,key,p=None,l=None,r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n\nN = int(input())\ntreelist = [list(input().split()) for i in range(N)]\nroot = None\n\ndef inorder(root):\n x = root\n if x == None:\n return\n inorder(x.l)\n \n global inlist\n inlist.append(x.key)\n \n inorder(x.r)\n\ndef insert(root,z):\n y = None\n x = root\n while x != None:\n y = x\n if z.key < x.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n \ndef outorder(root):\n x = root\n if x == None:\n return\n global outlist\n outlist.append(x.key)\n \n outorder(x.l)\n outorder(x.r)\n\nfor data in treelist:\n if data[0] == \"insert\":\n z = binaryTree(int(data[1]))\n root = insert(root,z)\n \n if data[0] == \"print\":\n inlist = []\n outlist = []\n \n inorder(root)\n indata = \" \" + \" \".join([str(num) for num in inlist])\n print(indata)\n \n outorder(root)\n outdata = \" \" + \" \".join([str(num) for num in outist])\n print(outdata)\n", "jacc_sim": 0.9830508474576272, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [462, 462], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u007270338", "n_user": "u007270338", "pos": "#coding:utf-8\n\nclass MakeTree():\n def __init__(self, key, p=None, l=None, r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n \ndef Insert(root,value):\n y = None\n x = root\n z = MakeTree(value)\n\n while x != None:\n y = x\n if x.key > z.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n\ndef inParse(u):\n if u == None:\n return\n inParse(u.l)\n global inParseList\n inParseList.append(u.key)\n inParse(u.r)\n\ndef preParse(u):\n if u == None:\n return\n global preParseList\n preParseList.append(u.key)\n preParse(u.l)\n preParse(u.r)\n\n\nroot = None \nn = int(input())\ninParseList = []\npreParseList = []\nfor i in range(n):\n order = list(input().split())\n if order[0] == \"insert\":\n root = Insert(root, int(order[1]))\n else:\n inParse(root)\n preParse(root)\n\n print(\" \" + \" \".join([str(i) for i in inParseList]))\n print(\" \" + \" \".join([str(i) for i in preParseList]))\n preParseList = []\n inParseList = []\n\n", "neg": "#coding:utf-8\n\nclass MakeTree():\n def __init__(self, key, p=None, l=None, r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n \ndef Insert(root,value):\n y = None\n x = root\n z = MakeTree(value)\n\n while x != None:\n y = x\n if x.key > z.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n\ndef inParse(u):\n if u == None:\n return\n inParse(u.l)\n global inParseList\n inParseList.append(u.key)\n inParse(u.r)\n\ndef preParse(u):\n if u == None:\n return\n global preParseList\n preParseList.append(u.key)\n preParse(u.l)\n preParse(u.r)\n\n\nroot = None \nn = int(input())\ninParseList = []\npreParseList = []\nfor i in range(n):\n order = list(input().split())\n if order[0] == \"insert\":\n root = Insert(root, int(order[1]))\n else:\n inParse(root)\n preParse(root)\n\n print(\" \".join([str(i) for i in inParseList]))\n print(\" \".join([str(i) for i in preParseList]))\n\n", "jacc_sim": 0.9838709677419355, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [441, 421], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u805716376", "n_user": "u805716376", "pos": "class Node():\n def __init__(self, key):\n self.key = key\n self.left = self.right = None\n \ndef insert(key):\n global root\n\n x = root\n y = None\n while x:x, y = x.left if key < x.key else x.right , x\n if y == None:root = Node(key)\n elif y.key < key:y.right = Node(key)\n else:y.left = Node(key)\n \n \ndef pre(node):\n if node == None:return\n print('',node.key, end = '');pre(node.left);pre(node.right)\n \ndef ino(node):\n if node == None:return\n ino(node.left);print('',node.key,end='');ino(node.right)\n\n\nn = int(input())\nroot = None\nfor j in range(n):\n s, *i = input().split()\n if s[0] == 'i':insert(int(i[0]))\n else:\n ino(root);print();pre(root);print()\n \n \n", "neg": "class Node():\n def __init__(self, key):\n self.key = key\n self.left = self.right = None\n \ndef insert(key):\n global root\n\n x = root\n y = None\n while x:x, y = x.left if key < x.key else x.right , x\n if y == None:root = Node(key)\n elif y.key < key:y.right = Node(key)\n else:y.left = Node(key)\n \n \ndef pre(node):\n if node == None:return\n print('',node.key, end = '');pre(node.left);pre(node.right)\n \ndef ino(node):\n if node == None:return\n ino(node.left);print('',node.key,end='');ino(node.right)\n\n\nn = int(input())\nroot = None\nfor j in range(n):\n s, *i = input().split()\n if s[0] == 'i':insert(int(i[0]))\n else:\n ino(root);print('');pre(root)print()\n \n \n", "jacc_sim": 1.0, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [280, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u797495064", "n_user": "u797495064", "pos": "class Node:\n def __init__(self, key):\n self.key = key\n self.left = None\n self.right = None\n self.p = None\n \n \ndef insert(root, add):\n parent = None\n pCandidate = root\n while pCandidate is not None:\n parent = pCandidate\n if add.key < pCandidate.key:\n pCandidate = pCandidate.left\n else:\n pCandidate = pCandidate.right\n add.p = parent\n \n if parent is None:\n root = add\n elif add.key < parent.key:\n parent.left = add\n else:\n parent.right = add\n return root\n\ndef inorderTreeWalk(node):\n if node.left is not None:\n inorderTreeWalk(node.left)\n print(\" {0}\".format(node.key), end=\"\")\n if node.right is not None:\n inorderTreeWalk(node.right)\n \ndef preorderTreeWalk(node):\n print(\" {0}\".format(node.key), end=\"\")\n if node.left is not None:\n preorderTreeWalk(node.left)\n if node.right is not None:\n preorderTreeWalk(node.right)\n\nn = int(input())\nroot = None\nfor i in range(n):\n line = input().split()\n if line[0] == \"insert\":\n root = insert(root, Node(int(line[1])))\n else:\n inorderTreeWalk(root)\n print()\n preorderTreeWalk(root)\n print()", "neg": "class Node:\n def __init__(self, key):\n self.key = key\n self.left = None\n self.right = None\n self.p = None\n \n \ndef insert(root, add):\n parent = None\n pCandidate = root\n while pCandidate is not None:\n parent = pCandidate\n if add.key < pCandidate.key:\n pCandidate = pCandidate.left\n else:\n pCandidate = pCandidate.right\n add.p = parent\n \n if parent is None:\n root = add\n elif add.key < parent.key:\n parent.left = add\n else:\n parent.right = add\n return root\n\ndef inorderTreeWalk(node):\n if node.left is not None:\n inorderTreeWalk(node.left)\n print(node.key, end=\" \")\n if node.right is not None:\n inorderTreeWalk(node.right)\n \ndef preorderTreeWalk(node):\n print(node.key, end=\" \")\n if node.left is not None:\n preorderTreeWalk(node.left)\n if node.right is not None:\n preorderTreeWalk(node.right)\n\nn = int(input())\nroot = None\nfor i in range(n):\n line = input().split()\n if line[0] == \"insert\":\n root = insert(root, Node(int(line[1])))\n else:\n inorderTreeWalk(root)\n print()\n preorderTreeWalk(root)\n print()", "jacc_sim": 0.9433962264150944, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [389, 377], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u935184340", "n_user": "u935184340", "pos": "import sys\n \nclass Node():\n def __init__(self,key):\n self.key = key\n self.left = None\n self.right = None\n \ndef insert(t, z):\n y = None\n x = t\n while x is not None:\n y = x\n if z.key < x.key:\n x = x.left\n else:\n x = x.right\n \n if y is None:\n return z\n else:\n if z.key < y.key:\n y.left = z\n else:\n y.right = z\n return t\n \ndef inorder(t):\n s = \"\"\n l = []\n curr = t\n while True:\n while curr is not None:\n l.append(curr)\n curr = curr.left\n if curr is None and len(l) == 0:\n break\n else:\n curr = l.pop()\n s += \" \" + str(curr.key)\n curr = curr.right\n return s\n \ndef preorder(t):\n s = \"\"\n l = []\n curr = t\n while True:\n while curr is not None:\n s += \" \" + str(curr.key)\n l.append(curr)\n curr = curr.left\n if curr is None and len(l) == 0:\n break\n else:\n curr = l.pop()\n curr = curr.right\n return s\n \nt = None\nn = sys.stdin.readline()\nlines = sys.stdin.readlines()\nfor line in lines:\n com = line.split()\n if com[0] == \"insert\":\n t = insert(t, Node(int(com[1])))\n else:\n print(inorder(t))\n print(preorder(t))", "neg": "import sys\n\nclass Node():\n def __init__(self,key):\n self.key = key\n self.left = None\n self.right = None\n\ndef insert(t, z):\n y = None\n x = t\n while x is not None:\n y = x\n if z.key < x.key:\n x = x.left\n else:\n x = x.right\n\n if y is None:\n return z\n else:\n if z.key < y.key:\n y.left = z\n else:\n y.right = z\n return t\n\ndef in_order(t):\n s = \"\"\n l = []\n curr = t\n while True:\n while curr is not None:\n l.append(curr)\n curr = curr.left\n if curr is None and len(l) == 0:\n break\n else:\n curr = l.pop()\n s += \" \" + str(curr.key)\n curr = curr.right\n return s\n\ndef pre_order(t):\n s = \"\"\n l = []\n curr = t\n while True:\n while curr is not None:\n s += \" \" + str(curr.key)\n l.append(curr)\n curr = curr.left\n if curr is None and len(l) == 0:\n break\n else:\n curr = l.pop()\n curr = curr.right\n return s\n\nt = None\nn = sys.stdin.readline()\nlines = sys.stdin.readlines()\nfor line in lines:\n com = line.split()\n if line[0] == \"insert\":\n t = insert(t, Node(int(com[1])))\n else:\n print(in_order(t))\n print(pre_order(t))", "jacc_sim": 0.9344262295081968, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [450, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u890722286", "n_user": "u890722286", "pos": "def insert(r, n):\n if 0 == len(T):\n T[n] = [None, None]\n else:\n if n < r:\n left = T[r][0]\n if left == None:\n T[r][0] = n\n T[n] = [None, None]\n else:\n insert(left, n)\n if r < n:\n right = T[r][1]\n if right == None:\n T[r][1] = n\n T[n] = [None, None]\n else:\n insert(right, n)\n\ndef print_inorder(r):\n left = T[r][0]\n right = T[r][1]\n ans = \"\"\n if left != None:\n ans += print_inorder(left)\n ans += \" {}\".format(r)\n if right != None:\n ans += print_inorder(right)\n return ans\n\ndef print_preorder(r):\n left = T[r][0]\n right = T[r][1]\n ans = \" {}\".format(r)\n if left != None:\n ans += print_preorder(left)\n if right != None:\n ans += print_preorder(right)\n return ans\n\n\n\n\nn = int(input())\nT = {}\n\nroot = None\nfor i in range(n):\n inst = input()\n if inst[0] == 'i':\n num = int(inst[7:])\n if i == 0:\n root = num\n insert(root, num)\n elif inst[0] == 'p':\n print(print_inorder(root))\n print(print_preorder(root))", "neg": "def insert(r, n):\n if 0 == len(T):\n T[n] = [None, None]\n else:\n if n < r:\n left = T[r][0]\n if left == None:\n T[r][0] = n\n T[n] = [None, None]\n else:\n insert(left, n)\n if r < n:\n right = T[r][1]\n if right == None:\n T[r][1] = n\n T[n] = [None, None]\n else:\n insert(right, n)\n\ndef print_inorder(r):\n left = T[r][0]\n right = T[r][1]\n ans = \"\"\n if left != None:\n ans += print_inorder(left)\n ans += \" {}\".format(r)\n if right != None:\n ans += print_inorder(right)\n return ans\n\ndef print_preorder(r):\n left = T[r][0]\n right = T[r][1]\n ans = \" {}\".format(r)\n if left != None:\n ans += print_inorder(left)\n if right != None:\n ans += print_inorder(right)\n return ans\n\n\n\n\nn = int(input())\nT = {}\n\nroot = None\nfor i in range(n):\n inst = input()\n if inst[0] == 'i':\n num = int(inst[7:])\n if i == 0:\n root = num\n insert(root, num)\n elif inst[0] == 'p':\n print(print_inorder(root))\n print(print_preorder(root))", "jacc_sim": 1.0, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [424, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u159356473", "n_user": "u159356473", "pos": "#coding:UTF-8\nclass Node:\n def __init__(self,point):\n self.n=point\n self.left=None\n self.right=None\n \ndef insert(t,z):\n y=None\n x=t\n while x!=None:\n y=x\n if z.n here.node:\n here = here.right\n if x < temp.node:\n temp.left = node\n elif x > temp.node:\n temp.right = node\n\n def inorder(self, answer, address = \"root\"):\n if address is \"root\":\n address = self.root\n elif address is None:\n return\n self.inorder(answer, address.left)\n answer.append(address.node)\n self.inorder(answer, address.right)\n\n def preorder(self, answer, address = \"root\"):\n if address is \"root\":\n address = self.root\n elif address is None:\n return\n answer.append(address.node)\n self.preorder(answer, address.left)\n self.preorder(answer, address.right)\n\n class Node:\n def __init__(self, x):\n self.node = x\n self.left = None\n self.right = None\n\nquery = int(input())\nbt = BinarySearchTree()\nfor _ in range(query):\n command = input()\n if command[0] == \"i\":\n bt.insert(int(command.split(\" \")[1]))\n else:\n a = []\n bt.inorder(a)\n print(\" \", end = \"\")\n print(*a)\n a = []\n bt.preorder(a)\n print(\" \", end = \"\")\n print(*a)", "neg": "class BinarySearchTree:\n def __init__(self):\n self.root = None\n\n def insert(self, x):\n node = self.Node(x)\n if self.root is None:\n self.root = node\n else:\n here = self.root\n #\n temp = None\n while here is not None:\n temp = here\n if x < here.node:\n here = here.left\n elif x > here.node:\n here = here.right\n if x < temp.node:\n temp.left = node\n elif x > temp.node:\n temp.right = node\n\n def inorder(self, answer, address = \"root\"):\n if address is \"root\":\n address = self.root\n elif address is None:\n return\n self.inorder(answer, address.left)\n answer.append(address.node)\n self.inorder(answer, address.right)\n\n def preorder(self, answer, address = \"root\"):\n if address is \"root\":\n address = self.root\n elif address is None:\n return\n answer.append(address.node)\n self.preorder(answer, address.left)\n self.preorder(answer, address.right)\n\n class Node:\n def __init__(self, x):\n self.node = x\n self.left = None\n self.right = None\n\nquery = int(input())\nbt = BinarySearchTree()\nfor _ in range(query):\n command = input()\n if command[0] == \"i\":\n bt.insert(int(command.split(\" \")[1]))\n else:\n a = [\" \"]\n bt.inorder(a)\n \n print(*a)\n a = [\" \"]\n bt.preorder(a)\n print(*a)", "jacc_sim": 0.9827586206896551, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [464, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\n\nclass Node:\n __slots__ = ['key', 'left', 'right']\n def __init__(self, key):\n self.key = key\n self.left = self.right = None\n\nclass BST:\n __slots__ = ['root']\n def __init__(self):\n self.root = None\n def insert(self, key):\n x, y = self.root, None\n while x != None: x, y = x.left if key < x.key else x.right, x\n if y == None: self.root = Node(key)\n elif key < y.key: y.left = Node(key)\n else: y.right = Node(key)\n def print_tree(self):\n def inorder(node):\n return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''\n def preorder(node):\n return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''\n print(inorder(self.root))\n print(preorder(self.root))\n\ntree = BST()\ninput()\nfor e in sys.stdin:\n if e[0] == 'i': tree.insert(int(e[7:]))\n else: tree.print_tree()\n", "neg": "import sys\n\nclass Node:\n __slots__ = ['key', 'left', 'right']\n def __init__(self, key):\n self.key = key\n self.left = self.right = None\n\nclass BST:\n def __init__(self):\n self.root = None\n def insert(self, key):\n x, y = self.root, None\n while x != None: x, y = x.left if key < x.key else x.right, x\n if y == None: self.root = Node(key)\n elif key < y.key: y.left = Node(key)\n else: y.right = z\n def print_tree(self):\n def inorder(node):\n return inorder(node.left) + f' {node.key}' + inorder(node.right) if node else ''\n def preorder(node):\n return f' {node.key}' + preorder(node.left) + preorder(node.right) if node else ''\n print(inorder(self.root))\n print(preorder(self.root))\n\ntree = BST()\ninput()\nfor e in sys.stdin:\n if e[0] == 'i': tree.insert(int(e[7:]))\n else: tree.print_tree()\n", "jacc_sim": 0.9811320754716981, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [327, 315], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u724548524", "n_user": "u724548524", "pos": "import sys\n\nclass Node():\n __slots__ = ['key', 'left', 'right']\n def __init__(self, key):\n self.key = key\n self.left, self.right = None, None\n \n def __str__(self):\n return self.key\n\nroot = None\ndef insert(z):\n global root\n x, y = root, None\n while x:\n y = x\n if z < x.key:\n x = x.left\n else:\n x = x.right\n \n if y == None:\n root = Node(z)\n elif z < y.key:\n y.left = Node(z)\n else:\n y.right = Node(z)\n \ndef preorder(x):\n return f\" {x.key}\" + preorder(x.left) + preorder(x.right) if x else \"\"\n\ndef inorder(x):\n return inorder(x.left) + f\" {x.key}\" + inorder(x.right) if x else \"\"\n \ninput()\nnode = {}\nfor s in sys.stdin:\n if s[0] == \"p\":\n pass\n print(inorder(root))\n print(preorder(root))\n else:\n insert(int(s[7:]))\n", "neg": "import sys\n\nclass Node():\n __slots__ = ['key', 'left', 'right']\n def __init__(self, key):\n self.key = key\n self.left, self.right = None\n\nroot = None\ndef insert(z):\n global root\n x, y = root, None\n while x:\n y = x\n if z < x.key:\n x = x.left\n else:\n x = x.right\n \n if y == -1:\n root = Node(z)\n elif z < y.key:\n y.left = Node(z)\n else:\n y.right = Node(z)\n \ndef preorder(x):\n return f\" {x.key}\" + preorder(x.left) + preorder(x.right) if x else \"\"\n\ndef inorder(x):\n return inorder(x.left) + f\" {x.key}\" + inorder(x.right) if x else \"\"\n \ninput()\nnode = {}\nroot = -1\nfor s in sys.stdin:\n if s[0] == \"p\":\n print(inorder(root))\n print(preorder(root))\n else:\n insert(int(s[7:])\n\n", "jacc_sim": 0.9259259259259259, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [320, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u684241248", "n_user": "u684241248", "pos": "class Tree:\n def __init__(self, orders):\n self.root = None\n for order in orders:\n if len(order) == 1:\n self.inorder_print()\n self.preorder_print()\n else:\n self.insert(int(order[1]))\n\n def insert(self, key):\n z = Node(key)\n y = None\n x = self.root\n while x:\n y = x\n if z.key < x.key:\n x = x.left\n else:\n x = x.right\n z.parent = y\n\n if not y:\n self.root = z\n elif z.key < y.key:\n y.left = z\n else:\n y.right = z\n\n def inorder_print(self):\n self.root.inorder_print()\n print()\n\n def preorder_print(self):\n self.root.preorder_print()\n print()\n\n\nclass Node:\n def __init__(self, key):\n self.key = key\n self.parent = None\n self.left = None\n self.right = None\n\n def inorder_print(self):\n if self.left:\n self.left.inorder_print()\n print(' {}'.format(self.key), end='')\n if self.right:\n self.right.inorder_print()\n\n def preorder_print(self):\n print(' {}'.format(self.key), end='')\n if self.left:\n self.left.preorder_print()\n if self.right:\n self.right.preorder_print()\n\n\nif __name__ == '__main__':\n import sys\n m = int(input())\n orders = [line.strip().split() for line in sys.stdin]\n # orders = [input().split() for i in range(m)]\n Tree(orders)\n\n", "neg": "class Tree:\n def __init__(self, orders):\n self.root = None\n for order in orders:\n if len(order) == 1:\n self.inorder_print()\n self.preorder_print()\n else:\n self.insert(int(order[1]))\n\n def insert(self, key):\n z = Node(key)\n y = None\n x = self.root\n while x:\n y = x\n if z.key < x.key:\n x = x.left\n else:\n x = x.right\n z.parent = y\n\n if not y:\n self.root = z\n elif z.key < y.key:\n y.left = z\n else:\n y.right = z\n\n def inorder_print(self):\n self.root.inorder_print()\n print()\n\n def preorder_print(self):\n self.root.preorder_print()\n print()\n\n\nclass Node:\n def __init__(self, key):\n self.key = key\n self.parent = None\n self.left = None\n self.right = None\n\n def inorder_print(self):\n if self.left:\n self.left.inorder_print()\n print(' {}'.format(self.key), end='')\n if self.right:\n self.right.inorder_print()\n\n def preorder_print(self):\n print(' {}'.format(self.key), end='')\n if self.left:\n self.left.preorder_print()\n if self.right:\n self.right.preorder_print()\n\n\nif __name__ == '__main__':\n import sys\n m = int(input())\n orders = [line.strip().split() for line in sys.stdin]\n # orders = [input().split() for i in range(m)]\n\n", "jacc_sim": 1.0, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [477, 471], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02283", "p_user": "u007270338", "n_user": "u007270338", "pos": "#coding:utf-8\nN = int(input())\ntrees = [list(input().split()) for i in range(N)]\n\nclass BinaryTree:\n def __init__(self,key,p=None,l=None,r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n\ndef Insert(root,z):\n y = None\n x = root\n while x != None:\n y = x\n if z.key < x.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n\ndef preOrder(root):\n x = root\n if x == None:\n return\n global preList\n preList.append(x.key)\n \n preOrder(x.l)\n preOrder(x.r)\n\ndef inOrder(root):\n x = root\n if x == None:\n return\n inOrder(x.l)\n\n global inList\n inList.append(x.key)\n \n inOrder(x.r)\n\nroot = None\nfor data in trees:\n if data[0] == \"insert\":\n z = BinaryTree(int(data[1]))\n root = Insert(root,z)\n if data[0] == \"print\":\n inList = []\n preList = []\n inOrder(root)\n a = \" \" + \" \".join([str(num) for num in inList])\n print(a)\n\n preOrder(root)\n a = \" \" + \" \".join([str(num) for num in preList])\n print(a)\n\n", "neg": "#coding:utf-8\nN = int(input())\ntrees = [list(input().split()) for i in range(N)]\n\nclass BinaryTree:\n def __init__(self,key,p=None,l=None,r=None):\n self.key = key\n self.p = p\n self.l = l\n self.r = r\n\ndef Insert(root,z):\n y = None\n x = root\n while x != None:\n y = x\n if z.key < x.key:\n x = x.l\n else:\n x = x.r\n z.p = y\n\n if y == None:\n root = z\n elif z.key < y.key:\n y.l = z\n else:\n y.r = z\n return root\n\ndef preOrder(root):\n x = root\n if x == None:\n return\n global preList\n preList.append(x.key)\n \n preOrder(x.l)\n preOrder(x.r)\n\ndef inOrder(root):\n x = root\n if x == None:\n return\n inOrder(x.l)\n\n global inList\n inList.append(x.key)\n \n inOrder(x.r)\n\nroot = None\nfor data in trees:\n if data[0] == \"insert\":\n z = BinaryTree(int(data[1]))\n root = Insert(root,z)\n if data[0] == \"print\":\n inList = []\n preList = []\n inOrder(root)\n a = \" \".join([str(num) for num in inList])\n print(a)\n\n preOrder(root)\n a = \" \".join([str(num) for num in preList])\n print(a)\n\n", "jacc_sim": 0.9838709677419355, "nl": "Binary Search Tree I\n\nSearch trees are dynamic data structures supporting operations like insert, search, and delete. They can function as dictionaries and priority queues. A binary search tree is a fundamental search tree where keys are stored to satisfy the binary search tree property: for any node x, if y is in the left subtree of x, then y.key \u2264 x.key; if y is in the right subtree of x, then x.key \u2264 y.key.\n\nA binary search tree can be used to print keys in sorted order through an inorder tree walk. It should maintain the binary search tree property after insertions and deletions. Each node in the tree has a key, satellite data, and fields left, right, and p pointing to its left child, right child, and parent, respectively.\n\nTo insert a new value v into a binary search tree T, the insert procedure is used. The program should perform insert and print operations on the binary search tree T. The insert operation uses the provided pseudo code. T is initially empty.\n\nInput:\nThe first line contains the number of operations m. The following m lines contain insert k or print operations.\n\nOutput:\nFor each print operation, print the keys obtained by inorder and preorder tree walks on a single line, with a space before each key.\n\nConstraints:\n- The number of operations \u2264 500,000\n- The number of print operations \u2264 10\n- -2,000,000,000 \u2264 key \u2264 2,000,000,000\n- The height of the binary tree does not exceed 100 using the provided pseudo code\n- The keys in the binary search tree are all different.\n\nSample Input 1:\n8\ninsert 30\ninsert 88\ninsert 12\ninsert 1\ninsert 20\ninsert 17\ninsert 25\nprint\n\nSample Output 1:\n 1 12 17 20 25 30 88\n 30 12 1 20 17 25 88\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [458, 452], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u357267874", "n_user": "u357267874", "pos": "def get_left_index(A, i):\n if len(A) > 2 * i:\n return 2 * i\n else:\n return None\n\ndef get_right_index(A, i):\n if len(A) > 2 * i + 1:\n return 2 * i + 1\n else:\n return None\n\ndef max_heapfy(A, i):\n left = get_left_index(A, i)\n right = get_right_index(A, i)\n largest = i\n if left and A[left] > A[i]:\n largest = left\n if right and A[right] > A[largest]:\n largest = right\n if largest != i:\n A[i], A[largest] = A[largest], A[i]\n max_heapfy(A, largest)\n\nH = int(input())\nA = [0]\nfor elem in map(int, input().split()):\n A.append(elem)\n\n\ndef build_max_heap(A):\n for i in range(H//2, 0, -1):\n max_heapfy(A, i)\nbuild_max_heap(A)\nprint(' ', end='') \nprint(*A[1:])\n", "neg": "def get_left_index(A, i):\n if len(A) > 2 * i:\n return 2 * i\n else:\n return None\n\ndef get_right_index(A, i):\n if len(A) > 2 * i + 1:\n return 2 * i + 1\n else:\n return None\n\ndef max_heapfy(A, i):\n left = get_left_index(A, i)\n right = get_right_index(A, i)\n largest = i\n if left and A[left] > A[i]:\n largest = left\n if right and A[right] > A[largest]:\n largest = right\n if largest != i:\n A[i], A[largest] = A[largest], A[i]\n max_heapfy(A, largest)\n\nH = int(input())\nA = [0]\nfor elem in map(int, input().split()):\n A.append(elem)\n\n\ndef build_max_heap(A):\n for i in range(H//2, 0, -1):\n print(i)\n max_heapfy(A, i)\nbuild_max_heap(A)\nprint(' ', end='') \nprint(*A[1:])\n", "jacc_sim": 1.0, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [306, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u320446607", "n_user": "u320446607", "pos": "H = int(input())\nA = [None] + list(map(int, input().split()))\n\ndef max_heapify(A, i):\n\tl = i * 2 \n\tr = i * 2 + 1\n\tlargest = i\n\tif l <= H:\n\t\tif A[l] > A[largest]:\n\t\t\tlargest = l\n\tif r <= H:\n\t\tif A[r] > A[largest]:\n\t\t\tlargest = r\n\tif largest != i:\n\t\tA[i], A[largest] = A[largest], A[i]\n\t\tmax_heapify(A, largest)\n\ndef build_max_heap(A):\n\tfor i in range(int(H / 2), 0, -1):\n\t\tmax_heapify(A, i)\n\nbuild_max_heap(A)\nprint(\" \", end = \"\")\nprint(*A[1:])", "neg": "H = int(input())\nA = [None] + list(map(int, input().split()))\n\ndef max_heapify(A, i):\n\tl = i * 2 \n\tr = i * 2 + 1\n\tlargest = i\n\tif l < H:\n\t\tif A[l] > A[largest]:\n\t\t\tlargest = l\n\tif r < H:\n\t\tif A[r] > A[largest]:\n\t\t\tlargest = r\n\tif largest != i:\n\t\tA[i], A[largest] = A[largest], A[i]\n\t\tmax_heapify(A, largest)\n\ndef build_max_heap(A):\n\tfor i in reversed(range(1, int(H / 2))):\n\t\tmax_heapify(A, i)\n\nbuild_max_heap(A)\nprint(\" \", end = \"\")\nprint(*A[1:])", "jacc_sim": 0.926829268292683, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [222, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u460172144", "n_user": "u460172144", "pos": "\n\ndef maxHeapify(i):\n l =2*i\n r = 2*i+1\n # print(A[i])\n largest =0\n if l <=H and A[l]> A[i]:\n largest = l\n else:\n largest = i\n\n if r <= H and A[r] > A[largest]:\n largest = r\n\n if largest != i :\n A[i],A[largest] = A[largest],A[i]\n maxHeapify(largest)\n # print(A)\n\n\n\nH = int(input())\n\nA = list(map(int,input().split()))\n\nA = [-1]+A\n\nfor i in range(int(H/2),0,-1):\n maxHeapify(i)\n\nAstr = list(map(str,A))\n\nprint(\" \",end=\"\")\n\nprint(\" \".join(Astr[1:]))", "neg": "\n\ndef maxHeapify(i):\n l =2*i\n r = 2*i+1\n print(A[i])\n largest =0\n if l <=H and A[l]> A[i]:\n largest = l\n else:\n largest = i\n\n if r <= H and A[r] > A[largest]:\n largest = r\n\n if largest != i :\n A[i],A[largest] = A[largest],A[i]\n maxHeapify(largest)\n print(A)\n\n\n\nH = int(input())\n\nA = list(map(int,input().split()))\n\nA = [-1]+A\n\nfor i in range(int(H/2),0,-1):\n maxHeapify(i)\n\nAstr = list(map(str,A))\n\n# print(\" \",end=\"\")\n\nprint(*A[1:])", "jacc_sim": 0.9777777777777777, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [231, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u159356473", "n_user": "u159356473", "pos": "#coding:UTF-8\ndef maxHeapify(A,i,n):\n l=2*i\n r=2*i+1\n if l <=n and A[l]>A[i] :\n largest=l\n else:\n largest=i\n if r<=n and A[r]>A[largest]:\n largest=r\n if largest!=i:\n A[i],A[largest]=A[largest],A[i]\n maxHeapify(A,largest,n)\n\ndef MH(A,n):\n for i in range(int(n/2),0,-1):\n maxHeapify(A,i,n)\n A.remove(-1)\n for i in range(len(A)):\n A[i]=str(A[i])\n print(\" \"+\" \".join(A)) \nif __name__==\"__main__\":\n H=int(input())\n A=input().split(\" \")\n for i in range(len(A)):\n A[i]=int(A[i])\n A=[-1]+A\n MH(A,H)", "neg": "#coding:UTF-8\ndef maxHeapify(A,i,n):\n print(i)\n l=2*i\n r=2*i+1\n if l <=n and A[l]>A[i] :\n largest=l\n else:\n largest=i\n if r<=n and A[r]>A[largest]:\n largest=r\n if largest!=i:\n A[i],A[largest]=A[largest],A[i]\n maxHeapify(A,largest,n)\n\ndef MH(A,n):\n for i in range(int(n/2),0,-1):\n maxHeapify(A,i,n)\n A.remove(-1)\n for i in range(len(A)):\n A[i]=str(A[i])\n print(\" \"+\" \".join(A)) \nif __name__==\"__main__\":\n H=int(input())\n A=input().split(\" \")\n for i in range(len(A)):\n A[i]=int(A[i])\n A=[-1]+A\n MH(A,H)", "jacc_sim": 1.0, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [283, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u742013327", "n_user": "u742013327", "pos": "#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B\n#???????????? 17:55~\n\ndef maxHeapify(heap, index):\n left_index = 2 * index\n right_index = 2 * index + 1\n largest_index = index\n \n if left_index < len(heap) and heap[left_index] > heap[index]:\n largest_index = left_index\n\n if right_index < len(heap) and heap[right_index] > heap[largest_index]:\n largest_index = right_index\n\n if largest_index != index:\n heap[index], heap[largest_index] = heap[largest_index], heap[index]\n maxHeapify(heap, largest_index)\n \ndef main():\n n_node = int(input())\n target_list = [\"\"] + [int(n) for n in input().split()]\n for i in range(1, int(len(target_list) / 2) + 1)[::-1]:\n maxHeapify(target_list, i)\n \n print(*target_list)\nif __name__ == \"__main__\":\n main()", "neg": "#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_9_B\n#???????????? 17:55~\n\ndef maxHeapify(heap, index):\n left_index = 2 * index\n right_index = 2 * index + 1\n\n if left_index < len(heap) and heap[left_index] > heap[index]:\n largest_index = left_index\n else:\n largest_index = index\n\n if right_index < len(heap) and heap[right_index] > heap[largest_index]:\n largest_index = right_index\n\n if not largest_index == index:\n heap[index], heap[largest_index] = heap[largest_index], heap[index]\n maxHeapify(heap, largest_index)\n \ndef main():\n n_node = int(input())\n target_list = [\"\"] + [int(n) for n in input().split()]\n for i in range(int(len(target_list) / 2), 0, -1):\n print(i)\n maxHeapify(target_list, i)\n \n print(*target_list)\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9354838709677419, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [302, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u112247126", "n_user": "u112247126", "pos": "def maxHeapify(heap, i):\n left = (i + 1) * 2 - 1\n right = (i + 1) * 2\n largest = left if left < len(heap) and heap[left] > heap[i] else i\n largest = right if right < len(heap) and heap[right] > heap[largest] else largest\n if largest != i:\n heap[i], heap[largest] = heap[largest], heap[i]\n maxHeapify(heap, largest)\n\ndef buildMaxHeap(heap):\n for i in range(len(heap) // 2, -1, -1):\n maxHeapify(heap, i)\n\nn = int(input())\nheap = list(map(int, input().split()))\nbuildMaxHeap(heap)\n\nout = ''\nfor key in heap:\n out += (' {}'.format(str(key)))\nprint(out)", "neg": "# ????????????????????????????????????\n\ndef maxHeapify(heap, i):\n left = (i + 1) * 2 - 1\n right = (i + 1) * 2\n largest = left if heap[left] > heap[i] and left < len(heap) else i\n largest = right if heap[right] > heap[largest] and right < len(heap) else largest\n if largest != i:\n heap[i], heap[largest] = heap[largest], heap[i]\n maxHeapify(heap, largest)\n\ndef buildMaxHeap(heap):\n for i in range(len(heap) // 2, -1, -1):\n maxHeapify(heap, i)\n\nn = int(input())\nheap = list(map(int, input().split()))\nbuildMaxHeap(heap)\nprint('', *heap)\n\n'''\nout = ''\nfor key in heap:\n out += (' {}'.format(str(key)))\nprint(out)\n'''", "jacc_sim": 0.9607843137254902, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [217, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u727760769", "n_user": "u727760769", "pos": "global A\n\ndef max_heapfy(i):\n left = 2*i+1\n right = 2*i+2\n\n max_val = 0\n if left< H and A[i] < A[left]:\n max_val = left\n else:\n max_val = i\n\n if rightA[i-1]:\n largest=l\n else:\n largest=i\n if r<=H and A[r-1]>A[largest-1]:\n largest=r\n \n if largest!=i:\n A[i-1],A[largest-1]=A[largest-1],A[i-1]\n maxHeapify(A,largest,H)\n \nH=int(input())\nA=list(map(int,input().split()))\nfor i in range(H//2,0,-1):\n maxHeapify(A,i,H)\n \nprint(\" {}\".format(\" \".join(map(str,A))))\n", "neg": "\n\ndef maxHeapify(i):\n l =2*i\n r = 2*i+1\n print(A[i])\n largest =0\n if l <=H and A[l]> A[i]:\n largest = l\n else:\n largest = i\n\n if r <= H and A[r] > A[largest]:\n largest = r\n\n if largest != i :\n A[i],A[largest] = A[largest],A[i]\n maxHeapify(largest)\n print(A)\n\n\n\nH = int(input())\n\nA = list(map(int,input().split()))\n\nA = [-1]+A\n\nfor i in range(int(H/2),0,-1):\n maxHeapify(i)\n\nAstr = list(map(str,A))\n\nprint(\" \".join(Astr[1:]))", "jacc_sim": 0.9130434782608695, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [212, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u150984829", "n_user": "u150984829", "pos": "H=int(input())+1\nA=[0]+list(map(int,input().split()))\ndef h(i):\n l=2*i;r=l+1\n if ri:A[i],A[g]=A[g],A[i];h(g)\n elif l a[i-1]:\n largest = l\n else:\n largest = i\n if r <= h and a[r-1] > a[largest-1]:\n largest = r\n \n if largest != i:\n a[i-1], a[largest-1] = a[largest-1], a[i-1]\n max_heapify(a, largest)\n\ndef build_max_heap(a):\n for i in list(range(1,h//2+1))[::-1]:\n max_heapify(a, i)\n #print(a)\n \nbuild_max_heap(a)\n\nfor i in range(h):\n print(' {}'.format(a[i]),end = '')\nprint()\n \n", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Jun 9 13:21:18 2018\nALDS1-9b\n@author: maezawa\n\"\"\"\nimport math\n\nh = int(input())\na = list(map(int,input().split()))\n\ndef parent(node):\n return math.floor(node/2)\n\ndef left(node):\n return 2*node\n\ndef right(node):\n return 2*node+1\n\ndef max_heapify(a, i):\n l = left(i)\n r = right(i)\n if l <= h and a[l-1] > a[i-1]:\n largest = l\n else:\n largest = i\n if r <= h and a[r-1] > a[largest-1]:\n largest = r\n \n if largest != i:\n a[i-1], a[largest-1] = a[largest-1], a[i-1]\n max_heapify(a, largest)\n\ndef build_max_heap(a):\n for i in list(range(1,h//2+1))[::-1]:\n max_heapify(a, i)\n #print(a)\n \nbuild_max_heap(a)\n\nfor i in range(h):\n print(' {}'.format(a[i]))\n \n", "jacc_sim": 0.9855072463768116, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [347, 340], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u007270338", "n_user": "u879226672", "pos": "#coding:utf-8\nH = int(input())\nA = list(map(int,input().split()))\n\ndef maxHeapify(A,i):\n l = 2 * i\n r = 2 * i + 1\n if l <= H and A[l-1] > A[i-1]:\n largest = l\n else:\n largest = i\n if r <= H and A[r-1] > A[largest-1]:\n largest = r\n if largest != i:\n A[i-1], A[largest-1] = A[largest-1], A[i-1]\n maxHeapify(A,largest)\n\ndef buildMaxHeap(A):\n for i in range(H // 2, 0, -1):\n maxHeapify(A,i)\n\nbuildMaxHeap(A)\nA = \" \" + \" \".join([str(num) for num in A])\nprint(A)\n\n", "neg": "# coding: utf-8\ndef maxHeapify(A, i):\n l = 2*i\n r = 2*i+1\n \n if l <= H and A[l] > A[i]:\n largest = l\n else:\n largest = i\n \n if r <= H and A[r] > A[largest]:\n largest = r\n if largest != i:\n A[i],A[largest] = A[largest],A[i]\n maxHeapify(A, largest)\n \ndef buildMaxHeap(A):\n for i in range(H/2,0,-1):\n maxHeapify(A,i)\n\nH = int(raw_input())\nA = map(int, [0]+raw_input().split())\nbuildMaxHeap(A)\nprint \" \".join(map(str,A[1:]))", "jacc_sim": 0.9215686274509803, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [230, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02288", "p_user": "u434132766", "n_user": "u460172144", "pos": "H = int(input())\nA = [0] + list(map(int, input().split()))\n\ndef maxHeapify(A, i):\n l = i*2\n r = i*2 + 1\n\n if l <= H and A[l] > A[i]:\n largest = l\n else:\n largest = i\n\n if r <= H and A[r] > A[largest]:\n largest = r \n\n if largest != i:\n A[largest], A[i] = A[i], A[largest]\n maxHeapify(A, largest)\n\nfor x in range(H//2, 0, -1):\n maxHeapify(A, x)\n\nprint(\"\", *A[1:])\n\n \n \n", "neg": "\n\ndef maxHeapify(i):\n l =2*i\n r = 2*i+1\n print(A[i])\n largest =0\n if l <=H and A[l]> A[i]:\n largest = l\n else:\n largest = i\n\n if r <= H and A[r] > A[largest]:\n largest = r\n\n if largest != i :\n A[i],A[largest] = A[largest],A[i]\n maxHeapify(largest)\n print(A)\n\n\n\nH = int(input())\n\nA = list(map(int,input().split()))\n\nA = [-1]+A\n\nfor i in range(int(H/2),0,-1):\n maxHeapify(i)\n\nAstr = list(map(str,A))\n\nprint(\" \",end=\"\")\n\nprint(*A[1:])", "jacc_sim": 0.9090909090909091, "nl": "Title: Maximum Heap\n\nA binary heap that adheres to the max-heap property is called a max-heap. In a max-heap, for every node i other than the root, A[i] \u2264 A[parent(i)], meaning the value of a node is at most the value of its parent. The largest element in a max-heap is stored at the root, and the subtree rooted at a node contains values no larger than that contained at the node itself.\n\nWrite a program that reads an array and constructs a max-heap from the array based on the following pseudo code:\n\nmaxHeapify(A, i) moves the value of A[i] down to leaves to make a sub-tree of node i a max-heap. Here, H is the size of the heap.\n\nThe following procedure buildMaxHeap(A) makes A a max-heap by performing maxHeapify in a bottom-up manner.\n\nInput:\nThe first line contains an integer H. The second line contains H integers representing elements in the binary heap in order of node id (from 1 to H).\n\nOutput:\nPrint values of nodes in the max-heap in order of their id (from 1 to H). Print a single space character before each value.\n\nConstraint:\n1 \u2264 H \u2264 500,000\n-2,000,000,000 \u2264 value of a node \u2264 2,000,000,000\n\nSample Input 1:\n10\n4 1 3 2 16 9 10 14 8 7\n\nSample Output 1:\n16 14 10 8 7 9 3 2 4 1\n\nReference:\nIntroduction to Algorithms, Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. The MIT Press.", "before_after_length": [186, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02289", "p_user": "u112247126", "n_user": "u112247126", "pos": "from sys import stdin\nfrom heapq import heappop, heappush\nreadline = stdin.readline\n\nheap = []\nwhile True:\n line = readline()\n if line[1] == 'x':\n print(-heappop(heap))\n elif line[0] == 'i':\n heappush(heap, -int(line.split()[1]))\n else:\n break\n\n\n'''\ndef insert(heap, key):\n heap.append(-1000000)\n heapIncreaseKey(heap, key)\n\ndef parent(i):\n return (i - 1) // 2\n\ndef heapIncreaseKey(heap, key):\n heap[len(heap) - 1] = key\n i = len(heap) - 1\n while i > 0 and heap[parent(i)] < heap[i]:\n heap[i], heap[parent(i)] = heap[parent(i)], heap[i]\n i = parent(i)\n\ndef heapExtractMax(heap):\n if len(heap) < 1:\n return None\n else:\n MAX = heap[0]\n heap[0] = heap.pop()\n maxHeapify(heap, 0)\n\n return MAX\n\ndef maxHeapify(heap, i):\n left = (i + 1) * 2 - 1\n right = (i + 1) * 2\n largest = left if left < len(heap) and heap[left] > heap[i] else i\n largest = right if right < len(heap) and heap[right] > heap[largest] else largest\n if largest != i:\n heap[i], heap[largest] = heap[largest], heap[i]\n maxHeapify(heap, largest)\n\n\nheap = []\nwhile True:\n line = sys.stdin.readline()\n if line[0] == 'i':\n insert(heap, int(line.split()[1]))\n elif line[0:2] == 'ex':\n print(str(heapExtractMax(heap)))\n else:\n break\n'''", "neg": "import sys\n\ndef insert(heap, key):\n heap.append(-1000000)\n heapIncreaseKey(heap, key)\n\ndef parent(i):\n return (i - 1) // 2\n\ndef heapIncreaseKey(heap, key):\n heap[len(heap) - 1] = key\n i = len(heap) - 1\n while i > 0 and heap[parent(i)] < heap[i]:\n heap[i], heap[parent(i)] = heap[parent(i)], heap[i]\n i = parent(i)\n\ndef heapExtractMax(heap):\n if len(heap) < 1:\n return None\n else:\n MAX = heap[0]\n heap[0] = heap.pop()\n maxHeapify(heap, 0)\n\n return MAX\n\ndef maxHeapify(heap, i):\n left = (i + 1) * 2 - 1\n right = (i + 1) * 2\n largest = left if left < len(heap) and heap[left] > heap[i] else i\n largest = right if right < len(heap) and heap[right] > heap[largest] else largest\n if largest != i:\n heap[i], heap[largest] = heap[largest], heap[i]\n maxHeapify(heap, largest)\n\n\nheap = []\nwhile True:\n line = sys.stdin.readline()\n if line[0] == 'i':\n insert(heap, int(line.split()[1]))\n elif line[0:2] == 'ex':\n print(str(heapExtractMax(heap)))\n else:\n break", "jacc_sim": 0.9206349206349206, "nl": "Priority Queue\n\nA priority queue is a data structure that maintains a set S of elements, each with an associated value (key), and supports the operations insert(S, k) to insert an element k into the set S, and extractMax(S) to remove and return the element of S with the largest key. Write a program to perform these operations on a priority queue S, managing a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue S are given. Each operation is in the form \"insert k\", \"extract\", or \"end\" in a line, where k represents an integer element to be inserted to the priority queue. The input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue S in a line.\n\nConstraints\n\n- The number of operations \u2264 2,000,000\n- 0 \u2264 k \u2264 2,000,000,000\n\nSample Input 1\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n8\n10\n11\n2", "before_after_length": [494, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02289", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfrom heapq import *\nH=[]\nO=''\nfor e in sys.stdin:\n if'i'==e[0]:heappush(H,-int(e[7:]))\n elif'x'==e[1]:O+=f'{-heappop(H)}\\n'\nprint(O[:-1])\n", "neg": "import sys\nfrom heapq import *\nH,O=[],''\nfor e in sys.stdin:\n if'i'==e[0]:heappush(H,-int(e[7:]))\n elif't'==e[2]:O+=f'{-heappop(H)}\\n'\nprint(O[-1])\n", "jacc_sim": 0.925, "nl": "Priority Queue\n\nA priority queue is a data structure that maintains a set S of elements, each with an associated value (key), and supports the operations insert(S, k) to insert an element k into the set S, and extractMax(S) to remove and return the element of S with the largest key. Write a program to perform these operations on a priority queue S, managing a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue S are given. Each operation is in the form \"insert k\", \"extract\", or \"end\" in a line, where k represents an integer element to be inserted to the priority queue. The input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue S in a line.\n\nConstraints\n\n- The number of operations \u2264 2,000,000\n- 0 \u2264 k \u2264 2,000,000,000\n\nSample Input 1\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n8\n10\n11\n2", "before_after_length": [82, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02289", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfrom heapq import *\nH,O=[],[]\nfor e in sys.stdin:\n if'i'==e[0]:heappush(H,-int(e[7:]))\n elif'x'==e[1]:O+=[-heappop(H)]\nprint('\\n'.join(map(str,O)))\n", "neg": "import sys\nfrom heapq import *\nH,O=[],[]\nfor e in sys.stdin:\n c=e[1]\n if'n'==c:heappush(H,-int(e[7:]))\n elif'x'==c:O+=[-heappop(H)]\nprint('\\n'.join(map(str,O)))\n", "jacc_sim": 0.9230769230769231, "nl": "Priority Queue\n\nA priority queue is a data structure that maintains a set S of elements, each with an associated value (key), and supports the operations insert(S, k) to insert an element k into the set S, and extractMax(S) to remove and return the element of S with the largest key. Write a program to perform these operations on a priority queue S, managing a set of integers, which are also keys for the priority.\n\nInput\n\nMultiple operations to the priority queue S are given. Each operation is in the form \"insert k\", \"extract\", or \"end\" in a line, where k represents an integer element to be inserted to the priority queue. The input ends with \"end\" operation.\n\nOutput\n\nFor each \"extract\" operation, print the element extracted from the priority queue S in a line.\n\nConstraints\n\n- The number of operations \u2264 2,000,000\n- 0 \u2264 k \u2264 2,000,000,000\n\nSample Input 1\ninsert 8\ninsert 2\nextract\ninsert 10\nextract\ninsert 11\nextract\nextract\nend\n\nSample Output 1\n8\n10\n11\n2", "before_after_length": [82, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02292", "p_user": "u519227872", "n_user": "u519227872", "pos": "from math import sqrt\nxp0, yp0, xp1, yp1 = map(int, input().split())\na = [xp0, yp0]\nb = [xp1, yp1]\nq = int(input())\n\nCCW = {1: 'COUNTER_CLOCKWISE',\n 2: 'CLOCKWISE',\n 3: 'ONLINE_BACK',\n 4: 'ONLINE_FRONT',\n 5: 'ON_SEGMENT',}\n\ndef dot(a, b):\n return sum([i * j for i,j in zip(a, b)])\n\ndef sub(a, b):\n return [a[0] - b[0],a[1] - b[1]]\n\ndef cross(a, b):\n return a[0] * b[1] - a[1] * b[0]\n\ndef _abs(a):\n return sqrt(a[0] ** 2 + a[1] ** 2)\n\ndef ccw(a, b, c):\n x = sub(b, a)\n y = sub(c, a)\n if cross(x, y) > 0: return 1\n if cross(x, y) < 0: return 2\n if dot(x, y) < 0: return 3\n if _abs(x) < _abs(y): return 4\n return 5\n\nfor i in range(q):\n c = list(map(int, input().split()))\n print(CCW[ccw(a, b, c)])\n ", "neg": "from math import sqrt\nxp0, yp0, xp1, yp1 = map(int, input().split())\na = [xp0, yp0]\nb = [xp1, yp1]\nq = int(input())\n\nCCW = {1: 'COUNTER_CLOCKWISE',\n 2: 'CLOCKWISE',\n 3: 'ONLINE_BACK',\n 4: 'ONLINE_FRONT',\n 5: 'ON_SEGMENT',}\n\ndef dot(a, b):\n return sum([i * j for i,j in zip(a, b)])\n\ndef sub(a, b):\n return [a[0] - b[0],a[1] - b[1]]\n\ndef cross(a, b):\n return a[0] * b[1] - a[1] * b[0]\n\ndef _abs(a):\n return sqrt(a[0] ** 2 + a[1] ** 2)\n\ndef ccw(a, b, c):\n x = sub(b, c)\n y = sub(c, a)\n if cross(x, y) > 0: return 1\n if cross(x, y) < 0: return 2\n if dot(x, y) < 0: return 3\n if _abs(x) < _abs(y): return 4\n return 5\n\nfor i in range(q):\n c = list(map(int, input().split()))\n print(CCW[ccw(a, b, c)])", "jacc_sim": 1.0, "nl": "Title: Counter-Clockwise\n\nFor given three points p0, p1, p2, print COUNTER_CLOCKWISE if p0, p1, p2 make a counterclockwise turn (1), CLOCKWISE if p0, p1, p2 make a clockwise turn (2), ONLINE_BACK if p2 is on a line p2, p0, p1 in this order (3), ONLINE_FRONT if p2 is on a line p0, p1, p2 in this order (4), ON_SEGMENT if p2 is on a segment p0p1 (5).\n\nInput:\nx_p0 y_p0 x_p1 y_p1\nq\nx_p2_0 y_p2_0\nx_p2_1 y_p2_1\n...\nx_p2_q-1 y_p2_q-1\n\nIn the first line, integer coordinates of p0 and p1 are given. Then, q queries are given for integer coordinates of p2.\n\nOutput:\nFor each query, print the above mentioned status.\n\nConstraints:\n- 1 \u2264 q \u2264 1000\n- -10000 \u2264 x_i, y_i \u2264 10000\n- p0 and p1 are not identical.\n\nSample Input 1:\n0 0 2 0\n2\n-1 1\n-1 -1\n\nSample Output 1:\nCOUNTER_CLOCKWISE\nCLOCKWISE\n\nSample Input 2:\n0 0 2 0\n3\n-1 0\n0 0\n3 0\n\nSample Output 2:\nONLINE_BACK\nON_SEGMENT\nONLINE_FRONT", "before_after_length": [366, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02293", "p_user": "u279605379", "n_user": "u279605379", "pos": "def dot(a,b):return a[0]*b[0] + a[1]*b[1]\ndef cross(a,b):return a[0]*b[1] - a[1]*b[0]\n\nq = int(input())\nfor i in range(q):\n x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]\n a = [x1-x0,y1-y0]\n b = [x3-x2,y3-y2]\n if dot(a,b) == 0 : print(1)\n elif cross(a,b) == 0 : print(2)\n else : print(0)", "neg": "def dot(a,b):return a[0]*b[0] + a[1]*b[1]\ndef cross(a,b):return a[0]*b[1] - a[1]*b[0]\n\nq = int(input())\nfor i in range(q):\n x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]\n a = [x1-x0,y1-y0]\n b = [x3-x2,y3-y2]\n if dot(a,b) == 0 : print(1)\n elif cross(a,b) == 0 : print(2)\n else : print(0)\n print(a,b,dot(a,b))", "jacc_sim": 1.0, "nl": "Title: Parallel/Orthogonal\n\nFor two given lines s1 and s2, output \"2\" if they are parallel, \"1\" if they are orthogonal, or \"0\" otherwise.\n\ns1 crosses points p0 and p1, and s2 crosses points p2 and p3.\n\nInput:\nThe input consists of the number of queries q, followed by q queries. Each query contains the integer coordinates of the points p0, p1, p2, and p3 in the format: xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3.\n\nOutput:\nFor each query, print \"2\", \"1\", or \"0\".\n\nConstraints:\n- 1 \u2264 q \u2264 1000\n- -10000 \u2264 xi, yi \u2264 10000\n- p0 \u2260 p1 and p2 \u2260 p3\n\nSample Input:\n3\n0 0 3 0 0 2 3 2\n0 0 3 0 1 1 1 4\n0 0 3 0 1 1 2 2\n\nSample Output:\n2\n1\n0", "before_after_length": [180, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02294", "p_user": "u567380442", "n_user": "u567380442", "pos": "from sys import stdin\nreadline = stdin.readline\n\n\ndef main():\n q = int(readline())\n for i in range(q):\n xy = map(int, readline().split())\n p0, p1, p2, p3 = [x + y * 1j for x, y in zip(*[xy] * 2)]\n print(1 if is_intersected_ls(p0, p1, p2, p3) else 0)\n\n\ndef is_intersected_ls(a1, a2, b1, b2):\n eps = 0\n if max(a1.real, a2.real) < min(b1.real, b2.real)\\\n or max(b1.real, b2.real) < min(a1.real, a2.real)\\\n or max(a1.imag, a2.imag) < min(b1.imag, b2.imag)\\\n or max(b1.imag, b2.imag) < min(a1.imag, a2.imag):\n return False\n\n #print(cross(a2-a1, b1-a1))\n #print(cross(a2-a1, b2-a1))\n #print(cross(b2-b1, a1-b1))\n #print(cross(b2-b1, a2-b1))\n return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) <= eps)\\\n and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) <= eps)\n\n\ndef cross(a, b):\n return a.real * b.imag - a.imag * b.real\nmain()", "neg": "from sys import stdin\nreadline = stdin.readline\n\n\ndef main():\n q = int(readline())\n for i in range(q):\n xy = map(int, readline().split())\n p0, p1, p2, p3 = [x + y * 1j for x, y in zip(*[xy] * 2)]\n print(1 if is_intersected_ls(p0, p1, p2, p3) else 0)\n\n\ndef is_intersected_ls(a1, a2, b1, b2):\n eps = 0\n return (cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < eps) and (cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < eps)\n\ndef cross(a, b):\n return a.real * b.imag - a.imag * b.real\nmain()", "jacc_sim": 0.9016393442622951, "nl": "Title: Intersection\n\nFor two given segments s1 and s2, output \"1\" if they intersect, \"0\" otherwise.\n\ns1 is defined by endpoints p0 and p1, and s2 is defined by endpoints p2 and p3.\n\nInput:\nThe input consists of the number of queries q, followed by q queries. Each query contains the integer coordinates of the endpoints of s1 and s2 in the format: xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3.\n\nOutput:\nFor each query, print \"1\" if the segments intersect, and \"0\" if they do not.\n\nConstraints:\n- 1 \u2264 q \u2264 1000\n- -10000 \u2264 xi, yi \u2264 10000\n- p0 \u2260 p1 and p2 \u2260 p3\n\nSample Input:\n3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0\n\nSample Output:\n1\n1\n0", "before_after_length": [434, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02294", "p_user": "u279605379", "n_user": "u279605379", "pos": "def dot(a,b):return a[0]*b[0] + a[1]*b[1]\ndef cross(a,b):return a[0]*b[1] - a[1]*b[0]\ndef isOn(a,b):\n if cross(a,b) == 0:\n if dot(a,b) < 0 or dot(a,a) < dot(b,b) : return False\n else : return True\n else : \n return False\n\nq = int(input())\nfor i in range(q):\n x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]\n a = [x1-x0,y1-y0]\n b = [x2-x0,y2-y0]\n c = [x3-x0,y3-y0]\n d = [x3-x2,y3-y2]\n e = [x0-x2,y0-y2]\n f = [x1-x2,y1-y2]\n if isOn(a,b) or isOn(a,c):\n print(1)\n elif cross(a,b) == 0 and cross(a,c) == 0:\n if ( not isOn(c,a) and isOn(b,a)) or (isOn(c,a) and not isOn(b,a)) :\n print(1)\n else:\n print(0)\n elif cross(a,b) * cross(a,c) > 0 :\n print(0)\n elif cross(d,e) * cross(d,f) > 0 :\n print(0)\n else :\n print(1)", "neg": "def dot(a,b):return a[0]*b[0] + a[1]*b[1]\ndef cross(a,b):return a[0]*b[1] - a[1]*b[0]\ndef isOn(a,b):\n if cross(a,b) == 0:\n if dot(a,b) < 0 or dot(a,a) < dot(b,b) : return False\n else : return True\n else : \n return False\n\nq = int(input())\nfor i in range(q):\n x0,y0,x1,y1,x2,y2,x3,y3 = [int(i) for i in input().split()]\n a = [x1-x0,y1-y0]\n b = [x2-x0,y2-y0]\n c = [x3-x0,y3-y0]\n d = [x3-x2,y3-y2]\n e = [x0-x2,y0-y2]\n f = [x1-x2,y1-y2]\n if isOn(a,b) or isOn(a,c) or isOn(c,a) or isOn(b,a):\n print(1)\n elif cross(a,b) == 0 and cross(a,c) == 0:\n print(0)\n elif cross(a,b) * cross(a,c) > 0 :\n print(0)\n elif cross(d,e) * cross(d,f) > 0 :\n print(0)\n else :\n print(1)", "jacc_sim": 0.9807692307692307, "nl": "Title: Intersection\n\nFor two given segments s1 and s2, output \"1\" if they intersect, \"0\" otherwise.\n\ns1 is defined by endpoints p0 and p1, and s2 is defined by endpoints p2 and p3.\n\nInput:\nThe input consists of the number of queries q, followed by q queries. Each query contains the integer coordinates of the endpoints of s1 and s2 in the format: xp0 yp0 xp1 yp1 xp2 yp2 xp3 yp3.\n\nOutput:\nFor each query, print \"1\" if the segments intersect, and \"0\" if they do not.\n\nConstraints:\n- 1 \u2264 q \u2264 1000\n- -10000 \u2264 xi, yi \u2264 10000\n- p0 \u2260 p1 and p2 \u2260 p3\n\nSample Input:\n3\n0 0 3 0 1 1 2 -1\n0 0 3 0 3 1 3 -1\n0 0 3 0 3 -2 5 0\n\nSample Output:\n1\n1\n0", "before_after_length": [425, 393], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nP =[]\ns = 0\nfor i in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor i in range(n):\n a = P[i][0] ; b = P[i][1]; c = P[i+1][0] ; d = P[i+1][1]\n s += a * d - b * c\nprint(abs(s)*0.5)", "neg": "n = int(input())\nP =[]\ns = 0\nfor i in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor i in range(n):\n a = P[i][0] ; b = P[i][1]; c = P[i+1][0] ; P[i+1][1]\n s += a * d - b * c\nprint(abs(s)*0.5)", "jacc_sim": 1.0, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [117, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nP =[]\ns = 0\nx0,y0 = [int(i) for i in input().split()]\nfor i in range(n-1):\n x,y = [int(i) for i in input().split()]\n P.append([x-x0,y-y0])\nfor i in range(n-2):\n s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]\nprint(abs(s)*0.5)", "neg": "n = int(input())\nP =[]\ns = 0\nx0,y0 = [int(i) for i in input().split()]\nfor i in range(n):\n x,y = [int(i) for i in input().split()]\n P.append([x-x0,y-y0])\nfor i in range(n-2):\n s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]\nprint(abs(s)*0.5)", "jacc_sim": 1.0, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [133, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nP =[]\ns = 0\nfor i in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor i in range(n):s += (P[i][0])*P[i+1][1] - (P[i][1])*P[i+1][0]\nprint(abs(s)*0.5)", "neg": "n = int(input())\nP =[]\ns = 0\nfor i in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor i in range(n-2):\n s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]\nprint(abs(s)*0.5)", "jacc_sim": 0.9629629629629629, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [101, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nP =[]\ns = 0\nfor i in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor i in range(n):s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]\nprint(s*0.5)", "neg": "n = int(input())\nP =[]\ns = 0\nfor _ in range(n):P.append([-int(i) for i in input().split()])\nP.append(P[0])\nfor j in range(n):s += P[j][1]*P[j+1][0] - P[j][0] * P[j+1][1]\nprint(s*0.5)", "jacc_sim": 0.9259259259259259, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [95, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nP =[]\ns = 0\nfor _ in range(n):P.append([int(i) for i in input().split()])\nP.append(P[0])\nfor j in range(n):s += P[j][1]*P[j+1][0] - P[j][0] * P[j+1][1]\nprint(-s*0.5)", "neg": "n = int(input())\nx = range(n)\nP =[]\ns = 0\nfor _ in x:P.append([int(i) for i in input().split()])\nP+=P[0]\nfor j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]\nprint(s*0.5)", "jacc_sim": 0.9642857142857143, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [97, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nx = range(n)\nP =[]\ns = 0\nfor i in x:P += [[int(i) for i in input().split()]]\nP+=[P[0]]\nfor i in x:s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]\nprint(s*0.5)", "neg": "n = int(input())\nx = range(n)\nP =[]\ns = 0\nfor _ in x:P += [[int(i) for i in input().split()]]\nP+=P[0]\nfor j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]\nprint(s*0.5)", "jacc_sim": 0.9259259259259259, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [96, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "x=range(int(input()))\nP=[]\ns=0\nfor i in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor i in x:s+=P[i][0]*P[i+1][1]-P[i][1]*P[i+1][0]\nprint(s*0.5)", "neg": "x=range(int(input()))\nP=[]\n_=0\nfor _ in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:s+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]\nprint(s*0.5)", "jacc_sim": 0.9230769230769231, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [94, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "n = int(input())\nx = range(n)\nP =[]\nn = 0\nfor _ in x:P += [[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:n += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]\nprint(n*0.5)", "neg": "n=int(input())\nP=[]\nfor _ in range(n):P+=[[int(i) for i in input().split()]]\n_=0\nP+=[P[0]]\nfor j in range(n-1):_+=P[j+1][1]*(P[j][0]-P[j+2][0])-P[j+1][0]*(P[j][1]-P[j+2][1])\nprint(_*0.5)", "jacc_sim": 0.9259259259259259, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [96, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "x=range(int(input()))\nf=lambda a,b,c,d : a*d - b*c \nP=[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\n_=0\nP+=[P[0]]\nfor j in x:_+=f(P[j][0],P[j][1],P[j+1][0],P[j+1][1])\nprint(_*0.5)", "neg": "x=range(int(input()))\nf=lambda a,b,c,d : a*d - b*c \nP=[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\n_=0\nP+=[P[0]]\nfor j in x:_+=f(P[j][0],P[j][1],,P[j+1][0]P[j+1][1])\nprint(_*0.5)", "jacc_sim": 1.0, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [114, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "x=range(int(input()))\nP=[]\nQ=[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:Q+=[P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]]\nprint(sum(Q)*0.5)", "neg": "x=range(int(input()))\nP=[]\n_=0\nfor _ in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:_+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0]\nprint(_*0.5)", "jacc_sim": 0.9259259259259259, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [96, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02297", "p_user": "u279605379", "n_user": "u279605379", "pos": "x=range(int(input())-1,-1,-1)\nP=[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:_+=P[j+1][1]*P[j][0]-P[j][1]*P[j+1][0]\nprint(_*0.5)", "neg": "x=range(int(input()),0,-1)\nP=[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\nP+=[P[0]]\nfor j in x:_+=P[j-1][0]*P[j][1]-P[j-1][1]*P[j][0]\nprint(_*0.5-1)", "jacc_sim": 1.0, "nl": "Area\n\nFor a given polygon g, calculate the area of the polygon.\n\ng is represented by a sequence of points p1, p2,..., pn where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of g. The line segment connecting pn and p1 is also a side of the polygon.\n\nNote that the polygon is not necessarily convex.\n\nInput\n\nThe input consists of coordinates of the points p1,..., pn in the following format:\n\nn\nx1 y1 \nx2 y2\n:\nxn yn\n\nThe first integer n is the number of points. The coordinate of a point pi is given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit of them.\n\nOutput\n\nPrint the area of the polygon in a line. The area should be printed with one digit to the right of the decimal point.\n\nConstraints\n\n- 3 \u2264 n \u2264 100\n- -10000 \u2264 xi, yi \u2264 10000\n- No point will occur more than once.\n- Two sides can intersect only at a common endpoint.\n\nSample Input 1\n3\n0 0\n2 2\n-1 1\n\nSample Output 1\n2.0\n\nSample Input 2\n4\n0 0\n1 1\n1 2\n0 2\n\nSample Output 2\n1.5", "before_after_length": [97, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02298", "p_user": "u279605379", "n_user": "u279605379", "pos": "def cross(a,b):return a[0]*b[1] - a[1]*b[0]\ndef dif(a,b):return [x-y for x,y in zip(a,b)]\n\nx = range(int(input()))\nt = 1\nP,Q = [],[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\nfor i in x:Q+=[dif(P[i],P[i-1])]\nfor i in x:\n if cross(Q[i-1],Q[i]) < 0: t *= False\nprint(t)", "neg": "def cross(a,b):return a[0]*b[1] - a[1]*b[0]\ndef dif(a,b):return [x-y for x,y in zip(a,b)]\n\nx = range(int(input()))\nt = 1\nP,Q = [],[]\nfor _ in x:P+=[[int(i) for i in input().split()]]\nfor i in x:Q+=[dif(P[i],P[i-1])]\nfor i in x:if cross(Q[i-1],Q[i]) < 0: t *= False\nprint(t)", "jacc_sim": 1.0, "nl": "Is-Convex\n\nFor a given polygon g, determine if g is a convex polygon. Print \"1\" if g is convex, and \"0\" otherwise. A convex polygon has all interior angles less than or equal to 180 degrees.\n\nInput\nThe polygon g is represented by a sequence of points p1, p2, ..., pn, where line segments connecting pi and pi+1 (1 \u2264 i \u2264 n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the polygon.\n\nThe input format for g is as follows:\nn\nx1 y1\nx2 y2\n...\nxn yn\nThe first integer n is the number of points. The coordinates of a point pi are given by two integers xi and yi. The coordinates of points are given in the order of counter-clockwise visit.\n\nOutput\nPrint \"1\" or \"0\" in a line.\n\nConstraints\n- 3 \u2264 n \u2264 100\n-10000 \u2264 xi, yi \u2264 10000\n- No point of the polygon will occur more than once.\n- Two sides of the polygon can intersect only at a common endpoint.\n\nSample Input 1\n4\n0 0\n3 1\n2 3\n0 3\n\nSample Output 1\n1\n\nSample Input 2\n5\n0 0\n2 0 \n1 1\n2 2\n0 2\n\nSample Output 2\n0", "before_after_length": [148, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u629780968", "n_user": "u629780968", "pos": "def cross(a, b):\n return a.real * b.imag - a.imag*b.real\n\ndef convex_hull(p):\n pp = sorted(p, key=lambda x:(x.imag, x.real))\n n = len(pp)\n ans = [0] * (n+1)\n j = 0\n\n #\u4e0a\u5074\u3092\u5165\u308c\u3066\u3044\u304f\n for i in range(n):\n while j > 1 and cross(ans[j-1] - ans[j-2], pp[i]-ans[j-1]) < 0: #\u5e38\u306b\u6b21\u306e\u70b9\u304c\u4e0b\u5074\u306b\n j -= 1\n ans[j] = pp[i]\n j += 1\n k = j\n #\u4e0b\u5074\u3092\u5165\u308c\u3066\u3044\u304f\n for i in range(n-2, -1, -1):\n while j > k and cross(ans[j-1]-ans[j-2], pp[i]-ans[j-1]) < 0: #\u5e38\u306b\u6b21\u306e\u70b9\u304c\u4e0b\u5074\u306b\n j -= 1\n ans[j] = pp[i]\n j +=1\n return ans[0:j-1]\n\nn = int(input())\np=[]\nfor i in range(n):\n x,y = list(map(int, input().split()))\n p.append(complex(x,y))\nans = convex_hull(p)\nprint(len(ans))\n\nfor i in ans:\n print(int(i.real), int(i.imag))\n\n", "neg": "def cross(a, b):\n return a.real * b.imag - a.imag*b.real\n\ndef convex_hull(p):\n pp = sorted(p, key=lambda x:(x.imag, x.real))\n n = len(pp)\n ans = [0] * (n+1)\n j = 0\n\n #\u4e0a\u5074\u3092\u5165\u308c\u3066\u3044\u304f\n for i in range(n):\n while j > 1 and cross(ans[j-1] - ans[j-2], pp[i]-ans[j-1]) < 0: #\u5e38\u306b\u6b21\u306e\u70b9\u304c\u4e0b\u5074\u306b\n j -= 1\n ans[j] = pp[i]\n j += 1\n k = j\n #\u4e0b\u5074\u3092\u5165\u308c\u3066\u3044\u304f\n for i in range(n-2, -1, -1):\n while j > k and cross(ans[j-1]-ans[j-2], pp[i]-ans[j-1]) < 0: #\u5e38\u306b\u6b21\u306e\u70b9\u304c\u4e0b\u5074\u306b\n j -= 1\n ans[j] = pp[i]\n j +=1\n return ans[0:j-1]\n\nn = int(input())\np=[]\nfor i in range(n):\n x,y = list(map(int, input().split()))\n p.append(complex(x,y))\nans = convex_hull(p)\n\n\nfor i in ans:\n print(int(i.real), int(i.imag))\n\n", "jacc_sim": 1.0, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [441, 435], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "from collections import deque\n\ndef isCLKWISE(ph):\n a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]\n b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]\n crs = a[0]*b[1] - a[1]*b[0]\n if crs < 0 : return False\n else : return True\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = int(input())\nP = deque([])\nfor i in range(n):\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R:\n print(r[0],r[1])", "neg": "from collections import deque\n\ndef isCLKWISE(ph):\n return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n : P.append([int(x) for x in input().split()])\nQ = deque(ConvexHullScan(P))\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q.rotate(idx)\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.90625, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [437, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph):\n a = ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]\n b = ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]\n crs = b[1]*a[0] - a[1]*b[0]\n if crs < 0 : return False\n else : return True\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = int(input())\nP = []\nfor i in range(n):\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R:\n print(r[0],r[1])", "neg": "def isCLKWISE(ph):\n if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) > 0 : return True\n return False\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9152542372881356, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [427, 402], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph):\n a = ph[-1][0] - ph[-3][0]\n d = - ph[-3][1] + ph[-2][1]\n c = ph[-2][0] - ph[-3][0]\n b = - ph[-3][1] + ph[-1][1] \n crs = a*d - b*c\n if crs < 0 : return False\n else : return True\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = int(input())\nP = []\nfor i in range(n):\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R:\n print(r[0],r[1])", "neg": "import heapq\n\ndef isCLKWISE(ph):\n a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]]\n b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]]\n crs = a[0]*b[1] - a[1]*b[0]\n if crs < 0 :\n return False\n else :\n return True\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) :\n break\n else :\n del phU[-2]\n if len(phU) == 2 :\n break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) :\n break\n else :\n del phL[-2]\n if len(phL) == 2 :\n break\n ph = phU + phL[1:-1]\n return ph\n\nn = int(input())\nP = []\nfor i in range(n):\n heappush(P,[int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nfor q in Q:\n idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\n R = Q[idx:] + Q[:idx]\nfor r in R:\n print(r[0],r[1])", "jacc_sim": 0.90625, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [427, 456], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "#CGL_4-A Convex Polygon - Convex Hull\ndef isCLKWISE(ph):\n if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False\n return True\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph):\n return (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9152542372881356, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [418, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph):\n if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) >= 0 : return True\n return False\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph):\n return ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) >= 0\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9818181818181818, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [402, 394], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph):\n return (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) >= 0\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph):\n return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P.sort()\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = []\nfor i in n:\n P.append([int(x) for x in input().split()])\n \nQ = ConvexHullScan(P).reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9122807017543859, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [395, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P) :\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:] :\n phU.append(p)\n while(True) :\n if isCLKWISE(phU) : break\n else :\n del phU[-2]\n if len(phU) == 2 : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1] :\n phL.append(p)\n while(True) :\n if isCLKWISE(phL) : break\n else :\n del phL[-2]\n if len(phL) == 2 : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n if isCLKWISE(phU) : continue\n while(True):\n del phU[-2]\n if len(phU) == 2 : break\n else :\n if isCLKWISE(phU) : break\n\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n if isCLKWISE(phU) : continue\n while(True):\n del phL[-2]\n if len(phL) == 2 : break\n else :\n if isCLKWISE(phL) : break\n\n \n \n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9821428571428571, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [391, 421], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n if isCLKWISE(phU) : continue\n while(True):\n del phU[-2]\n if len(phU) == 2 : break\n else :\n if isCLKWISE(phU) : break\n\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n if isCLKWISE(phL) : continue\n while(True):\n del phL[-2]\n if len(phL) == 2 : break\n else :\n if isCLKWISE(phL) : break\n\n \n \n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph) : return (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n if not isCLKWISE(phU) : continue\n while(True):\n del phU[-2]\n try:\n if isCLKWISE(phU) : break\n except IndexError : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n if not isCLKWISE(phL) : continue\n while(True):\n del phL[-2]\n try:\n if isCLKWISE(phL) : break\n except IndexError : break\n \n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "jacc_sim": 0.9166666666666666, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [421, 405], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n try :\n if isCLKWISE(phU) : break\n else : del phU[-2]\n except IndexError : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n try :\n if isCLKWISE(phL) : break\n else : del phL[-2]\n except IndexError : break\n ph = phU + phL[1:-1]\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nQ = ConvexHullScan(P)\nQ.reverse()\nprint(len(Q))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]\nR = Q[idx:] + Q[:idx]\nfor r in R : print(r[0],r[1])", "neg": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P) :\n P = sorted(P)\n phU = []\n phU.append(P[0])\n phU.append(P[1])\n for p in P[2:] :\n phU.append(p)\n if isCLKWISE(phU) : continue\n while(True)???:\n del phU[-2]\n try???:\n if isCLKWISE(phU) : break\n except IndexError : break\n phL = []\n phL.append(P[-1])\n phL.append(P[-2])\n for p in P[-3::-1] :\n phL.append(p)\n if isCLKWISE(phL) : continue\n while(True) :\n del phL[-2]\n try:\n if isCLKWISE(phL) : break\n except IndexError : break\n del phL[0]\n del phL[-1]\n ph = phU + phL\n return ph\n \nn = range(int(input()))\nP = [[int(x) for x in input().split()] for _ in n]\nP = ConvexHullScan(P)\nP.reverse()\nprint(len(P))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]\nfor p in P[idx:] + P[:idx] : print(p[0],p[1])", "jacc_sim": 0.9016393442622951, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [379, 431], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u279605379", "n_user": "u279605379", "pos": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P):\n P = sorted(P)\n phU = [P[0],P[1]]\n for p in P[2:]:\n phU.append(p)\n while(True):\n try :\n if isCLKWISE(phU) : break\n else : del phU[-2]\n except IndexError : break\n phL = [P[-1],P[-2]]\n for p in P[-3::-1]:\n phL.append(p)\n while(True):\n try :\n if isCLKWISE(phL) : break\n else : del phL[-2]\n except IndexError : break\n ph = phU + phL[1:-1]\n return ph\n \nP = [[int(x) for x in input().split()] for _ in range(int(input()))]\nP = ConvexHullScan(P)\nP.reverse()\nprint(len(P))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]\nfor p in P[idx:] + P[:idx] : print(p[0],p[1])", "neg": "def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)\n \ndef ConvexHullScan(P) :\n P = sorted(P)\n phU = []\n phU.append(P[0])\n phU.append(P[1])\n for p in P[2:] :\n phU.append(p)\n if isCLKWISE(phU) : continue\n while(True) :\n del phU[-2]\n try :\n if isCLKWISE(phU) : break\n except IndexError : break\n phL = []\n phL.append(P[-1])\n phL.append(P[-2])\n for p in P[-3::-1] :\n phL.append(p)\n if isCLKWISE(phL) : continue\n while(True) :\n del phL[-2]\n try:\n if isCLKWISE(phL) : break\n except IndexError : break\n del phL[0]\n del phL[-1]\n ph = phU + phL\n return ph\n\nP = [[int(x) for x in input().split()] for _ in range(int(input()))]\nP = ConvexHullScan(P)\nP.reverse()\nprint(len(P))\nidx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]\nfor p in P[idx:] + P[:idx] : print(p[0],p[1])", "jacc_sim": 0.9642857142857143, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [371, 436], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u519227872", "n_user": "u519227872", "pos": "from math import sqrt\nfrom collections import deque\n\ndef sub(a, b):\n return [a[0] - b[0],a[1] - b[1]]\n\ndef cross(a, b):\n return a[0] * b[1] - a[1] * b[0]\n\ndef ccw(a, b, c):\n x = sub(b, a)\n y = sub(c, a)\n return cross(x, y) > 0\n\nn = int(input())\nc = [list(map(int, input().split())) for i in range(n)]\nc.sort(key=lambda x: (x[0], x[1]))\nU = deque(c[:2])\n\nfor i in range(2, n):\n j = len(U)\n while j >= 2 and ccw(U[-1],U[-2],c[i]):\n U.pop()\n j -= 1\n U.append(c[i])\n\nc = c[::-1]\nL = deque(c[:2])\n\nfor i in range(2, n):\n j = len(L)\n while j >= 2 and ccw(L[-1], L[-2], c[i]):\n L.pop()\n j -= 1\n L.append(c[i])\n\nans = U\nfor i in range(1,len(L)-1):\n x, y = L[i]\n ans.append([x,y])\n\nprint(len(ans))\ni = ans.index(sorted(ans, key=lambda x: (x[1],x[0]))[0])\nans = list(ans)\nfor x,y in ans[i:] + ans[:i]:\n print(x, y)\n", "neg": "from math import sqrt\nfrom collections import deque\n\ndef sub(a, b):\n return [a[0] - b[0],a[1] - b[1]]\n\ndef cross(a, b):\n return a[0] * b[1] - a[1] * b[0]\n\ndef ccw(a, b, c):\n x = sub(b, a)\n y = sub(c, a)\n return cross(x, y) > 0\n\nn = int(input())\nc = [list(map(int, input().split())) for i in range(n)]\nc.sort(key=lambda x: (x[0], x[1]))\nU = deque(c[:2])\n\nfor i in range(2, n):\n j = len(U)\n while j >= 2 and ccw(U[-1],U[-2],c[i]):\n U.pop()\n j -= 1\n U.append(c[i])\n\nc = c[::-1]\nL = deque(c[:2])\n\nfor i in range(2, n):\n j = len(L)\n while j >= 2 and ccw(L[-1], L[-2], c[i]):\n L.pop()\n j -= 1\n L.append(c[i])\n\nans = U\nfor i in range(1,len(L)-1):\n x, y = L[i]\n ans.append([x,y])\n\ni = ans.index(sorted(ans, key=lambda x: (x[1],x[0]))[0])\nans = list(ans)\nfor x,y in ans[:i] + ans[i:]:\n print(x, y)\n", "jacc_sim": 1.0, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [424, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02300", "p_user": "u805716376", "n_user": "u336892997", "pos": "def sgined_area(v0, v1, v2):\n a1 = v1[0] - v0[0]\n a2 = v1[1] - v0[1]\n b1 = v2[0] - v0[0]\n b2 = v2[1] - v0[1]\n return a1*b2 - b1*a2\n\nn = int(input())\nvors = [[int(a) for a in input().split() ] for _ in range(n)]\nvors.sort(key=lambda v: (v[1], v[0]))\n\nover = [vors[0], vors[1]]\n\nfor v in vors[2:]:\n while len(over) > 1 and sgined_area(over[-2], over[-1], v) > 0:\n over.pop()\n over.append(v)\n \nunder = [vors[0], vors[1]]\n\nfor v in vors[2:]:\n while len(under) > 1 and sgined_area(under[-2], under[-1], v) < 0:\n under.pop()\n under.append(v)\n \nprint(len(over) + len(under) - 2)\nfor v in under[:-1]:\n print(v[0], v[1])\n\n \n \nfor v in reversed(over[1:]):\n print(v[0], v[1])\n", "neg": "\ndef clockwise(v0, v1, v2):\n a1 = v1[0] - v0[0]\n a2 = v1[1] - v0[1]\n b1 = v2[0] - v0[0]\n b2 = v2[1] - v0[1]\n return (a1*b2 - b1*a2) < 0\n\n\nn = int(input())\nvors = [[int(a) for a in input().split() ] for _ in range(n)]\nvors.sort(key=lambda v: (v[1], v[0]))\n\nover = [vors[0], vors[1]]\n\nfor v in vors[2:]:\n while len(over) > 1 and not clockwise(over[-2], over[-1], v):\n over.pop()\n over.append(v)\n \nunder = [vors[0], vors[1]]\n\nfor v in vors[2:]:\n while len(under) > 1 and clockwise(under[-2], under[-1], v):\n under.pop()\n under.append(v)\n\nprint(len(over) + len(under) - 2)\nfor v in under[:-1]:\n print(v[0], v[1])\n\nfor v in reversed(over[1:]):\n print(v[0], v[1])\n ", "jacc_sim": 0.9411764705882353, "nl": "Convex Hull: Find the smallest convex polygon containing all given points. The polygon should have all points of P on its corners and boundary. Input: n, followed by n lines of x and y coordinates. Output: Number of points on the convex polygon's boundary, followed by their coordinates in counter-clockwise order. Constraints: 3 \u2264 n \u2264 100000, -10000 \u2264 xi, yi \u2264 10000, no repeated points.", "before_after_length": [352, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02305", "p_user": "u265136581", "n_user": "u265136581", "pos": "\ncx1, cy1, r1 = map(float, input().split())\ncx2, cy2, r2 = map(float, input().split())\n\nimport math\ndistance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )\nrsum = r1 + r2\nrmax = max(r1, r2)\nrmin = min(r1, r2)\n\nimport sys\nif distance > rsum:\n print(4)\nelif abs(distance - rsum) < sys.float_info.epsilon:\n print(3)\nelse:\n if rmax < distance + rmin:\n print(2)\n elif abs(rmax - distance - rmin) < sys.float_info.epsilon:\n print(1)\n else:\n print(0)\n", "neg": "\ncx1, cy1, r1 = map(float, raw_input().split())\ncx2, cy2, r2 = map(float, raw_input().split())\n\nimport math\ndistance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) )\nrsum = r1 + r2\nrmax = math.max(r1, r2)\nrmin = math.min(r1, r2)\n\nimport sys\nif distance > rsum:\n print(4)\nelif abs(distance - rsum) < sys.float_info.epsilon:\n print(3)\nelse:\n if rmax < distance + rmin:\n print(2)\n elif abs(rmax - distance - rmin) < sys.float_info.epsilon:\n print(1)\n else:\n print(0)\n", "jacc_sim": 0.9545454545454546, "nl": "Intersection of Circles\n\nFor given two circles c1 and c2, print:\n4 if they do not cross (there are 4 common tangent lines),\n3 if they are circumscribed (there are 3 common tangent lines),\n2 if they intersect (there are 2 common tangent lines),\n1 if a circle is inscribed in another (there is 1 common tangent line),\n0 if a circle includes another (there is no common tangent line).\n\nInput\nCoordinates and radii of c1 and c2 are given in the following format:\nc1x c1y c1r\nc2x c2y c2r\nc1x, c1y, and c1r represent the center coordinate and radius of the first circle.\nc2x, c2y, and c2r represent the center coordinate and radius of the second circle.\nAll input values are given in integers.\n\nOutput\nPrint \"4\", \"3\", \"2\", \"1\", or \"0\" in a line.\n\nConstraints\n-1000 \u2264 c1x, c1y, c2x, c2y \u2264 1000\n1 \u2264 c1r, c2r \u2264 1000\nc1 and c2 are different.\n\nSample Input 1\n1 1 1\n6 2 2\n\nSample Output 1\n4\n\nSample Input 2\n1 2 1\n4 2 2\n\nSample Output 2\n3\n\nSample Input 3\n1 2 1\n3 2 2\n\nSample Output 3\n2\n\nSample Input 4\n0 0 1\n1 0 2\n\nSample Output 4\n1\n\nSample Input 5\n0 0 1\n0 0 2\n\nSample Output 5\n0", "before_after_length": [213, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02305", "p_user": "u825008385", "n_user": "u825008385", "pos": "# Intersection of Circles\nimport math\n\nclass Circle:\n def __init__(self, x, y, r):\n self.x = x\n self.y = y\n self.r = r\n\ndef Exchange(c1, c2):\n return list((c2, c1))\n\ndata = list(map(int, input(\"\").split()))\nc1 = Circle(data[0],data[1],data[2])\n\ndata = list(map(int, input(\"\").split()))\nc2 = Circle(data[0],data[1],data[2])\n\nif c1.r < c2.r:\n [c1, c2] = Exchange(c1, c2)\n \nd = math.sqrt((c1.x - c2.x)**2 + (c1.y - c2.y)**2)\n\nif d > c1.r + c2.r:\n print(4)\nelif d == c1.r + c2.r:\n print(3)\nelif c1.r - c2.r < d and d < c1.r + c2.r:\n print(2)\nelif d == c1.r - c2.r:\n print(1)\nelif d < c1.r - c2.r:\n print(0)\n\n", "neg": "# Intersection of Circles\nimport math\n\nclass Circle:\n def __init__(self, x, y, r):\n self.x = x\n self.y = y\n self.r = r\n\ndef Exchange(c1, c2):\n return list((c2, c1))\n\ndata = list(map(int, input(\"Please enter the value of c1: \").split()))\nc1 = Circle(data[0],data[1],data[2])\n\ndata = list(map(int, input(\"Please enter the value of c2: \").split()))\nc2 = Circle(data[0],data[1],data[2])\n\nif c1.r < c2.r:\n [c1, c2] = Exchange(c1, c2)\n \nd = math.sqrt((c1.x - c2.x)**2 + (c1.y - c2.y)**2)\n\nif d > c1.r + c2.r:\n print(4)\nelif d == c1.r + c2.r:\n print(3)\nelif c1.r - c2.r < d and d < c1.r + c2.r:\n print(2)\nelif d == c1.r - c2.r:\n print(1)\nelif d < c1.r - c2.r:\n print(0)\n\n", "jacc_sim": 0.9245283018867925, "nl": "Intersection of Circles\n\nFor given two circles c1 and c2, print:\n4 if they do not cross (there are 4 common tangent lines),\n3 if they are circumscribed (there are 3 common tangent lines),\n2 if they intersect (there are 2 common tangent lines),\n1 if a circle is inscribed in another (there is 1 common tangent line),\n0 if a circle includes another (there is no common tangent line).\n\nInput\nCoordinates and radii of c1 and c2 are given in the following format:\nc1x c1y c1r\nc2x c2y c2r\nc1x, c1y, and c1r represent the center coordinate and radius of the first circle.\nc2x, c2y, and c2r represent the center coordinate and radius of the second circle.\nAll input values are given in integers.\n\nOutput\nPrint \"4\", \"3\", \"2\", \"1\", or \"0\" in a line.\n\nConstraints\n-1000 \u2264 c1x, c1y, c2x, c2y \u2264 1000\n1 \u2264 c1r, c2r \u2264 1000\nc1 and c2 are different.\n\nSample Input 1\n1 1 1\n6 2 2\n\nSample Output 1\n4\n\nSample Input 2\n1 2 1\n4 2 2\n\nSample Output 2\n3\n\nSample Input 3\n1 2 1\n3 2 2\n\nSample Output 3\n2\n\nSample Input 4\n0 0 1\n1 0 2\n\nSample Output 4\n1\n\nSample Input 5\n0 0 1\n0 0 2\n\nSample Output 5\n0", "before_after_length": [326, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02305", "p_user": "u893844544", "n_user": "u893844544", "pos": "import math\n\nc1x,c1y,c1r = [int(i) for i in input().split()]\nc2x,c2y,c2r = [int(i) for i in input().split()]\n\nd = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2))\n\nbcr = 0\nscr = 0\n\nif c1r > c2r:\n bcr = c1r\n scr = c2r\nelse:\n bcr = c2r\n scr = c1r\n\n\nif d > bcr + scr:\n print(4)\nelif d == bcr + scr:\n print(3)\nelif d + scr > bcr:\n print(2)\nelif d + scr == bcr:\n print(1)\nelse:\n print(0)\n\n", "neg": "import math\n\nc1x,c1y,c1r = [int(i) for i in input().split()]\nc2x,c2y,c2r = [int(i) for i in input().split()]\n\nd = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2))\n\nif d > c1r + c2r:\n print(4)\nelif d == c1r + c2r:\n print(3)\nelif d + c1r > c2r or d + c2r > c1r:\n print(2)\nelif d + c1r == c2r or d + c2r == c1r:\n print(1)\nelse:\n print(0)\n\n", "jacc_sim": 0.925, "nl": "Intersection of Circles\n\nFor given two circles c1 and c2, print:\n4 if they do not cross (there are 4 common tangent lines),\n3 if they are circumscribed (there are 3 common tangent lines),\n2 if they intersect (there are 2 common tangent lines),\n1 if a circle is inscribed in another (there is 1 common tangent line),\n0 if a circle includes another (there is no common tangent line).\n\nInput\nCoordinates and radii of c1 and c2 are given in the following format:\nc1x c1y c1r\nc2x c2y c2r\nc1x, c1y, and c1r represent the center coordinate and radius of the first circle.\nc2x, c2y, and c2r represent the center coordinate and radius of the second circle.\nAll input values are given in integers.\n\nOutput\nPrint \"4\", \"3\", \"2\", \"1\", or \"0\" in a line.\n\nConstraints\n-1000 \u2264 c1x, c1y, c2x, c2y \u2264 1000\n1 \u2264 c1r, c2r \u2264 1000\nc1 and c2 are different.\n\nSample Input 1\n1 1 1\n6 2 2\n\nSample Output 1\n4\n\nSample Input 2\n1 2 1\n4 2 2\n\nSample Output 2\n3\n\nSample Input 3\n1 2 1\n3 2 2\n\nSample Output 3\n2\n\nSample Input 4\n0 0 1\n1 0 2\n\nSample Output 4\n1\n\nSample Input 5\n0 0 1\n0 0 2\n\nSample Output 5\n0", "before_after_length": [219, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02317", "p_user": "u209989098", "n_user": "u209989098", "pos": "import bisect\na = int(input())\nb = [int(input()) for d in range(a)]\nc = [b[0]]\nfor i in b[1:]:\n if c[-1] < i:\n c.append(i)\n else:\n c[bisect.bisect_left(c,i)] = i\n \nprint(len(c))\n", "neg": "import bisect\na = int(input())\nb = [int(input()) in d in range(a)]\nc = [b[1]]\nfor i in b[1:]:\n if c[-1] < i:\n c.append(i)\n else:\n c[bisect.bisect_left(c,i)] = i\n \nprint(len(c))\n", "jacc_sim": 0.9666666666666667, "nl": "Title: Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequence (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 \u2264 i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\nThe length of the longest increasing subsequence of A.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 0 \u2264 ai \u2264 10^9\n\nSample Input 1\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n3\n\nSample Input 2\n3\n1\n1\n1\n\nSample Output 2\n1", "before_after_length": [93, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02317", "p_user": "u567380442", "n_user": "u567380442", "pos": "from sys import stdin\nfrom bisect import bisect_left\nreadline = stdin.readline\n\n\ndp = [-float('inf')]\nn = int(readline())\na = (int(readline()) for _ in range(n))\nfor ai in a:\n if dp[-1] < ai:\n dp.append(ai)\n else:\n dp[bisect_left(dp, ai)] = ai\nprint(len(dp) - 1)", "neg": "from sys import stdin\nimport bisect\nreadline = stdin.readline\n\ndp = [-float('inf')]\nn = int(readline())\na = (int(readline()) for _ in range(n))\nfor ai in a:\n if dp[-1] < ai:\n dp.append(ai)\n else:\n dp[bisect.bisect(dp, ai)] = ai\nprint(len(dp) - 1)", "jacc_sim": 0.9714285714285714, "nl": "Title: Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequence (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 \u2264 i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\nThe length of the longest increasing subsequence of A.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 0 \u2264 ai \u2264 10^9\n\nSample Input 1\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n3\n\nSample Input 2\n3\n1\n1\n1\n\nSample Output 2\n1", "before_after_length": [108, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02317", "p_user": "u603049633", "n_user": "u603049633", "pos": "from bisect import bisect_left\nimport sys\n\nn = int(input())\nA = [int(i.rstrip(\"\\n\")) for i in sys.stdin.readlines()]\n\ndef LIS():\n L = A[:1]\n for i in A[1:]:\n if L[-1] < i:\n L.append(i)\n else:\n j = bisect_left(L, i)\n L[j] = i\n return len(L)\n\nprint(LIS())", "neg": "from bisect import bisect_left\nimport sys\nn = int(input())\nA = [int(i.rstrip(\"\\n\")) for i in sys.stdin.readlines()]\n\ndef LIS():\n L = A[:1]\n for i in A[1:]:\n if L[-1] < i:\n L.append(i)\n else:\n L[j] = i\n return len(L)\n\nprint(LIS())", "jacc_sim": 0.9736842105263158, "nl": "Title: Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequence (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 \u2264 i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\nThe length of the longest increasing subsequence of A.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 0 \u2264 ai \u2264 10^9\n\nSample Input 1\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n3\n\nSample Input 2\n3\n1\n1\n1\n\nSample Output 2\n1", "before_after_length": [122, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02317", "p_user": "u855199458", "n_user": "u855199458", "pos": "# -*- coding: utf-8 -*-\nfrom bisect import bisect_left\nN = int(input())\nA = [int(input()) for _ in range(N)]\nL = [A[0]]\n\nfor i in range(1, N):\n if L[-1] < A[i]:\n L.append(A[i])\n else:\n L[bisect_left(L, A[i])] = A[i]\nprint(len(L))", "neg": "# -*- coding: utf-8 -*-\nfrom bisect import bisect\nN = int(input())\nA = [int(input()) for _ in range(N)]\nL = [A[0]]\n\nfor i in range(1, N):\n if L[-1] < A[i]:\n L.append(A[i])\n else:\n L[bisect(L, A[i])] = A[i]\nprint(len(L))", "jacc_sim": 0.9722222222222222, "nl": "Title: Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequence (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 \u2264 i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\nThe length of the longest increasing subsequence of A.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 0 \u2264 ai \u2264 10^9\n\nSample Input 1\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n3\n\nSample Input 2\n3\n1\n1\n1\n\nSample Output 2\n1", "before_after_length": [116, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02317", "p_user": "u947762778", "n_user": "u947762778", "pos": "import bisect\nn = int(input())\nA = []\nfor i in range(n):\n num = int(input())\n if A == []:\n A.append(num)\n elif num > A[-1]:\n A.append(num)\n else:\n j = bisect.bisect_left(A, num)\n A[j] = num\nprint(len(A))", "neg": "import bisect\nn = int(input())\nA = []\nfor i in range(n):\n num = int(input())\n if A == []:\n A.append(num)\n elif num > A[-1]:\n A.append(num)\n else:\n j = bisect.bisect_left(A, num)\n A[j] = num\nprint(len(A) - 1)", "jacc_sim": 1.0, "nl": "Title: Longest Increasing Subsequence\n\nFor a given sequence A = {a0, a1, ... , an-1}, find the length of the longest increasing subsequence (LIS) in A.\n\nAn increasing subsequence of A is defined by a subsequence {ai0, ai1, ... , aik} where 0 \u2264 i0 < i1 < ... < ik < n and ai0 < ai1 < ... < aik.\n\nInput\nn\na0\na1\n:\nan-1\n\nIn the first line, an integer n is given. In the next n lines, elements of A are given.\n\nOutput\nThe length of the longest increasing subsequence of A.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 0 \u2264 ai \u2264 10^9\n\nSample Input 1\n5\n5\n1\n3\n2\n4\n\nSample Output 1\n3\n\nSample Input 2\n3\n1\n1\n1\n\nSample Output 2\n1", "before_after_length": [97, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u896240461", "n_user": "u896240461", "pos": "s1 = input()\ns2 = input()\nx = [[0 for i in range(len(s2))]for j in range(len(s1))]\n\ndef g(i,j):\n if i == 0 or j == 0:\n if s1[i] == s2[j]:\n x[i][j] = abs(i-j)\n else:\n if i == 0:\n x[i][j] = x[i][j-1] + 1\n else:\n x[i][j] = x[i-1][j] + 1\n elif s1[i] == s2[j]:\n x[i][j] = min(x[i-1][j-1],x[i][j-1]+1,x[i-1][j]+1)\n else:\n x[i][j] = min(x[i-1][j-1]+1,x[i][j-1]+1,x[i-1][j]+1)\n \n\nfor i in range(len(s1)):\n for j in range(len(s2)):\n g(i,j)\n\nprint(x[len(s1)-1][len(s2)-1])\n", "neg": "s1 = input()\ns2 = input()\nx = [[0 for i in range(len(s2))]for j in range(len(s1))]\n\ndef g(i,j):\n if i == 0 or j == 0:\n if s1[i] == s2[j]:\n x[i][j] = abs(i-j)\n else:\n if i == 0:\n x[i][j] = x[i][j-1] + 1\n else:\n x[i][j] = x[i-1][j] + 1\n elif s1[i] == s2[j]:\n x[i][j] = x[i-1][j-1]\n else:\n x[i][j] = min(x[i][j-1] + 1,x[i-1][j] + 1)\n \n\nfor i in range(len(s1)):\n for j in range(len(s2)):\n g(i,j)\n\nprint(x[len(s1)-1][len(s2)-1])\n", "jacc_sim": 1.0, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [299, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u564105430", "n_user": "u564105430", "pos": "s1=input()\ns2=input()\nls1=len(s1)\nls2=len(s2)\nf=[[0 for j in range(ls2+1)] for i in range(ls1+1)]\nfor i in range(ls1+1):\n f[i][0]=i\nfor i in range(ls2+1):\n f[0][i]=i\nfor i in range(1,ls1+1):\n for j in range(1,ls2+1):\n if s1[i-1]!=s2[j-1]:\n f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)\n else:\n f[i][j]=f[i-1][j-1]\nprint(f[i][j])\n", "neg": "s1=input()\ns2=input()\nls1=len(s1)\nls2=len(s2)\nf=[[0 for j in range(ls2+1)] for i in range(ls1+1)]\nfor i in range(ls1+1):\n f[i][0]=i\nfor i in range(ls2+1):\n f[0][i]=i\nfor i in range(1,ls1+1):\n for j in range(1,ls2+1):\n if s1[i-1]!=s2[j-1]:\n f[i][j]=min(f[i-1][j]+1,f[i][j-1]+1,f[i-1][j-1]+1)\n else:\n f[i][j]=f[i-1][j-1]\nprint(f)\n\n", "jacc_sim": 1.0, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [218, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u909075105", "n_user": "u909075105", "pos": "def search(X,Y):\n\n n=len(X)\n m=len(Y)\n p=[i for i in range(m+1)]\n for i in range(n):\n q=list(range(m+1))\n q[0] = i+1\n for j in range(m):\n if X[i]==Y[j]:\n cost=0\n else:\n cost=1\n q[j+1]=min(p[j+1]+1,q[j]+1,p[j]+cost)\n p,q=q,p\n \n return p[m]\n\n\nX=input()\nY=input()\n\nprint(search(X,Y))\n\n", "neg": "def search(X,Y):\n\n n=len(X)\n m=len(Y)\n p=[i for i in range(m+1)]\n for i in range(n):\n q=list(range(m+1))\n q[0] = i+1\n for j in range(m):\n if X[i]==Y[j]:\n cost=0\n else:\n cost=1\n q[j+1]=min(p[j+1]+1,q[j]+1,p[j]+cost)\n p,q=q,p\n \n return pre[m]\n\n\nX=input()\nY=input()\n\nprint(search(X,Y))\n\n", "jacc_sim": 0.9696969696969697, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [171, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u209989098", "n_user": "u209989098", "pos": "a = list(input())\nb = list(input())\n\nif len(a) == 0 or len(b) == 0:\n\tprint(max(len(a),len(b)))\n\nelse:\n\tdp = [[None for i in range(len(b)+1)] for j in range(len(a)+1)]\n\tfor i in range(len(a)+1):\n\t\tdp[i][0] = i\n\tfor i in range(len(b)+1):\n\t\tdp[0][i] = i\n\n\tfor i in range(1,len(a)+1):\n\t\tfor j in range(1,len(b)+1):\n\t\t\taaa = dp[i-1][j-1] if a[i-1] == b[j-1] else dp[i-1][j-1]+1\n\t\t\tdp[i][j] = min(aaa,dp[i-1][j] + 1,dp[i][j-1]+1)\n\nprint(dp[-1][-1])\n", "neg": "a = list(input())\nb = list(input())\n\nif len(a) == 0 or len(b) == 0:\n\tprint(max(len(a),len(b)))\n\nelse:\n\tdp = [[None for i in range(len(b)+1)] for j in range(len(a)+1)]\n\tfor i in range(len(a)+1):\n\t\tdp[i][0] = i\n\tfor i in range(len(b)+1):\n\t\tdp[0][i] = i\n\n\tfor i in range(1,len(a)+1):\n\t\tfor j in range(len(b)+1):\n\t\t\taaa = dp[i-1][j-1] if a[i-1] == b[j-1] else dp[i-1][j-1]+1\n\t\t\tdp[i][j] = min(aaa,dp[i-1][j] + 1,dp[i][j-1]+1)\n\nprint(dp[-1][-1])\n", "jacc_sim": 1.0, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [244, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u473666214", "n_user": "u473666214", "pos": "s_1 = input()\ns_2 = input()\n\nmemo = [[0 for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]\nflag = [[False for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]\n\nfor i in range(1, len(s_1)+1):\n memo[i][0] = i\nfor j in range(1, len(s_2)+1):\n memo[0][j] = j\n\nfor i in range(1, len(s_1)+1):\n for j in range(1, len(s_2)+1):\n if not flag[i][j]:\n flag[i][j] = True\n if s_1[i-1] == s_2[j-1]:\n memo[i][j] = min(memo[i-1][j-1], memo[i][j-1]+1)\n memo[i][j] = min(memo[i][j], memo[i-1][j]+1)\n else:\n memo[i][j] = min(memo[i-1][j-1]+1, memo[i][j-1]+1)\n memo[i][j] = min(memo[i][j], memo[i-1][j]+1)\n\nprint(memo[len(s_1)][len(s_2)])\n\n", "neg": "s_1 = input()\ns_2 = input()\n\nmemo = [[0 for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]\nflag = [[False for i in range(len(s_2)+1)] for j in range(len(s_1) + 1)]\n\nfor i in range(1, len(s_1)+1):\n for j in range(1, len(s_2)+1):\n if not flag[i][j]:\n flag[i][j] = True\n if s_1[i-1] == s_2[j-1]:\n memo[i][j] = min(memo[i-1][j-1], memo[i][j-1]+1)\n memo[i][j] = min(memo[i][j], memo[i-1][j]+1)\n else:\n memo[i][j] = min(memo[i-1][j-1]+1, memo[i][j-1]+1)\n memo[i][j] = min(memo[i][j], memo[i-1][j]+1)\n\nprint(memo[len(s_1)][len(s_2)])\n\n# ababa\n# babab\n\n", "jacc_sim": 0.90625, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [349, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02318", "p_user": "u886122084", "n_user": "u886122084", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef leven(s1, s2):\n n1 = len(s1)\n n2 = len(s2)\n dp = [[0]*(n1+1) for _ in range(n2+1)]\n\n for i in range(1, n1+1):\n dp[0][i] = i\n for i in range(1, n2+1):\n dp[i][0] = i\n\n for j in range(1, n2+1):\n for k in range(1, n1+1):\n m = min(dp[j-1][k], dp[j][k-1])+1\n if s1[k-1] == s2[j-1]: # \u6700\u5f8c\u306e\u6587\u5b57\u524a\u9664\n m = min(m, dp[j-1][k-1])\n else:\n m = min(m, dp[j-1][k-1]+1)\n dp[j][k] = m\n print(dp[-1][-1])\n\n\ns1 = input()[:-1]\ns2 = input()[:-1]\nleven(s1, s2)\n\n", "neg": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef leven(s1, s2):\n n1 = len(s1)\n n2 = len(s2)\n dp = [[0]*(n1+1) for _ in range(n2+1)]\n\n for i in range(1, n1+1):\n dp[0][i] = i\n for i in range(1, n2+1):\n dp[i][0] = i\n\n for j in range(1, n2+1):\n for k in range(1, n1+1):\n m = min(dp[j-1][k]+1, dp[j][k-1])\n if s1[j-1] == s2[k-1]: # \u6700\u5f8c\u306e\u6587\u5b57\u524a\u9664\n m = min(m, dp[j-1][k-1])\n else:\n m = min(m, dp[j-1][k-1]+1)\n dp[j][k] = m\n print(dp[-1][-1])\n\n\ns1 = input()[:-1]\ns2 = input()[:-1]\nleven(s1, s2)\n\n", "jacc_sim": 1.0, "nl": "Title: Edit Distance (Levenshtein Distance)\n\nFind the edit distance between two given words s1 and s2. The distance is the minimum number of single-character edits required to change one word into the other. Edits include insertion, deletion, and substitution of characters.\n\nInput:\ns1\ns2\n\nTwo words s1 and s2 are given in the first and second lines respectively. The words consist of lowercase characters.\n\nOutput:\nPrint the edit distance in a line.\n\nConstraints:\n- 1 \u2264 length of s1 \u2264 1000\n- 1 \u2264 length of s2 \u2264 1000\n\nSample Input 1:\nacac\nacm\n\nSample Output 1:\n2\n\nSample Input 2:\nicpc\nicpc\n\nSample Output 2:\n0", "before_after_length": [327, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02319", "p_user": "u197615397", "n_user": "u209989098", "pos": "N, W = map(int, input().split())\ndp = [0] + [W+1] * (N*100)\nfor i in range(N):\n v, w = map(int, input().split())\n for j in range(i*100, -1, -1):\n if dp[j+v] > dp[j] + w:\n dp[j+v] = dp[j] + w\n\nfor v, w in zip(range(N*100, -1, -1), dp[::-1]):\n if w < W+1:\n print(v)\n break", "neg": "N, W = map(int, input().split())\ndp = [0] + [W+1] * (N*100)\nfor i in range(N):\n x, y = map(int, input().split())\n for j in range(i*100, -1, -1):\n if dp[j+y] > dp[j] + x:\n dp[j+y] = dp[j] + x\n\nfor v, w in zip(range(N*100, -1, -1), dp[::-1]):\n if w < W+1:\n print(v)\n break\n", "jacc_sim": 0.9444444444444444, "nl": "0-1 Knapsack Problem II\n\nYou have N items that you want to put into a knapsack. Item i has value vi and weight wi. Find a subset of items to put such that the total value is maximized and the combined weight is at most W (capacity of the knapsack). Output the maximum total value of items in the knapsack.\n\nInput\nN W\nv1 w1\nv2 w2\n...\nvN wN\n\nOutput\nPrint the maximum total value of the items in a line.\n\nConstraints\n1 \u2264 N \u2264 100\n1 \u2264 vi \u2264 100\n1 \u2264 wi \u2264 10,000,000\n1 \u2264 W \u2264 1,000,000,000\n\nSample Input 1\n4 5\n4 2\n5 2\n2 1\n8 3\n\nSample Output 1\n13\n\nSample Input 2\n2 20\n5 9\n4 10\n\nSample Output 2\n9", "before_after_length": [147, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u022407960", "n_user": "u022407960", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ninput:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\noutput:\n4\n\"\"\"\nimport sys\n\n\ndef solve():\n dp = [[0] * (W + 1) for _ in range(H + 1)]\n\n for i in range(H):\n for j in range(W):\n if not int(carpet_info[i][j]):\n dp[i + 1][j + 1] = min(dp[i][j], dp[i][j + 1], dp[i + 1][j]) + 1\n\n max_width = max(map(max, dp))\n return pow(max_width, 2)\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n H, W = map(int, _input[0].split())\n carpet_info = list(map(lambda x: x.split(), _input[1:]))\n print(solve())", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ninput:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\noutput:\n4\n\"\"\"\nimport sys\n\n\ndef solve():\n dp = [[0] * W for _ in range(H)]\n max_width = 0\n\n # for m in range(H):\n # for n in range(W):\n # print(m, n, carpet_info[m][n])\n # dp[m][n] = (int(carpet_info[m][n]) + 1) % 2\n # max_width |= dp[m][n]\n\n for i in range(1, H):\n for j in range(1, W):\n if not int(carpet_info[i][j]):\n dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1\n max_width = max(max_width, dp[i][j])\n\n return max_width\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n H, W = map(int, _input[0].split())\n carpet_info = list(map(lambda x: x.split(), _input[1:]))\n print(solve())", "jacc_sim": 0.9242424242424242, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [265, 352], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u837811962", "n_user": "u837811962", "pos": "H,W = map(int,input().split())\ntile = [[0 for i in range(W)] for i in range(H)]\nbuf = [[0 for i in range(W+1)] for i in range(H+1)]\nmaxsquare = 0\n\nfor i in range(H):\n tile[i] = list(map(int,input().split()))\n\nfor i in range(1,H+1):\n for j in range(1,W+1):\n if tile[i-1][j-1]!=1:\n buf[i][j] = min(buf[i-1][j],buf[i][j-1],buf[i-1][j-1]) + 1\n\n if buf[i][j] > maxsquare:\n maxsquare = buf[i][j]\n\nprint(maxsquare**2)", "neg": "H,W = map(int,input().split())\ntile = [[0 for i in range(W)] for i in range(H)]\nbuf = [[1 for i in range(W)] for i in range(H)]\nmaxsquare = 0\n\nfor i in range(H):\n tile[i] = list(map(int,input().split()))\n\nfor i in range(1,H):\n for j in range(1,W):\n if tile[i][j]!=1:\n if tile[i-1][j]==1 or tile[i][j-1]==1 or tile[i-1][j-1]==1:\n buf[i][j] = 1\n elif tile[i-1][j]==tile[i][j-1]:\n buf[i][j] = buf[i-1][j-1]+1\n else:\n buf[i][j] = min(buf[i-1][j] , buf[i][j-1])+1\n\n if buf[i][j] > maxsquare:\n maxsquare = buf[i][j]\n\nfor i in buf:\n print(i)\n\nprint(maxsquare**2)", "jacc_sim": 0.918918918918919, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [202, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u426534722", "n_user": "u426534722", "pos": "import sys\nimport itertools\nh, w = map(int, sys.stdin.readline().split())\ndp = [[0] * w for _ in range(h)]\nG = [[int(j) for j in sys.stdin.readline().split()] for _ in range(h)]\nfor x in range(h):\n dp[x][0] = 1 if G[x][0] == 0 else 0\nfor y in range(w):\n dp[0][y] = 1 if G[0][y] == 0 else 0\nfor i in range(1, h):\n for j in range(1, w):\n if(G[i][j] == 0):\n dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1\nprint(max(max(i) for i in dp) ** 2)", "neg": "import sys\nh, w = map(int, sys.stdin.readline().split())\ndp = [[0] * w for _ in range(h)]\nG = [list(map(int, i.split())) for i in sys.stdin.readlines()]\nfor x in range(h):\n dp[x][0] = 1 if G[x][0] == 0 else 0\nfor y in range(w):\n dp[0][y] = 1 if G[0][y] == 0 else 0\nfor i in range(1, h):\n for j in range(1, w):\n if(G[i][j] == 0):\n dp[i][j] = min(dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]) + 1\nprint(max(sum(dp, []) ** 2))", "jacc_sim": 0.9047619047619048, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [214, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u736039489", "n_user": "u736039489", "pos": "# -*- coding: utf-8 -*-\n'''\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_A&lang=jp\n???????\u00a8???????\n?????\u00a7??\u00a3?????\u00a2\n'''\n\nH, W = map(int, input().split())\nC = list()\nmaxWidth = 0\n\nfor h in range(H):\n C.append(list(map(int, input().split())))\n\ndp = dict()\nfor h in range(H+1):\n dp[(h, 0)] = 0\n\nfor w in range(W+1):\n dp[(0, w)] = 0\n\nfor h in range(1, H+1):\n for w in range(1, W+1):\n if C[h-1][w-1] == 1:\n dp[(h, w)] = 0\n else:\n dp[(h, w)] = min(dp[(h-1, w-1)], dp[(h-1, w)], dp[(h, w-1)]) + 1\n maxWidth = max(dp[(h, w)], maxWidth)\n\nprint(maxWidth**2)", "neg": "# -*- coding: utf-8 -*-\n'''\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_A&lang=jp\n???????\u00a8???????\n?????\u00a7??\u00a3?????\u00a2\n'''\n\nH, W = map(int, input().split())\nC = list()\nmaxWidth = 0\n\nfor h in range(H):\n C.append(list(map(int, input().split())))\n\ndp = dict()\nfor h in range(H+1):\n dp[(h, 0)] = 0\n\nfor w in range(W+1):\n dp[(0, w)] = 0\n\nfor h in range(1, H+1):\n for w in range(1, W+1):\n if C[h-1][w-1] == 1:\n dp[(h, w)] = 0\n else:\n dp[(h, w)] = min(dp[(h-1, w-1)], dp[(h-1, w)], dp[(h, w-1)]) + 1\n maxWidth = max(dp[(h, w)], maxWidth)\n\nprint(maxWidth)", "jacc_sim": 0.9833333333333333, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [304, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u352394527", "n_user": "u352394527", "pos": "h, w = map(int, input().split())\nmp = []\nfor _ in range(h):\n lst = list(map(int, input().split()))\n cum = []\n acc = 0\n for i in lst:\n if i == 0:\n acc += 1\n else:\n acc = 0\n cum.append(acc)\n mp.append(cum)\nmp.append([-1] * w)\n\nans = 0\nfor x in range(w):\n score_stack = []\n ind_stack = []\n for y in range(h + 1):\n# print(score_stack, ind_stack)\n score = mp[y][x]\n if score_stack == []:\n score_stack.append(score)\n ind_stack.append(y)\n else:\n last_score = score_stack[-1]\n if last_score < score:\n score_stack.append(score)\n ind_stack.append(y)\n\n elif last_score == score:\n continue\n\n else:\n while score_stack != [] and score_stack[-1] >= score:\n last_score = score_stack.pop()\n last_ind = ind_stack.pop()\n# print(last_score, last_ind, ans)\n ans = max(ans, min(y - last_ind, last_score) ** 2)\n \n score_stack.append(score)\n ind_stack.append(last_ind)\nprint(ans)\n\n", "neg": "h, w = map(int, input().split())\nmp = []\nfor _ in range(h):\n lst = list(map(int, input().split()))\n cum = []\n acc = 0\n for i in lst:\n if i == 0:\n acc += 1\n else:\n acc = 0\n cum.append(acc)\n mp.append(cum)\nmp.append([-1] * w)\n\nans = 0\nfor x in range(w - 1, -1, -1):\n score_stack = []\n ind_stack = []\n for y in range(h + 1):\n# print(score_stack, ind_stack)\n score = mp[y][x]\n if score_stack == []:\n score_stack.append(score)\n ind_stack.append(y)\n else:\n last_score = score_stack[-1]\n if last_score < score:\n score_stack.append(score)\n ind_stack.append(y)\n\n elif last_score == score:\n continue\n\n else:\n while score_stack != [] and score_stack[-1] >= score:\n last_score = score_stack.pop()\n last_ind = ind_stack.pop()\n ans = max(ans, min(y - last_ind, (last_score - score)) ** 2)\n \n score_stack.append(score)\n ind_stack.append(last_ind)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [368, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02326", "p_user": "u519227872", "n_user": "u519227872", "pos": "H, W = map(int, input().split())\nc = []\n\nfor i in range(H):\n c.append([int(i) for i in input().split()])\ndp = [[0 for i in range(W)] for i in range(H)]\n\nmaxwidth = 0\n\nfor i in range(H):\n for j in range(W):\n dp[i][j] = (c[i][j] + 1) % 2\n maxwidth |= dp[i][j]\n\nfor i in range(1, H):\n for j in range(1, W):\n if c[i][j]:\n continue\n else:\n dp[i][j] = min(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) + 1\n maxwidth = max(maxwidth, dp[i][j])\n\nprint(maxwidth**2)\n", "neg": "H, W = map(int, input().split())\nc = []\nfor i in range(H):\n c.append([int(i) for i in input().split()])\ndp = [[0 for i in range(W)] for i in range(H)]\nmaxwidth = 0\nfor i in range(H):\n for j in range(W):\n dp[i][j] = (c[i][j] + 1) % 2\n maxwidth |= dp[i][j]\n\nfor i in range(1, H):\n for j in range(1, W):\n dp[i][j] = min(dp[i-1][j], dp[i-1][j-1], dp[i][j-1]) + 1\n maxwidth = max(maxwidth,dp[i][j])\n\nprint(maxwidth**2)\n", "jacc_sim": 0.918918918918919, "nl": "Title: Largest Square\n\nGiven a matrix (H x W) containing only 1s and 0s, find the area of the largest square matrix containing only 0s.\n\nInput:\nH W\nc1,1 c1,2 ... c1,W\nc2,1 c2,2 ... c2,W\n...\ncH,1 cH,2 ... cH,W\n\nIn the first line, two integers H and W separated by a space are given. In the following H lines, elements of the H x W matrix are given.\n\nOutput:\nPrint the area (number of 0s) of the largest square.\n\nConstraints:\n1 <= H, W <= 1,400\n\nSample Input:\n4 5\n0 0 1 0 0\n1 0 0 0 0\n0 0 0 1 0\n0 0 0 1 0\n\nSample Output:\n4", "before_after_length": [221, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02328", "p_user": "u260980560", "n_user": "u260980560", "pos": "N = int(input())\n*H, = map(int, input().split())\nst = [(0, -1)]\nans = 0\nfor i in range(N):\n h = H[i]\n base = i\n while st and h <= st[-1][0]:\n h0, j = st.pop()\n ans = max(ans, (i-j)*h0)\n base = j\n st.append((h, base))\nwhile st:\n h0, j = st.pop()\n ans = max(ans, (N-j)*h0)\nprint(ans)", "neg": "N = int(input())\n*H, = map(int, input().split())\nst = [(0, -1)]\nans = 0\nfor i in range(N):\n h = H[i]\n base = i\n while h <= st[-1][0]:\n h0, j = st.pop()\n ans = max(ans, (i-j)*h0)\n base = j\n st.append((h, base))\nwhile st:\n h0, j = st.pop()\n ans = max(ans, (N-j)*h0)\nprint(ans)", "jacc_sim": 0.9714285714285714, "nl": "Title: Largest Rectangle in a Histogram\n\nA histogram consists of a series of adjacent bars, all with the same width.\n\nGiven a histogram with N bars, each having a width of 1 and heights h1, h2, ..., hN, find the area of the largest rectangular shape that can be formed within the histogram.\n\nConstraints:\n- 1 \u2264 N \u2264 10^5\n- 0 \u2264 hi \u2264 10^9\n\nInput:\nThe input is provided in the following format:\nN\nh1 h2 ... hN\n\nOutput:\nPrint the area of the largest rectangle.\n\nSample Input 1:\n8\n2 1 3 5 3 4 2 1\n\nSample Output 1:\n12\n\nSample Input 2:\n3\n2 0 1\n\nSample Output 2:\n2", "before_after_length": [145, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02343", "p_user": "u893844544", "n_user": "u893844544", "pos": "n, nq = map(int, input().split())\nset_list = list(range(n))\n\ndef find(n):\n global set_list\n if set_list[n] == n:\n return n\n result = set_list[n] = find(set_list[n])\n return result\n\ndef same(x, y):\n set_list[find(y)] = find(x)\n\ndef unite(x, y):\n return find(x) == find(y)\n\nfor _ in range(nq):\n com,x,y = map(int, input().split())\n if com == 0:\n same(x, y)\n else:\n if unite(x, y):\n print(1)\n else:\n print(0)\n\n", "neg": "n, nq = map(int, input().split())\nset_list = list(range(n))\n\ndef find(n):\n global set_list\n if set_list[n] == n:\n return n\n result = set_list[n] = find(set_list[n])\n return result\n\ndef same(x, y):\n set_list[find(y)] = find(x)\n\ndef unite(x, y):\n return find(x) == find(y)\n\nfor _ in range(nq):\n com,x,y = map(int, input().split())\n if com == 0:\n same(x, y)\n else:\n if unite(x, y):\n print(0)\n else:\n print(1)\n\n", "jacc_sim": 1.0, "nl": "Disjoint Set\n\nWrite a program to manipulate a disjoint set S = {S1, S2, . . . , Sk}. Initially, create a disjoint set where each element consists of 0, 1, ... n-1 respectively.\n\nThen, the program should handle q queries. Two types of queries are allowed:\n- unite(x, y): Unite sets containing x and y into a new set.\n- same(x, y): Determine if x and y are in the same set.\n\nInput:\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nOutput:\nFor each same operation, print 1 if x and y are in the same set, otherwise 0.\n\nConstraints:\n1 \u2264 n \u2264 10000\n1 \u2264 q \u2264 100000\nx \u2260 y\n\nSample Input:\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output:\n0\n0\n1\n1\n1\n0\n1\n1", "before_after_length": [195, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02343", "p_user": "u528682978", "n_user": "u089116225", "pos": "def root(x):\n path_to_root = []\n while x != P[x]:\n path_to_root.append(x)\n x = P[x]\n for node in path_to_root:\n P[node]=x\n return x\n\ndef unite(x,y):\n P[root(x)] = root(y)\n\ndef is_same_set(x,y):\n return root(x) == root(y)\n\nn,q = map(int,input().split())\nP = [i for i in range(n)]\nfor _ in range(q):\n com,x,y=map(int,input().split())\n if com == 0:\n unite(x,y)\n else:\n if is_same_set(x,y):\n print(1)\n else:\n print(0)\n", "neg": "n,q = map(int, input().split())\n\nroot_list = [i for i in range(n)]\n\ndef root(x):\n path_to_root = []\n while root_list[x] != x:\n path_to_root.append(x):\n x = root_list[x]\n for node in path_to_root:\n root_list[node] = x\n return x\n\ndef is_same_set(x,y):\n return root(x) == root(y)\n\ndef unite(x,y):\n root_list[root(x)] = root(y)\n\nfor _ in range(q):\n com, x, y = map(int, input().split())\n if com == 0:\n #unite\n unite(x,y)\n else:\n if is_same_set(x,y):\n print(1)\n else:\n print(0)\n", "jacc_sim": 0.925, "nl": "Disjoint Set\n\nWrite a program to manipulate a disjoint set S = {S1, S2, . . . , Sk}. Initially, create a disjoint set where each element consists of 0, 1, ... n-1 respectively.\n\nThen, the program should handle q queries. Two types of queries are allowed:\n- unite(x, y): Unite sets containing x and y into a new set.\n- same(x, y): Determine if x and y are in the same set.\n\nInput:\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nOutput:\nFor each same operation, print 1 if x and y are in the same set, otherwise 0.\n\nConstraints:\n1 \u2264 n \u2264 10000\n1 \u2264 q \u2264 100000\nx \u2260 y\n\nSample Input:\n5 12\n0 1 4\n0 2 3\n1 1 2\n1 3 4\n1 1 4\n1 3 2\n0 1 3\n1 2 4\n1 3 0\n0 0 4\n1 0 2\n1 3 0\n\nSample Output:\n0\n0\n1\n1\n1\n0\n1\n1", "before_after_length": [214, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02345", "p_user": "u798803522", "n_user": "u798803522", "pos": "import math\n\ndef update(index,n):\n targ[index] = n\n index = (index - 1) // 2\n while True:\n targ[index] = min(targ[index * 2 + 1],targ[index * 2 + 2])\n if index <= 0:\n break\n index = (index - 1) // 2\n\ndef find(i,e,node,inode,enode):\n #print(i,e,node,inode,enode)\n if inode > e or enode < i:\n return float(\"inf\")\n elif (i <= inode and enode <= e) or inode==enode:\n return targ[node]\n\n else:\n irange = find(i,e,2*node + 1,inode,(inode+enode)// 2 )\n erange = find(i,e,2*node + 2,(inode+enode)//2 + 1,enode)\n return min(irange,erange)\n\nnum,query = (int(n) for n in input().split(' '))\ninitial = 2147483647\nln = 2 ** math.ceil(math.log2(num)) - 1\nif num == 1:\n tail = 2\nelse:\n tail = 2 ** math.ceil(math.log2(num)) - num\nglobal targ\ntarg = [initial] * (ln + num + tail)\n\nfor q in range(query):\n #print(targ)\n temp = [int(n) for n in input().split(' ') ]\n if temp[0] == 0:\n update(temp[1] + ln,temp[2])\n else:\n print(find(temp[1],temp[2],0,0,ln))", "neg": "import math\n\ndef update(index,n):\n targ[index] = n\n index = (index - 1) // 2\n while True:\n targ[index] = min(targ[index * 2],targ[index * 2 + 1])\n if index <= 0:\n break\n index = (index - 1) // 2\n\ndef find(i,e,node,inode,enode):\n #print(i,e,node,inode,enode)\n if inode > e or enode < i:\n return float(\"inf\")\n elif (i <= inode and enode <= e) or inode==enode:\n return targ[node]\n\n else:\n irange = find(i,e,2*node + 1,inode,(inode+enode)// 2 )\n erange = find(i,e,2*node + 2,(inode+enode)//2 + 1,enode)\n return min(irange,erange)\n\nnum,query = (int(n) for n in input().split(' '))\ninitial = 2147483647\nln = 2 ** math.ceil(math.log2(num)) - 1\nglobal targ\ntarg = [initial] * (ln + num)\nlength = num - 1\n\nfor q in range(query):\n #print(targ)\n temp = [int(n) for n in input().split(' ') ]\n if temp[0] == 0:\n update(temp[1] + ln,temp[2])\n else:\n print(find(temp[1],temp[2],0,0,length))", "jacc_sim": 0.9692307692307692, "nl": "Range Minimum Query (RMQ)\n\nWrite a program to manipulate a sequence A = {a0, a1, ..., an-1} with the following operations:\n- find(s, t): report the minimum element in as, as+1, ..., at.\n- update(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, ..., n-1) are 2^31-1.\n\nInput\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq-1 xq-1 yq-1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\nFor each find operation, print the minimum element.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 0 \u2264 xi < n, 0 \u2264 yi < 2^31-1.\n- If comi is 1, then 0 \u2264 xi < n, 0 \u2264 yi < n.\n\nSample Input 1\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n1\n2\n\nSample Input 2\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n2147483647\n5", "before_after_length": [415, 383], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02345", "p_user": "u798803522", "n_user": "u798803522", "pos": "class RMQ:\n def __init__(self, length, ini_num = float(\"inf\")):\n self.length = 1\n self.ini_num = ini_num\n while self.length < length:\n self.length <<= 1\n self.segtree = [ini_num] * (2 * self.length - 1)\n\n def update(self, index, n):\n leaf_index = index + self.length - 1\n self.segtree[leaf_index] = n\n while leaf_index > 0:\n leaf_index = (leaf_index - 1) // 2\n self.segtree[leaf_index] = min(self.segtree[leaf_index * 2 + 1], self.segtree[leaf_index * 2 + 2])\n\n def find(self, a, b, index, l, r):\n if a <= l <= r <= b:\n return self.segtree[index]\n elif b < l or r < a:\n return self.ini_num\n else:\n return min(self.find(a, b, index * 2 + 1, l, (l + r) // 2), self.find(a, b, index * 2 + 2, (l + r) // 2 + 1, r))\n\nv_num, query = map(int, input().split(\" \"))\nrmq = RMQ(v_num, 2147483647)\nfor _ in [0] * query:\n com, i, n = map(int, input().split(\" \"))\n if com == 0:\n rmq.update(i, n)\n else:\n print(rmq.find(i, n, 0, 0, rmq.length - 1))", "neg": "class RMQ:\n def __init__(self, length, ini_num = float(\"inf\")):\n self.length = 1\n while self.length < length:\n self.length <<= 1\n self.segtree = [ini_num] * (2 * self.length - 1)\n\n def update(self, index, n):\n leaf_index = index + self.length - 1\n self.segtree[leaf_index] = n\n while leaf_index > 0:\n leaf_index = (leaf_index - 1) // 2\n self.segtree[leaf_index] = min(self.segtree[leaf_index * 2 + 1], self.segtree[leaf_index * 2 + 2])\n\n def find(self, a, b, index, l, r):\n if a == b:\n return self.segtree[self.length - 1 + a] \n elif a <= l <= r <= b:\n return self.segtree[index]\n elif b <= l or r <= a:\n return float(\"inf\")\n else:\n return min(self.find(a, b, index * 2 + 1, l, (l + r) // 2), self.find(a, b, index * 2 + 2, (l + r) // 2, r))\n\nv_num, query = (int(n) for n in input().split(\" \"))\nrmq = RMQ(v_num, 2147483647)\nfor _ in range(query):\n com, i, n = (int(n) for n in input().split(\" \") )\n if com == 0:\n rmq.update(i, n)\n else:\n print(rmq.find(i, n, 0, 0, rmq.length - 1))", "jacc_sim": 0.9661016949152542, "nl": "Range Minimum Query (RMQ)\n\nWrite a program to manipulate a sequence A = {a0, a1, ..., an-1} with the following operations:\n- find(s, t): report the minimum element in as, as+1, ..., at.\n- update(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, ..., n-1) are 2^31-1.\n\nInput\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq-1 xq-1 yq-1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\nFor each find operation, print the minimum element.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 0 \u2264 xi < n, 0 \u2264 yi < 2^31-1.\n- If comi is 1, then 0 \u2264 xi < n, 0 \u2264 yi < n.\n\nSample Input 1\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n1\n2\n\nSample Input 2\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n2147483647\n5", "before_after_length": [407, 422], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02345", "p_user": "u167493070", "n_user": "u167493070", "pos": "import sys;\n\ndef init(n_):\n length = 1;\n while(length < n_):\n length*=2\n element=[0]*(2*length-1)\n for i in range(2*length-1):\n element[i] = initial\n return element,length\n\ndef update(k,a,element):\n k+=n-1\n element[k]=a\n while(k > 0):\n k = (int)((k-1)/2)\n element[k] = min(element[k*2+1],element[k*2+2])\n\ndef findmin(a, b):\n return findquery(a,b+1,0,0,n)\n\ndef findquery(a, b, k, l, r):\n if(r <= a or b <= l):\n return initial\n if(a <= l and r <= b):\n return element[k]\n\n vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))\n vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)\n return min(vl,vr)\n\nn,q = map(int, input().split());\n\ninitial = pow(2,31)-1\nelement,n = init(n)\n\nfor i in range(q):\n query,key,value = map(int, input().split());\n if(query == 0):\n update(key,value,element)\n else :\n print(findmin(key,value))\n", "neg": "import sys;\n\ndef init(n_):\n length = 1;\n while(length < n_):\n length*=2\n element=[0]*(2*length-1)\n for i in range(2*length-1):\n element[i] = initial\n return element\n\ndef update(k,a,element):\n k+=n\n element[k]=a\n while(k > 0):\n k = (int)((k-1)/2)\n element[k] = min(element[k*2+1],element[k*2+2])\n\ndef findmin(a, b):\n return findquery(a,b+1,0,0,n)\n\ndef findquery(a, b, k, l, r):\n if(r <= a or b <= l):\n return initial\n if(a <= l and r <= b):\n return element[k]\n\n vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))\n vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)\n return min(vl,vr)\n\nn,q = map(int, input().split());\n\ninitial = pow(2,31)-1\nelement = init(n)\n\nfor i in range(q):\n query,key,value = map(int, input().split());\n if(query == 0):\n update(key,value,element)\n else :\n print(findmin(key,value))\n", "jacc_sim": 1.0, "nl": "Range Minimum Query (RMQ)\n\nWrite a program to manipulate a sequence A = {a0, a1, ..., an-1} with the following operations:\n- find(s, t): report the minimum element in as, as+1, ..., at.\n- update(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, ..., n-1) are 2^31-1.\n\nInput\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq-1 xq-1 yq-1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\nFor each find operation, print the minimum element.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 0 \u2264 xi < n, 0 \u2264 yi < 2^31-1.\n- If comi is 1, then 0 \u2264 xi < n, 0 \u2264 yi < n.\n\nSample Input 1\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n1\n2\n\nSample Input 2\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n2147483647\n5", "before_after_length": [390, 384], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02345", "p_user": "u408284582", "n_user": "u408284582", "pos": "import sys\nsys.setrecursionlimit(10000)\n\n\ndef initRMQ(n, D):\n n_ = 1\n\n while n_ < n:\n n_ *= 2\n\n for i in range(2*n_ - 1):\n D.append(2147483647)\n\n return n_\n\n\ndef update(k, a):\n k += n_ - 1\n D[k] = a\n while k > 0:\n k = int((k - 1) / 2)\n D[k] = min(D[k*2 + 1], D[k*2 + 2])\n\n\ndef findMin(a, b):\n return query(a, b + 1, 0, 0, n_)\n\n\ndef query(a, b, k, l, r):\n #print('q', a, b, k, l, r)\n if r <= a or b <= l:\n return 2147483647\n\n if a <= l and r <= b:\n return D[k]\n\n vl = query(a, b, k*2 + 1, l, int((l + r)/2))\n vr = query(a, b, k*2 + 2, int((l + r)/2), r)\n\n return min(vl, vr)\n\n\nif __name__ == '__main__':\n n, q = map(int, input().split())\n\n D = []\n n_ = initRMQ(n, D)\n\n for _ in range(q):\n #print(D)\n c, x, y = map(int, input().split())\n\n if c == 0:\n update(x, y)\n\n else :\n print(findMin(x, y))\n\n", "neg": "import sys\nsys.setrecursionlimit(10000)\n\n\ndef initRMQ(n, D):\n n_ = 1\n\n while n_ < n:\n n_ *= 2\n\n for i in range(2*n_ - 1):\n D.append(2147483647)\n\n return n_\n\n\ndef update(k, a):\n k += n_ - 1\n D[k] = a\n while k > 0:\n k = int((k - 1) / 2)\n D[k] = min(D[k*2 + 1], D[k*2 + 2])\n\n\ndef findMin(a, b):\n return query(a, b + 1, 0, 0, n)\n\n\ndef query(a, b, k, l, r):\n #print('q', a, b, k, l, r)\n if r <= a or b <= l:\n return 2147483647\n\n if a <= l and r <= b:\n return D[k]\n\n vl = query(a, b, k*2 + 1, l, int((l + r)/2))\n vr = query(a, b, k*2 + 2, int((l + r)/2), r)\n\n return min(vl, vr)\n\n\nif __name__ == '__main__':\n n, q = map(int, input().split())\n\n D = []\n n_ = initRMQ(n, D)\n\n for _ in range(q):\n #print(D)\n c, x, y = map(int, input().split())\n\n if c == 0:\n update(x, y)\n\n else :\n print(findMin(x, y))\n\n", "jacc_sim": 1.0, "nl": "Range Minimum Query (RMQ)\n\nWrite a program to manipulate a sequence A = {a0, a1, ..., an-1} with the following operations:\n- find(s, t): report the minimum element in as, as+1, ..., at.\n- update(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, ..., n-1) are 2^31-1.\n\nInput\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq-1 xq-1 yq-1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\nFor each find operation, print the minimum element.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 0 \u2264 xi < n, 0 \u2264 yi < 2^31-1.\n- If comi is 1, then 0 \u2264 xi < n, 0 \u2264 yi < n.\n\nSample Input 1\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n1\n2\n\nSample Input 2\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n2147483647\n5", "before_after_length": [420, 419], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02345", "p_user": "u134812425", "n_user": "u134812425", "pos": "import bisect\nimport collections\nimport heapq\nimport itertools\nimport operator\nimport sys\n\n\ndef main():\n int_max = 2 ** 31 - 1\n n, q = map(int, sys.stdin.readline().split())\n n = 1 << (n - 1).bit_length()\n dat = [int_max] * 131072 * 2\n\n def update(i, x):\n i += n - 1\n dat[i] = x\n while i > 0:\n i = (i - 1) // 2\n dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2])\n\n def query(a, b, k, l, r):\n if r <= a or b <= l:\n return int_max\n if a <= l and r <= b:\n return dat[k]\n else:\n vl = query(a, b, k * 2 + 1, l, (l + r) // 2)\n vr = query(a, b, k * 2 + 2, (l + r) // 2, r)\n return min(vl, vr)\n\n for _ in range(q):\n com, x, y = map(int, sys.stdin.readline().split())\n if com == 0:\n update(x, y)\n elif com == 1:\n print(query(x, y + 1, 0, 0, n))\n\n\nif __name__ == \"__main__\":\n main()\n\n", "neg": "import bisect\nimport collections\nimport heapq\nimport itertools\nimport operator\nimport sys\n\n\ndef main():\n int_max = 2 ** 31 - 1\n n, q = map(int, sys.stdin.readline().split())\n dat = [int_max] * 131072 * 2\n\n def update(i, x):\n i += n - 1\n dat[i] = x\n while i > 0:\n i = (i - 1) // 2\n dat[i] = min(dat[i * 2 + 1], dat[i * 2 + 2])\n\n def query(a, b, k, l, r):\n if r <= a or b <= l:\n return int_max\n if a <= l and r <= b:\n return dat[k]\n else:\n vl = query(a, b, k * 2 + 1, l, (l + r) // 2)\n vr = query(a, b, k * 2 + 2, (l + r) // 2, r)\n return min(vl, vr)\n\n for _ in range(q):\n com, x, y = map(int, sys.stdin.readline().split())\n if com == 0:\n update(x, y)\n elif com == 1:\n print(query(x, y + 1, 0, 0, n))\n\n\nif __name__ == \"__main__\":\n main()\n\n", "jacc_sim": 0.9850746268656716, "nl": "Range Minimum Query (RMQ)\n\nWrite a program to manipulate a sequence A = {a0, a1, ..., an-1} with the following operations:\n- find(s, t): report the minimum element in as, as+1, ..., at.\n- update(i, x): change ai to x.\n\nNote that the initial values of ai (i = 0, 1, ..., n-1) are 2^31-1.\n\nInput\nn q\ncom0 x0 y0\ncom1 x1 y1\n...\ncomq-1 xq-1 yq-1\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes update(xi, yi) and '1' denotes find(xi, yi).\n\nOutput\nFor each find operation, print the minimum element.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 0 \u2264 xi < n, 0 \u2264 yi < 2^31-1.\n- If comi is 1, then 0 \u2264 xi < n, 0 \u2264 yi < n.\n\nSample Input 1\n3 5\n0 0 1\n0 1 2\n0 2 3\n1 0 2\n1 1 2\n\nSample Output 1\n1\n2\n\nSample Input 2\n1 3\n1 0 0\n0 0 5\n1 0 0\n\nSample Output 2\n2147483647\n5", "before_after_length": [357, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02346", "p_user": "u167493070", "n_user": "u167493070", "pos": "import sys;\n\ndef init(n_):\n length = 1;\n while(length < n_):\n length*=2\n element = [0]*(2*length-1)\n for i in range(2*length-1):\n element[i] = 0\n return element,length\n\ndef update(k,a,element):\n k+=n-1\n element[k]+=a\n while(k > 0):\n k = (int)((k-1)/2)\n element[k] = element[k*2+1]+element[k*2+2]\n\ndef findmin(a, b):\n return findquery(a,b+1,0,0,n)\n\ndef findquery(a, b, k, l, r):\n if(r <= a or b <= l):\n return 0\n if(a <= l and r <= b):\n return element[k]\n\n vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))\n vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)\n return vl+vr\n\nn,q = map(int, input().split());\n\nelement,n = init(n)\n\nfor i in range(q):\n query,key,value = map(int, input().split());\n if(query == 0):\n update(key-1,value,element)\n else :\n print(findmin(key-1,value-1))\n", "neg": "import sys;\n\ndef init(n_):\n length = 1;\n while(length < n_):\n length*=2\n length2 = (2*length-2)\n if(length2 == 0):\n length2 = 1\n element=[0]*length2\n for i in range(length2):\n element[i] = 0\n return element,length\n\ndef update(k,a,element):\n k+=n-1\n if(n == 1):\n k = 0\n element[k]+=a\n while(k > 0):\n k = (int)((k-1)/2)\n element[k] = element[k*2+1]+element[k*2+2]\n\ndef findmin(a, b):\n return findquery(a,b+1,0,0,n)\n\ndef findquery(a, b, k, l, r):\n if(r <= a or b <= l):\n return 0\n if(a <= l and r <= b):\n return element[k]\n\n vl = findquery(a,b,k*2+1,l,(int)((l+r)/2+0.5))\n vr = findquery(a,b,k*2+2,(int)((l+r)/2),r)\n return vl+vr\n\nn,q = map(int, input().split());\n\nelement,n = init(n)\n\nfor i in range(q):\n query,key,value = map(int, input().split());\n if(query == 0):\n update(key,value,element)\n else :\n if(n==1):\n key = 0\n print(findmin(key,value))\n", "jacc_sim": 0.9824561403508771, "nl": "Range Sum Query\n\nWrite a program to manipulate a sequence A = {a1, a2, ..., an} with the following operations:\n- add(i, x): add x to ai.\n- getSum(s, t): print the sum of as, as+1, ..., at.\n\nNote that the initial values of ai (i = 1, 2, ..., n) are 0.\n\nInput\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\nFor each getSum operation, print the sum in a line.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 1 \u2264 xi \u2264 n, 0 \u2264 yi \u2264 1000.\n- If comi is 1, then 1 \u2264 xi \u2264 n, 1 \u2264 yi \u2264 n.\n\nSample Input 1\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n3\n2", "before_after_length": [382, 420], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02346", "p_user": "u408284582", "n_user": "u408284582", "pos": "import sys\nsys.setrecursionlimit(10000)\n\n\ndef initRMQ(n):\n n_ = 1\n\n while n_ < n:\n n_ *= 2\n\n D = []\n for _ in range(2*n_ - 1):\n D.append(0)\n\n return n_, D\n\n\ndef update(k, a):\n k += n_ - 1\n D[k] += a\n while k > 0:\n k = int((k - 1) / 2)\n D[k] = D[k*2 + 1] + D[k*2 + 2]\n\n\ndef findSum(a, b):\n return query(a, b + 1, 0, 0, n_)\n\n\ndef query(a, b, k, l, r):\n #print('q', a, b, k, l, r)\n if r <= a or b <= l:\n return 0\n\n if a <= l and r <= b:\n return D[k]\n\n vl = query(a, b, k*2 + 1, l, int((l + r)/2))\n vr = query(a, b, k*2 + 2, int((l + r)/2), r)\n\n return vl + vr\n\n\nif __name__ == '__main__':\n n, q = map(int, input().split())\n\n n_, D = initRMQ(n)\n\n for _ in range(q):\n #print(D)\n c, x, y = map(int, input().split())\n\n if c == 0:\n update(x - 1, y)\n\n else :\n print(findSum(x - 1, y - 1))\n\n", "neg": "import sys\nsys.setrecursionlimit(10000)\n\n\ndef initRMQ(n):\n n_ = 1\n\n while n_ < n:\n n_ *= 2\n\n D = []\n for _ in range(2*n_ - 1):\n D.append(0)\n\n return n_, D\n\n\ndef update(k, a):\n k += n_ - 1\n D[k] += a\n while k > 0:\n k = int((k - 1) / 2)\n D[k] = D[k*2 + 1] + D[k*2 + 2]\n\n\ndef findSum(a, b):\n return query(a, b + 1, 0, 0, n_)\n\n\ndef query(a, b, k, l, r):\n #print('q', a, b, k, l, r)\n if r <= a or b <= l:\n return 0\n\n if a <= l and r <= b:\n return D[k]\n\n vl = query(a, b, k*2 + 1, l, int((l + r)/2))\n vr = query(a, b, k*2 + 2, int((l + r)/2), r)\n\n return vl + vr\n\n\nif __name__ == '__main__':\n n, q = map(int, input().split())\n\n n_, D = initRMQ(n)\n\n for _ in range(q):\n print(D)\n c, x, y = map(int, input().split())\n\n if c == 0:\n update(x - 1, y)\n\n else :\n print(findSum(x - 1, y - 1))\n\n", "jacc_sim": 1.0, "nl": "Range Sum Query\n\nWrite a program to manipulate a sequence A = {a1, a2, ..., an} with the following operations:\n- add(i, x): add x to ai.\n- getSum(s, t): print the sum of as, as+1, ..., at.\n\nNote that the initial values of ai (i = 1, 2, ..., n) are 0.\n\nInput\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\nFor each getSum operation, print the sum in a line.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 1 \u2264 xi \u2264 n, 0 \u2264 yi \u2264 1000.\n- If comi is 1, then 1 \u2264 xi \u2264 n, 1 \u2264 yi \u2264 n.\n\nSample Input 1\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n3\n2", "before_after_length": [417, 416], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02346", "p_user": "u126478680", "n_user": "u126478680", "pos": "import math\n\nclass SegmentTree():\n def __init__(self, n):\n self.n = n\n self.height = math.ceil(math.log2(n))\n self.nodes = [0 for i in range(pow(2, self.height+1)-1)]\n self.leaf_start = pow(2, self.height)-1\n\n def update(self, i, x):\n pntr = self.leaf_start + i\n self.nodes[pntr] += x\n while True:\n pntr = (pntr-1)//2\n if pntr == -1: break\n self.nodes[pntr] += x\n\n def __query(self, s, t, k, l, r):\n if t - s <= 0: return 0\n if r <= s or t <= l: return 0\n if l == s and t == r: return self.nodes[k]\n else:\n m = (l+r)//2\n if t <= m:\n return self.__query(s, t, k*2+1, l, m)\n elif m <= s:\n return self.__query(s, t, k*2+2, m, r)\n else:\n vl = self.__query(s, m, k*2+1, l, m)\n vr = self.__query(m, t, k*2+2, m, r)\n return vl + vr\n\n def find(self, s, t):\n return self.__query(s, t+1, 0, 0, pow(2, self.height))\n\nn, q = list(map(int, input().split(' ')))\nst = SegmentTree(n)\nfor i in range(q):\n com, x, y = list(map(int, input().split(' ')))\n if com == 0:\n st.update(x-1, y)\n elif com == 1:\n print(st.find(x-1, y-1))\n", "neg": "import math\n\nclass SegmentTree():\n def __init__(self, n):\n self.n = n\n self.height = math.ceil(math.log2(n))\n self.nodes = [0 for i in range(pow(2, self.height+1)-1)]\n self.leaf_start = pow(2, self.height)-1\n\n def update(self, i, x):\n pntr = self.leaf_start + i\n self.nodes[pntr] += x\n while True:\n pntr = (pntr-1)//2\n if pntr == -1: break\n self.nodes[pntr] += x\n\n def __query(self, s, t, k, l, r):\n if t - s <= 0: return 0\n if r <= s or t <= l: return 0\n if l == s and t == r: return self.nodes[k]\n else:\n m = (l+r)//2\n if t <= m:\n return self.__query(s, t, k*2+1, l, m)\n elif m <= s:\n return self.__query(s, t, k*2+2, m, r)\n else:\n vl = self.__query(s, m, k*2+1, l, m)\n vr = self.__query(m, t, k*2+2, m, r)\n return vl + vr\n\n def find(self, s, t):\n return self.__query(s, t+1, 0, 0, pow(2, self.height))\n\nn, q = list(map(int, input().split(' ')))\nst = SegmentTree(n)\nfor i in range(q):\n com, x, y = list(map(int, input().split(' ')))\n if com == 0:\n st.update(x-1, y)\n elif com == 1:\n print(st.find(x, y))\n", "jacc_sim": 1.0, "nl": "Range Sum Query\n\nWrite a program to manipulate a sequence A = {a1, a2, ..., an} with the following operations:\n- add(i, x): add x to ai.\n- getSum(s, t): print the sum of as, as+1, ..., at.\n\nNote that the initial values of ai (i = 1, 2, ..., n) are 0.\n\nInput\nn q\ncom1 x1 y1\ncom2 x2 y2\n...\ncomq xq yq\n\nIn the first line, n (the number of elements in A) and q (the number of queries) are given. Then, q queries are given where com represents the type of queries. '0' denotes add(xi, yi) and '1' denotes getSum(xi, yi).\n\nOutput\nFor each getSum operation, print the sum in a line.\n\nConstraints\n- 1 \u2264 n \u2264 100000\n- 1 \u2264 q \u2264 100000\n- If comi is 0, then 1 \u2264 xi \u2264 n, 0 \u2264 yi \u2264 1000.\n- If comi is 1, then 1 \u2264 xi \u2264 n, 1 \u2264 yi \u2264 n.\n\nSample Input 1\n3 5\n0 1 1\n0 2 2\n0 3 3\n1 1 2\n1 2 2\n\nSample Output 1\n3\n2", "before_after_length": [480, 476], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02347", "p_user": "u629780968", "n_user": "u669284080", "pos": "from sys import stdin\nimport math\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nreadline = stdin.readline\n\ndef main():\n xy = [tuple(map(int, readline().split())) + (i, ) for i in range(int(readline()))]\n xy.sort()\n root = int(math.sqrt(len(xy)))\n\n low = [x for x, y, i in xy[::root]]\n high = [x for x, y, i in xy[root - 1::root]] + [float('inf')]\n\n xy = [sorted(xy[i:i+root], key=itemgetter(1)) for i in range(0, len(xy),root)]\n xy = [([y for x, y, i in xyi], xyi) for xyi in xy]\n for sx, tx, sy, ty, in (map(int, readline().split()) for _ in range(int(readline()))):\n ret =[]\n for i in range(bisect_left(high, sx), bisect_right(low, tx)):\n k,v = xy[i]\n for i in range(bisect_left(k, sy), bisect_right(k, ty)):\n if sx <= v[i][0]<=tx:\n ret.append(v[i][2])\n if ret:\n ret.sort()\n print('\\n'.join(map(str, ret)))\n print()\nmain()\n\n", "neg": "import sys\nimport stdin\nimport math\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nreadline = stdin.readline\n\n# main\nn = int(readline())\nxy = [tuple(map(int, readline().split())) + (i,) for i in range(n)]\n# [..., (x_i, y_i, i), ...]\n# sort by x\nxy.sort()\n\nroot = int(math.sqrt(len(xy)))\n\nlow = [x for x, y, i in xy[::root]]\nhigh = [x for x, y, i in xy[root - 1::root]] + [float('inf')]\n\nxy = [sorted(xy[i:i + root], key=itemgetter(1)) for i in range(0, len(xy), root)]\nxy = [([y for x, y, i in xyi], xyi) for xyi in xy]\nfor sx, tx, sy, ty in (map(int, readline().split()) for _ in range(int(readline()))):\n ret = []\n for i in range(bisect_left(high, sx), bisect_right(low, tx)):\n k, v = xy[i]\n for i in range(bisect_left(k, sy), bisect_right(k, ty)):\n if sx <= v[i][0] <=tx:\n ret.append(v[i][2])\n if ret:\n ret.sort()\n print('\\n'.join(map(str,ret)))\n print()", "jacc_sim": 0.927536231884058, "nl": "Range Search (kD Tree)\n\nThe range search problem involves a set of attributed records S to determine which records from S intersect with a given range.\n\nFor n points on a plane, report a set of points within a given range. Note that insert and delete operations for the set are not considered.\n\nInput:\nn\nx0 y0\nx1 y1\n...\nxn-1 yn-1\nq\nsx0 tx0 sy0 ty0\nsx1 tx1 sy1 ty1\n...\nsxq-1 txq-1 syq-1 tyq-1\n\nThe first integer n is the number of points. In the following n lines, the coordinate of the i-th point is given by two integers xi and yi.\n\nThe next integer q is the number of queries. In the following q lines, each query is given by four integers, sx, tx, sy, ty.\n\nOutput:\nFor each query, report IDs of points such that sx \u2264 x \u2264 tx and sy \u2264 y \u2264 ty. The IDs should be reported in ascending order. Print an ID in a line, and print a blank line at the end of output for each query.\n\nConstraints:\n0 \u2264 n \u2264 500,000\n0 \u2264 q \u2264 20,000\n-1,000,000,000 \u2264 x, y, sx, tx, sy, ty \u2264 1,000,000,000\nsx \u2264 tx\nsy \u2264 ty\nFor each query, the number of points within the range is less than or equal to 100.\n\nSample Input 1:\n6\n2 1\n2 2\n4 2\n6 2\n3 3\n5 4\n2\n2 4 0 4\n4 10 2 5\n\nSample Output 1:\n0\n1\n2\n4\n\n2\n3\n5", "before_after_length": [360, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02359", "p_user": "u797673668", "n_user": "u797673668", "pos": "from itertools import accumulate\n\nn, t = map(int, input().split())\na = [0] * (t + 1)\nfor l, r in (map(int, input().split()) for _ in range(n)):\n a[l] += 1\n a[r] -= 1\nprint(max(accumulate(a)))", "neg": "from itertools import accumulate\n\nn, t = map(int, input().split())\na = [0] * (t + 2)\nfor l, r in (map(int, input().split()) for _ in range(n)):\n a[l] += 1\n a[r + 1] -= 1\nprint(max(accumulate(a)))", "jacc_sim": 0.9696969696969697, "nl": "Title: The Maximum Number of Customers\n\nDescription:\nN persons visited a restaurant. The restaurant is open from 0 to T. The i-th person entered the restaurant at l_i and left at r_i. Find the maximum number of persons during the business hours.\n\nConstraints:\n- 1 <= N <= 10^5\n- 1 <= T <= 10^5\n- 0 <= l_i < r_i <= T\n\nInput:\nThe input is given in the following format:\nN T\nl_1 r_1\nl_2 r_2\n...\nl_N r_N\n\nOutput:\nPrint the maximum number of persons in a line.\n\nSample Input 1:\n6 10\n0 2\n1 3\n2 6\n3 8\n4 10\n5 10\n\nSample Output 1:\n4\n\nSample Input 2:\n2 2\n0 1\n1 2\n\nSample Output 2:\n1", "before_after_length": [79, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u131811591", "n_user": "u131811591", "pos": "import sys\nimport queue\n\n\nclass Dijkstra:\n class Edge:\n def __init__(self, end, cost):\n self.to = end\n self.cost = cost\n\n def __init__(self, node_size, inf):\n self._node = node_size\n self._graph = [[] for _ in range(self._node)]\n self.inf = inf\n self.dist = [self.inf for _ in range(self._node)]\n\n def add_edge(self, st, ed, cs):\n self._graph[st].append(self.Edge(ed, cs))\n\n def solve(self, start):\n que = queue.PriorityQueue()\n self.dist[start] = 0\n que.put((0, start))\n while not que.empty():\n cur_cost, cur_vertex = que.get()\n if self.dist[cur_vertex] < cur_cost:\n continue\n for e in self._graph[cur_vertex]:\n if self.dist[e.to] > cur_cost + e.cost:\n self.dist[e.to] = cur_cost + e.cost\n que.put((self.dist[e.to], e.to))\n\n\nif __name__ == '__main__':\n V, E, r = map(int, sys.stdin.readline().split())\n dk = Dijkstra(V, 10 ** 10)\n for i in range(E):\n s, t, d = map(int, sys.stdin.readline().split())\n dk.add_edge(s, t, d)\n dk.solve(r)\n for value in dk.dist:\n if value == dk.inf:\n print(\"INF\")\n else:\n print(value)\n", "neg": "import sys\nimport queue\n\n\nclass Dijkstra:\n class Edge:\n def __init__(self, end, cost):\n self.to = end\n self.cost = cost\n\n def __init__(self, node_size, inf):\n self._node = node_size\n self._graph = [[] for _ in range(self._node)]\n self.inf = inf\n self.dist = [self.inf for _ in range(self._node)]\n\n def add_edge(self, st, ed, cs):\n self._graph[st].append(self.Edge(ed, cs))\n\n def solve(self, start):\n que = queue.PriorityQueue()\n self.dist[start] = 0\n que.put((0, start))\n while que:\n cur_cost, cur_vertex = que.get()\n if self.dist[cur_vertex] < cur_cost:\n continue\n for e in self._graph[cur_vertex]:\n if self.dist[e.to] > cur_cost + e.cost:\n self.dist[e.to] = cur_cost + e.cost\n que.put((self.dist[e.to], e.to))\n\n\nif __name__ == '__main__':\n V, E, r = map(int, sys.stdin.readline().split())\n dk = Dijkstra(V, 10 ** 10)\n for i in range(E):\n s, t, d = map(int, sys.stdin.readline().split())\n dk.add_edge(s, t, d)\n dk.solve(r)\n for value in dk.dist:\n if value == dk.inf:\n print(\"INF\")\n else:\n print(value)\n", "jacc_sim": 0.9733333333333334, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [434, 431], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u629780968", "n_user": "u089116225", "pos": "V,E,r = map(int, input().split())\nedges = []\nfor _ in range(E):\n tmp = [int(x) for x in input().split()]\n edges.append(tmp)\n \nd = [float('inf') for _ in range(V)]\nd[r] = 0\n \nfor _ in range(V-1):\n count = 0\n for x in edges:\n s,t,w = x\n if d[t] > d[s] + w:\n count += 1\n d[t] = d[s] + w\n if count == 0:\n break\n \nfor x in d:\n if x == float('inf'):\n print('INF')\n else:\n print(x)\n", "neg": "V,E,r = map(int, input().split())\nedges = []\nfor _ in range(E):\n tmp = [int(x) for x in input().split()]\n edges.append(tmp)\n\nd = [float('inf') for _ in range(V)]\nd[r] = 0\n\nfor _ in range(V-1):\n count = 0\n for x in edges:\n s,t,d = x\n if d[t] > d[s] + d:\n count += 1\n d[t] = d[s] + d\n if count == 0:\n break\n\nfor x in d:\n if x == float('inf'):\n print('INF')\n else:\n print(x)\n", "jacc_sim": 0.975609756097561, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [186, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u629780968", "n_user": "u629780968", "pos": "from heapq import heappush, heappop\nv,e,r = map(int,input().split())\nedges=[[] for i in range(v)]\nd = [float('INF')]*v\n\nfor i in range(e):\n s,t,c = map(int,input().split())\n edges[s].append([t,c])\n\nque = []\nheappush(que,(0,r))\nd[r] = 0\n\nwhile que:\n c, u = heappop(que)\n for v, s in edges[u]:\n if d[v] > s + c:\n d[v] = s + c\n heappush(que,(d[v],v))\nfor i in d:\n if i == float('inf'):\n print('INF')\n else:\n print(i)\n", "neg": "from heapq import heappush, heappop\nv,e,r = map(int,input().split())\nedges=[[] for i in range(v)]\nd = [float('INF')]*v\n\nfor i in range(e):\n s,t,c = map(int,input().split())\n edges.append([t,c])\n\nque = []\nheappush(que,(0,r))\nd[r] = 0\n\nwhile que:\n c, u = heappop(que)\n for v, s in edges[u]:\n if d[v] > s + c:\n d[v] = s + c\n heappush(que,(d[v],v))\nfor i in d:\n if i == float('inf'):\n print('INF')\n else:\n print(i)\n", "jacc_sim": 1.0, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [206, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "\nfrom collections import defaultdict\nfrom heapq import heappush, heappop\n\ndef main():\n #Read stdin\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n #Adjacency list\n G = defaultdict(list)\n for i in range(int(E)):\n s, t, w = [int(x) for x in input().split(\" \")]\n G[s].append((t,w))\n\n #initialized\n d = {}\n INF = float('inf')\n #INF = 10001\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = [R]\n while q:\n #u = heappop(q)\n u = q.pop(0)\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n #heappush(q, v[0])\n q.append(v[0])\n\n\n for k in d.keys():\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])\n\nif __name__ == '__main__':\n main()", "neg": "#from collections import defaultdict\n\ndef main():\n #Read stdin\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n #Adjacency list\n G = defaultdict(list)\n for i in range(int(E)):\n s, t, w = [int(x) for x in input().split(\" \")]\n\n #initialized\n d = {}\n INF = float('inf')\n #INF = 10001\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = [R]\n while q:\n u = q.pop(0)\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n q.append(v[0])\n\n for k in d.keys():\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])", "jacc_sim": 0.9230769230769231, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [336, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "#!usr/bin/env python3\n\nfrom collections import defaultdict\n\n\ndef main():\n #Read stdin\n\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n #Adjacency list\n G = defaultdict(list)\n for i in range(int(E)):\n s, t, w = [int(x) for x in input().split(\" \")]\n G[s].append((t,w))\n #initialized\n d = {}\n INF = float('inf')\n #INF = 10001\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = [R]\n while q:\n u = q.pop(0)\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n\n q.append(v[0])\n\n for k in range(V):\n if d[k] == float('inf'):\n \n print(\"INF\")\n else:\n print(d[k])\n\n\n\nif __name__ == '__main__':\n main()", "neg": "#!usr/bin/env python3\n#from collections import defaultdict\n\ndef main():\n #Read stdin\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n #Adjacency list\n G = defaultdict(list)\n for i in range(int(E)):\n s, t, w = [int(x) for x in input().split(\" \")]\n\n #initialized\n d = {}\n INF = float('inf')\n #INF = 10001\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = [R]\n while q:\n u = q.pop(0)\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n q.append(v[0])\n\n for k in d.keys():\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9852941176470589, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [315, 298], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "#!usr/bin/env python3\n\n'''\ntime score 7.88 for list\ntime score 03.17 for deque\ntime score 03.22 for defaultdict(dict)\n\n''' \n\nfrom collections import defaultdict\nfrom collections import deque\n#import time\n\ndef main():\n # Read stdin\n #start = time.clock()\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n # Adjacency list\n G = defaultdict(list)\n for i in range(E):\n s, t, w = [int(x) for x in input().split(\" \")]\n G[s].append((t, w))\n # initialized\n d = {}\n INF = float('inf')\n # INF = 10001\n nodes_list = range(V)\n for i in nodes_list:\n d[i] = INF\n d[R] = 0\n # deque is better than list aka double link list O(1) for pop head and append\n q = deque([R])\n while q:\n # u = heappop(q)\n u = q.popleft()\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n # heappush(q, v[0])\n q.append(v[0])\n for k in nodes_list:\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])\n #end = time.clock() - start\n #print('Computation time : {}'.format(end))\n\n\nif __name__ == '__main__':\n main()", "neg": "#!usr/bin/env python3\n\n'''\ntime score 7.88 for list\ntime score 03.17 for deque\ntime score 03.22 for defaultdict(dict)\n\n''' \n\nfrom collections import defaultdict\nfrom collections import deque\n#import time\n\ndef main():\n # Read stdin\n start = time.clock()\n fl = input().split(\" \")\n V = int(fl[0])\n E = int(fl[1])\n R = int(fl[2])\n # Adjacency list\n G = defaultdict(list)\n for i in range(E):\n s, t, w = [int(x) for x in input().split(\" \")]\n G[s].append((t, w))\n # initialized\n d = {}\n INF = float('inf')\n # INF = 10001\n nodes_list = range(V)\n for i in nodes_list:\n d[i] = INF\n d[R] = 0\n # deque is better than list aka double link list O(1) for pop head and append\n q = deque([R])\n while q:\n # u = heappop(q)\n u = q.popleft()\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n # heappush(q, v[0])\n q.append(v[0])\n for k in nodes_list:\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])\n #end = time.clock() - start\n #print('Computation time : {}'.format(end))\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [437, 436], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "from collections import defaultdict\nfrom collections import deque\nfrom sys import stdin\n\ndef sp(G,R,V):\n d = {}\n INF = float('inf')\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = deque([(R)])\n while q:\n u = q.popleft()\n for v in G[u].keys():\n if d[v] > d[u] + G[u][v]:\n d[v] = d[u] + G[u][v]\n q.append(v)\n return d\n\n\nV, E, R = [int(x) for x in stdin.readline().split()]\nG = defaultdict(dict)\nfor case in range(E):\n s, t, w = [int(x) for x in stdin.readline().split()]\n G[s][t] = w\nd = sp(G, R, V)\nfor k in range(V):\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])", "neg": "from collections import defaultdict\nfrom collections import deque\nfrom sys import stdin\n\ndef sp(G,R,V):\n d = {}\n INF = float('inf')\n for i in range(V):\n d[i] = INF\n d[R] = 0\n q = deque([(R)])\n while q:\n u = q.popleft()\n for v in G[u]:\n if d[v[0]] > d[u] + v[1]:\n d[v[0]] = d[u] + v[1]\n q.append(v[0])\n return d\n\n\nV, E, R = tuple(int(x) for x in stdin.readline().split(' '))\nG = defaultdict(list)\nfor case in range(E):\n s, t, w = tuple(int(x) for x in stdin.readline().split(' '))\n G[s].append((t,w))\nprint(G)\nd = sp(G, R, V)\nfor k in range(V):\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])", "jacc_sim": 0.9152542372881356, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [271, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u798803522", "n_user": "u798803522", "pos": "from collections import defaultdict\nimport heapq\n\nvertice,edge,source = map(int,input().split(\" \"))\nlink = defaultdict(dict)\nweight = defaultdict(dict)\nanswer = [-1] * vertice\nfor e in range(edge):\n i,j,w = map(int,input().split(\" \"))\n link[i] = link.get(i,set()) | {j}\n weight[i].update({j:w})\nqueue = []\nheapq.heappush(queue,(0,source))\nheapq.heapify(queue)\nwhile queue:\n #print(queue)\n now_cost,here = heapq.heappop(queue)\n #print(now_cost,here,queue)\n if answer[here] > -1:\n continue\n answer[here] = now_cost\n\n #print(v,here,now_cost,not_went,queue)\n for nw in link[here]:\n if answer[nw] == -1:\n heapq.heappush(queue,(now_cost + weight[here][nw],nw))\n\nfor a in answer:\n print(a if a != -1 else \"INF\")", "neg": "from collections import defaultdict\nimport heapq\n\n\nvertice,edge,source = map(int,input().split(\" \"))\nlink = defaultdict(dict)\nweight = defaultdict(dict)\nanswer = [-1] * vertice\nfor e in range(edge):\n i,j,w = map(int,input().split(\" \"))\n link[i] = link.get(i,set()) | {j}\n weight[i].update({j:w})\ngoal = v\nqueue = []\nheapq.heappush(queue,(0,source))\nheapq.heapify(queue)\nwhile queue:\n #print(queue)\n now_cost,here = heapq.heappop(queue)\n #print(now_cost,here,queue)\n if answer[here] > -1:\n continue\n answer[here] = now_cost\n\n #print(v,here,now_cost,not_went,queue)\n for nw in link[here]:\n if answer[nw] == -1:\n heapq.heappush(queue,(now_cost + weight[here][nw],nw))\n\nfor a in answer:\n print(a if a != -1 else \"INF\")", "jacc_sim": 0.9841269841269841, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [289, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "from collections import defaultdict\nfrom heapq import heappush, heappop, heapify\nfrom sys import stdin\ndef sp(G,R,V):\n d = {}\n q = [(0, R)]\n heapify(q)\n #seen = set()\n while q:\n (cost, v) = heappop(q)\n if v not in d:\n #seen.add(v)\n d[v] = cost\n for (next, c) in G[v].items():\n heappush(q, (cost + c, next))\n return d\n\nV, E, R = [int(x) for x in stdin.readline().split()]\nG = defaultdict(dict)\nfor case in range(E):\n s, t, w = [int(x) for x in stdin\n .readline().split()]\n G[s][t] = w\nd = sp(G, R, V)\nfor k in range(V):\n if k not in d:\n print(\"INF\")\n else:\n print(d[k])", "neg": "from collections import defaultdict\nfrom heapq import heappush, heappop, heapify\nfrom sys import stdin\n\ndef sp(G,R,V):\n d = {}\n q = [(0, R)]\n d[R] = 0\n heapify(q)\n while q:\n (cost, v) = heappop(q)\n for (next, c) in G[v].items():\n if v not in d:\n d[v] = c\n elif d[next] > d[v] + c:\n d[next] = d[v] + c\n heappush(q, (d[next], next))\n return d\n\n\nV, E, R = [int(x) for x in stdin.readline().split()]\nG = defaultdict(dict)\nfor case in range(E):\n s, t, w = [int(x) for x in stdin\n .readline().split()]\n G[s][t] = w\nd = sp(G, R, V)\nfor k in range(V):\n if k not in d:\n print(\"INF\")\n else:\n print(d[k])", "jacc_sim": 0.9032258064516129, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [261, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u279546122", "n_user": "u279546122", "pos": "from collections import defaultdict\nfrom heapq import heappush, heappop, heapify\nfrom sys import stdin\n#import time\n\ndef sp(G,R,V):\n d = {}\n INF = float('inf')\n for i in range(V):\n d[i] = INF\n q = [(0, R)]\n d[R] = 0\n heapify(q)\n while q:\n (cost, v) = heappop(q)\n for (next, c) in G[v].items():\n if d[next] > d[v] + c:\n d[next] = d[v] + c\n heappush(q, (d[next], next))\n return d\n\n#start = time.clock()\n\nV, E, R = [int(x) for x in stdin.readline().split()]\nG = defaultdict(dict)\nfor case in range(E):\n s, t, w = [int(x) for x in stdin\n .readline().split()]\n G[s][t] = w\nd = sp(G, R, V)\nfor k in range(V):\n if d[k] == float('inf'):\n print(\"INF\")\n else:\n print(d[k])\n#print('Computation time : {}'.format(time.clock()-start))", "neg": "from collections import defaultdict\nfrom heapq import heappush, heappop, heapify\nfrom sys import stdin\n#import time\n\ndef sp(G,R,V):\n d = {}\n INF = float('inf')\n for i in range(V):\n d[i] = INF\n q = [(0, R)]\n d[R] = 0\n heapify(q)\n while q:\n (cost, v) = heappop(q)\n for (next, c) in G[v].items():\n if d[next] > d[v] + c:\n d[next] = d[v] + c\n heappush(q, (d[next], next))\n return d\n\n#start = time.clock()\n\nV, E, R = [int(x) for x in stdin.readline().split()]\nG = defaultdict(dict)\nfor case in range(E):\n s, t, w = [int(x) for x in stdin\n .readline().split()]\n G[s][t] = w\nd = sp(G, R, V)\nfor k in range(V):\n if k not in d:\n print(\"INF\")\n else:\n print(d[k])\n#print('Computation time : {}'.format(time.clock()-start))", "jacc_sim": 0.9850746268656716, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [328, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u855775311", "n_user": "u855775311", "pos": "import heapq\n\n\ndef main():\n nvertices, nedges, s = map(int, input().split())\n adj = [[] for i in range(nvertices)]\n for i in range(nedges):\n u, v, w = map(int, input().split())\n adj[u].append((v, w))\n\n INF = float('inf')\n costs = [INF] * nvertices\n costs[s] = 0\n que = [(0, s)]\n for i in range(1, nvertices):\n que.append((INF, 1))\n cnt = 0\n while que:\n cost, u = heapq.heappop(que)\n if cost > costs[u]:\n continue\n costs[u] = cost\n for v, w in adj[u]:\n if costs[v] > costs[u] + w:\n costs[v] = costs[u] + w\n heapq.heappush(que, (costs[v], v))\n cnt += 1\n if cnt == nvertices:\n break\n\n for i in range(nvertices):\n print(costs[i] if costs[i] < INF else \"INF\")\n\n\nmain()", "neg": "import heapq\n\n\ndef main():\n nvertices, nedges, s = map(int, input().split())\n adj = [[] for i in range(nvertices)]\n for i in range(nedges):\n u, v, w = map(int, input().split())\n adj[u].append((v, w))\n\n INF = float('inf')\n costs = [INF] * nvertices\n costs[0] = 0\n que = [(0, s)]\n for i in range(1, nvertices):\n que.append((INF, 1))\n while que:\n cost, u = heapq.heappop(que)\n if cost > costs[u]:\n continue\n costs[u] = cost\n for v, w in adj[u]:\n if costs[v] > costs[u] + w:\n costs[v] = costs[u] + w\n heapq.heappush(que, (costs[v], v))\n\n for i in range(nvertices):\n print(costs[i] if costs[i] < INF else \"INF\")\n\n\nmain()", "jacc_sim": 0.96, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [293, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u835844653", "n_user": "u835844653", "pos": "'''\n????????\u00a3????????????????????????\n\n'''\n\nimport queue\nv,e,s=map(int,input().split())\nedge=[]\ninf =1000000100\nfor i in range(v):\n edge.append([])\n\nfor i in range(e):\n vs,vt,d=map(int,input().split())\n edge[vs].append((vt,d))\n \ndis=[]\nfor i in range(v):\n dis.append(inf)\n\ndis[s]=0\n\nq = queue.PriorityQueue()\nq.put((0,s))\n\nwhile(not q.empty()):\n now=q.get()\n# print(\"get\",now)\n nowv=now[1]\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n# print(\"put\",(dis[vt],vt))\n\n \nfor i in range(v):\n if dis[i]>=inf:\n print(\"INF\")\n else:\n print(dis[i])", "neg": "'''\n????????\u00a3????????????????????????\n\n'''\n\nimport queue\nv,e,s=map(int,input().split())\nedge=[]\ninf =1000000100\nfor i in range(v):\n edge.append([])\n\nfor i in range(e):\n vs,vt,d=map(int,input().split())\n edge[vs].append((vt,d))\n \ndis=[]\nfor i in range(v):\n dis.append(inf)\n\ndis[s]=0\n\nq = queue.PriorityQueue()\nq.put((0,s))\nfinished=0\n\nwhile(not finished==v):\n now=q.get()\n# print(\"get\",now)\n nowv=now[1]\n finished+=1\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n \n# print(\"put\",(dis[vt],vt))\n\n \nfor i in range(v):\n if dis[i]>=inf:\n print(\"INF\")\n else:\n print(dis[i])", "jacc_sim": 0.9615384615384616, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [296, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u835844653", "n_user": "u835844653", "pos": "'''\n????????\u00a3????????????????????????\n\n'''\n\nimport queue\nv,e,s=map(int,input().split())\nedge=[]\ninf =1000000100\nfor i in range(v):\n edge.append([])\n\nfor i in range(e):\n vs,vt,d=map(int,input().split())\n edge[vs].append((vt,d))\n \ndis=[]\nfor i in range(v):\n dis.append(inf)\n\ndis[s]=0\n\nq = queue.PriorityQueue()\nq.put((0,s))\n\n\nwhile(not q.empty()):\n now=q.get()\n nowv=now[1]\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n'''\nfinished=0\nwhile(finisheddis[nowv]: continue\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n finished+=1 \n'''\nfor i in range(v):\n if dis[i]>=inf:\n print(\"INF\")\n else:\n print(dis[i])", "neg": "'''\n????????\u00a3????????????????????????\n\n'''\n\nimport queue\nv,e,s=map(int,input().split())\nedge=[]\ninf =1000000100\nfor i in range(v):\n edge.append([])\n\nfor i in range(e):\n vs,vt,d=map(int,input().split())\n edge[vs].append((vt,d))\n \ndis=[]\nfor i in range(v):\n dis.append(inf)\n\ndis[s]=0\n\nq = queue.PriorityQueue()\nq.put((0,s))\n\n'''\nwhile(not q.empty()):\n now=q.get()\n\n nowv=now[1]\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n'''\nfinished=0\nwhile(finisheddis[nowv] continue;\n for (vt,d) in edge[nowv]:\n if dis[vt]>dis[nowv]+d:\n dis[vt]=dis[nowv]+d\n q.put((dis[vt],vt))\n finished+=1 \n\nfor i in range(v):\n if dis[i]>=inf:\n print(\"INF\")\n else:\n print(dis[i])", "jacc_sim": 0.9818181818181818, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [384, 386], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u742505495", "n_user": "u742505495", "pos": "import queue\n\ndef Dijkstra(vertex,edges,start):\n\tweight = [0 if i==start else float(\"inf\") for i in range(vertex)]\n\tQ = queue.PriorityQueue()\n\tQ.put((weight[start],start))\n\n\twhile(not Q.empty()):\n\t\tcur = Q.get()\n\t\tif weight[cur[1]] < cur[0]:\n\t\t\tcontinue\n\t\tfor j in range(len(edges[cur[1]])):\n\t\t\tif weight[edges[cur[1]][j][1]] > weight[cur[1]] + edges[cur[1]][j][2]:\n\t\t\t\tweight[edges[cur[1]][j][1]] = weight[cur[1]] + edges[cur[1]][j][2]\n\t\t\t\tQ.put((weight[edges[cur[1]][j][1]],edges[cur[1]][j][1]))\n\treturn weight\n\nV,E,r = map(int,input().split())\nedges = [[] for i in range(V)]\nfor i in range(E):\n\tdata = list(map(int,input().split()))\n\tedges[data[0]].append(data)\nfor j in range(V):\n\tedges[j].sort()\nw = Dijkstra(V,edges,r)\nfor i in range(len(w)):\n\tif w[i]==float(\"inf\"):\n\t\tprint('INF')\n\telse:\n\t\tprint(w[i])\n", "neg": "import queue\n\ndef Dijkstra(vertex,edges,start):\n\tweight = [0 if i==start else float(\"inf\") for i in range(vertex)]\n\tQ = queue.PriorityQueue()\n\tQ.put((weight[start],start))\n\n\twhile(not Q.empty()):\n\t\tcur = Q.get()\n\t\tif weight[cur[1]] < cur[0]:\n\t\t\tcontinue\n\t\tfor j in range(len(edges[cur[1]])):\n\t\t\tif weight[edges[cur[1]][j][1]] > weight[cur[1]] + edges[cur[1]][j][2]:\n\t\t\t\tweight[edges[cur[1]][j][1]] = weight[cur[1]] + edges[cur[1]][j][2]\n\t\t\t\tQ.put((weight[edges[cur[1]][j][1]],edges[cur[1]][j][1]))\n\treturn weight\n\nV,E,r = map(int,input().split())\nedges = [[] for i in range(V)]\nfor i in range(E):\n\tdata = list(map(int,input().split()))\n\tedges[data[0]].append(data)\n\tedges[data[1]].append([data[1],data[0],data[2]])\nfor j in range(V):\n\tedges[j].sort()\nw = Dijkstra(V,edges,r)\nfor i in range(len(w)):\n\tprint(w[i])\n", "jacc_sim": 0.9827586206896551, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [364, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02361", "p_user": "u089116225", "n_user": "u089116225", "pos": "\n#Bellman-Ford\u3060\u3068TLE\u306b\u306a\u308b(\u306f\u305a)\nV,E,r = map(int, input().split())\nedges = []\nfor _ in range(E):\n tmp = [int(x) for x in input().split()]\n edges.append(tmp)\n\nd = [float('inf') for _ in range(V)]\nd[r] = 0\n\nfor _ in range(V-1):\n count = 0\n for x in edges:\n s,t,w = x\n if d[t] > d[s] + w:\n count += 1\n d[t] = d[s] + w\n if count == 0:\n break\n\nfor x in d:\n if x == float('inf'):\n print('INF')\n else:\n print(x)\n", "neg": "\n#Bellman-Ford\u3060\u3068TLE\u306b\u306a\u308b(\u306f\u305a)\nV,E,r = map(int, input().split())\nedges = []\nfor _ in range(E):\n tmp = [int(x) for x in input().split()]\n edges.append(tmp)\n\nd = [float('inf') for _ in range(V)]\nd[r] = 0\n\nfor _ in range(V-1):\n count = 0\n for x in edges:\n if d[x[1]] > d[x[0]] + x[2]:\n count += 0\n d[x[1]] = d[x[0]] + x[2]\n if count == 0:\n break\n\nfor x in d:\n if x == float('inf'):\n print('INF')\n else:\n print(x)\n", "jacc_sim": 0.9245283018867925, "nl": "Title: Single Source Shortest Path\n\nFor a given weighted graph G(V, E) and a source r, find the shortest path from the source to each vertex (SSSP: Single Source Shortest Path).\n\nInput:\nAn edge-weighted graph G(V, E) and the source r.\n|V| |E| r\ns0 t0 d0\ns1 t1 d1\n...\ns|E|-1 t|E|-1 d|E|-1\n|V| is the number of vertices, |E| is the number of edges in G, and the vertices are named 0, 1,..., |V|-1 respectively. r is the source of the graph.\nsi and ti represent source and target vertices of the i-th edge (directed), and di represents the cost of the i-th edge.\n\nOutput:\nPrint the costs of SSSP in the format:\nc0\nc1\n...\nc|V|-1\nThe output consists of |V| lines. Print the cost of the shortest path from the source r to each vertex 0, 1, ..., |V|-1 in order. If there is no path from the source to a vertex, print INF.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100000\n- 0 \u2264 di \u2264 10000\n- 0 \u2264 |E| \u2264 500000\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 5 0\n0 1 1\n0 2 4\n1 2 2\n2 3 1\n1 3 5\n\nSample Output 1:\n0\n1\n3\n4\n\nSample Input 2:\n4 6 1\n0 1 1\n0 2 4\n2 0 1\n1 2 2\n3 1 1\n3 2 5\n\nSample Output 2:\n3\n0\n2\nINF", "before_after_length": [217, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02362", "p_user": "u871901071", "n_user": "u871901071", "pos": "import sys\n\ninf = int(1e12)\n\ndef shortestPath(graph, s):\n n = len(graph)\n dist = [inf for _ in range(n)]\n dist[s] = 0\n\n for i in range(n):\n for u in range(n):\n for v, cost in graph[u]:\n newDist = dist[u] + cost\n if dist[u] != inf and newDist < dist[v]:\n if i == n - 1:\n return None\n dist[v] = newDist\n return dist\n\ndef main():\n v, e, s = map(int, input().split())\n \n graph = [[] for _ in range(v)]\n \n for i in range(e):\n a, b, cost = map(int, input().split())\n graph[a].append((b, cost))\n \n dist = shortestPath(graph, s)\n\n if not dist:\n print(\"NEGATIVE CYCLE\")\n else:\n for d in dist:\n if d >= inf:\n print(\"INF\")\n else:\n print(d)\nmain()", "neg": "import sys\n\ndef shortestPath(graph, s):\n n = len(graph)\n dist = [inf for _ in range(n)]\n dist[s] = 0\n\n for i in range(n):\n for u in range(n):\n for v, cost in graph[u]:\n newDist = dist[u] + cost\n if dist[u] != inf and newDist < dist[v]:\n if i == n - 1:\n return None\n dist[v] = newDist\n return dist\n\ndef main():\n v, e, s = map(int, input().split())\n \n graph = [[] for _ in range(v)]\n \n for i in range(e):\n a, b, cost = map(int, input().split())\n graph[a].append((b, cost))\n \n dist = shortestPath(graph, s)\n\n if not dist:\n print(\"NEGATIVE CYCLE\")\n else:\n for d in dist:\n if d >= inf:\n print(\"INF\")\n else:\n print(d)\nmain()", "jacc_sim": 0.9827586206896551, "nl": "The problem is to find the shortest path from a given source vertex in a graph with weighted edges. The input consists of the graph G with vertices V and edges E, along with the source vertex r. The output should indicate if there is a negative cycle reachable from the source. If not, it should provide the cost of the shortest path from the source to each vertex. Constraints include the number of vertices and edges, edge weights, and the absence of parallel edges or self-loops. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [276, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02362", "p_user": "u567380442", "n_user": "u567380442", "pos": "class exist_negative_cycle(Exception):\n pass\ndef bellman_ford(g, size, start=0):\n d = [float('inf')] * size\n d[start] = 0\n \n for _ in range(size):\n for u in g:\n for length, v in g[u]:\n if d[v] > d[u] + length:\n d[v] = d[u] + length\n\n for u in g:\n for length, v in g[u]:\n if d[v] > d[u] + length:\n raise exist_negative_cycle \n return d\nfrom sys import stdin\nreadline = stdin.readline\nimport math\nfrom collections import defaultdict\n\nvertex, edge, r = map(int, readline().split())\n\ng = defaultdict(list)\nfor i in range(edge):\n s, t, length = map(int, readline().split())\n g[s].append((length, t))\ntry:\n d = bellman_ford(g, vertex, r)\n for di in d:\n print('INF' if math.isinf(di) else di)\nexcept exist_negative_cycle:\n print('NEGATIVE CYCLE')", "neg": "class exist_negative_cycle(Exception):\n pass\ndef bellman_ford(g, size, start=0):\n d = [float('inf')] * size\n d[start] = 0\n \n for _ in range(size):\n for u in g:\n for length, v in g[u]:\n if d[v] > d[u] + length:\n d[v] = d[u] + length\n\n for u in g:\n for length, v in g[u]:\n if d[v] > d[u] + length:\n raise exist_negative_cycle \n return d\nfrom sys import stdin\nreadline = stdin.readline\n\nfrom collections import defaultdict\n\nvertex, edge, r = map(int, readline().split())\n\ng = defaultdict(list)\nfor i in range(edge):\n s, t, length = map(int, readline().split())\n g[s].append((length, t))\ntry:\n d = bellman_ford(g, vertex, r)\n for di in d:\n print('INF' if math.isinf(di) else di)\nexcept exist_negative_cycle:\n print('NEGATIVE CYCLE')", "jacc_sim": 1.0, "nl": "The problem is to find the shortest path from a given source vertex in a graph with weighted edges. The input consists of the graph G with vertices V and edges E, along with the source vertex r. The output should indicate if there is a negative cycle reachable from the source. If not, it should provide the cost of the shortest path from the source to each vertex. Constraints include the number of vertices and edges, edge weights, and the absence of parallel edges or self-loops. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [292, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02362", "p_user": "u966364923", "n_user": "u966364923", "pos": "V, E, root = map(int, input().split())\nvisited = [False] * V\nnodes = [[] for i in range(V)]\ncost = [[] for i in range(V)]\nfor i in range(E):\n s, t, d = map(int, input().split())\n nodes[s].append(t)\n cost[s].append(d)\n\ndist = [float('inf')] * V\ndist[root] = 0\n\nnegative_cycle = False\n\nfor k in range(V):\n for i in range(V):\n for j in range(len(nodes[i])):\n if dist[nodes[i][j]] > dist[i] + cost[i][j]:\n dist[nodes[i][j]] = dist[i] + cost[i][j]\n if k == V - 1:\n dist[nodes[i][j]] = -float('inf')\n negative_cycle = True\nif negative_cycle:\n print('NEGATIVE CYCLE')\nelse:\n for i in range(V):\n if dist[i] == float('inf'):\n print('INF')\n else:\n print(dist[i])", "neg": "V, E, root = map(int, input().split())\nvisited = [False] * V\nnodes = [[] for i in range(V)]\ncost = [[] for i in range(V)]\nfor i in range(E):\n s, t, d = map(int, input().split())\n nodes[s].append(t)\n cost[s].append(d)\n\ndist = [float('inf')] * V\ndist[root] = 0\n\nnegative_cycle = False\n\nfor k in range(V):\n for i in range(V):\n for j in range(nodes[i]):\n if dist[nodes[i][j]] > dist[i] + cost[i][j]:\n dist[nodes[i][j]] = dist[i] + cost[i][j]\n if k==n-1:\n dist[nodes[i][j]] = -float('inf')\n negative_cycle = True\nif negative_cycle:\n print('NEGATIVE CYCLE')\nelse:\n for i in range(V):\n if dist[i] == float('inf'):\n print('INF')\n else:\n print(dist[i])", "jacc_sim": 0.9591836734693877, "nl": "The problem is to find the shortest path from a given source vertex in a graph with weighted edges. The input consists of the graph G with vertices V and edges E, along with the source vertex r. The output should indicate if there is a negative cycle reachable from the source. If not, it should provide the cost of the shortest path from the source to each vertex. Constraints include the number of vertices and edges, edge weights, and the absence of parallel edges or self-loops. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [283, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02362", "p_user": "u797673668", "n_user": "u797673668", "pos": "nv, ne, r = map(int, input().split())\n\nedges = set(tuple(map(int, input().split())) for _ in range(ne))\ncosts = [None] * nv\ncosts[r] = 0\n\nfor _ in range(nv - 1):\n for s, t, d in edges:\n if costs[s] is None:\n continue\n cost = costs[s] + d\n if costs[t] is None or costs[t] > cost:\n costs[t] = cost\n\nfor s, t, d in edges:\n if costs[s] is None:\n continue\n if costs[s] + d < costs[t]:\n print('NEGATIVE CYCLE')\n break\nelse:\n for cost in costs:\n print('INF' if cost is None else cost)", "neg": "nv, ne, r = map(int, input().split())\n\nedges = set(tuple(map(int, input().split())) for _ in range(ne))\ncosts = [None] * nv\ncosts[r] = 0\n\nfor _ in range(nv - 1):\n for s, t, d in edges:\n cost = d if costs[s] is None else costs[s] + d\n if costs[t] is None or costs[t] > cost:\n costs[t] = cost\n\nfor s, t, d in edges:\n cost = d if costs[s] is None else costs[s] + d\n if cost < costs[t]:\n print('NEGATIVE CYCLE')\n break\nelse:\n for cost in costs:\n print('INF' if cost is None else cost)", "jacc_sim": 0.9782608695652174, "nl": "The problem is to find the shortest path from a given source vertex in a graph with weighted edges. The input consists of the graph G with vertices V and edges E, along with the source vertex r. The output should indicate if there is a negative cycle reachable from the source. If not, it should provide the cost of the shortest path from the source to each vertex. Constraints include the number of vertices and edges, edge weights, and the absence of parallel edges or self-loops. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [198, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02362", "p_user": "u510829608", "n_user": "u510829608", "pos": "import sys\n\nINF = float('inf')\n\ndef Bellmanford(n, edges, r): #r: ?\u00a7????\n d = [INF] * n\n d[r] = 0\n \n for i in range(n):\n \n for (u, v, c) in edges:\n if d[u] != INF and d[u] + c < d[v]:\n d[v] = d[u] + c\n if i == n-1:\n return ['NEGATIVE CYCLE']\n \n d = [di if di < INF else 'INF' for di in d]\n return d\n \n\nV, E, R = map(int, sys.stdin.readline().split())\nEdges = [None] * E\n\nfor i in range(E):\n si, ti, di = map(int, sys.stdin.readline().split())\n Edges[i] = (si, ti, di)\n \nans = Bellmanford(V, Edges, R)\n\nprint(*ans, sep = '\\n')", "neg": "import sys\n\nINF = float('inf')\n\ndef Bellmanford(n, edges, r):\n d = [INF] * n\n d[r] = 0\n \n for i in range(n):\n flag = False\n \n for (u, v, c) in edges:\n if d[u] != INF and d[u] + c < d[v]:\n d[v] = d[u] + c\n flag = True\n \n if flag and i == n-1:\n return 'NEGATIVE CYCLE'\n \n d = [di if di < INF else 'INF' for di in d]\n return d\n\nV, E, R = map(int, sys.stdin.readline().split())\nEdges = [None] * E\n\nfor i in range(E):\n si, ti, di = map(int, sys.stdin.readline().split())\n Edges[i] = (si, ti, di)\n \nans = Bellmanford(V, Edges, R)\n\nprint(*ans, sep = '\\n')", "jacc_sim": 0.9047619047619048, "nl": "The problem is to find the shortest path from a given source vertex in a graph with weighted edges. The input consists of the graph G with vertices V and edges E, along with the source vertex r. The output should indicate if there is a negative cycle reachable from the source. If not, it should provide the cost of the shortest path from the source to each vertex. Constraints include the number of vertices and edges, edge weights, and the absence of parallel edges or self-loops. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [256, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u637322311", "n_user": "u637322311", "pos": "from sys import stdin\nfrom collections import deque\n\ndef read_graph(v, e):\n A = [ [float('inf')]*v for _ in range(v) ]\n for i in range(v):\n A[i][i] = 0\n for _ in range(e):\n line = list(stdin.readline().strip().split())\n i = line[0]\n j = line[1]\n k = line[2]\n A[int(i)][int(j)] = int(k)\n return A\n\ndef worshall_floyd(A, v):\n for k in range(v):\n for i in range(v):\n if A[i][k] == float('inf'):\n continue\n for j in range(v):\n if A[k][j] == float('inf'):\n continue\n A[i][j] = min(A[i][j], A[i][k] + A[k][j])\n return A\n\ndef print_ans(A, v):\n NEGATIVE = False\n for i in range(v):\n if A[i][i] < 0:\n NEGATIVE = True\n if NEGATIVE:\n print('NEGATIVE CYCLE')\n else:\n for i in A:\n print(*[str(k).upper() for k in i], sep=' ')\n\nv, e = [int(i) for i in input().split()]\nA = read_graph(v, e)\nA = worshall_floyd(A, v)\nprint_ans(A, v)\n\n", "neg": "from sys import stdin\nfrom collections import deque\n\ndef read_graph(v, e):\n A = [ [float('inf')]*v for _ in range(v) ]\n for i in range(v):\n A[i][i] = 0\n for _ in range(e):\n line = list(stdin.readline().strip().split())\n i = line[0]\n j = line[1]\n k = line[2]\n A[int(i)][int(j)] = int(k)\n return A\n\ndef worshall_floyd(A, v):\n for k in range(v):\n for i in range(v):\n if A[i][k] == float('inf'):\n continue\n for j in range(v):\n if A[k][j] == float('inf'):\n continue\n A[i][j] = min(A[i][j], A[i][k] + A[k][j])\n return A\n\ndef print_ans(A):\n if min(min(A)) < 0:\n print('NEGATIVE CYCLE')\n else:\n for i in A:\n print(*[str(k).upper() for k in i], sep=' ')\n\nv, e = [int(i) for i in input().split()]\nA = read_graph(v, e)\nprint_ans(worshall_floyd(A, v))\n", "jacc_sim": 0.9649122807017544, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [383, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u099826363", "n_user": "u099826363", "pos": "from sys import exit\nINF = 1<<32\nV,E = [int(n) for n in input().split()]\ns = [0]*E\nt = [0]*E\nd = [0]*E\ndist = [[INF for _ in range(V)] for __ in range(V)]\nfor i in range(V):\n dist[i][i]= 0\nfor i in range(E):\n s[i], t[i], d[i] = [int(n) for n in input().split()]\n dist[s[i]][t[i]] = d[i]\n\nfor k in range(V):\n for i in range(V):\n if(dist[i][k]== INF):continue\n for j in range(V):\n if(dist[k][j]== INF):continue\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nfor i in range(V):\n if dist[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n exit()\n\nfor i in range(V):\n for j in range(V):\n if j != V-1:\n print(dist[i][j] if dist[i][j] != INF else \"INF\",end=\" \")\n else:\n print(dist[i][j] if dist[i][j] != INF else \"INF\")\n\n# N = int(input())\n# a = [int(input()) for _ in range(N)]\n# S = str(input())\n# L = len(S)\n# T = str(input())\n# exit()\n\n", "neg": "from sys import exit\nINF = 1<<21\nV,E = [int(n) for n in input().split()]\ns = [0]*E\nt = [0]*E\nd = [0]*E\ndist = [[INF for _ in range(V)] for __ in range(V)]\nfor i in range(V):\n dist[i][i]= 0\nfor i in range(E):\n s[i], t[i], d[i] = [int(n) for n in input().split()]\n dist[s[i]][t[i]] = d[i]\n\nfor k in range(V):\n for i in range(V):\n if(dist[i][k]== INF):continue\n for j in range(V):\n if(dist[k][j]== INF):continue\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nfor i in range(V):\n for j in range(V):\n print(dist[i][j] if dist[i][j] != INF else \"INF\",end=\" \")\n print()\n\n# N = int(input())\n# a = [int(input()) for _ in range(N)]\n# S = str(input())\n# L = len(S)\n# T = str(input())\n# exit()\n\n", "jacc_sim": 0.9122807017543859, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [394, 328], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u967553879", "n_user": "u967553879", "pos": "import copy\n\nINF = 10**10\nv, e = map(int, input().split())\nM = [[INF]*v for i in range(v)]\nfor i in range(v):\n M[i][i] = 0\nfor i in range(e):\n s, t, d = map(int, input().split())\n M[s][t] = d\n\n# k:\u30b0\u30e9\u30d5\u306e\u7bc4\u56f2\nans = copy.deepcopy(M)\nfor k in range(v):\n for i in range(v):\n if ans[i][k] == INF:\n continue\n for j in range(v):\n if ans[k][j] == INF:\n continue\n # i, j\u306e\u30b0\u30e9\u30d5\u306e\u6700\u77ed\u8ddd\u96e2\n ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j])\n\nflag = False\nfor i in range(v):\n if ans[i][i] < 0:\n flag = True\n break\nif flag:\n print('NEGATIVE CYCLE')\nelse:\n for line in ans:\n line = ['INF' if tmp == INF else tmp for tmp in line]\n print(*line)\n\n", "neg": "import copy\n\nINF = 10**10\nv, e = map(int, input().split())\nM = [[INF]*v for i in range(v)]\nfor i in range(v):\n M[i][i] = 0\nfor i in range(e):\n s, t, d = map(int, input().split())\n M[s][t] = d\n\n# k:\u30b0\u30e9\u30d5\u306e\u7bc4\u56f2\nans = copy.deepcopy(M)\nfor k in range(v):\n for i in range(v):\n for j in range(v):\n # i, j\u306e\u30b0\u30e9\u30d5\u306e\u6700\u77ed\u8ddd\u96e2\n if k == 0:\n ans[i][j] = M[i][j]\n else:\n ans[i][j] = min(ans[i][j], ans[i][k]+ans[k][j])\n\nflag = False\nfor line in ans:\n if any([i < 0 for i in line]):\n flag = True\n break\nif flag:\n print('NEGATIVE CYCLE')\nelse:\n for line in ans:\n line = ['INF' if tmp == INF else tmp for tmp in line]\n print(*line)\n\n", "jacc_sim": 0.9666666666666667, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [321, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u871901071", "n_user": "u871901071", "pos": "import sys\n\ninf = int(1e12)\n\ndef shortestPath(graph):\n n = len(graph)\n dist = [[inf for _ in range(n)] for _ in range(n)]\n for i in range(n):\n dist[i][i] = 0\n \n for v in range(n):\n for u, cost in graph[v]:\n dist[v][u] = cost\n\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if dist[i][k] != inf and dist[k][j] != inf:\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n \n return dist\n\ndef main():\n v, e = map(int, input().split())\n \n graph = [[] for _ in range(v)]\n \n for i in range(e):\n a, b, cost = map(int, input().split())\n graph[a].append((b, cost))\n \n dist_mat = shortestPath(graph)\n\n for i in range(v):\n if dist_mat[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n return\n\n for i in range(v):\n output = []\n for j in range(v):\n if dist_mat[i][j] >= inf:\n output.append(\"INF\")\n else:\n output.append(str(dist_mat[i][j]))\n print(\" \".join(output))\n\nmain()", "neg": "import sys\n\ninf = int(1e12)\n\ndef shortestPath(graph):\n n = len(graph)\n dist = [[inf for _ in range(n)] for _ in range(n)]\n for i in range(n):\n dist[i][i] = 0\n \n for v in range(n):\n for u, cost in graph[v]:\n dist[v][u] = cost\n\n for k in range(n):\n for i in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n \n return dist\n\ndef main():\n v, e = map(int, input().split())\n \n graph = [[] for _ in range(v)]\n \n for i in range(e):\n a, b, cost = map(int, input().split())\n graph[a].append((b, cost))\n \n dist_mat = shortestPath(graph)\n\n for i in range(v):\n output = []\n for j in range(v):\n if dist_mat[i][j] >= inf:\n output.append(\"INF\")\n else:\n output.append(str(dist_mat[i][j]))\n print(\" \".join(output))\n\nmain()", "jacc_sim": 0.9122807017543859, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [385, 328], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u400336986", "n_user": "u400336986", "pos": "nv, ne = map(int, input().split(' '))\nedges = []\nfor i in range(ne):\n s, t, w = map(int, input().split(' '))\n edges.append((s, t, w))\n\ndist = [[float('inf')] * nv for i in range(nv)]\nfor i in range(nv):\n dist[i][i] = 0\nfor s, t, w in edges:\n dist[s][t] = w\n\nfor k in range(nv):\n for i in range(nv):\n for j in range(nv):\n if dist[i][j] > dist[i][k] + dist[k][j]:\n dist[i][j] = dist[i][k] + dist[k][j]\n\nfor i in range(nv):\n if dist[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n exit()\n\nfor row in dist:\n print(' '.join(str(d) if d < float('inf') else 'INF' for d in row))", "neg": "nv, ne = map(int, input().split(' '))\nedges = []\nfor i in range(ne):\n s, t, w = map(int, input().split(' '))\n edges.append((s, t, w))\n\ndist = [[float('inf')] * nv for i in range(nv)]\nfor i in range(nv):\n dist[i][i] = 0\nfor s, t, w in edges:\n dist[s][t] = w\n\nfor k in range(nv):\n for i in range(nv):\n for j in range(nv):\n if dist[i][j] > dist[i][k] + dist[k][j]:\n dist[i][j] = dist[i][k] + dist[k][j]\n\nfor i in range(nv):\n if dist[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n exit()\n\n[print(' '.join(map(str, dist[i]))) for i in range(nv)]", "jacc_sim": 0.9111111111111111, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [253, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u798803522", "n_user": "u798803522", "pos": "from collections import defaultdict\n\nvertice,edge = map(int,input().split(\" \"))\ncost = [[0 if m == n else float(\"inf\") for n in range(vertice)] for m in range(vertice)]\nlink = defaultdict(dict)\nweight = defaultdict(dict)\n\nfor e in range(edge):\n i,j,w = map(int,input().split(\" \"))\n link[i] = link.get(i,set()) | {j}\n weight[i].update({j:w})\n\nvertice_cnt = 0\nwhile 1:\n if vertice_cnt >= vertice:\n print(\"NEGATIVE CYCLE\")\n break\n update = False\n for source in range(vertice):\n for k,value in link.items():\n for v in value:\n if cost[source][v] > cost[source][k] + weight[k][v]:\n cost[source][v] = cost[source][k] + weight[k][v]\n update = True\n if not update:\n for o in range(vertice):\n\n print(*([n if n != float(\"INF\") else \"INF\" for n in cost[o]]))\n break\n vertice_cnt += 1", "neg": "from collections import defaultdict\n\nvertice,edge = map(int,input().split(\" \"))\ncost = [[0 if m == n else float(\"inf\") for n in range(vertice)] for m in range(vertice)]\nlink = defaultdict(dict)\nweight = defaultdict(dict)\n\nfor e in range(edge):\n i,j,w = map(int,input().split(\"\"))\n link[i] = link.get(i,set()) | {j}\n weight[i].update({j:w})\n\nvertice_cnt = 0\nwhile 1:\n if vertice_cnt >= vertice:\n print(\"NEGATIVE CYCLE\")\n break\n update = False\n for source in range(vertice):\n for k,value in link.items():\n for v in value:\n if cost[source][v] > cost[source][k] + weight[k][v]:\n cost[source][v] = cost[source][k] + weight[k][v]\n update = True\n if not update:\n for o in range(vertice):\n\n print(*([n if n != float(\"INF\") else \"INF\" for n in cost[o]]))\n break\n vertice_cnt += 1", "jacc_sim": 1.0, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [294, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u798803522", "n_user": "u798803522", "pos": "from collections import defaultdict\nvertices, edges = (int(n) for n in input().split(\" \"))\nconnect = defaultdict(list)\ncost_dp = [[float(\"inf\") if n != m else 0 for n in range(vertices)] for m in range(vertices)]\nfor e in range(edges):\n v1, v2, weight = (int(n) for n in input().split(\" \"))\n connect[v1].append([v2,weight])\n connect[v2].append([v1,weight])\n cost_dp[v1][v2] = weight\nfor neg in range(2):\n updated = 0\n for t in range(vertices):\n for i in range(vertices):\n for k in range(vertices):\n if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:\n updated = 1\n cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]\nif neg == 1 and updated:\n print(\"NEGATIVE CYCLE\")\nelse:\n for ve in range(vertices):\n ans = [\"INF\" if n == float(\"inf\") else n for n in cost_dp[ve]]\n print(*ans)", "neg": "from collections import defaultdict\nvertices, edges = (int(n) for n in input().split(\" \"))\nconnect = defaultdict(list)\ncost_dp = [[float(\"inf\") if n != m else 0 for n in range(vertices)] for m in range(vertices)]\nfor e in range(edges):\n v1, v2, weight = (int(n) for n in input().split(\" \"))\n connect[v1].append([v2,weight])\n connect[v2].append([v1,weight])\n cost_dp[v1][v2] = weight\nfor neg in range(2):\n updated = 0\n for t in range(vertices):\n for i in range(vertices):\n for k in range(vertices):\n if cost_dp[i][k] > cost_dp[i][t] + cost_dp[t][k]:\n updated = 1\n cost_dp[i][k] = cost_dp[i][t] + cost_dp[t][k]\nif neg == 1 and updated:\n print(\"NEGATIVE CYCLE\")\nelse:\n for ve in range(vertices):\n ans = [\"INF\" if n == float(\"inf\") else n for n in cost_dp[ve]]\n print(*ans)\n break", "jacc_sim": 0.9818181818181818, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [296, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u855199458", "n_user": "u855199458", "pos": "# -*- coding: utf-8 -*-\ndef inpl(): return tuple(map(int, input().split()))\n \nINF = float(\"inf\")\n \nV, E = inpl()\nadj = [[] for _ in range(V)]\nD = [[INF]*V for _ in range(V)]\n \nfor _ in range(E):\n s, t, d = inpl()\n D[s][t] = d\n \nfor v in range(V):\n D[v][v] = 0 \n\ndef WarshallFloyd(G):\n V = len(G)\n for k in range(V):\n for i in range(V):\n for j in range(V):\n G[i][j] = min(G[i][j], G[i][k] + G[k][j])\n return G\n\nD = WarshallFloyd(D)\n\nfor v in range(V):\n if D[v][v] < 0:\n print(\"NEGATIVE CYCLE\")\n break\nelse:\n for d in range(V):\n print(\" \".join(map(str, D[d])).replace(\"inf\", \"INF\"))\n", "neg": "# -*- coding: utf-8 -*-\ndef inpl(): return tuple(map(int, input().split()))\n \nINF = float(\"inf\")\n \nV, E = inpl()\nadj = [[] for _ in range(V)]\nD = [[INF]*V for _ in range(V)]\n \nfor _ in range(E):\n s, t, d = inpl()\n D[s][t] = d\n \nfor v in range(V):\n D[v][v] = 0 \n\ndef WarshallFloyd(G):\n V = len(G)\n for k in range(V):\n for i in range(V):\n for j in range(V):\n G[i][j] = min(G[i][j], G[i][k] + G[k][j])\n return G\n\nD = WarshallFloyd(D)\n\nfor v in range(V):\n if D[v][v] < 0:\n print(\"NEGATIVE CYCE\")\n break\nelse:\n for d in range(V):\n print(\" \".join(map(str, D[d])).replace(\"inf\", \"INF\"))\n", "jacc_sim": 0.9661016949152542, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [287, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02363", "p_user": "u464296040", "n_user": "u464296040", "pos": "import queue\nimport math\n\n\ndef warshall(graph, n):\n for i in range(n):\n graph[i][i] = 0\n\n for k in range(n):\n for i in range(n):\n for j in range(n):\n graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])\n\n return graph\n\n\ndef main():\n n, m = map(int, input().split())\n graph = [[float('inf') for _ in range(n)] for _ in range(n)]\n\n for _ in range(m):\n data = list(map(int, input().split()))\n\n graph[data[0]][data[1]] = data[2]\n\n dist = warshall(graph, n)\n\n for i in range(n):\n if dist[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n return\n\n for i in range(n):\n for j in range(n):\n\n if j == 0:\n print(dist[i][j] if dist[i][j] != float('inf') else 'INF', end=\"\")\n else:\n print(' {}'.format(dist[i][j] if dist[i][j] != float('inf') else 'INF'), end=\"\")\n\n print()\n\n return\n\n\nif __name__ == '__main__':\n main()\n\n", "neg": "import queue\nimport math\n\n\ndef warshall(graph, n):\n for i in range(n):\n graph[i][i] = 0\n\n for k in range(n):\n for i in range(n):\n for j in range(n):\n graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])\n\n return graph\n\n\ndef main():\n n, m = map(int, input().split())\n graph = [[float('inf') for _ in range(n)] for _ in range(n)]\n\n for _ in range(m):\n data = list(map(int, input().split()))\n\n graph[data[0]][data[1]] = data[2]\n\n dist = warshall(graph, n)\n\n for i in range(n):\n if dist[i][i] < 0:\n print(\"NEGATIVE CYCLE\")\n return\n\n for y in dist:\n for x in y:\n print('{} '.format(x if x != float('inf') else 'INF'), end=\"\")\n print()\n\n return\n\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 0.9642857142857143, "nl": "Title: All Pairs Shortest Path\n\nInput:\nAn edge-weighted graph G (V, E), where |V| is the number of vertices and |E| is the number of edges in G. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively. si and ti represent source and target vertices of i-th edge (directed) and di represents the cost of the i-th edge.\n\nOutput:\nIf the graph contains a negative cycle, print \"NEGATIVE CYCLE\" in a line. Otherwise, print the cost of the shortest path from vertex i to each vertex j. If there is no path from vertex i to vertex j, print \"INF\". The output consists of |V| lines.\n\nConstraints:\n- 1 \u2264 |V| \u2264 100\n- 0 \u2264 |E| \u2264 9900\n- -2 \u00d7 10^7 \u2264 di \u2264 2 \u00d7 10^7\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 1:\n0 1 3 4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 2:\n4 6\n0 1 1\n0 2 -5\n1 2 2\n1 3 4\n2 3 1\n3 2 7\n\nSample Output 2:\n0 1 -5 -4\nINF 0 2 3\nINF INF 0 1\nINF INF 7 0\n\nSample Input 3:\n4 6\n0 1 1\n0 2 5\n1 2 2\n1 3 4\n2 3 1\n3 2 -7\n\nSample Output 3:\nNEGATIVE CYCLE", "before_after_length": [351, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02364", "p_user": "u855775311", "n_user": "u855775311", "pos": "import sys\n\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.p = [i for i in range(n + 5)]\n self.rank = [0 for i in range(n + 5)]\n\n def find_set(self, x):\n if self.p[x] != x:\n self.p[x] = self.find_set(self.p[x])\n return self.p[x]\n\n def unite(self, x, y):\n px, py = self.find_set(x), self.find_set(y)\n if px == py:\n return\n if self.rank[px] > self.rank[py]:\n self.p[py] = px\n else:\n self.p[px] = py\n if self.rank[px] == self.rank[py]:\n self.rank[py] += 1\n\n\ndef main():\n sys.setrecursionlimit(int(1e5))\n nvertices, nedges = map(int, input().split())\n E = []\n uf = UnionFind(nvertices)\n for i in range(nedges):\n s, t, w = map(int, input().split())\n E.append((w, s, t))\n E.sort()\n\n ans = 0\n for w, s, t in E:\n if uf.find_set(s) != uf.find_set(t):\n ans += w\n uf.unite(s, t)\n\n print(ans)\n\n\nmain()", "neg": "import sys\n\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.p = [i for i in range(n + 5)]\n self.rank = [0 for i in range(n + 5)]\n\n def find_set(self, x):\n if self.p[x] != x:\n self.p[x] = self.find_set(self.p[x])\n return self.p[x]\n\n def unite(self, x, y):\n px, py = self.find_set(x), self.find_set(y)\n if px == py:\n return\n if self.rank[px] > self.rank[py]:\n self.p[y] = px\n else:\n self.p[x] = py\n if self.rank[px] == self.rank[py]:\n self.rank[py] += 1\n\n\ndef main():\n sys.setrecursionlimit(int(1e5))\n nvertices, nedges = map(int, input().split())\n E = []\n uf = UnionFind(nvertices)\n for i in range(nedges):\n s, t, w = map(int, input().split())\n E.append((w, s, t))\n E.sort()\n for e in E:\n print(e)\n ans = 0\n for w, s, t in E:\n if uf.find_set(s) != uf.find_set(t):\n ans += w\n uf.unite(s, t)\n\n print(ans)\n\n\nmain()", "jacc_sim": 0.9824561403508771, "nl": "Title: Minimum Spanning Tree\n\nFind the sum of weights of edges of the Minimum Spanning Tree for a given weighted undirected graph G = (V, E).\n\nInput:\n|V| |E|\ns0 t0 w0\ns1 t1 w1\n...\ns|E|-1 t|E|-1 w|E|-1\n\nWhere |V| is the number of vertices and |E| is the number of edges in the graph. The graph vertices are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target vertices of i-th edge (undirected) and wi represents the weight of the i-th edge.\n\nOutput:\nPrint the sum of the weights of the Minimum Spanning Tree.\n\nConstraints:\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 100,000\n- 0 \u2264 wi \u2264 10,000\n- The graph is connected\n- There are no parallel edges\n- There are no self-loops\n\nSample Input 1:\n4 6\n0 1 2\n1 2 1\n2 3 1\n3 0 1\n0 2 3\n1 3 5\n\nSample Output 1:\n3\n\nSample Input 2:\n6 9\n0 1 1\n0 2 3\n1 2 1\n1 3 7\n2 4 1\n1 4 3\n3 4 1\n3 5 1\n4 5 6\n\nSample Output 2:\n5", "before_after_length": [390, 402], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n n = int(input())\n ans = n * (n + 1) * (n + 2) // 6\n \n for i in range(n-1):\n x, y = map(int, input().split())\n if x > y:\n y, x = x, y\n ans -= x * (n - y + 1)\n print(ans)\n \nmain()\n", "neg": "def main() {\n n = int(input())\n ans = n * (n + 1) * (n + 2) // 6;\n for i in range(n):\n x, y = map(int, input().split())\n if (x > y) { y, x = x, y; }\n ans -= x * (n - y + 1);\n }\n print(ans);\n}\nmain()", "jacc_sim": 0.9090909090909091, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [98, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u623687794", "n_user": "u623687794", "pos": "n = int(input())\nans = n*(n+1)*(n+2)//6\n\nfor i in range(n-1):\n L,R = map(int,input().split())\n if L>R:L,R=R,L\n ans -= L*(n-R+1)\nprint(ans)", "neg": "n = int(input())\nans = n*(n+1)*(n+2)//6\nfor i in range(n-1):\n L,R = map(int,input().split())\n ans -= L*(n-R+1)\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [78, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u970308980", "n_user": "u970308980", "pos": "N = int(input())\nV = 0\nE = 0\nfor i in range(N+1):\n V += i * (N-i+1)\nfor i in range(N-1):\n a, b = map(int, input().split())\n if a > b:\n a, b = b, a\n E += a * (N-b+1)\nans = V - E\nprint(ans)\n", "neg": "N = int(input())\nV = 0\nE = 0\nfor i in range(N+1):\n V += i * (N-i+1)\nfor i in range(N):\n a, b = map(int, input().split())\n if a > b:\n a, b = b, a\n E += a * (N-b+1)\nans = V - E\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [102, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u571331348", "n_user": "u571331348", "pos": "# coding: utf-8\n\nn = int(input())\n\nans = 0\n\nfor i in range(1,n+1): #\u9802\u70b9\u6570\u306e\u7dcf\u548c\u3092\u6c42\u3081\u308b\n ans += i*(n-i+1)\n #print(ans)\n\nfor _ in range(n-1): #\u5404\u8fba\u306b\u3064\u3044\u3066u*(n-v+1)\u3092\u9802\u70b9\u6570\u306e\u7dcf\u548c\u304b\u3089\u5f15\u304f\n u,v = map(int, input().split())\n if u > v: #\u4e0a\u8a18\u3067\u306fuv\u306e\u3068\u304du\u3068v\u3092\u5165\u308c\u66ff\u3048\u308b\n u,v = v,u\n ans -= u*(n-v+1)\n #print(ans)\nprint(ans)", "neg": "n = int(input())\n\nans = 0\n\nfor i in range(1,n+1): #\u9802\u70b9\u6570\u306e\u7dcf\u548c\u3092\u6c42\u3081\u308b\n ans += i*(n-i+1)\n print(ans)\n\nfor _ in range(n-1): #\u5404\u8fba\u306b\u3064\u3044\u3066u*(n-v+1)\u3092\u9802\u70b9\u6570\u306e\u7dcf\u548c\u304b\u3089\u5f15\u304f\n u,v = map(int, input().split())\n if u > v: #\u4e0a\u8a18\u3067\u306fuv\u306e\u3068\u304du\u3068v\u3092\u5165\u308c\u66ff\u3048\u308b\n u,v = v,u\n ans -= u*(n-v+1)\n print(ans)\nprint(ans)", "jacc_sim": 0.9538461538461539, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [285, 275], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u017271745", "n_user": "u017271745", "pos": "n = int(input())\nans = n*(n+1)*(n+2)//6\nfor i in range(n-1):\n a, b = map(int, input().split())\n if b < a:\n a, b = b, a\n ans -= a*(n-b+1)\nprint(ans)\n", "neg": "n = int(input())\nans = n*(n+1)*(n+2)//6\nfor i in range(n):\n a, b = map(int, input.split())\n ans -= a*(n-b+1)\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [80, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u197457087", "n_user": "u197457087", "pos": "N = int(input())\nes = [[] for _ in range(N)]\nH = []\nfor i in range(N-1):\n a,b = map(int,input().split())\n if a > b:\n a,b = b,a\n a-=1;b-=1\n #es[a].append(b)\n #es[b].append(a)\n H.append([a,b])\n\nten = N*(N+1)*(N+2)//6\nhen = 0\nfor i in range(N-1):\n p,q = H[i]\n hen += (p+1)*(N-1-q+1)\nans = ten -hen\nprint(ans)", "neg": "N = int(input())\nes = [[] for _ in range(N)]\nH = []\nfor i in range(N-1):\n a,b = map(int,input().split())\n if a > b:\n a,b = b,a\n a-=1;b-=1\n #es[a].append(b)\n #es[b].append(a)\n H.append([a,b])\nprint(es)\n\nten = N*(N+1)*(N+2)//6\nhen = 0\nfor i in range(N-1):\n p,q = H[i]\n hen += (p+1)*(N-1-q+1)\nans = ten -hen\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [178, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u242757684", "n_user": "u242757684", "pos": "# Fast IO (only use in integer input) or take care about string\n \nimport os,io\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n \nN = int(input())\n \nans = 0\nfor i in range(N):\n ans += (N-i) * (i+1)\nfor _ in range(N-1):\n a,b = map(int,input().split())\n if a > b:\n c = a\n a = b\n b = c\n ans -= a * (N - b + 1)\nprint(ans)", "neg": "# Fast IO (only use in integer input) or take care about string\n\nimport os,io\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nN = int(input())\n\nAns = 0\nfor i in range(N):\n Ans += (N-i) * (i+1)\nfor _ in range(N-1):\n a,b = map(int,input().split())\n if a > b:\n c = a\n a = b\n b = c\n ans -= a * (n - b + 1)\nprint(ans)", "jacc_sim": 0.9591836734693877, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [152, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u937642029", "n_user": "u937642029", "pos": "n=int(input())\nans=n*(n+1)*(n+2)//6\nfor i in range(n-1):\n u=list(map(int,input().split()))\n ans-=min(u)*(n-max(u)+1)\nprint(ans)", "neg": "n=int(input())\nans=n*(n+1)*(n+2)//6\nfor i in range(n-1):\n u=map(int,input().split())\n ans-=min(u)*(n-max(u)+1)\nprint(ans)", "jacc_sim": 0.9642857142857143, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [70, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02617", "p_user": "u937642029", "n_user": "u248996551", "pos": "n = int(input())\nans = n*(n+1)*(n+2)//6\nfor i in range(n-1):\n u,v = map(int,input().split())\n if u > v:\n u,v = v,u\n ans -= u*(n-v+1)\nprint(ans)", "neg": "n=int(input())\nans=0\nfor i in range(1,n+1):\n ans += i*(i+1)/2\nfor i in range(n-1):\n u,v=map(int,input().split())\n if u > v:\n u,v=v,u\n ans -= u*(n-v+1)\nprint(ans)", "jacc_sim": 0.9310344827586207, "nl": "You are given a tree with N vertices and N-1 edges. Each edge connects two vertices. Define a function f(L, R) as the number of connected components in a subgraph formed from the vertex set S and edges whose endpoints belong to S. Compute the sum of f(L, R) for all pairs (L, R) where 1 \u2264 L \u2264 R \u2264 N. Constraints: 1 \u2264 N \u2264 2*10^5, 1 \u2264 u_i, v_i \u2264 N, and the given graph is a tree. Input format: N, followed by N-1 lines of u_i and v_i. Output the sum of f(L, R) for all pairs (L, R). Example: Input 3, then 1 3, 2 3. Output 7, as there are 6 possible pairs (L, R) with their respective connected components.", "before_after_length": [79, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u139216357", "n_user": "u139216357", "pos": "#\u5165\u529b\nD = int(input())\nC = [int(c) for c in input().split()]\nS = []\nfor _ in range(D):\n s = [int(x) for x in input().split()]\n S.append(s)\nT = []\nfor _ in range(D):\n t = int(input()) - 1\n T.append(t)\n \n#\u30b9\u30b3\u30a2\u8a08\u7b97\nscore = 0\nlast_day = [-1] * 26\nfor t in range(D):\n test = T[t]\n score += S[t][test]\n last_day[test] = t\n for i in range(26):\n score -= (C[i] * (t - last_day[i]))\n print(score)", "neg": "#\u5165\u529b\nD = int(input())\nC = [int(c) for c in input().split()]\nS = []\nfor _ in range(D):\n s = [int(x) for x in input().split()]\n S.append(s)\nT = []\nfor _ in range(D):\n t = int(input()) - 1\n T.append(t)\n \n\uff03\u30b9\u30b3\u30a2\u8a08\u7b97\nscore = 0\nlast_day = [-1] * 26\nfor t in range(D):\n test = T[t]\n score += S[t][test]\n last_day[test] = t\n for i in range(26):\n score -= (C * (t - last_day[i]))\n print(score)", "jacc_sim": 0.9767441860465116, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [200, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u753543081", "n_user": "u753543081", "pos": "import random\n\ndef down_score(d, c, last_d, score):\n sum = 0\n for i in range(26):\n sum = sum + c[i]*(d-last_d[i])\n \n return int(score - sum)\n\n\ndef main():\n D = int(input())\n\n c = list(map(int, input().split()))\n\n s = [list(map(int, input().split())) for i in range(D)]\n\n sche = []\n for i in range(D):\n x = int(input())\n sche.append(x)\n \n last_d = [0 for i in range(26)]\n score = 0\n \n for i in range(D):\n score += s[i][sche[i]-1]\n last_d[sche[i]-1] = i+1\n score = down_score(i+1, c, last_d, score)\n print(score)\n \nif __name__ == \"__main__\":\n main()\n", "neg": "def down_score(d, c, last_d, score):\n sum = 0\n for i in range(26):\n sum += c[i]*(d-last_d[i])\n \n return (score - sum)\n\n\ndef main():\n D = int(input())\n\n c = list(map(int, input().split()))\n\n s = [list(map(int, input().split())) for i in range(D)]\n\n sche = []\n for i in range(D):\n x = int(input())\n sche.append(x)\n \n last_d = [0 for i in range(26)]\n score = 0\n \n for i in range(D):\n score += s[i][sche[i]]\n last_d[sche[i]] = i+1\n score = down_score(i+1, c, last_d, score)\n print(score)\n \nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9545454545454546, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [260, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u274126492", "n_user": "u274126492", "pos": "\ndef read_input():\n D = int(input())\n C = input().split()\n C = [int(i) for i in C]\n S = [list(map(int, input().split())) for _ in range(D)]\n T = [int(input()) for _ in range(D)]\n return D, C, S, T\n\n\ndef scoring(S, D, T, C):\n res = []\n last = [0 for _ in range(26)]\n final = 0\n for i in range(D):\n dec = 0\n for j in range(26):\n for loc, val in enumerate(T[:i + 1]):\n if val == j + 1:\n last[j] = loc + 1\n dec += C[j] * (i - last[j] + 1)\n final += S[i][T[i] - 1] - dec\n res.append(final)\n return res\n\n\nD, C, S, T = read_input()\nres = scoring(S, D, T, C)\nfor x in res:\n print(x)\n", "neg": "\ndef read_input():\n D = int(input())\n C = input().split()\n C = [int(i) for i in C]\n S = [list(map(int, input().split())) for _ in range(D)]\n T = [int(input()) for _ in range(D)]\n return D, C, S, T\n\n\ndef scoring(S, D, T, C):\n res = []\n last = [0 for _ in range(26)]\n final = 0\n for i in range(D):\n dec = 0\n last[T[i] - 1] = i\n for j in range(26):\n dec += C[j] * (i - last[j] + 1)\n final += S[i][T[i] - 1] - dec\n res.append(final)\n return res\n\n\nD, C, S, T = read_input()\nres = scoring(S, D, T, C)\nfor x in res:\n print(x)\n", "jacc_sim": 0.9090909090909091, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [269, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u830054172", "n_user": "u830054172", "pos": "D = int(input())\nC = list(map(int, input().split()))\n\nS = [list(map(int, input().split())) for _ in range(D)]\n\ncontest = [0 for _ in range(26)]\nans = 0\n\nfor i in range(D):\n t = int(input())\n contest[t-1] = i+1\n ans += S[i][t-1]\n for j, con in enumerate(contest):\n if con:\n ans -= C[j]*(i+1-con)\n else:\n ans -= C[j]*(i+1)\n print(ans)", "neg": "D = int(input())\nC = list(map(int, input().split()))\n\nS = [list(map(int, input().split())) for _ in range(D)]\n\ncontest = [0 for _ in range(26)]\nans = 0\n\nfor i in range(D):\n t = int(input())\n contest[t-1] += i+1\n ans += S[i][t-1]\n for j, con in enumerate(contest):\n if con:\n ans -= C[j]*(i+1-con)\n else:\n ans -= C[j]*(i+1)\n print(ans)", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [158, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u634461820", "n_user": "u634461820", "pos": "import sys\nimport math\nfrom collections import deque\nimport heapq\nimport itertools\nfrom decimal import Decimal\nimport bisect\nfrom operator import itemgetter\nMAX_INT = int(10e18)\nMIN_INT = -MAX_INT\nmod = 1000000000+7\nsys.setrecursionlimit(1000000)\ndef IL(): return list(map(int,input().split()))\ndef SL(): return input().split()\ndef I(): return int(sys.stdin.readline())\ndef S(): return input()\n\ndef tami(date, LastDay, type, score):\n res = score\n res += s[date-1][type]\n for i in range(26):\n if i == type:\n continue\n res -= (date - LastDay[i]) *c[i]\n return res\n\nD = I()\nc = IL()\ns = [IL() for i in range(D)]\nans = [I() for i in range(D)]\n\nLastDay = [0]*26\nscore = 0\nfor d in range(D):\n score = tami(d+1, LastDay, ans[d]-1, score)\n LastDay[ans[d]-1] = d+1\n print(score)", "neg": "import sys\nimport math\nfrom collections import deque\nimport heapq\nimport itertools\nfrom decimal import Decimal\nimport bisect\nfrom operator import itemgetter\nMAX_INT = int(10e18)\nMIN_INT = -MAX_INT\nmod = 1000000000+7\nsys.setrecursionlimit(1000000)\ndef IL(): return list(map(int,input().split()))\ndef SL(): return input().split()\ndef I(): return int(sys.stdin.readline())\ndef S(): return input()\n\ndef tami(date, LastDay, type, score):\n res = score\n res += s[date-1][type-1]\n for i in range(26):\n if i == type-1:\n continue\n res -= (date - LastDay[i]) *c[i]\n return res\n\nD = I()\nc = IL()\ns = [IL() for i in range(D)]\nans = [I() for i in range(D)]\n\nLastDay = [0]*26\nscore = 0\nfor d in range(D):\n score = tami(d+1, LastDay, ans[d], score)\n LastDay[ans[d]-1] = d+1\n print(max(0, 10**6 + score))", "jacc_sim": 0.9571428571428572, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [291, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u036340997", "n_user": "u036340997", "pos": "D = int(input())\nc = list(map(int, input().split()))\ns = [[]]\nfor _ in range(D):\n s.append(list(map(int, input().split())))\n\nlasts = [0 for i in range(len(c))]\nans = 0\nfor d in range(1, D+1):\n t = int(input()) - 1\n lasts[t] = d\n ans += s[d][t]\n for i in range(len(c)):\n ans -= c[i] * (d - lasts[i])\n print(ans)", "neg": "D = map(int, input().split())\nc = list(map(int, input().split()))\ns = []\nfor _ in range(D):\n s.append(list(map(int, input().split())))\n\nlasts = [0 for i in range(len(c))]\nans = 0\nfor d in range(1, D+1):\n t = int(input()) - 1\n lasts[t] = d\n ans += s[d][t]\n for i in range(len(c)):\n ans -= c[i] * (d - lasts[i])\nprint(ans)", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [148, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u174181999", "n_user": "u174181999", "pos": "import copy\nD = int(input())\nc = list(map(int, input().split()))\ns = []\nfor _ in range(D):\n s.append(list(map(int, input().split())))\nt = []\nfor _ in range(D):\n t.append(int(input()))\nu = [] # last(d,i)\nx = [0] * 26\nu.append(x)\nfor i in range(D):\n v = copy.deepcopy(u)\n y = v[-1]\n y[t[i]-1] = i+1\n u.append(y)\ndel u[0]\n\nans = 0\nfor i in range(D):\n ans += s[i][t[i]-1]\n for j in range(26):\n ans -= c[j] * ((i+1) - u[i][j]) \n print(ans)\n", "neg": "import copy\nD = int(input())\nc = list(map(int, input().split()))\ns = []\nfor _ in range(D):\n s.append(list(map(int, input().split())))\nt = []\nfor _ in range(D):\n t.append(int(input()))\nu = [] # last(d,i)\nx = [0] * 26\nu.append(x)\nfor i in range(D):\n v = copy.deepcopy(u)\n y = v[-1]\n y[t[i]-1] = i+1\n u.append(y)\ndel u[0]\nprint(D)\nprint(c)\nprint(s)\nprint(t)\nprint(u)\nans = 0\nfor i in range(D):\n ans += s[i][t[i]-1]\n for j in range(26):\n ans -= c[j] * ((i+1) - u[i][j]) \n print(ans)", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [222, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u766566560", "n_user": "u766566560", "pos": "D = int(input())\nclist = list(map(int, input().split()))\nslist = [list(map(int, input().split())) for _ in range(D)]\ntlist = [int(input()) for _ in range(D)]\nzlist = []\ndlist = [0] * 26\nans = 0\n'''\nprint(sum(clist))\nprint('--------------')\nprint(slist[0][0])\nprint(slist[1][16])\nprint(clist[16])\n\nprint('--------------')\n'''\nfor i in range(D):\n #print(slist[i],tlist[i]-1)\n zlist.append(clist[tlist[i]-1] * ((i+1) - dlist[tlist[i]-1]))\n dlist[tlist[i]-1] = i+1\n ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + sum(zlist)\n print(ans)", "neg": "D = int(input())\nclist = list(map(int, input().split()))\nslist = [list(map(int, input().split())) for _ in range(D)]\ntlist = [int(input()) for _ in range(D)]\nzlist = []\nans = 0\n'''\nprint(sum(clist))\nprint('--------------')\nprint(slist[0][0])\nprint(slist[1][16])\nprint(clist[16])\n\nprint('--------------')\n'''\nfor i in range(D):\n #print(slist[i],tlist[i]-1)\n zlist.append(clist[tlist[i]-1] * (i+1))\n ans += slist[i][tlist[i]-1] - ((i+1) * sum(clist)) + sum(zlist)\n print(ans)", "jacc_sim": 0.9459459459459459, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [249, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u364027015", "n_user": "u364027015", "pos": "D=int(input())\nC=list(map(int,input().split()))\nS=list()\nfor i in range(D):\n S.append(list(map(int,input().split())))\nt=list()\nfor i in range(D):\n t.append(int(input()))\n\nM=0\ndi=[0]*26\nfor d in range(D):\n for i in range(26):\n if i==t[d]-1:\n di[i]=0\n else:\n di[i]+=1\n M+=S[d][t[d]-1]\n for i in range(26):\n M-=C[i]*(di[i])\n print(M)", "neg": "D=int(input())\nC=list(map(int,input().split()))\nimport sys\nS=list()\nfor i in range(D):\n S.append(list(map(int,input().split())))\nt=list()\nfor i in range(D):\n t.append(int(input()))\n\nM=0\ndi=[0]*26\nfor d in range(D):\n for i in range(26):\n if i==t[d]-1:\n di[i]=0\n else:\n di[i]+=1\n M+=S[d][t[d]-1]\n for i in range(26):\n M-=C[i]*(d+1-di[i])\n print(M)", "jacc_sim": 0.9444444444444444, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [179, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u153499445", "n_user": "u153499445", "pos": "D=int(input())\nc=[int(x) for x in input().split()]\ns=[[0]*i for i in range(D)]\nt=[]\nlast_d=[0]*26\nfor i in range(D):\n s[i]=[int(x) for x in input().split()]\nfor i in range(D):\n t.append(int(input()))\n\nv=0\nfor i in range(D):\n a=0\n for j in range(26):\n if j!=t[i]-1:\n n=i+1-last_d[j]\n a+=c[j]*n\n v=v+s[i][t[i]-1]-a\n print(v)\n last_d[t[i]-1]=i+1", "neg": "D=int(input())\nc=[int(x) for x in input().split()]\ns=[[0]*i for i in range(D)]\nt=[]\nlast_d=[0]*26\nfor i in range(D):\n s[i]=[int(x) for x in input().split()]\nfor i in range(D):\n t.append(int(input()))\n\nv=0\nC=sum(c)\nprint(C)\nfor i in range(D):\n a=0\n for j in range(26):\n if j!=t[i]-1:\n n=i+1-last_d[j]\n a+=c[j]*n\n v=v+s[i][t[i]-1]-a\n print(v)\n last_d[t[i]-1]=i+1", "jacc_sim": 0.9444444444444444, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [199, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u900548304", "n_user": "u900548304", "pos": "import numpy as np\n\n\nD = int(input())\nc = np.array(list( map(int,input().split())))\nS = np.zeros((D,26))\nfor i in range(D):\n S[i] = np.array(list( map(int,input().split())))\n\nT = np.array([])\nfor i in range(D):\n T = np.append(T,int(input()))\n\n\"\"\"\nD = 365\nc = np.random.randint(0,100,size=(26))\nS = np.random.randint(0,20000,size=(D,26))\n\"\"\"\n\ndef calc_score(T,D,c,S):\n last = np.ones(26) * (-1)\n scores = []\n score = 0\n for d in range(D):\n i = int(T[d])-1\n score += S[d,i]\n last[i] = d\n score -= np.sum(c*(d-last))\n scores.append(score)\n score = max([10**6+score,0])\n return score,scores\n\n_,ans = calc_score(T,D,c,S)\nfor a in ans:\n print(int(a))", "neg": "import numpy as np\n\n\nD = int(input())\nc = np.array(list( map(int,input().split())))\nS = np.zeros((D,26))\nfor i in range(D):\n S[i] = np.array(list( map(int,input().split())))\n\nT = np.array([])\nfor i in range(D):\n T = np.append(T,int(input()))\n\n\"\"\"\nD = 365\nc = np.random.randint(0,100,size=(26))\nS = np.random.randint(0,20000,size=(D,26))\n\"\"\"\n\ndef calc_score(T,D,c,S):\n last = np.ones(26) * (-1)\n scores = []\n score = 0\n for d in range(D):\n i = int(T[d])\n score += S[d,i]\n last[i] = d\n score -= np.sum(c*(d-last))\n scores.append(max([10**6+score,0]))\n score = max([10**6+score,0])\n return score,scores\n\n_,ans = calc_score(T,D,c,S)\nfor a in ans:\n print(int(a))", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [304, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u272682534", "n_user": "u272682534", "pos": "D=int(input())\n*c,=map(int,input().split())\n# for Greedy\nci=[(c[i-1],i) for i in range(1,27)]\nci=[(0,0)]+ci\n# ci=[(0,0)]+sorted(ci,reverse=True)\n\nlast=[[0]*27]*(D+1)\nS=[[0]*27]*(D+1)\nDP=[[0]*27]*(D+1)\nT=[0]*(D+1)\n\nfor d in range(1,D+1):\n *S[d],=map(int,input().split())\n S[d]=[0]+S[d]\n \nfor d in range(1,D+1):\n T[d] = int(input())\n\ndef do_id(i,d):\n dn=0\n last[d][i]=d \n for k in range(1,27):\n if k!=i:\n dn += ci[k][0]*(d-last[d][k])\n return S[d][i]-dn\n\nSatis=0 \nfor d in range(1,D+1):\n Satis+=do_id(T[d],d)\n print(Satis)\n \ndef cal(): \n for d in range(1,D+1):\n mxid=0\n mxi,mxd=0,0\n for i in range(1,27):\n tc,ti=ci[i]\n doid=do_id(ti,d)\n if doid>mxid:\n mxid=doid\n mxi,mxd=ti,d\n DP[mxd][mxi]=mxid \n last[mxd][mxi]=d\n print(DP) \n \n\n", "neg": "D=int(input())\n*c,=map(int,input().split())\n\nci=[(c[i-1],i) for i in range(1,27)]\nci=[(0,0)]+sorted(ci,reverse=True)\n\nlast=[[0]*27]*(D+1)\nS=[[0]*27]*(D+1)\nDP=[[0]*27]*(D+1)\nT=[0]*(D+1)\n\nfor d in range(1,D+1):\n *S[d],=map(int,input().split())\n S[d]=[0]+S[d]\n \nfor d in range(1,D+1):\n T[d] = int(input())\n\ndef do_id(i,d):\n dn=0\n for k in range(1,27):\n if k!=i:\n dn += ci[k][0]*(d-last[d][k])\n return S[d][i]-dn\n\nSatis=0 \nfor d in range(1,D+1):\n Satis+=do_id(T[d],d)\n print(Satis)\n \ndef cal(): \n for d in range(1,D+1):\n mxid=0\n mxi,mxd=0,0\n for i in range(1,27):\n doid=do_id(i,d)\n if doid>mxid:\n mxid=doid\n mxi,mxd=i,d\n DP[mxd][mxi]=mxid \n last[mxd][mxi]=d\n print(DP) \n ", "jacc_sim": 0.9230769230769231, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [444, 405], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u912208257", "n_user": "u912208257", "pos": "D = int(input())\nc = list(map(int,input().split()))\ns = []\nfor i in range(D):\n s.append(list(map(int,input().split())))\nt = [int(input()) for _ in range(D)]\ndef my_index(l,x,d,default=False):\n if x in l:\n return l.index(x)\n else:\n return d\ndef last(d,i):\n a= t[:d]\n a.reverse()\n day = -1*(my_index(a,i,d))+d\n return day\nscore = 0\nfor d in range(1,D+1):\n score += s[d-1][t[d-1]-1]\n for i in range(1,27):\n score -= c[i-1]*(d-last(d,i))\n print(score)", "neg": "D = int(input())\nc = list(map(int,input().split()))\ns = []\nfor i in range(D):\n s.append(list(map(int,input().split())))\nt = [int(input()) for _ in range(D)]\ndef my_index(l, x, default=False):\n if x in l:\n return l.index(x)\n else:\n return -1\ndef last(d,i):\n a= t[:d]\n reversed(a)\n day = my_index(a,i)+1\n return day\nscore = 0\nfor d in range(1,D+1):\n score += s[d-1][t[d-1]-1]\n for i in range(1,27):\n score -= c[i-1]*(d-last(d,i))\n print(score)", "jacc_sim": 0.9574468085106383, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [220, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u537142137", "n_user": "u537142137", "pos": "import numpy as np\n\nD = int(input())\nc = np.array( list(map(int, input().split())) )\ns = [[] for i in range(365+1)]\nfor i in range(D):\n s[i] = np.array( list(map(int, input().split())) )\n#\nlast = np.array( [-1]*26 )\nav = np.array( [0]*26 )\nid = np.identity(4,dtype=int)\n\nv = 0\nfor d in range(D):\n av = s[d] - sum( c*(d-last) ) + c*(d-last) \n t = int(input())\n t -= 1\n last[t] = d\n v += av[t]\n print( v )\n#\n", "neg": "import numpy as np\n\nD = int(input())\nc = np.array( list(map(int, input().split())) )\ns = [[] for i in range(365+1)]\nfor i in range(D):\n s[i] = np.array( list(map(int, input().split())) )\n#\nlast = np.array( [-1]*26 )\nav = np.array( [0]*26 )\nid = np.identity(4,dtype=int)\n\nv = 0\nfor d in range(D):\n av = s[d] - sum( c*(d-last) ) + c*(d-last) \n t = int(input())\n t -= 1\n last[t] = d\n v += av[t]\n print(t+1, v )\n#\n", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [193, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u295148058", "n_user": "u295148058", "pos": "D = int(input())\nc_list = list(map(int,input().split(' ')))\ns_list = []\nfor i in range(D):\n s_list.append(list(map(int,input().split(' '))))\nt_list = []\nfor j in range(D):\n t_list.append(int(input()))\nlast_list = [0 for k in range(26)]\nscore = 0\npoint = 0\nfor day in range(D):\n point += s_list[day][t_list[day]-1]\n last_list[t_list[day]-1] = day+1\n for c in range(26):\n point -= c_list[c]*((day+1)-last_list[c])\n if(point>-1000000):\n score = point+1000000\n print(point)\n", "neg": "D = int(input())\nc_list = list(map(int,input().split(' ')))\ns_list = []\nfor i in range(d):\n s_list.append(list(map(int,input().split(' '))))\nt_list = []\nfor j in range(d):\n t_list.append(int(input()))\nlast_list = [0 for k in range(26)]\nscore = 0\nfor day in range(D):\n point = 0\n point += s_list[day][t_list[day]]\n last_list[t_list[day]] = day+1\n for c in c_list:\n point -= c*((day+1)-last_list[t_list[day]])\n if(point>1000000):\n score += point+1000000\nprint(score)\n", "jacc_sim": 0.975609756097561, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [208, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u981418135", "n_user": "u981418135", "pos": "d =int(input())\nc = list(map(int, input().split())) \ns = []\nt = []\n\nd_l = []\nscore = 0\nsoft = 0\n\nfor i in range(d):\n s.append(0)\n s[i] = list(map(int, input().split()))\n\nfor i in range(26):\n d_l.append(0)\n \nfor i in range(d):\n t = int(input())\n soft = 0\n \n for j in range(26):\n if t-1 == j:\n d_l[j] = 0\n score += s[i][j]\n else:\n d_l[j] += 1\n soft += c[j] * d_l[j]\n \n score -= soft\n print(score)\n \n ", "neg": "d =int(input())\nc = list(map(int, input().split())) \ns = []\nt = []\n\nd_l = []\nscore = 0\nsoft = 0\n\nfor i in range(d):\n s.append(0)\n s[i] = list(map(int, input().split()))\n\nfor i in range(26):\n d_l.append(0)\n \nfor i in range(d):\n t = int(input())\n soft = 0\n \n for j in range(26):\n if t-1 == j:\n d_l[j] = 0\n score = s[i][j]\n else:\n d_l[j] += 1\n soft += c[j] * d_l[j]\n \n score -= soft\n print(score)\n \n ", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [207, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u802234211", "n_user": "u802234211", "pos": "def complain(comp,c,k,last_hold,i):\n # print(k)\n if(k > 26):\n # print(\"___\")\n return comp\n comp += c[k-1]*((i+1) - last_hold[k-1]) \n k += 1\n # print(comp,\"comp\")\n return complain(comp,c,k,last_hold,i)\n\nD = int(input())\nc = list(map(int,input().split()))\ns = [\"_\"]*(D)\n# print(c)\nfor i in range(D):\n s[i] = list(map(int,input().split()))\nlast_hold = [0]*26\nscore = [0]*(D+1)\n\nfor i in range(D):\n score[i+1] += score[i]\n t = int(input())\n last_hold[t-1] = i+1\n comp = 0\n k = 1\n score[i+1] += s[i][t-1] \n # print(s[i][t-1],\"s\")\n comp = complain(comp,c,k,last_hold,i) \n score[i+1] -= comp\n # print(comp,\"comp\")\n # print(score[i+1],\"score\")\n\nfor i in range(D):\n print(score[i+1])\n\n# \u03a3(Ci * (d - last(d,i)))\n# (1~26)\n\n# 18398\n# 35037\n# 51140\n# 65837\n# 79325", "neg": "def complain(comp,c,k,last_hold):\n # print(k)\n if(k > 26):\n # print(\"___\")\n return comp\n comp += c[k-1]*((i+1) - last_hold[k-1]) \n k += 1\n # print(comp,\"comp\")\n return complain(comp,c,k,last_hold)\n\nD = int(input())\nc = list(map(int,input().split()))\ns = [\"_\"]*(D)\nprint(c)\nfor i in range(D):\n s[i] = list(map(int,input().split()))\nlast_hold = [0]*26\nscore = [0]*(D+1)\n\nfor i in range(D):\n score[i+1] += score[i]\n t = int(input())\n last_hold[t-1] = i+1\n comp = 0\n k = 1\n score[i+1] += s[i][t-1]\n # print(s[i][t-1],\"s\")\n score[i+1] -= complain(comp,c,k,last_hold)\nfor i in range(D):\n print(score[i+1])\n\n# \u03a3(Ci * (d - last(d,i)))\n# (1~26)\n", "jacc_sim": 0.9019607843137255, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [393, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u798890085", "n_user": "u798890085", "pos": "D = int(input())\nC = list(map(int, input().split()))\nS = list(list(map(int, input().split())) for i in range(D))\nT = list(int(input()) for i in range(D))\nmanzoku = 0\nyasumi= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n#1\u65e5\u76ee\nfor day in range(D):\n yasumi = list(map(lambda x: x + 1, yasumi))\n yasumi[T[day] - 1] = 0\n manzoku += S[day][T[day] - 1]\n for i in range(26):\n manzoku -= C[i] * yasumi[i]\n print(manzoku)", "neg": "D = int(input())\nC = list(map(int, input().split()))\nS = list(list(map(int, input().split())) for i in range(D))\nT = list(int(input()) for i in range(D))\nmanzoku = 0\nyasumi= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nprint(len(yasumi))\n#1\u65e5\u76ee\nfor day in range(D):\n yasumi = list(map(lambda x: x + 1, yasumi))\n yasumi[T[day] - 1] = 0\n manzoku += S[day][T[day] - 1]\n for i in range(26):\n manzoku -= C[i] * yasumi[i]\n print(manzoku)", "jacc_sim": 0.972972972972973, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [227, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u404629709", "n_user": "u723304131", "pos": "D=int(input())\nc=list(map(int,input().split()))\ns=[]\nt=[]\nv=0\nlastday=[0 for i in range(26)]\n\nfor i in range(D):\n tmp=list(map(int,input().split()))\n s.append(tmp)\nfor i in range(D):\n tmp=int(input())-1\n t.append(int(tmp))\n\nfor i in range(1,D+1):\n v+=s[i-1][t[i-1]]\n lastday[t[i-1]]=i\n for j in range(26):\n v-=c[j]*(i-lastday[j])\n print(v)", "neg": "D = int(input())\nc = list(map(int,input().split()))\ns = [ [0 for j in range(26)] for i in range(D)]\nfor i in range(D):\n tmp = list(map(int,input().split()))\n for j in range(26):\n s[i][j] = tmp[j]\nt = []\nfor i in range(D):\n t.append(int(input()))\n\n\nv = [0] * D\nlast = [ [0 for j in range(26)] for i in range(D)]\nsum = 0\nfor i in range(D):\n sum += s[i][t[i]-1]\n last[i][t[i]-1] = i+1\n for j in range(26):\n sum -= c[j] * ( (i+1) - last[i][j] )\n v[i] = sum\n\nfor i in range(D):\n print(v[i])", "jacc_sim": 0.9142857142857143, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [179, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u312078744", "n_user": "u312078744", "pos": "import sys\nimport numpy as np\nfrom operator import mul\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nd = int(readline())\nc = list(map(int, readline().split()))\ns = []\nfor _ in range(d):\n add = list(map(int, readline().split()))\n s.append(add)\n\n#t = [0] * d\nday = 0\nsatisfy = 0\nsumC = sum(c)\ncount = np.zeros(26)\n\nfor i in range(d):\n t = int(readline()) - 1\n up = s[day][t]\n count += 1\n count[t] = 0\n sub = map(mul, count, c)\n satisfy += (up - sum(sub))\n # satisfy\n print(int(satisfy))\n day += 1\n", "neg": "import sys\nimport numpy as np\nfrom operator import mul\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nd = int(readline())\nc = list(map(int, readline().split()))\ns = []\nfor _ in range(d):\n add = list(map(int, readline().split()))\n s.append(add)\n\n#t = [0] * d\nday = 0\nsatisfy = 0\nsumC = sum(c)\ncount = np.zeros(26)\n\nfor i in range(d):\n t = int(readline()) - 1\n up = s[day][t]\n count += 1\n count[t] = 0\n sub = map(mul, count, c)\n satisfy += (up - sum(sub))\n\n # satisfy\n print(satisfy)\n", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [227, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u347640436", "n_user": "u986025116", "pos": "D = int(input())\nc = list(map(int, input().split()))\ns = [list(map(int, input().split())) for _ in range(D)]\nt = [int(input()) - 1 for _ in range(D)]\n\nS = 0\nlast = [-1] * 26\nscore = 0\nfor d in range(D):\n S += s[d][t[d]]\n last[t[d]] = d\n for i in range(26):\n S -= c[i] * (d - last[i])\n score += max(10 ** 6 + S, 0)\n print(S)\n", "neg": "D = int(input())\nc = list(map(int,input().split()))\ns = [list(map(int,input().split())) for _ in range(D)]\nt = [int(input()) for _ in range(D)]\n\nS = 0\nlast = [-1]*26\nscore = 0;\nfor d in range(D):\n S += s[d][t[d]]\n last[t[d]] = d\n for i in range(26):\n S-=c[i]*(d - last[i])\n score +=max(10**6+S,0)\n print(S)\n", "jacc_sim": 0.972972972972973, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [152, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u171654347", "n_user": "u171654347", "pos": "d = int(input())\ncList = input().split()\n\nsList = []\n\nfor idx in range(0, d):\n tempList = input().split()\n sList.append(tempList)\n\ntList = []\n\nfor idx in range(0, d):\n tList.append(int(input()))\n\ncountList = [0] * 26\nval = 0\n\nfor idx in range(0, d):\n val += int(sList[idx][tList[idx] -1])\n\n countList = list(map(lambda x: x+1, countList))\n countList[int(tList[idx]) -1] = 0\n\n for wkChar in range(0,26):\n val -= int(countList[wkChar]) * int(cList[wkChar])\n print(val)\n\n\n", "neg": "d = int(input())\ncList = input().split()\n\nsList = []\n\nfor idx in range(0, d):\n tempList = input().split()\n sList.append(tempList)\n\ntList = []\n\nfor idx in range(0, d):\n tList.append(int(input()))\n\n\nprint(sList)\nprint(tList)\n\ncountList = [0] * 26\nval = 0\n\nfor idx in range(0, d):\n val += int(sList[idx][tList[idx] -1])\n\n countList = list(map(lambda x: x+1, countList))\n countList[int(tList[idx]) -1] = 0\n\n for wkChar in range(0,26):\n val -= int(countList[wkChar]) * int(cList[wkChar])\n print(val)\n", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [201, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u324739185", "n_user": "u324739185", "pos": "# -*- coding: utf-8 -*-\nimport time\nimport numpy as np\n\nstart = time.time()\nlimit_time = 1.8\n\n# \u6574\u6570\u306e\u5165\u529b\nd = int(input())\nc = [int(i) for i in input().split()]\ns = [[int(i) for i in input().split()] for j in range(d)]\n\ndef point(t):\n result = 0\n map = {\n 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,\n 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,\n 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0\n }\n for i in range(d):\n comp = t[i] - 1\n day = i + 1\n map[comp] = day\n result = result + s[i][comp]\n for cc in range(26):\n result = result - c[cc] * (day - map[cc])\n print(result)\n return result\n\nt = [int(input()) for i in range(d)]\n\npoint(t)", "neg": "# -*- coding: utf-8 -*-\nimport time\nimport numpy as np\n\nstart = time.time()\nlimit_time = 1.8\n\n# \u6574\u6570\u306e\u5165\u529b\nd = int(input())\nc = [int(i) for i in input().split()]\ns = [[int(i) for i in input().split()] for j in range(d)]\n\ndef point(t):\n result = 0\n map = {\n 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0,\n 10: 0, 11: 0, 12: 0, 13: 0, 14: 0, 15: 0, 16: 0, 17: 0, 18: 0, 19: 0,\n 20: 0, 21: 0, 22: 0, 23: 0, 24: 0, 25: 0\n }\n for i in range(d):\n comp = t[i] - 1\n day = i + 1\n map[comp] = day\n result = result + s[i][comp]\n for cc in range(26):\n result = result - c[cc] * (day - map[cc])\n print(result)\n return result\n\nt = [int(input()) for i in range(d)]\n\n", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [335, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u495667483", "n_user": "u495667483", "pos": "import sys\nfrom itertools import accumulate\nimport bisect\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef main():\n D = ii()\n c = list(mi())\n s = [list(mi()) for i in range(D)]\n\n t = [ii()-1 for i in range(D)]\n\n last = [[0]*26 for i in range(D)]\n v = [0]*D\n\n for d in range(D):\n for i in range(26):\n if i == t[d]:\n last[d][i] = d+1\n else:\n last[d][i] = last[d-1][i]\n\n k = sum(c[i]*(d+1-last[d][i]) for i in range(26))\n v[d] = v[d-1] + s[d][t[d]] - k\n \n print(*v, sep='\\n')\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nfrom itertools import accumulate\nimport bisect\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef main():\n D = ii()\n c = list(mi())\n s = [list(mi()) for i in range(D)]\n\n t = [ii()-1 for i in range(D)]\n\n last = [[0]*26 for i in range(D)]\n v = [0]*D\n\n for d in range(D):\n for i in range(26):\n if i == t[d]:\n last[d][i] = d+1\n else:\n last[d][i] = last[d-1][i]\n\n k = sum(c[i]*(d+1-last[d][i]) for i in range(26))\n v[d] = v[d-1] + s[d][t[d]] - k\n \n print(v)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9444444444444444, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [277, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u370562440", "n_user": "u370562440", "pos": "#B\n\nimport numpy as np\nD = int(input())\nC = list(map(int,input().split()))\nS = np.empty((D,26))\nfor i in range(D):\n l = list(map(int,input().split()))\n for j in range(26):\n S[i][j] = l[j]\n \n#\u958b\u50ac\u65e5\u6642\u306e\u8a18\u9332\nR = np.zeros(26)\n\nsc = 0\n\n#\u4e0e\u3048\u3089\u308c\u305ft\u3067\u30b9\u30b3\u30a2\u3092\u8a08\u7b97\nfor i in range(1,D+1):\n \n #\u30e9\u30f3\u30c0\u30e0\u306b\u958b\u50ac\u3059\u308b\u30b3\u30f3\u30c6\u30b9\u30c8\u3092\u9078\u3076\n con = int(input()) - 1\n \n #\u30b9\u30b3\u30a2\u8a08\u7b97\n #\u30b3\u30f3\u30c6\u30b9\u30c8\u958b\u50ac\u306b\u3088\u308b\u4e0a\u6607\n sc += S[i-1][con]\n R[con] = i\n \n #\u30b3\u30f3\u30c6\u30b9\u30c8\u975e\u958b\u50ac\u306b\u3088\u308b\u6e1b\u5c11\n for j in range(26):\n sc -= C[j]*(i-R[j])\n \n print(int(sc))", "neg": "#B\n\nimport numpy as np\nD = int(input())\nC = list(map(int,input().split()))\nS = np.empty((D,26))\nfor i in range(D):\n l = list(map(int,input().split()))\n for j in range(26):\n S[i][j] = l[j]\n \n#\u958b\u50ac\u65e5\u6642\u306e\u8a18\u9332\nR = np.zeros(26)\n\nsc = 0\nfor i in range(1,D+1):\n \n #\u30e9\u30f3\u30c0\u30e0\u306b\u958b\u50ac\u3059\u308b\u30b3\u30f3\u30c6\u30b9\u30c8\u3092\u9078\u3076\n con = int(input()) - 1\n \n #\u30b9\u30b3\u30a2\u8a08\u7b97\n #\u30b3\u30f3\u30c6\u30b9\u30c8\u958b\u50ac\u306b\u3088\u308b\u4e0a\u6607\n sc += S[i-1][con]\n R[con] = i\n \n #\u30b3\u30f3\u30c6\u30b9\u30c8\u975e\u958b\u50ac\u306b\u3088\u308b\u6e1b\u5c11\n for j in range(26):\n sc -= C[j]*(i-R[j])\n \n print(sc)", "jacc_sim": 0.9090909090909091, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [399, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u732870425", "n_user": "u732870425", "pos": "D = int(input())#D=365\nc = list(map(int, input().split()))#0<=c<=100\ns = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000\n\nt = [int(input()) for _ in range(D)]\n\n\nv = []\nlast = [0] * 26\nvalue = 0\nfor d in range(D):\n type = t[d]\n value += s[d][type - 1]\n last[type - 1] = d + 1\n for i in range(26):\n value -= c[i] * (d + 1 - last[i])\n v.append(value)\n\nfor i in range(D):\n print(v[i])\n", "neg": "D = int(input())#D=365\nc = list(map(int, input().split()))#0<=c<=100\ns = [list(map(int, input().split())) for _ in range(D)]#0<=s<=20000\n\nt = [int(input()) for _ in range(D)]\n\n\nv = []\nlast = [0] * 26\nvalue = 0\nfor d in range(D):\n for i in range(26):\n value += s[d][i]\n value += c[i] * (d - last[i])\n v.append(value)\n\nfor i in range(D):\n print(v[i])\n", "jacc_sim": 0.95, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [191, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u441575327", "n_user": "u441575327", "pos": "D = int(input())\nc = list(map(int,input().split()))\ns = [list(map(int,input().split())) for i in range(D)]\nt = [int(input()) for i in range(D)]\n\nlast = {}\nfor i in range(1,27):\n last[i] = 0\n\nsatisfaction = 0\nfor d in range(1,D+1):\n satisfaction += s[d-1][t[d-1]-1]\n last[t[d-1]] = d\n for i in range(1,27):\n satisfaction -= c[i-1]*(d-last[i])\n print(satisfaction)\n", "neg": "D = int(input())\nc = list(map(int,input().split()))\ns = [list(map(int,input().split())) for i in range(D)]\nt = [int(input()) for i in range(D)]\n\nlast = {}\nfor i in range(1,27):\n last[i] = 0\n\nsatisfaction = 0\nfor d in range(1,D+1):\n satisfaction += s[d-1][t[d-1]-1]\n last[t[d-1]] = d\n for i in range(26):\n satisfaction -= c[d-1]*(d-last[t[d-1]])\n print(satisfaction)\n", "jacc_sim": 0.9705882352941176, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [175, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u332657092", "n_user": "u332657092", "pos": "d = int(input())\nC = list(map(int, input().split()))\nS = []\nfor i in range(d):\n S.append(list(map(int, input().split())))\nT = [0]\nfor i in range(d):\n T.append(int(input()))\n#print(S)\n#print(T)\n\n#\u6700\u7d42\u958b\u50ac\u65e5\nLast = [0] * 26\n\n#\u5404Scores\nScores = [0] * 26\n\nfor day in range(1, d+1):\n contest = T[day] - 1\n Last[contest] = day\n Scores[contest] += S[day-1][contest]\n for num in range(26):\n Scores[num] -= C[num] * (day - Last[num])\n print(sum(Scores))", "neg": "d = int(input())\nC = list(map(int, input().split()))\nS = []\nfor i in range(d):\n S.append(list(map(int, input().split())))\nT = [0]\nfor i in range(d):\n T.append(int(input()))\nprint(S)\nprint(T)\n\n#\u6700\u7d42\u958b\u50ac\u65e5\nLast = [0] * 26\n\n#\u5404Scores\nScores = [0] * 26\n\nfor day in range(1, d+1):\n contest = T[day] - 1\n Last[contest] = day\n Scores[contest] += S[day-1][contest]\n for num in range(26):\n Scores[num] -= C[num] * (day - Last[num])\n print(sum(Scores))", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [215, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u485319545", "n_user": "u485319545", "pos": "d=int(input())\nc=list(map(int,input().split()))\ns=[]\nfor _ in range(d):\n s_i=list(map(int,input().split()))\n s.append(s_i)\nt=[]\nfor _ in range(d):\n t_i=int(input())\n t.append(t_i)\n\n\ndp=[0]*26\n\nans=0\nfor i in range(d):\n s_i = s[i][t[i]-1]\n ans+=s_i\n dp[t[i]-1]=i+1\n tmp=0\n for j in range(26):\n tmp+=c[j]*((i+1)-dp[j])\n\n \n \n\n ans -= tmp\n\n print(ans)", "neg": "d=int(input())\nc=list(map(int,input().split()))\ns=[]\nfor _ in range(d):\n s_i=list(map(int,input().split()))\n s.append(s_i)\nfor _ in range(d):\n t=int(input())\n\ndp=[0]*26\n\nfor i in range(d):\n s_i = max(s[i])\n index=s[i].index(max(s[i]))\n dp[index]=i+1\n\n tmp=0\n\n for j in range(26):\n tmp+=c[j]*(d-dp[j])\n\n ans = s_i = tmp\n print(ans)", "jacc_sim": 0.9210526315789473, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [202, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u262597910", "n_user": "u262597910", "pos": "import random\nd = int(input())\nc = list(map(int, input().split()))\ns = [list(map(int, input().split())) for _ in range(d)]\nt = [int(input()) for _ in range(d)]\nans = 0\nlast = [0]*26\nfor i in range(1,d+1):\n #x = 0\n x = t[i-1]-1\n #x = random.randrange(26)\n last[x] = i\n ans += s[i-1][x]\n for j in range(26):\n ans -= c[j]*(i-last[j])\n print(ans)\n ", "neg": "import random\nd = int(input())\nc = list(map(int, input().split()))\ns = [list(map(int, input().split())) for _ in range(d)]\n#t = [int(input()) for _ in range(d)]\nans = 0\nlast = [0]*26\nfor i in range(1,d+1):\n x = 0\n #x = t[i-1]-1\n #x = random.randrange(26)\n last[x] = i\n ans += s[i-1][x]\n for j in range(26):\n ans -= c[j]*(i-last[j])\n print(ans)\n ", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [165, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u757715307", "n_user": "u757715307", "pos": "d = int(input())\nc = list(map(int, input().split(' ')))\n\ns = [list(map(int, input().split(' '))) for _ in range(d)]\n\nt = [int(input()) - 1 for _ in range(d)]\nca = [0] * 26 # \u653e\u7f6e\u3055\u308c\u305f\u4e0d\u6e80\u306e\u6570\u3005\ndc = 0 # \u30ab\u30ec\u30f3\u30c8\u306a\u6e80\u8db3\u5ea6\ndl = [] # \u6e80\u8db3\u5ea6\u306e\u30ed\u30b0\n\nfor i in range(1, d + 1):\n dc += s[i - 1][t[i - 1]]\n ca[t[i - 1]] = i\n dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(26)])\n dl.append(dc)\nprint('\\n'.join(list(map(str, dl))))", "neg": "d = int(input())\nc = list(map(int, input().split(' ')))\n \ns = [list(map(int, input().split(' '))) for _ in range(d)]\n \nt = [int(input()) - 1 for _ in range(d)]\nca = [0] * 26 # \u653e\u7f6e\u3055\u308c\u305f\u4e0d\u6e80\u306e\u6570\u3005\ndc = 0 # \u30ab\u30ec\u30f3\u30c8\u306a\u6e80\u8db3\u5ea6\ndl = [] # \u6e80\u8db3\u5ea6\u306e\u30ed\u30b0\n \nfor i in range(1, d + 1):\n dc += s[i - 1][t[i - 1]]\n ca[t[i - 1]] = i\n dc -= sum([c[i2] * (i - ca[i2]) for i2 in range(26)])\n dl.append(dc)", "jacc_sim": 0.9166666666666666, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [252, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02619", "p_user": "u470542271", "n_user": "u547608423", "pos": "D = int(input())\nc = list(map(int, input().split()))\ns = [list(map(int, input().split())) for _ in range(D)]\nt = [int(input()) for _ in range(D)]\n\nlast = [-1] * 26\nS = 0\nfor d in range(D):\n S += s[d][t[d] - 1]\n\n last[t[d] - 1] = d\n for i in range(26):\n S -= c[i] * (d - last[i])\n\n print(S)\n", "neg": "D = int(input())\nc = list(map(int, input().split()))\ns = [list(map(int, input().split())) for _ in range(D)]\nt = [int(input()) for _ in range(D)]\n\nv = 0\nlast = [0 for _ in range(26)]\n\nfor i in range(D):\n last[t[i]-1] = i+1\n v += s[i][t[i]-1]\n for j in range(26):\n v -= c[j]*(d-last[j])\n print(v)\n", "jacc_sim": 0.9117647058823529, "nl": "Please read problem A first. The maximum score you can get by solving this problem B is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide:\nLet's first write a program to calculate the score from a pair of input and output. You can know the total score by submitting your solution, or an official program to calculate a score is often provided for local evaluation as in this contest. Nevertheless, writing a score calculator by yourself is still useful to check your understanding of the problem specification. Moreover, the source code of the score calculator can often be reused for solving the problem or debugging your solution. So it is worthwhile to write a score calculator unless it is very complicated.\n\nProblem Statement:\nYou will be given a contest schedule for D days. For each d=1,2,...,D, calculate the satisfaction at the end of day d.\n\nInput:\nInput is given from Standard Input in the form of the input of Problem A followed by the output of Problem A.\nD\nc_1 c_2 ... c_26\ns_1,1 s_1,2 ... s_1,26\n...\ns_D,1 s_D,2 ... s_D,26\nt_1\nt_2\n...\nt_D\n- The constraints and generation methods for the input part are the same as those for Problem A.\n- For each d, t_d is an integer satisfying 1\u2264t_d\u226426, and your program is expected to work correctly for any value that meets the constraints.\n\nOutput:\nLet v_d be the satisfaction at the end of day d. Print D integers v_d to Standard Output in the following format:\nv_1\nv_2\n...\nv_D\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n\nSample Output 1:\n18398\n35037\n51140\n65837\n79325\n\nNote that this example is a small one for checking the problem specification. It does not satisfy the constraint D=365 and is never actually given as a test case.\n\nNext Step:\nWe can build a solution (schedule) for this problem in the order of day 1, day 2, and so on. And for every partial solution we have built, we can calculate the goodness (satisfaction) by using the above score calculator. So we can construct the following algorithm: for each d=1,2,...,D, we select the contest type that maximizes the satisfaction at the end of day d. You may have already encountered this kind of \"greedy algorithms\" in algorithm contests such as ABC. Greedy algorithms can guarantee the optimality for several problems, but unfortunately, it doesn't ensure optimality for this problem. However, even if it does not ensure optimality, we can still obtain a reasonable solution in many cases. Let's go back to Problem A and implement the greedy algorithm by utilizing the score calculator you just implemented!\nGreedy methods can be applied to a variety of problems, are easy to implement, and often run relatively fast compared to other methods. Greedy is often the most powerful method when we need to process huge inputs.\nWe can further improve the score by changing the greedy selection criteria (evaluation function), keeping multiple candidates instead of focusing on one best partial solution (beam search), or using the output of greedy algorithms as an initial solution of other methods.\nFor more information, please refer to the editorial that will be published after the contest.", "before_after_length": [140, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02620", "p_user": "u450956662", "n_user": "u450956662", "pos": "import sys\ninput = sys.stdin.readline\n\ndef scoring(sc):\n last = [0] * 26\n res = 0\n penalty = 0\n for i in range(D):\n t = out[i]\n res += S[i][t]\n penalty += sc - (i + 1 - last[t]) * C[t]\n res -= penalty\n last[t] = i + 1\n return res\n\nD = int(input())\nC = list(map(int, input().split()))\nS = [list(map(int, input().split())) for _ in range(D)]\nout = [int(input()) - 1 for _ in range(D)]\nsc = sum(C)\nM = int(input())\nfor _ in range(M):\n d, q = map(int, input().split())\n out[d-1] = q - 1\n print(scoring(sc))\n\n", "neg": "import sys\ninput = sys.stdin.readline\n\ndef scoring():\n last = [0] * 26\n res = 0\n penalty = 0\n for i in range(D):\n t = out[i]\n res += S[i][t]\n penalty += SC - (i + 1 - last[t]) * C[t]\n res -= penalty\n last[t] = i\n return res\n\nD = int(input())\nC = list(map(int, input().split()))\nS = [list(map(int, input().split())) for _ in range(D)]\nout = [int(input()) - 1 for _ in range(D)]\nSC = sum(C)\nM = int(input())\nfor _ in range(M):\n d, q = map(int, input().split())\n out[d-1] = q - 1\n print(scoring())\n\n", "jacc_sim": 0.9565217391304348, "nl": "Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide: \"Local search\" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process, the quality of the solution is gradually improved over time. The pseudo-code is as follows:\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n slightly modify the solution (randomly)\n if the solution gets worse:\n restore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q. The pseudo-code is as follows:\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n pick d and q at random\n old = t[d] # Remember the original value so that we can restore it later\n t[d] = q\n if the solution gets worse:\n t[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n1. If the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n2. In order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point. The score after the modification can, of course, be obtained by calculating the score from scratch. However, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification. Let's implement fast incremental score computation.\n\nProblem Statement: You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput: Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nOutput: Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n...\nv_M\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1:\n72882\n56634\n38425\n27930\n42884\n\nNext Step: Let's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented! For this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation. One of the most powerful and widely used variants of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves. For more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "before_after_length": [223, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02620", "p_user": "u877470159", "n_user": "u877470159", "pos": "import sys\ninput=sys.stdin.readline\nD=int(input())\nc=list(map(int,input().split()))\ns=[]\nfor i in range(D):\n sub=list(map(int,input().split()))\n s.append(sub)\nt=[]\nfor i in range(D):\n t.append(int(input()))\n\nh=0\nlast=[-1]*26\n\nfor i in range(D):\n h+=s[i][t[i]-1]\n last[t[i]-1]=i\n for j in range(26):\n h-=c[j]*(i-last[j])\n\nm=int(input())\nfor _ in range(m):\n d,q=map(int,input().split())\n h+=s[d-1][q-1]-s[d-1][t[d-1]-1]\n o=t[d-1]\n t[d-1]=q\n\n pre=1\n for i in range(d-2,-1,-1):\n if t[i]==o:\n break\n pre+=1\n post=1\n for j in range(d,D):\n if t[j]==o:\n break\n post+=1\n h-=c[o-1]*pre*post\n\n pre = 1\n for i in range(d - 2, -1, -1):\n if t[i] == q:\n break\n pre += 1\n post = 1\n for j in range(d, D):\n if t[j] == q:\n break\n post += 1\n h += c[q - 1] * pre * post\n\n print(h)\n\n\n", "neg": "import sys\ninput=sys.stdin.readline\nD=int(input())\nc=list(map(int,input().split()))\ns=[]\nfor i in range(D):\n sub=list(map(int,input().split()))\n s.append(sub)\nt=[]\nfor i in range(D):\n t.append(int(input()))\n\nh=0\nlast=[-1]*26\n\nfor i in range(D):\n h+=s[i][t[i]-1]\n last[t[i]-1]=i\n for j in range(26):\n h-=c[j]*(i-last[j])\n\nm=int(input())\nfor _ in range(m):\n d,q=map(int,input().split())\n h+=s[d-1][q-1]-s[d-1][t[d-1]-1]\n o=t[d-1]\n t[d-1]=q\n\n pre=1\n for i in range(d-2,-1,-1):\n if t[i]==o:\n break\n pre+=1\n post=1\n for j in range(d,D):\n if t[i]==o:\n break\n post+=1\n h-=c[o-1]*pre*post\n\n pre = 1\n for i in range(d - 2, -1, -1):\n if t[i] == q:\n break\n pre += 1\n post = 1\n for j in range(d, D):\n if t[i] == q:\n break\n post += 1\n h += c[q - 1] * pre * post\n\n print(h)\n\n\n", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide: \"Local search\" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process, the quality of the solution is gradually improved over time. The pseudo-code is as follows:\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n slightly modify the solution (randomly)\n if the solution gets worse:\n restore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q. The pseudo-code is as follows:\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n pick d and q at random\n old = t[d] # Remember the original value so that we can restore it later\n t[d] = q\n if the solution gets worse:\n t[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n1. If the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n2. In order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point. The score after the modification can, of course, be obtained by calculating the score from scratch. However, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification. Let's implement fast incremental score computation.\n\nProblem Statement: You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput: Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nOutput: Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n...\nv_M\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1:\n72882\n56634\n38425\n27930\n42884\n\nNext Step: Let's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented! For this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation. One of the most powerful and widely used variants of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves. For more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "before_after_length": [436, 436], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02620", "p_user": "u263824932", "n_user": "u263824932", "pos": "D=int(input())\nc=input().split()\nc=[int(a) for a in c]\nS=[]\nfor _ in range(D):\n s=input().split()\n s=[int(a) for a in s]\n S.append(s)\nT=[]\nfor _ in range(D):\n t=int(input())-1\n T.append(t)\nM=int(input())\nnumbers=[]\nfor _ in range(M):\n d,q=map(int,input().split())\n numbers.append([d,q])\nwhole=sum(c)\nfor m in range(M):\n ans = 0\n held = [0 for _ in range(26)]\n e=numbers[m][0]-1\n q=numbers[m][1]-1\n a=T[e]\n T[e]=q\n wholes=0\n for d in range(D):\n s = S[d]\n place = T[d]\n ans += s[place]\n wholes+=whole\n wholes-=c[place]*((d+1)-held[place])\n held[place] = d + 1\n ans-=wholes\n print(ans)\n", "neg": "D=int(input())\nc=input().split()\nc=[int(a) for a in c]\nS=[]\nfor _ in range(D):\n s=input().split()\n s=[int(a) for a in s]\n S.append(s)\nT=[]\nfor _ in range(D):\n t=int(input())-1\n T.append(t)\nM=int(input())\nnumbers=[]\nfor _ in range(M):\n d,q=map(int,input().split())\n numbers.append([d,q])\nwhole=sum(c)\nfor m in range(M):\n ans = 0\n held = [0 for _ in range(26)]\n e=numbers[m][0]-1\n q=numbers[m][1]-1\n a=T[e]\n T[e]=q\n number=[]\n for d in range(D):\n s = S[d]\n place = T[d]\n held[place] = d + 1\n ans += s[place]\n ans-=whole*(d+1)\n ans+=c[place]*(d+5)\n print(ans)\n", "jacc_sim": 0.9333333333333333, "nl": "Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide: \"Local search\" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process, the quality of the solution is gradually improved over time. The pseudo-code is as follows:\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n slightly modify the solution (randomly)\n if the solution gets worse:\n restore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q. The pseudo-code is as follows:\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n pick d and q at random\n old = t[d] # Remember the original value so that we can restore it later\n t[d] = q\n if the solution gets worse:\n t[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n1. If the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n2. In order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point. The score after the modification can, of course, be obtained by calculating the score from scratch. However, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification. Let's implement fast incremental score computation.\n\nProblem Statement: You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput: Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nOutput: Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n...\nv_M\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1:\n72882\n56634\n38425\n27930\n42884\n\nNext Step: Let's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented! For this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation. One of the most powerful and widely used variants of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves. For more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "before_after_length": [304, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02620", "p_user": "u873915460", "n_user": "u873915460", "pos": "D=int(input())\nC=list(map(int,input().split()))\nS=[list(map(int,input().split())) for i in range(D)]\nT=[int(input())-1 for i in range(D)]\nX=[0]*26\nY=[0]*26\nM=int(input())\nd,q=0,0\nP=0\nfor i in range(D):\n P+=S[i][T[i]]\n for j in range(26):\n X[j]+=C[j]\n X[T[i]]=0\n for j in range(26):\n Y[j]+=X[j]\nfor i in range(M):\n d,q=map(int,input().split())\n d,q=d-1,q-1\n P-=S[d][T[d]]\n P+=S[d][q]\n for j in range(26):\n X[j]=0\n Y[T[d]],Y[q]=0,0\n for j in range(D):\n if j==d:\n Z=q\n else:\n Z=T[j]\n X[T[d]]+=C[T[d]]\n X[q]+=C[q]\n X[Z]=0\n Y[T[d]]+=X[T[d]]\n Y[q]+=X[q]\n T[d]=q\n print(P-sum(Y))", "neg": "D=int(input())\nC=list(map(int,input().split()))\nS=[list(map(int,input().split())) for i in range(D)]\nT=[int(input())-1 for i in range(D)]\nX=[0]*26\nY=[0]*26\nM=int(input())\nd,q=0,0\nP=0\nfor i in range(D):\n P+=S[i][T[i]]\n for j in range(26):\n X[j]+=C[j]\n X[T[i]]=0\n for j in range(26):\n Y[j]+=X[j]\nprint(P-sum(Y))\nfor i in range(M):\n d,q=map(int,input().split())\n d,q=d-1,q-1\n P-=S[d][T[d]]\n P+=S[d][q]\n for j in range(26):\n X[j]=0\n Y[T[d]],Y[q]=0,0\n for j in range(D):\n if j==d:\n Z=q\n else:\n Z=T[j]\n X[T[d]]+=C[T[d]]\n X[q]+=C[q]\n X[Z]=0\n Y[T[d]]+=X[T[d]]\n Y[q]+=X[q]\n T[d]=q\n print(P-sum(Y))", "jacc_sim": 1.0, "nl": "Please read problem A first. The maximum score you can get by solving this problem C is 1, which will have almost no effect on your ranking.\n\nBeginner's Guide: \"Local search\" is a powerful method for finding a high-quality solution. In this method, instead of constructing a solution from scratch, we try to find a better solution by slightly modifying the already found solution. If the solution gets better, update it, and if it gets worse, restore it. By repeating this process, the quality of the solution is gradually improved over time. The pseudo-code is as follows:\n\nsolution = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n slightly modify the solution (randomly)\n if the solution gets worse:\n restore the solution\n\nFor example, in this problem, we can use the following modification: pick the date d and contest type q at random and change the type of contest to be held on day d to q. The pseudo-code is as follows:\n\nt[1..D] = compute an initial solution (by random generation, or by applying other methods such as greedy)\nwhile the remaining time > 0:\n pick d and q at random\n old = t[d] # Remember the original value so that we can restore it later\n t[d] = q\n if the solution gets worse:\n t[d] = old\n\nThe most important thing when using the local search method is the design of how to modify solutions.\n1. If the amount of modification is too small, we will soon fall into a dead-end (local optimum) and, conversely, if the amount of modification is too large, the probability of finding an improving move becomes extremely small.\n2. In order to increase the number of iterations, it is desirable to be able to quickly calculate the score after applying a modification.\n\nIn this problem C, we focus on the second point. The score after the modification can, of course, be obtained by calculating the score from scratch. However, by focusing on only the parts that have been modified, it may be possible to quickly compute the difference between the scores before and after the modification. Let's implement fast incremental score computation.\n\nProblem Statement: You will be given a contest schedule for D days and M queries of schedule modification. In the i-th query, given integers d_i and q_i, change the type of contest to be held on day d_i to q_i, and then output the final satisfaction at the end of day D on the updated schedule. Note that we do not revert each query. That is, the i-th query is applied to the new schedule obtained by the (i-1)-th query.\n\nInput: Input is given from Standard Input in the form of the input of Problem A followed by the output of Problem A and the queries.\n\nOutput: Let v_i be the final satisfaction at the end of day D on the schedule after applying the i-th query. Print M integers v_i to Standard Output in the following format:\n\nv_1\nv_2\n...\nv_M\n\nSample Input 1:\n5\n86 90 69 51 2 96 71 47 88 34 45 46 89 34 31 38 97 84 41 80 14 4 50 83 7 82\n19771 12979 18912 10432 10544 12928 13403 3047 10527 9740 8100 92 2856 14730 1396 15905 6534 4650 11469 3628 8433 2994 10899 16396 18355 11424\n6674 17707 13855 16407 12232 2886 11908 1705 5000 1537 10440 10711 4917 10770 17272 15364 19277 18094 3929 3705 7169 6159 18683 15410 9092 4570\n6878 4239 19925 1799 375 9563 3445 5658 19857 11401 6997 6498 19933 3848 2426 2146 19745 16880 17773 18359 3921 14172 16730 11157 5439 256\n8633 15862 15303 10749 18499 7792 10317 5901 9395 11433 3514 3959 5202 19850 19469 9790 5653 784 18500 10552 17975 16615 7852 197 8471 7452\n19855 17918 7990 10572 4333 438 9140 9104 12622 4985 12319 4028 19922 12132 16259 17476 2976 547 19195 19830 16285 4806 4471 9457 2864 2192\n1\n17\n13\n14\n13\n5\n1 7\n4 11\n3 4\n5 24\n4 19\n\nSample Output 1:\n72882\n56634\n38425\n27930\n42884\n\nNext Step: Let's go back to Problem A and implement the local search algorithm by utilizing the incremental score calculator you just implemented! For this problem, the current modification \"pick the date d and contest type q at random and change the type of contest to be held on day d to q\" is actually not so good. By considering why it is not good, let's improve the modification operation. One of the most powerful and widely used variants of the local search method is \"Simulated Annealing (SA)\", which makes it easier to reach a better solution by stochastically accepting worsening moves. For more information about SA and other local search techniques, please refer to the editorial that will be published after the contest.", "before_after_length": [365, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u052244548", "n_user": "u052244548", "pos": "import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\ndef main_chk():\n N = int(input())\n\n ans = 0\n for i in range(1,N+1):\n m = N // i\n ans += ( m + 1 ) * m * i / 2\n\n print(math.floor(ans))\nmain_chk()\n", "neg": "import itertools\nimport functools\nimport math\nfrom collections import Counter\nfrom itertools import combinations\nimport re\n\n\ndef main_chk():\n N = int(input())\n\n ans = 0\n for i in range(1,N+1):\n m = N // i\n ans += ( m + 1 ) * m * i / 2\n\n print(ans)\nmain_chk()\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [96, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u072717685", "n_user": "u072717685", "pos": "import sys\nread = sys.stdin.read\ndef main():\n n = int(input())\n if n == 1:\n print(1)\n sys.exit()\n # nd:num of div\n r = 0\n for i1 in range(1, n + 1):\n y = n // i1\n r += y * (y + 1) * i1 / 2\n print(int(r))\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n n = int(input())\n if n == 1:\n print(1)\n sys.exit()\n # nd:num of div\n r = 0\n for i1 in range(1, n):\n y = n // i1\n r += y * (y + 1) * i1 / 2\n print(int(r))\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9210526315789473, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [115, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u512266180", "n_user": "u512266180", "pos": "N = int(input())\nc = (N+1)//2\nans = 0\nfor i in range(1,N-c+1):\n ans += i*(1+N//i)*(N//i)/2\nans += N*c -(c-1)*c/2\nprint(int(ans))", "neg": "N = int(input())\nans = 0\nfor i in range(1,N+1):\n ans += int(i*(1+N//i)*(N//i)/2)\nprint(ans)", "jacc_sim": 0.9090909090909091, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [74, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u467479913", "n_user": "u467479913", "pos": "n = int(input())\n\ns = 0\nq = int(n ** .5)\nfor i in range(1, q+1):\n\tx = n // i\n\ts += i * (x * (x+1)) / 2\n\tif x**2 != n:\n\t\ty = max(n // (i+1), q)\n\t\ts += (i * (i+1) // 2) * ((x * (x+1) // 2) - (y * (y+1) // 2))\n\nprint(int(s))", "neg": "s = 0\nq = int(n ** .5)\nfor i in range(1, int(n ** .5) + 1):\n\tx = n // i\n\ts += i * (x * (x+1)) / 2\n\tif x**2 != n:\n\t\ty = max(n // (i+1), q)\n\t\ts += (i * (i+1) // 2) * ((x * (x+1) // 2) - (y * (y+1) // 2))\n\nprint(int(s))", "jacc_sim": 0.9655172413793104, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [129, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u303739137", "n_user": "u303739137", "pos": "n = int(input())\ncnts = [k*(n//k)*((n//k)+1)//2 for k in range(1,n//2+1)]\nprint(sum(cnts)+ ((n//2+1)+n)*(n-(n//2+1)+1)//2)", "neg": "n = int(input())\ncnts = [k*d*(d+1)//2 for k in range(1,n//2)]\nprint(sum(cnts)+ (n//2)*d*(d+1)//2)", "jacc_sim": 0.9130434782608695, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [71, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u047197186", "n_user": "u047197186", "pos": "def solve(n):\n ans = 0\n for i in range(1,n+1):\n y = n//i\n ans += (y*(y+1)*i)/2\n return ans\n\ndef main():\n n = int(input())\n print(int(solve(n)))\n\nif __name__ == \"__main__\":\n main()", "neg": "def solve(n):\n ans = 0\n for i in range(1,n+1):\n y = n//i\n print(y)\n ans += (y*(y+1)*i)/2\n return ans\n\ndef main():\n n = int(input())\n print(int(solve(n)))\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [86, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02624", "p_user": "u836311327", "n_user": "u836311327", "pos": "n=int(input())\n \nsu = 0\nfor i in range(1,int(n**0.5)+1):\n m = int(n/i) - i + 1\n su += m*(2*i*i + (m-1)*i) - i*i\n \n \nprint(su)", "neg": "n=int(input())\n\nsu = 0\nfor i in range(1,n+1):\n m = int(n/i)\n su += int(m*(2*i + (m-1)*i)/2)\n \n\nprint(su)", "jacc_sim": 0.9166666666666666, "nl": "You are given a positive integer N. Find the sum of K * f(K) for K ranging from 1 to N, where f(X) is the number of positive divisors of X. The input is given as N, and the output should be the sum of K * f(K). The constraints are 1 \u2264 N \u2264 10^7. For example, if N is 4, the output should be 23, calculated as 1*1 + 2*2 + 3*2 + 4*3. Be cautious of potential overflows.", "before_after_length": [76, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u943004959", "n_user": "u943004959", "pos": "MOD = 10**9 + 7\nMAX = 5*10**5 + 1\n\nfact = [0 for _ in range(MAX)]\nfactinv = [0 for _ in range(MAX)]\n\nfact[0] = 1\nfor k in range(1, MAX):\n fact[k] = fact[k - 1]*k\n fact[k] %= MOD\n\nfactinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)\nfor k in range(MAX - 1, 0, -1):\n factinv[k - 1] = factinv[k]*k\n factinv[k - 1] %= MOD\n\ndef nCk(n, k):\n return fact[n]*factinv[k]*factinv[n - k] % MOD\n\ndef nPk(n, k):\n return fact[n]*factinv[n - k] % MOD\n\nn, m = map(int, input().split(' '))\n\nans = 0\nfor k in range(n + 1):\n tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD\n if not k % 2: ans += tmp\n else: ans -= tmp\n ans %= MOD\n\nprint(ans)", "neg": "MOD = 10**9 + 7\nMAX = 5*10**5 + 1\n\nfact = [0 for _ in range(MAX)]\nfactinv = [0 for _ in range(MAX)]\n\nfact[0] = 1\nfor k in range(1, MAX):\n fact[k] = fact[k - 1]*k\n fact[k] %= MOD\n\nfactinv[MAX - 1] = pow(fact[MAX - 1], MOD - 2, MOD)\nfor k in range(MAX - 1, 0, -1):\n factinv[k - 1] = fact[k]*k\n factinv[k - 1] %= MOD\n\ndef nCk(n, k):\n return fact[n]*factinv[k]*factinv[n - k] % MOD\n\ndef nPk(n, k):\n return fact[n]*factinv[n - k] % MOD\n\nn, m = map(int, input().split(' '))\n\nans = 0\nfor k in range(n + 1):\n tmp = nCk(n, k)*nPk(m, k)*nPk(m - k, n - k)*nPk(m - k, n - k) % MOD\n if k % 2: ans += tmp\n else: ans -= tmp\n ans %= MOD\n\nprint(ans)", "jacc_sim": 0.9782608695652174, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [310, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u461993794", "n_user": "u461993794", "pos": "from functools import reduce\n\nn, m = map(int, input().split())\n\nmod = 10 ** 9 + 7\nans = 0\nc = 1\np1 = 1\np2 = reduce(lambda ac, v: ac * v % mod, range(m, m - n, -1), 1)\nfor i in range(n + 1):\n if i > 0:\n c = (c * (n - i + 1) * pow(i, mod - 2, mod)) % mod\n p1 = (p1 * (m - i + 1)) % mod\n p2 = (p2 * pow(m - i + 1, mod - 2, mod)) % mod\n x = c * p1 * (p2 ** 2)\n if i % 2 == 0:\n ans += x\n else:\n ans -= x\n ans %= mod\nprint(ans)\n", "neg": "from functools import reduce\n\nn, m = map(int, input().split())\n\nmod = 10 ** 9 + 7\nans = 0\nc = 1\np1 = 1\np2 = reduce(lambda ac, v: ac * v % mod, range(m, m - n, -1), 1)\nfor i in range(n + 1):\n if i > 0:\n c = (c * (n - i + 1) * pow(i, mod - 2, mod)) % mod\n p1 = (p1 * (n - i + 1)) % mod\n p2 = (p2 * pow(n - i + 1, mod - 2, mod)) % mod\n x = c * p1 * (p2 ** 2)\n if i % 2 == 0:\n ans += x\n else:\n ans -= x\n ans %= mod\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [206, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u210440747", "n_user": "u210440747", "pos": "#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\ndef p(n, k, mod):\n x = 1\n for ik in range(k):\n x *= (n - ik)\n x %= mod\n return x\n\nMAX = 10 ** 9 + 7\ndef main():\n n, m = map(int, input().strip().split())\n s = 0\n nck = 1\n mpk = 1\n mkpnk = p(m, n, MAX)\n for k in range(0, n+1):\n if 0 < k <= n:\n nck *= (n - (k-1)) * pow(k, MAX-2, MAX) \n nck %= MAX\n if 0 < k <= m:\n mpk *= (m - (k-1))\n mpk %= MAX\n if 0 < k <= n:\n mkpnk *= pow(m - (k - 1), MAX-2, MAX) \n mkpnk %= MAX\n s += nck * ( (-1) ** k) * mpk * (mkpnk) ** 2\n s %= MAX\n print(s)\n \n\nif __name__=='__main__':\n main()\n\n", "neg": "%%writefile e.py\n#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\ndef p(n, k, mod):\n x = 1\n for ik in range(k):\n x *= (n - ik)\n x %= mod\n return x\n\nMAX = 10 ** 9 + 7\ndef main():\n n, m = map(int, input().strip().split())\n s = 0\n nck = 1\n mpk = 1\n mkpnk = p(m, n, MAX)\n for k in range(0, n+1):\n if 0 < k <= n:\n nck *= (n - (k-1)) * pow(k, MAX-2, MAX) \n nck %= MAX\n if 0 < k <= m:\n mpk *= (m - (k-1))\n mpk %= MAX\n if 0 < k <= n:\n mkpnk *= pow(m - (k - 1), MAX-2, MAX) \n mkpnk %= MAX\n s += nck * ( (-1) ** k) * mpk * (mkpnk) ** 2\n s %= MAX\n print(s)\n \n\nif __name__=='__main__':\n main()\n\n", "jacc_sim": 0.9482758620689655, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [296, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u168578024", "n_user": "u168578024", "pos": "fac=[1]*505050\ninv=[1]*505050\nfinv=[1]*505050\nmod=1000000007\nfor i in range(2,500010):\n fac[i]=fac[i-1]*i%mod\n inv[i]=-inv[mod%i]*(mod//i)%mod\n finv[i]=finv[i-1]*inv[i]%mod\n\ndef C(n,r):\n if n<0 or r<0 or nn:\n return 0\n r = min(r, n-r)\n return fac[n] * (finv[r] * finv[n-r] % mod) % mod\n\ndef perm(n, r, mod):\n if r<0 or r>n:\n return 0\n return (fac[n] * finv[n-r]) % mod\n\nfac = [1, 1]\nfinv = [1, 1]\ninv = [0, 1]\nfor i in range(2, max(N + 1, M + 1)):\n fac.append((fac[-1] * i) % mod)\n inv.append((-inv[mod%i] * (mod//i)) % mod)\n finv.append((finv[-1] * inv[-1]) % mod)\nc = comb(M, N, mod)\nans = ((fac[N] * c % mod) ** 2) % mod\n\nfor i in range(1, N+1):\n ans += (-1)**i * ((comb(N, i, mod) * perm(M, i, mod))%mod * (perm(M-i, N-i, mod)**2)%mod)%mod\n ans %= mod\nprint(ans)", "neg": "N, M = map(int, input().split())\nmod = 10**9 + 7\n\ndef comb(n, r, mod):\n if r<0 or r>n:\n return 0\n r = min(r, n-r)\n return fac[n] * (finv[r] * finv[n-r] % mod) % mod\n\ndef perm(n, r, mod):\n if r<0 or r>n:\n return 0\n return (fac[n] * finv[n-r]) % mod\n\nfac = [1, 1]\nfinv = [1, 1]\ninv = [0, 1]\nfor i in range(2, max(N + 1, M + 1)):\n fac.append((fac[-1] * i) % mod)\n inv.append((-inv[mod%i] * (mod//i)) % mod)\n finv.append((finv[-1] * inv[-1]) % mod)\nfor i in range(N+1):\n ans += (-1)**i * ((comb(N, i, mod) * perm(M, i, mod))%mod * (perm(M-i, N-i, mod)**2)%mod)%mod\n ans %= mod\nprint(ans)", "jacc_sim": 0.9795918367346939, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [336, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u135346354", "n_user": "u135346354", "pos": "P = 10**9 + 7\nN, M = map(int, input().split())\n\nd = [0]*(M+1)\nd[0] = 1\nfor i in range(1, M+1):\n d[i] = (d[i-1]*i)%P\n\nans = d[M]*pow(d[M-N], P-2, P)\nans **= 2\nans %= P\nfor i in range(1, N+1):\n temp = (d[N]*pow(d[N-i], P-2, P)*pow(d[i], P-2, P))%P\n temp *= d[M]\n temp %= P\n temp *= pow(d[M-i], P-2, P)\n temp %= P\n temp *= ((d[M-i]*pow(d[max(M-N, 1)], P-2, P))**2)%P\n ans += (temp%P)*(-1)**i\n ans %= P\nprint(ans%P)", "neg": "P = 10**9 + 7\nN, M = map(int, input().split())\n\nd = [0]*(M+1)\nd[0] = 1\nfor i in range(1, M+1):\n d[i] = (d[i-1]*i)%P\n\nans = 0\nfor i in range(N+1):\n temp = (d[N]*pow(d[N-i], P-2, P)*pow(max(i, 1), P-2, P))%P\n temp *= d[M]\n temp %= P\n temp *= pow(d[M-i], P-2, P)\n temp %= P\n temp *= ((d[M-i]*pow(max(M-N, 1), P-2, P))**2)%P\n ans += (temp%P)*(-1)**i\n ans %= P\nprint(ans%P)", "jacc_sim": 1.0, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [246, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02625", "p_user": "u242757684", "n_user": "u242757684", "pos": "MOD = 10 ** 9 + 7\nN,M = map(int,input().split())\nans1 = 1\nfor i in range(N):\n ans1 *= M - i\n ans1 %= MOD\nans2 = [1,M-N]\nfor i in range(2,N+1):\n ans2.append((ans2[-2] * (i -1) + ans2[-1] * (M - N + i - 1))% MOD)\nprint(ans1 * ans2[N] % MOD)", "neg": "MOD = 10 ** 9 + 7\nN,M = map(int,input().split())\nans1 = 1\nfor i in range(N):\n ans1 *= M - i\n ans1 %= MOD\nans2 = [1,M-1]\nfor i in range(2,N+1):\n ans2.append((ans2[-2] * (N-1) + ans2[-1] * (M-1))% MOD)\nprint(ans1 * ans2[N] % MOD)", "jacc_sim": 1.0, "nl": "You are given a problem to count the pairs of length-N sequences made up of integers between 1 and M (inclusive). These sequences, denoted as A1, A2, ..., AN and B1, B2, ..., BN, must satisfy the following conditions: Ai \u2260 Bi for every i such that 1 \u2264 i \u2264 N, and Ai \u2260 Aj and Bi \u2260 Bj for every (i, j) such that 1 \u2264 i < j \u2264 N. The count can be large, so print it modulo (10^9+7). The constraints are 1 \u2264 N \u2264 M \u2264 5*10^5, and all input values are integers. The input is given in the format N M, and the output should be the count modulo (10^9+7). For example, given input 2 2, the output is 2, as there are two valid pairs of sequences.", "before_after_length": [121, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u608088992", "n_user": "u608088992", "pos": "import sys\n\ndef solve():\n input = sys.stdin.readline\n N = int(input())\n A = [int(a) for a in input().split()]\n xorR = 0\n for i in range(2, N):\n xorR ^= A[i]\n rbit = [0] * 41\n K = xorR\n for i in range(41):\n rbit[i] = K % 2\n K //= 2\n \n D = A[0] + A[1] - xorR\n if D < 0 or D % 2 == 1:\n print(-1)\n return 0\n else:\n D //= 2\n if D > A[0]:\n print(-1)\n return 0\n\n K = D\n dbit = [0] * 41\n for i in range(41):\n dbit[i] = K % 2\n K //= 2\n \n A0 = D\n for i in range(41):\n if rbit[40 - i] == dbit[40 - i] and rbit[40 - i] == 1:\n print(-1)\n return 0\n else:\n if rbit[40 - i] == 1:\n if A0 + pow(2, 40 - i) <= A[0]:\n A0 += pow(2, 40 - i)\n if A0 > 0: print(A[0] - A0)\n else: print(-1)\n\n return 0\n\nif __name__ == \"__main__\":\n solve()", "neg": "import sys\n\ndef solve():\n input = sys.stdin.readline\n N = int(input())\n A = [int(a) for a in input().split()]\n xorR = 0\n for i in range(2, N):\n xorR ^= A[i]\n rbit = [0] * 40\n K = xorR\n for i in range(40):\n rbit[i] = K % 2\n K //= 2\n \n D = A[0] + A[1] - xorR\n if D < 0 or D % 2 == 1:\n print(-1)\n return 0\n else:\n D //= 2\n K = D\n dbit = [0] * 40\n for i in range(40):\n dbit[i] = K % 2\n K //= 2\n A0, A1 = 0, 0\n for i in range(40):\n if rbit[39 - i] == dbit[39 - i] == 1:\n print(-1)\n break\n else:\n if rbit[39 - i] == 1:\n if (A0 + pow(2, 39 - i)) ^ D <= A[0]:\n A0 += pow(2, 39 - i)\n else:\n A1 += pow(2, 39 - i)\n if A0 > 0: print(A[0] - A0)\n else: print(-1)\n\n return 0\n\nif __name__ == \"__main__\":\n solve()", "jacc_sim": 0.9122807017543859, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [373, 367], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u923270446", "n_user": "u923270446", "pos": "n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in a[2:]:x^=i\nm=(a[0]+a[1]-x)//2\nif a[0]+a[1]!=x+m*2or m>a[0]or(x&m)!=0:exit(print(-1))\nl=1<<(max(x.bit_length(),m.bit_length())+1)\nwhile l>0:\n if((x&l)!=0)and((m|l)<=a[0]):m|=l\n l>>=1\nprint(a[0]-m if m!=0else-1)", "neg": "n=int(input())\na=list(map(int, input().split()))\nx=0\nfor i in a[2:]:x^=i\nm=(a[0]+a[1]-x)//2\nif a[0]+a[1]!=x+m*2or m>a[0]or(m&x)!=0:exit(print(-1))\nl=1<0:\n if (x&l)!=0and(m|l)<=a[0]:m|=l\n l>>=1\nprint(a[0]-m if a!=0else-1)", "jacc_sim": 0.9555555555555556, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [173, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u754022296", "n_user": "u754022296", "pos": "n = int(input())\na, b, *L = map(int, input().split())\nx = 0\nfor l in L:\n x ^= l\ns = a+b\nif s-x < 0 or (s-x)%2:\n print(-1)\n exit()\nd = (s-x)//2\nif d&x:\n print(-1)\n exit()\nif d > a:\n print(-1)\n exit()\nfor i in range(50, -1, -1):\n if (x>>i)&1 and d|(1< a:\n print(-1)\n exit()\nfor i in range(50, -1, -1):\n if (x>>i)&1 and d|(1<> bit & 1 == 0 and AND >> bit & 1 == 1:\n u |= 1 << bit\n v |= 1 << bit\n elif XOR >> bit & 1 == 1 and AND >> bit & 1 == 0:\n bits.append(bit)\n\nfor bit in bits:\n if (u | (1 << bit)) <= A[0]:\n u |= 1 << bit\n\nif u > A[0] or u == 0:\n print(-1)\n exit(0)\nprint(A[0] - u)", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\nXOR = 0\nfor el in A[2:]:\n XOR ^= el\n\nif (A[0] + A[1] - XOR) % 2 != 0:\n print(-1)\n exit(0)\n\nAND = (A[0] + A[1] - XOR) // 2\nif XOR & AND != 0:\n print(-1)\n exit(0)\n\nok = False\nu = 0\nv = 0\n\nbits = list()\nfor bit in range(60, -1, -1):\n if XOR >> bit & 1 == 0 and AND >> bit & 1 == 1:\n u |= 1 << bit\n v |= 1 << bit\n elif XOR >> bit & 1 == 1 and AND >> bit & 1 == 0:\n bits.append(bit)\n\nfor bit in bits:\n if (u | (1 << bit)) <= A[0]:\n u |= 1 << bit\n\nif u > A[0]:\n print(-1)\n exit(0)\nprint(A[0] - u)", "jacc_sim": 0.9791666666666666, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [271, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u368796742", "n_user": "u368796742", "pos": "n = int(input())\nl = list(map(int,input().split()))\n\nx = 0\ns = l[0]+l[1]\nfor i in l[2:]:\n x ^= i\nif x > s or (s-x)%2 or ((s-x)//2)&x:\n print(-1)\n exit()\na = (s-x)//2\nif a > l[0]:\n print(-1)\n exit()\nfor i in range(50,-1,-1):\n if 1< s or (s-x)%2 or ((s-x)//2)&x:\n print(-1)\n exit()\na = (s-x)//2\nif a > l[0]:\n print(-1)\nfor i in range(50,-1,-1):\n if 1< X[0]:\n print(-1)\n sys.exit()\nY = 0\nfor i in range(M, -1, -1):\n if T & (1< X[0]:\n print(-1)\n sys.exit()\nY = 0\nfor i in range(M, -1, -1):\n if T & (1< X[0]:\n print(-1)\n sys.exit()\na = 0\nfor i in range(M, -1, -1):\n if (T >> i)&1 and ((1<>1, y>>1, z>>1)\n Ro = inf\n if x:\n Ro = 2*it((x-1)>>1, (y+1)>>1, z>>1)+1\n Rz = min(Rz, Ro)\n d[(x, y, z)] = Rz\n return Rz\n\nr = it(X[0], X[1], t^X[0]^X[1])\nif 0 <= r < X[0]:\n print(r)\nelse:\n print(-1)\n", "neg": "N, = map(int, input().split())\nX = list(map(int, input().split()))\nt = 0\nfor x in X:\n t = t^x\ninf = float('inf')\nd = dict()\ndef it(x, y, z):\n if (x, y, z) in d:\n return d[(x, y, z)]\n xm, ym, zm = x%2, y%2, z%2\n if xm ^ ym != zm:\n d[(x, y, z)] = inf\n return inf\n if x^y == z:\n d[(x, y, z)] = 0\n return 0\n Rz = 2*it(x>>1, y>>1, z>>1)\n Ro = inf\n if x:\n Ro = 2*it((x-1)>>1, (y+1)>>1, z>>1)+1\n Rz = min(Rz, Ro)\n d[(x, y, z)] = Rz\n return Rz\n\nr = it(X[0], X[1], t^X[0]^X[1])\nif 0 < r < 10**18:\n print(r)\nelse:\n print(-1)\n", "jacc_sim": 0.9615384615384616, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [308, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u169350228", "n_user": "u169350228", "pos": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n = int(ipt())\n a = [int(i) for i in ipt().split()]\n x = 0\n for i in a[2::]:\n x ^= i\n s = a[0]+a[1]\n d = (s-x)//2\n if d < 0 or d&x or (s-x)&1 or d > a[0]:\n print(-1)\n exit()\n a1 = d\n xi = 1\n kx = x\n while kx > 0:\n xi *= 2\n kx >>= 1\n xi //= 2\n while xi > 0:\n if x&xi:\n if a1+xi <= a[0]:\n a1 += xi\n x -= xi\n xi //= 2\n if a1 == 0:\n print(-1)\n exit()\n else:\n print(a[0]-a1)\n\n return\n\nif __name__ == '__main__':\n main()\n", "neg": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n = int(ipt())\n a = [int(i) for i in ipt().split()]\n x = 0\n for i in a[2::]:\n x ^= i\n s = a[0]+a[1]\n d = (s-x)//2\n if d < 0 or d&x or d > a[0]:\n print(-1)\n exit()\n a1 = d\n xi = 1\n kx = x\n while kx > 0:\n xi *= 2\n kx >>= 1\n xi //= 2\n while xi > 0:\n if x&xi:\n if a1+xi <= a[0]:\n a1 += xi\n x -= xi\n xi //= 2\n if a1 == a[0]:\n print(-1)\n exit()\n else:\n print(a[0]-a1)\n\n return\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [323, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u201928947", "n_user": "u201928947", "pos": "n = int(input())\na = list(map(int,input().split()))\nx = 0\nfor i in range(2,n):\n x ^= a[i]\ns = a[0]+a[1]\nif s < x or (s-x) % 2 == 1:\n print(-1)\n exit()\nd = (s-x)//2\nif d & x != 0 or d > a[0]:\n print(-1)\n exit()\ni = 50\nans = d\nwhile i >= 0:\n if x >> i & 1:\n if (1 << i) + ans <= a[0]:\n ans += 1 << i\n i -= 1\nif ans == 0:\n print(-1)\n exit()\nprint(a[0]-ans)", "neg": "n = int(input())\na = list(map(int,input().split()))\nx = 0\nfor i in range(2,n):\n x ^= a[i]\ns = a[0]+a[1]\nif s < x or (s-x) % 2 == 1:\n print(-1)\n exit()\nd = (s-x)//2\nif d & x != 0 or d > a[0]:\n print(-1)\n exit()\ni = 50\nans = d\nwhile i >= 0:\n if x >> i & 1:\n if 1 << i + ans <= a:\n ans += a << i\n i -= 1\nprint(a[0]-ans)", "jacc_sim": 1.0, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [189, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u711539583", "n_user": "u711539583", "pos": "import sys\nn = int(input())\na = list(map(int, input().split()))\nc = a[0] + a[1]\n\nt = 0\n\nfor ai in a[2:]:\n t = t ^ ai\n\nbit_len = c.bit_length()+1\n\nif c < t:\n print(-1)\n sys.exit()\n\nif (c-t) % 2:\n print(-1)\n sys.exit()\n\nb1 = (c - t) // 2\n\n\na1 = b1\na2 = b1\n\n\nif a1 > a[0]:\n print(-1)\n sys.exit()\n \n\nfor i in reversed(range(bit_len)):\n if t & (1 << i):\n if b1 & (1 << i):\n print(-1)\n sys.exit()\n if a1 + 2 ** i <= a[0]:\n a1 += 2 ** i\n\nif a1 == 0:\n print(-1)\nelse:\n print(a[0]-a1)\n \n\n", "neg": "import sys\nn = int(input())\na = list(map(int, input().split()))\nc = a[0] + a[1]\n\nt = 0\n\nfor ai in a[2:]:\n t = t ^ ai\n\nbit_len = c.bit_length()+1\n\nif c < t:\n print(-1)\n sys.exit()\n\nif (c-t) % 2:\n print(-1)\n sys.exit()\n\nb1 = (c - t) // 2\n\n\na1 = b1\na2 = b1\n\n\nif a1 > a[0]:\n sys.exit()\n\nfor i in reversed(range(bit_len)):\n if t & (1 << i):\n if a1 + 2 ** i <= a[0]:\n a1 += 2 ** i\n\nif a1 == 0:\n print(-1)\nelse:\n print(a[0]-a1)\n \n\n", "jacc_sim": 1.0, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [266, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u242757684", "n_user": "u242757684", "pos": "N = int(input())\nA = list(map(int,input().split()))\nxorValue = 0\nsumValue = A[0] + A[1]\nfor i in range(2,N):\n xorValue ^= A[i]\nif sumValue % 2 != xorValue % 2:\n print(-1)\nelse:\n Base = (sumValue - xorValue) // 2\n if Base > A[0]:\n print(-1)\n else:\n strXOR = bin(xorValue)[2:]\n minStoneMovement = A[0] - Base\n strBase = bin(Base)[2:]\n lenStrXOR = len(strXOR)\n cannotMove = False\n if Base < 0:\n cannotMove = True\n for i in range(-1,-1 * min(len(strXOR),len(strBase)) - 1,-1):\n if strBase[i] == '1' and strXOR[i] == '1':\n cannotMove = True\n break\n if not cannotMove:\n for i in range(lenStrXOR):\n if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):\n minStoneMovement -= 2 ** (lenStrXOR - 1 - i)\n if minStoneMovement == A[0] or cannotMove:\n print(-1)\n else:\n print(minStoneMovement)", "neg": "N = int(input())\nA = list(map(int,input().split()))\nxorValue = 0\nsumValue = A[0] + A[1]\nfor i in range(2,N):\n xorValue ^= A[i]\nif sumValue % 2 != xorValue % 2:\n print(-1)\nelse:\n Base = (sumValue - xorValue) // 2\n if Base > A[0]:\n print(-1)\n else:\n strXOR = bin(xorValue)[2:]\n minStoneMovement = A[0] - Base\n strMinMove = bin(minStoneMovement)[2:]\n lenStrXOR = len(strXOR)\n cannotMove = False\n if len(strMinMove) > len(strXOR):\n cannotMove = True\n else:\n for i in range(lenStrXOR):\n if strXOR[i] == '0' and i >= len(strXOR) - len(strMinMove) and strMinMove[i + len(strMinMove) - len(strXOR)] == '1':\n cannotMove = True\n break\n if strXOR[i] == '1' and minStoneMovement >= 2 ** (lenStrXOR - 1 - i):\n minStoneMovement -= 2 ** (lenStrXOR - 1 - i)\n if minStoneMovement == A[0] or cannotMove:\n print(-1)\n else:\n print(minStoneMovement)", "jacc_sim": 0.9464285714285714, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [351, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u864197622", "n_user": "u864197622", "pos": "N = int(input())\nA = [int(a) for a in input().split()]\nt = 0\nfor a in A[2:]:\n t ^= a\ns = sum(A[:2])\nif s < t or (s ^ t) & 1:\n print(-1)\n exit()\n\nu = (s - t) // 2\na = A[0]\nn = 0\nfor i in range(40)[::-1]:\n b, c = (t >> i) & 1, (u >> i) & 1\n if b == c == 1:\n print(-1)\n exit()\n if b == 0 and c == 1:\n n += 1 << i\nfor i in range(40)[::-1]:\n b, c = (t >> i) & 1, (u >> i) & 1\n if b == 1 and c == 0:\n if n + (1 << i) <= a:\n n += 1 << i\n\nif n > a or n == 0:\n print(-1)\nelse:\n print(a - n)", "neg": "N = int(input())\nA = [int(a) for a in input().split()]\nt = 0\nfor a in A[2:]:\n t ^= a\ns = sum(A[:2])\nif s < t or (s ^ t) & 1:\n print(-1)\n exit()\n\nu = (s - t) // 2\n\na = A[0]\nn = 0\nfor i in range(40)[::-1]:\n b, c = (t >> i) & 1, (u >> i) & 1\n if b == c == 1:\n print(-1)\n exit()\n if b == 0 and c == 1:\n n += 1 << i\nfor i in range(40)[::-1]:\n b, c = (t >> i) & 1, (u >> i) & 1\n if b == 1 and c == 0:\n if n + (1 << i) <= a:\n n += 1 << i\nif n > a:\n print(-1)\nelse:\n print(a - n)", "jacc_sim": 1.0, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [257, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02626", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nn,*a = map(int,read().split())\n\nv = 0\nfor i in a[2:]:\n v ^= i\n\nw = a[0]+a[1]\n\nz = w-v\nif z&1==1 or z<0:\n print(-1)\nelse:\n z //= 2\n \"\"\"\n z = p&q\n v = p^q\n \"\"\"\n if z&v:\n print(-1)\n exit()\n\n ans = z\n for i in range(60,-1,-1):\n m = 1< a[0] or ans==0: print(-1)\n else: print(a[0]-ans) \n \n \n \n \n \n\n\n\n\n", "neg": "# coding: utf-8\n# Your code here!\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\n\nn,*a = map(int,read().split())\n\nv = 0\nfor i in a[2:]:\n v ^= i\n\nw = a[0]+a[1]\n\nz = w-v\nif z&1 or z<0 or z&w:\n print(-1)\nelse:\n z //= 2\n \"\"\"\n z = p&q\n v = p^q\n \"\"\"\n #print(z,v,z&w)\n ans = z\n for i in range(60,-1,-1):\n m = 1<= a[0] or ans==0: print(-1)\n else: print(a[0]-ans) \n \n \n \n \n \n\n\n\n\n", "jacc_sim": 0.9818181818181818, "nl": "You are given N piles of stones, each with a different number of stones. Aoki and Takahashi take turns removing stones from a single pile. The player unable to make a move loses. Takahashi, the second player, aims to guarantee his win by moving 0 to (A1 - 1) stones from the first pile to the second before the game starts. If possible, print the minimum number of stones to move; otherwise, print -1. Constraints: 2 \u2264 N \u2264 300, 1 \u2264 Ai \u2264 10^12. Input format: N followed by A1...AN. Output the minimum number of stones to move or -1. Examples: (1) Input: 2, 5 3; Output: 1. (2) Input: 2, 3 5; Output: -1. (3) Input: 3, 1 1 2; Output: -1. (4) Input: 8, 10 9 8 7 6 5 4 3; Output: 3. (5) Input: 3, 4294967297 8589934593 12884901890; Output: 1. Note: Watch out for overflows.", "before_after_length": [258, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u478275206", "n_user": "u478275206", "pos": "A,B,C,D = map(int, input().split())\n\nP=998244353\n\ndp = [[0 for j in range(3002)] for i in range(3002)]\ndp[A][B] = 1\n\nfor row in range(A, C + 1):\n for col in range(B, D + 1):\n dp[row][col] += col * dp[row - 1][col] + row * dp[row][col - 1]\n dp[row][col] -= (row - 1) * (col - 1) * dp[row - 1][col - 1]\n dp[row][col] %= P\n\nprint(dp[C][D])", "neg": "A,B,C,D = map(int, input().split())\n\nP=998244353\n\ndp = [[[0 for k in range(2)] for j in range(3002)] for i in range(3002)]\ndp[A][B][1] = 1\n\nfor row in range(A, C + 1):\n for col in range(B, D + 1):\n dp[row][col + 1][1] += dp[row][col][0] + row * dp[row][col][1]\n dp[row][col + 1][1] %= P\n dp[row + 1][col][0] = col * (dp[row][col][0] + dp[row][col][1])\n\nprint((dp[C][D][0]+dp[C][D][1])%P)", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [164, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u052499405", "n_user": "u052499405", "pos": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\n\na, b, c, d = map(int, input().split())\ndp = [[0] * (d - b + 1) for _ in range(c - a + 1)]\n\ndp[0][0] = 1\nfor i in range(c - a + 1):\n for j in range(d - b + 1):\n if i > 0:\n dp[i][j] += dp[i-1][j] * (b+j)\n if j > 0:\n dp[i][j] += dp[i][j-1] * (a+i)\n if i > 0 and j > 0:\n dp[i][j] -= dp[i-1][j-1] * (b+j-1) * (a+i-1)\n dp[i][j] %= 998244353\n\nprint(dp[-1][-1])", "neg": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nMOD = 998244353\n\na, b, c, d = map(int, input().split())\n\ndp = [[0] * d for _ in range(c)]\ndp[a-1][b-1] = 1\nfor i in range(c):\n for j in range(d):\n # Use i, j\n if i - 1 >= 0:\n dp[i][j] += dp[i-1][j]\n if j - 1 >= 0:\n dp[i][j] += dp[i][j-1]\n # Use others\n if i - 1 >= 0:\n dp[i][j] += dp[i][j-1] * i \n dp[i][j] %= MOD\n\nprint(dp[-1][-1])", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [232, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u375616706", "n_user": "u375616706", "pos": "A,B,C,D = map(int,input().split())\n\nMOD=998244353\n\n#dp[i][j]\u305f\u3066\u306bi\u56de\u3001\u6a2a\u306bj\u56de\u8ffd\u52a0\u3057\u305f\u3068\u304d\u306e\u6570\nDP=[[0]*(D-B+1) for _ in range(C-A+1)]\nDP[0][0]=1\n\nfor i in range(1,C-A+1):\n DP[i][0]=DP[i-1][0]*B\n DP[i][0]%=MOD\nfor i in range(1,D-B+1):\n DP[0][i]=DP[0][i-1]*A\n DP[0][i]%=MOD\n\nfor i in range(1,min(C-A,D-B)+1):\n for j in range(i,C-A+1):\n DP[j][i] = DP[j-1][i]*(B+i) + DP[j][i-1]*(A+j)-DP[j-1][i-1]*(B+i-1)*(A+j-1)\n DP[j][i]%=MOD\n for j in range(i+1,D-B+1):\n DP[i][j] = DP[i-1][j]*(B+j) + DP[i][j-1]*(A+i)-DP[i-1][j-1]*(B+j-1)*(A+i-1)\n DP[i][j]%=MOD\n\n\nprint(DP[-1][-1])\n", "neg": "A,B,C,D = map(int,input().split())\n\nMOD=998244353\n\n#dp[i][j]\u305f\u3066\u306bi\u56de\u3001\u6a2a\u306bj\u56de\u8ffd\u52a0\u3057\u305f\u3068\u304d\u306e\u6570\nDP=[[0]*(D-B+1) for _ in range(C-A+1)]\nDP[0][0]=1\n\nfor i in range(1,C-A+1):\n DP[i][0]=DP[i-1][0]*B\n DP[i][0]%=MOD\nfor i in range(1,D-B+1):\n DP[0][i]=DP[0][i-1]*A\n DP[0][i]%=MOD\n\nprint(DP)\n\nfor i in range(1,min(C-A,D-B)+1):\n for j in range(i,C-A+1):\n DP[j][i] = DP[j-1][i]*(B+i) + DP[j][i-1]*(A+j)-DP[j-1][i-1]*(B+i-1)*(A+j-1)\n DP[j][i]%=MOD\n for j in range(i+1,D-B+1):\n DP[i][j] = DP[i-1][j]*(B+j) + DP[i][j-1]*(A+i)-DP[i-1][j-1]*(B+j-1)*(A+i-1)\n DP[i][j]%=MOD\n\nprint(DP[-1][-1])\n", "jacc_sim": 1.0, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [425, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u070201429", "n_user": "u070201429", "pos": "mod = 998244353\na, b, c, d = map(int, input().split())\n\ndp0 = [0] * (c-a+1)\ndp1 = [1]\nfor i in range(c-a):\n dp1.append(dp1[-1] * b % mod)\n\nfor j in range(1, d-b+1):\n new_dp0 = [(dp0[0] * a + dp1[0]) % mod]\n new_dp1 = [dp1[0] * (a-1) % mod]\n for i in range(1, c-a+1):\n new_dp0.append((dp0[i] * (a+i) + dp1[i]) % mod)\n new_dp1.append((new_dp0[-2] + new_dp1[-1]) * (b+j) % mod)\n\n dp0 = new_dp0\n dp1 = new_dp1\n\nprint((dp0[-1] + dp1[-1]) % mod)", "neg": "mod = 998244353\na, b, c, d = map(int, input().split())\n\ndp0 = [0] * (c-a+1)\ndp1 = [1]\n\nfor i in range(c-a):\n dp1.append(dp1[-1] * b % mod)\n\ni = [dp0[i] + dp1[i] for i in range(len(dp0))]\nprint(i)\n\nfor j in range(1, d-b+1):\n new_dp0 = [(dp0[0] * a + dp1[0]) % mod]\n new_dp1 = [dp1[0] * (a-1) % mod]\n for i in range(1, c-a+1):\n new_dp0.append((dp0[i] * (a+i) + dp1[i]) % mod)\n new_dp1.append((new_dp0[-2] + new_dp1[-1]) * (b+j) % mod)\n\n dp0 = new_dp0\n dp1 = new_dp1\n\n i = [dp0[i] + dp1[i] for i in range(len(dp0))]\n print(i)\n\nprint(dp0[-1] + dp1[-1])", "jacc_sim": 0.972972972972973, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [251, 315], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u860002137", "n_user": "u860002137", "pos": "a, b, c, d = map(int, input().split())\nMOD = 998244353\n\ndp = [[0] * (d - b + 1) for _ in range(c - a + 1)]\n\ndp[0][0] = 1\n\nfor x in range(1, d - b + 1):\n dp[0][x] = dp[0][x - 1] * a % MOD\nfor y in range(1, c - a + 1):\n dp[y][0] = dp[y - 1][0] * b % MOD\n\nfor x in range(1, c - a + 1):\n for y in range(1, d - b + 1):\n dp[x][y] = (dp[x - 1][y] * (b + y) + dp[x][y - 1] * (a + x) - dp[x - 1][y - 1] * (a + x - 1) * (b + y - 1)) % MOD\n\nprint(dp[-1][-1])", "neg": "a, b, c, d = map(int, input().split())\nMOD = 998244353\n\ndp = [[0] * (d - b + 1) for _ in range(c - a + 1)]\n\ndp[0][0] = 1\n\nfor x in range(1, d - b + 1):\n dp[0][x] = dp[0][x - 1] * a % MOD\nfor y in range(1, c - a + 1):\n dp[y][0] = dp[y - 1][0] * b % MOD\n\nfor x in range(1, c - a + 1):\n for y in range(1, d - b + 1):\n dp[x][y] = (dp[x - 1][y] * (b + y) + dp[x][y - 1] * (a + x)) % MOD\n \nprint(dp[-1][-1])", "jacc_sim": 1.0, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [241, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02634", "p_user": "u145600939", "n_user": "u145600939", "pos": "a,b,c,d = map(int,input().split())\nmod = 998244353\ndp = [[0]*(d-b+1) for i in range(c-a+1)]\nif a == c and b == d:\n print(1)\nelif a == c:\n print(pow(a,d-b,mod))\nelif b == d:\n print(pow(b,c-a,mod))\nelse:\n for i in range(c-a):\n p = 0\n for j in range(d-b+1):\n if i == j == 0:\n dp[i][j] = 1\n dp[i+1][j] = (p + dp[i][j]*(b+j))%mod\n\n p += dp[i][j]\n p %= mod\n p *= a+i\n p %= mod\n\n ans = 0\n for d in dp[-1]:\n ans *= c\n ans %= mod\n ans += d\n ans %= mod\n print(ans)", "neg": "a,b,c,d = map(int,input().split())\nmod = 998244353\ndp = [[0]*(d-b+1) for i in range(c-a+1)]\nif a == c and b == d:\n print(1)\nelif a == c:\n print(a)\nelif b == d:\n print(b):\nelse:\n for i in range(c-a):\n p = 0\n for j in range(d-b+1):\n if i == j == 0:\n dp[i][j] = 1\n dp[i+1][j] = (p + dp[i][j]*(b+j))%mod\n\n p += dp[i][j]\n p %= mod\n p *= a+i\n p %= mod\n\n ans = 0\n for d in dp[-1]:\n ans *= c\n ans %= mod\n ans += d\n ans %= mod\n print(ans)", "jacc_sim": 0.9736842105263158, "nl": "You are given a grid with A horizontal rows and B vertical columns, initially all painted white. You can repeatedly add a row or column to the grid and then paint one of the added squares black. The grid eventually has C horizontal rows and D vertical columns. Find the number of ways to paint the squares in the end, modulo 998244353. Constraints: 1 \u2264 A \u2264 C \u2264 3000, 1 \u2264 B \u2264 D \u2264 3000. Input format: A B C D. Output: Number of ways to paint the squares. Example: Input: 1 1 2 2, Output: 3 (any two of the three squares other than the bottom-left square can be painted black).", "before_after_length": [254, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02635", "p_user": "u104282757", "n_user": "u104282757", "pos": "MOD = 998244353\n\n\ndef solve(s, k):\n one_count = []\n ones = 0\n for st in s:\n if st == \"1\":\n ones += 1\n else:\n one_count.append(ones)\n ones = 0\n one_count.append(ones)\n ss = sum(one_count)\n # print(ss)\n m = len(one_count)\n dp = [[[0] * (ss + 1) for _ in range(ss + 1)] for __ in range(m + 1)]\n dp[0][0][0] = 1\n for i in range(m):\n c = one_count[i]\n for j in range(ss + 1):\n for p in range(ss + 1):\n dp[i][j][p] %= MOD\n for q in range(ss + 1 - max(j, p)):\n dp[i + 1][j + q][p + q] += dp[i][j][p]\n for q in range(-c, 0):\n if j + q >= 0:\n dp[i + 1][j + q][p] += dp[i][j][p]\n\n # print(dp)\n res = sum([dp[m][0][p] for p in range(min(k + 1, ss + 1))])\n # print(res)\n return res % MOD\n\n\ndef main():\n s, k_ = input().split()\n k = int(k_)\n res = solve(s, k)\n print(res)\n\n\ndef test():\n assert solve(\"0101\", 1) == 4\n assert solve(\"01100110\", 2) == 14\n assert solve(\"1101010010101101110111100011011111011000111101110101010010101010101\", 20) == 113434815\n\n\nif __name__ == \"__main__\":\n test()\n main()\n", "neg": "MOD = 998244353\n\n\ndef solve(s, k):\n one_count = []\n ones = 0\n for st in s:\n if st == \"1\":\n ones += 1\n else:\n one_count.append(ones)\n ones = 0\n one_count.append(ones)\n m = len(one_count)\n dp = [[[0] * 300 for _ in range(300)] for __ in range(m + 1)]\n dp[0][0][0] = 1\n for i in range(m):\n c = one_count[i]\n for j in range(300):\n for p in range(300):\n dp[i][j][p] %= MOD\n for q in range(300 - max(j, p)):\n dp[i + 1][j + q][p + q] += dp[i][j][p]\n for q in range(-c, 0):\n dp[i + 1][j + q][p] += dp[i][j][p]\n\n # print(dp)\n res = sum([dp[m][0][p] for p in range(k + 1)])\n # print(res)\n return res % MOD\n\n\ndef main():\n s, k_ = input().split()\n k = int(k_)\n res = solve(s, k)\n print(res)\n\n\ndef test():\n assert solve(\"0101\", 1) == 4\n assert solve(\"01100110\", 2) == 14\n assert solve(\"1101010010101101110111100011011111011000111101110101010010101010101\", 20) == 113434815\n\n\nif __name__ == \"__main__\":\n test()\n main()\n", "jacc_sim": 0.9402985074626866, "nl": "You are given a string S consisting of 0s and 1s. Find the number of strings, modulo 998244353, that can result from applying a specific operation on S between 0 and K times (inclusive). The operation involves choosing a pair of integers i, j (1\u2264i= m:\n x += dp[i-1][j-m][k]\n else:\n x += dp[i-1][j-m][k-(m-num)]\n dp[i][j][k] = x%mod\n smprv += num\nans = 0\nfor i in range(sm+1):\n if i <= K:\n ans += dp[-1][-1][i]\n ans %= mod\nprint(ans)", "neg": "s,k = input().split()\nK = int(k)\nif s[-1] == \"1\":\n s += \"0\"\nn = len(s)\nls = []\ncnt = 0\nfor i in range(n):\n if s[i] == \"0\":\n ls.append(cnt)\n cnt = 0\n else:\n cnt += 1\nl = len(ls)\nsm = sum(ls)\nmod = 998244353\ndp = [[[0 for i in range(sm+1)] for j in range(sm+1)] for k in range(l+1)]\ndp[0][0][0] = 1\nsmprv = 0\nfor i in range(1,l+1):\n num = ls[i-1]\n for j in range(smprv+num,sm+1):\n if j == smprv+num:\n dp[i][j][0] = 1\n for k in range(1,sm+1):\n for m in range(j+1):\n if num >= m:\n dp[i][j][k] += dp[i-1][j-m][k]\n else:\n dp[i][j][k] += dp[i-1][j-m][k-(m-num)]\n dp[i][j][k] %= mod\n else:\n for k in range(1,sm+1):\n dp[i][j][k] += dp[i][j-1][k-1]+dp[i-1][j-num][k]\n dp[i][j][k] %= mod\n smprv += num\n\nans = 0\nfor i in range(sm+1):\n if i <= K:\n ans += dp[-1][-1][i]\n ans %= mod\nprint(ans)", "jacc_sim": 0.9782608695652174, "nl": "You are given a string S consisting of 0s and 1s. Find the number of strings, modulo 998244353, that can result from applying a specific operation on S between 0 and K times (inclusive). The operation involves choosing a pair of integers i, j (1\u2264i 3 else str\n \nval = input()\nprint(first_three(val))", "neg": "def first_three(str):\n\treturn str[:3] if len(str) > 3 else str\n \n val = input()\n print(first_three(val))\n", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [41, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u113569368", "n_user": "u185806788", "pos": "S = input()\n\nprint(S[0]+S[1]+S[2])", "neg": "S=input()\nprint(\"S[0]\"+\"S[1]\"+\"S[2]\")", "jacc_sim": 0.9230769230769231, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [20, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u571395477", "n_user": "u571395477", "pos": "import sys\nimport random\n\ndef main():\n S = input()\n l = len(S)\n n = [0, 1, 2]\n out = S[n[0]] + S[n[1]] + S[n[2]]\n \n print(out)\nmain()", "neg": "import sys\nimport random\n\ndef main():\n S = input()\n l = len(S)\n n = [0, 1, l-1]\n out = S[n[0]] + S[n[1]] + S[n[2]]\n \n print(out)\nmain()", "jacc_sim": 0.9583333333333334, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [70, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u309821257", "n_user": "u309821257", "pos": "# -*- coding: utf-8 -*-\n\n_in = input()\n\n# if True:\n# print(_in)\n# else:\n# print(_in)\n\nprint(_in[0:3])\n", "neg": "# -*- coding: utf-8 -*-\n\n_in = input()\n\n# if True:\n# print(_in)\n# else:\n# print(_in)\n\nprint(_in[1:3])", "jacc_sim": 0.9047619047619048, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [54, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u636615077", "n_user": "u636615077", "pos": "import math\nimport os\nimport random\nimport re\nimport sys\nimport collections\nimport itertools\n\ndef solution(data):\n return data[:3]\n\n\nif __name__==\"__main__\":\n a = input()\n print(solution(a))\n", "neg": "import math\nimport os\nimport random\nimport re\nimport sys\nimport collections\nimport itertools\n\ndef solution(data):\n return data[:3]\n\n\nif __name__==\"__main__\":\n \ta = input()\n\n print(solution(a))\n", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [61, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u065099501", "n_user": "u844789719", "pos": "print(input()[:3:])", "neg": "print(input([:3]))\n", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [8, 8], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u926046014", "n_user": "u265118937", "pos": "s = input()\n\nprint(s[0],end=\"\")\nprint(s[1],end=\"\")\nprint(s[2],end=\"\")", "neg": "s = input()\nprint(s[2], end=\"\")\nprint(s[1], end=\"\")\nprint(s[0])", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [35, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u388497015", "n_user": "u426092370", "pos": "a = input()\nprint(a[0:3])\n", "neg": "a=input()\nprint(a)\nprint(a[0:3])", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [15, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u284262180", "n_user": "u730807152", "pos": "a = input()\n\nprint(a[:3])\n", "neg": "a = str(input())\n\nprint(a[3:])", "jacc_sim": 0.9090909090909091, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [13, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u701017915", "n_user": "u227597629", "pos": "S = input()\nnickname = S[:3]\nprint(nickname)", "neg": "nickname = input('S ')\n\nprint(nickname[:3])", "jacc_sim": 0.9166666666666666, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [18, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u475503988", "n_user": "u483331319", "pos": "S = input()\nans = S[:3]\nprint(ans)\n", "neg": "S = input()\nprint(S[3:])", "jacc_sim": 0.9090909090909091, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [17, 12], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u878389297", "n_user": "u206352909", "pos": "a=input()\nb=a[:3]\nprint(b)", "neg": "a=input()\nprint(a[3:])", "jacc_sim": 0.9090909090909091, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [16, 12], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u106778233", "n_user": "u702018889", "pos": "s=input()\nprint(s[:2]+s[2])", "neg": "s=input()\nprint(s[:2])", "jacc_sim": 0.9090909090909091, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [15, 11], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u007263493", "n_user": "u196757406", "pos": "s = input()\nt = s[0:3]\nprint(t)", "neg": " s = input()\n \n print(s[0:3])", "jacc_sim": 0.9166666666666666, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [18, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u617037231", "n_user": "u617037231", "pos": "S = input()\nans = S[0:3]\nprint(ans)", "neg": "S = int(input())\nans = S[0:3]\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [18, 20], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u288430479", "n_user": "u731807761", "pos": "s =input()\nprint(s[0:3])", "neg": "S = input()\n\nprint(s[0:3])", "jacc_sim": 0.9166666666666666, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [13, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u709304134", "n_user": "u642341748", "pos": "S = input()\nprint (S[:3])", "neg": "S = input()\nS = str()\n\nprint(S[:3])", "jacc_sim": 0.9090909090909091, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [11, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02645", "p_user": "u583276018", "n_user": "u000351359", "pos": "s = input()\n\n\nprint(s[:3])", "neg": "s = input()\nprint s[:3]", "jacc_sim": 1.0, "nl": "You are given a string, S, of length between 3 and 20, consisting of lowercase English letters. Choose three consecutive characters from S to create a nickname. Print the valid nickname. The input is given as S, and the output should be the chosen nickname.", "before_after_length": [13, 10], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02652", "p_user": "u493130708", "n_user": "u493130708", "pos": "S = list(input())\nN = len(S)\n\n\nZ = 0\nSUM = 0\nfor s in S:\n if s == \"1\":\n SUM += 1\n Z = max(Z,SUM)\n else:\n SUM -= 1\n\nruiseki_max = [0]\nMAX = SUM\nfor s in S[1:][::-1]:\n if s == \"1\":\n SUM -= 1\n else:\n SUM += 1\n MAX = max(MAX,SUM)\n ruiseki_max.append(MAX-SUM)\n\ndef f(Z):\n SUM = 0\n MIN = 0\n for i in range(N):\n s = S[i]\n if s == \"1\":\n SUM += 1\n elif s == \"0\":\n SUM -= 1\n MIN = min(MIN,SUM)\n else:\n if SUM + 1 + ruiseki_max[N-1-i] <= Z:\n SUM += 1\n else:\n SUM -= 1\n MIN = min(MIN,SUM)\n return MIN\n\nprint(min(Z-f(Z),(Z+1-f(Z+1))))", "neg": "S = list(input())\nN = len(S)\n\n\nZ = 0\nSUM = 0\nfor s in S:\n if s == \"1\":\n SUM += 1\n Z = max(Z,SUM)\n else:\n SUM -= 1\n\nMAX = 0\nSUM = 0\nruiseki_max = []\nfor s in S[::-1]:\n if s == \"1\":\n SUM += 1\n MAX = max(MAX,SUM)\n else:\n SUM -= 1\n ruiseki_max.append(MAX)\n \ndef f(Z):\n SUM = 0\n MIN = 0\n for i in range(N):\n s = S[i]\n if s == \"1\":\n SUM += 1\n elif s == \"0\":\n SUM -= 1\n MIN = min(MIN,SUM)\n else:\n if SUM + ruiseki_max[N-2-i] <= Z:\n SUM += 1\n else:\n SUM -= 1\n MIN = min(MIN,SUM)\n return MIN\n\nprint(min(Z-f(Z),(Z+1-f(Z+1))))", "jacc_sim": 0.975, "nl": "You are given a string S consisting of 0s, 1s, and question marks. Create a new string S' by replacing each question mark with either 0 or 1. The unbalancedness of S' is defined as the maximum absolute difference between the occurrences of 0s and 1s in any substring of S. Find the minimum possible unbalancedness of S'. The constraints are 1 \u2264 |S| \u2264 10^6. The input is given as the string S, and the output should be the minimum possible unbalancedness of S'. Here are some sample inputs and outputs.", "before_after_length": [283, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u627600101", "n_user": "u627600101", "pos": "N, S = map(int, input().split())\nA = list(map(int, input().split()))\nmod = 998244353\ndp = [-1 for _ in range(S+1)]\nvisited = [0]\ndp[0] = 1\ndp = tuple(dp)\nfor k in range(N):\n a = A[k]\n nextdp = list(dp)\n nextvisit = []\n for item in visited:\n #process1 \u8ffd\u52a0\u3059\u308b\n if item + a <= S:\n if nextdp[item+a] == -1:\n nextvisit.append(item+a)\n nextdp[item+a] = 0\n nextdp[item+a] += dp[item]\n nextdp[item+a] %= mod\n #process2 \u8ffd\u52a0\u3057\u306a\u3044\n nextdp[item] += dp[item]\n nextdp[item] %= mod\n dp = tuple(nextdp)\n visited.extend(nextvisit)\n\nprint(max(dp[-1], 0))\n", "neg": "N, S = map(int, input().split())\nA = list(map(int, input().split()))\nmod = 998244353\ndp = [-1 for _ in range(S+1)]\nvisited = [0]\ndp[0] = 1\ndp = tuple(dp)\nfor k in range(N):\n a = A[k]\n nextdp = list(dp)\n nextvisit = []\n for item in visited:\n #process1 \u8ffd\u52a0\u3059\u308b\n if item + a <= S:\n if nextdp[item+a] == -1:\n nextvisit.append(item+a)\n nextdp[item+a] = 0\n nextdp[item+a] += dp[item]\n nextdp[item+a] %= mod\n #process2 \u8ffd\u52a0\u3057\u306a\u3044\n nextdp[item] += dp[item]\n nextdp[item] %= mod\n dp = tuple(nextdp)\n visited.extend(nextvisit)\n\nprint(dp[-1])\n\n", "jacc_sim": 0.9803921568627451, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [268, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u595952233", "n_user": "u968846084", "pos": "n, s = map(int, input().split())\nA = list(map(int, input().split()))\nmod = 998244353\n\ndp = [[0] * (s+1) for i in range(n+1)]\ndp[0][0] = 1\n\nfor i in range(n):\n a = A[i]\n for j in range(s+1):\n if j < s:\n dp[i+1][j] = (dp[i+1][j] + 2*dp[i][j])%mod\n if j+a s:\n continue\n else:\n dp[i][j+nexta] += (dp[i-1][j])%mod\n print((dp[n][s])%mod)\nresolve()", "neg": "def resolve():\n n, s = map(int, input().split())\n a = list(map(int,input().split()))\n dp = [[0]*(s+10) for _ in range(n+10)]\n dp[0][0] = 1\n mod = 998244353\n for i in range(1,n+1):\n nexta = a[i-1]\n for j in range(0, s+1):\n dp[i][j] += (2 * dp[i - 1][j])% mod\n if j + nexta > s:\n continue\n else:\n dp[i][j+nexta] += (dp[i-1][j])%mod\n print((dp[n][s])%mod)\nresolve(()", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [188, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u820888375", "n_user": "u450304927", "pos": "MOD = 998244353\nN, S = map(int, input().split())\nA = list(map(int, input().split()))\n\ndp = [[0 for i in range(S + 1)] for j in range(N + 1)]\n\ndp[0][0] = 1\n\nfor i in range(N):\n for j in range(S + 1):\n dp[i+1][j] += dp[i][j] * 2\n dp[i+1][j] %= MOD\n if j + A[i] <= S:\n dp[i + 1][j + A[i]] += dp[i][j]\n dp[i + 1][j + A[i]] %= MOD\nprint(dp[N][S])\n", "neg": "N, S = map(int,input.split())\nA = list(map(int, input.split()))\nmod = 998244353\ndp = [[0 for j in range(S+1)] for i in range(N+1)]\ndp[0][0] = 1\nfor i in range(N):\n\tfor j in range(S+1):\n\t\tdp[i + 1][j] += 2 * dp[i][j]\n dp[i + 1][j] %= mod \n if j + A[i] <= S : \n dp[i + 1][j + A[i]] += dp[i][j]\n dp[i + 1][j + A[i]] %= mod\nprint(dp[N][S])\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [179, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u330728443", "n_user": "u330728443", "pos": "#F\nN,S=map(int,input().split())\nA=list(map(int,input().split()))\nmod=998244353\n\ndp=[[0 for j in range(S+1)] for i in range(N+1)]\ndp[0][0]+=1\nfor i in range(N):\n for j in range(S+1):\n dp[i+1][j]+=2*dp[i][j]\n dp[i+1][j]%=mod\n if j+A[i]<=S:\n dp[i+1][j+A[i]]+=dp[i][j]\n dp[i+1][j+A[i]]%=mod \nprint(dp[N][S])", "neg": "#F\nN,S=map(int,input().split())\nA=list(map(int,input().split()))\nmod=998244353\n\ndp=[[0 for j in range(S+1)] for i in range(N+1)]\ndp[0][0]+=1\nprint(dp)\nfor i in range(N):\n for j in range(S+1):\n dp[i+1][j]+=2*dp[i][j]\n dp[i+1][j]%=mod\n if j+A[i]<=S:\n dp[i+1][j+A[i]]+=dp[i][j]\n dp[i+1][j+A[i]]%=mod \nprint(dp[N][S])", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [184, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u201387466", "n_user": "u201387466", "pos": "import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 8)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nfrom copy import deepcopy\nalf = list(\"abcdefghijklmnopqrstuvwxyz\")\nALF = list(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n#import numpy as np\nINF = float(\"inf\")\n#d = defaultdict(int)\n#d = defaultdict(list)\n#N = int(input())\n#A = list(map(int,input().split()))\n#S = list(input())[:-1]\n#S.remove(\"\\n\")\n#N,M = map(int,input().split())\n#S,T = map(str,input().split())\n#A = [int(input()) for _ in range(N)]\n#S = [list(input())[:-1] for _ in range(N)]\n#A = [list(map(int,input().split())) for _ in range(N)]\n\nN,S = map(int,input().split())\nMOD = 998244353\nA = list(map(int,input().split()))\ndp = [[0]*(S+1) for _ in range(N)]\nif A[0] <= S:\n dp[0][A[0]] = 1\ndp[0][0] = 2\nfor i in range(1,N):\n a = A[i]\n for j in range(S+1):\n dp[i][j] += 2*dp[i-1][j] % MOD\n if j - a < 0:\n continue\n else:\n dp[i][j] += dp[i-1][j-a]\n dp[i][j] %= MOD\nprint(dp[N-1][S])\n \n\n\n\n", "neg": "import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10 ** 8)\nfrom itertools import accumulate\nfrom itertools import permutations\nfrom itertools import combinations\nfrom collections import defaultdict\nfrom collections import Counter\nimport fractions\nimport math\nfrom collections import deque\nfrom bisect import bisect_left\nfrom bisect import insort_left\nimport itertools\nfrom heapq import heapify\nfrom heapq import heappop\nfrom heapq import heappush\nimport heapq\nfrom copy import deepcopy\nalf = list(\"abcdefghijklmnopqrstuvwxyz\")\nALF = list(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\n#import numpy as np\nINF = float(\"inf\")\n#d = defaultdict(int)\n#d = defaultdict(list)\n#N = int(input())\n#A = list(map(int,input().split()))\n#S = list(input())[:-1]\n#S.remove(\"\\n\")\n#N,M = map(int,input().split())\n#S,T = map(str,input().split())\n#A = [int(input()) for _ in range(N)]\n#S = [list(input())[:-1] for _ in range(N)]\n#A = [list(map(int,input().split())) for _ in range(N)]\n\nN,S = map(int,input().split())\nMOD = 998244353\nA = list(map(int,input().split()))\ndp = np.zeros(N)\nif A[0] <= S:\n dp[0][A[0]] = 1\ndp[0][0] = 2\nfor i in range(1,N):\n a = A[i]\n for j in range(S+1):\n dp[i][j] += 2*dp[i-1][j] % MOD\n if j - a < 0:\n continue\n else:\n dp[i][j] += dp[i-1][j-a]\n dp[i][j] %= MOD\nprint(dp[N-1][S])", "jacc_sim": 0.9882352941176471, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [499, 484], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u726285999", "n_user": "u726285999", "pos": "import sys\n\nMOD = 998244353\n\ndef main():\n N, S = map(int, input().split())\n X = [int(x) for x in sys.stdin.readline().split()]\n\n # dp = np.zeros((N+1)*(S+1), dtype=np.int).reshape((N+1),(S+1))\n dp = [[0 for _ in range(S+1)] for _ in range(N+1)]\n\n dp[0][0] = 1\n\n for i in range(N):\n xi = X[i]\n # xi \u3092 U \u306b\u52a0\u3048\u306a\u3044\u5834\u5408\n for j in range(S+1):\n dp[i+1][j] += dp[i][j]*2 # T \u306b\u52a0\u3048\u308b\uff0f\u52a0\u3048\u306a\u3044\n dp[i+1][j] %= MOD\n # xi \u3092 U \u306b\u52a0\u3048\u308b\u5834\u5408\n if j+xi > S: continue\n dp[i+1][j+xi] += dp[i][j]\n dp[i+1][j+xi] %= MOD\n\n print(dp[N][S] % MOD)\n\nmain()", "neg": "import sys\n\nimport numpy as np\n\nMOD = 998244353\n\ndef main():\n N, S = map(int, input().split())\n X = [int(x) for x in sys.stdin.readline().split()]\n\n dp = np.zeros((N+1)*(S+1), dtype=np.int).reshape((N+1),(S+1))\n\n dp[0][0] = 1\n\n for i in range(N):\n xi = X[i]\n # xi \u3092 U \u306b\u52a0\u3048\u306a\u3044\u5834\u5408\n dp[i+1] += dp[i]*2 # T \u306b\u52a0\u3048\u308b\uff0f\u52a0\u3048\u306a\u3044\n for j in range(S+1):\n # xi \u3092 U \u306b\u52a0\u3048\u308b\u5834\u5408\n if j+xi > S: continue\n dp[i+1][j+xi] += dp[i][j]\n dp[i+1][j+xi] %= MOD\n\n print(dp[N][S] % MOD)\n\nmain()", "jacc_sim": 0.9508196721311475, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [335, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u686230543", "n_user": "u686230543", "pos": "import numpy as np\n\nmod = 998244353\nn, s = map(int, input().split())\ndp = np.zeros((n+1, s+1), dtype=int)\ndp[0, 0] = 1\nfor i, a in enumerate(map(int, input().split())):\n dp[i+1] = dp[i] * 2 % mod\n dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod\nprint(dp[-1, -1])", "neg": "mod = 998244353\nn, s = map(int, input().split())\ndp = np.zeros((n+1, s+1), dtype=int)\ndp[0, 0] = 1\nfor i, a in enumerate(map(int, input().split())):\n dp[i+1] = dp[i] * 2 % mod\n dp[i+1][a:] = (dp[i+1][a:] + dp[i][:-a]) % mod\nprint(dp[-1, -1])", "jacc_sim": 0.9166666666666666, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [131, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u454899755", "n_user": "u454899755", "pos": "N, S = map(int, input().split())\nA = map(int, input().split())\n \ndef solve(length, target, nums):\n \n dp = [[0]*(target+1) for i in range(length+1)]\n dp[0][0] = 1\n for i, n in enumerate(nums):\n for j, comb_num in enumerate(dp[i]):\n sub = j - n\n dp[i + 1][j] += comb_num * 2\n #print(i, j, sub, dp[i])\n if sub >= 0:\n dp[i + 1][j] += dp[i][sub]\n dp[i + 1][j] %= 998244353\n #print(dp)\n print(dp[length][target])\n \nsolve(N, S, A)", "neg": "N, S = map(int, input().split())\nA = map(int, input().split())\n \ndef solve(length, target, nums):\n \n dp = [[0]*(target+1) for i in range(length+1)]\n\n for i, n in enumerate(nums):\n for j, comb_num in enumerate(dp[i]):\n sub = j - n\n dp[i + 1][j] += comb_num * 2\n #print(i, j, sub, dp[i])\n if sub == 0:\n #dp[i + 1][j] += 2 ** (i) % 998244353\n dp[i + 1][j] += 1\n if sub > 0 and dp[i][sub]:\n dp[i + 1][j] += dp[i][sub]\n #print(dp)\n print(dp[length][target] % 998244353)\n \nsolve(N, S, A)", "jacc_sim": 0.9767441860465116, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [201, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u408620326", "n_user": "u408620326", "pos": "def main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n N, S = [int(x) for x in input().strip().split()]\n An = [int(x) for x in input().strip().split()]\n dp = np.zeros((S+1), dtype=int)\n dp[0] = 2\n if An[0] <= S:\n dp[An[0]] = 1\n\n for n in range(1, N):\n dp *= 2\n dp[An[n]:] += dp[:-An[n]] // 2\n dp %= 998244353\n\n print(dp[S])\n \nif __name__ == '__main__':\n main()", "neg": "def main():\n import sys\n import numpy as np\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n N, S = [int(x) for x in input().strip().split()]\n An = [int(x) for x in input().strip().split()]\n dp = np.zeros((2, S+1), dtype=int)\n dp[0, 0] = 2\n if An[0] <= S:\n dp[0, An[0]] = 1\n\n for n in range(1, N):\n for k in range(S, -1, -1):\n dp[n%2, k] = (dp[n%2, k] + dp[(n-1)%2, k] * 2) % 998244353\n if k + An[n] > S:\n continue\n dp[n%2, k+An[n]] = (dp[n%2, k+An[n]] + dp[(n-1)%2, k]) % 998244353\n\n print(dp[(N-1)%2, S])\n \nif __name__ == '__main__':\n main()", "jacc_sim": 0.9245283018867925, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [190, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u141786930", "n_user": "u141786930", "pos": "import sys\nreadline = sys.stdin.readline\n\nN, S = map(int, readline().split())\nA = list(int(x) for x in readline().split())\nMOD = 998244353\n\ndp = [[0] * (S+1) for _ in range(N+1)]\ndp[0][0] = 1\n\nfor i in range(N):\n for j in range(S+1):\n # 1,2\u306e\u30b1\u30fc\u30b9\u3002j\u304c\u5909\u308f\u3089\u306a\u3044\u9077\u79fb\u304c2\u901a\u308a\u3042\u308b\u3002\n dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % MOD\n # 3\u306e\u30b1\u30fc\u30b9\u3002j+A[i] <= S\u306a\u3089\u3070\u3001j+A[i]\u306b\u9077\u79fb\u3059\u308b\u3002\n if j + A[i] <= S:\n dp[i+1][j+A[i]] = (dp[i+1][j+A[i]] + dp[i][j]) % MOD\nprint(dp[N][S])", "neg": "N, S = map(int, input().split())\nA = list(int(x) for x in input().split())\nMOD = 998244353\n\ndp = [[0] * (S+1) for _ in range(N+1)]\ndp[0][0] = 1\n\nfor i in range(N):\n for j in range(S+1):\n print(i, j)\n # 1,2\u306e\u30b1\u30fc\u30b9\u3002j\u304c\u5909\u308f\u3089\u306a\u3044\u9077\u79fb\u304c2\u901a\u308a\u3042\u308b\u3002\n dp[i+1][j] += dp[i][j] * 2\n # 3\u306e\u30b1\u30fc\u30b9\u3002j+A[i] <= S\u306a\u3089\u3070\u3001j+A[i]\u306b\u9077\u79fb\u3059\u308b\u3002\n if j + A[i] <= S:\n dp[i+1][j+A[i]] += dp[i][j]\n print(dp)\nprint(dp[N][S])", "jacc_sim": 0.9032258064516129, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [320, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u728732647", "n_user": "u728732647", "pos": "# Import\nfrom collections import deque\nimport math\n\n# I/O\ndef read(): return input()\ndef read_int(): return int(input())\ndef read_array(type=int): return [type(i) for i in input().split()]\ndef read_tupple(type=None):\n tmp = input().split()\n if type is None: return map(int, tmp)\n assert len(tmp) == len(type)\n return [type[i](tmp[i]) for i in range(len(tmp))]\n\nMOD = 998244353\nN, S = read_tupple()\nA = read_array()\n\ndp = [[0 for j in range(S+1)] for i in range(N+1)]\ndp[0][0] = 1\nfor i in range(N):\n for j in range(S+1):\n dp[i + 1][j] += 2 * dp[i][j]\n if j - A[i] >= 0:\n dp[i + 1][j] += dp[i][j - A[i]]\n \n while dp[i+1][j] > MOD:\n dp[i+1][j] -= MOD\n \nprint(dp[N][S])\n", "neg": "# Import\nfrom collections import deque\nimport math\n\n# I/O\ndef read(): return input()\ndef read_int(): return int(input())\ndef read_array(type=int): return [type(i) for i in input().split()]\ndef read_tupple(type=None):\n tmp = input().split()\n if type is None: return map(int, tmp)\n assert len(tmp) == len(type)\n return [type[i](tmp[i]) for i in range(len(tmp))]\n\nMOD = 998244353\nN, S = read_tupple()\nA = read_array()\n\ndp = [[0 for j in range(S+1)] for i in range(N+1)]\ndp[0][0] = 1\nfor i in range(N):\n for j in range(S+1):\n dp[i + 1][j] += 2 * dp[i][j]\n if j - A[i] >= 0:\n dp[i + 1][j] += dp[i][j - A[i]]\n \n while dp[i+1][j] > MOD:\n\t\t\tdp[i+1][j] -= MOD\n \nprint(dp[N][S])\n", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [298, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u645855527", "n_user": "u623231048", "pos": "n, s = map(int, input().split())\na = sorted(list(map(int, input().split())))\nmod = 998244353\n\ndp = [[0] * (s+1) for _ in range(n+1)]\ndp[0][0] = 1\n\nfor i in range(1, n+1):\n for j in range(s+1):\n dp[i][j] += 2 * dp[i-1][j]\n dp[i][j] %= mod\n\n if j + a[i-1] <= s:\n dp[i][j+a[i-1]] += dp[i-1][j]\n dp[i][j+a[i-1]] %= mod\n\nprint(dp[-1][-1])\n", "neg": "n,s = map(int,input().split())\na = list(map(int,input().split()))\n\nmod = 998244353\n\ndp = [[0]*s for _ in range(n)]\n\nfor i in range(n):\n if a[i]-1 < n:\n dp[i][a[i]-1] += 2**i\n dp[i][a[i]-1] %= mod\n\nfor i in range(n):\n for j in range(s):\n if i != n-1:\n dp[i+1][j] += dp[i][j] * 2\n dp[i+1][j] %= mod\n if i != n-1 and j + a[i+1] < s:\n dp[i+1][j+a[i+1]] += dp[i][j]\n dp[i+1][j+a[i+1]] %= mod\n\nprint(dp[-1][-1]%mod)\n", "jacc_sim": 0.9210526315789473, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [187, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u117541450", "n_user": "u117541450", "pos": "import numpy as np\nN,S=map(int,input().split())\nAs=list(map(int,input().split()))\n\nMOD=998244353\n\n#d = [[0]*3001 for _ in range(3001)]\nd=np.zeros((3001,3001))\nd[0,0]=1\n\nfor i in range(1,N+1):\n Ai=As[i-1]\n d[i] += 2*d[i-1]\n d[i,Ai:] += d[i-1][:-Ai]\n d[i] %= MOD\nprint(int(d[N][S]))", "neg": "import numpy as np\nN,S=map(int,input().split())\nAs=list(map(int,input().split()))\n\nMOD=998244353\n\n#d = [[0]*3001 for _ in range(3001)]\nd=np.zeros((3001,3001))\nd[0,0]=1\n\nfor i in range(1,N+1):\n Ai=As[i-1]\n d[i] += 2*d[i-1]\n d[i,Ai:] += d[i-1][:-Ai]\n d[i] %= MOD\n print(d[i,:10])\nprint(int(d[N][S]))", "jacc_sim": 0.975609756097561, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [160, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u703950586", "n_user": "u703950586", "pos": "import sys,queue,math,copy,itertools,bisect,collections,heapq\n\ndef main():\n sys.setrecursionlimit(10**7)\n INF = 10**18\n MOD = 998244353\n LI = lambda : [int(x) for x in sys.stdin.readline().split()]\n NI = lambda : int(sys.stdin.readline())\n SI = lambda : sys.stdin.readline().rstrip()\n\n N,S = LI()\n A = [0] + LI()\n dp = [[0] * (S+1) for _ in range(N+1)]\n dp[0][0] = pow(2,N,MOD)\n d2 = pow(2,MOD-2,MOD)\n for i in range(1,N+1):\n for j in range(0,S+1):\n if j >= A[i]:\n dp[i][j] = (dp[i-1][j] + dp[i-1][j-A[i]] * d2) % MOD\n else:\n dp[i][j] = dp[i-1][j]\n\n print(dp[-1][-1])\n\nif __name__ == '__main__':\n main()", "neg": "import sys,queue,math,copy,itertools,bisect,collections,heapq\n\ndef main():\n sys.setrecursionlimit(10**7)\n INF = 10**18\n MOD = 998244353\n LI = lambda : [int(x) for x in sys.stdin.readline().split()]\n NI = lambda : int(sys.stdin.readline())\n SI = lambda : sys.stdin.readline().rstrip()\n\n N,S = LI()\n A = [0] + LI()\n dp = [[0] * (S+1) for _ in range(N+1)]\n dp[0][0] = 0\n for i in range(1,N+1):\n for j in range(1,S+1):\n if j >= A[i]:dp[i][j] = max(dp[i-1][j],dp[i-1][j-A[i]]+1)\n else: dp[i][j] = dp[i-1][j]\n\n ans = 0\n for i in range(1,N):\n if dp[i][-1] > 0:\n ans = (ans + pow(2,N-dp[i][-1],MOD)) % MOD\n print(ans)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.953125, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [303, 322], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u163320134", "n_user": "u163320134", "pos": "import sys\ninput=sys.stdin.readline\n\ndef calc():\n mod=998244353\n n,s=map(int,input().split())\n arr=list(map(int,input().split()))\n dp=[0]*(s+1)\n dp[0]=1\n ans=0\n for i in range(1,n+1):\n val=arr[i-1]\n for k in range(s,-1,-1):\n dp[k]*=2\n dp[k]%=mod\n if k>=val and dp[k-val]!=0:\n dp[k]+=dp[k-val]\n dp[k]%=mod\n print(dp[s]%mod)\ncalc()", "neg": "import sys\ninput=sys.stdin.readline\n\ndef calc():\n mod=998244353\n n,s=map(int,input().split())\n arr=list(map(int,input().split()))\n dp=[0]*(s+1)\n dp[0]=1\n ans=0\n for i in range(1,n+1):\n val=arr[i-1]\n for k in range(s,-1,-1):\n dp[k]*=2\n if k>=val and dp[k-val]!=0:\n dp[k]+=dp[k-val]\n print(dp[n])\ncalc()", "jacc_sim": 0.9772727272727273, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [188, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u539969758", "n_user": "u539969758", "pos": "MOD = 998244353\nN, S = map(int, input().split())\nA = list(map(int, input().split()))\n\ndp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i\u756a\u76ee\u307e\u3067\u898b\u3066\u91cd\u3055j\u306e\u3082\u306e\u3092\u53d6\u308b\u65b9\u6cd5\ndp[0][0] = 1\n\n# for i in range(N):\n# for j in range(S+1):\n# dp[i+1][j] += 2*dp[i][j]\n# dp[i+1][j] %= MOD\n# if j + A[i] <= S:\n# dp[i+1][j+A[i]] += dp[i][j]\n# dp[i+1][j+A[i]] %= MOD\n\nfor i in range(1, N+1):\n for j in range(S+1):\n get = 0\n non_get = 2*dp[i-1][j] % MOD\n \n if j - A[i-1] >= 0:\n get = dp[i-1][j - A[i-1]]\n dp[i][j] = (non_get + get) % MOD\n \n \n\nprint(dp[N][S]) \n\n# print(dp)\n ", "neg": "MOD = 998244353\nN, S = map(int, input().split())\nA = list(map(int, input().split()))\n\ndp = [[0 for j in range(S+1)] for i in range(N+1)] #dp[i][j] = i\u756a\u76ee\u307e\u3067\u898b\u3066\u91cd\u3055j\u306e\u3082\u306e\u3092\u53d6\u308b\u65b9\u6cd5\ndp[0][0] = 1\n\n# for i in range(N):\n# for j in range(S+1):\n# dp[i+1][j] += 2*dp[i][j]\n# dp[i+1][j] %= MOD\n# if j + A[i] <= S:\n# dp[i+1][j+A[i]] += dp[i][j]\n# dp[i+1][j+A[i]] %= MOD\n\nfor i in range(1, N):\n for j in range(S+1):\n get = 0\n non_get = 2*dp[i-1][j] % MOD\n \n if j - A[i] >= 0:\n get = dp[i-1][j - A[i]]\n # dp[i][j] = (2*non_get + get) % MOD\n dp[i][j] = (non_get + get) % MOD\n \n \n\nprint(dp[N][S]) \n\n# print(dp)\n ", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [356, 371], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u201660334", "n_user": "u869519920", "pos": "n, s = map(int, input().split())\na = list(map(int, input().split()))\nmod = 998244353\n\ntemp = [1] + [0] * s\nfor i in range(n):\n temp2 = [0] * (s + 1)\n for j in range(s + 1):\n temp2[j] += temp[j] * 2\n temp2[j] %= mod\n for j in range(s + 1 - a[i]):\n temp2[j + a[i]] += temp[j]\n temp2[j + a[i]] %= mod\n temp = temp2\nprint(temp[s])", "neg": "n, s = list(map(int, input().split()))\na = list(map(int, input().split()))\ncombi = [[0]*(s+1) for i in range(n)]\ncombi[0][0] = 2\ncombi[0][a[0]] = 1\nmod = 998244353\nfor i in range(1, n):\n for j in range(s+1):\n combi[i][j] += combi[i-1][j] * 2\n combi[i][j] %= 998244353\n for j in range(s-a[i]+1):\n combi[i][j+a[i]] += combi[i-1][j]\n combi[i][j+a[i]] %= 998244353\nprint(combi[n-1][s])", "jacc_sim": 0.9117647058823529, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [162, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u266014018", "n_user": "u266014018", "pos": "def main():\n import sys\n mod = 998244353\n def input(): return sys.stdin.readline().rstrip()\n n,s = map(int, input().split())\n a = list(map(int, input().split()))\n dp = [0]*(s+1)\n dp[0] = 1\n import numpy as np\n dp = np.array(dp)\n for i in range(n):\n dp[a[i]:] = (2*dp[a[i]:]%mod + dp[:-a[i]])%mod\n dp[:a[i]] *= 2\n dp[:a[i]] %= mod\n print(dp[-1])\n\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n import sys\n mod = 998244353\n def input(): return sys.stdin.readline().rstrip()\n n,s = map(int, input().split())\n a = list(map(int, input().split()))\n dp = [0]*(s+1)\n dp[0] = 1\n import numpy as np\n dp = np.array(dp)\n for i in range(n):\n dp[a[i]:] = (2*dp[a[i]:]%mod + dp[:-a[i]])%mod\n print(dp[-1])\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [184, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u169350228", "n_user": "u169350228", "pos": "import math\nimport numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n,s = map(int,ipt().split())\n a = [int(i) for i in ipt().split()]\n mod = 998244353\n two = [1]*(n+1)\n for i in range(n):\n two[i+1] = two[i]*2%mod\n dp = np.zeros(3010,dtype = int)\n dp[0] = 1\n for i,ai in enumerate(a):\n ndp = dp*2\n ndp[ai:] += dp[:-ai]\n ndp %= mod\n dp = ndp\n print(dp[s])\n return\n\nif __name__ == '__main__':\n main()\n", "neg": "import math\nimport numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n,s = map(int,ipt().split())\n a = [int(i) for i in ipt().split()]\n mod = 998244353\n two = [1]*(n+1)\n for i in range(n):\n two[i+1] = two[i]*2%mod\n dp = np.zeros((n+1,s+1),dtype = int)\n for i,ai in enumerate(a):\n if ai > s:\n continue\n for si in range(s):\n dp[s-si][ai:] += dp[s-si-1][:-ai]\n dp[1][ai] += 1\n ans = 0\n for i in range(n+1):\n dpi = dp[i]\n ans = (ans+(dpi[s]*two[n-i])%mod)%mod\n print(ans)\n return\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9027777777777778, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [249, 311], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u893063840", "n_user": "u686230543", "pos": "n, s = map(int, input().split())\na = list(map(int, input().split()))\nmod = 998244353\n\ndp = [[0] * (s + 1) for _ in range(n + 1)]\ndp[0][0] = 1\n\nfor i, e in enumerate(a, 1):\n for j in range(s + 1):\n dp[i][j] += 2 * dp[i-1][j]\n if j - e >= 0:\n dp[i][j] += dp[i-1][j-e]\n\n dp[i][j] %= mod\n\nans = dp[n][s]\nprint(ans)\n\n", "neg": "mod = 998244353\nn, s = map(int, input().split())\ndp = [[0] * (s + 1) for _ in range(n + 1)]\nfor i, a in enumerate(map(int, input().split())):\n for j in range(s + 1):\n dp[i+1][j] = (dp[i][j] + 2) % mod\n if j >= a:\n dp[i+1][j] = (dp[i+1][j] + dp[i][j-a] + 1) % mod\nprint(dp[-1][-1])", "jacc_sim": 0.9210526315789473, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [165, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u249218427", "n_user": "u249218427", "pos": "# -*- coding: utf-8 -*-\nimport sys\nimport numpy as np\n\nN,S, *A = map(int, sys.stdin.buffer.read().split())\nmod = 998244353\nA = sorted(A)\n\nanswer = np.zeros(3002).astype(np.int64)\npower2 = 1\n\ntotal = 0\nfor a in A:\n total = min(3001,a+total)\n answer[a+1:total+1] = (2*answer[a+1:total+1]+answer[1:total-a+1])%mod\n answer[a] = (2*answer[a]+power2)%mod\n answer[1:a] = (2*answer[1:a])%mod\n power2 = (2*power2)%mod\n\nprint(answer[S])", "neg": "# -*- coding: utf-8 -*-\nimport sys\nimport numpy as np\n\nN,S, *A = map(int, sys.stdin.buffer.read().split())\nmod = 998244353\nA = sorted(A)\n\nanswer = np.zeros(S+1).astype(np.int64) # [0 for _ in range(S+1)]\npower2 = 1\n\ntotal = 0\nfor a in A:\n total = min(S,a+total)\n answer[a+1:total+1] = (2*answer[a+1:total+1]+answer[1:total-a+1])%mod\n answer[a] = (2*answer[a]+power2)%mod\n answer[1:a] = (2*answer[1:a])%mod\n power2 = (2*power2)%mod\n\nprint(answer[S])", "jacc_sim": 0.9215686274509803, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [205, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u102445737", "n_user": "u102445737", "pos": "#from collections import deque,defaultdict\nfrom sys import stdin\ninput = stdin.readline\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nhf = pow(2,R-2,R)\nn,s = inm()\na = inl()\ndp = [[0]*(s+1) for i in range(n+1)]\nfor i in range(n+1):\n dp[i][0] = pow(2,n,R)\nsm = 0\nfor i in range(1,n+1):\n dp[i] = [x for x in dp[i-1]]\n for j in range(s):\n if dp[i-1][j]>0 and j+a[i-1]<=s:\n dp[i][j+a[i-1]] = (dp[i][j+a[i-1]]+dp[i-1][j]*hf)%R\n #ddprint(i)\n #ddprint(dp[i])\nprint(dp[n][s])\n", "neg": "#from collections import deque,defaultdict\nfrom sys import stdin\ninput = stdin.readline\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nn,s = inm()\na = inl()\ndp = [[0]*(s+1) for i in range(n+1)]\nfor i in range(n+1):\n dp[i][0] = 1\nsm = 0\nfor i in range(1,n+1):\n for j in range(s):\n if dp[i-1][j]>0 and j+a[i-1]<=s:\n dp[i][j+a[i-1]] += dp[i-1][j]\n if j+a[i-1]==s:\n sm = (sm+dp[i-1][j]*pow(2,n-i+1,R))%R\n ddprint(dp)\nprint(sm)\n", "jacc_sim": 0.9848484848484849, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [345, 315], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u353797797", "n_user": "u353797797", "pos": "import sys\nfrom collections import defaultdict\n\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\n\ndef main():\n md=998244353\n n,s=MI()\n aa=LI()\n dp=[0]*(s+1)\n dp[0]=1\n inv=pow(2,md-2,md)\n for k,a in enumerate(aa):\n for i in range(s-a,-1,-1):\n dp[i+a]=(dp[i+a]+dp[i]*inv)%md\n #print(k,dp)\n ans=dp[s]*pow(2,n,md)%md\n print(ans)\n\nmain()", "neg": "import sys\nfrom collections import defaultdict\n\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\n\ndef main():\n md=998244353\n n,s=MI()\n aa=LI()\n dp=[0]*(s+1)\n dp[0]=1\n inv=pow(2,md-2,md)\n for k,a in enumerate(aa):\n for i in range(s-a,-1,-1):\n dp[i+a]=(dp[i+a]+dp[i]*inv)%md\n #print(k,dp)\n ans=dp[s]*pow(2,n,md)\n print(ans)\n\nmain()", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [279, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u227082700", "n_user": "u227082700", "pos": "n,s,*a=map(int,open(0).read().split());d=[0]*-~s;m=998244353;v=pow(2,m-2,m);d[0]=pow(2,n,m)\nfor i in a:\n for j in range(s,i-1,-1):d[j]+=(d[j-i]*v)%m\nprint(d[s]%m)", "neg": "n,s,*a=map(int,open().read().split());d=[0]*-~s;m=998244353;v=pow(2,m-2,m);d[0]=pow(2,n,m)\nfor i in a:\n for j in range(s,i-1,-1):d[j]+=(d[j-i]*v)%m\nprint(d[s])", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [108, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u578514593", "n_user": "u578514593", "pos": "n, s = map(int, input().split())\na = list(map(int, input().split()))\n\nmod = 998244353\n\ndp = [[0] * 4000 for _ in range(4000)]\n\ndef pow_k(x, n):\n \"\"\"\n O(log n)\n \"\"\"\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x % mod\n x *= x % mod\n n //= 2\n\n return K * x % mod\n\ninv2 = pow_k(2, mod - 2)\npow2n = pow_k(2, n)\n\ndp[0][0] = pow2n\nfor i in range(1, n + 1):\n for j in range(s + 1):\n if j >= a[i - 1]:\n dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i - 1]] * inv2 % mod) % mod\n else:\n dp[i][j] = dp[i - 1][j]\nprint(dp[n][s])\n", "neg": "n, s = map(int, input().split())\na = list(map(int, input().split()))\n\nmod = 998244353\n\ndp = [[0] * (n + 1) for _ in range(s + 1)]\n\ndef pow_k(x, n):\n \"\"\"\n O(log n)\n \"\"\"\n if n == 0:\n return 1\n\n K = 1\n while n > 1:\n if n % 2 != 0:\n K *= x % mod\n x *= x % mod\n n //= 2\n\n return K * x % mod\n\ninv2 = pow_k(2, mod - 2)\npow2n = pow_k(2, n)\n\ndp[0][0] = pow2n\nfor i in range(1, n + 1):\n for j in range(s + 1):\n if j >= a[i - 1]:\n dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - a[i - 1]] * inv2 % mod) % mod\n else:\n dp[i][j] = dp[i - 1][j]\nprint(dp[n][s])\n", "jacc_sim": 0.98, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [286, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u306950978", "n_user": "u426108351", "pos": "n , s = map(int,input().split())\na = list(map(int,input().split()))\ndp = [[0 for j in range(s+1)] for i in range(n+1)]\nmod = 998244353\nfor i in range(1,n+1):\n if 0 <= a[i-1] <= s:\n if dp[i][a[i-1]] == 0:\n dp[i][a[i-1]] += pow(2,i-1,mod)\n for j in range(0,s+1):\n dp[i][j] += (dp[i-1][j]*2)%mod\n if j - a[i-1] >= 0:\n dp[i][j] += dp[i-1][j-a[i-1]]\n dp[i][j] %= mod\n\nprint(dp[n][s])\n ", "neg": "n, s = map(int, input().split())\na = list(map(int, input().split()))\n\ndp = [[0]*(s+1) for i in range(n+1)]\n\ndp[0][0] = 1\n\nfor i in range(n):\n for j in range(s+1):\n if j+a[i] <= s:\n dp[i+1][j+a[i]] += dp[i][j]\n\n dp[i+1][j] += dp[i][j]\n\nmod = 998244353\nans = 0\nfor i in range(n):\n ans += (dp[i+1][s] - dp[i][s]) * pow(2, i, mod)\n ans %= mod\n\nprint(ans)\n", "jacc_sim": 0.9459459459459459, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [217, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u249218427", "n_user": "u249218427", "pos": "# -*- coding: utf-8 -*-\nimport sys\n\nN,S, *A = map(int, sys.stdin.buffer.read().split())\nmod = 998244353\n\nanswer = [0 for _ in range(S+1)]\npower2 = 1\n\nfor a in A:\n answer_next = [(2*b)%mod for b in answer]\n if a<=S:\n answer_next[a] = (answer_next[a]+power2)%mod\n for i in range(a+1,S+1):\n answer_next[i] = (answer_next[i]+answer[i-a])%mod\n answer = answer_next\n power2 = (2*power2)%mod\n\nprint(answer[S])", "neg": "# -*- coding: utf-8 -*-\nimport sys\n\nN,S, *A = map(int, sys.stdin.buffer.read().split())\nmod = 998244353\n\nanswer = [0 for _ in range(S+1)]\npower2 = 1\n\nfor j in range(N):\n a = A[j]\n answer_next = [2*answer[i] for i in range(S+1)]\n for i in range(a+1,S+1):\n answer_next[i] += answer[i-a]\n answer_next[a] += power2\n power2 = (2*power2)%mod\n answer = [answer_next[i]%mod for i in range(S+1)]\n\nprint(answer[S])", "jacc_sim": 0.9130434782608695, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [189, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u189479417", "n_user": "u173148629", "pos": "mod = 998244353\nN, S = map(int,input().split())\nA = list(map(int,input().split()))\ndp = [[0 for i in range(S+1)] for j in range(N+1)]\ndp[0][0] = 1\n\nfor i in range(N):\n for j in range(S+1):\n dp[i+1][j] += dp[i][j] * 2\n if j + A[i] <= S:\n dp[i+1][j+A[i]] += dp[i][j]\n dp[i+1][j] %= mod\n\nprint(dp[N][S])", "neg": "N,S=map(int,input().split())\nA=list(map(int,input().split()))\nmod=998244353\n\ndp=[[0]*(S+1) for _ in range(N)]\n\ndp[0][0]=2\ndp[0][A[0]]=1\nfor i in range(N-1):\n for j in range(S+1):\n dp[i+1][j]+=dp[i][j]*2\n dp[i+1][j]%=mod\n if j+A[i+1]<=S:\n dp[i+1][j+A[i+1]]+=dp[i][j]\n dp[i+1][j+A[i+1]]%=mod\n\nprint(dp[N-1][S]%mod)", "jacc_sim": 0.9428571428571428, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [161, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u218843509", "n_user": "u490642448", "pos": "MOD = 998244353\nn, s = map(int, input().split())\na = list(map(int, input().split()))\n\ndp = [[0 for _ in range(s+1)] for _ in range(n+1)]\ndp[0][0] = 1\nfor i in range(n):\n\tfor j in range(s+1):\n\t\tdp[i+1][j] = dp[i][j] * 2\n\t\tif j >= a[i]:\n\t\t\tdp[i+1][j] += dp[i][j-a[i]]\n\t\tdp[i+1][j] %= MOD\nprint(dp[n][s])", "neg": "n,s = map(int,input().split())\na = list(map(int,input().split()))\nmod = 998244353\n\ndp = [[0] * (s+1) for _ in range(n+1)]\n\ndp[0][0] = 1\nfor i in range(1,n+1):\n for j in range(0,s+1):\n dp[i][j] += dp[i-1][j]\n if(j>=a[i-1]):\n dp[i][j] += dp[i-1][j-a[i-1]]\n dp[i][j] %= mod\n\nprint(dp[-1][-1])", "jacc_sim": 0.9166666666666666, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [161, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02662", "p_user": "u905582793", "n_user": "u153556810", "pos": "n,s = map(int,input().split())\na = list(map(int,input().split()))\ndp = [[0 for i in range(s+1)] for j in range(n+1)]\ndp[0][0] = 1\nmod = 998244353\nfor i in range(1,n+1):\n x = a[i-1]\n for j in range(s+1):\n dp[i][j] += dp[i-1][j]*2\n dp[i][j] %= mod\n for j in range(x,s+1):\n dp[i][j] += dp[i-1][j-x]\n dp[i][j] %= mod\nprint(dp[-1][-1])", "neg": "n,s = map(int, input().split())\na = list(map(int,input().split()))\ndp = [[0]*(s+1) for i in range(n+1)]\ndiv = 998244353\ndp[0][0] = 1\nfor i in range(1,n+1):\n dp[i] = dp[i-1]*2\n for j in range(a[i-1],s+1):\n dp[i][j] += dp[i-1][j-a[i-1]]\n dp[i][j] %= div\nprint(dp[n][s])\n", "jacc_sim": 0.9117647058823529, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N and another positive integer S. For a non-empty subset T of the set {1, 2, ..., N}, define f(T) as the number of different non-empty subsets {x_1, x_2, ..., x_k} of T such that A_{x_1}+A_{x_2}+...+A_{x_k} = S. Find the sum of f(T) over all 2^N-1 subsets T of {1, 2, ..., N}, and print it modulo 998244353. Constraints: All values in input are integers, 1 <= N <= 3000, 1 <= S <= 3000, 1 <= A_i <= 3000. Input is given as N S followed by A_1 A_2 ... A_N. Output the sum of f(T) modulo 998244353.", "before_after_length": [180, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02667", "p_user": "u487767879", "n_user": "u487767879", "pos": "import math\nimport re\nT=input()\nx=0\nTd=T\nd = len(re.sub(r'0', '', Td))\nx += math.ceil((d/2+1)*d/2)\nspT = T.split('0')\nlenT = list(map(len, spT))\n\ntmpX = math.ceil(d/2)\nbT = 0\naT = d\ntmp = ''\nfor i in range(len(spT) - 1):\n tmp += spT[i]\n bT += lenT[i]\n aT -= lenT[i]\n if bT % 2==1:\n bT += 1\n if aT % 2 ==1:\n tmpX += 1\n x += tmpX\n tmp += '0'\n else:\n tmp +='+'\ntmp += spT[-1]\n\nspT = tmp.split('+')\nvT =[]\naT = bT\nbT = 0\n\nodT = 0\ntmpOd = True\n\nfor i in range(len(spT)):\n \n od = len(re.sub(r'0', '', spT[i][0 if tmpOd else 1::2]))\n ev = len(re.sub(r'0', '', spT[i][1 if tmpOd else 0::2]))\n odT += od\n vT.append(od - ev)\n if len(spT[i]) %2 == 1:\n tmpOd = not tmpOd\n\nfor i in reversed(range(1, len(spT))):\n odT = odT - vT[i]\n x += odT\n vT[i-1] -= vT[i]\n\n\nprint(x)", "neg": "import math\nimport re\nT=input()\nx=0\nTd=T\nd = len(re.sub(r'0', '', Td))\nx += math.ceil((d/2+1)*d/2)\nspT = T.split('0')\nlenT = list(map(len, spT))\n\ntmpX = math.ceil(d/2)\nbT = 0\naT = d\ntmp = ''\nfor i in range(len(spT) - 1):\n tmp += spT[i]\n bT += lenT[i]\n aT -= lenT[i]\n if bT % 2==1:\n bT += 1\n if aT % 2 ==1:\n tmpX += 1\n x += tmpX\n tmp += '0'\n else:\n tmp +='+'\ntmp += spT[-1]\n\nspT = tmp.split('+')\nvT =[]\naT = bT\nbT = 0\nodT = 0\ntmpOd = True\n\nfor i in range(len(spT)):\n \n od = len(re.sub(r'0', '', spT[i][0 if tmpOd else 1::2]))\n ev = len(re.sub(r'0', '', spT[i][1 if tmpOd else 0::2]))\n odT += od\n vT.append(od - ev)\n if len(spT[i]) %2 == 1:\n tmpOd = not tmpOd\n\nprint(x)", "jacc_sim": 0.9807692307692307, "nl": "Takahashi starts with an empty string S and a variable x initialized to 0. Given a string T consisting of 0s and 1s, Takahashi performs the following steps |T| times: insert a 0 or 1 at any position in S, then increment x by the sum of the digits in the odd positions of S. The goal is to find the maximum final value of x after a sequence of operations such that S equals T. Constraints: 1 \u2264 |T| \u2264 2 \u00d7 10^5. Input is given as T, and the output should be the maximum possible final value of x.", "before_after_length": [424, 371], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02667", "p_user": "u423585790", "n_user": "u423585790", "pos": "T=input()\nn=len(T)\ni=r=a=0\nfor c in T:\n k=i-r\n if c=='0':\n r+=~k&1\n else:\n a+=i//2-k//2+(~k&1)*(n-i)\n i+=1\nprint(a)\n", "neg": "T=input()\nn=len(t)\ni=r=a=0\nfor c in T:\n k=i-r\n if c=='0':r+=k&1\n else:a+=i//2-k//2+(k&1)*(n-i)\nprint(a)", "jacc_sim": 0.9310344827586207, "nl": "Takahashi starts with an empty string S and a variable x initialized to 0. Given a string T consisting of 0s and 1s, Takahashi performs the following steps |T| times: insert a 0 or 1 at any position in S, then increment x by the sum of the digits in the odd positions of S. The goal is to find the maximum final value of x after a sequence of operations such that S equals T. Constraints: 1 \u2264 |T| \u2264 2 \u00d7 10^5. Input is given as T, and the output should be the maximum possible final value of x.", "before_after_length": [88, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u970899068", "n_user": "u970899068", "pos": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\np = list(map(int, input().split()))\n\ndistance = [[min(i, j, n - i - 1, n - j - 1) for i in range(n)] for j in range(n)]\ncheck = [[1] * n for i in range(n)]\np = [((i - 1) // n, (i - 1) % n) for i in p]\n\ndef move(x,y,nx,ny):\n if distance[nx][ny] > distance[x][y] + check[x][y]:\n distance[nx][ny] = distance[x][y] + check[x][y]\n d.append((nx,ny))\n\nans = 0\nfor i, j in p:\n ans += distance[j][i]\n d=[]\n d.append((j,i))\n check[j][i] = 0\n while len(d):\n x, y = d.pop()\n if x!=0:\n move(x,y,x-1,y)\n if x!=n-1:\n move(x,y,x+1,y)\n if y!=0:\n move(x,y,x,y-1)\n if y!=n-1:\n move(x,y,x,y+1)\n\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\nn = int(input())\np = list(map(int, input().split()))\n\ndistance = [[min(i, j, n - i - 1, n - j - 1) for i in range(n)] for j in range(n)]\ncheck = [[1] * n for i in range(n)]\np = [((i - 1) // n, (i - 1) % n) for i in p]\n\ndef move(x,y,nx,ny):\n if distance[nx][ny] > distance[x][y] + check[nx][ny]:\n distance[nx][ny] = distance[x][y] + check[nx][ny]\n d.append((nx,ny))\n\nans = 0\nfor i, j in p:\n ans += distance[j][i]\n d=deque()\n d.append((j,i))\n check[j][i] = 0\n while len(d):\n x, y = d.popleft()\n if x!=0:\n move(x,y,x-1,y)\n if x!=n-1:\n move(x,y,x+1,y)\n if y!=0:\n move(x,y,x,y-1)\n if y!=n-1:\n move(x,y,x,y+1)\n\nprint(ans)", "jacc_sim": 0.9074074074074074, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [341, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u606045429", "n_user": "u606045429", "pos": "N, *P = map(int, open(0).read().split())\n\ndp = [0] + [min(i, j, N - 1 - i, N - 1 - j) for i in range(N) for j in range(N)]\nmemo = [1] * (N * N + 1)\n\ndef move(fr, to):\n if dp[to] > dp[fr] + memo[fr]:\n dp[to] = dp[fr] + memo[fr]\n S.append(to)\n\nans = 0\nfor p in P:\n ans += dp[p]\n memo[p] = 0\n\n S = [p]\n while S:\n v = S.pop()\n\n q, r = divmod(v - 1, N)\n if r != 0:\n move(v, v - 1)\n if r != N - 1:\n move(v, v + 1)\n if q < N - 1:\n move(v, v + N)\n if q >= 1:\n move(v, v - N)\n\nprint(ans)", "neg": "N, *P = map(int, open(0).read().split())\n\ndp = [0] + [min(i, j, N + 1 - i, N + 1 - j) for i in range(N) for j in range(N)]\nmemo = [1] * (N * N + 1)\n\ndef move(fr, to):\n if dp[to] > dp[fr] + memo[fr]:\n dp[to] = dp[fr] + memo[fr]\n S.append(to)\n\nans = 0\nfor p in P:\n ans += dp[p]\n memo[p] = 0\n\n S = [p]\n while S:\n v = S.pop()\n\n q, r = divmod(v - 1, N)\n if r != 0:\n move(v, v - 1)\n if r != N - 1:\n move(v, v + 1)\n if q < N - 1:\n move(v, v + N)\n if q >= 1:\n move(v, v - N)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [263, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\nn = int(input())\na = list(map(int,input().split()))\nn += 2\nls = [0 for i in range(n*n)]\nfor i in range(n):\n for j in range(n):\n ls[i*n+j] = min(i,j,n-1-i,n-1-j)-1\nans = 0\nst = [0]*(n*n)\nfor i in a:\n x,y = divmod(i-1,n-2)\n i = (x+1)*n+(y+1)\n ans += ls[i]\n st[i]=1\n q = deque([i])\n while q:\n j = q.popleft()\n for k in (j-n,j+n,j+1,j-1):\n if st[j]:\n if ls[j] < ls[k]:\n ls[k] = ls[j]\n q.append(k)\n elif ls[j]+1 < ls[k]:\n ls[k] = ls[j]+1\n q.append(k)\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\nn = int(input())\na = list(map(int,input().split()))\nn += 2\nls = [0 for i in range(n*n)]\nfor i in range(n):\n for j in range(n):\n ls[i*n+j] = min(i,j,n-1-i,n-1-j)-1\nans = 0\nst = [0]*(n*n)\nfor i in a:\n x,y = divmod(i-1,n-2)\n i = (x+1)*n+(y+1)\n ans += ls[i]\n st[i]=1\n q = deque([i])\n while q:\n j = q.popleft()\n for k in (j-n,j+n,j+1,j-1):\n if st[j]:\n if ls[j] < l[k]:\n ls[k] = ls[j]\n q.append(k)\n elif ls[j]+1 < ls[k]:\n ls[k] = ls[j]+1\n q.append(k)\nprint(ans)", "jacc_sim": 0.98, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [291, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u368780724", "n_user": "u368780724", "pos": "import sys\nfrom collections import deque\nreadline = sys.stdin.readline\n\nN = int(readline())\nP = list(map(int, readline().split()))\n\ngeta = N+2\nG = [0]*(geta*geta)\n\nfor v in range(-1-(-N//2), -1, -1):\n l = v+1\n r = N-v\n for i in range(geta):\n G[i*geta+l] = v\n G[i*geta+r] = v\n G[l*geta+i] = v\n G[r*geta+i] = v\n\nfor i in range(geta):\n G[i*geta] = -1\n G[i*geta + geta-1] = -1\n G[i] = -1\n G[geta*(geta-1)+i] = -1\n\nPn = []\n\nfor p in P:\n a, b = divmod(p-1, N)\n Pn.append((1+a)*geta+1+b)\n\nDIREC = (1, -1, geta, -geta)\nans = 0\nused = [False]*(geta*geta)\nfor p in Pn:\n ans += G[p]\n res = G[p]\n for d in DIREC:\n res = min(res, G[p+d])\n if G[p] != res:\n G[p] = res\n Q = [p]\n while Q:\n vn = Q.pop()\n for d in DIREC:\n vf = vn + d\n if not used[vf]:\n if G[vf] > G[vn] + 1:\n G[vf] = G[vn] + 1\n Q.append(vf)\n else:\n if G[vf] > G[vn]:\n G[vf] = G[vn]\n Q.append(vf)\n \n used[p] = True\nprint(ans)", "neg": "import sys\nfrom collections import deque\nreadline = sys.stdin.readline\n\nN = int(readline())\nP = list(map(int, readline().split()))\n\ngeta = N+2\nG = [0]*(geta*geta)\n\nfor v in range(-1-(-N//2), -1, -1):\n l = v+1\n r = N-v\n for i in range(geta):\n G[i*geta+l] = v\n G[i*geta+r] = v\n G[l*geta+i] = v\n G[r*geta+i] = v\n\nfor i in range(geta):\n G[i*geta] = -1\n G[i*geta + geta-1] = -1\n G[i] = -1\n G[geta*(geta-1)+i] = -1\n\nPn = []\n\nfor p in P:\n a, b = divmod(p-1, N)\n Pn.append((1+a)*geta+1+b)\n\nDIREC = [1, -1, geta, -geta]\nans = 0\nused = [False]*(geta*geta)\nfor p in Pn:\n ans += G[p]\n res = G[p]\n for d in DIREC:\n res = min(res, G[p+d])\n if G[p] != res:\n G[p] = res\n \n while Q:\n vn = Q.pop()\n for d in DIREC:\n vf = vn + d\n if not used[vf]:\n if G[vf] > G[vn] + 1:\n G[vf] = G[vn] + 1\n Q.appendleft(vf)\n else:\n if G[vf] > G[vn]:\n G[vf] = G[vn]\n Q.appendleft(vf)\n \n used[p] = True\nprint(ans)", "jacc_sim": 0.9841269841269841, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [504, 501], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u600402037", "n_user": "u600402037", "pos": "# coding: utf-8\nimport sys\nfrom collections import deque\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\ndef main():\n N = ir()\n P = lr()\n P = [((p-1)//N, (p-1)%N) for p in P]\n dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]\n people = [[True] * N for i in range(N)]\n\n answer = 0\n for i, j in P:\n answer += dp[i][j]\n people[i][j] = False\n que = deque([(i, j, dp[i][j])])\n popleft = que.popleft; append = que.append\n while que:\n y, x, cur = popleft()\n cur += people[y][x]\n if x > 0:\n if dp[y][x-1] > cur:\n dp[y][x-1] = cur\n append((y, x-1, cur))\n if x < N-1:\n if dp[y][x+1] > cur:\n dp[y][x+1] = cur\n append((y, x+1, cur))\n if y > 0:\n if dp[y-1][x] > cur:\n dp[y-1][x] = cur\n append((y-1, x, cur))\n if y < N-1:\n if dp[y+1][x] > cur:\n dp[y+1][x] = cur\n append((y+1, x, cur))\n\n print(answer)\n \nif __name__ == \"__main__\":\n main()\n", "neg": "# coding: utf-8\nimport sys\nfrom collections import deque\nfrom numba import jit\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\n@jit\ndef main():\n N = ir()\n P = lr()\n P = [((p-1)//N, (p-1)%N) for p in P]\n dp = [[min(i, N-1-i, j, N-1-j) for j in range(N)] for i in range(N)]\n people = [[True] * N for i in range(N)]\n\n answer = 0\n for i, j in P:\n answer += dp[i][j]\n people[i][j] = False\n que = deque([(i, j, dp[i][j])])\n popleft = que.popleft; append = que.append\n while que:\n y, x, cur = popleft()\n cur += people[y][x]\n if x > 0:\n if dp[y][x-1] > cur:\n dp[y][x-1] = cur\n append((y, x-1, cur))\n if x < N-1:\n if dp[y][x+1] > cur:\n dp[y][x+1] = cur\n append((y, x+1, cur))\n if y > 0:\n if dp[y-1][x] > cur:\n dp[y-1][x] = cur\n append((y-1, x, cur))\n if y < N-1:\n if dp[y+1][x] > cur:\n dp[y+1][x] = cur\n append((y+1, x, cur))\n\n print(answer)\n \nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9565217391304348, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [453, 464], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u334712262", "n_user": "u334712262", "pos": "# -*- coding: utf-8 -*-\nimport sys\nbuff_readline = sys.stdin.buffer.readline\n\n\ndef read_int():\n return int(buff_readline())\n\n\ndef read_int_n():\n return list(map(int, buff_readline().split()))\n\n\ndef slv(N, P):\n M = N+2\n cost = [0] * M**2\n occupy = [1] * M**2\n for i in range(N):\n im = i*M + M + 1\n for j in range(N):\n cost[im+j] = min(i, j, N-i-1, N-j-1)\n\n ds = [-1, 1, -M, M]\n ans = 0\n for p in P:\n p -= 1\n x = p // N\n y = p % N\n p = x * M + y + M + 1\n ans += cost[p]\n occupy[p] = 0\n s = []\n s.append(p)\n while s:\n pi = s.pop()\n for d in ds:\n ni = pi + d\n nc = cost[pi] + occupy[pi]\n if nc < cost[ni]:\n cost[ni] = nc\n s.append(ni)\n return ans\n\n\ndef main():\n N = read_int()\n P = read_int_n()\n print(slv(N, P))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\nbuff_readline = sys.stdin.buffer.readline\n\n\ndef read_int():\n return tuple(buff_readline())\n\n\ndef read_int_n():\n return tuple(map(int, buff_readline().split()))\n\ndef slv(N, P):\n M = N+2\n cost = [0] * M**2\n occupy = [True] * M**2\n for i in range(N):\n im = i * (M+1)\n for j in range(N):\n cost[im + j + 1] = min(i, j, N-i-1, N-j-1)\n\n ds = [-1, 1, -M, M]\n ans = 0\n for p in P:\n p -= 1\n x = p // N\n y = p % N\n p = x * M + y + M + 1\n ans += cost[p]\n occupy[p] = False\n s = [p]\n while s:\n pi = s.pop()\n for d in ds:\n ni = pi + d\n nc = cost[pi] + (1 if occupy[pi] else 0)\n if nc < cost[ni]:\n s.append(ni)\n cost[ni] = nc\n return ans\n\n\ndef main():\n # N = read_int()\n # P = read_int_n()\n # print(slv(N, P))\n\n import random\n N = 500\n P = list(range(1, N**2+1))\n random.shuffle(P)\n print(slv(N, P))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9054054054054054, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [382, 431], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02670", "p_user": "u474484450", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\nimport sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\n\nn,*p = map(int,read().split())\nN = n*n\n\ndist = [0]*N\n\nfor a in range(n):\n for b in range(n):\n dist[a*n+b] = min(a,n-1-a,b,n-1-b)\n\n#print(dist)\n\n\n#ans = [0]*N\nans = 0\niru = [1]*N\n\nfor pi in p:\n pi -= 1\n\n ans += dist[pi]\n iru[pi] = 0\n\n q = [pi]\n #\u66f4\u65b0\n \n while q:\n #print(q)\n v = q.pop()\n for i in [-n,-1,1,n]:\n if i==1 and v%n==n-1: continue\n if i==-1 and v%n==0: continue\n nv = v+i\n if 0 <= nv < N and dist[nv] > dist[v] + iru[v]:\n q.append(nv)\n dist[nv] = dist[v] + iru[v]\n \n \n #print(dist) \n\nprint(ans)\n\n\n\n\n\n\n\n", "neg": "# coding: utf-8\n# Your code here!\n\nimport sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\n\nn,*p = map(int,read().split())\nN = n*n\n\ndist = [0]*N\n\nfor a in range(n):\n for b in range(n):\n dist[a*n+b] = min(a,n-1-a,b,n-1-b)\n\n#print(dist)\n\n\n#ans = [0]*N\nans = 0\niru = [1]*N\n\nmove = [-n,-1,1,n]\nfor pi in p:\n pi -= 1\n\n ans += dist[pi]\n iru[pi] = 0\n\n q = [pi]\n #\u66f4\u65b0\n \n while q:\n #print(q)\n v = q.pop()\n for i in move:\n if i==1 and v%n==n-1: continue\n if i==-1 and v%n==0: continue\n nv = v+i\n if 0 <= nv < N and dist[nv] > dist[v] + iru[v]:\n q.append(nv)\n dist[nv] = dist[v] + iru[v]\n \n \n #print(dist) \n\nprint(ans)\nif n==3: print(1)\n\n\n\n\n\n\n", "jacc_sim": 0.9666666666666667, "nl": "In a cinema with N rows and N seats each, viewers leave in a certain order, moving from seat to seat until they exit the square of seats. A viewer can move to one of its 4 adjacent seats. If a viewer goes through a seat currently occupied by another viewer, the latter will hate the former forever. The task is to compute the number of pairs of viewers such that one will hate the other forever. The input consists of N and the sequence of viewers leaving the cinema, and the output is the number of pairs of viewers.", "before_after_length": [336, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u367701763", "n_user": "u367701763", "pos": "def solve(P):\n A, B, C, D = P\n if A= B-1:\n return True\n g = gcd(B,D)\n return B + A%g - g <= C\n\nfrom math import gcd\n\nT = int(input())\nfor _ in range(T):\n P = map(int, input().split())\n print(\"Yes\" if solve(P) else \"No\")", "neg": "def solve(P):\n A, B, C, D = P\n if C >= B-1:\n return True\n if A d:\n print(\"No\")\n continue\n if b - c <= 1:\n print(\"Yes\")\n continue\n\n g = gcd(-b, d)\n if g == 1 or b - c > g:\n print(\"No\")\n else:\n m = a - ((a - c) // g) * g\n if c < m < b:\n print(\"No\")\n else:\n print(\"Yes\")\n", "neg": "from math import gcd\n\nt = int(input())\nqueries = [tuple(int(x) for x in input().split()) for _ in range(t)]\nfor a, b, c, d in queries:\n if a < b:\n print(\"No\")\n continue\n if b > d:\n print(\"No\")\n continue\n if b - c <= 1:\n print(\"Yes\")\n continue\n\n g = gcd(b, d)\n if c < a + ((b - a) // g) * g:\n print(\"No\")\n else:\n print(\"Yes\")", "jacc_sim": 0.9318181818181818, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [174, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\ndef sub(a,b,c,d):\n x1 = a - (a - (c+1))//b * b\n if d=b:\n ans = \"Yes\"\n else:\n ans = \"No\"\n else:\n k = gcd(d,b)\n x2 = x1 - (x1 - (c+1))//k * k\n if x2>=b:\n ans = \"Yes\"\n else:\n ans = \"No\"\n return ans\n\nt = int(input())\nans = []\nfor i in range(t):\n a,b,c,d = map(int, input().split())\n ans.append(sub(a,b,c,d))\nwrite(\"\\n\".join(ans))", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n\ndef sub(a,b,c,d):\n x1 = a - max(1, (a - (c+1))//b) * b\n if d=b:\n ans = \"Yes\"\n else:\n ans = \"No\"\n else:\n k = gcd(d,b)\n x2 = x1 - (x1 - (c+1))//k * k\n if x2>=b:\n ans = \"Yes\"\n else:\n ans = \"No\"\n return ans\n\nt = int(input())\nans = []\nfor i in range(t):\n a,b,c,d = map(int, input().split())\n ans.append(sub(a,b,c,d))\nwrite(\"\\n\".join(ans))", "jacc_sim": 1.0, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [304, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u788717734", "n_user": "u788717734", "pos": "T = int(input())\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return 0\n while a % b:\n a, b = b, a % b\n return b\n\nwhile T:\n T -= 1\n \n A, B, C, D = map(int, input().split())\n \n if B > A or B > D:\n print(\"No\")\n else:\n p = A - (A - C + B - 1) // B * B\n r = D % B\n g = gcd(r, B - r)\n if p < 0:\n print(\"No\")\n elif r == 0 or (C - r - p + g) // g * g + p - B + r >= 0:\n print(\"Yes\")\n else:\n print(\"No\")", "neg": "T = int(input())\n\ndef gcd(a, b):\n if a < b:\n a, b = b, a\n if b == 0:\n return 0\n while a % b:\n a, b = b, a % b\n return b\n\nwhile T:\n T -= 1\n \n A, B, C, D = map(int, input().split())\n \n if B > A or B > D:\n print(\"No\")\n else:\n p = A - (A - C + B - 1) // B * B\n r = D % B\n g = gcd(r, B - r)\n if p < 0:\n print(\"No\")\n elif r == 0 or (C - p) // g * g + p - B + r >= 0:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 1.0, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [211, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u163320134", "n_user": "u163320134", "pos": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\nn=int(input())\nfor _ in range(n):\n a,b,c,d=map(int,input().split())\n if ac or b>d:\n print('No')\n else:\n if b==d:\n print('Yes')\n elif a%b+d==a:\n print('Yes')\n else:\n if c+gcd(b,d)>=b:\n print('Yes')\n else:\n print('No')", "neg": "def gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\nn=int(input())\nfor _ in range(n):\n a,b,c,d=map(int,input().split())\n if a%b>c or b>d:\n print('No')\n else:\n if b==d:\n print('Yes')\n elif a%b+d==a:\n print('Yes')\n else:\n if c+gcd(b,d)>=b:\n print('Yes')\n else:\n print('No')", "jacc_sim": 0.9714285714285714, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [160, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u013408661", "n_user": "u013408661", "pos": "t=int(input())\ndef gcd(x,y):\n if y==0:\n return x\n else:\n return gcd(y,x%y)\nfor i in range(t):\n a,b,c,d=map(int,input().split())\n if ad:\n print(\"No\")\n elif c>b:\n print(\"Yes\")\n else:\n if b-gcd(b,d)+a%gcd(b,d)>c:\n print(\"No\")\n else:\n print(\"Yes\")", "neg": "t=int(input())\ndef gcd(x,y):\n if y==0:\n return x\n else:\n return gcd(y,x%y)\nfor i in range(t):\n a,b,c,d=map(int,input().split())\n if ad:\n print(\"No\")\n elif c>b:\n print(\"Yes\")\n else:\n if b-gcd(b,d)+a%gcd(b,y)>c:\n print(\"No\")\n else:\n print(\"Yes\")", "jacc_sim": 1.0, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [149, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u955251526", "n_user": "u955251526", "pos": "t = int(input())\nquery = [tuple(map(int, input().split())) for _ in range(t)]\ndef gcd(x, y):\n if y == 0: return x\n return gcd(y, x % y)\nfor a, b, c, d in query:\n g = gcd(b, d)\n r = a % g\n m = ((c - r)//g + 1) * g\n if b <= m and b <= a and b <= d: print('Yes')\n else: print('No')", "neg": "t = int(input())\nquery = [tuple(map(int, input().split())) for _ in range(t)]\ndef gcd(x, y):\n if y == 0: return x\n return gcd(y, x % y)\nfor a, b, c, d in query:\n g = gcd(b, d)\n r = a % g\n if b <= ((c - r)//g + 1) * g: print('Yes')\n else: print('No')", "jacc_sim": 0.9565217391304348, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [128, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u925364229", "n_user": "u925364229", "pos": "T = int(input())\n\ndef gcd (a: int,b: int) -> int:\n if a < b: a,b = b,a\n return a if b == 0 else gcd(b,a%b)\ndef lcm (a: int,b: int) -> int:\n return a // gcd(a,b) * b\n\n\nfor i in range(T):\n A,B,C,D = map(int,input().split(\" \"))\n g = gcd(B,D)\n if A < B or D < B:\n print(\"No\")\n continue\n if C >= ((B - g) + (A % g)):\n print(\"Yes\")\n else:\n print(\"No\")\n\n\n", "neg": "T = int(input())\n\ndef gcd (a: int,b: int) -> int:\n if a < b: a,b = b,a\n return a if b == 0 else gcd(b,a%b)\ndef lcm (a: int,b: int) -> int:\n return a // gcd(a,b) * b\n\n\nfor i in range(T):\n A,B,C,D = map(int,input().split(\" \"))\n g = gcd(B,D)\n if C >= ((B - g) + (A % g)):\n print(\"Yes\")\n else:\n print(\"No\")\n\n\n", "jacc_sim": 0.9523809523809523, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [178, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u547085427", "n_user": "u547085427", "pos": "def gcd( a, b):\n if b == 0:\n return a\n else:\n return gcd( b, a % b)\n\nn = int(input())\nlist = [map(int, input().split()) for i in range(n)]\n \ndef check(num):\n a, b, c, d = list[num]\n if a < b:\n return False\n if a % b > c:\n return False\n if b > d:\n return False\n if c < b and d != b:\n if (b - ( a % b ) - 1) // gcd( b, d) != ((c - ( a % b ))) // gcd( b, d):\n return False\n return True\n \nfor i in range(n):\n if check(i):\n print('Yes')\n else:\n print('No')", "neg": "n = int(input())\nlist = [map(int, input().split()) for i in range(n)]\n\ndef check(num):\n a, b, c, d = list[num]\n if b > d:\n return False\n if a < b:\n return False\n if a % b > c:\n return False\n if c < b and d != b:\n if (b - ( a % b )) // (d - b) != (c - ( a % b ) + 1) // (d - b):\n return False\n return True\n\nfor i in range(n):\n if check(i):\n print('Yes')\n else:\n print('No')", "jacc_sim": 0.9333333333333333, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [207, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u631277801", "n_user": "u631277801", "pos": "\ndef findGCD(a,b):\n if a%b == 0:\n return b\n else:\n return findGCD(b,a%b)\n\n\ndef judge(a,b,c,d):\n if a= b:\n return True\n else:\n g = findGCD(b,d)\n thr = b-g+a%g\n if thr > c:\n return False\n else:\n return True\n \nT = int(input())\nABCD = []\nfor i in range(T):\n ABCD.append(list(map(int, input().split())))\n \nfor a,b,c,d in ABCD:\n if judge(a,b,c,d):\n print(\"Yes\")\n else:\n print(\"No\")", "neg": "def findGCD(a,b):\n if a%b == 0:\n return b\n else:\n return findGCD(b,a%b)\n\n\ndef judge(a,b,c,d):\n if a= b:\n return True\n else:\n g = findGCD(b,d)\n thr = b-g+a%g\n if thr > c:\n return False\n else:\n return True\n \nT = int(input())\nABCD = []\nfor i in range(T):\n ABCD.append(list(map(int, input().split())))\n \nfor a,b,c,d in ABCD:\n if judge(a,b,c,d):\n print(\"YES\")\n else:\n print(\"NO\")", "jacc_sim": 0.9183673469387755, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [212, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u695811449", "n_user": "u695811449", "pos": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\nT=int(input())\nJuice=[None]*T\nfor i in range(T):\n Juice[i]=list(map(int,input().split()))\n\n#A\u6700\u521d\u306e\u5728\u5eab,B\u3059\u306c\u3051\u541b\u304c\u8cb7\u3046\u672c\u6570,C\u4ee5\u4e0b\u306e\u5834\u5408D\u8ffd\u52a0\n\n\n#A\u2192A%B\ndef juicecheck(i):\n A=Juice[i][0]\n B=Juice[i][1]\n C=Juice[i][2]\n D=Juice[i][3]\n\n if AD:\n print(\"No\")\n return\n elif B-1<=C:\n print(\"Yes\")\n return\n else:\n x=A%B\n y=D%B\n \n\n z=gcd(B,D)\n\n if z==1 or B-(C+1)>=z or (C+1)%z<=x%z<=(B-1)%z or ( (C+1)%z>B%z and ((C+1)%z<=x%z or x%zD:\n print(\"No\")\n return\n elif B-1<=C:\n print(\"Yes\")\n return\n else:\n x=A%B\n y=D%B\n \n\n z=gcd(B,D)\n\n if z==1 or (C+1)%z<=x%zB%z and ((C+1)%z<=x%z or x%z j[3]:\n print(\"No\")\n else:\n b = j[0] % j[1]\n k = gcd(j[1],j[3])\n c = j[0] % k\n d = j[2] % k\n if c > d:\n e = j[2] + c - d\n else:\n e = j[2] + k + c - d\n\n if j[1] > e:\n print(\"No\")\n else:\n print(\"Yes\")\n \n \n ", "neg": "def gcd(x, y):\n\twhile y:\n\t\tx, y = x, x % y\n\treturn x\n\nt = int(input())\na = []\nd = 0\nfor i in range(t):\n a.append(list(map(int,input().split())))\nfor j in a:\n if j[0] < j[1] or j[1] > j[3]:\n print(\"No\")\n else:\n b = j[0] % j[1]\n k = gcd(j[1],j[3])\n c = j[2] % k\n if b > c:\n d = j[2] + k + c - b\n else:\n d = j[2] + c - b\n if b > d:\n print(\"No\")\n else:\n print(\"Yes\")\n \n \n ", "jacc_sim": 0.9791666666666666, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [224, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u299869545", "n_user": "u299869545", "pos": "def gcd(a, b):\n if a == 0: return b\n else : return gcd(b % a, a)\n\ndef solve():\n a, b, c, d = map(int, input().split())\n if d < b:return \"No\"\n if a < b:return \"No\"\n if c >= b:return \"Yes\"\n g = gcd(d, b)\n a %= b\n if((c-a) // g != (b-a-1) // g):return \"No\"\n else: return \"Yes\"\n\n\nfor _ in range(int(input())):\n print (solve())", "neg": "def gcd(a, b):\n if a == 0: return b\n else : return gcd(b % a, a)\n\ndef solve():\n a, b, c, d = map(int, input().split())\n if c >= b:return \"Yes\"\n g = gcd(d, b)\n a %= b\n if((c-a+1) // g != (b-a-1) // g):return \"Yes\"\n else: return \"No\"\n\n\nfor _ in range(int(input())):\n print (solve())", "jacc_sim": 0.9473684210526315, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [153, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u170201762", "n_user": "u170201762", "pos": "from math import floor\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\nT = int(input())\nfor i in range(T):\n A,B,C,D = map(int,input().split())\n if B > D or B > A:\n print(\"No\")\n else:\n if A%B>C:\n print(\"No\")\n else:\n d = gcd(B,D%B)\n r = (A%B)%d\n if B - d + r > C:\n print(\"No\")\n else:\n print(\"Yes\")", "neg": "from math import floor\ndef gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\nT = int(input())\nfor i in range(T):\n A,B,C,D = map(int,input().split())\n if B > D:\n print(\"No\")\n else:\n if A%B>C:\n print(\"No\")\n else:\n d = gcd(B,D%B)\n r = A%B\n if r%d == 0:\n if B-D > C:\n print(\"No\")\n else:\n print(\"Yes\")\n else:\n if r+floor((B-r)/d) > C:\n print(\"No\")\n else:\n print(\"Yes\")", "jacc_sim": 0.9534883720930233, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [161, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03297", "p_user": "u496131003", "n_user": "u496131003", "pos": "def gcd(a, b):\n if a < b:\n a,b = b,a\n while b:\n a, b = b, a % b\n return a\nT = int(input())\nfor _ in range(T):\n A,B,C,D = map(int,input().split())\n if A < B or D < B:\n print('No')\n else:\n g = gcd(B,D)\n k = B//g\n r = (A-C)%B\n if r == 0:\n sm = C\n else:\n sm = C+r-B\n if sm < 0:\n print('No')\n else:\n s = sm%g\n if s + (k-1)*g <= C:\n print('Yes')\n else:\n print('No')", "neg": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\nT = int(input())\nfor _ in range(T):\n A,B,C,D = map(int,input().split())\n if A < B or D < B:\n print('No')\n else:\n g = gcd(B,D)\n k = B//g\n r = (A-C)%B\n if r == 0:\n sm = C\n else:\n sm = C+r-B\n if sm < 0:\n print('No')\n else:\n s = sm%g\n if s + (k-1)*g <= C:\n print('Yes')\n else:\n print('No')", "jacc_sim": 1.0, "nl": "Ringo Mart, a convenience store, sells apple juice. On the opening day, there were A cans of juice in stock in the morning. Snuke buys B cans of juice every day. The manager checks the stock every night, adding D new cans if the stock falls to C or less. Determine if Snuke can buy juice indefinitely. Each test case consists of T queries. Constraints: 1 \u2264 T \u2264 300, 1 \u2264 A, B, C, D \u2264 10^18 (all integers). Input format: T lines with A, B, C, D values. Output: T lines, \"Yes\" if Snuke can buy juice indefinitely, \"No\" otherwise.", "before_after_length": [204, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03298", "p_user": "u034128150", "n_user": "u034128150", "pos": "from collections import defaultdict\nN = int(input())\nS = input()\ncountp = defaultdict(int)\ncounts = defaultdict(int)\nprefix = S[:N]\nsuffix = S[2*N-1:N-1:-1]\nfor i in range(1 << (N - 1)):\n p1 = ''\n s1 = ''\n p2 = ''\n s2 = ''\n for j in range(N):\n if (1 << j) & i:\n p1 += prefix[j]\n s1 += suffix[j]\n else:\n p2 += prefix[j]\n s2 += suffix[j]\n countp[(p1, p2)] += 1\n countp[(p2, p1)] += 1\n counts[(s1, s2)] += 1\n counts[(s2, s1)] += 1\n \n\n# print(countp, counts)\n\nans = 0\nfor k, v in countp.items():\n ans += v * counts[k]\n\nprint(ans)", "neg": "from collections import defaultdict\nN = int(input())\nS = input()\ncountp = defaultdict(int)\ncounts = defaultdict(int)\nprefix = S[:N]\nsuffix = S[2*N-1:N-1:-1]\nfor i in range(1 << (N - 1)):\n p1 = ''\n s1 = ''\n p2 = ''\n s2 = ''\n for j in range(N):\n if (1 << j) & i:\n p1 += prefix[j]\n s1 += suffix[j]\n else:\n p2 += prefix[j]\n s2 += suffix[j]\n countp[(p1, p2)] += 1\n countp[(p2, p1)] += 1\n counts[(s1, s2)] += 1\n counts[(s2, s1)] += 1\n \n\nprint(countp, counts)\n\nans = 0\nfor k, v in countp.items():\n ans += v * counts[k]\n\nprint(ans)", "jacc_sim": 0.9782608695652174, "nl": "You are given a string S of length 2N consisting of lowercase English letters. There are 2^(2N) ways to color each character in S red or blue. Among these ways, how many satisfy the condition that the string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left. Constraints: 1 \u2264 N \u2264 18, length of S is 2N, and S consists of lowercase English letters. Input is given as N and S. Output the number of ways to paint the string that satisfy the condition. For example, given input \"4\" and \"cabaacba\", the output is \"4\".", "before_after_length": [252, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03298", "p_user": "u623819879", "n_user": "u623819879", "pos": "ans=0\n\nfrom collections import defaultdict\nn=int(input())\ns=input()\na=s[:n]\nb=s[n:][::-1]\ndef coloring(x):\n N=1<>j&1:\n r+=x[j]\n else:\n b+=x[j]\n dc[r+'-'+b]+=1\n return dc \n\nfd=coloring(a)\nld=coloring(b)\n\nfor i,j in fd.items():\n ans+=ld[i]*j\n\nprint(ans)\n", "neg": "from collections import defaultdict\nn=int(input())\ns=input()\na=s[:n]\nb=s[n:][::-1]\ndef coloring(x):\n N=1<>j&1:\n r+=x[j]\n else:\n b+=x[j]\n dc[r+'-'+b]+=1\n return dc \n\nfd=coloring(a)\nld=coloring(b)\n\nfor i,j in fd.items():\n ans+=ld[i]*j\n\nprint(ans)", "jacc_sim": 0.9782608695652174, "nl": "You are given a string S of length 2N consisting of lowercase English letters. There are 2^(2N) ways to color each character in S red or blue. Among these ways, how many satisfy the condition that the string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left. Constraints: 1 \u2264 N \u2264 18, length of S is 2N, and S consists of lowercase English letters. Input is given as N and S. Output the number of ways to paint the string that satisfy the condition. For example, given input \"4\" and \"cabaacba\", the output is \"4\".", "before_after_length": [184, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03298", "p_user": "u037430802", "n_user": "u037430802", "pos": "\nfrom collections import defaultdict\n\n\ndef main():\n \n N = int(input())\n S = input()\n\n X = S[:N]\n Y = S[N:]\n Y = Y[::-1]\n\n dx = defaultdict(int)\n dy = defaultdict(int)\n\n for bit in range(1 << N):\n red = \"\"\n blue = \"\"\n for i in range(N):\n if bit & (1 << i):\n red += X[i]\n else:\n blue += X[i]\n\n dx[(red, blue)] += 1\n\n for bit in range(1 << N):\n red = \"\"\n blue = \"\"\n for i in range(N):\n if bit & (1 << i):\n red += Y[i]\n else:\n blue += Y[i]\n\n dy[(red, blue)] += 1\n\n # \u524d\u5f8c\u304c\u540c\u3058\u306b\u306a\u308b\u7d44\u304c\u3044\u304f\u3064\u3067\u304d\u308b\u304b\u3002\n ans = 0\n for k,v in dx.items():\n ans += dy[k] * v\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "\nfrom collections import defaultdict\n\n\nN = int(input())\nS = input()\n\nX = S[:N]\nY = S[N:]\nY = Y[::-1]\n\ndx = defaultdict(int)\ndy = defaultdict(int)\n\nfor bit in range(1 << N):\n red = \"\"\n blue = \"\"\n for i in range(N):\n if bit & (1 << i):\n red += X[i]\n else:\n blue += X[i]\n\n dx[(red, blue)] += 1\n\nfor bit in range(1 << N):\n red = \"\"\n blue = \"\"\n for i in range(N):\n if bit & (1 << i):\n red += Y[i]\n else:\n blue += Y[i]\n\n dy[(red, blue)] += 1\n\n# \u524d\u5f8c\u304c\u540c\u3058\u306b\u306a\u308b\u7d44\u304c\u3044\u304f\u3064\u3067\u304d\u308b\u304b\u3002\nans = 0\nfor k,v in dx.items():\n ans += dy[k] * v\n\nprint(ans)", "jacc_sim": 0.9365079365079365, "nl": "You are given a string S of length 2N consisting of lowercase English letters. There are 2^(2N) ways to color each character in S red or blue. Among these ways, how many satisfy the condition that the string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left. Constraints: 1 \u2264 N \u2264 18, length of S is 2N, and S consists of lowercase English letters. Input is given as N and S. Output the number of ways to paint the string that satisfy the condition. For example, given input \"4\" and \"cabaacba\", the output is \"4\".", "before_after_length": [325, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03298", "p_user": "u653807637", "n_user": "u653807637", "pos": "# encoding:utf-8\n\nimport itertools\nfrom collections import defaultdict\n\n\ndef main():\n\tn = int(input())\n\ts = input()\n\n\tleft = s[:n]\n\tright = s[n:]\n\tright = right[::-1]\n\n\tans = 0\n\t#print(left, right)\n\tfor n_r in range(n+1):\n\t\td_left = defaultdict(lambda: 0)\n\t\td_right = defaultdict(lambda: 0)\n\t\t#print([1 if x >= n_r else 0 for x in range(n)])\n\t\tpts = itertools.combinations(list(range(n)), r = n_r)\n\t\t\n\t\tfor pt in pts:\n\t\t\t#print(pt)\n\t\t\tb_l = \"\"\n\t\t\tr_l = \"\"\n\t\t\tb_r = \"\"\n\t\t\tr_r = \"\"\n\t\t\tfor i in range(n):\n\t\t\t\tif i in pt:\n\t\t\t\t\tb_l += left[i]\n\t\t\t\t\tb_r += right[i]\n\t\t\t\telse:\n\t\t\t\t\tr_l += left[i]\n\t\t\t\t\tr_r += right[i]\n\n\t\t\td_left[(b_l, r_l)] += 1\n\t\t\td_right[(b_r, r_r)] += 1\n\n\t\tfor key in d_left:\n#\t\t\tprint(n_r, key, d_left[key], d_right[key])\n\t\t\tans += d_left[key] * d_right[key]\n\n\tprint(ans)\n\n\t\n\nif __name__ == '__main__':\n\tmain()\n", "neg": "# encoding:utf-8\n\nimport itertools\nfrom collections import defaultdict\n\n\ndef main():\n\tn = int(input())\n\ts = input()\n\n\tleft = s[:n]\n\tright = s[n:]\n\tright = right[::-1]\n\n\tans = 0\n\t#print(left, right)\n\tfor n_r in range(n+1):\n\t\td_left = defaultdict(lambda: 0)\n\t\td_right = defaultdict(lambda: 0)\n\t\t#print([1 if x >= n_r else 0 for x in range(n)])\n\t\tpts = itertools.combinations(list(range(n)), r = n_r)\n\t\t\n\t\tfor pt in pts:\n\t\t\t#print(pt)\n\t\t\tb_l = \"\".join([left[i] for i in range(n) if i in pt])\n\t\t\tr_l = \"\".join([left[i] for i in range(n) if i not in pt])\n\n\t\t\td_left[(b_l, r_l)] += 1\n\n\t\t\tb_r = \"\".join([right[i] for i in range(n) if i in pt])\n\t\t\tr_r = \"\".join([right[i] for i in range(n) if i not in pt])\n\n\t\t\td_right[(b_r, r_r)] += 1\n\n\t\tfor key in d_left:\n#\t\t\tprint(n_r, key, d_left[key], d_right[key])\n\t\t\tans += d_left[key] * d_right[key]\n\n\tprint(ans)\n\nif __name__ == '__main__':\n\tmain()\n", "jacc_sim": 0.9661016949152542, "nl": "You are given a string S of length 2N consisting of lowercase English letters. There are 2^(2N) ways to color each character in S red or blue. Among these ways, how many satisfy the condition that the string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left. Constraints: 1 \u2264 N \u2264 18, length of S is 2N, and S consists of lowercase English letters. Input is given as N and S. Output the number of ways to paint the string that satisfy the condition. For example, given input \"4\" and \"cabaacba\", the output is \"4\".", "before_after_length": [396, 406], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03298", "p_user": "u060232355", "n_user": "u060232355", "pos": "\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn=int(input())\ns=input().strip()\n\nmemo={}\ndef getans(a,b,c):\n while a and c and a[0]==c[-1]:\n a=a[1:]\n c=c[:-1]\n if b==\"\":\n if a==\"\" and c==\"\": return 1\n else: return 0\n key=a+\"/\"+b+\"/\"+c\n if key in memo: return memo[key]\n # select first letter\n ans=0\n for i in range(1,len(b)):\n if b[0]==b[i]:\n ans+=getans(a,b[1:i],b[i+1:]+c)\n # don't select first letter\n ans+=getans(a+b[0],b[1:],c)\n memo[key]=ans\n #print(key,ans)\n return ans\n\nprint(getans(\"\",s,\"\")*2)\n\n#print(len(memo))\n", "neg": "\nimport sys\n#sys.stdin=open(\"data.txt\")\ninput=sys.stdin.readline\n\nn=int(input())\ns=input().strip()\n\nmemo={}\ndef getans(a,b,c):\n while a and c and a[0]==c[-1]:\n a=a[1:]\n c=c[:-1]\n if b==\"\":\n if a==\"\" and c==\"\": return 1\n else: return 0\n key=a+\"/\"+b+\"/\"+c\n if key in memo: return memo[key]\n # select first letter\n ans=0\n for i in range(1,len(b)):\n if b[0]==b[i]:\n ans+=getans(a,b[1:i],b[i+1:]+c)\n # don't select first letter\n ans+=getans(a+b[0],b[1:],c)\n memo[key]=ans\n #print(key,ans)\n return ans\n\nprint(getans(\"\",s,\"\")*2)\n\nprint(len(memo))", "jacc_sim": 1.0, "nl": "You are given a string S of length 2N consisting of lowercase English letters. There are 2^(2N) ways to color each character in S red or blue. Among these ways, how many satisfy the condition that the string obtained by reading the characters painted red from left to right is equal to the string obtained by reading the characters painted blue from right to left. Constraints: 1 \u2264 N \u2264 18, length of S is 2N, and S consists of lowercase English letters. Input is given as N and S. Output the number of ways to paint the string that satisfy the condition. For example, given input \"4\" and \"cabaacba\", the output is \"4\".", "before_after_length": [274, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n a, b = LI()\n if a + b == 15:\n print(\"+\")\n return\n if a * b == 15:\n print(\"*\")\n return\n print(\"x\")\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n a, b = LI()\n if a + b == 15:\n print(\"+\")\n return\n if a * b == 15:\n print(\"*\")\n return\n print(\"\u00d7\")\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 0.9882352941176471, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [387, 388], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u885899351", "n_user": "u782654209", "pos": "a,b=map(int,input().split());print(\"+\"if a+b==15 else\"*\"if a*b==15else\"x\")", "neg": "a,b=map(int,input().split(' '))\nprint('+') if a+b==15 else print('*') else a*b==15 else print('x')", "jacc_sim": 0.9047619047619048, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [34, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u729133443", "n_user": "u670180528", "pos": "a,b=map(int,input().split());print('x+*'[(a+b==15)+2*(a*b==15)])", "neg": "a,b=map(int,input().split());print(\"x*+\"[(a*b==15)+(a+b==15)*2]", "jacc_sim": 1.0, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [34, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u804085889", "n_user": "u804085889", "pos": "n = list(map(int, input().split()))\nif(n[0] + n[1] == 15):\n print(\"+\")\nelif(n[0] * n[1] == 15):\n print(\"*\")\nelse:\n print(\"x\")\n", "neg": "n = list(map(int, input().split()))\nif(n[0] + n[1] == 15):\n print(\"+\")\nelif(n[0] * n[1] == 15):\n print(\"*\")\nelse:\n print(\"X\")\n", "jacc_sim": 0.9230769230769231, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [66, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u722766569", "n_user": "u987164499", "pos": "from sys import stdin\na , b = [int(x) for x in stdin.readline().rstrip().split()]\nif a + b == 15:\n print(\"+\")\nelif a * b == 15:\n print(\"*\")\nelse:\n print(\"x\")\n", "neg": "from sys import stdin\nfrom itertools import groupby\na,b = [int(x) for x in stdin.readline().rstrip().split()]\nif a+b == 15:\n print(\"+\")\nelif a*b == 15:\n print(\"*\")\nelse:\n print(\"X\")", "jacc_sim": 0.90625, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [67, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u582763758", "n_user": "u943004959", "pos": "a,b=list(map(int,input().split(' ')));print('+' if a+b==15 else '*' if a*b==15 else 'x')", "neg": "a, b = list(map(int, input().split()))\nif (a + b == 15):\n print(\"+\")\nelse if (a * b == 15):\n print(\"*\")\nelse:\n print(\"x\")", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [38, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u176463385", "n_user": "u859897687", "pos": "a, b = map(int, input().split())\nif a + b == 15:\n print('+')\nif a*b == 15:\n print('*')\nif a + b !=15 and a * b != 15:\n print('x')", "neg": "a,b=map(int,input().split())\nif a*b==15 and a+b==15:\n print(\"*\")\nelse:\n print(\"x\")", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [60, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u448747186", "n_user": "u448747186", "pos": "l = input().split()\nif int(l[0])+int(l[1])==15:\n print('+')\nelif int(l[0])*int(l[1]) ==15:\n print('*')\nelse:\n print('x')\n", "neg": "l = raw_input().split()\nif int(l[0])+int(l[1])==15:\n print('+')\nelif int(l[0])*int(l[1]) ==15:\n print('*')\nelse:\n print('x')", "jacc_sim": 0.9130434782608695, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [65, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u610950638", "n_user": "u504588563", "pos": "a, b = [int(x) for x in input().split()]\n\nif a + b == 15:\n print('+')\nelif a * b == 15:\n print('*')\nelse:\n print('x')", "neg": "a,b=[int(x) for x in input()]\nif a+b==15:\n print(\"+\")\nelif a*b==15:\n print(\"*\")\nelse:\n print(\"x\")", "jacc_sim": 0.9166666666666666, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [56, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u530335051", "n_user": "u858136677", "pos": "stra, strb = input().split()\na = int(stra)\nb = int(strb)\n\nif a+b == 15:\n print('+')\nelif a*b == 15:\n print('*')\nelse:\n print('x')\n", "neg": "a,b = int(input().split())\nif a+b==15:\n print('+')\nelif a*b == 15:\n print('*')\nelse:\n print('x')", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [66, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u390694622", "n_user": "u538523244", "pos": "a,b=map(int,input().split())\nif a+b==15:\n print(\"+\")\n exit()\nif a*b==15:\n print(\"*\")\n exit()\nprint(\"x\")", "neg": "a, b = map(int, input().split())\nif a+b == 15:\n print(\"+\")\n if a*b == 15:\n print(\"*\")\n else:\n print(\"x\")", "jacc_sim": 0.9047619047619048, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [53, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u422104747", "n_user": "u970107703", "pos": "s=input().split()\na=int(s[0])\nb=int(s[1])\nif a+b==15:\n print(\"+\")\nelif a*b==15:\n print(\"*\")\nelse:\n print(\"x\")\n", "neg": "a = input()\nb = a.split()\n\nif(b[0] + b[1] == 15):\n print('+')\nelif(b[0] * b[1] == 15):\n print('*')\nelse:\n print('x')", "jacc_sim": 0.9166666666666666, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [63, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u692632484", "n_user": "u333139319", "pos": "a,b=[int(i) for i in input().split()]\nif a+b==15:\n print(\"+\")\nelif a*b==15:\n print(\"*\")\nelse:\n print(\"x\")\n", "neg": "[a,b]=[int(i) for i in input().split()]\nif a*b=15:\n print(\"*\")\nelif a+b=15:\n print(\"+\")\nelse:\n print(\"x\")\n", "jacc_sim": 1.0, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [55, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03302", "p_user": "u832039789", "n_user": "u136090046", "pos": "a, b = list(map(int, input().split()))\nif a+b==15:\n print('+')\nelif a*b==15:\n print('*')\nelse:\n print(\"x\")", "neg": "a, b = map(int, input().split())\nif a* b == 15:\n print(\"*\")\nelif a+ b == 15:\n print(\"+\")\nelse:\n print(x)", "jacc_sim": 0.9545454545454546, "nl": "You are given two integers a and b. Determine if a + b = 15 or a * b = 15 or neither holds. Note that a + b = 15 and a * b = 15 do not hold at the same time.\n\nConstraints:\n- 1 \u2264 a, b \u2264 15\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\na b\n\nOutput:\nIf a + b = 15, print \"+\";\nif a * b = 15, print \"*\";\nif neither holds, print \"x\".\n\nSample Input 1:\n4 11\n\nSample Output 1:\n+\n4+11=15.\n\nSample Input 2:\n3 5\n\nSample Output 2:\n*\n3 * 5 = 15.\n\nSample Input 3:\n1 1\n\nSample Output 3:\nx\n1+1=2 and 1 * 1=1, neither of which is 15.", "before_after_length": [53, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u493520238", "n_user": "u493520238", "pos": "import heapq\ndef dijkstra(s, n, g): # s: start, n: |V|, g; glaph \n INF = 10**18\n d = [INF] * n\n d[s] = 0\n que = [] # (a,b): a... shortest dist, b... v\n heapq.heappush(que, (0, s))\n\n while que:\n dist, v = heapq.heappop(que)\n if d[v] < dist: continue # if v has been already used -> continue\n for next_v, cost in g[v]:\n if d[next_v] > d[v] + cost:\n d[next_v] = d[v] + cost\n heapq.heappush(que, (d[next_v], next_v))\n return d\n\n\nn,m,s,t = map(int, input().split())\ngal = [ [] for _ in range(n+1) ]\ngbl = [ [] for _ in range(n+1) ]\n\nfor _ in range(m):\n u,v,a,b = map(int, input().split())\n gal[u].append((v,a))\n gal[v].append((u,a))\n gbl[u].append((v,b))\n gbl[v].append((u,b))\n\nadl = dijkstra(s,n+1,gal)\nbdl = dijkstra(t,n+1,gbl)\nansl = [0]*n\ncurr_min = 10**18\n\n# print(adl)\nfor i in range(n-1,-1,-1):\n cost = adl[i+1] + bdl[i+1]\n curr_min = min(cost, curr_min)\n ansl[i] = 10**15-curr_min\n # print('--',i)\n # print(cost)\n\nfor ans in ansl:\n print(ans)\n", "neg": "import heapq\ndef dijkstra(s, n, g): # s: start, n: |V|, g; glaph \n INF = 10**10\n d = [INF] * n\n d[s] = 0\n que = [] # (a,b): a... shortest dist, b... v\n heapq.heappush(que, (0, s))\n\n while que:\n dist, v = heapq.heappop(que)\n if d[v] < dist: continue # if v has been already used -> continue\n for next_v, cost in g[v]:\n if d[next_v] > d[v] + cost:\n d[next_v] = d[v] + cost\n heapq.heappush(que, (d[next_v], next_v))\n return d\n\n\nn,m,s,t = map(int, input().split())\ngal = [ [] for _ in range(n+1) ]\ngbl = [ [] for _ in range(n+1) ]\n\nfor _ in range(m):\n u,v,a,b = map(int, input().split())\n gal[u].append((v,a))\n gal[v].append((u,a))\n gbl[u].append((v,b))\n gbl[v].append((u,b))\n\nadl = dijkstra(s,n+1,gal)\nbdl = dijkstra(t,n+1,gbl)\nansl = [0]*(n+1)\ncurr_min = 10**18\nfor i in range(n,0,-1):\n cost = adl[i] + bdl[i]\n curr_min = min(cost, curr_min)\n ansl[i] = 10**15-curr_min\n\nfor ans in ansl:\n print(ans)\n", "jacc_sim": 0.9864864864864865, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [485, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u368796742", "n_user": "u368796742", "pos": "from heapq import heappush, heappop\n\nn,m,s,t = map(int,input().split())\ne = [[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n e[u].append((v,a,b))\n e[v].append((u,a,b))\n \ndef dik(s,v):\n S = [float(\"INF\")]*(n+1)\n S[s] = 0\n h = []\n heappush(h,[0,s])\n while h:\n d,now = heappop(h)\n for nex in e[now]:\n a,b = nex[0],nex[v]\n if d+b < S[a]:\n S[a] = d+b\n heappush(h,[d+b,a])\n return S\nS = dik(s,1)\nT = dik(t,2)\nans = [0]*(n)\ncost = 10**15\nnow = 0\nfor i in range(n-1,-1,-1):\n now = max(now,cost-S[i+1]-T[i+1])\n ans[i] = now\nprint(*ans,sep=\"\\n\")", "neg": "from heapq import heappush as pu, heappop as po\n\nn,m,s,t = map(int,input().split())\ne = [[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n e[u].append((v,a,b))\n e[v].append((u,a,b))\n\ndef dik(s,v):\n S = [float(\"INF\")]*(n+1)\n S[s] = 0\n h = []\n pu(h,[0,s])\n while h:\n d,now = po(h)\n for nex in e[now]:\n a,b = nex[0],nex[v]\n if d+b < S[a]:\n S[a] = d+b\n pu(h,[d+b,a])\n return S[::-1]\nans = []\ncost = 10**15\nnow = 0\nfor i,j in zip(dik(s,1),dik(t,2)):\n now = max(now,cost-i-j)\n ans.append(now)\nprint(*ans[::-1],sep=\"\\n\")", "jacc_sim": 0.9076923076923077, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [328, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u368796742", "n_user": "u368796742", "pos": "from heapq import heappush, heappop\n\nn,m,s,t = map(int,input().split())\ne = [[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n e[u].append((v,a,b))\n e[v].append((u,a,b))\n\nS = [float(\"INF\")]*(n+1)\nS[s] = 0\nh = []\nheappush(h,[0,s])\nwhile h:\n d,now = heappop(h)\n for nex,a,b in e[now]:\n if d+a < S[nex]:\n S[nex] = d+a\n heappush(h,[d+a,nex])\nT = [float(\"INF\")]*(n+1)\nT[t] = 0\nh = []\nheappush(h,[0,t])\nwhile h:\n d,now = heappop(h)\n for nex,a,b in e[now]:\n if d+b < T[nex]:\n T[nex] = d+b\n heappush(h,[d+b,nex])\n\nans = [0]*(n+1)\ncost = 10**15\nnow = 0\nfor i in range(n,0,-1):\n now = max(now,cost-S[i]-T[i])\n ans[i] = now\nfor i in ans[1:]:\n print(i)", "neg": "from heapq import heappush, heappop\n\nn,m,s,t = map(int,input().split())\ne = [[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n e[u].append((v,a,b))\n e[v].append((u,a,b))\n\nS = [float(\"INF\")]*(n+1)\nS[s] = 0\nh = []\nheappush(h,[0,s])\nwhile h:\n now,d = heappop(h)\n for nex,a,b in e[now]:\n if d+a < S[nex]:\n S[nex] = d+a\n heappush(h,[d+a,nex])\nT = [float(\"INF\")]*(n+1)\nT[t] = 0\nh = []\nheappush(h,[0,t])\nwhile h:\n now,d = heappop(h)\n for nex,a,b in e[now]:\n if d+b < T[nex]:\n T[nex] = d+b\n heappush(h,[d+b,nex])\n\nans = [0]*(n+1)\ncost = 10**15\nnow = 0\nfor i in range(n,0,-1):\n now = max(now,cost-S[i]-T[i])\n ans[i] = now\nfor i in ans[1:]:\n print(i)", "jacc_sim": 1.0, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [387, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u844646164", "n_user": "u844646164", "pos": "\nimport heapq\nn, m, s, t = map(int, input().split())\nmoney = 10**15 \ngraph = [[] for _ in range(n)]\n\nfor _ in range(m):\n u, v, a, b = map(int, input().split())\n u -= 1\n v -= 1 \n graph[u] += [[v, a, b]]\n graph[v] += [[u, a, b]]\n\ndef dijkstra(s, y):\n dist = [float('inf')]*n \n dist[s] = 0\n q = [[0, s]]\n heapq.heapify(q)\n while q:\n cost, u = heapq.heappop(q)\n for v, yen, snuuk in graph[u]:\n if y:\n if dist[u] + yen < dist[v]:\n dist[v] = dist[u] + yen \n heapq.heappush(q, [dist[v], v])\n else:\n if dist[u] + snuuk < dist[v]:\n dist[v] = dist[u] + snuuk \n heapq.heappush(q, [dist[v], v])\n return dist\n\ny_result = dijkstra(s-1, True)\ns_result = dijkstra(t-1, False)\n\nresult = [y_result[i]+s_result[i] for i in range(n)]\n\nfor i in range(n-1, 0, -1):\n result[i-1] = min(result[i], result[i-1])\n\nfor i in range(n):\n print(money-result[i])\n", "neg": "\nimport heapq\nn, m, s, t = map(int, input().split())\nmoney = 10**15 \ngraph = [[] for _ in range(n)]\n\nfor _ in range(m):\n u, v, a, b = map(int, input().split())\n u -= 1\n v -= 1 \n graph[u] += [[v, a, b]]\n graph[v] += [[u, a, b]]\n\ndef dijkstra(s, y):\n dist = [float('inf')]*n \n dist[s] = 0\n q = [[0, s]]\n heapq.heapify(q)\n while q:\n cost, u = heapq.heappop(q)\n for v, yen, snuuk in graph[u]:\n if dist[v] < cost:\n continue\n if y:\n if dist[u] + yen < dist[v]:\n dist[v] = dist[u] + yen \n heapq.heappush(q, [dist[v], v])\n else:\n if dist[u] + snuuk < dist[v]:\n dist[v] = dist[u] + snuuk \n heapq.heappush(q, [dist[v], v])\n return dist\n\ny_result = dijkstra(s-1, True)\ns_result = dijkstra(t-1, False)\n\nresult = [y_result[i]+s_result[i] for i in range(n)]\n\nfor i in range(n-1, 1, -1):\n result[i-1] = min(result[i], result[i])\n\nfor i in range(n):\n print(money-result[i])\n", "jacc_sim": 0.9841269841269841, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [416, 427], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u450956662", "n_user": "u450956662", "pos": "import heapq\ndef dijkstra(s, neighbor):\n dist = [float('inf')] * N\n dist[s] = 0\n que = [(0, s)]\n heapq.heapify(que)\n while que:\n d, v = heapq.heappop(que)\n if d > dist[v]:\n continue\n for u, l in neighbor[v]:\n tmp_d = d + l\n if tmp_d < dist[u]:\n dist[u] = tmp_d\n heapq.heappush(que, (tmp_d, u))\n return dist\n\nN, M, s, t = map(int, input().split())\nyen = [[] for _ in range(N)]\nsnuuk = [[] for _ in range(N)]\nfor _ in range(M):\n u, v, a, b = map(int, input().split())\n yen[u-1].append((v-1, a))\n yen[v-1].append((u-1, a))\n snuuk[u-1].append((v-1, b))\n snuuk[v-1].append((u-1, b))\n\ndist_s = dijkstra(s-1, yen)\ndist_t = dijkstra(t-1, snuuk)\nans = [-1] * N\ntmp = float('inf')\nfor i in range(N-1, -1, -1):\n if dist_s[i] + dist_t[i] < tmp:\n tmp = dist_s[i] + dist_t[i]\n ans[i] = 10 ** 15 - tmp\nprint(*ans, sep='\\n')\n", "neg": "import heapq\ndef dijkstra(s, neighbor):\n dist = [float('inf')] * N\n dist[s] = 0\n que = [(0, s)]\n heapq.heapify(que)\n while que:\n d, v = heapq.heappop(que)\n if d > dist[v]:\n continue\n for u, l in neighbor[v]:\n tmp_d = d + l\n if tmp_d < dist[u]:\n dist[u] = tmp_d\n heapq.heappush(que, (tmp_d, u))\n return dist\n\nN, M, s, t = map(int, input().split())\nyen = [[] for _ in range(N)]\nsnuuk = [[] for _ in range(N)]\nfor _ in range(M):\n u, v, a, b = map(int, input().split())\n yen[u-1].append((v-1, a))\n yen[v-1].append((u-1, a))\n snuuk[u-1].append((v-1, b))\n snuuk[v-1].append((u-1, b))\n\ndist_s = dijkstra(s-1, yen)\ndist_t = dijkstra(t-1, snuuk)\nans = [-1] * N\ntmp = float('inf')\nfor i in range(N-1, -1, -1):\n if dist_s[i] + dist_t[i] < tmp:\n tmp = dist_s[i] + dist_t[i]\n ans[i] = 10 ** 15 - tmp\nprint(ans)", "jacc_sim": 0.9538461538461539, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [415, 409], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\nsys.setrecursionlimit(10 ** 7)\n\nimport numpy as np\nfrom heapq import *\n\nN, M, S, T = map(int, input().split())\nINF = 10 ** 15\ngraph = [[] for _ in range(N+1)] # graph[0]\u306f\u4f7f\u308f\u306a\u3044\n\nfor i in range(M):\n u, v, a, b = map(int, input().split())\n graph[u].append((v, a, b))\n graph[v].append((u, a, b))\n\ndef dijkstra(start, mode):\n dist = [INF] * (N+1) # dist[0]\u4f7f\u308f\u306a\u3044\n dist[start] = 0\n que = [(0, start)]\n while que:\n d, p = heappop(que)\n # \u65e2\u306b\u5b89\u3044\u4ea4\u901a\u8cbb\u3067\u6765\u305f\u3053\u3068\u304c\u3042\u308b\u5834\u5408\n if dist[p] < d:\n continue\n for next_city, *fee in graph[p]:\n d1 = d + fee[mode]\n if dist[next_city] > d1:\n dist[next_city] = d1\n heappush(que, (d1, next_city))\n return dist\n\nd1 = np.array(dijkstra(S, 0))\nd2 = np.array(dijkstra(T, 1))\nd1 += d2\n\nanswer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]\nprint('\\n'.join(answer.astype(str)))", "neg": "import sys\nsys.setrecursionlimit(10 ** 7)\n\nimport numpy as np\nfrom heapq import *\n\nN, M, S, T = map(int, input().split())\nINF = 10 ** 7\ngraph = [[] for _ in range(N+1)] # graph[0]\u306f\u4f7f\u308f\u306a\u3044\n\nfor i in range(M):\n u, v, a, b = map(int, input().split())\n graph[u].append((v, a, b))\n graph[v].append((u, a, b))\n\ndef dijkstra(start, mode):\n dist = [INF] * (N+1) # dist[0]\u4f7f\u308f\u306a\u3044\n dist[start] = 0\n que = [(0, start)]\n while que:\n d, p = heappop(que)\n # \u65e2\u306b\u5b89\u3044\u4ea4\u901a\u8cbb\u3067\u6765\u305f\u3053\u3068\u304c\u3042\u308b\u5834\u5408\n if dist[p] < d:\n continue\n for next_city, *fee in graph[p]:\n d1 = d + fee[mode]\n if dist[next_city] > d1:\n dist[next_city] = d1\n heappush(que, (d1, next_city))\n return dist\n\nd1 = np.array(dijkstra(S, 0))\nd2 = np.array(dijkstra(T, 1))\nd1 += d2\n\nanswer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]\nprint('\\n'.join(answer.astype(str)))", "jacc_sim": 1.0, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [437, 437], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u619819312", "n_user": "u619819312", "pos": "from heapq import heappush,heappop\nn,m,s,t=map(int,input().split())\na,b=[[]for i in range (n+1)],[[]for i in range(n+1)]\nfor i in range(m):\n p,q,r,g=(int(i) for i in input().split())\n a[p].append((q,r))\n a[q].append((p,r))\n b[p].append((q,g))\n b[q].append((p,g))\ndef f(x,r):\n p=[float(\"inf\")for i in range(n+1)]\n p[x],q=0,[[0,x]]\n while q:\n y,z=heappop(q)\n for i,j in r[z]:\n if p[i]>y+j:\n p[i]=y+j\n heappush(q,[p[i],i])\n return p\ns1,t1,p=f(s,a),f(t,b),[]\nfor i in range(1,n+1):\n p.append((s1[i]+t1[i],i))\np,e=sorted(p),0\nfor i in range(n):\n while p[e][1]<=i: e+=1\n print(10**15-p[e][0])", "neg": "from heapq import *\nimport numpy as np\nn,m,s,t=map(int,input().split())\na=[[]for i in range (n+1)]\nb=[[]for i in range(n+1)]\nfor i in range(m):\n p,q,r,g=map(int,input().split())\n a[p].append([q,r])\n a[q].append([p,r])\n b[p].append([q,g])\n b[q].append([p,g])\ndef f(x,r):\n p=[float(\"INF\")]*(n+1)\n p[x],q=0,[[0,x]]\n while q:\n y,z=heappop(q)\n for i in r[z]:\n if p[i[0]]>y+i[1]:\n p[i[0]]=y+i[0]\n heappush(q,[y+i[1],i[0]])\n return p[1:]\ns1,t1=f(s,a),f(t,b)\np=[]\nfor i in range(n):\n p.append([s1[i]+t1[i],i])\np,e=sorted(p),0\nfor i in range(n):\n while p[e][1]<=i: e+=1\n print(10**15-p[e][0])", "jacc_sim": 0.9032258064516129, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [342, 346], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u211160392", "n_user": "u211160392", "pos": "from collections import deque\nn,m,s,t = map(int,input().split())\nedgem = [[]for i in range(n)]\nedges = [[]for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n edgem[u-1].append([v-1,a])\n edgem[v-1].append([u-1,a])\n edges[u-1].append([v-1,b])\n edges[v-1].append([u-1,b])\n\ncostm = [float('inf')]*n\ncosts = [float('inf')]*n\ncostm[s-1],costs[t-1] = 0,0\n\nqueue = deque([s-1])\nwhile queue.__len__() > 0:\n p = queue.popleft()\n for a,b in edgem[p]:\n if costm[a] > costm[p] + b:\n costm[a] = costm[p] + b\n queue.append(a)\nqueue = deque([t-1])\nwhile queue.__len__() > 0:\n p = queue.popleft()\n for a,b in edges[p]:\n if costs[a] > costs[p] + b:\n costs[a] = costs[p] + b\n queue.append(a)\nans = [float('inf')]*n\nfor i in range(n):\n ans[i] = costm[i] + costs[i]\nfor i in range(n-1,0,-1):\n ans[i-1] = min(ans[i-1],ans[i])\nmoney = 10**15\nfor i in ans:\n print(money-i)", "neg": "from collections import deque\nn,m,s,t = map(int,input().split())\nedgem = [[]for i in range(n)]\nedges = [[]for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n edgem[u-1].append([v-1,a])\n edgem[v-1].append([u-1,a])\n edges[u-1].append([v-1,b])\n edges[v-1].append([u-1,b])\n\ncostm = [float('inf')]*n\ncosts = [float('inf')]*n\ncostm[s-1],costs[t-1] = 0,0\n\nqueue = deque([s-1])\nwhile queue != deque([]) > 0:\n p = queue.popleft()\n for a,b in edgem[p]:\n if costm[a] > costm[p] + b:\n costm[a] = costm[p] + b\n queue.append(a)\nqueue = deque([t-1])\nwhile queue != deque([]):\n p = queue.popleft()\n for a,b in edges[p]:\n if costs[a] > costs[p] + b:\n costs[a] = costs[p] + b\n queue.append(a)\nans = [float('inf')]*n\nfor i in range(n):\n ans[i] = costm[i] + costs[i]\nfor i in range(n-1,0,-1):\n ans[i-1] = min(ans[i-1],ans[i])\nmoney = 10**15\nfor i in ans:\n print(money-i)", "jacc_sim": 0.9636363636363636, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [429, 427], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\nimport numpy as np\nfrom heapq import heappush, heappop\n\nN,M,S,T = map(int,input().split())\ngraph = [[] for _ in range(N+1)]\nfor _ in range(M):\n u,v,a,b = map(int,input().split())\n graph[u].append((v,a,b))\n graph[v].append((u,a,b))\n\ndef dijkstra(start, mode):\n INF = 10 ** 15\n dist = [INF] * (N+1)\n dist[start] = 0\n q = [(0,start)]\n while q:\n d,v = heappop(q)\n if dist[v] < d:\n continue\n for w,*a in graph[v]:\n d1 = d + a[mode]\n if dist[w] > d1:\n dist[w] = d1\n heappush(q, (d1,w))\n return dist\n\nd1 = np.array(dijkstra(S,0))\nd2 = np.array(dijkstra(T,1))\n\nd1 += d2\nanswer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]\n\nprint(*answer, sep='\\n')", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\nimport numpy as np\nfrom heapq import heappush, heappop\n\nN,M,S,T = map(int,input().split())\ngraph = [[] for _ in range(N+1)]\nfor _ in range(M):\n u,v,a,b = map(int,input().split())\n graph[u].append((v,a,b))\n graph[v].append((u,a,b))\n\ndef dijkstra(start, mode):\n INF = 10 ** 15\n dist = [INF] * (N+1)\n dist[start] = 0\n q = [(0,start)]\n while q:\n d,v = heappop(q)\n if dist[v] < d:\n continue\n for w,*a in graph[v]:\n d1 = d + a[mode]\n if dist[w] > d1:\n dist[w] = d1\n heappush(q, (d1,w))\n return dist\n\nd1 = np.array(dijkstra(S,0))\nd2 = np.array(dijkstra(T,1))\n\nd1 += d2\nanswer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1]\n\nprint(*answer)", "jacc_sim": 0.9444444444444444, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [348, 341], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u729707098", "n_user": "u729707098", "pos": "from heapq import heappop,heappush\nn,m,s,t = (int(i) for i in input().split())\nx,y = [[] for i in range(n+1)],[[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = (int(i) for i in input().split())\n x[u].append((v,a))\n x[v].append((u,a))\n y[u].append((v,b))\n y[v].append((u,b))\ndef dijkstra(n,s,adj):\n\tdis = [float(\"inf\") for i in range(n+1)]\n\tdis[s],q = 0,[[0,s]]\n\twhile q:\n\t\tnum2,num = heappop(q)\n\t\tfor i,j in adj[num]:\n\t\t\tif dis[i]>num2+j:\n\t\t\t\tdis[i] = num2+j\n\t\t\t\theappush(q,[dis[i],i])\n\treturn dis\nX,Y,z = dijkstra(n,s,x),dijkstra(n,t,y),[]\nfor i in range(1,n+1): z.append((X[i]+Y[i],i))\nz,k = sorted(z),0\nfor i in range(n):\n while z[k][1]<=i: k+=1\n print(10**15-z[k][0])", "neg": "from heapq import heappop,heappush\nn,m,s,t = (int(i) for i in input().split())\nx,y = [[] for i in range(n+1)],[[] for i in range(n+1)]\nfor i in range(m):\n u,v,a,b = (int(i) for i in input().split())\n x[u].append((v,a))\n x[v].append((u,a))\n y[u].append((v,b))\n y[v].append((u,b))\ndef dijkstra(n,s,adj):\n\tdis = [float(\"inf\") for i in range(n+1)]\n\tdis[s],q = 0,[[0,s]]\n\twhile q:\n\t\tnum2,num = heappop(q)\n\t\tfor i,j in adj[num]:\n\t\t\tif dis[i]>num2+j:\n\t\t\t\tdis[i] = num2+j\n\t\t\t\theappush(q,[dis[i],i])\n\treturn dis\nX,Y,z = dijkstra(n,s,x),dijkstra(n,t,y),[]\nfor i in range(1,n+1): z.append((X[i]+Y[i],i))\nz,k = sorted(z),0\nfor i in range(n):\n while z[k][1]<=i: k+=1\n print(z[k][0])", "jacc_sim": 0.9333333333333333, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [366, 362], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u170201762", "n_user": "u170201762", "pos": "from heapq import *\n\nINF = 10**15\n\ndef djikstra(G,s,d):\n #d = [0]*V\n que = []\n d[s] = 0\n visited = [False] * V\n heappush(que,(0,s))\n while(len(que)!=0):\n c,v = heappop(que)\n if visited[v]:\n continue\n visited[v] = True\n for i in range(len(G[v])):\n e = G[v][i]\n if visited[e[0]]:\n continue\n if d[e[0]] > d[v] + e[1]:\n d[e[0]] = d[v] + e[1]\n heappush(que,(d[e[0]],e[0]))\n\n\nn,m,s,t = map(int,input().split())\nV = n\nGa = [[] for i in range(n)]\nGb = [[] for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n Ga[u-1].append((v-1,a))\n Ga[v-1].append((u-1,a))\n Gb[u-1].append((v-1,b))\n Gb[v-1].append((u-1,b))\n\nS = [INF]*V\nT = [INF]*V\ndjikstra(Ga,s-1,S)\ndjikstra(Gb,t-1,T)\nM = [0]*n\nfor i in range(n):\n M[i] = INF-S[i]-T[i]\nans = [0]*n\nans[n-1] = M[n-1]\nfor i in range(n-2,-1,-1):\n ans[i] = max(ans[i+1],M[i])\n\nfor i in range(n):\n print(ans[i])", "neg": "from heapq import *\n\nINF = 10**15\n\ndef djikstra(G,s,d):\n #d = [0]*V\n que = []\n d[s] = 0\n visited = [False] * V\n heappush(que,(0,s))\n while(len(que)!=0):\n c,v = heappop(que)\n if visited[v]:\n continue\n visited[v] = True\n for i in range(len(G[v])):\n e = G[v][i]\n if visited[e[0]]:\n continue\n if d[e[0]] > d[v] + e[1]:\n d[e[0]] = d[v] + e[1]\n heappush(que,(d[e[0]],e[0]))\n\n\nn,m,s,t = map(int,input().split())\nV = n\nGa = [[] for i in range(n)]\nGb = [[] for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n Ga[u-1].append((v-1,a))\n Ga[v-1].append((u-1,a))\n Gb[u-1].append((v-1,b))\n Gb[v-1].append((u-1,b))\n\nS = [INF]*V\nT = [INF]*V\ndjikstra(Ga,s-1,S)\ndjikstra(Gb,t-1,T)\nM = [0]*n\nfor i in range(n):\nM[i] = INF-S[i]-T[i]\nans = [0]*n\nans[n-1] = M[n-1]\nfor i in range(n-2,-1,-1):\n ans[i] = max(ans[i+1],M[i])\n\nfor i in range(n):\n print(ans[i])\n", "jacc_sim": 1.0, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [500, 500], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03305", "p_user": "u170201762", "n_user": "u170201762", "pos": "from heapq import *\nfrom numpy import array\nINF = 10**15\n\ndef djikstra(G,s,d):\n #d = [0]*V\n que = []\n d[s] = 0\n visited = [False] * V\n heappush(que,(0,s))\n while(len(que)!=0):\n c,v = heappop(que)\n if visited[v]:\n continue\n visited[v] = True\n for i in range(len(G[v])):\n e = G[v][i]\n if visited[e[0]]:\n continue\n if d[e[0]] > d[v] + e[1]:\n d[e[0]] = d[v] + e[1]\n heappush(que,(d[e[0]],e[0]))\n\n\nn,m,s,t = map(int,input().split())\nV = n\nGa = [[] for i in range(n)]\nGb = [[] for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n Ga[u-1].append((v-1,a))\n Ga[v-1].append((u-1,a))\n Gb[u-1].append((v-1,b))\n Gb[v-1].append((u-1,b))\n\nS = [INF]*V\nT = [INF]*V\ndjikstra(Ga,s-1,S)\ndjikstra(Gb,t-1,T)\n\nM = INF-(array(S)+array(T))\nans = [0]*n\nans[n-1] = M[n-1]\nfor i in range(n-2,-1,-1):\n ans[i] = max(ans[i+1],M[i])\n\nfor i in range(n):\n print(ans[i])\n", "neg": "from heapq import *\nfrom numpy import array,inf\n\n\ndef djikstra(s):\n que = []\n d = [inf]*V\n d[s] = 0\n visited = [False] * n\n heappush(que,(0,s))\n while(len(que)!=0):\n p = heappop(que)\n v = p[1]\n if visited[p[0]]:\n continue\n visited[p[0]] = True\n for i in range(len(G[v])):\n if visited[p[0]]:\n continue\n e = G[v][i]\n if d[e[0]] > d[v] + e[1]:\n d[e[0]] = d[v] + e[1]\n heappush(que,(d[e[0]],e[0]))\n return d\n\n\nn,m,s,t = map(int,input().split())\nV = n\nGa = [[] for i in range(n)]\nGb = [[] for i in range(n)]\nfor i in range(m):\n u,v,a,b = map(int,input().split())\n Ga[u-1].append((v-1,a))\n Ga[v-1].append((u-1,a))\n Gb[u-1].append((v-1,b))\n Gb[v-1].append((u-1,b))\n\nG = Ga\nS = djikstra(s-1)\nG = Gb\nT = djikstra(t-1)\n\nM = 10**15-(array(S)+array(T))\nans = [0]*n\nans[n-1] = M[n-1]\nfor i in range(n-2,-1,-1):\n ans[i] = max(ans[i+1],M[i])\n\nfor i in range(n):\n print(ans[i])\n", "jacc_sim": 0.9142857142857143, "nl": "Kenkoooo plans a trip in the Republic of Snuke, which has n cities and m trains. The cities are numbered 1 through n, and the i-th train connects City u_i and v_i bidirectionally. Train fares can be paid in yen or snuuk. Kenkoooo starts with 10^15 yen in City s and wants to reach City t with as much snuuk as possible. He can exchange yen for snuuk at any city, but each city's exchange office will close in subsequent years. The task is to find the maximum amount of snuuk Kenkoooo can have when reaching City t after i years. Constraints include the number of cities, trains, and specific rules for train connections and currency exchange. The input format includes n, m, s, t, followed by train details, and the output should display the maximum amount of snuuk for each year. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [487, 486], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03306", "p_user": "u144913062", "n_user": "u144913062", "pos": "from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nG = [[] for _ in range(n+1)]\nfor _ in range(m):\n u, v, s = map(int, input().split())\n G[u].append((v, s))\n G[v].append((u, s))\nval = [None] * (n+1)\nval[1] = (1, 0)\nqueue = deque([1])\nwhile queue:\n u = queue.popleft()\n for v, s in G[u]:\n if val[v]:\n continue\n val[v] = (-val[u][0], s - val[u][1])\n queue.append(v)\nma = float('inf')\nmi = 1\nx = -1\nfor u in range(1, n+1):\n if val[u][0] == -1:\n ma = min(ma, val[u][1] - 1)\n else:\n mi = max(mi, -val[u][1] + 1)\n for v, s in G[u]:\n if u > v:\n continue\n if val[u][0] + val[v][0] == 0:\n if val[u][1] + val[v][1] != s:\n print(0)\n exit()\n else:\n a = val[u][0] + val[v][0]\n b = s - (val[u][1] + val[v][1])\n if a < 0:\n b *= -1\n if b <= 0 or b % 2 == 1:\n print(0)\n exit()\n if x == -1:\n x = b // 2\n elif x != b // 2:\n print(0)\n exit()\nif x != -1:\n if mi <= x <= ma:\n print(1)\n else:\n print(0)\nelse:\n print(max(ma - mi + 1, 0))", "neg": "from collections import deque\nimport sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nG = [[] for _ in range(n+1)]\nfor _ in range(m):\n u, v, s = map(int, input().split())\n G[u].append((v, s))\n G[v].append((u, s))\nval = [None] * (n+1)\nval[1] = (1, 0)\nqueue = deque([1])\nwhile queue:\n u = queue.popleft()\n for v, s in G[u]:\n if val[v]:\n continue\n val[v] = (-val[u][0], s - val[u][1])\n queue.append(v)\nma = float('inf')\nmi = -float('inf')\nx = -1\nprint(val)\nfor u in range(1, n+1):\n if val[u][0] == -1:\n ma = min(ma, val[u][1] - 1)\n else:\n mi = max(mi, -val[u][1] + 1)\n for v, s in G[u]:\n if val[u][0] + val[v][0] == 0:\n if val[u][1] + val[v][1] != s:\n print(0)\n exit()\n else:\n a = val[u][0] + val[v][0]\n b = s - (val[u][1] + val[v][1])\n if b % a != 0:\n print(0)\n exit()\n c = b // a\n if c <= 0:\n print(0)\n exit()\n if x == -1:\n x = c\n elif x != c:\n print(0)\n exit()\nif x != -1:\n print(1)\nelse:\n print(max(ma - mi + 1, 0))", "jacc_sim": 0.9375, "nl": "You are given a simple connected graph with vertices numbered from 1 to n. Each edge connects two vertices and has a fixed integer value. Your task is to assign a positive integer to each vertex so that for every edge, the sum of the integers assigned to its two vertices equals the fixed integer value of the edge. Find the number of ways to assign these integers. The input consists of n, m, and m lines of u, v, and s values. Output the number of ways to satisfy the condition.", "before_after_length": [495, 478], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03312", "p_user": "u065446124", "n_user": "u065446124", "pos": "n=int(input())\nl=[0]+list(map(int,input().split()))\nfrom itertools import accumulate\nl=list(accumulate(l))\nfrom bisect import bisect, bisect_left, bisect_right\nans=10**15\nfor i in range(2,n-1):\n x=bisect_left(l,l[i]//2)\n p1=l[x]\n p2=l[x-1]\n if abs(l[i]-p1*2)>=abs(l[i]-p2*2):\n p=p2\n else:\n p=p1\n q=l[i]-p\n x=bisect_left(l,(l[n]-l[i])//2+l[i])\n r1=l[x]-l[i]\n r2=l[x-1]-l[i]\n if abs(l[n]-l[i]-r1*2)>=abs(l[n]-l[i]-r2*2):\n r=r2\n else:\n r=r1\n s=l[n]-l[i]-r\n ans=min(ans,max(p,q,r,s)-min(p,q,r,s))\nprint(ans)", "neg": "n=int(input())\nl=[0]+list(map(int,input().split()))\nfrom itertools import accumulate\nl=list(accumulate(l))\nfrom bisect import bisect, bisect_left, bisect_right\nans=10**15\nfor i in range(2,n-1):\n \tx=bisect_left(l,l[i]//2)\n p1=l[x]\n p2=l[x-1]\n if abs(l[i]-p1*2)>=abs(l[i]-p2*2):\n p=p2\n else:\n p=p1\n q=l[i]-p\n x=bisect_left(l,(l[n]-l[i])//2+l[i])\n r1=l[x]-l[i]\n r2=l[x-1]-l[i]\n if abs(l[n]-l[i]-r1*2)>=abs(l[n]-l[i]-r2*2):\n r=r2\n else:\n r=r1\n s=l[n]-l[i]-r\n ans=min(ans,max(p,q,r,s)-min(p,q,r,s))\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has an integer sequence A of length N. He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D, and E. The positions of the cuts can be freely chosen. Let P, Q, R, S be the sums of the elements in B, C, D, E, respectively. Snuke is happier when the absolute difference of the maximum and the minimum among P, Q, R, S is smaller. Find the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nConstraints:\n- 4 \u2264 N \u2264 2 \u00d7 10^5\n- 1 \u2264 A_i \u2264 10^9\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 ... A_N\n\nOutput:\nFind the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nSample Input 1:\n5\n3 2 4 1 2\n\nSample Output 1:\n2\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3, Q=2, R=4, S=1+2=3. Here, the maximum and the minimum among P, Q, R, S are 4 and 2, with the absolute difference of 2. We cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2:\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2:\n36\n\nSample Input 3:\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3:\n999999994", "before_after_length": [324, 325], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03312", "p_user": "u521699075", "n_user": "u521699075", "pos": "N = int(input())\nA = [int(_) for _ in input().split()]\n \nans = []\nt = []\nc = 0\nfor i in range(N):\n c += A[i]\n t.append(c)\n \nl = 0\nr = 0\n\nfor _ in range(1, N-1):\n while t[_] > t[l]+t[l+1]:\n l += 1\n while t[-1]+t[_] > t[r]+t[r+1]:\n r += 1\n n = [t[l], t[_]-t[l], t[r]-t[_], t[-1]-t[r]]\n ans.append(max(n)-min(n))\nprint(min(ans))", "neg": "N = int(input())\nA = [int(_) for _ in input().split()]\n \nans = []\nt = []\nc = 0\nfor i in range(N):\n c += A[i]\n t.append(c)\n \nl = 0\nr = 0\n\nfor _ in range(2, N-1):\n while t[_] > t[l]+t[l+1]:\n l += 1\n while t[-1]+t[_] > t[r]+t[r+1]:\n r += 1\n n = [t[l], t[_]-t[l], t[r]-t[_], t[-1]-t[r]]\n ans.append(max(n)-min(n))\n \nprint(min(ans))", "jacc_sim": 0.9714285714285714, "nl": "Snuke has an integer sequence A of length N. He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D, and E. The positions of the cuts can be freely chosen. Let P, Q, R, S be the sums of the elements in B, C, D, E, respectively. Snuke is happier when the absolute difference of the maximum and the minimum among P, Q, R, S is smaller. Find the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nConstraints:\n- 4 \u2264 N \u2264 2 \u00d7 10^5\n- 1 \u2264 A_i \u2264 10^9\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 ... A_N\n\nOutput:\nFind the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nSample Input 1:\n5\n3 2 4 1 2\n\nSample Output 1:\n2\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3, Q=2, R=4, S=1+2=3. Here, the maximum and the minimum among P, Q, R, S are 4 and 2, with the absolute difference of 2. We cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2:\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2:\n36\n\nSample Input 3:\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3:\n999999994", "before_after_length": [189, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03312", "p_user": "u310678820", "n_user": "u310678820", "pos": "from bisect import bisect_left\nN = int(input())\nA = list(map(int, input().split()))\nS1 = [A[0]]*N\nS2 = [A[-1]]*N\nfor i in range(1, N):\n S1[i] = S1[i-1]+A[i]\n S2[i] = S2[i-1]+A[N-i-1]\nans = S1[-1]\nfor i in range(1, N-2):\n s1 = S1[i]\n b = bisect_left(S1, s1/2)\n if abs(S1[b]-s1/2)>abs(s1/2-S1[b-1]):\n b-=1\n P, Q = S1[b], s1-S1[b]\n s2 = S2[N-i-2]\n c = bisect_left(S2, s2/2)\n if abs(S2[c]-s2/2)>abs(s2/2-S2[c-1]):\n c-=1\n R, S = S2[c], s2-S2[c]\n res = max(P, Q, R, S)-min(P, Q, R, S)\n ans = min(ans, res)\nprint(ans)", "neg": "from bisect import bisect_left\nN = int(input())\nA = list(map(int, input().split()))\nS1 = [A[0]]*N\nS2 = [A[-1]]*N\nfor i in range(1, N):\n S1[i] = S1[i-1]+A[i]\n S2[i] = S2[i-1]+A[N-i-1]\nans = S1[-1]\nfor i in range(1, N-2):\n s1 = S1[i]\n b = bisect_left(S1, s1/2)\n if abs(S1[b]-s1/2)>abs(s1/2-S1[b-1]):\n b-=1\n P, Q = S1[b], s1-S1[b]\n s2 = S2[N-i-2]\n c = bisect_left(S2, s2/2)\n if abs(S1[c]-s2/2)>abs(s2/2-S1[c-1]):\n c-=1\n R, S = S2[c], s2-S2[c]\n res = max(P, Q, R, S)-min(P, Q, R, S)\n ans = min(ans, res)\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has an integer sequence A of length N. He will make three cuts in A and divide it into four (non-empty) contiguous subsequences B, C, D, and E. The positions of the cuts can be freely chosen. Let P, Q, R, S be the sums of the elements in B, C, D, E, respectively. Snuke is happier when the absolute difference of the maximum and the minimum among P, Q, R, S is smaller. Find the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nConstraints:\n- 4 \u2264 N \u2264 2 \u00d7 10^5\n- 1 \u2264 A_i \u2264 10^9\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 ... A_N\n\nOutput:\nFind the minimum possible absolute difference of the maximum and the minimum among P, Q, R, S.\n\nSample Input 1:\n5\n3 2 4 1 2\n\nSample Output 1:\n2\nIf we divide A as B,C,D,E=(3),(2),(4),(1,2), then P=3, Q=2, R=4, S=1+2=3. Here, the maximum and the minimum among P, Q, R, S are 4 and 2, with the absolute difference of 2. We cannot make the absolute difference of the maximum and the minimum less than 2, so the answer is 2.\n\nSample Input 2:\n10\n10 71 84 33 6 47 23 25 52 64\n\nSample Output 2:\n36\n\nSample Input 3:\n7\n1 2 3 1000000000 4 5 6\n\nSample Output 3:\n999999994", "before_after_length": [330, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03313", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\ninput = sys.stdin.readline\nfrom heapq import heappushpop\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\n# B_x = max {A_y | y\\subset x}\n# \u3068\u601d\u3063\u305f\u304c\u30012\u5143\u305a\u3064\u6301\u3064\u5fc5\u8981\u304c\u3042\u308b\u3002\n# (\u5024\u3001\u4f55\u756a\u304b\u3089\u6765\u305f\u304b)\nB = []\nfor n,a in enumerate(A):\n arr = [(0,0),(a,n)]\n m = n\n while m:\n bit = m & (-m)\n (x,i),(y,j) = B[n-bit]\n if (x,i) != arr[-1]:\n heappushpop(arr,(x,i))\n if (y,j) != arr[-1]:\n heappushpop(arr,(y,j))\n m -= bit\n B.append(arr)\n\nanswer = [0]\nfor (x,i),(y,j) in B[1:]:\n z = answer[-1]\n if z < x + y:\n z = x + y\n answer.append(z)\nprint('\\n'.join(map(str,answer[1:])))\n\n", "neg": "import sys\ninput = sys.stdin.readline\nfrom heapq import heappushpop\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\n# B_x = max {A_y | y\\subset x}\n# \u3068\u601d\u3063\u305f\u304c\u30012\u5143\u305a\u3064\u6301\u3064\u5fc5\u8981\u304c\u3042\u308b\u3002\n# (\u5024\u3001\u4f55\u756a\u304b\u3089\u6765\u305f\u304b)\nB = []\nfor n,a in enumerate(A):\n arr = [(0,0),(a,n)]\n m = n\n while m:\n bit = m & (-m)\n (x,i),(y,j) = B[n-bit]\n heappushpop(arr,(x,i))\n heappushpop(arr,(y,j))\n m -= bit\n B.append(arr)\n\nanswer = [0]\nfor (x,i),(y,j) in B[1:]:\n z = answer[-1]\n if z < x + y:\n z = x + y\n answer.append(z)\nprint('\\n'.join(map(str,answer[1:])))\n\n", "jacc_sim": 0.9876543209876543, "nl": "You are given an integer sequence of length 2^N, indexed from 0. For each integer K (1 \u2264 K \u2264 2^N-1), find the maximum value of A_i + A_j, where 0 \u2264 i < j \u2264 2^N-1 and (i or j) \u2264 K. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i \u2264 10^9. Input format: N followed by A_0 to A_{2^N-1}. Output format: Print 2^N-1 lines, each containing the answer for K=i.", "before_after_length": [358, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03313", "p_user": "u214617707", "n_user": "u214617707", "pos": "N = int(input())\nA = list(map(int, input().split()))\nINF = float(\"inf\")\nB = [[A[i], -INF] for i in range(1 << N)]\nfor i in range(N):\n for j in range(1 << N):\n if j & (1 << i):\n tmp = B[j] + B[j ^ (1 << i)]\n tmp = sorted(tmp, reverse=True)\n B[j] = tmp[:2]\n\nans = -INF\nfor i in range(1, 1 << N):\n ans = max(ans, sum(B[i]))\n print(ans)\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\nINF = float(\"inf\")\nB = [[A[i], -INF] for i in range(1 << N)]\nfor i in range(N):\n for j in range(1 << N):\n if j & (1 << i):\n tmp = B[j] + B[j ^ (1 << i)]\n tmp = sorted(tmp, reverse=True)\n B[j] = tmp[:2]\n\nans = -INF\nfor i in range(1, 1 << N):\n ans = max(ans, sum(B[i]))\n print(sum(B[i]))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length 2^N, indexed from 0. For each integer K (1 \u2264 K \u2264 2^N-1), find the maximum value of A_i + A_j, where 0 \u2264 i < j \u2264 2^N-1 and (i or j) \u2264 K. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i \u2264 10^9. Input format: N followed by A_0 to A_{2^N-1}. Output format: Print 2^N-1 lines, each containing the answer for K=i.", "before_after_length": [156, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03313", "p_user": "u958766300", "n_user": "u958766300", "pos": "# -*- coding:utf-8 -*-\nn = int(input())\na = [int(i) for i in input().split()]\ndp = [[x, 0] for x in range(0, len(a))]\n \n \ndef ins(x, i):\n if x in dp[i]:\n return\n if dp[i][0] != x and a[dp[i][0]] < a[x]:\n dp[i][1] = dp[i][0]\n dp[i][0] = x\n elif dp[i][1] != x and a[dp[i][1]] < a[x]:\n dp[i][1] = x\n \n \ndef mix(i, j):\n ins(dp[i][0], j)\n ins(dp[i][1], j)\n \n \nfor i in range(0, len(a)):\n for j in range(0, n):\n if i & (1 << j) == 0:\n mix(i, i | (1 << j))\n \n \nans = 0\nfor i in range(1, len(a)):\n u = a[dp[i][0]]+a[dp[i][1]]\n ans = max(ans, u)\n print(ans)", "neg": "# -*- coding:utf-8 -*-\nn = int(input())\na = [int(i) for i in input().split()]\ndp = [[x, 0] for x in range(0, len(a))]\n\n\ndef ins(x, i):\n if dp[i][0] != x and a[dp[i][0]] < a[x]:\n dp[i][1] = dp[i][0]\n dp[i][0] = x\n elif dp[i][1] != x and a[dp[i][1]] < a[x]:\n dp[i][1] = x\n\n\ndef mix(i, j):\n ins(dp[i][0], j)\n ins(dp[i][1], j)\n\n\nfor i in range(0, len(a)):\n for j in range(0, n):\n if i & (1 << j) == 0:\n mix(i, i | (1 << j))\n\nans = 0\nfor i in range(1, len(a)):\n u = a[dp[i][0]]+a[dp[i][1]]\n ans = max(ans, u)\n print(ans)\n", "jacc_sim": 0.9777777777777777, "nl": "You are given an integer sequence of length 2^N, indexed from 0. For each integer K (1 \u2264 K \u2264 2^N-1), find the maximum value of A_i + A_j, where 0 \u2264 i < j \u2264 2^N-1 and (i or j) \u2264 K. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i \u2264 10^9. Input format: N followed by A_0 to A_{2^N-1}. Output format: Print 2^N-1 lines, each containing the answer for K=i.", "before_after_length": [308, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03313", "p_user": "u062147869", "n_user": "u062147869", "pos": "from copy import deepcopy\nN=int(input())\nA=[int(i) for i in input().split()]\n\ndef chmax(a,b):\n if a[0] 100*snuke:\n break\n po_snuke = func(i)\n if min_snuke > po_snuke:\n min_snuke = po_snuke\n next_snuke = i\n next_index = m\n print(next_snuke)\n snuke = next_snuke\n index = index + next_index + 1\n count += 1 ", "neg": "k = int(input())\n\ndef func(a):\n s = 0\n for i in str(a):\n s += int(i)\n return a/s\n\ncandidate_lst = []\nfor i in range(18):\n for j in range(1, 150):\n candidate_lst.append(int(str(j) + '9' * i))\ncandidate_lst = sorted(candidate_lst)\n\ncount = 0\nindex = -1\nsnuke = 1\nwhile count < k:\n min_snuke = 10**100\n for m, i in enumerate(candidate_lst[index+1:]):\n if i > 100*snuke:\n break\n po_snuke = func(i)\n if min_snuke > po_snuke:\n min_snuke = po_snuke\n next_snuke = i\n next_index = m\n print(next_snuke)\n snuke = next_snuke\n index = index + next_index + 2\n count += 1 ", "jacc_sim": 0.9454545454545454, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [262, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03318", "p_user": "u619458041", "n_user": "u619458041", "pos": "import sys\n\ndef S(n):\n return n / sum(map(int, str(n)))\n\n\ndef f(n):\n d = 0\n C = [n]\n while S(n) > (10**d / 9*(d+1)):\n c = 10**(d+1) * (n // 10**(d+1) + 1) - 1\n C.append(c)\n d += 1\n Smin = float('inf')\n res = 0\n for c in C:\n if S(c) < Smin:\n Smin = S(c)\n res = c \n return res\n\n\ndef main():\n input = sys.stdin.readline\n K = int(input())\n ans = 1\n for _ in range(K):\n print(ans)\n ans = f(ans+1)\n\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n\ndef S(n):\n return n / sum(map(int, str(n)))\n\n\ndef f(n):\n d = 0\n C = [n]\n while S(n) > (10**(d-1) / (9*d)):\n c = 10**(d+1) * (n // 10**(n+1) + 1) - 1\n C.append(c)\n \n Smin = float('inf')\n res = 0\n for c in C:\n if S(c) < Smin:\n res = c \n return res\n \ndef main():\n input = sys.stdin.readline\n K = int(input())\n ans = 1\n while _ in range(K):\n print(ans)\n ans = f(ans+1)\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [224, 214], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03318", "p_user": "u434208140", "n_user": "u434208140", "pos": "from math import log10 as l\ns=lambda f:sum(map(int,list(str(f))))\np=lambda a,j:(a//10**(j+1)+1)*10**(j+1)-1\nn=int(input())\na=1\nfor i in range(n):\n print(a)\n if(a<9):\n a+=1\n continue\n a+=1\n k=[p(a,j) for j in range(int(l(a)))]\n o=[p(a,j)/s(p(a,j)) for j in range(int(l(a)))]\n a=k[o.index(min(o))]", "neg": "from math import log10 as l\ns=lambda f:sum(map(int,list(str(f))))\np=lambda a,j:(a//10**(j+1)+1)*10**(j+1)-1\nn=int(input())\na=1\nfor i in range(n):\n print(a)\n if(a<10):\n a+=1\n continue\n a+=1\n k=[p(a,j) for j in range(int(l(a)))]\n o=[p(a,j)/s(p(a,j)) for j in range(int(l(a)))]\n a=k[o.index(min(o))]", "jacc_sim": 0.9782608695652174, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [169, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03318", "p_user": "u236127431", "n_user": "u236127431", "pos": "import math\nK=int(input())\nk=2\nm=0\ndef D(x):\n s=str(x)\n array=list(map(int,list(s)))\n return sum(array)\nN=1\nS=1\na=0\nprint(1)\nwhile k<=K:\n N+=10**a\n S=D(N)\n if a 0:\n if step < snuke/sum(map(int, str(snuke))):\n snuke += 9 * step\n step *= 10\n else:\n print(snuke)\n snuke += step\n K -= 1", "neg": "import sys \n\nK = int(input())\n\nif K <= 0:\n sys.exit(0)\n\nstep = 1 \nsnuke = 1 \n\nwhile K >= 0:\n if step < snuke/sum(map(int, str(snuke))):\n snuke += 9 * step\n step *= 10\n else:\n print(snuke)\n snuke += step\n K -= 1", "jacc_sim": 1.0, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [104, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03318", "p_user": "u631277801", "n_user": "u631277801", "pos": "MAX = 10**15\n\ndef find_next_n(n):\n cand = []\n n_str = str(n)\n n_list = list(n_str)\n for i in range(1,len(str(n))+1):\n n_list[-i] = '9'\n cand.append(int(\"\".join(n_list)))\n cand_result = [num/snuke(num) for num in cand]\n min_idx = cand_result.index(min(cand_result))\n\n return cand[min_idx]\n \n \ndef snuke(num):\n ans = 0\n while num//10 != 0:\n ans += num%10\n num = num//10\n return ans + num\n\ndef main():\n K = int(input())\n if K<10:\n for i in range(1,K+1):\n print(i)\n else:\n n = 10\n for i in range(1,n):\n print(i)\n for i in range(10,K+1):\n ans = find_next_n(n)\n print(ans)\n n = ans+1\n \n if n>MAX:\n break\n \n \nif __name__ == \"__main__\":\n main()", "neg": "MAX = 10**15+1\n\ndef find_next_n(n):\n cand = []\n n_str = str(n)\n n_list = list(n_str)\n for i in range(1,len(str(n))+1):\n n_list[-i] = '9'\n cand.append(int(\"\".join(n_list)))\n cand_result = [num/snuke(num) for num in cand]\n min_idx = cand_result.index(min(cand_result))\n\n return cand[min_idx]\n \n \ndef snuke(num):\n ans = 0\n while num//10 != 0:\n ans += num%10\n num = num//10\n return ans + num\n\ndef main():\n K = int(input())\n if K<10:\n for i in range(1,K+1):\n print(i)\n else:\n n = 10\n for i in range(K):\n print(i)\n for i in range(10,K+1):\n ans = find_next_n(n)\n print(ans)\n n = ans+i\n \n if n>MAX:\n break\n \n \nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [316, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03318", "p_user": "u517152997", "n_user": "u517152997", "pos": "# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\nfrom operator import itemgetter\n\nk =int(input())\nnmax=0\ns = []\nfor i in range(1,200):\n for j in range(14):\n p = i\n for ii in range(j):\n p=p*10+9\n q = i // 100 + (i // 10) % 10 + i % 10 + 9*j\n r = p / q\n\n s.append((p,q,r))\n\ns= sorted( s, key=itemgetter(2) )\n#print(s)\nnum=0\nfor a in s :\n if a[0] > nmax:\n nmax = a[0]\n print(nmax)\n num += 1\n if num >= k :\n break \n \n", "neg": "# -*- coding: utf-8 -*-\n# \nimport math\nimport sys\nimport itertools\nimport numpy as np\nfrom operator import itemgetter\n\nk =int(input())\nnmax=0\ns = []\nfor i in range(1,200):\n for j in range(14):\n p = i\n for ii in range(j):\n p=p*10+9\n q = i // 100 + (i // 10) % 10 + i % 10 + 9*j\n r = p / q\n\n s.append((p,q,r))\n\ns= sorted( s, key=itemgetter(2) )\nprint(s)\nnum=0\nfor a in s :\n if a[0] > nmax:\n nmax = a[0]\n print(nmax)\n num += 1\n if num >= k :\n break \n \n", "jacc_sim": 1.0, "nl": "You are given a problem to find the smallest \"Snuke numbers.\" These are defined as integers where, for all positive integers m greater than n, the ratio of n to the sum of its digits is less than or equal to the ratio of m to the sum of its digits. Your task is to list the K smallest Snuke numbers, where K is an input integer. The constraints are that K is at least 1 and the K-th smallest Snuke number is not greater than 10^15. The input is given in the format of a single integer K, and the output should be K lines, each containing the corresponding smallest Snuke number. For example, given an input of 10, the output should be the first 10 smallest Snuke numbers.", "before_after_length": [213, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03321", "p_user": "u884982181", "n_user": "u884982181", "pos": "import sys\nsys.setrecursionlimit(10**7)\nn,m = map(int,input().split())\nG = [[1]*n for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n a -=1;b-=1\n G[a][b] = G[b][a] = 0\ncolors = [-1 for i in range(n)]\npossible = True\nni = []\ndef dfs(x,y):\n colors[x] = y\n k[y] += 1\n for l in range(n):\n if l == x or G[x][l] == 0:\n continue\n if colors[l] == -1:\n dfs(l,1-y)\n elif colors[l] != 1-y:\n global possible\n possible = False\nfor i in range(n):\n k = [0,0]\n if colors[i] != -1:\n continue\n dfs(i,0)\n ni.append([k[0],k[1]])\nif possible == False:\n print(-1)\n exit()\ndp =[0]*701\ndp[0] = 1\nfor i in ni:\n for j in range(700,-1,-1):\n if dp[j]:\n dp[j] = 0\n dp[j+i[0]] = 1\n dp[j+i[1]] = 1\nans = float(\"inf\")\nfor i in range(0,701):\n if dp[i]:\n tmp = (n-i)*(n-i-1)//2 + i*(i-1)//2\n ans = min(tmp,ans)\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10**7)\nn,m = map(int,input().split())\nG = [[1]*n for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n a -=1;b-=1\n G[a][b] = G[b][a] = 0\ncolors = [-1 for i in range(n)]\npossible = True\nni = []\ndef dfs(x,y):\n colors[x] = y\n k[y] += 1\n for l in range(n):\n if l == x or G[x][l] == 0:\n continue\n if colors[l] == -1:\n dfs(l,1-y)\n elif colors[l] != 1-y:\n possible = False\nfor i in range(n):\n k = [0,0]\n if colors[i] != -1:\n continue\n dfs(i,0)\n ni.append([k[0],k[1]])\nif possible == False:\n print(-1)\n exit()\ndp =[0]*701\ndp[0] = 1\nfor i in ni:\n for j in range(700,-1,-1):\n if dp[j]:\n dp[j+i[0]] = 1\n dp[j+i[1]] = 1\nans = float(\"inf\")\nfor i in range(1,701):\n if dp[i]:\n tmp = (n-i)*(n-i-1)//2 + i*(i-1)//2\n ans = min(tmp,ans)\nprint(ans)", "jacc_sim": 0.984375, "nl": "In the State of Takahashi in AtCoderian Federation, there are N cities, numbered 1, 2, ..., N. M bidirectional roads connect these cities. The i-th road connects City A_i and City B_i. Every road connects two distinct cities. Also, for any two cities, there is at most one road that directly connects them.\n\nOne day, it was decided that the State of Takahashi would be divided into two states, Taka and Hashi. After the division, each city in Takahashi would belong to either Taka or Hashi. It is acceptable for all the cities to belong to Taka, or for all the cities to belong Hashi. Here, the following condition should be satisfied:\n\nAny two cities in the same state, Taka or Hashi, are directly connected by a road.\n\nFind the minimum possible number of roads whose endpoint cities belong to the same state. If it is impossible to divide the cities into Taka and Hashi so that the condition is satisfied, print -1.\n\nConstraints:\n2 \u2264 N \u2264 700\n0 \u2264 M \u2264 N(N-1)/2\n1 \u2264 A_i \u2264 N\n1 \u2264 B_i \u2264 N\nA_i \u2260 B_i\nIf i \u2260 j, at least one of the following holds: A_i \u2260 A_j and B_i \u2260 B_j.\nIf i \u2260 j, at least one of the following holds: A_i \u2260 B_j and B_i \u2260 A_j.\n\nInput:\nN M\nA_1 B_1\nA_2 B_2\n...\nA_M B_M\n\nOutput:\nPrint the answer.", "before_after_length": [415, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u222668979", "n_user": "u222668979", "pos": "from itertools import permutations\n\nn, c = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(c)]\ncmat = [list(map(int, input().split())) for _ in range(n)]\n\ndcnt = [[0] * c for _ in range(3)]\nfor i in range(n):\n for j in range(n):\n mod = (i + j) % 3\n dcnt[mod][cmat[i][j] - 1] += 1\n\nans = 10 ** 9\nfor color in permutations(range(c), 3):\n tmp = 0\n for tgt, cnt in zip(color, dcnt):\n tmp += sum(d[i][tgt] * cnt[i] for i in range(c))\n ans = min(ans, tmp)\nprint(ans)\n", "neg": "from itertools import permutations\n\nn, c = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(c)]\ncmat = [list(map(int, input().split())) for _ in range(n)]\n\ndcnt = [[0] * c for _ in range(3)]\nfor i in range(n):\n for j in range(n):\n mod = (i + j) % 3\n dcnt[mod][c[i][j] - 1] += 1\n\nans = 10 ** 9\nfor color in permutations(range(c), 3):\n tmp = 0\n for tgt, cnt in zip(color, dcnt):\n tmp += sum(d[i][tgt] * cnt[i] for i in range(c))\n ans = min(ans, tmp)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [205, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u070201429", "n_user": "u070201429", "pos": "def main():\n from sys import stdin\n def input():\n return stdin.readline().strip()\n \n n, c = map(int, input().split())\n d = [list(map(int, input().split())) for _ in range(c)]\n\n '''\n # if I can change the color of the same square many times\n # Warshall-Floyd algorithm\n for k in range(c):\n for i in range(c):\n for j in range(c):\n if d[i][j] > d[i][k] + d[k][j]:\n d[i][j] = d[i][k] + d[k][j]\n '''\n\n color = [list(map(int, input().split())) for _ in range(n)]\n\n counters = [[0] * c for _ in range(3)]\n for i in range(n):\n for j in range(n):\n counters[(i+j) % 3][color[i][j] - 1] += 1\n \n # full search\n cost = []\n for group in counters:\n l = []\n # from j to i\n for i in range(c):\n num = 0\n for j in range(c):\n num += d[j][i] * group[j]\n l.append((num, i))\n l.sort()\n cost.append(l[:3])\n\n ans = 10 ** 9\n for i in range(3):\n for j in range(3):\n for k in range(3):\n if cost[0][i][1] != cost[1][j][1] and cost[1][j][1] != cost[2][k][1] and cost[2][k][1] != cost[0][i][1]:\n if ans > cost[0][i][0] + cost[1][j][0] + cost[2][k][0]:\n ans = cost[0][i][0] + cost[1][j][0] + cost[2][k][0]\n \n print(ans)\n\nmain()", "neg": "def main():\n from sys import stdin\n def input():\n return stdin.readline().strip()\n \n n, c = map(int, input().split())\n d = [list(map(int, input().split())) for _ in range(c)]\n\n \n # if I can change the color of the same square many times\n # Warshall-Floyd algorithm\n for k in range(c):\n for i in range(c):\n for j in range(c):\n if d[i][j] > d[i] + d[j]:\n d[i][j] = d[i][j]\n \n\n color = [list(map(int, input().split())) for _ in range(n)]\n\n counters = [[0] * c for _ in range(3)]\n for i in range(n):\n for j in range(n):\n counters[(i+j) % 3][color[i][j] - 1] += 1\n \n # full search\n cost = []\n for group in counters:\n l = []\n for i in range(c):\n num = 0\n for j in range(c):\n num += d[j][i] * group[j]\n l.append((num, i))\n l.sort()\n cost.append(l[c-3:])\n\n ans = 10 ** 9\n for i in range(3):\n for j in range(3):\n for k in range(3):\n if cost[0][i][1] != cost[1][j][1] and cost[1][j][1] != cost[2][k][1] and cost[2][k][1] != cost[0][i][1]:\n if ans > cost[0][i][0] + cost[1][j][0] + cost[2][k][0]:\n ans = cost[0][i][0] + cost[1][j][0] + cost[2][k][0]\n \n print(ans)\n\nmain()", "jacc_sim": 0.9726027397260274, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [508, 491], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u225388820", "n_user": "u225388820", "pos": "from itertools import permutations\nn,C=map(int,input().split())\nd=[list(map(int,input().split())) for _ in range(C)]\nc=[list(map(int,input().split())) for _ in range(n)]\na=[[0]*C for _ in range(3)]\nfor i in range(n):\n\tfor j in range(n):\n\t\ta[(i+j)%3][c[i][j]-1]+=1\nans=10**9\nfor v in permutations(range(C),3):\n\ttmp=0\n\tfor i in range(3):\n\t\tfor j in range(C):\n\t\t\ttmp+=a[i][j]*d[j][v[i]]\n\tans=min(ans,tmp)\nprint(ans)", "neg": "from itertools import combinations\nn,c=map(int,input().split())\nd=[list(map(int,input().split())) for _ in range(c)]\nc=[list(map(int,input().split())) for _ in range(n)]\na=[[0]*c for _ in range(3)]\nfor i in range(n):\n\tfor j in range(n):\n\t\ta[(i+j)%3][c[i][j]-1]+=1\nans=10**9\nfor v in combinations(c,3):\n\ttmp=0\n\tfor i in range(3):\n\t\tfor j in range(30):\n\t\t\ttmp+=a[i][j]*c[j][v[i]]\n\tans=min(ans,tmp)\nprint(ans)", "jacc_sim": 0.9090909090909091, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [191, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u873915460", "n_user": "u873915460", "pos": "N,C=map(int,input().split())\nD=[list(map(int,input().split())) for i in range(C)]\nA=[list(map(int,input().split())) for i in range(N)]\nX=[[0]*C for i in range(3)]\nfor c in range(C):\n for i in range(N):\n for j in range(N):\n X[(i+j)%3][c]+=D[A[i][j]-1][c]\nP=10**20\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n if len(set([i,j,k]))==3:\n P=min(P,X[0][i]+X[1][j]+X[2][k])\nprint(P)", "neg": "N,C=map(int,input().split())\nD=[list(map(int,input().split())) for i in range(C)]\nA=[list(map(int,input().split())) for i in range(N)]\nX=[[0]*C for i in range(3)]\nfor c in range(C):\n for i in range(N):\n for j in range(N):\n X[(i+j)%3][c]+=D[A[i][j]][c]\nP=10**20\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n if len(set([i,j,k]))==3:\n P=min(P,X[0][i]+X[1][j]+X[2][k])\nprint(P)", "jacc_sim": 0.975609756097561, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [201, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u441575327", "n_user": "u441575327", "pos": "N,C = list(map(int,input().split()))\n\ndiscomforts = [[0]*(N+1)]\nfor _ in range(C):\n row = [0]\n row.extend(list(map(int,input().split())))\n discomforts.append(row)\ngrid = [[0]*(N+1)]\nfor _ in range(N):\n row = [0]\n row.extend(list(map(int,input().split())))\n grid.append(row)\n\ncolor_counts = [[0]*(C+1) for i in range(3)]\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n color_counts[(i+j)%3][grid[i][j]] += 1\n\nans = float('inf')\nfor c0 in range(1,C+1):\n for c1 in range(1,C+1):\n for c2 in range(1,C+1):\n if c0 != c1 and c1 != c2 and c2 != c0:\n total = 0\n for i in range(1,C+1):\n total += discomforts[i][c0]*color_counts[0][i]\n total += discomforts[i][c1]*color_counts[1][i]\n total += discomforts[i][c2]*color_counts[2][i]\n ans = min(ans,total)\nprint(ans)", "neg": "N,C = list(map(int,input().split()))\n\ndiscomforts = [[0]*(N+1)]\nfor _ in range(C):\n discomforts.append([0,*map(int,input().split())])\nprint(discomforts)\ngrid = [[0]*(N+1)]\nfor _ in range(N):\n grid.append([0,*map(int,input().split())])\n\ncolor_counts = [[0]*(C+1) for i in range(3)]\n\nfor i in range(1,N+1):\n for j in range(1,N+1):\n color_counts[(i+j)%3][grid[i][j]] += 1\n\nans = float('inf')\nfor c0 in range(1,C+1):\n for c1 in range(1,C+1):\n for c2 in range(1,C+1):\n if c0 != c1 and c1 != c2 and c2 != c0:\n total = 0\n for i in range(1,C+1):\n total += discomforts[i][c0]*color_counts[0][i]\n total += discomforts[i][c1]*color_counts[1][i]\n total += discomforts[i][c2]*color_counts[2][i]\n ans = min(ans,total)\nprint(ans)", "jacc_sim": 0.9574468085106383, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [362, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u338824669", "n_user": "u338824669", "pos": "from collections import defaultdict\n\nN,C=map(int,input().split())\nD=[list(map(int,input().split())) for _ in range(C)]\ngrid=[list(map(int,input().split())) for _ in range(N)]\n\nmod_0=defaultdict(int)\nmod_1=defaultdict(int)\nmod_2=defaultdict(int)\n\nfor i in range(N):\n for j in range(N):\n n=(i+j+2)%3\n if n==0:\n mod_0[grid[i][j]]+=1\n elif n==1:\n mod_1[grid[i][j]]+=1\n else:\n mod_2[grid[i][j]]+=1\n\nans=float(\"inf\")\nfor i in range(C):\n for j in range(C):\n if i==j:\n continue\n for k in range(C):\n if k in [i,j]:\n continue\n\n total=0\n for prev,cnt in mod_0.items():\n total+=D[prev-1][i]*cnt\n for prev,cnt in mod_1.items():\n total+=D[prev-1][j]*cnt\n for prev,cnt in mod_2.items():\n total+=D[prev-1][k]*cnt\n \n ans=min(ans,total)\nprint(ans)", "neg": "from collections import defaultdict\n\nN,C=map(int,input().split())\nD=[list(map(int,input().split())) for _ in range(C)]\ngrid=[list(map(int,input().split())) for _ in range(N)]\n\nmod_0=defaultdict(int)\nmod_1=defaultdict(int)\nmod_2=defaultdict(int)\n\nfor i in range(N):\n for j in range(N):\n n=(i+j+2)%3\n if n==0:\n mod_0[grid[i][j]]+=1\n elif n==1:\n mod_1[grid[i][j]]+=1\n else:\n mod_2[grid[i][j]]+=1\n\nans=float(\"inf\")\nfor i in range(C):\n for j in range(C):\n if i==j:\n continue\n for k in range(C):\n if k in [i,j]:\n continue\n\n total\n for prev,cnt in mod_0.items():\n total+=D[prev-1][i]*cnt\n for prev,cnt in mod_1.items():\n total+=D[prev-1][j]*cnt\n for prev,cnt in mod_2.items():\n total+=D[prev-1][k]*cnt\n \n ans=min(ans,total)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [345, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u609061751", "n_user": "u609061751", "pos": "import sys\ninput = sys.stdin.readline\n\nn, c = [int(x) for x in input().split()]\n\nd_list = [[int(x) for x in input().split()] for _ in range(c)]\nc_ = [[int(x) for x in input().split()] for _ in range(n)]\n\nmod_0 = [0] * c\nmod_1 = [0] * c\nmod_2 = [0] * c\n\nfor i in range(n):\n for j in range(n):\n if (i + j) % 3 == 0:\n m = mod_0\n elif (i + j) % 3 == 1:\n m = mod_1\n else:\n m = mod_2\n for k in range(c):\n m[k] += d_list[c_[i][j] - 1][k]\n\nans = 10 ** 18\n\nfor i in range(c):\n for j in range(i + 1, c):\n for k in range(j + 1, c):\n a = mod_0[i] + mod_1[j] + mod_2[k]\n b = mod_0[i] + mod_1[k] + mod_2[j]\n c__ = mod_0[j] + mod_1[i] + mod_2[k]\n d = mod_0[j] + mod_1[k] + mod_2[i]\n e = mod_0[k] + mod_1[i] + mod_2[j]\n f = mod_0[k] + mod_1[j] + mod_2[i]\n ans = min(ans, a, b, c__, d, e, f)\n\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\n\nn, c = [int(x) for x in input().split()]\n\nd_list = [[int(x) for x in input().split()] for _ in range(c)]\nc_ = [[int(x) for x in input().split()] for _ in range(n)]\n\nmod_0 = [0] * c\nmod_1 = [0] * c\nmod_2 = [0] * c\n\nfor i in range(n):\n for j in range(n):\n if (i + j) % 3 == 0:\n m = mod_0\n elif (i + j) % 3 == 1:\n m = mod_1\n else:\n m = mod_2\n for k in range(c):\n m[k] += d_list[c_[i][j] - 1][k]\n\nans = 10 ** 18\nprint(c)\nfor i in range(c):\n for j in range(i + 1, c):\n for k in range(j + 1, c):\n print(i, j, k)\n a = mod_0[i] + mod_1[j] + mod_2[k]\n b = mod_0[i] + mod_1[k] + mod_2[j]\n c__ = mod_0[j] + mod_1[i] + mod_2[k]\n d = mod_0[j] + mod_1[k] + mod_2[i]\n e = mod_0[k] + mod_1[i] + mod_2[j]\n f = mod_0[k] + mod_1[j] + mod_2[i]\n ans = min(ans, a, b, c__, d, e, f)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [426, 440], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u167988719", "n_user": "u167988719", "pos": "from collections import Counter\nfrom itertools import permutations\n\nN, C = map(int, input().split())\nD = [[int(x) for x in input().split()] for _ in range(C)]\n\ncnt = [Counter() for _ in range(3)]\n\nfor i in range(N):\n c = [int(x)-1 for x in input().split()]\n for j in range(3):\n cnt[j].update(c[(3-(i+2)+j)%3::3])\n\nans = 1000*500*500+5\nfor p in permutations(range(C), 3):\n s = 0\n for j in range(3):\n for k, v in cnt[j].items():\n s += D[k][p[j]] * v\n ans = min(ans, s)\n\nprint(ans)", "neg": "from collections import Counter\nfrom itertools import permutations\n\ndef main():\n N, C = map(int, input().split())\n D = [[int(x) for x in input().split()] for _ in range(C)]\n\n cnt = [Counter() for _ in range(3)]\n\n for i in range(N):\n c = [int(x)-1 for x in input().split()]\n for j in range(3):\n cnt[j].update(c[(3-(i+2)+j)%3::3])\n\n ans = 1000*500*500+5\n for p in permutations(range(C), 3):\n s = sum(D[k][p[j]] * v for k, v in cnt[j].items() for j in range(3))\n ans = min(ans, s)\n\n print(ans)\n\nmain()", "jacc_sim": 0.9245283018867925, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [201, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u518042385", "n_user": "u518042385", "pos": "n,c=map(int,input().split())\nd=[]\nfor i in range(c):\n d.append(list(map(int,input().split())))\ncol=[]\nfor i in range(n):\n col.append(list(map(int,input().split())))\nlc1=[]\nlc2=[]\nlc3=[]\nfor i in range(c):\n ccount1=0\n ccount2=0\n ccount3=0\n for j in range(n):\n for k in range(n):\n if (j+k)%3==0:\n ccount1+=d[col[j][k]-1][i]\n elif (j+k)%3==1:\n ccount2+=d[col[j][k]-1][i]\n else:\n ccount3+=d[col[j][k]-1][i]\n lc1.append(ccount1)\n lc2.append(ccount2)\n lc3.append(ccount3)\nmin=10**10\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i==j or j==k or i==k:\n pass\n else:\n if min>lc1[i]+lc2[j]+lc3[k]:\n min=lc1[i]+lc2[j]+lc3[k]\nprint(min)\n", "neg": "n,c=map(int,input().split())\nd=[]\nfor i in range(c):\n d.append(list(map(int,input().split())))\ncol=[]\nfor i in range(n):\n col.append(list(map(int,input().split())))\nlc1=[]\nlc2=[]\nlc3=[]\nfor i in range(c):\n ccount1=0\n ccount2=0\n ccount3=0\n for j in range(n):\n for k in range(n):\n if (j+k)%3==0:\n ccount1+=d[col[j][k]][i]\n elif (j+k)%3==1:\n ccount2+=d[col[j][k]][i]\n else:\n ccount3+=d[col[j][k]][i]\n lc1.append(ccount1)\n lc2.append(ccount2)\n lc3.append(ccount3)\nmin=10**10\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i==j or j==k or i==k:\n pass\n else:\n if min>lc1[i]+lc2[j]+lc3[k]:\n min=lc1[i]+lc2[j]+lc3[k]\nprint(min)", "jacc_sim": 0.9782608695652174, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [351, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u223646582", "n_user": "u223646582", "pos": "from collections import defaultdict\nN, C = map(int, input().split())\n\nD = [tuple(map(int, input().split())) for _ in range(C)]\n\nd = [defaultdict(int) for i in range(3)]\n\n\nfor i in range(N):\n c = [int(x) for x in input().split()]\n for j in range(N):\n for k in range(C):\n d[(i+j) % 3][k] += D[c[j]-1][k]\n# print(d)\n\nans = 10**9\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n if i != j and j != k and k != i:\n ans = min(ans, d[0][i]+d[1][j]+d[2][k])\n\nprint(ans)\n", "neg": "from collections import defaultdict\nN, C = map(int, input().split())\n\nD = [tuple(map(int, input().split())) for _ in range(C)]\n\nd = [defaultdict(int) for i in range(3)]\n\n\nfor i in range(N):\n c = [int(x) for x in input().split()]\n for j in range(N):\n for k in range(C):\n d[(i+j) % 3][k] += D[c[j]-1][k]\nprint(d)\n\nans = 10**9\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n if i != j and j != k and k != i:\n ans = min(ans, d[0][i]+d[1][j]+d[2][k])\n\nprint(ans)\n", "jacc_sim": 0.9787234042553191, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [215, 214], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u073852194", "n_user": "u073852194", "pos": "n,c = map(int,input().split())\nD = [list(map(int,input().split())) for _ in range(c)]\nC = [list(map(int,input().split())) for _ in range(n)]\n\ncolor_count = [[0]*c for i in range(3)]\nfor i in range(n):\n for j in range(n):\n color_count[(i+j)%3][C[i][j]-1] += 1\n\nmin_wrongness = 10**9\n\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i!=j and j!=k and k!=i:\n wrongness = 0\n for l in range(3):\n for m in range(c):\n if l == 0:\n wrongness += D[m][i]*color_count[l][m]\n elif l == 1:\n wrongness += D[m][j]*color_count[l][m]\n else:\n wrongness += D[m][k]*color_count[l][m]\n min_wrongness = min(min_wrongness,wrongness)\n \nprint(min_wrongness)", "neg": "n,c = map(int,input().split())\nD = [list(map(int,input().split())) for _ in range(c)]\nC = [list(map(int,input().split())) for _ in range(n)]\n\ncolor_count = [[0]*c for i in range(3)]\nfor i in range(n):\n for j in range(n):\n color_count[(i+j)%3][C[i][j]-1] += 1\n\nprint(color_count)\n\nmin_wrongness = 10**9\n\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i!=j and j!=k and k!=i:\n wrongness = 0\n for l in range(3):\n for m in range(c):\n if l == 0:\n wrongness += D[m][i]*color_count[l][m]\n elif l == 1:\n wrongness += D[m][j]*color_count[l][m]\n else:\n wrongness += D[m][k]*color_count[l][m]\n min_wrongness = min(min_wrongness,wrongness)\n \nprint(min_wrongness)", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [296, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u017810624", "n_user": "u970899068", "pos": "import itertools\nn,c=map(int,input().split())\nld=[list(map(int,input().split())) for i in range(c)]\nlc=[list(map(int,input().split())) for i in range(n)]\nct=[[0 for i in range(c)] for i in range(3)]\nfor i in range(n):\n for j in range(n):\n ct[(i+j+2)%3][lc[i][j]-1]+=1\nL=list(itertools.permutations([i for i in range(c)],3))\nans=[]\nfor i in range(len(L)):\n ct2=0\n for j in range(3):\n for k in range(c):\n ct2+=ld[k][L[i][j]]*ct[j][k]\n ans.append(ct2)\nprint(min(ans))", "neg": "import itertools\nn,c=map(int,input().split())\nld=[list(map(int,input().split())) for i in range(c)]\nlc=[list(map(int,input().split())) for i in range(n)]\nct=[[0 for i in range(c)] for i in range(3)]\nfor i in range(n):\n for j in range(n):\n ct[(i+j+2)%3][lc[i][j]-1]+=1\nL=list(itertools.permutations([i for i in range(c)],3))\nprint(L)\nans=[]\nfor i in range(len(L)):\n ct2=0\n for j in range(3):\n for k in range(c):\n ct2+=ld[k][L[i][j]]*ct[j][k]\n ans.append(ct2)\nprint(min(ans))", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [218, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u176645218", "n_user": "u176645218", "pos": "import itertools\nN,C = map(int,input().split(' '))\nD = [list(map(int,input().split(' '))) for i in [0]*C]\nc = [list(map(int,input().split(' '))) for i in [0]*N]\n\n\nl = [[],[],[]]\nn = 0\nfor i in range(N):\n\tfor j in range(i+1):\n\t\tl[n].append(c[i-j][j])\n\tn = (n+1) % 3\nfor i in range(N-1):\n\tfor j in range(N-i-1):\n\t\tl[n].append(c[i+j+1][N-j-1])\n\tn = (n+1) % 3\n\nd1,d2,d3 = [[sum([D[j-1][i] for j in l[n]]) for i in range(C)] for n in range(3)]\n\nans = 1000*500*500\ncolors = list(range(C))\nfor c1,c2,c3 in itertools.permutations(colors,3):\n\tans = min(ans,d1[c1] + d2[c2] + d3[c3])\nprint(ans)\n\n\n\n", "neg": "import itertools\nN,C = map(int,input().split(' '))\nD = [list(map(int,input().split(' '))) for i in [0]*C]\nc = [list(map(int,input().split(' '))) for i in [0]*N]\n\n\nl = [[],[],[]]\nn = 0\nfor i in range(N):\n\tfor j in range(i+1):\n\t\tl[n].append(c[i-j][j])\n\tn = (n+1) % 3\nfor i in range(N-1):\n\tfor j in range(N-i-1):\n\t\tl[n].append(c[i+j+1][N-j-1])\n\tn = (n+1) % 3\n\nd1,d2,d3 = [[sum([D[j-1][i] for j in l[n]]) for i in range(C)] for n in range(3)]\n\nans = 1000*500*500\ncolors = list(range(C))\nfor c1,c2,c3 in itertools.combinations(colors,3):\n\tans = min(ans,d1[c1] + d2[c2] + d3[c3])\nprint(ans)\n\n\n\n\n\n", "jacc_sim": 0.96, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [303, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u886633618", "n_user": "u886633618", "pos": "import sys\ninput = sys.stdin.readline\n\nN, C = map(int, input().split())\n\ngrid_array = [[0] * C for _ in range(3)]\n\nD_array = [list(map(int, input().split())) for _ in range(C)]\n\nfor i in range(N):\n C_array = map(int, input().split())\n for j, c in enumerate(C_array):\n grid_array[(i+j) % 3][c-1] += 1\n\n# print(D_array)\n\ncost_array = [[0] * C for _ in range(3)]\nfor i in range(3):\n for j in range(C):\n cost = 0\n for k in range(C):\n cost += grid_array[i][k] * D_array[k][j]\n cost_array[i][j] = cost\n\nans = 10 ** 20\n\nfor i in range(C):\n for j in range(C):\n if j == i:\n continue\n for k in range(C):\n if k == i or k == j:\n continue\n ans = min(ans, cost_array[0][i] +\n cost_array[1][j] + cost_array[2][k])\nprint(ans)\n", "neg": "import sys\ninput = sys.stdin.readline\n\nN, C = map(int, input().split())\n\ngrid_array = [[0] * C for _ in range(3)]\n\nD_array = [list(map(int, input().split())) for _ in range(C)]\n\nfor i in range(N):\n C_array = map(int, input().split())\n for j, c in enumerate(C_array):\n grid_array[(i+j) % 3][c-1] += 1\n\nprint(D_array)\n\ncost_array = [[0] * C for _ in range(3)]\nfor i in range(3):\n for j in range(C):\n cost = 0\n for k in range(C):\n cost += grid_array[i][k] * D_array[k][j]\n cost_array[i][j] = cost\n\nans = 10 ** 20\n\nfor i in range(C):\n for j in range(C):\n if j == i:\n continue\n for k in range(C):\n if k == i or k == j:\n continue\n ans = min(ans, cost_array[0][i] +\n cost_array[1][j] + cost_array[2][k])\nprint(ans)\n", "jacc_sim": 0.98, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [315, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u310678820", "n_user": "u310678820", "pos": "N, C = map(int, input().split())\nD = [list(map(int, input().split())) for _ in range(C)]\nc_map = [list(map(int, input().split())) for _ in range(N)]\ncount = [[0]*C for _ in range(3)]\nfor i in range(N):\n for j in range(N):\n c = c_map[i][j]\n amari = (i+j)%3\n count[amari][c-1]+=1\nans = float('inf')\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n tmp = 0\n if i == k or j == k or i==j:\n continue\n else:\n for l in range(C):\n tmp+=count[0][l]*D[l][i]\n tmp+=count[1][l]*D[l][j]\n tmp+=count[2][l]*D[l][k]\n ans = min(ans, tmp)\nprint(ans)", "neg": "N, C = map(int, input().split())\nD = [list(map(int, input().split())) for _ in range(C)]\nc_map = [list(map(int, input().split())) for _ in range(N)]\ncount = [[0]*C for _ in range(3)]\nfor i in range(N):\n for j in range(N):\n c = c_map[i][j]\n amari = (i+j)%3\n count[amari][c-1]+=1\nans = float('inf')\nfor i in range(C):\n for j in range(C):\n for k in range(C):\n tmp = 0\n if i == k or j == k or i==j:\n continue\n else:\n for l in range(C):\n tmp+=count[0][l]*D[l][i]\n tmp+=count[1][l]*D[l][j]\n tmp+=count[2][l]*D[l][k]\n ans = min(ans, tmp)\nprint(count)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [261, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u543954314", "n_user": "u543954314", "pos": "from collections import defaultdict as ddict\ntot = 10**12\nn,c = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(c)]\nclr = [list(map(int, input().split())) for _ in range(n)]\nl = [ddict(int) for _ in range(3)]\nfor y in range(n):\n for x in range(n):\n l[(x+y)%3][clr[y][x]] += 1\nfor c1 in range(c):\n for c2 in range(c):\n if c1 == c2:\n continue\n for c3 in range(c):\n if c1==c3 or c2==c3:\n continue\n ctot = 0\n cl = [c1,c2,c3]\n for i in range(3):\n for x in l[i]:\n ctot += d[x-1][cl[i]]*l[i][x]\n if tot > ctot:\n tot = ctot\nprint(tot)", "neg": "from collections import defaultdict\ntot = 10**12\nn,c = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(n)]\nclr = [list(map(int, input().split())) for _ in range(n)]\nl = [dict()]*3\nfor y in range(n):\n for x in range(n):\n l[(x+y)%3][clr[y][x]] += 1\nfor c1 in range(c):\n for c2 in range(c):\n if c1 == c2:\n continue\n for c3 in range(c):\n if c1==c3 or c2==c3:\n continue\n ctot = 0\n cl = [c1,c2,c3]\n for i in range(3):\n for x in l[i]:\n ctot += d[x-1][c[i]]*l[i][x]\n if tot > ctot:\n tot = ctot\nprint(tot)\n ", "jacc_sim": 0.9423076923076923, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [263, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u367130284", "n_user": "u367130284", "pos": "from itertools import*\nn,c=map(int,input().split())\ncost=[list(map(int,input().split()))for i in range(c)]\nd=[[0]*c for i in range(3)]\nfor i in range(n):\n for j,v in enumerate(map(int,input().split())):\n d[(i+j)%3][v-1]+=1\nprint(min(sum(cost[j][cmb[i]]*d[i][j]for j in range(c)for i in range(3))for cmb in permutations(range(c),3)))", "neg": "from itertools import*\nn,c=map(int,input().split())\ncost=[list(map(int,input().split()))for i in range(c)]\nd=[[0]*c for i in range(3)]\nfor i in range(n):\n for j,v in enumerate(map(int,input().split())):\n d[(i+j)%3][v-1]+=1\nprint(min(sum(d[j][cmb[i]]*cost[i][j]for j in range(c)for i in range(3))for cmb in permutations(range(c),3)))", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [146, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u129836004", "n_user": "u129836004", "pos": "import collections\nN , C = map(int, input().split())\nds =[list(map(int, input().split())) for i in range(C)]\ncs =[list(map(int, input().split())) for i in range(N)]\nc0 = collections.defaultdict(int)\nc1 = collections.defaultdict(int)\nc2 = collections.defaultdict(int)\nfor i in range(N):\n for j in range(N):\n if (i+j) % 3 == 0:\n c0[cs[i][j]] += 1\n elif (i+j) % 3 == 1:\n c1[cs[i][j]] += 1\n else:\n c2[cs[i][j]] += 1\n \nd = 10**9\nfor i in range(C):\n for j in range(C):\n if i == j:\n continue\n for k in range(C):\n if i == k or j == k:\n continue\n d0 = 0\n for l in c0:\n d0 += c0[l] * ds[l-1][i]\n for l in c1:\n d0 += c1[l] * ds[l-1][j]\n for l in c2:\n d0 += c2[l] * ds[l-1][k]\n if d > d0:\n d = d0\n \nprint(d)", "neg": "mport collections\nN , C = map(int, input().split())\nds =[list(map(int, input().split())) for i in range(C)]\ncs =[list(map(int, input().split())) for i in range(N)]\nc0 = collections.defaultdict(int)\nc1 = collections.defaultdict(int)\nc2 = collections.defaultdict(int)\nfor i in range(N):\n for j in range(N):\n if (i+j) % 3 == 0:\n c0[cs[i][j]] += 1\n elif (i+j) % 3 == 1:\n c1[cs[i][j]] += 1\n else:\n c2[cs[i][j]] += 1\n \nd = 10**9\nfor i in range(C):\n for j in range(C):\n if i == j:\n continue\n for k in range(C):\n if i == k or j == k:\n continue\n d0 = 0\n for l in c0:\n if l != i:\n d0 += c0[l] * ds[l-1][i]\n for l in c1:\n if l != j:\n d0 += c1[l] * ds[l-1][j]\n for l in c2:\n if l != k:\n d0 += c2[l] * ds[l-1][k]\n if d > d0:\n d = d0\nprint(d)", "jacc_sim": 0.94, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [344, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u001024152", "n_user": "u001024152", "pos": "N,C = map(int, input().split())\ncost = [list(map(int, input().split())) for _ in range(C)]\ncolor = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]\n\nmod3 = {0:[], 1:[], 2:[]}\nfor i in range(N):\n for j in range(N):\n m = (i+j)%3\n mod3[m].append(color[i][j])\n \nfrom collections import Counter\nfrom itertools import combinations, permutations\ncnts = [Counter(mod3[i]) for i in range(3)]\n# print(cnts)\nans = float('inf')\nfor comb in combinations(range(C), 3):\n for p in permutations(comb):\n cond = 0\n for i in range(3):\n for col in cnts[i].keys():\n cond += cnts[i][col]*cost[col][p[i]]\n ans = min(ans, cond)\n #print(cond, p)\nprint(ans)\n ", "neg": "N,C = map(int, input().split())\ncost = [list(map(int, input().split())) for _ in range(C)]\ncolor = [list(map(int, input().split())) for _ in range(N)]\n\nmod3 = {0:[], 1:[], 2:[]}\nfor i in range(N):\n for j in range(N):\n m = (i+j)%3\n mod3[m].append(color[i][j])\n \nfrom collections import Counter\nfrom itertools import combinations, permutations\ncnts = [Counter(mod3[i]) for i in range(3)]\n# print(cnts)\nans = float('inf')\nfor comb in combinations(range(C), 3):\n for p in permutations(comb):\n cond = 0\n for i in range(3):\n for col in cnts[i].keys():\n cond += cnts[i][col]*cost[col][p[i]]\n ans = min(ans, cond)\n #print(cond, p)\nprint(ans)\n ", "jacc_sim": 0.9482758620689655, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [263, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u514383727", "n_user": "u514383727", "pos": "from itertools import permutations\nfrom collections import deque\nfrom collections import Counter\nN, C = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(C)]\nc = [list(map(int, input().split())) for _ in range(N)]\n\nr0 = deque()\nr1 = deque()\nr2 = deque()\nfor i in range(N):\n for j in range(N):\n rest = (i+1+j+1) % 3\n if rest == 0:\n r0.append(c[i][j]-1)\n elif rest == 1:\n r1.append(c[i][j]-1)\n else:\n r2.append(c[i][j]-1)\nc0 = Counter(r0)\nc1 = Counter(r1)\nc2 = Counter(r2)\nans = 10**10\nfor p in permutations([i for i in range(C)], 3):\n point = 0\n point += sum([d[k][p[0]]* v for k, v in c0.items()])\n point += sum([d[k][p[1]]* v for k, v in c1.items()])\n point += sum([d[k][p[2]]* v for k, v in c2.items()])\n ans = min(ans, point)\nprint(ans)\n", "neg": "from itertools import permutations\nfrom collections import deque\nfrom collections import Counter\nN, C = map(int, input().split())\nd = [list(map(int, input().split())) for _ in range(C)]\nc = [list(map(int, input().split())) for _ in range(N)]\n\nr0 = deque()\nr1 = deque()\nr2 = deque()\nfor i in range(N):\n for j in range(N):\n rest = (i+1+j+1) % 3\n if rest == 0:\n r0.append(c[i][j]-1)\n elif rest == 1:\n r1.append(c[i][j]-1)\n else:\n r2.append(c[i][j]-1)\nc0 = Counter(r0)\nc1 = Counter(r1)\nc2 = Counter(r2)\nans = 10**10\nfor p in permutations([i for i in range(C)], 3):\n point = 0\n point += sum([d[k][p[0] * v] for k, v in c0.items()])\n point += sum([d[k][p[1] * v] for k, v in c1.items()])\n point += sum([d[k][p[2] * v] for k, v in c2.items()])\n ans = min(ans, point)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [340, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u741397536", "n_user": "u741397536", "pos": "N, C = map(int, input().split())\nD = []\nfor i in range(C):\n D.append(list(map(int, input().split())))\n\nc_arr = []\nfor i in range(N):\n c_arr.append(list(map(int, input().split())))\n\n\nc_arr1 = []\nc_arr2 = []\nc_arr3 = []\n\nfor i in range(N):\n for j in range(N):\n if (i+j)%3 == 0: \n c_arr1.append(c_arr[i][j])\n if (i+j)%3 == 1: \n c_arr2.append(c_arr[i][j])\n if (i+j)%3 == 2: \n c_arr3.append(c_arr[i][j])\n\ntmp = 1000*500*500\n\ndef cost(arr, aft):\n sum = 0\n for i in range(len(arr)):\n sum += D[arr[i]-1][aft]\n return sum\n\nans_arr1 = []\nans_arr2 = []\nans_arr3 = []\n\nfor l in range(C):\n ans_arr1.append(cost(c_arr1, l))\nfor l in range(C):\n ans_arr2.append(cost(c_arr2, l))\nfor l in range(C):\n ans_arr3.append(cost(c_arr3, l))\n\n\nans_arr = []\nfor l in range(C):\n for m in range(C):\n for n in range(C):\n if l == n or n == m or m == l:\n pass\n else:\n ans_arr.append(ans_arr1[l]+ans_arr2[m]+ans_arr3[n])\n\nprint(min(ans_arr))", "neg": "N, C = map(int, input().split())\nD = []\nfor i in range(C):\n D.append(list(map(int, input().split())))\n\nc_arr = []\nfor i in range(N):\n c_arr.append(list(map(int, input().split())))\n\n\nc_arr1 = []\nc_arr2 = []\nc_arr3 = []\n\nfor i in range(N):\n for j in range(N):\n if (i+j)%3 == 0: \n c_arr1.append(c_arr[i][j])\n if (i+j)%3 == 1: \n c_arr2.append(c_arr[i][j])\n if (i+j)%3 == 2: \n c_arr3.append(c_arr[i][j])\n\ntmp = 1000*500*500\n\ndef cost(arr, aft):\n sum = 0\n for i in range(len(arr)):\n sum += D[arr[i]-1][aft]\n return sum\n\nans_arr = []\n\nfor l in range(C):\n for m in range(C):\n if l == m:\n pass\n else:\n for n in range(C):\n if l == n or m == n:\n pass\n else:\n print(l,m,n)\n ans_arr.append(cost(c_arr1, l) + cost(c_arr2, m) + cost(c_arr3, n))\n\nprint(min(ans_arr))", "jacc_sim": 0.9473684210526315, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [458, 385], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u983918956", "n_user": "u983918956", "pos": "import itertools\nN,C = map(int,input().split())\nD = [list(map(int,input().split())) for i in range(C)]\ngrid = [list(map(int,input().split())) for i in range(N)]\nl1 = [0]*C\nl2 = [0]*C\nl3 = [0]*C\nfor i in range(1,N+1):\n for j in range(1,N+1):\n if (i+j) % 3 == 0:\n l1[grid[i-1][j-1]-1] += 1\n elif (i+j) % 3 == 1:\n l2[grid[i-1][j-1]-1] += 1\n elif (i+j) % 3 == 2:\n l3[grid[i-1][j-1]-1] += 1\ncolor = list(range(1,C+1))\nans = float('inf')\nfor x,y,z in itertools.permutations(color,3):\n res = 0\n for i in range(C):\n res += D[i][x-1]*l1[i]\n for i in range(C):\n res += D[i][y-1]*l2[i]\n for i in range(C):\n res += D[i][z-1]*l3[i]\n if res < ans:\n ans = res\nprint(ans)", "neg": "import itertools\nN,C = map(int,input().split())\nD = [list(map(int,input().split())) for i in range(C)]\ngrid = [list(map(int,input().split())) for i in range(N)]\ncolor = list(range(1,C+1))\nans = float('inf')\nfor x,y,z in itertools.permutations(color,3):\n print(x,y,z)\n res = 0\n for i in range(1,N+1):\n for j in range(1,N+1):\n if (i+j) % 3 == 0:\n res += D[grid[i-1][j-1]-1][x-1]\n elif (i+j) % 3 == 1:\n res += D[grid[i-1][j-1]-1][y-1]\n elif (i+j) % 3 == 2:\n res += D[grid[i-1][j-1]-1][z-1]\n if res < ans:\n ans = res\nprint(ans)", "jacc_sim": 0.9183673469387755, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [344, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u466335531", "n_user": "u466335531", "pos": "N,C=map(int,input().split())\nD=[list(map(int,input().split())) for _ in range(C)]\nG=[list(map(int,input().split())) for _ in range(N)]\nC0=[0]*(C+1)\nC1=[0]*(C+1)\nC2=[0]*(C+1)\n\nfor x in range(N):\n for y in range(N):\n if (x+y+2)%3==0: C0[G[x][y]]+=1\n elif (x+y+2)%3==1: C1[G[x][y]]+=1\n elif (x+y+2)%3==2: C2[G[x][y]]+=1\n\nminiwa=250000000\nfor c0 in range(1,C+1):\n for c1 in range(1,C+1):\n for c2 in range(1,C+1):\n if (c1-c0)*(c2-c1)*(c0-c2)==0: continue\n iwa=0\n for i in range(1,C+1):\n iwa+=(D[i-1][c0-1]*C0[i]+D[i-1][c1-1]*C1[i]+D[i-1][c2-1]*C2[i])\n miniwa=min(miniwa,iwa)\nprint(miniwa)", "neg": "N,C=map(int,input().split())\nD=[list(map(int,input().split())) for _ in range(C)]\nG=[list(map(int,input().split())) for _ in range(N)]\nC0=[0]*(C+1)\nC1=[0]*(C+1)\nC2=[0]*(C+1)\n\nfor x in range(N):\n for y in range(N):\n if (x+y+2)%3==0: C0[G[x][y]]+=1\n elif (x+y+2)%3==1: C1[G[x][y]]+=1\n elif (x+y+2)%3==2: C2[G[x][y]]+=1\n\nminiwa=250000000\nfor c0 in range(1,C+1):\n for c1 in range(1,C+1):\n for c2 in range(1,C+1):\n if (c1-c0)*(c2-c1)*(c0-c2)==0: break\n iwa=0\n for i in range(1,C+1):\n iwa+=(D[i-1][c0-1]*C0[i]+D[i-1][c1-1]*C1[i]+D[i-1][c2-1]*C2[i])\n miniwa=min(miniwa,iwa)\nprint(miniwa)", "jacc_sim": 0.9574468085106383, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [358, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u782098901", "n_user": "u782098901", "pos": "import itertools\n\n\ndef main():\n N, C = map(int, input().split())\n D = [list(map(int, input().split())) for _ in range(C)]\n CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]\n\n cost = [[0 for _ in range(C)] for _ in range(3)]\n for c in range(C):\n for i in range(N):\n for j in range(N):\n cost[(i + j) % 3][c] += D[CC[i][j]][c]\n\n res = float(\"inf\")\n color = [i for i in range(C)]\n for i, c in enumerate(list(itertools.permutations(color, 3))):\n tmp = 0\n for it in range(3):\n tmp += cost[it][c[it]]\n res = min(res, tmp)\n\n print(res)\n\nmain()", "neg": "import itertools\nimport sys\ninput = sys.input.readline()\n\n\ndef main():\n N, C = map(int, input().split())\n D = [list(map(int, input().split())) for _ in range(C)]\n CC = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(N)]\n\n cost = [[0 for _ in range(C)] for _ in range(3)]\n for c in range(C):\n for i in range(N):\n for j in range(N):\n cost[(i + j) % 3][c] += D[CC[i][j]][c]\n\n res = float(\"inf\")\n color = [i for i in range(C)]\n for i, c in enumerate(list(itertools.permutations(color, 3))):\n tmp = 0\n for it in range(3):\n tmp += cost[it][c[it]]\n res = min(res, tmp)\n\n print(res)\n\nmain()\n", "jacc_sim": 0.96, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [241, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,c=map(int,input().split())\nd=[list(map(int,input().split()))for _ in range(c)]\nl=[[i for i in[0]*c]for _ in range(3)]\nfor i in range(n):\n t=list(map(int,input().split()))\n for j in range(n):\n l[(i+j)%3][t[j]-1]+=1\na=10**18\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i==j or j==k or k==i:continue\n a=min(a,sum(d[x][i]*l[0][x]+d[x][j]*l[1][x]+d[x][k]*l[2][x]for x in range(c)))\nprint(a)", "neg": "n,c=map(int,input().split())\nd=[list(map(int,input().split()))for _ in range(c)]\nl=[[i for i in[0]*c]for _ in range(3)]\nfor i in range(n):\n t=list(map(int,input().split()))\n for j in range(n):\n l[(i+j)%3][t[j]-1]+=1\nc=10**18\nfor i in range(c):\n for j in range(c):\n for k in range(c):\n if i==j or j==k or k==i:continue\n c=min(c,sum(d[x][i]*l[0][x]+d[x][j]*l[1][x]+d[x][k]*l[2][x]for x in range(c)))\nprint(c)", "jacc_sim": 0.9767441860465116, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [212, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u325227960", "n_user": "u325227960", "pos": "n,c=map(int,input().split())\nD=[]\nfor i in range(c):\n D.append(list(map(int,input().split())))\nC=[]\nfor i in range(n):\n C.append(list(map(int,input().split())))\n\n#print(D)\n\nC1=[]\nC2=[]\nC3=[]\nfor i in range(n):\n for j in range(n):\n f=(i+j)%3\n if f==0:\n C1.append(C[i][j])\n if f==1:\n C2.append(C[i][j])\n if f==2:\n C3.append(C[i][j])\n \n\nminiwa=1000*500*500\n\n#print(C3)\niwa1=[]\niwa2=[]\niwa3=[]\n\nfor cc in range(0,c):\n iwa1.append(sum(D[i-1][cc] for i in C1))\n iwa2.append(sum(D[i-1][cc] for i in C2))\n iwa3.append(sum(D[i-1][cc] for i in C3))\n\nfor c1 in range(0,c):\n for c2 in range(0,c):\n for c3 in range(0,c):\n if c1!=c2 and c2!=c3 and c3!=c1 :\n iwa=iwa1[c1]+iwa2[c2]+iwa3[c3]\n miniwa=min(miniwa,iwa)\n\nprint(miniwa)\n", "neg": "n,c=map(int,input().split())\nD=[]\nfor i in range(c):\n D.append(list(map(int,input().split())))\nC=[]\nfor i in range(n):\n C.append(list(map(int,input().split())))\n\nprint(D)\n\nC1=[]\nC2=[]\nC3=[]\nfor i in range(n):\n for j in range(n):\n f=(i+j)%3\n if f==0:\n C1.append(C[i][j])\n if f==1:\n C2.append(C[i][j])\n if f==2:\n C3.append(C[i][j])\n \n\nminiwa=1000*500*500\n\nprint(C3)\n\nfor c1 in range(0,c):\n iwa1=sum(D[i-1][c1] for i in C1)\n for c2 in range(0,c):\n iwa2=sum(D[j-1][c2] for j in C2)\n for c3 in range(0,c):\n if c1!=c2 and c2!=c3 and c3!=c1 :\n iwa3=sum(D[k-1][c3] for k in C3)\n iwa=iwa1+iwa2+iwa3\n miniwa=min(miniwa,iwa)\n\nprint(miniwa)\n", "jacc_sim": 0.9444444444444444, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [412, 368], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u594859393", "n_user": "u594859393", "pos": "from itertools import product\nfrom collections import Counter\n \nn, c = map(int, input().split())\ncolor_costs = [list(map(int, input().split())) for _ in range(c)]\nmatrix = [list(map(int, input().split())) for _ in range(n)]\n\ncolord = {(i, j):cost for i, row in enumerate(color_costs)\n for j, cost in enumerate(row)}\n \nres = []\nfor n in range(3):\n color_count = Counter(c-1 for i, row in enumerate(matrix) \n for j, c in enumerate(row) \n if (i + j) % 3 == n)\n def color_cost(color):\n return sum(colord[ccolor, color] * ccount for ccolor, ccount in color_count.items())\n cx = [(color, color_cost(color)) for color in range(c)]\n sorted_by_cost = sorted(cx, key=lambda x:x[1])\n cheapest3 = sorted_by_cost[:3]\n res.append(cheapest3)\n\ncolor_pickss = product(*res)\nfiltered_unique = (picks for picks in color_pickss if len(set(x[0] for x in picks)) == 3)\ncosts = (sum(x[1] for x in picks) for picks in filtered_unique)\nprint(min(costs))", "neg": "from itertools import product\nfrom collections import Counter\n \nn, c = map(int, input().split())\ncolor_costs = [list(map(int, input().split())) for _ in range(c)]\nmatrix = [list(map(int, input().split())) for _ in range(n)]\n\ncolord = {(i, j):cost for i, row in enumerate(color_costs)\n for j, cost in enumerate(row)}\n \nres = []\nfor n in range(3):\n color_count = Counter(c-1 for i, row in enumerate(matrix) \n for j, c in enumerate(row) \n if (i + j) % 3 == n)\n def color_cost(color):\n return sum(colord[ccolor, color] * ccount for ccolor, ccount in color_count.items())\n cx = [(color, color_cost(color)) for color in range(c)]\n sorted_by_cost = sorted(cx, key=lambda x:x[1])\n cheapest3 = sorted_by_cost[:3]\n res.append(cheapest3)\n\ncolor_pickss = product(*res)\nfiltered_unique = (picks for picks in color_pickss if len(set(x[0] for x in picks)) == 3)\ncosts = (sum(x[1] for x in picks) for pick in filtered_unique)\nprint(min(costs))", "jacc_sim": 0.9857142857142858, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [350, 349], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u149260203", "n_user": "u149260203", "pos": "N,C = [int(i) for i in input().split()]\nD = [[int(j) for j in input().split()] for i in range(C)]\nc_temp = [[int(j)-1 for j in input().split()] for i in range(N)]\nc = [[0 for i in range(C)] for j in range(3)]\nfor i in range(N):\n for j in range(N):\n c[(i+j)%3][c_temp[i][j]] += 1\n\nmin = 10**15\nfor i in [ii for ii in range(C)]:\n for j in [jj for jj in range(C) if jj != i]:\n for k in [kk for kk in range(C) if kk != i and kk != j]:\n count = sum([D[x][i]*c[0][x] + D[x][j]*c[1][x] + D[x][k]*c[2][x] for x in range(C)])\n if min > count:\n min = count\nprint(min)\n\n\n", "neg": "N,C = [int(i) for i in input().split()]\nD = [[int(j) for j in input().split()] for i in range(C)]\nc_temp = [[int(j)-1 for j in input().split()] for i in range(N)]\nc = [[0 for i in range(C)] for j in range(3)]\nprint(c)\nfor i in range(N):\n for j in range(N):\n c[(i+j+2)%3][c_temp[i][j]] += 1\n print((i+j+2)%3, c_temp[i][j])\n\nmin = 100000\nfor i in [ii for ii in range(C)]:\n for j in [jj for jj in range(C) if jj != i]:\n for k in [kk for kk in range(C) if kk != i and kk != j]:\n count = sum([D[x][i]*c[0][x] + D[x][j]*c[1][x] + D[x][k]*c[2][x] for x in range(C)])\n if min > count:\n min = count\nprint(min)\n\n\n", "jacc_sim": 0.9333333333333333, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [261, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03330", "p_user": "u047668580", "n_user": "u047668580", "pos": "# \u57fa\u672c\u306f\uff13\u3067\u5272\u3063\u305f\u3042\u307e\u308a\u6bce\u306b\u5909\u63db\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\u3059\u308b.\n# a[i][j] i\u7a2e\u985e\u76ee\u304cj\u8272\u306b\u5909\u308f\u308b\u6642\u306e\u30b3\u30b9\u30c8\u3068\u8a08\u7b97\u3057\u3001\u305d\u308c\u306e\u5408\u8a08\u306emin\u3092\u53d6\u308b\n\nimport numpy as np\nN,C = map(int,input().split())\na = np.zeros((3,C))\nD = np.array([ list(map(int,input().split())) for i in range(C)])\nc = np.array([ list(map(int,input().split())) for i in range(N)])\n\n\nfor i in range(N):\n for j in range(N):\n a[(i+j)%3] += D[c[i][j]-1]\n\nsum_arr = []\nfor C1 in range(C):\n for C2 in range(C):\n for C3 in range(C):\n if C1 != C2 and C2 != C3 and C3 != C1:\n sum_arr.append(a[0][C1]+a[1][C2]+a[2][C3])\n\nprint(int(min(sum_arr)))\n", "neg": "# \u57fa\u672c\u306f\uff13\u3067\u5272\u3063\u305f\u3042\u307e\u308a\u6bce\u306b\u5909\u63db\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\u3059\u308b.\n# a[i][j] i\u7a2e\u985e\u76ee\u304cj\u8272\u306b\u5909\u308f\u308b\u6642\u306e\u30b3\u30b9\u30c8\u3068\u8a08\u7b97\u3057\u3001\u305d\u308c\u306e\u5408\u8a08\u306emin\u3092\u53d6\u308b\n\nimport numpy as np\nN,C = map(int,input().split())\na = np.zeros((3,C))\nD = np.array([ list(map(int,input().split()))) for i in range(C)])\nc = np.array([ list(map(int,input().split()))) for i in range(N)])\n\n\nfor i in range(N):\n for j in range(N):\n a[(i+j)%3] += D[c[i][j]-1]\n\nsum_arr = []\nfor C1 in range(C):\n for C2 in range(C):\n for C3 in range(C):\n if C1 != C2 and C2 != C3 and C3 != C1:\n sum_arr.append(a[0][C1]+a[1][C2]+a[2][C3])\n\nprint(int(min(l)))\n", "jacc_sim": 0.9883720930232558, "nl": "You are given a grid with N rows and N columns of squares, each initially painted with one of C colors. The grid is considered \"good\" if certain conditions are met. You need to repaint some squares to make the grid \"good\" and find the minimum sum of wrongness for all squares. Constraints: 1 \u2264 N \u2264 500, 3 \u2264 C \u2264 30, 1 \u2264 D_{i,j} \u2264 1000 (i \u2260 j), D_{i,j}=0 (i=j), 1 \u2264 c_{i,j} \u2264 C. Input format: N C D_{1,1} ... D_{1,C} ... D_{C,1} ... D_{C,C} c_{1,1} ... c_{1,N} ... c_{N,1} ... c_{N,N}. Output the minimum possible sum of wrongness. Example input: 2 3 0 1 1 1 0 1 1 4 0 1 2 3 3. Example output: 3.", "before_after_length": [391, 389], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u790710233", "n_user": "u790710233", "pos": "MOD = 998244353\nn, a, b, k = map(int, input().split())\nmemo = [0]*(n//2+1)\n\n\ndef com(n, r):\n if n < r or r < 0:\n return 0\n if n-r < r:\n r = n-r\n if r == 0:\n memo[r] = 1\n return memo[r]\n if memo[r] != 0:\n return memo[r]\n X = Y = 1\n for i in range(1, r+1):\n Y = Y*i % MOD\n X = X*(n-i+1) % MOD\n memo[i] = X*pow(Y, MOD-2, MOD)\n return memo[r]\n\n\ncom(n, n//2)\nans = 0\nfor x in range(n+1):\n y, r = divmod(k-a*x, b)\n if y < 0:\n continue\n if r == 0:\n ans += com(n, x)*com(n, y)\n ans %= MOD\nprint(ans % MOD)\n", "neg": "MOD = 998244353\nn, a, b, k = map(int, input().split())\n\n\n\npair = []\nfor x in range(n+1):\n y, r = divmod(k-a*x, b)\n if y < 0:\n continue\n if r == 0:\n pair.append((x, y))\n\n\nmemo = [0]*n\n\n\ndef com(n, r):\n X = Y = 1\n if n < r:\n return 0\n if n-r < r:\n r = n-r\n if memo[r] != 0:\n return memo[r]\n for i in range(1, r+1):\n Y = Y*i % MOD\n X = X*(n-i+1) % MOD\n memo[i] = X*pow(Y, MOD-2, MOD)\n return memo[r]\n\ncom(n, n//2)\n\nans = 0\nfor x, y in pair:\n ans += com(n, x)*com(n, y) % MOD\nprint(ans % MOD)\n", "jacc_sim": 0.94, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [274, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u223904637", "n_user": "u223904637", "pos": "n,a,b,k=map(int,input().split())\nmod=998244353\nans=0\np=[1]*(n+1)\nfor i in range(n):\n p[i+1]=((i+1)*p[i])%mod\nfor ai in range(n+1):\n if k-a*ai>=0 and (k-a*ai)%b==0:\n bi=(k-a*ai)//b\n if bi<=n:\n ans+=p[n]*pow(p[ai],mod-2,mod)*pow(p[n-ai],mod-2,mod)*p[n]*pow(p[bi],mod-2,mod)*pow(p[n-bi],mod-2,mod)\n ans%=mod\nprint(ans)\n", "neg": "n,a,b,k=map(int,input().split())\nmod=998244353\nans=0\np=[1]*(n+1)\nfor i in range(n):\n p[i+1]=((i+1)*p[i])%mod\nfor ai in range(n+1):\n if k-a*ai>=0 and (k-a*ai)%b==0:\n bi=(k-a*ai)//b\n ans+=p[n]*pow(p[ai],mod-2,mod)*pow(p[n-ai],mod-2,mod)\n ans%=mod\n ans+=p[n]*pow(p[bi],mod-2,mod)*pow(p[n-bi],mod-2,mod)\n ans%=mod\nprint(ans)", "jacc_sim": 0.975, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [198, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u864197622", "n_user": "u864197622", "pos": "n, a, b, k = map(int, input().split())\n\nmod = 998244353\nfact = [1] + [0] * n\ninv_fact = [0] * (n+1)\nfor i in range(n):\n fact[i+1] = (fact[i] * (i+1)) % mod\n\nfor i in range(n+1):\n inv_fact[i] = pow(fact[i],mod-2,mod)\n \ndef cb(n, k, mod):\n return (fact[n] * inv_fact[k] * inv_fact[n-k]) % mod\n\nans = 0\nfor x in range(n+1):\n if (k-x*a) % b == 0:\n y = (k-x*a)//b\n if y >= 0:\n if x > n or y > n:\n pass\n else:\n ans += cb(n, x, mod) * cb(n, y, mod)\n ans %= mod\n \nprint(ans)\n", "neg": "n, a, b, k = map(int, input().split())\n\nmod = 998244353\nfact = [1] + [0] * n\ninv_fact = [0] * (n+1)\nfor i in range(n):\n fact[i+1] = (fact[i] * (i+1)) % mod\n\nfor i in range(n+1):\n inv_fact[i] = pow(fact[i],mod-2,mod)\n \ndef cb(n, k, mod):\n return (fact[n] * inv_fact[k] * inv_fact[n-k]) % mod\n\nans = 0\nfor x in range(max(0, (k-(n+1)*b)//a+1), min(n+1, k//a)):\n if (k-x*a) % b == 0:\n y = (k-x*a)//b\n if y >= 0:\n if x > n or y > n:\n pass\n else:\n ans += cb(n, x, mod) * cb(n, y, mod)\n ans %= mod\n \nprint(ans)\n", "jacc_sim": 0.9574468085106383, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [254, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u846150137", "n_user": "u846150137", "pos": "n,a,b,k=map(int,input().split())\ns=0\nm=998244353\nf=[1]\nr=[1]\n \nfor i in range(1,n+1):\n f+=[i*f[i-1]%m]\n r+=[pow(f[i],m-2,m)]\n\ncb=lambda x,y:f[x]*r[x-y]*r[y]\n\nfor i in range(n+1):\n c,d=divmod(k-a*i,b)\n if d==0 and 0<=c<=n:\n s=(s+cb(n,i)*cb(n,c))%m\n\nprint(s)", "neg": "n,a,b,k=map(int,input().split())\ns=0\nm=998244353\nf=[1]\nr=[1]\n \nfor i in range(1,n+1):\n f+=[i*f[i-1]%m]\n r+=[pow(f[i],m-2,m)]\n\ncb=lambda x,y:f[x]*r[x-y]*r[y]\n\nfor i in range(n//a):\n c,d=divmod(k-a*i,b)\n if d==0 and 0<=c<=n:\n s=(s+cb(n,i)*cb(n,c))%m\n\nprint(s)", "jacc_sim": 0.9777777777777777, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [178, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u075012704", "n_user": "u075012704", "pos": "N, A, B, K = map(int, input().split())\nmod = 998244353\n\n# \u968e\u4e57 & \u9006\u5143\u8a08\u7b97\nfactorial = [1]\ninverse = [1]\nfor i in range(1, N+2):\n factorial.append(factorial[-1] * i % mod)\n inverse.append(pow(factorial[-1], mod-2, mod))\n\n\n# \u7d44\u307f\u5408\u308f\u305b\u8a08\u7b97\ndef nCr(n, r):\n if n < r:\n return 0\n elif r == 0:\n return 1\n return factorial[n] * inverse[r] * inverse[n - r] % mod\n\n\nans = 0\nfor r in range(N+1):\n b = (K - A*r) / B\n # \u9752\u3067\u5857\u308b\u7b87\u6240\u304c\u6574\u6570\u306a\u3089\u3070\n if b == (K-A*r) // B and 0 <= b <= N:\n ans += nCr(N, r) * nCr(N, int(b)) % mod\n\nprint(ans % mod)\n", "neg": "N, A, B, K = map(int, input().split())\nmod = 998244353\n\n# \u968e\u4e57 & \u9006\u5143\u8a08\u7b97\nfactorial = [1]\ninverse = [1]\nfor i in range(1, N+2):\n factorial.append(factorial[-1] * i % mod)\n inverse.append(pow(factorial[-1], mod-2, mod))\n\n\n# \u7d44\u307f\u5408\u308f\u305b\u8a08\u7b97\ndef nCr(n, r):\n if n < r or n == 0 or r == 0:\n return 0\n return factorial[n] * inverse[r] * inverse[n - r] % mod\n\n\nans = 0\nfor r in range(N+1):\n b = (K - A*r) / B\n # \u9752\u3067\u5857\u308b\u7b87\u6240\u304c\u6574\u6570\u306a\u3089\u3070\n if b == (K-A*r) // B:\n ans += nCr(N, r) * nCr(N, int(b)) % mod\n\nprint(ans)\n", "jacc_sim": 0.9583333333333334, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [311, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u280016524", "n_user": "u280016524", "pos": "li = input().split()\nN=int(li[0])\nA=int(li[1])\nB=int(li[2])\nK=int(li[3])\nmod = 998244353 #\u51fa\u529b\u306e\u5236\u9650\ng1 = [1, 1] # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [0, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0;\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\ncount=0\nfor i in range (N+1):\n if(((A+B)*N-A*i-K)%B==0):\n k=((A+B)*N-A*i-K)//B\n ca=cmb(N,i,mod)\n cb=cmb(N,k,mod)\n count=count+ca*cb\nprint(count%mod)", "neg": "def cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 998244353 #\u51fa\u529b\u306e\u5236\u9650\ng1 = [1, 1] # \u5143\u30c6\u30fc\u30d6\u30eb\ng2 = [1, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\ninverse = [0, 1] #\u9006\u5143\u30c6\u30fc\u30d6\u30eb\u8a08\u7b97\u7528\u30c6\u30fc\u30d6\u30eb\nN1=10**4+1\nfor i in range( 2, N1 + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nli = input().split()\nN=int(li[0])\nA=int(li[1])\nB=int(li[2])\nK=int(li[3])\ncount=0\nfor i in range (N+1):\n for k in range(N+1):\n if((A+B)*N-A*i-B*k==K):\n \n ca=cmb(N, i,mod)\n cb=cmb(N,k,mod)\n count=count+ca*cb\nprint(count%mod)", "jacc_sim": 0.9420289855072463, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [409, 410], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u925364229", "n_user": "u303019816", "pos": "N,A,B,K = map(int,input().split(\" \"))\nmod = 998244353\nncr = [1]*(N+1)\nv = 1\nfor i in range(N):\n\tv = (v * ((N-i)%mod) * pow((i+1),mod-2,mod)) % mod\n\tncr[i+1] = v%mod\n\npat = 0\nfor a in range(N+1):\n\tif (K - (a * A) < 0):\n\t\tbreak\n\tif (K - (a * A)) % B == 0 and ((K - (a * A))//B) <= N:\n\t\tpat += ncr[a]*ncr[(K - (a * A))//B]\n\t\tpat %= mod\n\nprint(pat % mod)\n\n", "neg": "N, A, B, K = map(int, input().split(\" \"))\nmod = 998244353\nncr = [1] * (N + 1)\nv = 1\n\nprint(ncr)\nfor i in range(N):\n v = (v * ((N - i) % mod) * pow((i + 1), mod - 2, mod)) % mod\n ncr[i + 1] = v % mod\n\npat = 0\nfor a in range(N + 1):\n if (K - (a * A) < 0):\n break\n if (K - (a * A)) % B == 0 and ((K - (a * A)) // B) <= N:\n pat += ncr[a] * ncr[(K - (a * A)) // B]\n pat %= mod\n\nprint(pat % mod)", "jacc_sim": 1.0, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [197, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u497625442", "n_user": "u497625442", "pos": "N,A,B,K = map(int,input().split())\nsprime = 998244353 # approx 10**9\nA,B = sorted((A,B))\nif (A+B) * N < K:\n\tprint(0)\n\texit()\n \ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n \ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n \nmemo = [0] * (N+1)\nmemo[0] = memo[N] = 1\nfor i in range(1,N//2+1):\n\tv = memo[i-1] * (N-i+1) * modinv(i,sprime)\n\tv = v % sprime\n\tmemo[i] = memo[N-i] = v\n \n# max is A*N + B*N\nsum = 0\nfor b in range(N+1):\n a = (K-b*B)//A\n if 0 <= a <= N and a*A+b*B == K:\n sum += memo[a]*memo[b]\n sum %= sprime\n\nprint(sum)", "neg": "N,A,B,K = map(int,input().split()\nsprime = 998244353 # approx 10**9\nA,B = sorted((A,B))\nif (A+B) * N < K:\n\tprint(0)\n\texit()\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\nmemo = [0] * (N+1)\nmemo[0] = memo[N] = 1\nfor i in range(1,N//2+1):\n\tv = memo[i-1] * (N-i+1) * modinv(i,sprime)\n\tv = v % sprime\n\tmemo[i] = memo[N-i] = v\n\n# max is A*N + B*N\nsum = 0\nfor j in range(0,N):\n\ti = (K-B*j)//A\n\tif 0 <= i <= N and A*i+B*j==K:\n\t\tsum += memo[i] * memo[j]\n\t\tsum %= sprime\n\nprint(sum)\n\n", "jacc_sim": 0.9848484848484849, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [359, 360], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 998244353\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\ndef inv(x):\n return pow(x, mod - 2, mod)\n\nnm = {}\nnm[0] = 1\ndef nCr_(n):\n b = n // 2 + 1\n r = 1\n d = 1\n for k in range(1,b+1):\n r = r * (n-k+1) % mod\n d = d * k % mod\n nm[k] = r * inv(d) % mod\n\ndef nCr(n, b):\n if b > n - b:\n b = n - b\n return nm[b]\n\ndef main():\n n,a,b,k = LI()\n r = 0\n nCr_(n)\n for i in range(n+1):\n ai = a * i\n bi = k - ai\n if bi < 0 or bi % b > 0 or bi // b > n:\n continue\n bb = bi // b\n r += nCr(n,i) * nCr(n,bb)\n r %= mod\n\n return r\n\n\nprint(main())\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 998244353\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\ndef inv(x):\n return pow(x, mod - 2, mod)\n\nnm = {}\ndef nCr_(n):\n b = n // 2 + 1\n r = 1\n d = 1\n for k in range(1,b+1):\n r = r * (n-k+1) % mod\n d = d * k % mod\n nm[k] = r * inv(d) % mod\n\ndef nCr(n, b):\n if b > n - b:\n b = n - b\n return nm[b]\n\ndef main():\n n,a,b,k = LI()\n r = 0\n nCr_(n)\n for i in range(n+1):\n ai = a * i\n bi = k - ai\n if bi < 0 or bi % b > 0 or bi // b > n:\n continue\n bb = bi // b\n r += nCr(n,i) * nCr(n,bb)\n r %= mod\n\n return r\n\n\nprint(main())\n\n", "jacc_sim": 1.0, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [474, 467], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03332", "p_user": "u327466606", "n_user": "u327466606", "pos": "MOD = 998244353\n\nN,A,B,K = map(int,input().split())\n\nA,B = sorted((A,B))\n\nif (A+B)*N < K:\n print(0)\n exit()\n\n# tabulate combinations\n\n\n\n# \u62e1\u5f35\u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u4e92\u9664\u6cd5\n# ax + by = gcd(a,b)\u306e\u6700\u5c0f\u6574\u6570\u89e3\u3092\u8fd4\u3059\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\n\n# m\u3092\u6cd5\u3068\u3059\u308ba\u306e\u4e57\u6cd5\u7684\u9006\u5143\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n\nmemo = [0]*(N+1)\nmemo[0] = memo[N] = 1\nfor k in range(1,N//2+1):\n v = memo[k-1]*(N-k+1)*modinv(k,MOD)\n v %= MOD\n memo[k] = memo[N-k] = v\n\ncnt = 0\n\nfor b in range(N+1):\n a = (K-b*B)//A\n if 0 <= a <= N and a*A+b*B == K:\n cnt += memo[a]*memo[b]\n cnt %= MOD\n\nprint(cnt)", "neg": "MOD = 998244353\n\nN,A,B,K = map(int,input().split())\n\nA,B = sorted((A,B))\n\nif (A+B)*N < K:\n print(0)\n exit()\n\n# tabulate combinations\n\n\n\n# \u62e1\u5f35\u30e6\u30fc\u30af\u30ea\u30c3\u30c9\u4e92\u9664\u6cd5\n# ax + by = gcd(a,b)\u306e\u6700\u5c0f\u6574\u6570\u89e3\u3092\u8fd4\u3059\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, y, x = egcd(b % a, a)\n return (g, x - (b // a) * y, y)\n\n\n# m\u3092\u6cd5\u3068\u3059\u308ba\u306e\u4e57\u6cd5\u7684\u9006\u5143\ndef modinv(a, m):\n g, x, y = egcd(a, m)\n if g != 1:\n raise Exception('modular inverse does not exist')\n else:\n return x % m\n\n\nmemo = [0]*(N+1)\nmemo[0] = memo[N] = 1\nfor k in range(1,N//2+1):\n v = memo[k-1]*(N-k+1)*modinv(k,MOD)\n v %= MOD\n memo[k] = memo[N-k] = v\n\ncnt = 0\n\nfor b in range((max(0,K-N*A)-1)//B+1, (K-1)//B+1):\n a = (K-b*B)//A\n if a*A+b*B == K:\n cnt += memo[a]*memo[b]\n cnt %= MOD\n\nprint(cnt)", "jacc_sim": 0.9782608695652174, "nl": "Takahashi has a tower with N layers initially uncolored. He can paint layers red, green, or blue. The beauty of the tower is the sum of the scores of the N layers, where a layer scores A if red, A+B if green, B if blue, and 0 if uncolored. Takahashi wants the tower's beauty to be exactly K. How many ways can he paint the tower to achieve this? Find the count modulo 998244353. Constraints: 1 \u2264 N \u2264 3\u00d710^5, 1 \u2264 A,B \u2264 3\u00d710^5, 0 \u2264 K \u2264 18\u00d710^{10}. Input format: N A B K. Output: Number of ways to paint tiles, modulo 998244353. Example: Input: 4 1 2 5, Output: 40.", "before_after_length": [455, 472], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03333", "p_user": "u923270446", "n_user": "u923270446", "pos": "I,i,H=input,int,range\nn,L,R,A,C=i(I()),[0],[0],0,0\nfor _ in H(n):l,r=map(i,I().split());L+=[l];R+=[r]\nL=sorted(L)[::-1];R.sort()\nfor j in H(n//2+1):C+=(L[j]-R[j])*2;A=max(A,C)\nprint(A)", "neg": "I,i,R=input,int,range\nn,L,R,A,C=i(I()),[],[],0,0\nfor _ in R(n):l,r=map(i,I().split());L+=[l];R+=[r]\nL=sorted(l)[::-1];R.sort()\nfor j in R(n):C+=(L[j]-R[j])*2;A=max(A,C)\nprint(A)", "jacc_sim": 0.9487179487179487, "nl": "Takahashi and Aoki play a game using a number line and segments. Takahashi starts at coordinate 0 and Aoki has N segments, each defined by [L_i, R_i]. The game has N steps. Aoki selects a segment, and Takahashi moves within that segment. After N steps, Takahashi returns to coordinate 0. The goal is to find the total distance traveled by Takahashi (K). Aoki aims to maximize K, while Takahashi aims to minimize it. Constraints: 1 \u2264 N \u2264 10^5, -10^5 \u2264 L_i < R_i \u2264 10^5. Input format: N followed by N lines of L and R values. Output: Print the total distance traveled by Takahashi. The distance will always be an integer.", "before_after_length": [121, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03333", "p_user": "u144913062", "n_user": "u144913062", "pos": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nleft = []\nright = []\nleft_inv = []\nright_inv = []\nfor i in range(N):\n L, R = map(int, input().split())\n left.append((R, i))\n right.append((L, i))\n left_inv.append((-L, i))\n right_inv.append((-R, i))\n\ndef calc(left, right):\n left.sort(key=lambda p: -p[0])\n right.sort(key=lambda p: p[0])\n used = set()\n x = 0\n ans = 0\n while right or left:\n while right and right[-1][1] in used:\n right.pop()\n if right:\n y, i = right.pop()\n used.add(i)\n if x < y:\n ans += y - x\n x = y\n while left and left[-1][1] in used:\n left.pop()\n if left:\n y, i = left.pop()\n used.add(i)\n if y < x:\n ans += x - y\n x = y\n ans += abs(x)\n return ans\n\nans = max(calc(left, right), calc(left_inv, right_inv))\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nleft = []\nright = []\nleft_inv = []\nright_inv = []\nfor i in range(N):\n L, R = map(int, input().split())\n left.append((R, i))\n right.append((L, i))\n left_inv.append((-L, i))\n right_inv.append((-R, i))\n\ndef calc(left, right):\n left.sort(key=lambda p: -p[0])\n right.sort(key=lambda p: p[0])\n used = set()\n x = 0\n ans = 0\n while right or left:\n while right and right[-1][1] in used:\n right.pop()\n if right:\n y, i = right.pop()\n used.add(i)\n if x < y:\n ans += y - x\n x = y\n while left and left[-1][1] in used:\n left.pop()\n if left:\n y, i = left.pop()\n used.add(i)\n if y < x:\n ans += x - y\n x = y\n ans += abs(x)\n return ans\n\nans = min(calc(left, right), calc(left_inv, right_inv))\nprint(ans)", "jacc_sim": 0.9636363636363636, "nl": "Takahashi and Aoki play a game using a number line and segments. Takahashi starts at coordinate 0 and Aoki has N segments, each defined by [L_i, R_i]. The game has N steps. Aoki selects a segment, and Takahashi moves within that segment. After N steps, Takahashi returns to coordinate 0. The goal is to find the total distance traveled by Takahashi (K). Aoki aims to maximize K, while Takahashi aims to minimize it. Constraints: 1 \u2264 N \u2264 10^5, -10^5 \u2264 L_i < R_i \u2264 10^5. Input format: N followed by N lines of L and R values. Output: Print the total distance traveled by Takahashi. The distance will always be an integer.", "before_after_length": [333, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03333", "p_user": "u695811449", "n_user": "u695811449", "pos": "N=int(input())\nLR=[None]*N\nfor i in range(N):\n LR[i]=list(map(int,input().split()))\n\nRAN=(len(LR)+1)//2\n\nLR_L=sorted(LR,key=lambda x: x[0],reverse=True)\nLR_R=sorted(LR,key=lambda x: x[1])\n\nANS_l=[0]*(RAN*2+2)\nANS_r=[0]*(RAN*2+2)\n\nfor i in range(RAN):\n ANS_l[2*i+1]=ANS_l[2*i]+LR_L[i][0]\n ANS_l[2*i+2]=ANS_l[2*i+1]-LR_R[i][1]\n\n ANS_r[2*i+1]=ANS_r[2*i]-LR_R[i][1]\n ANS_r[2*i+2]=ANS_r[2*i+1]+LR_L[i][0]\n\n\nprint(max(max(ANS_l)*2,max(ANS_r)*2))", "neg": "N=int(input())\nLR=[None]*N\nfor i in range(N):\n LR[i]=list(map(int,input().split()))\n\nRAN=(len(LR)+1)//2\n\nLR_L=sorted(LR,key=lambda x: x[0],reverse=True)\nLR_R=sorted(LR,key=lambda x: x[1])\n\nANS_k=[0]*(RAN*2+2)\n\nfor i in range(RAN):\n ANS_k[2*i+1]=ANS_k[2*i]+LR_L[i][0]\n ANS_k[2*i+2]=ANS_k[2*i+1]-LR_R[i][1]\n\nprint(ANS_k)\nprint(max(ANS_k)*2)\n", "jacc_sim": 0.9285714285714286, "nl": "Takahashi and Aoki play a game using a number line and segments. Takahashi starts at coordinate 0 and Aoki has N segments, each defined by [L_i, R_i]. The game has N steps. Aoki selects a segment, and Takahashi moves within that segment. After N steps, Takahashi returns to coordinate 0. The goal is to find the total distance traveled by Takahashi (K). Aoki aims to maximize K, while Takahashi aims to minimize it. Constraints: 1 \u2264 N \u2264 10^5, -10^5 \u2264 L_i < R_i \u2264 10^5. Input format: N followed by N lines of L and R values. Output: Print the total distance traveled by Takahashi. The distance will always be an integer.", "before_after_length": [284, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03333", "p_user": "u327466606", "n_user": "u327466606", "pos": "N = int(input())\nL,R = [None]*N,[None]*N\nfor i in range(N):\n L[i],R[i] = map(int,input().split())\nL.append(0)\nR.append(0)\nL.sort(reverse=True)\nR.sort()\n\ndef it():\n for l,r in zip(L,R):\n if r < l:\n yield 2*(l-r)\n else:\n return\n\nprint(sum(it()))", "neg": "N = int(input())\nL,R = [None]*N,[None]*N\nfor i in range(N):\n L[i],R[i] = map(int,input().split())\nL.sort(reverse=True)\nR.sort()\n\ndef it():\n for l,r in zip(L,R):\n if r < l\n yield 2*(l-r)\n else:\n return\n\nprint(sum(it()))", "jacc_sim": 0.95, "nl": "Takahashi and Aoki play a game using a number line and segments. Takahashi starts at coordinate 0 and Aoki has N segments, each defined by [L_i, R_i]. The game has N steps. Aoki selects a segment, and Takahashi moves within that segment. After N steps, Takahashi returns to coordinate 0. The goal is to find the total distance traveled by Takahashi (K). Aoki aims to maximize K, while Takahashi aims to minimize it. Constraints: 1 \u2264 N \u2264 10^5, -10^5 \u2264 L_i < R_i \u2264 10^5. Input format: N followed by N lines of L and R values. Output: Print the total distance traveled by Takahashi. The distance will always be an integer.", "before_after_length": [125, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03334", "p_user": "u340781749", "n_user": "u340781749", "pos": "def check_odd(i, j):\n return (i + j) % 2 == 0\n\n\ndef check_even(i, j):\n return i % 2 == 0\n\n\ndef solve(n, d1, d2):\n s1, s2 = 0, 0\n while d1 % 4 == 0:\n d1 >>= 2\n s1 += 1\n while d2 % 4 == 0:\n d2 >>= 2\n s2 += 1\n\n f1 = check_odd if d1 % 2 else check_even\n f2 = check_odd if d2 % 2 else check_even\n lim = n ** 2\n\n buf = []\n cnt = 0\n for i in range(2 * n):\n _i1 = i >> s1\n _i2 = i >> s2\n for j in range(2 * n):\n if f1(_i1, j >> s1) and f2(_i2, j >> s2):\n buf.append('{} {}'.format(i, j))\n cnt += 1\n if cnt == lim:\n return buf\n\n\nn, d1, d2 = map(int, input().split())\nprint('\\n'.join(solve(n, d1, d2)))\n", "neg": "def check_odd(i, j):\n return (i + j) % 2 == 0\n\n\ndef check_even(i, j):\n return i % 2 == 0\n\n\ndef solve(n, d1, d2):\n s1, s2 = 0, 0\n while d1 % 4 == 0:\n d1 >>= 2\n s1 += 1\n while d2 % 4 == 0:\n d2 >>= 2\n s2 += 1\n\n f1 = check_odd if d1 % 2 else check_even\n f2 = check_odd if d2 % 2 else check_even\n lim = n ** 2\n\n buf = []\n cnt = 0\n for i in range(2 * n):\n _i1 = i >> s1\n _i2 = i >> s2\n for j in range(2 * n):\n if f1(_i1, j >> s1) and f2(_i2, j >> s2):\n buf.append('{} {}'.format(i, j))\n cnt += 1\n if cnt == lim:\n break\n return buf\n\n\nn, d1, d2 = map(int, input().split())\nprint('\\n'.join(solve(n, d1, d2)))\n", "jacc_sim": 0.9818181818181818, "nl": "Takahashi is researching sets of points in a plane. A set S of points is considered a \"good set\" if it satisfies two conditions: the distance between any two points in S is not \u221aD1 and not \u221aD2, where D1 and D2 are positive integer constants. Takahashi has proved that for any choice of D1 and D2, there exists a way to choose N^2 points from a set X of points (i, j) on a coordinate plane, where 0 \u2264 i, j < 2N, so that the chosen points form a good set. The task is to find a subset of X with N^2 points that forms a good set. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 D1 \u2264 2\u00d710^5, 1 \u2264 D2 \u2264 2\u00d710^5, and all input values are integers. The input is given in the format N D1 D2, and the output should be N^2 distinct points that satisfy the condition. Each point (x, y) must satisfy 0 \u2264 x, y < 2N and be printed in any order. If there are multiple possible solutions, any valid solution can be output.", "before_after_length": [300, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03334", "p_user": "u327466606", "n_user": "u327466606", "pos": "def judge(D):\n n = 0\n while D%4==0:\n n += 1\n D //= 4\n\n return (lambda x,y: ~((x>>n)^(y>>n))&1) if D%2==1 else (lambda x,y: ~(x>>n)&1)\n\nN,D1,D2 = map(int,input().split())\nj1,j2 = judge(D1),judge(D2)\nfor _,(x,y) in zip(range(N*N),filter(lambda p: j1(*p) and j2(*p), ((x,y) for x in range(N*2) for y in range(N*2)))):\n print(x,y)", "neg": "def judge(D):\n n = 0\n while D%4==0:\n n += 1\n D //= 4\n\n return lambda x,y: ~((x>>n)^(y>>n))&1 if D%2==1 else lambda x,y: ~(x>>n)&1\n\nN,D1,D2 = map(int,input().split())\nj1,j2 = judge(D1),judge(D2)\nfor _,(x,y) in zip(range(N*N),filter(lambda p: j1(*p) and j2(*p), ((x,y) for x in range(N*2) for y in range(N*2)))):\n print(x,y)", "jacc_sim": 1.0, "nl": "Takahashi is researching sets of points in a plane. A set S of points is considered a \"good set\" if it satisfies two conditions: the distance between any two points in S is not \u221aD1 and not \u221aD2, where D1 and D2 are positive integer constants. Takahashi has proved that for any choice of D1 and D2, there exists a way to choose N^2 points from a set X of points (i, j) on a coordinate plane, where 0 \u2264 i, j < 2N, so that the chosen points form a good set. The task is to find a subset of X with N^2 points that forms a good set. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 D1 \u2264 2\u00d710^5, 1 \u2264 D2 \u2264 2\u00d710^5, and all input values are integers. The input is given in the format N D1 D2, and the output should be N^2 distinct points that satisfy the condition. Each point (x, y) must satisfy 0 \u2264 x, y < 2N and be printed in any order. If there are multiple possible solutions, any valid solution can be output.", "before_after_length": [181, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u536034761", "n_user": "u536034761", "pos": "N = int(input())\nS = input()\nE = S.count(\"E\")\nW = 0\nans = N + 1\nfor s in S:\n if s == \"E\":\n E -= 1\n ans = min(W + E, ans)\n if s == \"W\":\n W += 1\nprint(ans)", "neg": "N = int(input())\nS = input()\nE = S.count(\"E\")\nW = 0\nans = N + 1\nfor s in S:\n if s == \"E\":\n E -= 1\n ans = min(W + E, ans)\n if s == \"W\":\n W -= 1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [79, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u696499790", "n_user": "u696499790", "pos": "N=int(input())\nS=list(input())\nnsums=[0]*N\n\nright =0\nfor s in S:\n if s=='E':right+=1\n\nleft =0\nmin_sum=N\nfor i in range(N):\n if S[i] == 'E':right-=1\n nsums[i] = right + left\n if S[i]=='W':left+=1\n\n min_sum = min(min_sum,nsums[i])\nprint(min_sum)", "neg": "N=int(input())\nS=list(input())\nnsums=[0]*N\n\nright =0\nfor s in S:\n if s=='E':right+=1\n\nleft =0\nmin_sum=N\nfor i in range(N):\n if S[i] == 'E':right-=1\n if S[i]=='W':left+=1\n nsums[i] = right + left\n min_sum = min(min_sum,nsums[i])\nprint(min_sum)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [129, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u373047809", "n_user": "u373047809", "pos": "from itertools import*\ninput();s = input()\nb, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans(\"EW\",\"01\"[::a])))))[:-1])[::a] for a in [-1,1]]\nprint(min(x+y for x, y in zip(b, c)))", "neg": "from itertools import*\n_, s = open(0)\nb, c = [([0]+list(accumulate(map(int, s[::a].translate(str.maketrans(\"EW\",\"01\"[::a])))))[:-1])[::a] for a in [-1,1]]\nprint(min(x+y for x, y in zip(b, c)))", "jacc_sim": 0.9024390243902439, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [87, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u244416763", "n_user": "u244416763", "pos": "n = int(input())\ns = str(input())\nW = [0]\nfor i in range(n):\n if s[i] == \"W\":\n W.append(W[-1]+1)\n else:\n W.append(W[-1])\n\nans = n\n\nfor i in range(n+1):\n ans = min(ans,W[i] + (n-i)-(W[-1] - W[i]))\nprint(ans)\n", "neg": "n = int(input())\ns = str(input())\nE = [0]\nW = [0]\n\nfor i in range(n):\n if s[i] == \"E\":\n E.append(E[-1]+1)\n W.append(W[-1])\n else:\n E.append(E[-1])\n W.append(W[-1]+1)\n\nE = E[1:]\nW = W[1:]\n\nans = n*2\n\nfor i in range(1,n-1):\n ans = min(ans,W[i-1]+(E[-1] - E[i+1]))\n\nprint(ans)", "jacc_sim": 0.90625, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [114, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u193264896", "n_user": "u193264896", "pos": "import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(readline())\n S = readline().decode('utf-8')\n L = len(S)\n A = [0]*L\n for i in range(L):\n if S[i] == 'E':\n if i == 0:\n A[i] = 1\n else:\n A[i]=A[i-1]+1\n else:\n if i == 0:\n continue\n else:\n A[i]=A[i-1]\n ans = INF\n for i in range(N):\n tmp = 0\n if i>0:\n tmp += i - A[i-1]\n if i0:\n tmp += i - A[i-1]\n if i1\u306e\u7d2f\u7a4d\u548c\uff0c[0]start\nfor i in range(1, N+1):\n j = 0\n if S[i-1] == \"W\":\n j = 1\n A[i]=A[i-1] +j\n#A =list(accumulate(A))\n#print(A)\n\n#i\u3088\u308a\u5de6\u306b\u3044\u3066\u897f\u3092\u5411\u3044\u3066\u3044\u308b\u4eba\u306e\u6700\u5c0f\u5024\nans=N\nfor i in range(1, N+1):\n val = N-i +A[i] -A[N]\n ans = min(ans, A[i-1] +val)\n\nprint(ans)", "neg": "from itertools import accumulate\n\nN = int(input())\nS = list(input())\n\nA = [0]*(N+1) #N+1\u307e\u3067\u5165\u308c\u308b\u3053\u3068\u5fd8\u308c\u305a\n\n#\u30ea\u30fc\u30c0\u30fc\u306e\u65b9\u5411\u3092\u5411\u304f\uff0cW->1\u306e\u7d2f\u7a4d\u548c\nfor i in range(1, N+1):\n j = 0\n if S[i-1] == \"W\":\n j = 1\n A[i]=A[i-1] +j\n#A =list(accumulate(A))\nprint(A)\n\n#\u3068\u3059\u308b\u3068i\u3088\u308a\u5de6\u306b\u3044\u3066\u897f\u3092\u5411\u3044\u3066\u3044\u308b\u4eba\u306e\u6700\u5c0f\u5024\nans=N\nfor i in range(N):\n val = N-i +A[i] -A[N]\n ans = min(ans, A[i-1] +val)\n\nif ans==0: #\u5265\u304f\u4eba\u3044\u306a\u3044\u3068\u304d1\n ans=1\n\nprint(ans)", "jacc_sim": 0.9315068493150684, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [304, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u754022296", "n_user": "u754022296", "pos": "n = int(input())\ns = input()\nl = [0]*n\nc = 0\nfor i in range(n-1):\n if s[i+1] == \"E\":\n c += 1\n if s[i] == \"E\":\n l[i+1] = l[i] - 1\n else:\n l[i+1] = l[i]\n else:\n if s[i] == \"W\":\n l[i+1] = l[i] + 1\n else:\n l[i+1] = l[i]\nans = min(l) + c\nprint(ans)", "neg": "n = int(input())\ns = input()\nl = [0]*n\nc = 0\nfor i in range(n-1):\n if s[i+1] == \"E\":\n c += 1\n if s[i] == \"E\":\n l[i+1] = l[i] - 1\n else:\n l[i+1] = l[i]\n else:\n if s[i+1] == \"W\":\n l[i+1] = l[i] + 1\n else:\n l[i+1] = l[i]\nans = min(l) + c\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [154, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u760794812", "n_user": "u760794812", "pos": "N = int(input())\nS = input()\nW = S.count('W')\nE = S.count('E')\ncounter = len(S)\ncost = E\nfor i in range(len(S)):\n if S[i] == 'E':\n cost -= 1\n if cost < counter:\n counter = cost\n else:\n if cost < counter:\n counter = cost\n cost +=1\nprint(counter)", "neg": "N = int(input())\nS = input()\nW = S.count('W')\nE = S.count('E')\ncounter = len(S)\ncost = E\nfor i in range(len(S)):\n if S[i] = 'E':\n cost -= 1\n if cost < counter:\n counter = cost\n else:\n cost +=1\nprint(counter)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [105, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u215743476", "n_user": "u215743476", "pos": "n = int(input())\ns = input()\n\nmin_n = s[1:].count('E')\ntmp_n = min_n\nfor i in range(1, n):\n tmp_n += s[i-1].count('W') - s[i].count('E')\n min_n = min(tmp_n, min_n)\n\nprint(min_n)", "neg": "n = int(input())\ns = input()\n\nmin_n = s[1:].count('E')\nfor i in range(1, n):\n tmp_n += s[i-1].count('W') - s[i].count('E')\n min_n = min(tmp_n, min_n)\n\nprint(min_n)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [93, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u471684875", "n_user": "u471684875", "pos": "n=int(input())\ns=str(input())\n\nl=[]\nc=s.count('E',1)\nfor i in range(1,n):\n if s[i-1]=='W':\n c+=1\n if s[i]=='E':\n c-=1\n l.append(c)\nprint(min(min(l),s.count('E')))\n", "neg": "n=int(input())\ns=str(input())\n\nl=[]\nc=s.count('E',1)\nfor i in range(1,n):\n if s[i-1]=='W':\n c+=1\n if s[i]=='E':\n c-=1\n l.append(c)\nprint(min(l))\n", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [98, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u948524308", "n_user": "u547608423", "pos": "N = int(input())\nS = input()\n\nlW = 0\nrE = S[1:N].count(\"E\")\nmi = lW + rE\nfor i in range(1, N):\n if S[i - 1] == \"W\":\n lW += 1\n if S[i] == \"E\":\n rE -= 1\n if lW + rE < mi:\n mi = lW + rE\n\nprint(mi)\n", "neg": "N=int(input())\nS=input()\nl=0\nr=S[1:].count(\"E\")\nprint(r)\nanswer=N\n\nfor i in range(N-1):\n if l+rtmp:\n ans = tmp\n\nprint(ans)", "neg": "N = int(input())\nline = input()\n\nans = line[1:N].count('E')\ntmp = ans\nfor i in range(1,N):\n if line[i] == 'E':\n tmp -= 1\n if line[i-1] == 'W':\n tmp += 1\n if ans>tmp:\n ans = tmp\n print(i)\n\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [88, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u329709276", "n_user": "u135116520", "pos": "N = int(input())\nS = input()\nE = S.count('E')\nW = 0\nresult = E\nfor i in range(N):\n if S[i] == 'E':\n E -= 1\n else:\n W += 1\n result = min(result,E+W)\nprint(result)", "neg": "N=int(input())\nS=input()\nDP=[0]**N\nDP[0]=S[1:].count(\"E\")\nfor i in range(1,N):\n if S[i]==\"E\":\n DP[i]=DP[i-1]-1+S[:i].count(\"W\")\n else:\n DP[i]=DP[i-1]+S[:i].count(\"W\")\nprint(min(DP))\n", "jacc_sim": 0.9032258064516129, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [78, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u373295322", "n_user": "u373295322", "pos": "input()\nss = input()\nloss = ss[1:].count(\"E\")\nmin_loss = loss\nss_before = ss[:-1]\nss_after = ss[1:]\nfor b, a in zip(ss_before, ss_after):\n loss += b == \"W\"\n loss -= a == \"E\"\n if loss < min_loss:\n min_loss = loss\nprint(\"{}\".format(min_loss))", "neg": "input()\nss = input()\nloss = ss[1:].count(\"E\")\nmin_loss = loss\nss_before = ss[:-1]\nss_after = ss[1:]\nfor b, a in zip(ss_before, ss_after):\n if b == \"E\":\n loss -=1\n else:\n loss +=1\n if a == \"W\":\n loss -=1\n else:\n loss +=1\n if loss < min_loss:\n min_loss = loss\nprint(\"{}\".format(min_loss))\n ", "jacc_sim": 0.9696969696969697, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [105, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u384679440", "n_user": "u378407062", "pos": "N = int(input())\nS = input()\n\nleft = 0\nright = S[1:].count('E')\nresult = left + right\n\nfor i in range(1, N):\n\tif S[i - 1] == \"W\":\n\t\tleft += 1\n\tif S[i] == \"E\":\n\t\tright -= 1\n\tresult = min(result, left + right)\nprint(result)", "neg": "N = int(input())\nS = input()\n \nans = len(S) - 1\nleft = 0\nright = S[0:].count(\"E\")\n\nfor i in range(1, N):\n if S[i - 1] == \"W\":\n left += 1\n if S[i] == \"E\":\n right -= 1 \n ans = min(ans, left + right)\nprint(ans)", "jacc_sim": 0.90625, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [98, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u301043830", "n_user": "u301043830", "pos": "N = input()\nS = list(input())\n\nlength = len(S)\nmin_num = 300000\nleft = 0\nright = S.count(\"E\")\n\nfor i in range(length):\n\n if i > 0:\n left += int(S[i - 1] == \"W\")\n\n if i < length:\n right -= int(S[i] == \"E\")\n\n if left + right < min_num:\n min_num = left + right\n\nprint(min_num)\n", "neg": "N = input()\nS = list(input())\n\nmin_num = 300000\nleft = 0\n\nfor i in range(len(S)):\n\n if i > 0:\n left += int(S[i] == \"W\")\n \n right = S[i+1: ].count(\"E\")\n\n if left + right < min_num:\n min_num = left + right\n\nprint(min_num)\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [124, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u710201258", "n_user": "u710201258", "pos": "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n\nn = input()\ns = input()\n \nprint(foo(s))", "neg": "def foo (s):\n ans = 0\n count = 0\n for i in s:\n if i == 'W':\n count += 1\n elif count :\n count -= 1\n ans += 1\n else:\n pass\n return ans\n\nn = input()\ns = input()\n \nprint(foo(s))", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u710201258", "n_user": "u710201258", "pos": "def foo (s):\n\tans = 0\n\tcount = 0\n\tfor i in s:\n\t\tif (not count) and (i == 'E'):pass\n\t\telif not count: count += 1\n\t\telif i == 'E': count -= 1; ans += 1\n\t\telse: count += 1\n\treturn ans\n\nn = input()\ns = input()\n\nprint(foo(s))", "neg": "def foo (s):\n\tans = 0\n\tcount = 0\n\tfor i in s:\n\t\tif (not count) and (i == 'E'):pass\n\t\telif not count: count += 1\n\t\telif i == 'E': count -= 1; ans += 1\n\t\telse: count += 1\n\treturn ans\n \n n = int(input())\n s = input()\n print(foo(s))", "jacc_sim": 0.9666666666666667, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [99, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u674569298", "n_user": "u674569298", "pos": "n = int(input())\na = list(input())\nfor i in range(n):\n if a[i] == 'E':\n a[i] = 1\n else:\n a[i] = 0\n\nans = 99999999999999999999\n# print(a)\nl = 0\nr = sum(a)\nfor i in range(n):\n\n if i == 0:\n if a[i] == 1:\n r -= a[i]\n a[i] = 0\n else:\n a[i] = 1\n l = 0\n else:\n if a[i] == 1:\n a[i] = 0\n r -= 1\n else:\n a[i] = 1\n l += a[i-1]\n\n ans = min(l+r,ans)\n # print(i,l,r,ans)\nprint(ans)\n\n", "neg": "n = int(input())\na = list(input())\nfor i in range(n):\n if a[i] == 'E':\n a[i] = 1\n else:\n a[i] = 0\n\nans = 99999999999999999999\n# print(a)\nl = 0\nr = sum(a)\nfor i in range(n):\n\n if i == 0:\n if a[i] == 1:\n r -= a[i]\n a[i] = 0\n else:\n a[i] = 1\n l = 0\n else:\n if a[i] == 1:\n a[i] = 0\n r -= 1\n else:\n a[i] = 1\n l += a[i-1]\n\n ans = min(l+r,ans)\n print(i,l,r,ans)\nprint(ans)\n\n", "jacc_sim": 1.0, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [219, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03341", "p_user": "u314057689", "n_user": "u314057689", "pos": "def solve():\n N = int(input())\n S = input()\n\n AW = [0]*(N+1)\n AE = [0]*(N)\n\n wcount = 0\n ecount = 0\n for i in range(N):\n if S[i] == \"W\":\n wcount += 1\n else:\n ecount += 1\n AW[i] = wcount\n AE[i] = ecount\n\n MIN = 1000000\n\n for i in range(N):\n tmp = 0\n tmp += AW[i-1]\n tmp += AE[-1] - AE[i]\n MIN = min(MIN, tmp)\n print(MIN)\n\nif __name__ == \"__main__\":\n solve()", "neg": "def solve():\n N = int(input())\n S = input()\n\n AW = [0]*(N+1)\n AE = [0]*(N)\n\n wcount = 0\n ecount = 0\n for i in range(N):\n if S[i] == \"W\":\n wcount += 1\n else:\n ecount += 1\n AW[i] = wcount\n AE[i] = ecount\n\n MIN = 1000000\n\n for i in range(N):\n tmp = 0\n tmp += AW[i-1]\n tmp += AE[-1] - AE[i]\n MIN = min(MIN, tmp)\n print(MIN)\n\nif __name__ == \"__main__\":\n local_test()\n solve()", "jacc_sim": 0.9736842105263158, "nl": "You are given a row of people facing either east or west. You need to appoint a leader and have the rest face the same direction as the leader. Find the minimum number of people who need to change their direction. Constraints: 2 \u2264 N \u2264 3 \u00d7 10^5, |S| = N, where S_i is either 'E' or 'W'. Input is given as N and the string S. Output the minimum number of people who need to change their direction. Example: For input 5 and \"WEEWW\", the output is 1.", "before_after_length": [186, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u707124227", "n_user": "u707124227", "pos": "def main(n,k,q,x):\n ret=float('inf')\n for xi in x:\n c=[]\n tmp=[]\n for y in x:\n if y=k:\n tmp.sort()\n for j in range(len(tmp)-k+1):\n c.append(tmp[j])\n tmp=[]\n else:\n tmp.append(y)\n if len(tmp)>=k:\n tmp.sort()\n for j in range(len(tmp)-k+1):\n c.append(tmp[j])\n if len(c)>=q:\n c.sort()\n ret=min(ret,c[q-1]-xi)\n return ret\n\n#n=int(input())\n#a=list(input())\n#a=list(map(int,input().split()))\n#b=list(map(int,input().split()))\n#ab=[list(map(int,input().split())) for _ in range(n)]\nn,k,q=map(int,input().split())\nx=list(map(int,input().split()))\nprint(main(n,k,q,x))\n", "neg": "def main(n,k,q,x):\n ret=float('inf')\n for i,xi in enumerate(x):\n c=[]\n tmp=[]\n for y in x:\n if y=k:\n tmp.sort()\n for j in range(len(tmp)-k+1):\n c.append(tmp[j])\n tmp=[]\n else:tmp.append(y)\n if len(tmp)>=k:\n tmp.sort()\n for j in range(len(tmp)-k+1):\n c.append(tmp[j])\n tmp=[]\n c.sort()\n print(xi,c)\n if len(c)>=q:ret=min(ret,c[q-1]-c[0])\n return ret\n\n#n=int(input())\n#a=list(input())\n#a=list(map(int,input().split()))\n#b=list(map(int,input().split()))\n#ab=[list(map(int,input().split())) for _ in range(n)]\nn,k,q=map(int,input().split())\nx=list(map(int,input().split()))\nprint(main(n,k,q,x))\n", "jacc_sim": 0.9423076923076923, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [301, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u227082700", "n_user": "u227082700", "pos": "n,k,q=map(int,input().split())\na=list(map(int,input().split()))\nans=10**10\nfor y in a:\n\tt=[[]]\n\tfor i in a:\n\t\tif i K-1:\n tmp2 += tmp[:tn-K+1]\n tmp = []\n continue\n tmp.append(x)\n tmp.sort()\n tn = len(tmp)\n if tn-K+1 > 0:\n tmp2 += tmp[:tn-K+1]\n tmp2.sort()\n if len(tmp2) >= Q:\n r = min(r, tmp2[Q-1] - y)\nprint(r)\n", "neg": "N, K, Q = map(int, input().split())\nX = list(map(int, input().split()))\n\nr = Y[Q-1] - Y[0]\nfor y in X:\n tmp = []\n tmp2 = []\n for x in X:\n if x < y:\n tmp.sort()\n tn = len(tmp)\n if len(tmp) > K-1:\n tmp2 += tmp[:tn-K+1]\n print(tmp, tmp[:tn-K+1])\n tmp = []\n continue\n tmp.append(x)\n tn = len(tmp)\n if tn-K+1 > 0:\n tmp2 += tmp[:tn-K+1]\n tmp2.sort()\n if len(tmp2) >= Q:\n r = min(r, tmp2[Q-1] - y)\nprint(r)\n", "jacc_sim": 0.9047619047619048, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [201, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u564902833", "n_user": "u564902833", "pos": "# \u5165\u529b\nN, K, Q = map(int, input().split())\nA = list(map(int, input().split()))\n\nINF = 10**20\n\n# Y = A_1, .., A_N \u306e\u3068\u304d\u306e X - Y \u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n# Y \u3092\u6c7a\u3081\u6253\u3064\u3068\u3001 X - Y \u306e\u6700\u5c0f\u5024\u306fO(NlogN)\u3067\u6c42\u3081\u3089\u308c\u308b\n\n\ndef f(b):\n i = 0\n T = []\n while i < N:\n S = []\n while i < N and A[i] >= b:\n S.append(A[i])\n i += 1\n if len(S) >= K:\n T.extend(sorted(S)[:(len(S) - K + 1)])\n i += 1\n return (\n sorted(T)[Q - 1] if len(T) >= Q else\n INF\n )\n\n\nans = min(f(a) - a for a in sorted(A))\n\n# \u51fa\u529b\nprint(ans)\n", "neg": "# \u5165\u529b\nN, K, Q = map(int, input().split())\nA = list(map(int, input().split()))\n\nINF = 10**20\n\n# Y = A_1, .., A_N \u306e\u3068\u304d\u306e X - Y \u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n# Y \u3092\u6c7a\u3081\u6253\u3064\u3068\u3001 X - Y \u306e\u6700\u5c0f\u5024\u306fO(NlogN)\u3067\u6c42\u3081\u3089\u308c\u308b\n\n\ndef f(b):\n i = 0\n T = []\n while i < N:\n S = []\n while i < N and A[i] >= b:\n S.append(A[i])\n i += 1\n if len(S) >= K:\n T.extend(sorted(S)[:(len(S) - K + 1)])\n i += 1\n return (\n sorted(T)[Q - 1] if len(T) >= Q else\n INF\n )\n\n\nans = min(f(b) - b for b in B)\n\n# \u51fa\u529b\nprint(ans)\n", "jacc_sim": 0.974025974025974, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [327, 325], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u098240946", "n_user": "u098240946", "pos": "N,K,Q = a = map(int,input().split())\na = list(map(int,input().split()))\ninf = 10**10\nans = inf\nfor i in range(N):\n small = a[i]\n seq = []\n seqq = []\n for j in range(N):\n if a[j] < small:\n seq.append(seqq)\n seqq = []\n else:\n seqq.append(a[j])\n seq.append(seqq)\n aaa = []\n for s in seq:\n if len(s)>=K:\n s.sort()\n aaa += s[:len(s)-K+1]\n if len(aaa)>=Q:\n aaa.sort()\n ans = min(ans,aaa[Q-1]-aaa[0])\nprint(ans)", "neg": "N,K,Q = a = map(int,input().split())\na = list(map(int,input().split()))\ninf = 10**10\nans = inf\nfor i in range(N):\n small = a[i]\n seq = []\n seqq = []\n for j in range(N):\n if a[j] < small:\n seq.append(seqq)\n seqq = []\n else:\n seqq.append(a[j])\n seq.append(seqq)\n aaa = []\n for s in seq:\n if len(s)>=K:\n s.sort()\n aaa += s[:len(s)-K+1]\n if len(aaa)>=Q:\n aaa.sort()\n ans = min(ans,aaa[Q-1]-aaa[0])\n print(i,a[i],aaa,ans)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [212, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u652498023", "n_user": "u652498023", "pos": "N, K, Q = map(int, input().split())\na = list(map(int, input().split()))\n\nd=[a]\na = sorted(a)\n\nans = a[Q-1] - a[0]\n\n\nwhile True:\n d_temp = list()\n sub_temp = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n sub_temp.append(c)\n else:\n d_temp.append(sub_temp)\n sub_temp = list()\n d_temp.append(sub_temp)\n sub_temp = list()\n\n d = list()\n a = list()\n for sub in d_temp:\n if len(sub) < K:\n continue\n else:\n d.append(sub)\n sub = sorted(sub)\n a.extend(sub[0:len(sub)-K+1])\n\n a.sort()\n\n if len(a) < Q:\n break\n else:\n ans = min(ans, a[Q-1] - a[0])\n\nprint(ans)\n", "neg": "N, K, Q = map(int, input().split())\na = list(map(int, input().split()))\n\nd=[a]\na = sorted(a)\n\nans = a[Q-1] - a[0]\n\n\nwhile True:\n d_temp = list()\n sub_temp = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n sub_temp.append(c)\n else:\n d_temp.append(sub_temp)\n sub_temp = list()\n d_temp.append(sub_temp)\n sub_temp = list()\n\n d = list()\n a = list()\n for sub in d_temp:\n if len(sub) < K:\n continue\n else:\n d.append(sub)\n sub = sorted(sub)\n a.extend(sub[0:len(sub)-K+1])\n\n a.sort()\n\n if len(a) < Q:\n break\n else:\n ans = min(ans, a[Q-1] - a[0])\n\n#print(ans)\n", "jacc_sim": 0.9777777777777777, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [279, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03343", "p_user": "u059727354", "n_user": "u652498023", "pos": "n, k, q = map(int, input().split())\na = list(map(int, input().split()))\n\nd = [a]\na = sorted(a)\nans = a[q - 1] - a[0]\n\nwhile True:\n newd = list()\n li = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n li.append(c)\n else:\n newd.append(li)\n li = list()\n newd.append(li)\n li = list()\n\n d = list()\n a = list()\n for li in newd:\n if len(li) < k:\n continue\n else:\n d.append(li)\n li = sorted(li)\n a.extend(li[0:len(li) - k + 1])\n \n a.sort()\n\n if len(a) >= q:\n ans = min(a[q - 1] - a[0], ans)\n else:\n break\nprint(ans)", "neg": "n, k, q = map(int, input().split())\na = list(map(int, input().split()))\n \nd = [a]\na.sort\nans = a[q - 1] - a[0]\n \nwhile True:\n newd = list()\n li = list()\n for sub in d:\n for c in sub:\n if c != a[0]:\n li.append(c)\n else:\n newd.append(li)\n li = list()\n newd.append(li)\n li = list()\n \n d = list()\n a = list()\n for li in newd:\n if len(li) < k:\n continue\n else:\n d.append(li)\n li.sort()\n a.extend(li[0:len(li) - k + 1])\n \n a.sort()\n \n if len(a) >= q:\n ans = min(a[q - 1] - a[0], ans)\n else:\n break\nprint(ans)\n", "jacc_sim": 0.9777777777777777, "nl": "You are given an integer sequence A of length N and an integer K. Perform Q operations on this sequence. In each operation, choose a contiguous subsequence of length K and remove the smallest element. Find the smallest possible difference between the largest and smallest elements removed. Constraints: 1 \u2264 N \u2264 2000, 1 \u2264 K \u2264 N, 1 \u2264 Q \u2264 N-K+1, 1 \u2264 Ai \u2264 10^9. Input format: N K Q followed by the sequence A. Output the smallest possible difference between the largest and smallest elements removed.", "before_after_length": [261, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u177756077", "n_user": "u863076295", "pos": "A,B,C,K=map(int,input().split())\nans=(A-B)*(-1)**K\nprint(ans)", "neg": "A,B,C,K = map(int,input().split())\nprint((B - A)*(-1)**K)", "jacc_sim": 0.9444444444444444, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [33, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u522726434", "n_user": "u922416423", "pos": "A, B, C, K = list(map(int, input().split()))\n\nif abs(A - B) > 10**18:\n print('Unfair')\nelse:\n print((A -B)*(-1)**K)", "neg": "A,B,C,K = map(int, input().split())\n\nif abs(A-B) > 10**(18):\n print(\"Unfair\")\nelse:print(A-B)", "jacc_sim": 0.9259259259259259, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [58, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u138486156", "n_user": "u169138653", "pos": "a, b, c, k = map(int, input().split())\nans = (a-b)*(-1)**k\nprint(ans)\n", "neg": "a,b,c,k=map(int,input().split())\nprint((a-b)*(-1)**(k-1))", "jacc_sim": 0.9444444444444444, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [35, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u536113865", "n_user": "u434208140", "pos": "a,b,c,k = map(int,input().split())\nprint((a-b)*(-1)**k)\n", "neg": "a,b,c,k=map(int,input().input())\nprint((a-b)*(-1)**k)", "jacc_sim": 0.9411764705882353, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [30, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u422104747", "n_user": "u422104747", "pos": "s=input().split()\nprint((int(s[0])-int(s[1]))*(-1)**int(s[3]))", "neg": "s=input().split()\nprint((int(s[0])-int(s[1]))*(-1)**s[3])", "jacc_sim": 1.0, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [33, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u729133443", "n_user": "u729133443", "pos": "a,b,c,k=map(int,input().split());print((-1)**k*(a-b))", "neg": "a,b,c,k=map(int,input().split());print(-1**k*(a-b))", "jacc_sim": 1.0, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [28, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u602860891", "n_user": "u883792993", "pos": "A, B, C, K = list(map(int, input().split()))\nanswer = (-1)**K * (A - B)\nprint(answer)\n", "neg": "A,B,C,K=list(map(int.input().split()))\nprint(((-1)**K)*(A-B))", "jacc_sim": 0.9473684210526315, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [39, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u906501980", "n_user": "u629350026", "pos": "a, b, c, k = map(int, input().split())\nprint((-1)**k*(a-b) if abs(a-b) <= 10**18 else \"Unfair\")", "neg": "a,b,c,k=map(int,input().split())\nif abs(a-b)<=10**18:\n print(abs(a-b))\nelse:\n print(\"Unfair\")", "jacc_sim": 0.9230769230769231, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [46, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03345", "p_user": "u957084285", "n_user": "u945418216", "pos": "a, b, c, k = map(int ,input().split())\nif abs(a-b) >10**18:\n print('Unfair')\nelse:\n print((a-b)*(-1)**k)", "neg": "a,b,c,k = map(int, input().split())\n\nx = a-b\nif abs(x)>10**18:\n print('Unfair')\nelse:\n print(x * -1**k)\n", "jacc_sim": 0.9629629629629629, "nl": "You are given three integers A, B, and C, belonging to Takahashi, Nakahashi, and Hikuhashi, respectively. After performing a specific operation K times, find the difference between the integer Takahashi will have and the integer Nakahashi will have. In each operation, they simultaneously calculate the sum of the integers that the other two people have and replace their own integer with the result. If the absolute value of the answer exceeds 10^18, print \"Unfair\". Constraints: 1 \u2264 A, B, C \u2264 10^9, 0 \u2264 K \u2264 10^18. Input format: A B C K. Output the difference after K operations. If the absolute value exceeds 10^18, print \"Unfair\". Example: Input: 1 2 3 1, Output: 1.", "before_after_length": [54, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u222668979", "n_user": "u222668979", "pos": "from collections import Counter\n\nn = int(input())\np = [int(input()) for _ in range(n)]\n\nlst = [False] * (n + 1)\nfor num in p:\n bfo = lst[num - 1]\n if bfo:\n lst[num] = bfo\n else:\n lst[num] = num\ncnt = Counter(lst).values()\nprint(n - max(cnt))\n", "neg": "from collections import Counter\n\nn = int(input())\np = [int(input()) for _ in range(n)]\n\nlst = [False] * (n + 1)\nfor num in p:\n bfo = lst[num - 1]\n if bfo:\n lst[num] = num\n else:\n lst[num] = bfo\ncnt = Counter(lst).values()\nprint(n - max(cnt))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [103, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u222668979", "n_user": "u222668979", "pos": "from collections import Counter\n\nn = int(input())\np = [int(input()) for _ in range(n)]\n\nlst = [-1] * (n + 1)\nfor num in p:\n bfo = lst[num - 1]\n if bfo == -1:\n lst[num] = num\n elif bfo > 0:\n lst[num] = bfo\ncnt = Counter(lst).values()\nprint(n - max(cnt))\n", "neg": "from collections import Counter\n\nn = int(input())\np = [int(input()) for _ in range(n)]\n\nlst = [-1] * (n + 1)\nfor num in p:\n bfo = lst[num - 1]\n if bfo == -1:\n lst[num] = num\n elif bfo > 0:\n lst[num] = num - 1\ncnt = Counter(lst).values()\nprint(n - max(cnt))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [110, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u054514819", "n_user": "u054514819", "pos": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\n\nQ = [0]*N\nfor i in range(N):\n p = int(input())\n Q[p-1] = i\n\ncnt = 0\nnow_idx = -1\nans = 0\nfor i in range(N):\n idx = Q[i]\n if idx>now_idx:\n cnt += 1\n ans = max(ans, cnt)\n else:\n cnt = 1\n now_idx = idx\n\nprint(N-ans)", "neg": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\n\nQ = [0]*N\nfor i in range(N):\n p = int(input())\n Q[p-1] = i\n\ncnt = 1\nnow_idx = -1\nans = 0\nfor i in range(N):\n idx = Q[i]\n if idx>now_idx:\n cnt += 1\n ans = max(ans, cnt)\n else:\n cnt = 1\n now_idx = idx\nprint(N-ans)\n ", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [163, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u801049006", "n_user": "u801049006", "pos": "n = int(input())\np = [int(input()) for _ in range(n)]\n\nq = [0] * (n+1)\nfor i in range(n):\n q[p[i]] = q[p[i]-1] + 1\n\nprint(n - max(q))\n", "neg": "n = int(input())\np = [int(input()) for _ in range(n)]\n\nq = [0] * (n+1)\nfor i in range(n):\n q[p[i]] = q[p[i]-1] + 1\n\nprint(q - max(q))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [73, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u674574659", "n_user": "u674574659", "pos": "N = int(input())\nP = [0]\nfor i in range(N):\n P.append(int(input()))\nQ = [0]*(N+1)\nfor i in range(1,N+1):\n Q[P[i]] = i\nres = Q[1]\ncnt = 0 \nc = 1\nfor i in range(2,N+1):\n if res < Q[i]:\n c += 1\n res = Q[i]\n if i == N:\n cnt = max(cnt,c)\n else:\n cnt = max(cnt,c)\n c = 1\n res = Q[i]\nans = N-cnt\nif N ==1:\n ans = 0 \nprint(ans) ", "neg": "N = int(input())\nP = [0]\nfor i in range(N):\n P.append(int(input()))\nQ = [0]*(N+1)\nfor i in range(1,N+1):\n Q[P[i]] = i\nres = Q[1]\ncnt = 0 \nc = 1\nfor i in range(2,N+1):\n if res < Q[i]:\n c += 1\n res = Q[i]\n if i == N:\n cnt = max(cnt,c)\n else:\n cnt = max(cnt,c)\n c = 1\n res = Q[i]\nprint(N-cnt) ", "jacc_sim": 0.9696969696969697, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [182, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = int(input())\nlis = [int(input()) for i in range(n)]\nli = [-1 for i in range(n)]\nfor i in range(n):\n li[lis[i]-1] = i\ncnt = 0\nans = n-1\nfor i in range(n-1):\n if li[i] < li[i+1]:\n cnt += 1\n else:\n ans = min(ans,n-1-cnt)\n cnt = 0\nans = min(ans,n-1-cnt)\nprint(ans)", "neg": "n = int(input())\nlis = [int(input()) for i in range(n)]\nli = [-1 for i in range(n)]\nfor i in range(n):\n li[lis[i]-1] = i\ncnt = 0\nans = n-1\nfor i in range(n-1):\n if li[i] > li[i+1]:\n cnt += 1\n else:\n ans = min(ans,n-1-cnt)\n cnt = 0\nans = min(ans,n-1-cnt)\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [136, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n p = IR(n)\n q = [None for i in range(n + 1)] + [-1]\n for i in range(n):\n q[p[i]] = i\n ans = 0\n tmp = 1\n for i in range(2, n + 2):\n if q[i - 1] < q[i]:\n continue\n ans = max(ans, i - tmp)\n tmp = i\n print(n-ans)\n return\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n p = IR(n)\n q = [None for i in range(n + 1)] + [-1]\n for i in range(n):\n q[p[i]] = 1\n ans = 0\n tmp = 0\n for i in range(2, n + 2):\n if q[i - 1] < q[i]:\n continue\n ans = max(ans, i - tmp)\n tmp = i\n print(n-ans)\n return\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [452, 452], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u547167033", "n_user": "u547167033", "pos": "n=int(input())\np=[int(input()) for _ in range(n)]\ndp=[0]*(n+10)\nfor i in p:\n dp[i]=dp[i-1]+1\nprint(n-max(dp))", "neg": "n=int(input())\np=[int(input()) for _ in range(n)]\ndp=[0]*(n+10)\nfor i in p:\n dp[p]=dp[p-1]+1\nprint(n-max(dp))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [59, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u346308892", "n_user": "u346308892", "pos": "N=int(input())\n\nq=[-1]*N\nfor i in range(N):\n k = int(input())\n #print(k)\n q[k-1]=i\n\n\nmax_con=1\ncount=1\nfor i in range(N-1):\n if q[i] 0:\n b[a[i]] = b[a[i]+1] + 1\n else:\n b[a[i]] = 1\n \n return N-max(b)\nprint(main())\n", "neg": "#N, *a = map(int, open(0).read().split())\ndef main():\n N = int(input())\n a=[]\n for i in range(N):\n a.append(int(input()))\n\n b = [0 for _ in range(N+1)]\n cnt = 1\n ans = 0\n flag = 1\n i = 0\n for i in reversed(range(N)):\n if b[a[i]+1] > 0:\n b[a[i]] = b[a[i]+1] + 1\n else:\n b[a[i]] = 1\n \n return N-max(b)\nprint(main())\n", "jacc_sim": 0.9761904761904762, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [167, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u711539583", "n_user": "u711539583", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\nmemo = [0 for i in range(n)]\nfor i in range(n):\n memo[int(input())-1] = i\ncand = 0\ntmp = 0\nfor n1, n2 in zip(memo[:], memo[1:]):\n if n2 > n1:\n tmp += 1\n if tmp > cand:\n cand = tmp\n else:\n tmp = 0\nprint(n - cand - 1)\n", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\nmemo = [0 for i in range(n)]\nfor i in range(n):\n memo[int(input())-1] = i\ncand = 0\ntmp = 0\nfor n1, n2 in range(n - 1):\n if n2 > n1:\n tmp += 1\n if tmp > cand:\n cand = tmp\n else:\n tmp = 0\nprint(n - cand - 1)", "jacc_sim": 0.9696969696969697, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [123, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u932465688", "n_user": "u932465688", "pos": "N = int(input())\nL = []\nfor i in range(N):\n L.append(int(input()))\nTF = [False]*(N+1)\ndp = [0]*(N+1)\nfor i in range(N):\n TF[L[i]] = True\n if TF[L[i]-1] == True:\n dp[L[i]] = dp[L[i]-1]+1\nprint(N-max(dp)-1)", "neg": "N = int(input())\nL = []\nfor i in range(N):\n L.append(int(input()))\nTF = [False]*(N+1)\ndp = [0]*(N+1)\nfor i in range(N):\n TF[L[i]] = True\n if TF[L[i]-1] == True:\n dp[L[i]] = dp[L[i]-1]+1\nprint(max(dp)+1)", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [114, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u075012704", "n_user": "u075012704", "pos": "N = int(input())\nP = [int(input()) for i in range(N)]\n\n\nQ = sorted([(p, i) for i, p in enumerate(P, start=1)])\nQ = [i for p, i in Q]\n\ndp = [1] * (N + 1)\nfor i in range(1, N):\n if Q[i] > Q[i - 1]:\n dp[i] = dp[i - 1] + 1\n\nprint(N - max(dp))\n", "neg": "N = int(input())\nP = [int(input()) for i in range(N)]\n\n\nQ = sorted([(p, i) for i, p in enumerate(P, start=1)])\nQ = [i for p, i in Q]\n\ndp = [1] * (N + 1)\nfor i in range(1, N):\n print(i)\n if Q[i] > Q[i - 1]:\n dp[i] = dp[i - 1] + 1\n\nprint(N - max(dp))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [122, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u054106284", "n_user": "u054106284", "pos": "N = int(input())\ndp = [0]*N\nfor i in range(N):\n dp[int(input())-1] = i\nans = 0\ncc = 0\nfor i in range(N-1):\n if dp[i] < dp[i+1]:\n cc += 1\n else:\n ans = max(cc, ans)\n cc = 0\nans = max(cc, ans)\nprint(N-ans-1)", "neg": "N = int(input())\ndp = [0]* (N)\nfor i in range(N):\n dp[int(input())-1] = i\nans = 0\ncc = 0\nfor i in range(N-1):\n if dp[i] < dp[i+1]:\n cc += 1\n else:\n ans = max(cc, ans)\n cc = 0\nans = max(cc, ans)\nprint(N-ans+1)", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [108, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u254022775", "n_user": "u254022775", "pos": "N = int(input())\na = [0 for i in range(N)]\nchain = [0 for i in range(N+1)]\nfor i in range(N):\n a[i] = int(input())\n chain[a[i]] = chain[a[i]-1]+1\nprint(N-max(chain))", "neg": "N = int(input())\na = [0 for i in range(N)]\nchain = [0 for i in range(N)]\nfor i in range(N):\n a[i] = int(input())\n chain[a[i]] = chain[a[i]-1]+1\nprint(max(chain))", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [79, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u982762220", "n_user": "u982762220", "pos": "N = int(input())\na = [0]\nfor _ in range(N):\n a.append(int(input()))\n\nQ = [0 for i in range(N + 1)]\nfor i in range(N + 1):\n Q[a[i]] = i\nans = 1\nnum = 1\n\nfor idx in range(2, len(Q)):\n if Q[idx - 1] < Q[idx]:\n num += 1\n else:\n ans, num = max(num, ans), 1\n\nprint(N - max(num, ans))\n", "neg": "N = int(input())\na = [0]\nfor _ in range(N):\n a.append(int(input()))\n\nQ = [0 for i in range(N + 1)]\nfor i in range(N + 1):\n Q[a[i]] = i\nans = 1\nnum = 0\n\nfor idx in range(2, len(a)):\n if a[idx - 1] < a[idx]:\n num += 1\n else:\n ans, num = max(num, ans), 1\n\nprint(N - max(num, ans))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [137, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u657541767", "n_user": "u657541767", "pos": "n = int(input())\np = [int(input()) for _ in range(n)]\nq = [0] * (n+1)\n\nfor i in range(n):\n q[p[i]] = i\nmaxl = 1\ncnt = 1\nfor i in range(1, n):\n if q[i+1] > q[i]:\n cnt += 1\n else:\n maxl = max(maxl, cnt)\n cnt = 1\nprint(n - max(maxl, cnt))\n", "neg": "n = int(input())\np = [int(input()) for _ in range(n)]\nq = [0] * (n+1)\n\nfor i in range(n):\n q[p[i]] = i\nmaxl = 0\ncnt = 0\nfor i in range(n):\n if q[i+1] > q[i]:\n cnt += 1\n else:\n maxl = max(maxl, cnt)\nprint(n - maxl)\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [124, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u876442898", "n_user": "u876442898", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nContents : AtCoder Grand Contest 024 B\u554f\u984c WA\nAuthor : Kitaura Hiromi\nLastUpdate : 20180520\nSince : 20180520\n\"\"\"\nN = int(input())\np = [int(input()) for i in range(N)]\nq = [0 for i in range(N)]\nfor i in range(N):\n q[p[i]-1] = i\n\ncnt = 1\nmax_cnt = 1\nfor i in range(N-1):\n if q[i+1] > q[i]:\n cnt += 1\n else:\n max_cnt = max(max_cnt, cnt)\n cnt = 1\nmax_cnt = max(max_cnt, cnt)\nprint(N - max_cnt)", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nContents : AtCoder Grand Contest 024 B\u554f\u984c WA\nAuthor : Kitaura Hiromi\nLastUpdate : 20180520\nSince : 20180520\n\"\"\"\nN = int(input())\np = [int(input()) for i in range(N)]\nq = [0] * N\nfor i in range(N):\n q[p[i]-1] = i\n\ncnt = 1\nfor i in range(N-1):\n if q[i+1] - q[i] > 0:\n cnt += 1\n else:\n max_cnt = max(max_cnt, cnt)\n cnt = 1\nprint(N - max_cnt)", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [205, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u394794741", "n_user": "u394794741", "pos": "N=int(input())\nP=[int(input()) for _ in range(N)]\nQ=[0 for _ in range(N)]\n\nfor i in range(N):\n Q[P[i]-1]=i\n\ncnt=0\ntmp=0\nfor i in range(N-1):\n if Q[i]0:\n k+=1\n else:\n s=max(s,k)\n k=1\ns=max(s,k)\nprint(n-s)", "neg": "def i1():\n return int(input())\ndef i2():\n return [int(i) for i in input().split()]\nn=i1()\np=[]\nq=[0 for i in range(n)]\nfor i in range(n): \n p.append(i1())\n q[p[-1]-1]=i\nk=1\ns=0\nwhile n-1>j:\n if q[i+1]-q[i]>0:\n k+=1\n else:\n s=max(s,k)\n k=1\n j+=1\ns=max(s,k)\nprint(n-s)", "jacc_sim": 0.9444444444444444, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [155, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u340781749", "n_user": "u340781749", "pos": "n = int(input())\nppp = list(map(int, (input() for _ in range(n))))\n\ntmp = [0] * (n + 1)\nfor p in ppp:\n tmp[p] = tmp[p - 1] + 1\n\nprint(n - max(tmp))\n", "neg": "n = int(input())\nppp = list(map(int, (input() for _ in range(n))))\n\ntmp = [0] * n\nfor p in ppp:\n tmp[p] = tmp[p - 1] + 1\n\nprint(n - max(tmp))\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [73, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u315838013", "n_user": "u315838013", "pos": "import sys\nif __name__ == \"__main__\":\n N = int(input())\n P = []\n Q = [0]*(N+1)\n for i in range(1, N+1):\n p = int(input())\n Q[p] = i\n\n # 1 4 5 2 3 -> 4 5\u3092\u79fb\u52d5\n # 1 4 5 3 2 -> 3 4 5 \u3092\u79fb\u52d5\n # 5 2 1 3 4 -> 1 5 \u3092\u79fb\u52d5\n cur = 1\n max_cur = 1\n for i in range(1, N):\n if Q[i] < Q[i+1]:\n cur += 1\n max_cur = max(cur, max_cur)\n else:\n cur = 1\n print(N - max_cur)\n", "neg": "import sys\nif __name__ == \"__main__\":\n N = int(input())\n P = []\n Q = [0]*(N+1)\n for i in range(N):\n p = int(input())\n Q[p] = i\n\n # 1 4 5 2 3 -> 4 5\u3092\u79fb\u52d5\n # 1 4 5 3 2 -> 3 4 5 \u3092\u79fb\u52d5\n # 5 2 1 3 4 -> 1 5 \u3092\u79fb\u52d5\n cur = 1\n max_cur = 1\n for i in range(1, N):\n if Q[i] < Q[i+1]:\n cur += 1\n max = max(cur, max_cur)\n else:\n cur = 1\n print(N - max_cur)", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [206, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u846150137", "n_user": "u846150137", "pos": "n=int(input())\na=[int(input()) for i in range(n)]\n\nal= {}\nans=0\nfor ai in a:\n if ai - 1 in al.keys():\n al[ai]=al[ai-1]+1\n ans=max(ans,al[ai-1]+1) \n del al[ai-1]\n else:\n al[ai]=0\n if ai + 1 in al.keys():\n del al[ai]\nprint(n-ans-1)", "neg": "n=int(input())\na=[int(input()) for i in range(n)]\n\nal= {}\nds=[]\nans=0\nfor ai in a:\n ds=\n if ai - 1 in al.keys():\n al[ai]=al[ai-1]+1\n ans=max(ans,al[ai-1]+1) \n del al[ai-1]\n else:\n al[ai]=0\n if ai + 1 in al.keys():\n del al[ai]\nprint(n-ans-1)", "jacc_sim": 0.96875, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [124, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u297574184", "n_user": "u297574184", "pos": "N = int(input())\n\nPs = [(int(input()), i) for i in range(N)]\nPs.sort()\n\nnum = 0\nans = 0\nfor i in range(N - 1):\n if Ps[i][1] < Ps[i + 1][1]:\n num += 1\n else:\n ans = max(ans, num)\n num = 0\n \nans = max(ans, num)\nprint(N - ans - 1)\n", "neg": "N = int(input())\n\nPs = [(int(input()), i) for i in range(N)]\nPs.sort()\n\nprint(Ps)\n\nnum = 0\nans = 0\nfor i in range(N - 1):\n if Ps[i][1] < Ps[i + 1][1]:\n num += 1\n else:\n ans = max(ans, num)\n num = 0\n \nans = max(ans, num)\nprint(N - ans - 1)\n", "jacc_sim": 1.0, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [113, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u657357805", "n_user": "u657357805", "pos": "def main():\n N=int(input())\n p=[False]*(N+1)\n c=[False]*(N+1)\n for i in range(N):\n x=int(input())\n c[x]=True\n if c[x-1]:\n p[x-1] = True\n ans=0\n j=0\n for i in range(1,N+1):\n if p[i]:\n j+=1\n else:\n ans=max(ans,j)\n j=0\n ans=max(ans,j)\n print(N-ans-1)\n\nif __name__ == \"__main__\":\n main()\n", "neg": "def main():\n N=int(input())\n P=[0]*N\n p=[False]*(N+1)\n P[0]=int(input())\n for i in range(N-1):\n P[i+1=int(input())\n if P[-1]-1 in P[:-1]:\n p[P[-1]-1] = True\n ans=0\n j=0\n for i in range(N):\n if p[i]==True:\n j+=1\n else:\n ans=max(ans,j)\n j=0\n print(N-ans-1)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [168, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03346", "p_user": "u066337396", "n_user": "u066337396", "pos": "\n\ndef main():\n n = int(input())\n pp = []\n for _ in range(n):\n pp.append(int(input()))\n dd = {}\n for i in range(n):\n dd[pp[i]] = i\n\n xx = [-1] * n\n for s in range(n - 1, -1, -1):\n if xx[s] >= 0:\n continue\n count = 1\n pre = pp[s]\n while pre + 1 in dd and dd[pre + 1] > s:\n i = dd[pre + 1]\n if xx[i] >= 0:\n xx[s] = xx[i] + count\n break\n pre += 1\n count += 1\n else:\n xx[s] = count\n print(n - max(xx))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "\n\ndef main():\n n = int(input())\n pp = []\n for _ in range(n):\n pp.append(int(input()))\n dd = {}\n for i in range(n):\n dd[pp[i]] = i\n\n xx = [-1] * n\n for s in range(n - 1, -1, -1):\n if xx[s] >= 0:\n continue\n count = 1\n pre = pp[s]\n while pre + 1 in dd:\n i = dd[pre + 1]\n if xx[i] < 0:\n xx[s] = xx[i] + count\n break\n pre = pp[i]\n count += 1\n else:\n xx[s] = count\n print(n - max(xx))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9555555555555556, "nl": "You are given a sequence (P_1,P_2,...,P_N) which is a permutation of the integers from 1 through N. Sort this sequence in ascending order by choosing an element and moving it to the beginning or the end of the sequence. Find the minimum number of operations required. Constraints: 1 \u2264 N \u2264 2\u00d710^5, (P_1,P_2,...,P_N) is a permutation of (1,2,...,N), and all values in input are integers. Input is given in the format: N, P_1, P_2, ..., P_N. Output the minimum number of operations required. Example: For input 4, the output is 2.", "before_after_length": [218, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u174404613", "n_user": "u174404613", "pos": "n=int(input())\nl=[int(input()) for _ in range(n)]\nans=0\nif l[0]!=0:\n print(-1)\n exit()\nfor i in range(n-1):\n if l[i+1]-l[i]>1:\n print(-1)\n exit()\n elif (l[i]+1==l[i+1]):\n ans+=1\n else:\n ans+=l[i+1]\nprint(ans)\n", "neg": "n=int(input())\nl=[int(input()) for _ in range(n)]\nans=0\nif l[0]!=0:\n print(-1)\n exit()\nfor i in range(n-1):\n if l[i+1]-l[i]>1:\n print(-1)\n exit()\n elif (l[i]+1==l[i+1]):\n ans+=1\n else:\n\tans+=l[i+1]\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [125, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u222668979", "n_user": "u222668979", "pos": "n = int(input())\na = [int(input()) for _ in range(n)]\n\nans, tmp, flag = 0, 0, (a[0] > 0)\nfor i in range(n - 1, 0, -1):\n if a[i] - a[i - 1] > 1:\n print(-1)\n break\n elif tmp != a[i]:\n ans += a[i]\n tmp = max(a[i] - 1, 0)\nelse:\n print(-1 if flag else ans)\n", "neg": "n = int(input())\na = [int(input()) for _ in range(n)]\n\nans, tmp, flag = 0, 0, (a[0] == 0)\nfor i in range(n - 1, 0, -1):\n if a[i] - a[i - 1] > 1:\n frag = False\n elif tmp != a[i]:\n ans += a[i]\n tmp = max(a[i] - 1, 0)\nelse:\n print(-1 if flag else ans)\n", "jacc_sim": 0.9090909090909091, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [128, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u520276780", "n_user": "u520276780", "pos": "#\u89e3\u8aac\u53c2\u7167\nimport sys\nn,*a,=map(int, sys.stdin.read().split())\nif a[0]:\n print(-1)\n exit()\n\nans=0\nfor i in range(n-1):\n if a[i+1]>a[i]+1:\n print(-1)\n exit()\n if a[i+1]-a[i]==1:\n ans+=1\n else:####\n ans+=a[i+1]\n\nprint(ans)", "neg": "#\u89e3\u8aac\u53c2\u7167\nimport sys\nn,*a,=map(int, sys.stdin.read().split())\nif a[0]:\n print(-1)\n exit()\n\nans=0\nfor i in range(1,n-1):\n if a[i+1]>a[i]+1:\n print(-1)\n exit()\n if a[i+1]-a[i]:\n ans+=1\n else:####\n ans+=a[i+1]\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [137, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = int(input())\nlis = [int(input()) for i in range(n)]\nif lis[0] != 0:print(-1);exit()\nans = 0\nfor i in range(n-1,0,-1):\n if lis[i] - lis[i-1] > 1:print(-1);exit()\n elif lis[i] - lis[i-1] == 1:ans += 1\n else:ans += lis[i]\nprint(ans)", "neg": "n = int(input())\nlis = [int(input()) for i in range(n)]\nif lis[0] != 0:print(-1);exit()\nans = 0\nfor i in range(n-1,0,-1):\n if lis[i-1] - lis[i] > 1:print(-1);exit()\n elif lis[i-1] - lis[i] == 1:ans += 1\n else:ans += lis[i]\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [120, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n a = IR(n)\n if a[0] != 0:\n print(-1)\n return\n ans = 0\n tmp = 0\n for i in a:\n if tmp + 1 == i:\n tmp += 1\n continue\n if tmp >= i:\n ans += tmp\n tmp = i\n else:\n print(-1)\n return\n print(ans + tmp)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n a = IR(n)\n if a[0] != 0:\n print(-1)\n ans = 0\n tmp = 0\n for i in a:\n if tmp + 1 == i:\n tmp += 1\n continue\n if tmp >= i:\n ans += tmp\n tmp = i\n else:\n print(-1)\n return\n print(ans + tmp)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [442, 439], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u672475305", "n_user": "u672475305", "pos": "n = int(input())\nA = [int(input()) for _ in range(n)]\nans = 0\nprev = 0\nif A[0]!=0:\n print(-1)\n exit()\nfor i in range(n):\n a = A[i]\n if prev == None and a!=0:\n ans = -1\n break\n if prev != None:\n dif = a-prev\n if dif >= 2:\n ans = -1\n break\n elif dif<=0:\n ans += prev\n prev = a\nif ans!=-1:\n ans += prev\nprint(ans)", "neg": "n = int(input())\nA = [int(input()) for _ in range(n)]\nans = 0\nprev = 0\nfor i in range(n):\n a = A[i]\n if prev == None and a!=0:\n ans = -1\n break\n if prev != None:\n dif = a-prev\n if dif >= 2:\n ans = -1\n break\n elif dif<=0:\n ans += prev\n prev = a\nif ans!=-1:\n ans += prev\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [151, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\na = []\nfor _ in range(N): a.append(int(input()))\nif a[0] != 0:\n print(-1)\n exit(0)\nfor i in range(N - 1):\n if a[i + 1] > a[i] and (a[i + 1] - a[i] > 1):\n print(-1)\n exit(0)\nres = 0\ns = 0\nx = 1\nfor i in range(1, N):\n if a[i] == x:\n s += 1\n else:\n if x > 0: res += (s - 1) * x + 1\n if x > a[i] and a[i] > 1:\n res += a[i] - 1\n s = 1\n x = a[i]\n #print(i, res)\nif x > 0: res += (s - 1) * x + 1\nprint(res)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\na = []\nfor _ in range(N): a.append(int(input()))\nif a[0] != 0:\n print(-1)\n exit(0)\nfor i in range(N - 1):\n if a[i + 1] > a[i] and (a[i + 1] - a[i] > 1):\n print(-1)\n exit(0)\nres = 0\ns = 0\nx = 1\nfor i in range(1, N):\n if a[i] == x:\n s += 1\n else:\n if x > 0: res += (s - 1) * x + 1\n if x > a[i]:\n res += a[i] - 1\n s = 1\n x = a[i]\n #print(i, res)\nif x > 0: res += (s - 1) * x + 1\nprint(res)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [242, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u670180528", "n_user": "u670180528", "pos": "n, *a = map(int, open(0).read().split())\nans = 0\nif a[0] != 0:\n\tprint(-1)\n\texit()\nfor x, y in zip(a, a[1:]+[0]):\n\tif x + 1 < y:\n\t\tprint(-1)\n\t\texit()\n\tif x >= y:\n\t\tans += x\nprint(ans)\n", "neg": "n, *a = map(int, open(0).read().split())\nans = 0\nif a[0] != 0:\n\tprint(-1)\n\texit()\nfor x, y in zip(a, a[1:]):\n\tif x + 1 < y:\n\t\tprint(-1)\n\t\texit()\n\tif x >= y:\n\t\tans += x\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [99, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u410118019", "n_user": "u410118019", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ncur = -1\nc = 0\nfor i in a:\n pre,cur = cur,i\n if cur == 0:\n continue\n elif cur == pre + 1:\n c += 1\n elif cur <= pre:\n c += cur\n else:\n print(-1)\n exit()\nprint(c)", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ncur = -1\nc = 0\nfor i in a:\n pre,cur = cur,i\n if cur == 0:\n continue\n elif cur <= pre + 1:\n c += 1\n else:\n print(-1)\n exit()\nprint(c)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [112, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u940061594", "n_user": "u940061594", "pos": "#Sequence Growing Easy\n\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = [int(input()) for i in range(N)]\n\njudge = 1\nfor i in range(N):\n if i != N-1:\n if A[i+1] <= A[i]+1 and A[i] <= i:\n pass\n else:\n judge = 0\n else:\n if A[i] <= i:\n pass\n else:\n judge = 0\n\nif judge == 0:\n print(-1)\nelse:\n n = 1\n if A[N-1] == 0:\n n = 0\n for i in range(N-1):\n if A[(N-2)-i] == 0:\n n = n\n elif A[(N-2)-i] < A[(N-1)-i] and A[(N-2)-i] != 0:\n n = n + 1\n elif A[(N-2)-i] == A[(N-1)-i] and A[(N-2)-i] != 0:\n n = n + A[(N-2)-i]\n elif A[(N-2)-i] > A[(N-1)-i] and A[(N-1)-i] != 0:\n n = n + A[(N-1)-i]\n else:\n n = n + 1\n print(int(n))", "neg": "#Sequence Growing Easy\n\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = [int(input()) for i in range(N)]\n\njudge = 1\nfor i in range(N):\n if i != N-1:\n if A[i+1] <= A[i]+1 and A[i] <= i:\n pass\n else:\n judge = 0\n else:\n if A[i] <= i:\n pass\n else:\n judge = 0\n\nif judge == 0:\n print(-1)\nelse:\n n = 1\n for i in range(N-1):\n if A[(N-2)-i] == 0:\n n = n\n elif A[(N-2)-i] < A[(N-1)-i] and A[(N-2)-i] != 0:\n n = n + 1\n elif A[(N-2)-i] == A[(N-1)-i] and A[(N-2)-i] != 0:\n n = n + A[(N-2)-i]\n else:\n n = n + A[(N-1)-i]\n print(int(n))", "jacc_sim": 0.9743589743589743, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [359, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u373958718", "n_user": "u373958718", "pos": "n=int(input());ans=0\nl=[int(input()) for i in range(n)]\nif l[0]!=0:\n print(-1);exit()\nfor i in range(n-1):\n if l[i+1]>l[i]+1:\n print(-1);exit()\nfor i in range(1,n):\n if l[i]==l[i-1]+1:\n ans+=1\n else:\n ans+=l[i]\nprint(ans)", "neg": "n=int(input());ans=0\nl=[int(input()) for i in range(n)]\nif l[0]!=0:\n print(-1);exit\nfor i in range(n-1):\n if l[i+1]>l[i]+1:\n print(-1);exit\nfor i in range(1,n):\n if l[i]==l[i-1]+1:\n ans+=1\n else:\n ans+=l[i]\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [125, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u476604182", "n_user": "u476604182", "pos": "N = int(input())\nls = [-1]\nfor i in range(N):\n ls += [int(input())]\n\nans = 0\np = 0\nfor i in range(1,N+1):\n if ls[i-1]+1 t:\n ans += num_list[i]\n t = num_list[i]\n elif num_list[i] < t:\n ans = -1\n break\n\nif t != 0:\n ans = -1\nprint(ans)", "neg": "n = int(input())\nnum_list = [ int(input()) for i in range(n) ]\nnum_list.reverse()\n\nans = 0\nt = 0\nfor i in range(n):\n t = max(t-1, 0)\n if num_list[i] != 0 and num_list[i] > t:\n ans += num_list[i]\n t = num_list[i]\n elif num_list[i] != 0 and num_list[i] < t:\n ans = 0\n break\n\nif t != 0:\n ans = 0\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [141, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u543954314", "n_user": "u543954314", "pos": "n = int(input())\na = [int(input()) for _ in range(n)]\nif a[0] != 0:\n print(-1)\n exit(0)\ncnt = 0\ncur = 0\nfor i in range(n-1,-1,-1):\n if cur > a[i]:\n print(-1)\n exit(0)\n if cur < a[i]:\n cur = a[i]\n cnt += a[i]\n if cur > 0:\n cur -= 1\nprint(cnt)", "neg": "n = int(input())\na = [int(input()) for _ in range(n)]\nfor i in range(1,n):\n if a[i]-a[i-1] > 1:\n print(-1)\n exit(0)\ncnt = 0\ncur = 0\nfor i in range(n-1,-1,-1):\n if cur < a[i]:\n cur = a[i]\n cnt += a[i]\n if cur:\n cur -= 1\nprint(cnt)", "jacc_sim": 0.9642857142857143, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [129, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u091051505", "n_user": "u091051505", "pos": "n = int(input())\na = []\nans = 0\nfor _ in range(n):\n a.append(int(input()))\nif a[0] != 0:\n ans = -1\nelse:\n for i in range(n - 1):\n if (a[i+1] - a[i]) > 1:\n ans = -1\n break\n else:\n if a[i+1] == a[i]:\n if a[i+1] > 0:\n ans += a[i+1] - 1\n if a[i+1] > 0:\n ans += 1\n if a[i+1] < a[i]:\n if a[i+1] > 1:\n ans += a[i+1] - 1\n \nprint(ans)", "neg": "n = int(input())\na = []\nans = 0\nfor _ in range(n):\n a.append(int(input()))\nif a[0] != 0:\n ans = -1\nelse:\n for i in range(n - 1):\n if (a[i+1] - a[i]) > 1:\n ans = -1\n break\n else:\n if a[i+1] == a[i]:\n if a[i+1] > 0:\n ans += a[i+1] - 1\n if a[i+1] > 0:\n ans += 1\n if a[i+1] < a[i]:\n ans += a[i+1] - 1\n \nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [193, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u163320134", "n_user": "u163320134", "pos": "n=int(input())\narr=[int(input()) for _ in range(n)]\nl=0\nflag=True\nfor i in range(n):\n if arr[i]==0:\n l=1\n else:\n if arr[i]>l:\n flag=False\n break\n l+=1\n if i!=0:\n if arr[i]-arr[i-1]>=2:\n flag=False\n break\nif flag==False:\n print(-1)\nelse:\n ans=arr[-1]\n tmp=arr[-1]\n for i in range(n-2,-1,-1):\n if arr[i]l:\n flag-False\n break\n l+=1\nif flag==False:\n print(-1)\nelse:\n ans=arr[-1]\n tmp=arr[-1]\n for i in range(n-2,-1,-1):\n if arr[i]==tmp:\n ans+=arr[i]\n else:\n tmp=arr[i]\n print(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [216, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u177132624", "n_user": "u177132624", "pos": "N = int(input())\nl =[]\n#deal with error\nfor i in range(N):\n l.append(int(input()))\n if i == 0 and l[i]!=0:\n print(-1)\n exit()\n if i>=1:\n if l[i]-l[i-1]>1 :\n print(-1)\n exit()\n \nans = 0\npre = -1\nfor a in l[::-1]:\n if pre - 1 != a:\n ans += a\n pre = a\nprint(ans)", "neg": "N = int(input())\nl =[]\n#deal with error\nfor i in range(N):\n l.append(int(input()))\n if i == 0 and l[i]!=0:\n print(-1)\n break\n if i>=1:\n if l[i]-l[i-1]>1 :\n print(-1)\n break\n\nans = 0\npre = -1\nfor a in l[::-1]:\n if pre - 1 != a:\n ans += a\n pre = a\n \nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [140, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u223904637", "n_user": "u223904637", "pos": "n=int(input())\nli=[0]*n\nfor i in range(n):\n li[i]=int(input())\nfl=0\nans=0\nif li[0]!=0:\n fl+=1\nfor i in range(n-1):\n if li[i]>=li[i+1]:\n ans+=li[i]\n if li[i+1]-li[i]>1:\n fl+=1\nif fl>0:\n print(-1)\nelse:\n print(ans+li[n-1])\n \n", "neg": "n=int(input())\nli=[0]*n\nfor i in range(n):\n li[i]=int(input())\nfl=0\nans=0\nif li[0]!=0:\n fl+=1\nfor i in range(n-1):\n if li[i]>=li[i+1]:\n ans+=li[i]\n if li[i+1]-li[i]>1:\n fl+=1\nif fl>0:\n print(-1)\nelse:\n print(ans)\n ", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [142, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u536113865", "n_user": "u536113865", "pos": "n = int(input())\nx = [int(input()) for _ in range(n)]\nf = 0\n\nif x[0]>0: f = 1\nfor i in range(n-1):\n if x[i]+1 < x[i+1]: f = 1\nimport sys\nif f:\n print(-1)\n sys.exit()\nans = 0\nfor i in range(n-1):\n if x[i+1] == x[i]+1:\n ans += 1\n else:\n ans += x[i+1]\nprint(ans)", "neg": "n = int(input())\nx = [int(input()) for _ in range(n)]\nf = 0\n\nif x[0]>0: f = 1\nfor i in range(n-1):\n if x[i]+1 < x[i+1]: f = 1\nimport sys\nif f:\n print(-1)\n sys.exit()\nans = 0\nfor i in range(n-1):\n if x[i+1] == x[i]+1:\n ans += 1\n else:\n ans += x[i+1]\n print(ans)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [139, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u339025042", "n_user": "u339025042", "pos": "\nN = int(input())\nA = [int(input()) for _ in range(N)]\n \nif A[0] != 0:\n print(-1)\n\nelse:\n roop = 0\n for i in range(1,N):\n num = A[i]\n if num == A[i-1]+1:\n roop += 1\n elif num <= A[i-1]:\n roop += num\n else:\n roop = -1\n break\n print(roop)\n ", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\n \nif A[0] != 0:\n print(-1)\n\nelse:\n roop = 0\n for i in range(1,N):\n num = A[i]\n if num == A[i-1]+1:\n roop += 1\n elif num == A[i-1]:\n roop += num\n elif num == 0:\n continue\n else:\n roop = -1\n break\n print(roop)\n ", "jacc_sim": 0.9333333333333333, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [127, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u786607349", "n_user": "u786607349", "pos": "n = int(input())\na = []\nans = 0\nflag = True\nfor i in range(n):\n A = int(input())\n a.append(A)\nnext = 0\nfor i in range(n-1,-1,-1):\n if next - a[i] >= 2:\n flag = False\n break\n if a[i] == 0:\n next = 0\n continue\n if next - a[i] == 1:\n next = a[i]\n continue\n next = a[i]\n ans += a[i]\nif a[0] != 0:\n flag = False\nif flag:\n print(ans)\nelse:\n print(-1)\n", "neg": "n = int(input())\na = []\nans = 0\nflag = True\nfor i in range(n):\n A = int(input())\n a.append(A)\nnext = 0\nfor i in range(n-1,-1,-1):\n if a[i] == 0:\n next = 0\n continue\n if next - a[i] == 1:\n next = a[i]\n continue\n if next - a[i] >= 2:\n flag = False\n break\n next = a[i]\n ans += a[i]\nif a[0] != 0:\n flag = False\nif flag:\n #print(ans)\nelse:\n #print(-1)\nprint(-1)\n", "jacc_sim": 0.9722222222222222, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [173, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u738835924", "n_user": "u738835924", "pos": "N = int(input())\n\nstart = int(input())\nflag = 0\nif start != 0:\n flag = 1\nt = 0\n\nfor i in range(N-1):\n k = int(input())\n if k == start:\n t += start\n elif k == start + 1:\n t += 1\n start = k\n elif k == 0:\n start = 0\n elif k > start + 1:\n t = -1\n break\n else:\n t += k\n start = k\n\nif flag ==1:\n t = -1\nprint(t)", "neg": "N = int(input())\n\nstart = int(input())\nt = 0\n\nfor i in range(N-1):\n k = int(input())\n if k == start:\n t += start\n elif k == start + 1:\n t += 1\n start = k\n elif k == 0:\n start = 0\n elif k > start + 1:\n t = -1\n break\n else:\n t += k\n start = k\n\nprint(t)", "jacc_sim": 0.9230769230769231, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [137, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u926295427", "n_user": "u926295427", "pos": "#!python\n# -*- coding: utf-8 -*-\n\n\ndef main():\n N = int(input())\n A = [int(input()) for i in range(N)]\n X = [0 for i in range(N)]\n A += [0]\n X += [0]\n\n count = 0\n\n if A[0] != 0:\n print(-1)\n return\n\n for i in range(N - 1, -1, -1):\n if A[i - 1] + 1 < A[i]:\n print(-1)\n return\n\n X[i] = max(0, X[i + 1] - 1)\n if A[i] == X[i]:\n continue\n\n count += A[i]\n X[i] = A[i]\n\n print(count)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!python\n# -*- coding: utf-8 -*-\n\n\ndef main():\n N = int(input())\n A = [int(input()) for i in range(N)]\n X = [0 for i in range(N)]\n\n if A[0] != 0:\n print(-1)\n return\n\n count = 0\n\n for i in range(N - 1, -1, -1):\n X[i] = X[i + 1] - 1\n if A[i] == X[i]:\n continue\n\n count += A[i]\n X[i] = A[i]\n\n print(count)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9487179487179487, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [222, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03347", "p_user": "u729707098", "n_user": "u729707098", "pos": "n = int(input())\na = [int(input()) for i in range(n)]\nans,flag = 0,True\nif a[0]!=0: flag = False\nfor i in range(n-1):\n\tif a[i]+1==a[i+1]: ans+=1\n\telif a[i]>=a[i+1]: ans+=a[i+1]\n\telse:\n\t\tflag = False\n\t\tbreak\nif flag: print(ans)\nelse: print(-1)", "neg": "n = int(input())\na = [int(input()) for i in range(n)]\nans,flag = 0,True\nfor i in range(n-1):\n\tif a[i]+1==a[i+1]: ans+=1\n\telif a[i]>=a[i+1]: ans+=a[i+1]\n\telse:\n\t\tflag = False\n\t\tbreak\nif flag: print(ans)\nelse: print(-1)", "jacc_sim": 0.9666666666666667, "nl": "You are given a sequence X of length N, where each element is initially 0. Another sequence A of length N is provided. Determine if X can be made equal to A by a specific operation. If possible, find the minimum number of operations required. The operation involves choosing an integer i (1 \u2264 i \u2264 N-1) and replacing the value of X_{i+1} with the value of X_i plus 1. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 N). Input is given as N followed by A_1 to A_N. If X can be made equal to A, print the minimum number of operations required; otherwise, print -1.", "before_after_length": [125, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00667", "p_user": "u539753516", "n_user": "u539753516", "pos": "def f3(n):\n a=b=c=0\n for _ in range(n):\n a,b,c=(a+b+c+1)%100000007,a,b\n return a\n \ndef f5(n):\n a=b=c=d=e=0\n for _ in range(n):\n a,b,c,d,e=(a+b+c+d+e+1)%100000007,a,b,c,d\n return a\n\nwhile 1:\n s=input()\n if s==\"#\":break\n ans=1\n num=\"_\"\n cnt=1\n for n in s+\"_\":\n if n==num:\n cnt+=1\n else:\n if num in \"80\":\n ans=ans*f3(cnt)%100000007\n else:\n ans=ans*f5(cnt)%100000007\n num=n\n cnt=1\n print(ans)\n", "neg": "def f3(n):\n a=b=c=0\n for _ in range(n):\n a,b,c=(a+b+c+1)%100000007,a,b\n return a\n \ndef f5(n):\n a=b=c=d=e=0\n for _ in range(n):\n a,b,c,d,e=(a+b+c+d+e+1)%100000007,a,b,c,d\n return a\n\nwhile 1:\n s=input()\n if s==\"#\":break\n ans=1\n num=\"_\"\n cnt=1\n for n in s+\"_\":\n if n==num:\n cnt+=1\n else:\n if num in \"80\":\n ans*=f3(cnt)\n else:\n ans*=f5(cnt)\n num=n\n cnt=1\n print(ans)\n", "jacc_sim": 1.0, "nl": "Title: Problem I: 11224111122411\n\nA person's arm is stuck and can't be pulled out. While trying to retrieve something that rolled under a desk, they accidentally got their arm stuck and can't move it without pain. They consider calling for help but realize no one is around. They decide to use their phone to send a message for help. However, the phone's input method has a unique behavior where pressing a number key multiple times can result in different characters based on the time intervals between presses. The task is to determine the number of possible interpretations of the sent message. The input consists of multiple cases, each containing a string of numbers. The output should be the interpretation of the message modulo 100000007. The input ends with a line containing only \"#\". The problem is from The University of Aizu Programming Contest 2011 Summer.", "before_after_length": [242, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00682", "p_user": "u078042885", "n_user": "u078042885", "pos": "c=0\nwhile 1:\n n=int(input())\n if n==0:break\n c+=1\n p=[complex(*map(int,input().split())) for _ in range(n)]\n s,pre=0,p[0]\n while p:\n now=p.pop()\n s+=now.real*pre.imag-now.imag*pre.real\n pre=now\n print(c,abs(s)/2);input()", "neg": "while 1:\n n=int(input())\n if n==0:break\n p=[complex(*map(int,input().split())) for _ in range(n)]\n s,pre=0,p[0]\n while p:\n now=p.pop()\n s+=now.real*pre.imag-now.imag*pre.real\n pre=now\n print(abs(s)/2);input()", "jacc_sim": 0.9743589743589743, "nl": "Area of Polygons\n\nPolygons are fundamental in geometric processing. Complex figures are often represented and handled as polygons with many short sides. If interested in geometric data processing, try programming exercises about basic polygon operations.\n\nYour task is to write a program that computes the area of polygons.\n\nA polygon is represented by a sequence of points, its vertices. Given vertices p1, p2, ..., pn, line segments connecting pi and pi+1 (1 <= i <= n-1) are sides of the polygon. The line segment connecting pn and p1 is also a side of the polygon.\n\nAssume the polygon is not degenerate. No point occurs as a vertex more than once. Two sides can intersect only at a common endpoint (vertex). The polygon has at least 3 vertices. Note that the polygon is not necessarily convex; an inner angle may be larger than 180 degrees.\n\nInput\nThe input contains multiple data sets, each representing a polygon. A data set is given in the format:\nn\nx1 y1\nx2 y2\n...\nxn yn\n\nThe first integer n is the number of vertices, such that 3 <= n <= 50. The coordinate of a vertex pi is given by (xi, yi). xi and yi are integers between 0 and 1000 inclusive. The coordinates of vertices are given in the order of clockwise visit of them. The end of input is indicated by a data set with 0 as the value of n.\n\nOutput\nFor each data set, the program should output its sequence number and the area of the polygon separated by a single space. The area should be printed with one digit to the right of the decimal point. The sequence number and the area should be printed on the same line.\n\nSample Input\n3\n1 1\n3 4\n6 0\n7\n0 0\n10 10\n0 20\n10 30\n0 40\n100 40\n100 0\n0\n\nOutput for the Sample Input\n1 8.5\n2 3800.0", "before_after_length": [115, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00706", "p_user": "u506554532", "n_user": "u506554532", "pos": "while True:\n N = int(input())\n if N == 0: break\n W,H = map(int,input().split())\n fld = [[0 for w in range(W)] for h in range(H)]\n for i in range(N):\n x,y = map(lambda s:int(s)-1,input().split())\n fld[y][x] = 1\n cums = [[0 for w in range(W+1)] for h in range(H+1)]\n for y in range(H):\n for x in range(W):\n cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]\n S,T = map(int,input().split())\n ans = 0\n for y in range(H-T+1):\n for x in range(W-S+1):\n ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])\n print(ans)", "neg": "while True:\n N = int(input())\n if N == 0: break\n W,H = map(int,input().split())\n fld = [[0 for w in range(W)] for h in range(H)]\n for i in range(N):\n x,y = map(lambda s:int(s)-1,raw_input().split())\n fld[y][x] = 1\n cums = [[0 for w in range(W+1)] for h in range(H+1)]\n for y in range(H):\n for x in range(W):\n cums[y+1][x+1] = fld[y][x] + cums[y][x+1] + cums[y+1][x] - cums[y][x]\n S,T = map(int,input().split())\n ans = 0\n for y in range(H-T+1):\n for x in range(W-S+1):\n ans = max(ans, cums[y+T][x+S] - cums[y+T][x] - cums[y][x+S] + cums[y][x])\n print(ans)", "jacc_sim": 0.975609756097561, "nl": "Title: Get Many Persimmon Trees\n\nSeiji Hayashi, a professor at the Nisshinkan Samurai School in the 18th century, is rewarded with a rectangular estate within a large field in the Aizu Basin by Katanobu Matsudaira, the lord of the domain of Aizu. The estate's size is specified, but its location within the field is not. The field contains many Japanese persimmon trees, known as 'Mishirazu Persimmon', a famous product of the Aizu region. Hayashi, a fan of persimmons, aims to maximize the number of persimmon trees within the estate.\n\nGiven the dimensions of the field and the coordinates of the persimmon trees, the task is to find the estate of a given size (width and height) that contains the largest number of persimmon trees.\n\nInput:\n- The input consists of multiple data sets.\n- Each data set includes the number of persimmon trees, the width and height of the field, coordinates of the persimmon trees, and the width and height of the estate.\n\nOutput:\n- For each data set, output the maximum possible number of persimmon trees that can be included in an estate of the given size.\n\nSample Input:\n- Provided sample input data.\n\nSample Output:\n- Corresponding output for the sample input.", "before_after_length": [282, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00710", "p_user": "u966364923", "n_user": "u966364923", "pos": "while True:\n (n, r) = [int(x) for x in input().split()]\n if n==0 and r==0:\n exit()\n cards = [n-i for i in range(n)]\n for _ in range(r):\n (p, c) = [int(x) for x in input().split()]\n cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]\n print(cards[0])", "neg": "while True:\n (n, r) = [int(x) for x in input().split()]\n if n==0 and r==0:\n exit()\n cards = [n-i for i in range(n)]\n for _ in range(r):\n (p, c) = [int(x) for x in input().split()]\n cards = cards[p-1:c] + cards[p-1:p-1+c] + cards[p-1+c:]\n print(cards[0])", "jacc_sim": 1.0, "nl": "Problem A: Hanafuda Shuffle\n\nThere are various ways to shuffle a deck of cards. Hanafuda shuffling, used in the Japanese card game 'Hanafuda', is one such method. The process involves pulling out a certain number of cards from the deck and placing them on top, known as a cutting operation.\n\nWrite a program to simulate Hanafuda shuffling and determine which card will end up on top of the deck.\n\nInput:\nThe input consists of multiple data sets. Each set begins with two positive integers, n (1 <= n <= 50) and r (1 <= r <= 50), representing the number of cards in the deck and the number of cutting operations, respectively. This is followed by r lines, each representing a cutting operation. Each line contains two positive integers, p and c (p + c <= n + 1), indicating the starting position and the number of cards to be pulled out and placed on top. The input ends with a line containing two zeros.\n\nOutput:\nFor each data set, the program should output the number of the top card after the shuffle. Assume the cards are initially numbered from 1 to n, from bottom to top.\n\nSample Input:\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [125, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00710", "p_user": "u653710476", "n_user": "u653710476", "pos": "first = input().split()\nn = int(first[0])\nr = int(first[1])\nwhile n != 0 or r != 0:\n i = 0\n card = list(range(1,n+1))[::-1]\n while i < r:\n sh = input().split()\n p, c = list(map(int,sh))\n card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]\n i = i + 1\n print(card[0])\n next = input().split()\n n, r = list(map(int,next))", "neg": "first = input().split()\nn = int(first[0])\nr = int(first[1])\nwhile n != 0 or r != 0:\n i = 0\n card = list(range(1,n+1))[::-1]\n while i < r:\n sh = input().split()\n p, c = list(map(int,sh))\n card = card[p-1:p+c-1] + card[:p-1] + card[p+c-1:]\n i = i + 1\n print(card)\n next = input().split()\n n, r = list(map(int,next))", "jacc_sim": 1.0, "nl": "Problem A: Hanafuda Shuffle\n\nThere are various ways to shuffle a deck of cards. Hanafuda shuffling, used in the Japanese card game 'Hanafuda', is one such method. The process involves pulling out a certain number of cards from the deck and placing them on top, known as a cutting operation.\n\nWrite a program to simulate Hanafuda shuffling and determine which card will end up on top of the deck.\n\nInput:\nThe input consists of multiple data sets. Each set begins with two positive integers, n (1 <= n <= 50) and r (1 <= r <= 50), representing the number of cards in the deck and the number of cutting operations, respectively. This is followed by r lines, each representing a cutting operation. Each line contains two positive integers, p and c (p + c <= n + 1), indicating the starting position and the number of cards to be pulled out and placed on top. The input ends with a line containing two zeros.\n\nOutput:\nFor each data set, the program should output the number of the top card after the shuffle. Assume the cards are initially numbered from 1 to n, from bottom to top.\n\nSample Input:\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [156, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00710", "p_user": "u489876484", "n_user": "u489876484", "pos": "while True:\n n, r = list(map(lambda x: int(x), input().split(\" \")))\n if n == 0 and r == 0:\n break\n cards = [i for i in range(1,n+1)]\n cards = cards[::-1]\n\n for i in range(r):\n p, c = list(map(lambda x: int(x), input().split(\" \")))\n p -= 1\n cards = cards[p:p+c] + cards[0:p] + cards[p+c:]\n \n print(cards[0])\n", "neg": "while True:\n n, r = list(map(lambda x: int(x), input().split(\" \")))\n if n == 0 and r == 0:\n break\n cards = [i for i in range(1,n+1)]\n cards = cards[::-1]\n\n for i in range(r):\n print(cards)\n p, c = list(map(lambda x: int(x), input().split(\" \")))\n p -= 1\n cards = cards[p:p+c] + cards[0:p] + cards[p+c:]\n \n print(cards[0])\n", "jacc_sim": 1.0, "nl": "Problem A: Hanafuda Shuffle\n\nThere are various ways to shuffle a deck of cards. Hanafuda shuffling, used in the Japanese card game 'Hanafuda', is one such method. The process involves pulling out a certain number of cards from the deck and placing them on top, known as a cutting operation.\n\nWrite a program to simulate Hanafuda shuffling and determine which card will end up on top of the deck.\n\nInput:\nThe input consists of multiple data sets. Each set begins with two positive integers, n (1 <= n <= 50) and r (1 <= r <= 50), representing the number of cards in the deck and the number of cutting operations, respectively. This is followed by r lines, each representing a cutting operation. Each line contains two positive integers, p and c (p + c <= n + 1), indicating the starting position and the number of cards to be pulled out and placed on top. The input ends with a line containing two zeros.\n\nOutput:\nFor each data set, the program should output the number of the top card after the shuffle. Assume the cards are initially numbered from 1 to n, from bottom to top.\n\nSample Input:\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [143, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00710", "p_user": "u963883732", "n_user": "u963883732", "pos": "while True:\n\tl = input()\n\tL = l.split()\n\tfor i in range(len(L)):\n\t\tL[i] = int(L[i])\n\tif L[0] == 0:\n\t\tbreak\t\n\ta = [L[0]-number for number in range(L[0])]\n\tfor j in range(L[1]):\n\t\tr = input()\n\t\tR = r.split()\n\t\tfor k in range(len(R)):\n\t\t\tR[k] = int(R[k])\n\t\tb = []\n\t\tb += a[R[0]-1:R[0]+R[1]-1]\n\t\tb += a[:R[0]-1]\n\t\tb += a[R[0]+R[1]-1:]\n\t\ta.clear()\n\t\ta = b.copy()\n\tprint(a[0])\n", "neg": "l = input()\nL = l.split()\nfor i in range(len(L)):\n\tL[i] = int(L[i])\nwhile True:\n\tif L[0] == 0:\n\t\tbreak\n\ta = [L[0]-number for number in range(L[0])]\n\tfor j in range(L[1]):\n\t\tr = input()\n\t\tR = r.split()\n\t\tfor k in range(len(R)):\n\t\t\tR[k] = int(R[k])\n\t\tb = []\n\t\tb += a[R[0]-1:R[0]+R[1]-1]\n\t\tb += a[:R[0]-1]\n\t\tb += a[R[0]+R[1]-1:]\n\t\ta.clear()\n\t\ta = b.copy()\n\tprint(a[0])\n", "jacc_sim": 1.0, "nl": "Problem A: Hanafuda Shuffle\n\nThere are various ways to shuffle a deck of cards. Hanafuda shuffling, used in the Japanese card game 'Hanafuda', is one such method. The process involves pulling out a certain number of cards from the deck and placing them on top, known as a cutting operation.\n\nWrite a program to simulate Hanafuda shuffling and determine which card will end up on top of the deck.\n\nInput:\nThe input consists of multiple data sets. Each set begins with two positive integers, n (1 <= n <= 50) and r (1 <= r <= 50), representing the number of cards in the deck and the number of cutting operations, respectively. This is followed by r lines, each representing a cutting operation. Each line contains two positive integers, p and c (p + c <= n + 1), indicating the starting position and the number of cards to be pulled out and placed on top. The input ends with a line containing two zeros.\n\nOutput:\nFor each data set, the program should output the number of the top card after the shuffle. Assume the cards are initially numbered from 1 to n, from bottom to top.\n\nSample Input:\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [222, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00710", "p_user": "u598814210", "n_user": "u998188826", "pos": "while True:\n n,r = map(int,input().split())\n if(n==0): break\n cards = list(range(n,0,-1))\n for i in range(r):\n p,c = map(int,input().split())\n cards = cards[p-1:p+c-1] + cards[:p-1] + cards[p+c-1:]\n print(cards[0])\n\n", "neg": "\nwhile True:\n\tn, r = map(int, input().split())\n\tif (n, r) == (0, 0):\n\t\tbreak\n\tcards = list(range(1, n+1))[::-1]\n\tprint(cards)\n\n\tfor i in range(r):\n\t\tp, c = map(int, input().split())\n\t\tcards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]\n\tprint(cards[0])", "jacc_sim": 1.0, "nl": "Problem A: Hanafuda Shuffle\n\nThere are various ways to shuffle a deck of cards. Hanafuda shuffling, used in the Japanese card game 'Hanafuda', is one such method. The process involves pulling out a certain number of cards from the deck and placing them on top, known as a cutting operation.\n\nWrite a program to simulate Hanafuda shuffling and determine which card will end up on top of the deck.\n\nInput:\nThe input consists of multiple data sets. Each set begins with two positive integers, n (1 <= n <= 50) and r (1 <= r <= 50), representing the number of cards in the deck and the number of cutting operations, respectively. This is followed by r lines, each representing a cutting operation. Each line contains two positive integers, p and c (p + c <= n + 1), indicating the starting position and the number of cards to be pulled out and placed on top. The input ends with a line containing two zeros.\n\nOutput:\nFor each data set, the program should output the number of the top card after the shuffle. Assume the cards are initially numbered from 1 to n, from bottom to top.\n\nSample Input:\n5 2\n3 1\n3 1\n10 3\n1 10\n10 1\n8 3\n0 0\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [107, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00718", "p_user": "u078042885", "n_user": "u078042885", "pos": "a={'m':1000,'c':100,'x':10,'i':1}\nfor _ in range(int(input())):\n b,s,t=input(),0,1\n for x in b:\n if x==' ':continue\n if x in a:s+=a[x]*t;t=1\n else:t=int(x)\n ans=''\n for k in ['m','c','x','i']:\n c,s=divmod(s,a[k])\n if c:ans+=['',str(c)][c!=1]+k\n print(ans)", "neg": "a={'m':1000,'c':100,'x':10,'i':1}\nfor _ in range(int(input())):\n b,s,t=input(),0,1\n for x in b:\n if x==' ':continue\n if x in a:s+=a[x]*t;t=1\n else:t=int(x)\n ans=''\n for k in ['m','c','x','i']:\n c,s=divmod(s,a[k])\n if c:ans+=['',str(c)][c!=0]+k\n print(ans)", "jacc_sim": 1.0, "nl": "Problem C: Numeral System\n\nProf. Hachioji has created a new numeral system using four lowercase letters \"m\", \"c\", \"x\", \"i\" and eight digits \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\". The system excludes the digits \"0\" and \"1\". Each letter corresponds to a specific value: \"m\" = 1000, \"c\" = 100, \"x\" = 10, and \"i\" = 1. The digits \"2\" to \"9\" correspond to their respective values. This system is unrelated to the Roman numeral system.\n\nFor example, the strings \"5m2c3x4i\", \"m2c4i\", and \"5m2c3x\" correspond to the integral numbers 5234, 1204, and 5230, respectively. Each letter may be prefixed by a digit from \"2\" to \"9\", forming a pair where the prefix digit multiplies the value of the letter. The letters \"m\", \"c\", \"x\", and \"i\" must appear in that order from left to right, and when a digit exists in a string, it should appear as the prefix digit of the following letter. An MCXI-string corresponds to a positive integer, and each integer from 1 to 9999 has a unique MCXI-string.\n\nYour task is to write a program that reads two MCXI-strings, computes the sum of their MCXI-values, and prints the MCXI-string corresponding to the result.\n\nInput:\nThe first line contains a positive integer n (<= 500) indicating the number of following lines. Each of the next n lines contains two MCXI-strings separated by a space.\n\nOutput:\nFor each specification, your program should print an MCXI-string in a line. Its MCXI-value should be the sum of the two MCXI-values of the MCXI-strings in the specification. No other characters should appear in the output.", "before_after_length": [149, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00722", "p_user": "u506554532", "n_user": "u506554532", "pos": "MAXN = 10**6\nsieve = [0]*2 + [1]*MAXN\nn = 2\nwhile n*n <= MAXN:\n if sieve[n]:\n for i in range(2*n,MAXN+1,n):\n sieve[i] = 0\n n += 1\n\nwhile True:\n a,d,n = map(int,input().split())\n if n == 0: break\n cnt = 0\n for i in range(a,MAXN+1,d):\n if sieve[i]:\n cnt += 1\n if cnt == n:\n print(i)\n break", "neg": "MAXN = 10**6\nsieve = [1 for i in range(MAXN+1)]\nn = 2\nwhile n*n <= MAXN:\n if sieve[n]:\n for i in range(2*n,MAXN+1,n):\n sieve[i] = 0\n n += 1\n\nwhile True:\n a,d,n = map(int,input().split())\n if n == 0: break\n cnt = 0\n for i in range(a,MAXN+1,d):\n if sieve[i]:\n cnt += 1\n if cnt == n:\n print(i)\n break", "jacc_sim": 1.0, "nl": "Problem A: Dirichlet's Theorem on Arithmetic Progressions\n\nGood evening, contestants.\n\nIf \"a\" and \"d\" are relatively prime positive integers, the arithmetic sequence beginning with \"a\" and increasing by \"d\" contains infinitely many prime numbers. This is known as Dirichlet's Theorem on Arithmetic Progressions, conjectured by Johann Carl Friedrich Gauss and proved by Johann Peter Gustav Lejeune Dirichlet in 1837.\n\nYour mission is to write a program to find the \"n\"th prime number in this arithmetic sequence for given positive integers \"a\", \"d\", and \"n\".\n\nInput:\nThe input is a sequence of datasets. Each dataset is a line containing three positive integers \"a\", \"d\", and \"n\" separated by a space. \"a\" and \"d\" are relatively prime. The end of the input is indicated by a line containing three zeros separated by a space.\n\nOutput:\nThe output should be composed of as many lines as the number of the input datasets. Each line should contain a single integer, which corresponds to the \"n\"th prime number among those contained in the arithmetic sequence beginning with \"a\" and increasing by \"d\". The result is always less than 10^6 under this input condition.\n\nSample Input:\n(Provided in the original problem)\n\nOutput for the Sample Input:\n(Provided in the original problem)", "before_after_length": [152, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00723", "p_user": "u124909914", "n_user": "u124909914", "pos": "ls = []\n\ndef add(t):\n if t not in ls:\n ls.append(t)\n\nn = int(input())\nfor i in range(n):\n t = input()\n ls = [t] \n for j in range(1,len(t)):\n f, b = t[:j], t[j:]\n add(f+b[::-1])\n add(f[::-1]+b)\n add(f[::-1]+b[::-1])\n add(b+f)\n add(b+f[::-1])\n add(b[::-1]+f)\n add(b[::-1]+f[::-1])\n print(len(ls))", "neg": "ls = []\n\ndef add(t):\n if t not in ls:\n ls.append(t)\n\nn = int(input())\nfor i in range(n):\n t = input()[:-1]\n ls = [t] \n for j in range(1,len(t)):\n f, b = t[:j], t[j:]\n add(f+b[::-1])\n add(f[::-1]+b)\n add(f[::-1]+b[::-1])\n add(b+f)\n add(b+f[::-1])\n add(b[::-1]+f)\n add(b[::-1]+f[::-1])\n print(len(ls))", "jacc_sim": 1.0, "nl": "Problem B: Organize Your Train part II\n\nRJ Freight, a Japanese railroad company for freight operations has recently constructed exchange lines at Hazawa, Yokohama. The layout of the lines is shown in Figure B-1.\n\nA freight train consists of 2 to 72 freight cars, denoted by 26 lowercase letters from \"a\" to \"z\". Upon arrival at the exchange lines, a train is divided into two sub-trains at an arbitrary position. Each sub-train may have its direction reversed. Finally, the two sub-trains are connected in either order to form the final configuration.\n\nFor each dataset representing an arriving train, output the number of possible train configurations.", "before_after_length": [179, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u282479278", "n_user": "u282479278", "pos": "j = 0\nlists = []\nflag = 0\ncnt = 0\nwhile 1:\n cnt = 0\n flag_max = 0\n flag_min = 0\n lists = []\n n = int(input())\n if n == 0:\n break\n for i in range(n):\n s = int(input())\n lists.append(s)\n for i in range(n):\n if lists[i] == max(lists):\n flag_max += 1\n pass\n elif lists[i] == min(lists):\n flag_min += 1\n pass\n else:\n cnt += lists[i]\n n -= 2\n if flag_max >= 2:\n cnt += max(lists)\n elif flag_min >= 2:\n cnt += min(lists)\n print(cnt // n)\n\n", "neg": "j = 0\nlists = []\nflag = 0\ncnt = 0\nwhile 1:\n n = int(input())\n if n == 0:\n break\n for i in range(n):\n s = int(input())\n lists.append(s)\n for i in range(n):\n if lists[i] == max(lists):\n flag += 1\n pass\n elif lists[i] == min(lists):\n flag += 1\n pass\n else:\n cnt += lists[i]\n if flag >= 2:\n n -= 2\n print(cnt // n)\n\n", "jacc_sim": 0.9473684210526315, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [200, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u966364923", "n_user": "u966364923", "pos": "while True:\n n = int(input())\n if n == 0:\n exit()\n score = []\n for i in range(n):\n score.append(int(input()))\n print(sum(sorted(score)[1:-1])//(n-2))", "neg": "while True:\n n = int(input())\n if n == 0:\n exit()\n score = []\n for i in range(n):\n score.append(int(input()))\n print((sorted(score)[1:-1])//(n-2))", "jacc_sim": 0.9642857142857143, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [68, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u128811851", "n_user": "u128811851", "pos": "averages = []\n\nwhile True:\n amount = int(input())\n if amount == 0:\n break\n scores = [int(input()) for i in range(amount)]\n scores.remove(max(scores))\n scores.remove(min(scores))\n averages.append(sum(scores) // (amount - 2))\n\nfor i in range(len(averages)):\n print(averages[i])", "neg": "averages = []\n\nwhile True:\n amount = int(input())\n if amount == 0:\n break\n scores = [int(input()) for i in range(amount)]\n scores.remove(max(scores))\n scores.remove(min(scores))\n averages.append(sum(scores) // amount)\n\nfor i in range(len(averages)):\n print(averages[i])", "jacc_sim": 0.9354838709677419, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [102, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u808582184", "n_user": "u808582184", "pos": "import statistics\n\nwhile True:\n n = int(input())\n if n == 0: break\n s = [int(input()) for i in range(n)]\n ave = statistics.mean(sorted(s)[1:-1])\n print(int(ave))", "neg": "import statistics\n\nwhile True:\n n = int(input())\n if n == 0: break\n s = [int(input()) for i in range(n)]\n ave = statistics.mean(sorted(s[1:-1]))\n print(int(ave))", "jacc_sim": 1.0, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [65, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u166871988", "n_user": "u166871988", "pos": "while True:\n n=int(input())\n if n==0:break\n points=[]\n for i in range(n):\n points.append(int(input()))\n points.remove(max(points))\n points.remove(min(points))\n print(int(sum(points)/len(points)))", "neg": "while True:\n n=int(input())\n points=[]\n for i in range(n):\n points.append(int(input()))\n points.remove(max(points))\n points.remove(min(points))\n print(int(sum(points)/len(points)))\n if int(input())==0:break", "jacc_sim": 1.0, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [78, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u780025254", "n_user": "u780025254", "pos": "import sys\n\nwhile True:\n n = int(sys.stdin.readline().rstrip())\n\n if n == 0:\n break\n\n scores = [int(sys.stdin.readline().rstrip()) for i in range(n)]\n result = (sum(scores) - (max(scores) + min(scores))) // (n - 2)\n\n print(result)", "neg": "import sys\n\nwhile True:\n n = int(sys.stdin.readline().rstrip())\n \n if n == 0:\n break\n \n scores = [int(sys.stdin.readline().rstrip()) for i in range(n)]\n result = (sum(scores) - (min(scores) + max(scores)) // n - 2)\n \n print(result)", "jacc_sim": 1.0, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [92, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u661290476", "n_user": "u661290476", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n MIN = 1000\n MAX = 0\n points = 0\n for i in range(n):\n p = int(input())\n if MIN > p:\n MIN = p\n if MAX < p:\n MAX = p\n points += p\n print((points - MIN - MAX) // (n - 2))\n\n", "neg": "while True:\n try:\n n = int(input())\n MIN = 1000\n MAX = 0\n points = 0\n for i in range(n):\n p = int(input())\n if MIN > p:\n MIN = p\n if MAX < p:\n MAX = p\n points += p\n print((points - MIN - MAX) // (n - 2))\n except:\n break\n\n", "jacc_sim": 0.9333333333333333, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [100, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u005739171", "n_user": "u546285759", "pos": "import bisect\nwhile True:\n n = int(input())\n if n == 0:\n break\n score = []\n for _ in range(n):\n s = int(input())\n bisect.insort(score, s)\n print(sum(score[1:-1])//(len(score)-2))\n", "neg": "import bisect\nwhile True:\n n = int(input())\n if n+1:\n break\n score = []\n for _ in range(n):\n s = int(input())\n bisect.insort(score, s)\n print(sum(score[1:-1])//(len(score)-2))", "jacc_sim": 0.9393939393939394, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [79, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u925259339", "n_user": "u925259339", "pos": "import math\n\ndef main():\n r = []\n while True:\n n = int(input())\n if n == 0:\n break\n m = []\n for i in range(n):\n m.append(int(input()))\n r.append(math.floor((sum(m) - max(m) - min(m))/(n-2)))\n for j in r:\n print(j)\n\nmain()\n\n", "neg": "import math\n\ndef main():\n r = []\n while True:\n n = int(input())\n if n == 0:\n break\n m = []\n for i in range(n):\n m.append(int(input()))\n r.append(math.floor((sum(m) - max(m) - min(m)/(n-2))))\n res = ''\n for j in r:\n print(j)\n\nmain()\n\n", "jacc_sim": 0.9459459459459459, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [110, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u209989098", "n_user": "u209989098", "pos": "i = int(input())\np = 0\nwhile i != 0:\n k =[ [0]*100]*20\n ma = 0\n mi = 1000\n for pp in range(i):\n l = int(input())\n k[p][pp] = l\n ma = max(ma,l)\n mi = min(mi,l)\n su = sum(k[p]) - ma - mi\n l = i -2\n print(su // l)\n p += 1\n i = int(input()) \n", "neg": "i = int(input())\nwhile i == 0:\n i = 0\n p = 0\n k[20][100] = [[0]]\n ma = 0\n mi = 1000\n for i in range(i):\n l = int(input())\n k[p][i] = l\n ma = max(ma,l)\n mi = min(mi,l)\n su = sum(k[p]) - ma - mi\n print(su // (i-2))\n p += 1\n i = int(input()) \n", "jacc_sim": 0.9166666666666666, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [127, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00728", "p_user": "u910909659", "n_user": "u878596989", "pos": "while True:\n N = int(input())\n if N == 0:\n break\n S = []\n for i in range(N):\n S.append(int(input()))\n a = sum(S)-max(S)-min(S)\n print(int(a/(N-2)))\n", "neg": "while True:\n N = int(input())\n if 3\n N == 0:\n break\n S = []\n for i in range(N):\n S.append(int(input()))\n print((sum(S) - max(S) - min(S))//(len(S)-2))\n", "jacc_sim": 0.9032258064516129, "nl": "Problem A: ICPC Score Totalizer Software\n\nThe International Clown and Pierrot Competition (ICPC) is a prestigious and popular event in show business. The contest involves a large number of judges, sometimes up to one hundred, who score contestants' performances. Each contestant may have a different number of judges, as judges with any relationship to a specific contestant are temporarily excluded from scoring. \n\nContestants' scores are calculated by averaging the judges' scores, excluding the highest and lowest scores to mitigate the influence of extreme viewpoints. If multiple judges give the same highest or lowest score, only one is ignored. The average, possibly containing fractions, is truncated to obtain the final integer score.\n\nThe task is to write a program that computes performance scores based on judges' scores, to expedite the event for television.\n\nInput:\nThe input consists of datasets, each corresponding to a contestant's performance. There are no more than 20 datasets. Each dataset begins with an integer \"n\" (3 \u2264 n \u2264 100), representing the number of judges. The following \"n\" lines contain integral scores marked by judges (0 \u2264 s \u2264 1000). The input ends with a line containing a single zero.\n\nOutput:\nFor each dataset, output a single decimal integer indicating the score for the corresponding performance.\n\nSample Input:\n3\n1000\n342\n0\n5\n2\n2\n9\n11\n932\n5\n300\n1000\n0\n200\n400\n8\n353\n242\n402\n274\n283\n132\n402\n523\n0\n\nOutput for the Sample Input:\n342\n7\n300\n326", "before_after_length": [76, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u270681687", "n_user": "u270681687", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\nn, m = map(int, input().split())\ng = [[] for _ in range(n)]\n\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n g[a].append(b)\n g[b].append(a)\n\nq = int(input())\n\nquery = [list(map(int, input().split())) for _ in range(q)]\n\ncolor = [0] * n\ndepth = [-1] * n\n\ndef dfs(node, dist, col, pre_node):\n if dist <= depth[node]:\n return\n depth[node] = dist\n if color[node] == 0:\n color[node] = col\n if dist == 0:\n return\n for next_node in g[node]:\n if next_node == pre_node:\n continue\n dfs(next_node, dist-1, col, node)\n\nfor v, d, c in query[::-1]:\n v -= 1\n dfs(v, d, c, -1)\n\nfor co in color:\n print(co)\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\nn, m = map(int, input().split())\ng = [[] for _ in range(n)]\n\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n g[a].append(b)\n g[b].append(a)\n\nq = int(input())\n\nquery = [list(map(int, input().split())) for _ in range(q)]\n\ncolor = [0] * n\ndepth = [-1] * n\n\ndef dfs(node, dist, dist_max, col, pre_node):\n if dist <= depth[node]:\n return\n depth[node] = dist\n if dist > dist_max:\n return\n if color[node] == 0:\n color[node] = col\n if dist == dist_max:\n return\n for next_node in g[node]:\n if next_node == pre_node:\n continue\n dfs(next_node, dist+1, dist_max, col, node)\n\nfor v, d, c in query[::-1]:\n v -= 1\n dfs(v, 0, d, c, -1)\n\nfor co in color:\n print(co)\n", "jacc_sim": 0.9473684210526315, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [300, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u816116805", "n_user": "u816116805", "pos": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n\n\"\"\"\nagc012 C\n\"\"\"\n\nfrom collections import defaultdict\n\nn, m = map(int, input().split())\n\ngraph = defaultdict(list)\nfor i in range(m):\n a, b = map(int, input().split())\n graph[a].append(b)\n graph[b].append(a)\n\nq = int(input())\nqlist = [tuple(map(int, input().split())) for i in range(q)]\nqlist.reverse()\n\ndp = [[-1]*11 for i in range(n+1)]\ncol = [0]\n\n\ndef updatedp(v, t, d):\n if dp[v][d] == -1:\n dp[v][d] = t\n if d > 0:\n updatedp(v, t, d-1)\n for u in graph[v]:\n updatedp(u, t, d-1)\n\n\nt = 0\nfor v, d, c in qlist:\n col.append(c)\n updatedp(v, t, d)\n t += 1\n\nfor i in range(1, n+1):\n print(col[dp[i][0]+1])\n", "neg": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n\n\"\"\"\nagc012 C\n\"\"\"\n\n\nn, m = map(int, input().split())\n\ngraph = [[] for i in range(n+1)]\nfor i in range(m):\n a, b = map(int, input().split())\n graph[a].append(b)\n graph[b].append(a)\n\nq = int(input())\nqlist = [tuple(map(int, input().split())) for i in range(q)]\nqlist.reverse()\n\ndp = [[-1]*11 for i in range(n+1)]\ncol = [0]\n\n\ndef updatedp(v, t, d):\n if dp[v][d] == -1:\n for i in range(d+1):\n dp[v][i] = t\n if d > 0:\n for u in graph[v]:\n updatedp(u, t, d-1)\n\n\nt = 0\nfor v, d, c in qlist:\n col.append(c)\n updatedp(v, t, d)\n t += 1\n\nfor i in range(1, n+1):\n print(col[dp[i][0]+1])\n", "jacc_sim": 0.921875, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [323, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u226155577", "n_user": "u226155577", "pos": "N, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n G[a-1].append(b-1)\n G[b-1].append(a-1)\n\ndp = [{-1: -1} for i in range(N)]\nmark = {}\nQ = int(input())\ncol = [0]*(Q+1)\ncol[-1] = 0\nC = []\nfor i in range(Q):\n v, d, c = map(int, input().split())\n col[i] = c\n C.append((v-1, d))\n\ndef dfs(v, d, idx):\n if d <= max(dp[v]):\n return\n dp[v][d] = idx\n if d:\n for w in G[v]:\n dfs(w, d-1, idx)\n\nfor i in range(Q-1, -1, -1):\n v, d = C[i]\n dfs(v, d, i)\nprint(*(col[max(e.values())] for e in dp), sep='\\n')", "neg": "N, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n G[a-1].append(b-1)\n G[b-1].append(a-1)\n\ndp = [{-1: -1} for i in range(N)]\nmark = {}\nQ = int(input())\ncol = [0]*(Q+1)\ncol[-1] = 0\nC = []\nfor i in range(Q):\n v, d, c = map(int, input().split())\n col[i] = c\n C.append((v-1, d))\n\ndef dfs(v, d, idx):\n if d <= max(dp[v]):\n return\n print(v, d, idx)\n dp[v][d] = idx\n if d:\n for w in G[v]:\n dfs(w, d-1, idx)\n\nfor i in range(Q-1, -1, -1):\n v, d = C[i]\n dfs(v, d, i)\nprint(*(col[max(e.values())] for e in dp), sep='\\n')\n", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [291, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u243492642", "n_user": "u104282757", "pos": "from collections import deque\nfrom collections import defaultdict\n\nG = defaultdict(list)\nN, M = map(int, input().split())\ncolor = [0] * (N + 1)\n\nfor _ in range(M):\n a, b = map(int, input().split())\n G[a].append(b)\n G[b].append(a)\nQ = int(input())\n\ndata = [list(map(int, input().split())) for _ in range(Q)]\ndata.reverse()\ncolor_d = [-1] * (N + 1)\n\nfor v, d, c in data:\n if color_d[v] >= d:\n pass\n # BFS\n deq = deque([v])\n if color[v] == 0:\n color[v] = c\n color_d[v] = d\n while len(deq) > 0:\n s = deq.popleft()\n for t in G[s]:\n if color_d[t] >= color_d[s] - 1:\n pass\n else:\n color_d[t] = color_d[s] - 1\n if color[t] == 0:\n color[t] = c\n if color_d[t] > 0:\n deq.append(t)\n\nfor n in range(1, N + 1):\n print(color[n])", "neg": "from collections import deque\n\nG = dict()\nN, M = map(int, input().split())\ncolor = [0]*(N+1)\nfor n in range(1, N+1):\n G[n] = []\nfor _ in range(M):\n a, b = map(int, input().split())\n G[a].append(b)\n G[b].append(a)\nQ = int(input())\n\n\n\n\ndata = [list(map(int, input().split())) for _ in range(Q)]\ndata.reverse()\ncolor_d = [-1]*(N+1)\n\nfor v, d, c in data:\n # BFS\n dist = dict()\n deq = deque([v])\n color[v] = c\n color_d[v] = d\n while len(deq) > 0:\n s = deq.popleft()\n for t in G[s]:\n if color_d[t] >= color_d[s] - 1:\n pass\n else:\n color_d[t] = color_d[s] - 1\n if color[t] == 0:\n color[t] = c\n if color_d[t] > 0:\n deq.append(t)\n \nfor n in range(1, N+1):\n print(color[n])\n \n\n", "jacc_sim": 0.9473684210526315, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [335, 334], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u006493569", "n_user": "u006493569", "pos": "n, m = map(int, input().split())\nedges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]\nedges += [[i, i] for i in range(n)]\n\nq = int(input())\ncolor = [0] * (q + 1)\ndp = [[0 for j in range(n)] for i in range(11)]\nfor i in range(q):\n v, d, color[i + 1] = map(int, input().split())\n dp[d][v - 1] = i + 1\n \nfor i in reversed(range(1, 11)):\n for u, v in edges:\n dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])\n dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])\n \nprint(*[color[dp[0][i]] for i in range(n)], sep = '\\n')", "neg": "n, m = map(int, input().split())\nedges = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(m)]\nedges += [[i, i] for i in range(n)]\n\nq = int(input())\ncolor = [0] * q\ndp = [[0 for j in range(n)] for i in range(11)]\nfor i in range(q):\n v, d, color[i] = map(int, input().split())\n dp[d][v - 1] = i\n \nfor i in reversed(range(1, 11)):\n for u, v in edges:\n dp[i - 1][u] = max(dp[i - 1][u], dp[i][v])\n dp[i - 1][v] = max(dp[i - 1][v], dp[i][u])\n \nprint(*[color[dp[0][i]] for i in range(n)], sep = '\\n')", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [244, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03768", "p_user": "u379559362", "n_user": "u379559362", "pos": "n, m = map(int, input().split())\nnode = [[] for _ in range(n + 1)]\nfor i in range(m):\n a, b = map(int, input().split())\n node[a].append(b)\n node[b].append(a)\n\nq = int(input())\nnode_color = [0 for _ in range(n + 1)]\nvdc = [list(map(int, input().split())) for _ in range(q)]\n\nvdc = vdc[::-1]\npainted = set()\nvisited = [[0] * 11 for _ in range(n + 1)]\n\n\ndef dfs(now, dist, color):\n if dist < 0:\n return\n if visited[now][dist]:\n return\n\n visited[now][dist] += 1\n if not node_color[now]:\n node_color[now] = color\n\n for x in node[now]:\n dfs(x, dist - 1, color)\n\n\nfor i in vdc:\n v, d, c = i\n dfs(v, d, c)\n\nfor m in range(n):\n print(node_color[m + 1])\n", "neg": "q = int(input())\nnode_color = [0 for _ in range(n + 1)]\nvdc = [list(map(int, input().split())) for _ in range(q)]\n\nvdc = vdc[::-1]\npainted = set()\nvisited = [[0] * 11 for _ in range(n + 1)]\n\n\ndef dfs(now, dist, color):\n if dist < 0:\n return\n if visited[now][dist]:\n return\n\n visited[now][dist] += 1\n if not node_color[now]:\n node_color[now] = color\n\n for x in node[now]:\n dfs(x, dist - 1, color)\n\n\nfor i in vdc:\n v, d, c = i\n dfs(v, d, c)\n\nfor m in range(n):\n print(node_color[m + 1])\n", "jacc_sim": 0.94, "nl": "Score: 700 points\nProblem Statement: Squid loves painting vertices in graphs. There is a simple undirected graph with N vertices numbered 1 through N and M edges. Initially, all vertices are color 0. The i-th edge connects two vertices a_i and b_i bidirectionally with a length of 1. Squid performs Q operations on the graph. In the i-th operation, he repaints all vertices within a distance of d_i from vertex v_i in color c_i. Find the color of each vertex after the Q operations.\nConstraints:\n- 1 \u2264 N, M, Q \u2264 10^5\n- 1 \u2264 a_i, b_i, v_i \u2264 N\n- a_i \u2260 b_i\n- 0 \u2264 d_i \u2264 10\n- 1 \u2264 c_i \u2264 10^5\n- d_i and c_i are integers\n- No self-loops or multiple edges in the given graph\nPartial Score: 200 points for passing the test set satisfying 1 \u2264 N, M, Q \u2264 2,000\nInput: N M, a_1 b_1, ..., a_M b_M, Q, v_1 d_1 c_1, ..., v_Q d_Q c_Q\nOutput: Print the answer in N lines. In the i-th line, print the color of vertex i after the Q operations.\nSample Input 1: 7 7, 1 2, 1 3, 1 4, 4 5, 5 6, 5 7, 2 3, 2, 6 1 1, 1 2 2\nSample Output 1: 2, 2, 2, 2, 2, 1, 0\nSample Input 2: 14 10, 1 4, 5 7, 7 11, 4 10, 14 7, 14 3, 6 14, 8 11, 5 13, 8 3, 8, 8 6 2, 9 7 85, 6 9 3, 6 7 5, 10 3 1, 12 9 4, 9 6 6, 8 2 3\nSample Output 2: 1, 0, 3, 1, 5, 5, 3, 3, 6, 1, 3, 4, 5, 3", "before_after_length": [288, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u245960901", "n_user": "u245960901", "pos": "s = list(map(int, input().split()))\nn=s[0]\nk=s[1]\nprint((n+k)%24)\n ", "neg": "s = list(map(int, input().split()))\nn=s[0]\nk=s[1]\nprint((n+k))\n ", "jacc_sim": 0.9047619047619048, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [39, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u027403702", "n_user": "u027403702", "pos": "A,B = map(int, input().split())\n# N = int(input())\n# A = int(input())\nprint((A + B) % 24) ", "neg": "A,B = map(int, input().split())\n# N = int(input())\n# A = int(input())\nprint((A % 24) + B)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [39, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u290187182", "n_user": "u290187182", "pos": "import sys\nimport copy\nimport math\nimport bisect\nimport pprint\nimport bisect\nfrom functools import reduce\nfrom copy import deepcopy\nfrom collections import deque\n\nif __name__ == '__main__':\n a = [int(i) for i in input().split()]\n print((a[0]+a[1] )%24)", "neg": "import sys\nimport copy\nimport math\nimport bisect\nimport pprint\nimport bisect\nfrom functools import reduce\nfrom copy import deepcopy\nfrom collections import deque\n\nif __name__ == '__main__':\n a = [int(i) for i in input().split()]\n print(a[0]+a[1] %24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [76, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u681444474", "n_user": "u681444474", "pos": "# coding: utf-8\n# Your code here!\na, b = map(int,input().split())\n\nprint((a+b) % 24)", "neg": "# coding: utf-8\n# Your code here!\na, b = map(int,input().split())\n\nprint(a + b)", "jacc_sim": 0.92, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [36, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u992910889", "n_user": "u992910889", "pos": "A,B=map(int,input().split())\n#print(sorted(B)[0])\nprint((A+B)%24)", "neg": "A,B=map(str,input().split())\n#print(sorted(B)[0])\nprint((A+B)%24)", "jacc_sim": 0.9047619047619048, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [32, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u636311816", "n_user": "u636311816", "pos": "a,b = list(map(int, input().split()))\nres = (a+b)%24\nprint(res)", "neg": "a,b = list(map(int, input().split()))\n\nres = (a+b)%24", "jacc_sim": 0.9411764705882353, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [30, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u593590006", "n_user": "u593590006", "pos": "a,b=map(int,input().split())\nprint((a+b+12-12)%24)", "neg": "a,b=map(int,input().split())\nprint((a+b+12)%24)", "jacc_sim": 0.9411764705882353, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [26, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u891438775", "n_user": "u891438775", "pos": "def r_t(n):\n return sum(map(int, n.split()))%24\nprint(r_t(input()))", "neg": "def r_t(n):\n return sum(map(int, n.split()))%24\nr_t(input())", "jacc_sim": 0.9411764705882353, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [33, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u370331385", "n_user": "u790865353", "pos": "A,B = map(int,input().split())\na = (A+B)%24\nprint(a)", "neg": "A,B=map(int,input().split())\nprint((a + b) % 24)", "jacc_sim": 0.9411764705882353, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [27, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u367130284", "n_user": "u367130284", "pos": "a=map(int,input().split());print(sum(a)%24)", "neg": "a,b=map(int,input().split());print(sum(a,b)%24)", "jacc_sim": 0.9375, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [19, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u950708010", "n_user": "u256823895", "pos": "a,b = (int(i) for i in input().split())\n\nprint((a+b)%24)", "neg": "a, b = (int(i) for i in input().split()) \nprint (a+b)%24", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [27, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u131405882", "n_user": "u131405882", "pos": "num = list(map(int, input().split()))\na = num[0] + num[1]\nprint(int(a%24))\n", "neg": "num = list(map(int, input().split()))\na = num[0] + num[1]\nprint(int(a/24))\n", "jacc_sim": 0.9047619047619048, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [35, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u939552576", "n_user": "u394482932", "pos": "print(eval(\"(\"+input().replace(' ','+')+\")%24\"))", "neg": "print(eval(int,input().replace(\" \",\"+\"))%24)", "jacc_sim": 0.9230769230769231, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [19, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u612721349", "n_user": "u372144784", "pos": "n,m=map(int,input().split());print((n+m)%24)", "neg": "n,m = map(int,input().split())\n\nprint((n+m%24))", "jacc_sim": 0.9375, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [21, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u785205215", "n_user": "u785205215", "pos": "def read_int_list():\n return list(int(i) for i in input().split())\n \nx,y = read_int_list()\nprint((x+y)%24)\n", "neg": "def read_int_list():\n return list(int(i) for i in input().split())\nx,y = read_int_list()\nprint((x+y)%12)", "jacc_sim": 0.9130434782608695, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [47, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u996252264", "n_user": "u996252264", "pos": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\n \na,b = rli()\nprint((a+b)%24)", "neg": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\n\na,b = rli()\nprint(a+b%24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [75, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u806201407", "n_user": "u343437894", "pos": "\na, b = map(int, input().split(\" \"));\nprint( (a+b) % 24);\n", "neg": "a, b = map(int, input().split(\" \");\nprint( (a+b) % 24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [27, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u532087742", "n_user": "u532087742", "pos": "# coding: utf-8\nimport sys\n\nfor line in sys.stdin.readlines():\n a = line.strip().split(\" \")\n a1 = int(a[0])\n a2 = int(a[1])\n print((a1+a2) % 24)", "neg": "# coding: utf-8\nimport sys\n\nfor line in sys.stdin.readlines():\n a = line.strip().split(\" \")\n a1 = int(a[0])\n a2 = int(a[1])\n print(a1+a2 % 24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [67, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u057586044", "n_user": "u057586044", "pos": "time = input()\nans = time.split()\nprint((int(ans[0]) + int(ans[1])) % 24)", "neg": "time = input()\nans = time.split()\nprint(int(ans[0]) + int(ans[1]) % 24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [30, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u076936237", "n_user": "u076936237", "pos": "def main():\n A, B = tuple(map(int, input().split(' ')))\n print('{}'.format((A+B)%24))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n A, B = tuple(map(int, raw_input().split(' ')))\n print('{}'.format((A+B)%24))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9259259259259259, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [53, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u481165257", "n_user": "u481165257", "pos": "if __name__ == \"__main__\":\n times = [int(time) for time in input().split()]\n A = times[0]\n B = times[1]\n print((A+B)%24)", "neg": "if __name__ == \"__main__\":\n times = [int(time) for time in input().split()]\n print((A+B)%24)", "jacc_sim": 0.9230769230769231, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [53, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u265689893", "n_user": "u265689893", "pos": "# -*- coding: utf-8 -*-\nA, B = map(int, input().split())\nprint(\"%d\" % ((A+B)%24))\n", "neg": "# -*- coding: utf-8 -*-\nA, B = map(int, input().split())\nprint(\"%d\" % (A+B%24))\n", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [40, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u209647862", "n_user": "u209647862", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\na, b = map(int, input().split())\nprint((a + b) % 24)\n", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\na, b = map(int, input().split())\nprint((a + b) % 23)\n", "jacc_sim": 0.9310344827586207, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [47, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u803848678", "n_user": "u803848678", "pos": "N, K = list(map(int, input().split()))\nprint((N+K)%24)", "neg": "N, K = list(map(int, input().split()))\nprint(N+K%24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [25, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u481333386", "n_user": "u481333386", "pos": "# -*- coding: utf-8 -*-\n\n\ndef main():\n a, b = [int(e) for e in input().split()]\n answer = (a + b) % 24\n return answer\n\n\nprint(main())\n", "neg": "# -*- coding: utf-8 -*-\n\n\ndef main():\n a, b = [int(e) for e in input().split()]\n answer = (a + b) % 23\n return answer\n\n\nprint((main())\n", "jacc_sim": 0.9354838709677419, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [60, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u755962107", "n_user": "u559722042", "pos": "a, b = map(int, input().split())\nprint ((a+b)%24)", "neg": "a,b = map(int,input().split())\nprint((a+b)%24+1)", "jacc_sim": 0.9375, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [22, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u132528440", "n_user": "u343437894", "pos": "a,b = input().split(\" \")\na = int(a)\nb = int(b)\nprint((a + b) % 24)", "neg": "a, b = map(int, input().split(\" \"))\n\nprint(a+b%24)", "jacc_sim": 0.9375, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [33, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u202619899", "n_user": "u333190709", "pos": "A, B = map(int, input().split())\nA += B\nA %= 24\nprint(A)", "neg": "A, B = map(int. input().split())\n\nprint((A + B) % 24)", "jacc_sim": 1.0, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [25, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u234395310", "n_user": "u238130426", "pos": "a,b = map(int,input().split(' '))\nprint((a+b)%24)", "neg": "a, b = map(int, split.input())\nprint((a+b)%24)", "jacc_sim": 0.9375, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [24, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03773", "p_user": "u886790158", "n_user": "u682997551", "pos": "A, B = list(map(int, input().split()))\n\nans = (A + B) % 24\nprint(ans)\n", "neg": "A, B = map(int, input().split())\n\nans = A + B % 24\n\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "Dolphin enjoys participating in programming contests and is about to take part in an AtCoder contest. In this country, they use a 24-hour clock system. Given the current time as A o'clock and the contest starting in B hours, determine the time when the contest will begin in 24-hour format. Constraints: 0 \u2264 A,B \u2264 23, where A and B are integers. The input is given in the format A B, and the output should be the starting time of the contest in 24-hour format. For example, if the input is 9 12, the output should be 21. If the input is 19 0, the output should be 19, indicating that the contest has just started. If the input is 23 2, the output should be 1, indicating that the contest will begin at 1 o'clock the next day.", "before_after_length": [32, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03780", "p_user": "u258009780", "n_user": "u258009780", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\na = sorted(a)[::-1]\nans = n\nsm = 0\n\nfor i in range(n):\n if sm + a[i] < k:\n sm += a[i]\n else:\n ans = min(ans, n - i - 1)\n\nprint(ans)\n", "neg": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\na = sorted(a)[::-1]\nans = n\nsm = 0\n\nfor i in range(0, n):\n if sm + a[i] < k:\n sm += a[i];\n else:\n ans = min(ans, i);\n\nprint(ans)\n", "jacc_sim": 0.9696969696969697, "nl": "AtCoDeer the deer has N cards with positive integers written on them. He considers a subset of the cards \"good\" if the sum of the numbers in the subset is at least K. For each card, he determines if it's \"unnecessary\" based on whether removing it from any good subset still leaves a good subset. The task is to find the number of unnecessary cards. Constraints: 1 \u2264 N \u2264 5000, 1 \u2264 K \u2264 5000, 1 \u2264 ai \u2264 10^9 (1 \u2264 i \u2264 N). The input format is N K followed by the values of a1 to aN. The output should be the number of unnecessary cards.", "before_after_length": [100, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u277104886", "n_user": "u277104886", "pos": "x = int(input())\n\nn = int((2*x)**0.5)\n\nfor i in range(n, n+3):\n if i*(i+1) >= x*2:\n print(i)\n exit()", "neg": "x = int(input())\n\nn = int((2*x)**0.5)\n\nfor i in range(n, n+3):\n if i*(i+1) > x*2:\n print(i)\n exit()", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [58, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u357751375", "n_user": "u230265105", "pos": "x = int(input())\ni = 1\nwhile x > 0:\n x -= i\n i += 1\nprint(i-1)\n", "neg": "x = int(input())\ni = 0\nwhile x>0\n i = i+1\n x = x-i\nprint(i)", "jacc_sim": 0.9333333333333333, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [34, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u693974737", "n_user": "u468972478", "pos": "n = int(input())\ni = 1\nwhile n > 0:\n n -= i\n i += 1\ni -= 1\nprint(i)\n", "neg": "n = int(input())\ni = 1\nwhile n > 0:\n n -= i\n i += 1\nprint(i)", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [36, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u430223993", "n_user": "u430223993", "pos": "n = int(input())\nimport sys\nif n == 1:\n print(1)\n sys.exit()\nfor i in range(1,n**2):\n if round(i*(i+1)/2) >= n:\n print(i)\n sys.exit()", "neg": "n = int(input())\nimport sys\nfor i in range(1,n):\n if i*(i+1)/2 >= n:\n print(i)\n sys.exit()", "jacc_sim": 0.96, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [67, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u845937249", "n_user": "u845937249", "pos": "import sys\nimport os\nif sys.platform==\"darwin\":\n\tbase = os.path.dirname(os.path.abspath(__file__))\n\tname = os.path.normpath(os.path.join(base, '../Documents/input.txt'))\n\t#print(name)\n\tsys.stdin = open(name)\n\nx = int(input())\nchk = 0\ni = 1\n\nwhile chk < x:\n\tchk = chk + i\n\ti = i + 1\n\t#print(chk,i)\n\nprint(i-1)\n", "neg": "import sys\nimport os\nif sys.platform==\"darwin\":\n\tbase = os.path.dirname(os.path.abspath(__file__))\n\tname = os.path.normpath(os.path.join(base, '../Documents/input.txt'))\n\t#print(name)\n\tsys.stdin = open(name)\n\nx = int(input())\nchk = 0\ni = 1\n\nwhile chk < x:\n\tchk = chk + i\n\ti = i + 1\n\tprint(chk,i)\n\nprint(i-1)\n", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [132, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u109617108", "n_user": "u109617108", "pos": "X=int(input())\ni=1\nsum1=1\nwhile sum1=x:\n\t\tprint(i)\n\t\tbreak", "neg": "x=int(input())\nfor i in range(1,x):\n\tif (i+1)*i*0.5>=x:\n\t\tprint(i)\n\t\tbreak", "jacc_sim": 0.9166666666666666, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [48, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u767664985", "n_user": "u767664985", "pos": "X = int(input())\nfor i in range(1, X + 1):\n\tif i * (i - 1) / 2 < X <= i * (i + 1) / 2:\n\t\tprint(i)\n\t\texit()\n", "neg": "X = int(input())\nfor i in range(1, X):\n\tif i * (i - 1) / 2 < X <= i * (i + 1) / 2:\n\t\tprint(i)\n\t\texit()\n", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [56, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u102960641", "n_user": "u488127128", "pos": "import math\nx = int(input()) * 2\nans = math.ceil((-1 + (1+4*x) ** 0.5) / 2)\nprint(ans)", "neg": "import math\nx = int(input())\nprint(-(-((x*2+1/4)**0.5-1/2)//1))", "jacc_sim": 0.9047619047619048, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [42, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u163320134", "n_user": "u163320134", "pos": "n=int(input())\ntmp=0\nfor i in range(100000):\n tmp+=i\n if tmp>=n:\n print(i)\n break", "neg": "n=int(input())\ntmp=0\nfor i in range(100000):\n tmp+=i\n if tmp>=n:\n print(i)", "jacc_sim": 0.9473684210526315, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [42, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u397531548", "n_user": "u397531548", "pos": "N=int(input())\na=0\ni=0\nwhile a=n:\n ans=i\n break\nprint(ans)\n", "neg": "n=int(input())\nans=0\nfor i in range(n+1):\n if i*(i+1)/2>n:\n ans=i\n break\nprint(ans)\n", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [48, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u329865314", "n_user": "u329865314", "pos": "x=int(input())\nfor i in range(100000):\n if i * (i+1) >= 2 * x:\n print(i)\n quit()", "neg": "x=int(input())\nfor i in range(100000):\n if i * i+1 >= 2 * x:\n print(i)\n quit()", "jacc_sim": 1.0, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [40, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u018679195", "n_user": "u388971072", "pos": "X = int(input())\nfor i in range(1, 100000):\n if i*(i+1)/2 >= X:\n print(i)\n exit(0)", "neg": "X = int(input())\n\nfor i in range(1,X):\n if(i*(i+1)//2>=X):\n print(i)\n exit()", "jacc_sim": 0.9130434782608695, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [41, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03781", "p_user": "u140806166", "n_user": "u140806166", "pos": "x = int(input())\nd = 0\nfor i in range(1, 10 ** 6):\n d += i\n if x <= d:\n print(i)\n break\n", "neg": "x = input()\nd = 0\nfor i in range(1, 10 ** 6):\n d += i\n if x <= d:\n print(i)\n break\n\n\n", "jacc_sim": 0.9565217391304348, "nl": "The kangaroo starts at coordinate 0 on an infinite number line. At each time step, it can stay in place or jump left or right by a distance equal to the current time step. The goal is to find the earliest time the kangaroo can reach a specific coordinate X on the number line. The input is the value of X, and the output should be the earliest possible time for the kangaroo to reach coordinate X. The constraints are that X is an integer and 1 \u2264 X \u2264 10^9.", "before_after_length": [44, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03791", "p_user": "u827202523", "n_user": "u827202523", "pos": "import sys\n# from collections import defaultdict, deque\n# import math\n# import copy\nfrom bisect import bisect_left, bisect_right\n# import heapq\n\n# sys.setrecursionlimit(1000000)\n\n# input aliases\ninput = sys.stdin.readline\n\ngetS = lambda: input().strip()\ngetN = lambda: int(input())\ngetList = lambda: list(map(int, input().split()))\ngetZList = lambda: [int(x) - 1 for x in input().split()]\n\nINF = 10 ** 20\nMOD = 10 ** 9 + 7\ndef solve():\n n = getN()\n nums = getList()\n kaijyo = [1, 1]\n\n for i in range(2, n + 3):\n kaijyo.append((kaijyo[-1] * i % MOD))\n # print(kaijyo)\n\n ans = 1\n cnt = 0\n for num in nums:\n cnt +=1\n if num <= (cnt - 1) * 2:\n # ans *= kaijyo[cnt]\n ans *= cnt\n ans %= MOD\n cnt -= 1\n\n prev = num\n ans *= kaijyo[cnt]\n ans %= MOD\n print(ans)\n # print((11 * kaijyo[10]) % MOD)\n # print(pow(311014372, MOD -2, MOD))\n\ndef main():\n n = getN()\n for _ in range(n):\n solve()\nif __name__ == \"__main__\":\n # main()\n solve()\n", "neg": "import sys\n# from collections import defaultdict, deque\n# import math\n# import copy\nfrom bisect import bisect_left, bisect_right\n# import heapq\n\n# sys.setrecursionlimit(1000000)\n\n# input aliases\ninput = sys.stdin.readline\n\ngetS = lambda: input().strip()\ngetN = lambda: int(input())\ngetList = lambda: list(map(int, input().split()))\ngetZList = lambda: [int(x) - 1 for x in input().split()]\n\nINF = 10 ** 20\nMOD = 1000000007\ndef solve():\n n = getN()\n nums = getList()\n kaijyo = [1, 1]\n\n for i in range(2, n + 3):\n kaijyo.append((kaijyo[-1] * i % MOD))\n\n ans = 1\n prev = -1\n sukima = 0\n cnt = 0\n for num in nums:\n sukima += num - prev - 1\n\n if sukima < cnt:\n ans *= kaijyo[cnt]\n ans %= MOD\n cnt -= 1\n sukima += 1\n cnt += 1\n prev = num\n # print(ans, cnt, sukima)\n ans *= kaijyo[cnt]\n ans %= MOD\n print(ans)\n\ndef main():\n n = getN()\n for _ in range(n):\n solve()\nif __name__ == \"__main__\":\n # main()\n solve()\n", "jacc_sim": 0.9125, "nl": "You are developing frog-shaped robots and want to race them. Initially, you place N robots on a number line, each with a unique coordinate. Robots can jump to adjacent unoccupied coordinates. When a robot's coordinate becomes 0 or less, it's removed. Find the number of different orders in which the N robots can finish the race, considering the modulo 10^9+7. Constraints: 2 \u2264 N \u2264 10^5, 0 < x1 < x2 < ... < xN \u2264 10^9. For a partial score of 500 points, N \u2264 8. Input format: N followed by N coordinates. Output the number of different orders modulo 10^9+7.", "before_after_length": [380, 365], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03791", "p_user": "u102960641", "n_user": "u102960641", "pos": "mod = 10 ** 9 + 7\nn = int(input())\nX = list(map(int, input().split()))\n\nans = []\nnow_x = 0\nnow_num = 0\nfree = n\nfor k,x in enumerate(X):\n now_num += 1\n dist = x - now_x\n if (dist-1) // 2 + 1 < now_num:\n ans += [free] * (now_num)\n free -= 1\n now_num = 0\n now_x = x\nans += [free] * now_num\nres = 1\nfor k,v in enumerate(ans[::-1]):\n res *= v-k\n res %= mod\nprint(res)", "neg": "mod = 10 ** 9 + 7\nn = int(input())\nX = list(map(int, input().split()))\n\nans = []\nnow_x = 0\nnow_num = 0\nfree = n\nfor k,x in enumerate(X):\n now_num += 1\n dist = x - now_x\n if dist // 2 + 1 < now_num:\n ans += [free] * (now_num-1)\n free -= 1\n now_num = 1\n now_x = x-1\nans += [free] * now_num\nres = 1\nres2 = 1\nprint(ans)\nfor k,v in enumerate(ans[::-1]):\n print(v-k)\n res *= v-k\n res %= mod\nprint(res)", "jacc_sim": 0.9767441860465116, "nl": "You are developing frog-shaped robots and want to race them. Initially, you place N robots on a number line, each with a unique coordinate. Robots can jump to adjacent unoccupied coordinates. When a robot's coordinate becomes 0 or less, it's removed. Find the number of different orders in which the N robots can finish the race, considering the modulo 10^9+7. Constraints: 2 \u2264 N \u2264 10^5, 0 < x1 < x2 < ... < xN \u2264 10^9. For a partial score of 500 points, N \u2264 8. Input format: N followed by N coordinates. Output the number of different orders modulo 10^9+7.", "before_after_length": [170, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03791", "p_user": "u622011073", "n_user": "u622011073", "pos": "input()\na=b=1\nfor r in input().split():\n a=a*b%(10**9+7)\n if b*2M//2:\n ans=M//2\n N-=ans\n if M%2==0:\n M=0\n else:\n M=1\nelse:\n ans=N\n M-=N*2\n N=0\n if M>3:\n X=M//4\n M-=X*4\n ans+=X\nwhile True:\n if M<2:\n break\n if N==0:\n if M<4:\n break\n if N>0:\n N-=1\n M-=2\n ans+=1\n elif M>3:\n M-=2\n ans+=1\nprint(ans)", "neg": "N,M=map(int,input().split())\nans=M//2\nN-=M//2\nif M%2==0:\n M=0\nelse:\n M=1\nif N<0:\n X=abs(N)\n N+=X\n ans-=X\n M+=X*2\nwhile True:\n if M<2:\n break\n if N==0:\n if M<4:\n break\n if N>0:\n N-=1\n M-=2\n ans+=1\n elif M>3:\n M-=2\n ans+=1\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [185, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u730769327", "n_user": "u163320134", "pos": "n,m=map(int,input().split())\nif 2*n>=m:print(m//2)\nelse:print((m//2+n)//2)", "neg": "n,m=map(int,input().split())\nif n>=m//2:\n print(m//2)\nelse:\n print(n+(m-2*n)//3)", "jacc_sim": 0.9090909090909091, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [41, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u143051858", "n_user": "u143051858", "pos": "s,c = map(int,input().split())\nres = 0\nif s*2 <= c:\n res = s\n c -= s*2\n s = 0\nelse:\n res += c//2\n c = 0\n\nif c:\n res += c//4\nprint(res)", "neg": "s,c = map(int,input().split())\nres = 0\n\nif s*2 <= c:\n res += s\n c -= s*2\n res+= c\nelse:\n res += c//2\n c //= 2\nif c:\n res += m//4\nprint(res)", "jacc_sim": 0.96, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [73, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u593567568", "n_user": "u593567568", "pos": "N,M = map(int,input().split())\n\ndef solve(N,M):\n # \u4eca\u3042\u308b\u3082\u306e\n if M < N * 2:\n return M // 2\n \n M -= N * 2\n \n ans = N + (M // 4)\n return ans\n\nprint(solve(N,M))\n", "neg": "N,M = map(int,input().split())\n\ndef solve(N,M):\n # \u4eca\u3042\u308b\u3082\u306e\n if M < N * 2:\n return N\n \n M -= N * 2\n \n ans = N + M // 3\n return ans\n\nprint(solve(N,M))\n", "jacc_sim": 0.9375, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [90, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u954774382", "n_user": "u954774382", "pos": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\n# import math\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(int(pow(10, 2)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\n\n\nn,m=l()\nif(m<2*n):\n print(m//2)\nelif(m==2*n):\n print(n)\nelse:\n print(n+(m-2*n)//4)", "neg": "import sys\nfrom functools import lru_cache, cmp_to_key\nfrom heapq import merge, heapify, heappop, heappush\nfrom math import *\n# import math\nfrom collections import defaultdict as dd, deque, Counter as C\nfrom itertools import combinations as comb, permutations as perm\nfrom bisect import bisect_left as bl, bisect_right as br, bisect\nfrom time import perf_counter\nfrom fractions import Fraction\n# sys.setrecursionlimit(int(pow(10, 2)))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = int(pow(10, 9) + 7)\nmod2 = 998244353\ndef data(): return sys.stdin.readline().strip()\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var))+end)\ndef l(): return list(sp())\ndef sl(): return list(ssp())\ndef sp(): return map(int, data().split())\ndef ssp(): return map(str, data().split())\ndef l1d(n, val=0): return [val for i in range(n)]\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\n\n\n\n# @lru_cache(None)\n\n\nn,m=l()\nif(m<2*n):\n print(m//2)\nelif(m==2*n):\n print(n)\nelse:\n print(n+(m-n)//4)", "jacc_sim": 1.0, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [385, 383], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u048176319", "n_user": "u048176319", "pos": "n,m = map(int, input().split())\n\nif n > (m+n)/3:\n print(m//2)\n exit()\nif m > 10000000000:\n print(m//4)\n exit()\n\nwhile n <= (n+m)/3:\n n += 1\n m -= 2\n\nprint(n-1)", "neg": "n,m = map(int, input().split())\n\nif n > (m+n)/3:\n print(m//2)\n exit()\nif m > 100000:\n print(m//4)\n exit()\n\nwhile n <= (n+m)/3:\n n += 1\n m -= 2\n\nprint(n-1)", "jacc_sim": 0.9259259259259259, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [85, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u024782094", "n_user": "u024782094", "pos": "import sys\nfrom collections import Counter\nfrom collections import deque\nimport math\ndef input(): return sys.stdin.readline().strip()\ndef mp(): return map(int,input().split())\ndef lmp(): return list(map(int,input().split()))\n\nn,m=mp()\n\nif 2*n>=m:\n print(m//2)\n exit()\nprint(n+math.ceil((m-2*n)//4))", "neg": "import sys\nfrom collections import Counter\nfrom collections import deque\nimport math\ndef input(): return sys.stdin.readline().strip()\ndef mp(): return map(int,input().split())\ndef lmp(): return list(map(int,input().split()))\n\nn,m=mp()\nif m<2:\n print(0)\n exit()\nif n>=2*m:\n print(m//2)\n exit()\nprint(n+-(-(m-2*n)//4))", "jacc_sim": 0.925, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [108, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u442877951", "n_user": "u442877951", "pos": "S,C = map(int,input().split())\nans = min(S,C//2)\nC -= 2*ans\nS = C//2\nans += S//2\n\nprint(ans)\n", "neg": "S,C = map(int,input().split())\nans = min(S,C//2)\nC -= 2*ans\nans += C//3\n\nprint(ans)", "jacc_sim": 0.95, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [48, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u318127926", "n_user": "u936985471", "pos": "n, m = map(int, input().split())\ns = n\nc = m//2\nif s>c:\n print(c)\nelse:\n print((s+c)//2)", "neg": "n,m=map(int,input().split())\nc=m//2\nif n>c:\n print(c)\nelse:\n print(s+c//2)", "jacc_sim": 1.0, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [48, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u707124227", "n_user": "u048176319", "pos": "n,m=map(int,input().split())\nif n==m//2:\n print(m//2)\n exit()\nif n>m//2:\n print(m//2)\n exit()\nans=0\nans+=n\nm-=2*n\nans+=m//4\nprint(ans)\n", "neg": "n,m = map(int, input().split())\n\nif n > (m+n)/3:\n print(m//2)\n exit()\n\nans = n\nm -= 2*n\nans += m//4", "jacc_sim": 0.92, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [81, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u994521204", "n_user": "u994521204", "pos": "n,m=map(int,input().split())\np1=n\np2=m//2\nif p1>p2:\n print(p2)\nelse:\n delta=p2-p1\n print(delta//2+p1)", "neg": "n,m=map(int,input().split())\np1=n\np2=m//2\nif p1>p2:\n \tprint(p2)\nelse:\n\tdelta=p2-p1\n print(delta//2+p1)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [62, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u984276646", "n_user": "u984276646", "pos": "N, M = map(int, input().split())\nif 2 * N > M:\n print(M // 2)\nelse:\n C = M // 2\n n = (C - N) // 2\n print(max(min(N+n-1, C-n+1), min(N+n, C-n), min(N+n+1, C-n-1)))\n", "neg": "N, M = map(int, input().split())\nif 2 * N > M:\n print(M // 2)\nelse:\n C = M // 2\n n = (C - N) // 2\n print(max(min(S+n-1, C-n+1), min(S+n, C-n), min(S+n+1, C-n-1)))", "jacc_sim": 0.9629629629629629, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [94, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u278356323", "n_user": "u278356323", "pos": "# ARC069c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n\n n, m = map(int, input().split())\n if m > n*2:\n print(n+(m-n*2)//4)\n else:\n print(m//2)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# ARC069c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n\n n, m = map(int, input().split())\n if n > m*2:\n print(m//2+(n-m//2)//2)\n else:\n print(n)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9722222222222222, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [105, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u777283665", "n_user": "u777283665", "pos": "s, c = map(int, input().split())\n\ncnt = 0\nif c < s*2:\n cnt = c//2\n print(cnt)\nelse:\n cnt = s\n c -= 2*s\n cnt += c//4\n print(cnt)", "neg": "s, c = map(int, input().split())\n\ncnt = 0\nif c < s*2:\n cnt = c//2\n print(cnt)\nelse:\n cnt = s\n cnt += c//4\n print(cnt)", "jacc_sim": 0.9583333333333334, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [66, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u802963389", "n_user": "u861141787", "pos": "n, m = map(int, input().split())\nif m // 2 > n:\n sadd = (m - 2 * n) // 4\n print(n + sadd)\nelse:\n print(min(n, m // 2))", "neg": "n, m = map(int, input().split())\n\n\nif n > m // 4:\n print(n + (m - 2 * n) // 4)\nelse:\n print(m // 4 + min(n, m % 4 // 2))", "jacc_sim": 0.92, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [59, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u163320134", "n_user": "u163320134", "pos": "n,m=map(int,input().split())\nif 2*n<=m:\n print(n+(m-2*n)//4)\nelse:\n print(m//2)", "neg": "n,m=map(int,input().split())\nif 2*n<=m:\n print(n+(m-2*n)//3)\nelse:\n print(m//2)", "jacc_sim": 0.9130434782608695, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [48, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u724742135", "n_user": "u724742135", "pos": "from sys import exit, stdin\nN, M = [int(_) for _ in stdin.readline().rstrip().split()]\nr = M-2*N\nif r <= 0:\n print(M//2)\nelse:\n print(N+r//4)", "neg": "from sys import exit, stdin\nN, M = [int(_) for _ in stdin.readline().rstrip().split()]\nr = M-2*N\nif r <= 0:\n print(N//2)\nelse:\n pritnt(N+r//4)", "jacc_sim": 0.9714285714285714, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [64, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u859897687", "n_user": "u859897687", "pos": "s,c=map(int,input().split())\nif s*2>=c:\n print(c//2)\nelse:\n ans=s\n c-=s*2\n ans+=c//4\n print(ans)\n", "neg": "s,c=map(int,input().split())\nif s>=c*2:\n print(s)\nelse:\n ans=s\n c-=s*2\n ans+=c//3\n print(ans)", "jacc_sim": 0.9166666666666666, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [60, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u357050210", "n_user": "u858670323", "pos": "n,m = map(int,input().split())\nans = 0\nif m >= 2 * n :\n ans += n\n m -= 2 * n\nelse:\n ans += m//2\n m = 0 \nans += (m//4)\nprint(ans)\n", "neg": "n,m = map(int,input().split())\nans = 0\nif 2*n>m:\n ans += m//2\nelse:\n ans += n\n m -= 2*n\n ans += m//3\n \nprint(ans)", "jacc_sim": 0.92, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [66, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u655975843", "n_user": "u655975843", "pos": "import sys\nimport collections\nns = lambda: sys.stdin.readline().rstrip()\nni = lambda: int(ns())\nnm = lambda: map(int, sys.stdin.readline().split())\nnl = lambda: list(nm())\nnsl = lambda: map(str, sys.stdin.readline().split())\n\nn, m = nm()\nif m >= 2 * n:\n c = m - 2 * n\n print(n + (c // 4))\nelse:\n print(m // 2)\n", "neg": "import sys\nimport collections\nns = lambda: sys.stdin.readline().rstrip()\nni = lambda: int(ns())\nnm = lambda: map(int, sys.stdin.readline().split())\nnl = lambda: list(nm())\nnsl = lambda: map(str, sys.stdin.readline().split())\n\nn, m = nm()\nif m >= 2 * n:\n c = 2 * n - m\n print(n + (c // 4))\nelse:\n print(n)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [123, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef POW(x, y):\n if y == 0:\n return 1\n elif y == 1:\n return x\n elif y % 2 == 0:\n return POW(x, y // 2) ** 2 % MOD\n else:\n return POW(x, y // 2) ** 2 * x % MOD\ndef mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom functools import reduce\n\ndef main():\n N, M = LI()\n if N >= M // 2:\n return M // 2\n rem = M - 2 * N\n ans = N + rem // 4\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef POW(x, y):\n if y == 0:\n return 1\n elif y == 1:\n return x\n elif y % 2 == 0:\n return POW(x, y // 2) ** 2 % MOD\n else:\n return POW(x, y // 2) ** 2 * x % MOD\ndef mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom functools import reduce\n\ndef main():\n N, M = LI()\n if N >= 2 * M:\n return M\n rem = 2 * M - N\n ans = M + rem // 3\n return ans\n\nprint(main())", "jacc_sim": 0.9666666666666667, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [298, 296], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u669696235", "n_user": "u637824361", "pos": "N,M=map(int,input().split())\n\nans=0\nif(M//2>=N):\n ans+=N\n M-=N*2\n ans+=M//4\nelse:\n ans+=M//2\n\nprint(ans)", "neg": "N, M = map(int, input().split())\nans = 0\nif N > M//2:\n print(M//2)\nelse:\n p = M - 2*N\n print(N + p//4", "jacc_sim": 0.96, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [66, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u064408584", "n_user": "u222668979", "pos": "n,m=map(int, input().split())\nans,m=min(n,m//2),m-n*2\nprint(ans+max(0,m//4))", "neg": "n, m = map(int, input().split())\n\nans = max(n, m // 2)\nans += (m - ans * 2) // 4\nprint(ans)\n", "jacc_sim": 0.9090909090909091, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [43, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u932465688", "n_user": "u503111914", "pos": "N,M = map(int,input().split())\nif (2*N <= M):\n print(N+((M-2*N)//4))\nelse:\n print(M//2)", "neg": "N,M = map(int()input().split())\nif N <= M//2+1:\n print(N)\nelse:\n print(N+(M-N*2)//4)", "jacc_sim": 0.9565217391304348, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [48, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u742897895", "n_user": "u131881594", "pos": "n, m = map(int,input().split())\n\nif n >= m // 2:\n ans = m // 2\n\nelse:\n ans = n\n m -= n * 2\n ans += m // 4\n\nprint(ans)\n", "neg": "n,m=map(int,input().split())\nif 2*n>=m: print(m//2)\nelse:\n print(n+m//4)", "jacc_sim": 0.9130434782608695, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [58, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u835482198", "n_user": "u179169725", "pos": "N, M = map(int, input().split())\n\nans = min(N, M // 2)\nN -= ans\nM -= (ans * 2)\n\nans += M // 4\n\nprint(ans)\n", "neg": "N,M=map(int,input().split())\nn1=min(N,M//2)\nN-=n1\nM-=2*n1\nprint(ans+(M-2*n1)//4)\n", "jacc_sim": 0.9523809523809523, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [50, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u340781749", "n_user": "u272028993", "pos": "n, m = map(int, input().split())\nif n * 2 >= m:\n print(m // 2)\nelse:\n print(n + (m - n * 2) // 4)\n", "neg": "n,m=map(int,raw_input().split())\nif n>=2*m:\n print m/2\nelse:\n m-=2*n\n print n+m/4\n", "jacc_sim": 0.9130434782608695, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [48, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u622011073", "n_user": "u622011073", "pos": "n,m=map(int,input().split())\nprint(min(m+2*n,2*m)//4)", "neg": "n,m=map(int,input().split())\nprint(min((m+2*n),2*m)//2)", "jacc_sim": 0.9444444444444444, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [30, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u880644800", "n_user": "u880644800", "pos": "def solve(s, c):\n \"\"\"rv = min(Sr, Cr//2), where\n Sr = S + a\n Cr = C - 2a # a>=0, a is number of (2c->S) conversions\n thus\n rv = max(min(S + a, C//2 - a) for a in range(0, C//2))\n if a >=0, optimum is Sr == Cr//2, thus\n S + a == Cr//2 - a\n a = (C//2 - S) / 2\n \"\"\"\n a = (c / 2 - s) / 2\n if a < 0:\n a = 0\n al = int(a)\n ar = int(a) + 1\n return max(min(s + a, c//2 - a) for a in (al, ar))\n\n\nif __name__ == \"__main__\":\n import sys\n S, C = map(int, sys.stdin.readline().split())\n print(solve(S, C))\n\n\ndef test_solve():\n assert solve(1, 2) == 1\n assert solve(0, 4) == 1\n assert solve(0, 1) == 0\n\n\ndef test_atcode():\n assert solve(1, 6) == 2\n assert solve(12345, 678901) == 175897", "neg": "def solve(s, c):\n \"\"\"rv = min(Sr, Cr//2), where\n Sr = S + a\n Cr = C - 2a # a>=0, a is number of (2c->S) conversions\n thus\n rv = max(min(S + a, C//2 - a) for a in range(0, C//2))\n if a >=0, optimum is Sr == Cr//2, thus\n S + a == Cr//2 - a\n a = (C//2 - S) / 2\n \"\"\"\n a = (c / 2 - s) / 2\n if a < 0:\n a = 0\n al = int(a)\n ar = int(a) + 1\n return max(min(s + a, c//2 - a) for a in (al, ar))\n\n\nif __name__ == \"__main__\":\n import sys\n S, C = sys.stdin.readline().split()\n print(solve(s, c))\n\n\ndef test_solve():\n assert solve(1, 2) == 1\n assert solve(0, 4) == 1\n assert solve(0, 1) == 0\n\n\ndef test_atcode():\n assert solve(1, 6) == 2\n assert solve(12345, 678901) == 175897", "jacc_sim": 0.9838709677419355, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [324, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u309333806", "n_user": "u309333806", "pos": "n, m = (int(_) for _ in input().split())\nans = min(n, m // 2)\nm -= ans * 2\nans += m // 4\nprint(ans)\n", "neg": "n, m = (int(_) for _ in input().split())\nans = min(n, m // 2)\nm -= ans * 2\nans += m // 3\nprint(ans)\n", "jacc_sim": 0.9130434782608695, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [44, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u327466606", "n_user": "u495415554", "pos": "N, M = map(int, input().split())\n\nif 2*N >= M:\n print(M//2)\nelse:\n result = N\n M -= 2*N\n result += M//4\n print(result)", "neg": "N, M = map(int, input().split())\n\nif N >= 2 * M:\n print(M // 2)\nelse:\n print(N + ((M - 2 * N) // 4)", "jacc_sim": 0.9565217391304348, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [57, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03799", "p_user": "u123756661", "n_user": "u333139319", "pos": "n,m=[int(i) for i in input().split()]\nans=0\nif m>=n*2:\n ans=n\n m-=n*2\n ans+=m//4\nelse:\n ans=m//2\nprint(ans)", "neg": "[n,m] = [int(i) for i in input().split()]\nif n * 2 >= m:\n print(n)\nelse:\n if m >= 2:\n ans = n\n m = min(m - n * 2,0)\n ans += m//4\n print(ans)\n else:\n print(0)\n", "jacc_sim": 0.9655172413793104, "nl": "Score: 300 points\nProblem Statement:\nSnuke loves puzzles. Today, he is working on a puzzle using S- and c-shaped pieces. In this puzzle, you can combine two c-shaped pieces into one S-shaped piece. Snuke wants to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces. Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.\nConstraints:\n1 \u2264 N,M \u2264 10^12\nInput:\nThe input is given from Standard Input in the following format:\nN M\nOutput:\nPrint the answer.\nSample Input 1:\n1 6\nSample Output 1:\n2\nTwo Scc groups can be created as follows:\n- Combine two c-shaped pieces into one S-shaped piece\n- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces\nSample Input 2:\n12345 678901\nSample Output 2:\n175897", "before_after_length": [65, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u144913062", "n_user": "u144913062", "pos": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\na = list(map(int, input().split()))\naa = list(set(a))\naa.sort()\ncompress = {aa[i]: i for i in range(len(aa))}\ncnt = [0] * len(aa)\nidx = [-1] * len(aa)\nfor i in range(N)[::-1]:\n n = compress[a[i]]\n cnt[n] += 1\n idx[n] = i\nans = [0] * N\nfor n in range(1, len(aa))[::-1]:\n i = idx[n]\n ans[i] += cnt[n] * (aa[n] - aa[n-1])\n cnt[n-1] += cnt[n]\n idx[n-1] = min(idx[n-1], i)\nans[0] += N * aa[0]\nprint(*ans, sep='\\n')", "neg": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\na = list(map(int, input().split()))\naa = list(set(a))\naa.sort()\ncompress = {aa[i]: i for i in range(len(aa))}\ncnt = [0] * len(aa)\nidx = [-1] * len(aa)\nfor i in range(N)[::-1]:\n n = compress[a[i]]\n cnt[n] += 1\n idx[n] = i\nans = [0] * N\nfor n in range(1, len(aa))[::-1]:\n i = idx[n]\n ans[i] += cnt[n] * (aa[n] - aa[n-1])\n cnt[n-1] += cnt[n]\n idx[n-1] = min(idx[n-1], i)\n print(ans)\nans[0] += N * aa[0]\nprint(*ans, sep='\\n')", "jacc_sim": 1.0, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [237, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u922449550", "n_user": "u922449550", "pos": "N = int(input())\nA = [0] + list(map(int, input().split()))\nB = [[a, i, 1] for i, a in enumerate(A)]\nC = sorted(B, reverse=True)\na_max, idx = 0, 0 # [value, idx]\nleft_max = [[0, 0] for i in range(N+1)] # [value, idx]\nfor i, a in enumerate(A):\n left_max[i] = [a_max, idx]\n if a > a_max:\n a_max, idx = a, i\n\nans = [0] * (N+1)\nnext_i = C[0][1]\nfor _, i, _ in C:\n a, _, num = B[i]\n if i == next_i:\n next_a, next_i = left_max[i]\n now_i = i\n ans[i] += (a - next_a) * num\n B[next_i][2] += num\n else:\n ans[now_i] += (a - next_a) * num\n B[next_i][2] += num\n\nprint(*ans[1:], sep='\\n')", "neg": "N = int(input())\nA = [0] + list(map(int, input().split()))\nB = [[a, i, 1] for i, a in enumerate(A)]\nC = sorted(B, reverse=True)\na_max, idx = 0, 0 # [value, idx]\nleft_max = [[0, 0] for i in range(N+1)] # [value, idx]\nfor i, a in enumerate(A):\n left_max[i] = [a_max, idx]\n if a > a_max:\n a_max, idx = a, i\n\nprint(left_max)\nans = [0] * (N+1)\nnext_i = C[0][1]\nprint(B)\nprint(C)\nfor _, i, _ in C:\n a, _, num = B[i]\n if i == next_i:\n next_a, next_i = left_max[i]\n now_i = i\n ans[i] += (a - next_a) * num\n B[next_i][2] += num\n else:\n ans[now_i] += (a - next_a) * num\n B[next_i][2] += num\n \n\nprint(*ans[1:], sep='\\n')", "jacc_sim": 1.0, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [295, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u819048695", "n_user": "u819048695", "pos": "N=int(input())\nA=list(map(int,input().split()))\n\nnum=A[0]\ndata=[[A[0],0]]\n\nfor i in range(1,N):\n if A[i]>num:\n data.append([A[i],i])\n num=A[i]\n \nB=sorted(A,reverse=True)\nC=[0]*N\nC[0]=B[0]\nfor i in range(1,N):\n C[i]=C[i-1]+B[i]\n \n \nans=[0]*N\ncnt=0\nkkk=0\nfor i in range(len(data)-1,0,-1):\n \n zzz=data[i-1][0]\n while kkkzzz:\n kkk+=1\n num=C[kkk-1]-kkk*zzz\n num-=cnt\n ans[data[i][1]]=num\n cnt+=num\n\nans[0]=sum(A)-sum(ans)\n\nfor u in ans:\n print(u)", "neg": "N=int(input())\nA=list(map(int,input().split()))\n\nnum=A[0]\ndata=[[A[0],0]]\n\nfor i in range(1,N):\n if A[i]>num:\n data.append([A[i],i])\n num=A[i]\n \nB=sorted(A,reverse=True)\n\nans=[0]*N\n\nkkk=0\nfor i in range(len(data)-1,0,-1):\n \n zzz=data[i][0]\n while kkk=zzz:\n kkk+=1\n \n ans[data[i][1]]=(zzz-data[i-1][0])*kkk\n cnt+=1\nans[0]=sum(A)-sum(ans)\n\nfor u in ans:\n print(u)", "jacc_sim": 0.9777777777777777, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [283, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u392319141", "n_user": "u392319141", "pos": "N = int(input())\nA = [(a, i) for i, a in enumerate(map(int, input().split()))]\nA.sort(reverse=True)\nA.append((0, 0))\n\nans = [0] * N\nnow = float('inf')\n\nfor j, (a, i) in enumerate(A[:N], start=1):\n now = min(now, i)\n ans[now] += j * (a - A[j][0])\n\nprint(*ans, sep='\\n')\n", "neg": "N = int(input())\nA = [(a, i) for i, a in enumerate(map(int, input().split()))]\nA.sort(reverse=True)\nA.append((0, 0))\n\nans = [0] * N\nnow = float('inf')\n\nfor j, (a, i) in enumerate(A[:N], start=1):\n now = min(now, a)\n ans[now] += j * (now - A[j][0])\n\nprint(*ans, sep='\\n')\n", "jacc_sim": 1.0, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [127, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u426108351", "n_user": "u426108351", "pos": "N = int(input())\na = list(map(int, input().split()))\nb = []\nfor i in range(N):\n b.append([a[i], i+1])\nb.sort(reverse = True)\nans = [0]*(N+1)\nmini = N+1\n\nfor i in range(N-1):\n mini = min(mini, b[i][1])\n if b[i+1][0] - b[i][0] < 0:\n ans[mini] += (b[i][0] - b[i+1][0])*(i+1)\n\nans[1] += N*b[-1][0]\nfor i in range(N):\n print(ans[i+1])\n", "neg": "N = int(input())\na = list(map(int, input().split()))\nb = []\nfor i in range(N):\n b.append([a[i], i+1])\nb.sort(reverse = True)\nans = [0]*(N+1)\nmini = N+1\n\nfor i in range(N-1):\n mini = min(mini, b[i][1])\n if b[i+1][0] - b[i][0] < 0:\n ans[mini] += (b[i][0] - b[i+1][0])*(i+1)\n\nans[1] += N*min(b)\nfor i in range(N):\n print(ans[i+1])\n", "jacc_sim": 1.0, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [183, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u281303342", "n_user": "u281303342", "pos": "from collections import Counter\nN = int(input())\nS = list(map(int,input().split()))\nT = []\nfor i in range(N):\n T.append((i,S[i]))\nU = sorted(T,key=lambda x:x[1], reverse=True)\n\nAns = [0]*N\nc,v = 0,10**10\n\nfor i in range(N-1):\n c+=1\n v = min(v,U[i][0])\n if U[i][1]==U[i+1][1]:\n continue\n else:\n Ans[v] += (U[i][1] - U[i+1][1])*c\nelse:\n Ans[0] = 0\n Ans[0] = sum(S) - sum(Ans)\n\nfor i in range(N):\n print(Ans[i])", "neg": "from collections import Counter\nN = int(input())\nS = list(map(int,input().split()))\nT = []\nfor i in range(N):\n T.append((i,S[i]))\nU = sorted(T,key=lambda x:x[1], reverse=True)\n\nAns = [0]*N\nc,v = 0,10**10\n\nfor i in range(N-1):\n c+=1\n v = min(v,U[i][0])\n if U[i][1]==U[i+1][1]:\n continue\n else:\n Ans[v] += (U[i][1] - U[i+1][1])*c\nelse:\n Ans[0] += U[i+1][1]\n\nfor i in range(N):\n print(Ans[i])", "jacc_sim": 0.9787234042553191, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [218, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03801", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = int(input())\nlis = list(map(int, input().split()))\n\nkey = lis[0]\nnum = [0]\nli = [key]\nfor i in range(1,n):\n\tif lis[i] > key:\n\t\tkey = lis[i]\n\t\tnum.append(i)\n\t\tli.append(key)\n\nm = len(li)\nnu = [li[0]]+[li[i+1]-li[i] for i in range(m-1)]\n\nhe = [0]*m\ncou = [0]*m\n\nfrom bisect import bisect_left\n\nfor k in lis:\n\tsen = bisect_left(li,k)\n\tcou[sen] += k -li[sen]\n\the[sen] += 1\n\nkey = 0\nfor i in reversed(range(m)):\n\tkey += he[i]\n\the[i] = key\n\nfor i in range(m):\n\tcou[i] += he[i]*nu[i]\n\nans = [0]*n\nfor i,c in zip(num,cou):\n\tans[i] = c\n\nfor r in ans:\n\tprint(r)", "neg": "n = int(input())\nlis = list(map(int, input().split()))\nkey = lis[0]\nnum = [0]\nli = [key]\nfor i in range(1,n):\n\tif lis[i] > key:\n\t\tline = lis[i]\n\t\tnum.append(i)\n\t\tli.append(line)\nm = len(li)\nnu = [li[0]]+[li[i+1]-li[i] for i in range(m-1)]\nhe = [0]*m\ncou = [0]*m\nfrom bisect import bisect_left\nfor k in lis:\n\tsen = bisect_left(li,k)\n\tcou[sen] += k -li[sen]\n\the[sen] += 1\nt = 0\nfor i in reversed(range(m)):\n\tt += he[i]\n\the[i] = t\nfor i in range(m):cou[i] += he[i]*nu[i]\nans = [0]*n\nfor i,c in zip(num,cou):ans[i] = c\nfor r in ans:print(r)", "jacc_sim": 0.9591836734693877, "nl": "Snuke enjoys creating integer sequences. Given N piles of stones, each with a certain number of stones, Snuke constructs a sequence by repeatedly selecting the pile with the most stones and removing one stone from it. This process continues until no piles have stones left. The goal is to find the lexicographically smallest sequence and determine how many times each integer from 1 to N occurs in that sequence. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 a_i \u2264 10^9. The input is given as N followed by the number of stones in each pile. The output should display the occurrences of each integer in the lexicographically smallest sequence.", "before_after_length": [298, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u911449886", "n_user": "u911449886", "pos": "from copy import deepcopy\n\ndef getval():\n n,ma,mb = map(int,input().split())\n p = [list(map(int,input().split())) for i in range(n)]\n return n,ma,mb,p \n\ndef main(n,ma,mb,p):\n dp = [[[-1 for i in range(401)] for i in range(401)]]\n dp[0][0][0] = 0\n for i in range(n):\n temp = deepcopy(dp[-1])\n temp[0][0] = 0\n cur = p[i]\n prev = dp[-1]\n for a in range(401):\n for b in range(401):\n if cur[0]>a or cur[1]>b:\n continue\n if prev[a-cur[0]][b-cur[1]]==-1:\n continue\n elif prev[a][b]==-1:\n temp[a][b] = prev[a-cur[0]][b-cur[1]] + cur[2]\n #print(i,a,b,temp[a][b],prev[a-cur[0]][b-cur[1]])\n else:\n temp[a][b] = min(prev[a][b], prev[a-cur[0]][b-cur[1]] + cur[2])\n dp.append(temp)\n ans = -1\n for i in range(1,401):\n if i*ma>400 or i*mb>400:\n break\n if dp[n][i*ma][i*mb]!=-1:\n if ans==-1:\n ans = dp[n][i*ma][i*mb]\n else:\n ans = min(ans,dp[n][i*ma][i*mb])\n print(ans)\n #print(dp[n])\n\nif __name__==\"__main__\":\n n,ma,mb,p = getval()\n main(n,ma,mb,p)\n", "neg": "from copy import deepcopy\n\ndef getval():\n n,ma,mb = map(int,input().split())\n p = [list(map(int,input().split())) for i in range(n)]\n return n,ma,mb,p \n\ndef main(n,ma,mb,p):\n dp = [[[-1 for i in range(401)] for i in range(401)]]\n dp[0][0][0] = 0\n for i in range(n):\n temp = deepcopy(dp[-1])\n temp[0][0] = 0\n cur = p[i]\n prev = dp[-1]\n for a in range(401):\n for b in range(401):\n if cur[0]>a or cur[1]>b:\n continue\n if prev[a-cur[0]][b-cur[1]]==-1:\n continue\n elif prev[a][b]==-1:\n temp[a][b] = prev[a-cur[0]][b-cur[1]] + cur[2]\n #print(i,a,b,temp[a][b],prev[a-cur[0]][b-cur[1]])\n else:\n temp[a][b] = min(prev[a][b], prev[a-cur[0]][b-cur[1]] + cur[2])\n #dp.append(temp)\n ans = -1\n for i in range(1,11):\n if i*ma>10 or i*mb>10:\n break\n if dp[n][i*ma][i*mb]!=-1:\n if ans==-1:\n ans = dp[n][i*ma][i*mb]\n else:\n ans = min(ans,dp[n][i*ma][i*mb])\n print(ans)\n print(dp[n])\n\nif __name__==\"__main__\":\n n,ma,mb,p = getval()\n main(n,ma,mb,p)", "jacc_sim": 0.9508196721311475, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [492, 491], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u020604402", "n_user": "u020604402", "pos": "N, Ma, Mb = map(int,input().split())\nL = []\nfor _ in range(N):\n L.append( list(map(int,input().split())) )\ndp = [[[10**10 for _ in range(601)] for _ in range(601)] for _ in range(N+10)]\ndp[0][0][0] = 0\n\nfor l in range(N):\n for i in range(200):\n for j in range(200):\n dp[l+1][i][j] = min(dp[l+1][i][j],dp[l][i][j])\n dp[l+1][i+L[l][0]][j+L[l][1]] = min(dp[l+1][i+L[l][0]][j+L[l][1]],dp[l][i][j] + L[l][2])\n\n\nans = 10**10\nfor i in range(1,10000):\n try: ans = min(ans, dp[N][Ma*i][Mb*i])\n except: pass\nif ans == 10**10: print(-1)\nelse: print(ans)\n\n\n\n", "neg": "N, Ma, Mb = map(int,input().split())\nL = []\nfor _ in range(N):\n L.append( list(map(int,input().split())) )\ndp = [[[10**10 for _ in range(601)] for _ in range(601)] for _ in range(N+10)]\ndp[0][0][0] = 0\n\nfor l in range(N):\n for i in range(200):\n for j in range(200):\n dp[l+1][i][j] = min(dp[l+1][i][j],dp[l][i][j])\n dp[l+1][i+L[l][0]][j+L[l][1]] = min(dp[l+1][i+L[l][0]][j+L[l][1]],dp[l][i][j] + L[l][2])\n\n\nans = 10**10\nfor i in range(1,10000):\n try: ans = min(ans, dp[N+1][Ma*i][Mb*i])\n except: pass\nif ans == 10**10: print(-1)\nelse: print(ans)\n\n\n\n", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [287, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u995062424", "n_user": "u995062424", "pos": "def main():\n N, Ma, Mb = map(int, input().split())\n yakuhin = []\n sa = 0\n sb = 0\n for i in range(N):\n yakuhin.append(list(map(int, input().split())))\n sa += yakuhin[i][0]\n sb += yakuhin[i][1]\n \n INF = 10**15\n DP = [[[INF for _ in range(sb+1)] for _ in range(sa+1)] for _ in range(N+1)]\n \n for i in range(N):\n DP[i][0][0] = 0\n \n for i in range(N):\n for j in range(sa+1):\n for k in range(sb+1):\n if(j >= yakuhin[i][0] and k >= yakuhin[i][1]):\n DP[i+1][j][k] = min(DP[i][j][k], DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]]+yakuhin[i][2])\n else:\n DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])\n \n ans = INF\n for i in range(1, N+1):\n for j in range(1, sa+1):\n for k in range(1, sb+1):\n if(j*Mb == k*Ma):\n ans = min(ans, DP[i][j][k]) \n \n print(ans if ans != INF else -1)\n \nmain()", "neg": "def main():\n N, Ma, Mb = map(int, input().split())\n yakuhin = []\n sa = 0\n sb = 0\n for i in range(N):\n yakuhin.append(list(map(int, input().split())))\n sa += yakuhin[i][0]\n sb += yakuhin[i][1]\n \n INF = 10**15\n DP = [[[INF for _ in range(sb+1)] for _ in range(sa+1)] for _ in range(N+1)]\n DP[0][0][0] = 0\n \n for i in range(N):\n for j in range(sa+1):\n for k in range(sb+1):\n if(j >= yakuhin[i][0] and k >= yakuhin[i][1]):\n DP[i+1][j][k] = min(DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]], DP[i][j-yakuhin[i][0]][k-yakuhin[i][1]]+yakuhin[i][2])\n else:\n DP[i+1][j][k] = min(DP[i+1][j][k], DP[i][j][k])\n \n ans = INF\n for i in range(1, N):\n for j in range(1, sa+1):\n for k in range(1, sb+1):\n if(j*Mb == k*Ma):\n ans = min(ans, DP[i][j][k]) \n \n print(ans if ans != INF else -1)\n \nmain()", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [431, 440], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u500297289", "n_user": "u500297289", "pos": "N, Ma, Mb = map(int, input().split())\nabc = [list(map(int, input().split())) for _ in range(N)]\n\ninf = float('inf')\ndp = [[[inf] * 401 for _ in range(401)] for _ in range(N + 1)]\n\ndp[0][0][0] = 0\n\nfor i in range(N):\n for j in range(401):\n for k in range(401):\n dp[i + 1][j][k] = dp[i][j][k]\n if j - abc[i][0] >= 0 and k - abc[i][1] >= 0:\n dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j - abc[i][0]][k - abc[i][1]] + abc[i][2])\nans = inf\nfor a in range(1, 401):\n for b in range(1, 401):\n if a * Mb == b * Ma:\n ans = min(ans, dp[N][a][b])\nif ans == inf:\n ans = -1\nprint(ans)\n", "neg": "N, Ma, Mb = map(int, input().split())\nabc = [list(map(int, input().split())) for _ in range(N)]\n\ninf = float('inf')\ndp = [[[inf] * 401 for _ in range(401)] for _ in range(N + 1)]\n\ndp[0][0][0] = 0\n\nfor i in range(N - 1):\n for j in range(401):\n for k in range(401):\n if j - abc[i][0] >= 0 and k - abc[i][1] >= 0:\n dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - abc[i][0]][k - abc[i][1]] + abc[i][2])\nans = inf\nfor a in range(401):\n if a % Ma == 0:\n b = a // Ma * Mb\n if b <= 401:\n ans = min(ans, dp[N][a][b])\nif ans == inf:\n ans = -1\nprint(ans)\n", "jacc_sim": 0.9347826086956522, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [281, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u994521204", "n_user": "u994521204", "pos": "import sys\ninput = sys.stdin.buffer.readline\nn,ma,mb=map(int,input().split())\nABC=[list(map(int,input().split())) for _ in range(n)]\ninfi=10**15\ndp=[[[infi]*(401) for _ in range(401)]for _ in range(41)]\ndp[0][0][0]=0\nfor i in range(n):\n a,b,c=ABC[i]\n for j in range(401-a):\n for k in range(401-b):\n ni=i+1\n nj=j+a\n nk=k+b\n dp[ni][j][k]=min(dp[ni][j][k], dp[i][j][k])\n dp[ni][nj][nk]=min(dp[i][j][k]+c,dp[ni][nj][nk])\n\nans=infi\nfor i in range(1,401):\n if ma*i>400:\n break\n if mb*i>400:\n break \n ans=min(ans, dp[n][ma*i][mb*i])\nprint(ans if ans!=infi else -1)", "neg": "import sys\ninput = sys.stdin.buffer.readline\nn,ma,mb=map(int,input().split())\nABC=[list(map(int,input().split())) for _ in range(n)]\ninfi=10**15\ndp=[[[infi]*(401) for _ in range(401)]for _ in range(41)]\ndp[0][0][0]=0\nfor i in range(n):\n a,b,c=ABC[i]\n for j in range(401-a):\n for k in range(401-b):\n ni=i+1\n dp[ni][j][k]=min(dp[ni][j][k], dp[i][j][k])\n dp[ni][nj][nk]=min(dp[i][j][k]+c,dp[ni][nj][nk])\n\nans=infi\nfor i in range(1,401):\n if ma*i>400:\n break\n if mb*i>400:\n break \n ans=min(ans, dp[n][ma*i][mb*i])\nprint(ans if ans!=infi else -1)", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [292, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u893063840", "n_user": "u893063840", "pos": "n, ma, mb = map(int, input().split())\nabc = [list(map(int, input().split())) for _ in range(n)]\n\nINF = 40 * 100 + 1\nab_max = 10 * n\n\ndp = [[[INF] * (ab_max + 1) for _ in range(ab_max + 1)] for _ in range(n + 1)]\ndp[0][0][0] = 0\n\nfor i, (a, b, c) in enumerate(abc, 1):\n for j in range(ab_max + 1):\n for k in range(ab_max + 1):\n dp[i][j][k] = dp[i-1][j][k]\n if j - a >= 0 and k - b >= 0:\n if dp[i-1][j-a][k-b] != INF:\n dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a][k-b] + c)\n\n\nans = INF\nfor j in range(1, ab_max + 1):\n for k in range(1, ab_max + 1):\n if j * mb == k * ma:\n ans = min(ans, dp[n][j][k])\n\nif ans == INF:\n ans = -1\n\nprint(ans)\n", "neg": "n, ma, mb = map(int, input().split())\nabc = [list(map(int, input().split())) for _ in range(n)]\n\nINF = 40 * 100 + 1\nab_max = 10 * n\n\ndp = [[[INF] * (ab_max + 1) for _ in range(ab_max + 1)] for _ in range(n + 1)]\ndp[0][0][0] = 0\n\nfor i, (a, b, c) in enumerate(abc, 1):\n for j in range(ab_max + 1):\n for k in range(ab_max + 1):\n dp[i][j][k] = dp[i-1][j][k]\n if j - a >= 0 and k - b >= 0:\n if dp[i-1][j-a][k-b] != INF:\n dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a][k-b] + c)\n\n\nans = INF\nfor j in range(1, ab_max + 1):\n for k in range(1, ab_max + 1):\n if j * mb == k * ma:\n ans = min(ans, dp[n][j][k])\n\nif ans == INF:\n ans = -1\n\nprint(ans)\nprint(*dp[n], sep=\"\\n\")", "jacc_sim": 0.9387755102040817, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [321, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u595289165", "n_user": "u595289165", "pos": "import numpy as np\nn, ma, mb = map(int, input().split())\nr = 10 * n + 6\ninf = 10**5\ndp = np.full((n+1, r, r), inf)\ndp[0][0][0] = 0\nfor i in range(n):\n a, b, c = map(int, input().split())\n dp[i+1][a:, b:] = np.minimum(\n dp[i][:r-a, :r-b] + c, dp[i][a:, b:]\n )\n dp[i+1] = np.minimum(dp[i+1], dp[i])\n\nans = inf\nx, y = 0, 0\nwhile True:\n x += ma\n y += mb\n if x < r and y < r:\n ans = min(ans, dp[n][x][y])\n else:\n break\nif ans == inf:\n print(-1)\nelse:\n print(int(ans))", "neg": "import numpy as np\nn, ma, mb = map(int, input().split())\nr = 10 * n + 6\ninf = 10**5\ndp = np.full((n+1, r, r), inf)\ndp[0][0][0] = 0\nfor i in range(n):\n a, b, c = map(int, input().split())\n for j in range(r):\n for k in range(r):\n if j + a < r and k + b < r:\n dp[i+1][j+a][k+b] = min(\n dp[i][j][k] + c, dp[i][j+a][k+b]\n )\n dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k])\n\nans = inf\nx, y = 0, 0\nfor i in range(1, n+1):\n while True:\n x += ma\n y += mb\n if x < r and y < r:\n ans = min(ans, dp[i][x][y])\n else:\n break\nif ans == inf:\n print(-1)\nelse:\n print(int(ans))", "jacc_sim": 0.9433962264150944, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [241, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u557494880", "n_user": "u557494880", "pos": "N,Ma,Mb = map(int,input().split())\ndp = [[[10**9 for i in range(401)] for j in range(401)] for k in range(N+1)]\ndp[0][0][0] = 0\nfor i in range(1,N+1):\n a,b,c = map(int,input().split())\n for j in range(401):\n for k in range(401):\n if j < a:\n dp[i][j][k] = dp[i-1][j][k]\n else:\n if k < b:\n dp[i][j][k] = dp[i-1][j][k]\n else:\n dp[i][j][k] = min(dp[i-1][j][k],dp[i-1][j-a][k-b] + c)\nm = max(Ma,Mb)\nimport math\nn = math.floor(400 / m)\nans = 10**9\nfor i in range(1,400):\n x = Ma*i\n y = Mb*i\n if x > 400:\n break\n if y > 400:\n break\n ans = min(dp[N][x][y],ans)\nif ans == 10**9:\n print(-1)\n quit()\nprint(ans)", "neg": "N,Ma,Mb = map(int,input().split())\ndp = [[[10**9 for i in range(400)] for j in range(400)] for k in range(N+1)]\ndp[0][0][0] = 0\nfor i in range(1,N+1):\n a,b,c = map(int,input().split())\n for j in range(401):\n for k in range(401):\n if j < a:\n d[i][j][k] = d[i-1][j][k]\n else:\n if k < b:\n d[i][j][k] = d[i-1][j][k]\n else:\n d[i][j][k] = min(d[i-1][j][k],d[i-1][j-a][k-b] + c)\nm = max(Ma,Mb)\nimport math\nn = math.floor(400 / m)\nans = 10**9\nfor i in range(n):\n x = Ma*i\n y = Mb*i\n ans = min(dp[N][x][y])\nprint(ans)", "jacc_sim": 0.9245283018867925, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [325, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u780475861", "n_user": "u780475861", "pos": "n, ma, mb = [int(i) for i in input().split()]\nlst = [[int(i) for i in input().split()] for _ in range(n)]\nlst.sort(key=lambda x: x[2])\ndic = {}\ndef push(k,v):\n if k in dic:\n dic[k] = min(dic[k],v)\n else:\n dic[k] = v\n\n\nfor i in lst:\n k, v = i[0] * mb - i[1] * ma, i[2]\n l = [[j, dic[j]] for j in dic]\n for item in l:\n push(item[0] + k, item[1] + v)\n push(k, v)\n\nprint(dic[0] if 0 in dic else '-1')", "neg": "n, ma, mb = [int(i) for i in input().split()]\nlst = [[int(i) for i in input().split()] for _ in range(n)]\nlst.sort(key=lambda x: x[2])\n\ndef push(k,v):\n if k in dic:\n dic[k] = min(dic[k],v)\n else:\n dic[k] = v\n\n\nfor i in lst:\n k, v = i[0] * mb - i[1] * ma, i[2]\n l = [[j, dic[j]] for j in dic]\n for item in l:\n push(item[0] + k, item[1] + v)\n push(k, v)\n\nprint(dic[0] if 0 in dic else '-1')", "jacc_sim": 0.9555555555555556, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [199, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u263830634", "n_user": "u263830634", "pos": "N, Ma, Mb = map(int, input().split())\n\nINF = 10 ** 8\n\nlst = [[INF] * 401 for i in range(401)]\nlst[0][0] = 0\n\nfor _ in range(N):\n a, b, c = map(int, input().split())\n for i in range(400, a - 1, -1):\n for j in range(400, b - 1, -1):\n if lst[i- a][j - b] == INF:\n pass\n else:\n lst[i][j] = min(lst[i][j], lst[i - a][j - b] + c)\n\nans = INF\nn = 400 // max(Ma, Mb)\nfor i in range(1, n + 1):\n ans = min(ans, lst[Ma * i][Mb * i])\n\nif ans == INF:\n print (-1)\nelse:\n print (ans)\n\n# for i in range(7):\n# print (lst[i][:7])", "neg": "N, Ma, Mb = map(int, input().split())\n\nINF = 10 ** 8\n\nlst = [[INF] * 401 for i in range(401)]\nlst[0][0] = 0\n\nfor _ in range(N):\n a, b, c = map(int, input().split())\n for i in range(a, 401):\n for j in range(b, 401):\n if lst[i][j] == INF:\n pass\n else:\n lst[i][j] = min(lst[i][j], lst[i - a][j - b] + c)\n\nans = INF\nn = 400 // max(Ma, Mb)\nfor i in range(1, n + 1):\n ans = min(ans, lst[Ma * i][Mb * i])\n\nif ans == INF:\n print (-1)\nelse:\n print (ans)", "jacc_sim": 0.9565217391304348, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [252, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u314906167", "n_user": "u314906167", "pos": "inf = float(\"inf\")\nN, Ma, Mb = map(int, input().split())\nABC = []\nfor _ in range(N):\n a, b, c = map(int, input().split())\n ABC.append((a, b, c))\ndp = [[inf] * 420 for _ in range(420)]\ndp[0][0] = 0\nfor a, b, c in ABC:\n for i in range(410, -1, -1):\n for j in range(410, -1, -1):\n if dp[i][j] < inf:\n dp[i+a][j+b] = min(dp[i+a][j+b], dp[i][j] + c)\nans = inf\nn = 1\nwhile max(Ma * n, Mb * n) < 420:\n ans = min(ans, dp[Ma * n][Mb * n])\n n += 1\nprint(ans if ans < inf else -1)\n", "neg": "inf = float(\"inf\")\nN, Ma, Mb = map(int, input().split())\nABC = []\nfor _ in range(N):\n a, b, c = map(int, input().split())\n ABC.append((a, b, c))\ndp = [[inf] * 420 for _ in range(420)]\ndp[0][0] = 0\nfor a, b, c in ABC:\n for i in range(410):\n for j in range(410):\n if dp[i][j] < inf:\n dp[i+a][j+b] = min(dp[i+a][j+b], dp[i][j] + c)\nans = inf\nn = 1\nwhile max(Ma * n, Mb * n) < 420:\n print(Ma * n, Mb * n)\n ans = min(ans, dp[Ma * n][Mb * n])\n n += 1\nprint(ans if ans < inf else -1)\n", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [241, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u820047642", "n_user": "u820047642", "pos": "n,ma,mb=map(int,input().split())\nab=[[[10**6]*401 for _ in range(401)] for _ in range(n+1)]\nab[0][0][0]=0\n\nfor p in range(1,n+1):\n a,b,c=map(int,input().split())\n for i in range(400):\n for j in range(400):\n ab[p][i][j]=min(ab[p][i][j],ab[p-1][i][j])\n if i+a<=400 and j+b<=400:\n ab[p][i+a][j+b]=min(ab[p][i+a][j+b],ab[p-1][i][j]+c)\n\nans=10**6-1\nfor i in range(401):\n for j in range(401):\n if i!=0 and j!=0:\n if i*mb==j*ma:\n ans=min(ans,ab[n][i][j])\n\nif ans==10**6-1:\n print(-1)\nelse:\n print(ans)", "neg": "n,ma,mb=map(int,input().split())\nab=[[[10**6]*401 for _ in range(401)] for _ in range(n+1)]\nab[0][0][0]=0\n\nfor p in range(1,n+1):\n a,b,c=map(int,input().split())\n for i in range(400):\n for j in range(400):\n if i+a<=400 and j+b<=400:\n ab[p][i+a][j+b]=min(ab[p][i+a][j+b],ab[p-1][i][j]+c)\n\nans=10**6-1\nfor i in range(401):\n for j in range(401):\n if i!=0 and j!=0:\n if i*mb==j*ma:\n ans=min(ans,ab[n][i][j])\n\nif ans==10**6-1:\n print(-1)\nelse:\n print(ans)", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [278, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u116002573", "n_user": "u116002573", "pos": "def main():\n\n N, Ma, Mb = map(int, input().split())\n drug = []\n for _ in range(N):\n a, b, c = map(int, input().split())\n drug.append([a, b, c])\n\n cur = dict()\n cur[(0, 0)] = 0\n for i in range(N):\n temp = cur.copy()\n for p in cur:\n a, b = p[0]+drug[i][0], p[1]+drug[i][1]\n\n if (a, b) not in temp:\n temp[(a, b)] = cur[p] + drug[i][2]\n else:\n temp[(a, b)] = min(temp[(a, b)], cur[p]+drug[i][2])\n cur = temp\n\n # print(cur)\n min_c = float('inf')\n for p in cur:\n if p != (0, 0) and p[0]*Mb == p[1]*Ma:\n min_c = min(min_c, cur[p])\n if min_c == float('inf'):\n return -1\n else:\n return min_c\n\nif __name__ == '__main__':\n print(main())", "neg": "def main():\n\n N, Ma, Mb = map(int, input().split())\n drug = []\n for _ in range(N):\n a, b, c = map(int, input().split())\n drug.append([a, b, c])\n\n cur = dict()\n cur[(0, 0)] = 0\n for i in range(N):\n temp = cur.copy()\n for p in cur:\n a, b = p[0]+drug[i][0], p[1]+drug[i][1]\n\n if (a, b) not in temp:\n temp[(a, b)] = cur[p] + drug[i][2]\n else:\n temp[(a, b)] = min(temp[(a, b)], cur[p]+drug[i][2])\n cur = temp\n\n # print(cur)\n min_c = float('inf')\n for p in cur:\n if p != (0, 0) and p[0]*Mb == p[1]*Ma:\n min_c = min(min_c, cur[p])\n if min_c == float('inf'):\n return -1\n else:\n return min_c\n", "jacc_sim": 0.9622641509433962, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [321, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u347640436", "n_user": "u347640436", "pos": "import sys\ninf = float('inf')\nn, ma, mb = map(int, input().split())\nt = [[inf] * 401 for _ in range(401)]\nt[0][0] = 0\nfor _ in range(n):\n a, b, c = map(int, input().split())\n for aa in range(400, -1, -1):\n for bb in range(400, -1, -1):\n if t[aa][bb] == inf:\n continue\n if t[a + aa][b + bb] > c + t[aa][bb]:\n t[a + aa][b + bb] = c + t[aa][bb]\nresult = inf\nfor a in range(400, 0, -1):\n for b in range(400, 0, -1):\n if a * mb == b * ma and t[a][b] < result:\n result = t[a][b]\nif result == inf:\n print(-1)\nelse:\n print(result)\n", "neg": "import sys\ninf = float('inf')\nn, ma, mb = map(int, input().split())\nt = [[inf] * 401 for _ in range(401)]\nt[0][0] = 0\nfor _ in range(n):\n a, b, c = map(int, input().split())\n for aa in range(400, 0, -1):\n for bb in range(400, 0, -1):\n if t[aa][bb] == inf:\n continue\n if t[a + aa][b + bb] > c + t[aa][bb]:\n t[a + aa][b + bb] = c + t[aa][bb]\nresult = inf\nfor a in range(400, 0, -1):\n for b in range(400, 0, -1):\n if a * mb == b * ma and t[a][b] < result:\n result = t[a][b]\nif result == inf:\n print(-1)\nelse:\n print(result)\n", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [243, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline #\u6587\u5b57\u5217\u5165\u529b\u306e\u3068\u304d\u306f\u6ce8\u610f\n\nn,A,B = [int(i) for i in readline().split()]\nabc = [[int(i) for i in readline().split()] for j in range(n)]\n\nans = 10**9\n\nd = {0:0}\nfor i in range(n):\n nd = {}\n a,b,c = abc[i]\n for amari,yen in d.items():\n if amari in nd:\n nd[amari] = min(nd[amari],yen)\n else:\n nd[amari] = yen\n\n yen += c\n amari += a*B-b*A\n if amari == 0 and yen != 0:\n ans = min(ans,yen)\n elif amari in nd:\n nd[amari] = min(nd[amari],yen)\n else:\n nd[amari] = yen\n d = nd\n# print(d,nd)\n\nif ans == 10**9:\n print(-1)\nelse:\n print(ans)\n\n\n\n", "neg": "# coding: utf-8\n# Your code here!\n\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline #\u6587\u5b57\u5217\u5165\u529b\u306e\u3068\u304d\u306f\u6ce8\u610f\n\nn,A,B = [int(i) for i in readline().split()]\nabc = [[int(i) for i in readline().split()] for j in range(n)]\n\nans = 10**9\n\nd = {0:0}\nfor i in range(n):\n nd = {}\n a,b,c = abc[i]\n for amari,yen in d.items():\n if amari in nd:\n nd[amari] = min(nd[amari],yen)\n else:\n nd[amari] = yen\n\n yen += c\n amari += a*B-b*A\n if amari == 0 and yen != 0:\n ans = min(ans,yen)\n elif amari in nd:\n nd[amari] = min(nd[amari],yen)\n else:\n nd[amari] = yen\n d = nd\n# print(d,nd)\n\nprint(ans)\n\n\n\n", "jacc_sim": 0.9852941176470589, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [330, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u502389123", "n_user": "u502389123", "pos": "N, Ma, Mb = map(int, input().split())\na = [0] * N\nb = [0] * N\nc = [0] * N\nfor i in range(N):\n a[i], b[i], c[i] = map(int, input().split())\n\nINF = 10 ** 5\nnums = 401\n\ndp = [[[INF for _ in range(nums+100)] for _ in range(nums+100)] for _ in range(N+1)]\n\ndp[0][0][0] = 0\n\nfor i in range(N):\n for sum_a in range(nums):\n for sum_b in range(nums):\n #if dp[i][sum_a][sum_b] == INF:\n # continue\n dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])\n dp[i+1][sum_a][sum_b] = min(dp[i+1][sum_a][sum_b], dp[i][sum_a][sum_b])\n #dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])\n #print(i, dp[i][sum_a][sum_b], sum_a, sum_b)\n\n\nres = INF\nfor i in range(1, nums):\n for j in range(1, nums):\n if i * Mb == j * Ma:\n res = min(res, dp[N][i][j])\n\nif res == INF:\n res = -1\n\nprint(res)\n", "neg": "N, Ma, Mb = map(int, input().split())\na = [0] * N\nb = [0] * N\nc = [0] * N\nfor i in range(N):\n a[i], b[i], c[i] = map(int, input().split())\n\nINF = 10 ** 5\nnums = 7\n\ndp = [[[INF for _ in range(nums)] for _ in range(nums)] for _ in range(N+1)]\n\ndp[0][0][0] = 0\n\nfor i in range(N):\n for sum_a in range(nums):\n for sum_b in range(nums):\n if dp[i][sum_a][sum_b] == INF:\n continue\n dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])\n dp[i+1][sum_a][sum_b] = min(dp[i+1][sum_a][sum_b], dp[i][sum_a][sum_b])\n #dp[i+1][sum_a+a[i]][sum_b+b[i]] = min(dp[i+1][sum_a+a[i]][sum_b+b[i]], dp[i][sum_a][sum_b] + c[i])\n #print(i, dp[i][sum_a][sum_b], sum_a, sum_b)\n\n\nres = INF\nfor i in range(1, nums):\n for j in range(1, nums):\n if i * Mb == j * Ma:\n res = min(res, dp[N][i][j])\n\nif res == INF:\n res = -1\n\nprint(res)\n", "jacc_sim": 0.9333333333333333, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [470, 463], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u983918956", "n_user": "u983918956", "pos": "inf = float('inf')\n\nN,Ma,Mb = map(int,input().split())\nabc = [list(map(int,input().split())) for _ in range(N)]\n\n# dp[i][j][k]: i\u756a\u76ee\u307e\u3067\u307f\u3066j(g), k(g)\u3068\u306a\u308b\u3088\u3046\u306a\u6700\u5c0f\u4e88\u7b97\ndp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n a,b,c = abc[i]\n for j in range(401):\n for k in range(401):\n if j - a >= 0 and k - b >= 0:\n dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b] + c)\n else:\n dp[i+1][j][k] = dp[i][j][k]\n\nans = inf\n\nfor j in range(1,401):\n for k in range(1,401):\n if j * Mb == Ma * k:\n ans = min(ans, dp[N][j][k])\n\nif ans == inf:\n ans = -1\nprint(ans)", "neg": "from fractions import gcd\n\ninf = float('inf')\n\nN,Ma,Mb = map(int,input().split())\nabc = [list(map(int,input().split())) for _ in range(N)]\n\n# dp[i][j][k]: i\u756a\u76ee\u307e\u3067\u307f\u3066j(g), k(g)\u3068\u306a\u308b\u3088\u3046\u306a\u6700\u5c0f\u4e88\u7b97\ndp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n a,b,c = abc[i]\n for j in range(401):\n for k in range(401):\n if j - a >= 0 and k - b >= 0:\n dp[i+1][j][k] = min(dp[i][j][k], dp[i][j-a][k-b] + c)\n else:\n dp[i+1][j][k] = dp[i][j][k]\n\nans = inf\n\nfor j in range(1,401):\n for k in range(1,401):\n G = gcd(j,k)\n if (j//G, k//G) == (Ma, Mb):\n ans = min(ans, dp[N][j][k])\n\nif ans == inf:\n ans = -1\nprint(ans)", "jacc_sim": 0.9104477611940298, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [340, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u969190727", "n_user": "u969190727", "pos": "n,ma,mb=map(int,input().split())\ninf=10**4\nA=[]\nappend=A.append\nfor i in range(n):\n a,b,c=map(int,input().split())\n append([a,b,c])\nDP=[[[inf]*(10*n+1) for _ in range(10*n+1)] for _ in range(n+1)]\nDP[0][0][0]=0\nfor i in range(n):\n a,b,c=A[i][0],A[i][1],A[i][2]\n for j in range(10*(i+1)+1):\n for k in range(10*(i+1)+1):\n if j>=a and k>=b:\n DP[i+1][j][k]=min(DP[i][j-a][k-b]+c,DP[i][j][k])\n else:\n DP[i+1][j][k]=DP[i][j][k]\nans=inf\nfor i in range(10*n+1):\n for j in range(10*n+1):\n if i*mb==j*ma and i*j!=0:\n ans=min(ans,DP[n][i][j])\nprint(ans if ans!=inf else -1)", "neg": "n,ma,mb=map(int,input().split())\ninf=10**4\nA=[]\nappend=A.append\nfor i in range(n):\n a,b,c=map(int,input().split())\n append([a,b,c])\nDP=[[[inf]*(10*n+1) for _ in range(10*n+1)] for _ in range(n+1)]\nDP[0][0][0]=0\nfor i in range(n):\n a,b,c=A[i][0],A[i][1],A[i][2]\n for j in range(10*(i+1)+1):\n for k in range(10*(i+1)+1):\n if j>=a and k>=b:\n DP[i+1][j][k]=min(DP[i][j-a][k-b]+c,DP[i][j][k])\n else:\n DP[i+1][j][k]=DP[i][j][k]\nans=inf\nfor i in range(1,10*n+1):\n if i*mb%ma==0:\n j=i*mb//ma\n ans=min(ans,DP[n][i][j])\nprint(ans if ans!=inf else -1)", "jacc_sim": 0.9574468085106383, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [325, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u785989355", "n_user": "u785989355", "pos": "\nN,A,B = list(map(int,input().split()))\n\nitem=[]\nfor i in range(N):\n a,b,c = list(map(int,input().split()))\n item.append([a,b,c])\n\nD = [[[10**27 for i in range(401)] for j in range(401)] for k in range(N+1)]\nD[0][0][0] = 0\nfor i in range(N):\n for j in range(401):\n for k in range(401):\n if D[i][j][k]<10**26:\n D[i+1][j][k]=min(D[i+1][j][k],D[i][j][k])\n D[i+1][j+item[i][0]][k+item[i][1]] = min(D[i+1][j+item[i][0]][k+item[i][1]],D[i][j][k]+item[i][2])\n\ni=1\nmin_cost=10**27\nwhile A*i<=400 and B*i<=400:\n min_cost = min(D[N][A*i][B*i],min_cost)\n i+=1\nif min_cost==10**27:\n\tprint(-1)\nelse:\n\tprint(min_cost)", "neg": "N,A,B = list(map(int,input().split()))\n\nitem=[]\nfor i in range(N):\n a,b,c = list(map(int,input().split()))\n item.append([a,b,c])\n\nD = [[10**27 for i in range(401)] for j in range(401)]\nD[0][0] = 0\nfor i in range(N):\n for j in range(401):\n for k in range(401):\n if D[j][k]<10**27:\n D[j+item[i][0]][k+item[i][1]] = min(D[j+item[i][0]][k+item[i][1]],D[j][k]+item[i][2])\n\ni=1\nmin_cost=10**27\nwhile A*i<=400 and B*i<=400:\n min_cost = min(D[A*i][B*i],min_cost)\n i+=1\nif min_cost==10**27:\n\tprint(-1)\nelse:\n\tprint(min_cost)", "jacc_sim": 0.9787234042553191, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [332, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u572144347", "n_user": "u572144347", "pos": "N, Ma, Mb = map(int, input().split())\nABC = [list(map(int, input().split())) for _ in range(N)]\n\ninf = float(\"inf\")\n\ndp = [ [ [inf] * 401 for _ in range(401)] for _ in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n a,b,c = ABC[i]\n for ma in range(400):\n for mb in range(400):\n dp[i+1][ma][mb] = min(dp[i+1][ma][mb],\n dp[i][ma][mb])\n if ma + a > 400: continue\n if mb + b > 400: continue\n \n dp[i+1][ma+a][mb+b] = \\\n min(dp[i+1][ma+a][mb+b],\n dp[i][ma][mb]+c)\n \nans = inf\nfor i in range(1,40000):\n if Ma*i > 400 or Mb*i > 400: break\n ans = min(ans, dp[N][Ma*i][Mb*i])\n\nif ans == inf:\n print(-1); exit()\nprint(ans)", "neg": "N, Ma, Mb = map(int, input().split())\nABC = [list(map(int, input().split())) for _ in range(N)]\n\ninf = float(\"inf\")\n\ndp = [ [ [inf] * 401 for _ in range(401)] for _ in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n a,b,c = ABC[i]\n for ma in range(400):\n for mb in range(400):\n dp[i+1][ma][mb] = min(dp[i+1][ma][mb],\n dp[i][ma][mb])\n if ma + a > 400: continue\n if mb + b > 400: continue\n \n dp[i+1][ma+a][mb+b] = \\\n min(dp[i+1][ma+a][mb+b],\n dp[i][ma][mb]+c)\n \nans = inf\nfor i in range(1,40000):\n if Ma*i > 400 or Mb*i > 400: break\n ans = min(ans, dp[N][Ma*i][Mb*i])\n\nprint(ans)", "jacc_sim": 0.94, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [305, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u826438738", "n_user": "u826438738", "pos": "N,Ma,Mb=map(int,input().split())\n\ndp = [[10**18 for _ in range(401)] for _ in range(401)]\n\ndp[0][0]=0\nfor i in range(N):\n a,b,c=map(int,input().split())\n for ca in range(i * 10, -1, -1):\n for cb in range(i * 10, -1, -1):\n dp[ca+a][cb+b] = min(dp[ca+a][cb+b],dp[ca][cb]+c)\n\nans = 10**18\nfor ca in range(401):\n for cb in range(401):\n if not ca*Mb == cb*Ma or ca == 0:\n continue\n if ans > dp[ca][cb]:\n ans = dp[ca][cb]\n \nif ans == 10**18:\n print(-1)\nelse:\n print(ans)\n", "neg": "N,Ma,Mb=map(int,input().split())\n\nA,B,C = [],[],[]\nfor i in range(N):\n a,b,c=map(int,input().split())\n A += [a]\n B += [b]\n C += [c]\n\ndp = [[[10**18 for _ in range(401)] for _ in range(401)] for _ in range(N+1)]\n\ndp[0][0][0]=0\nfor i in range(N):\n for ca in range(i * 10):\n for cb in range(i * 10):\n dp[i+1][ca][cb] = min(dp[i+1][ca][cb],dp[i][ca][cb])\n dp[i+1][ca+A[i]][cb+B[i]] = min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])\n\nans = 10**18\nfor ca in range(401):\n for cb in range(401):\n if not ca*Mb == cb*Ma or ca == 0:\n continue\n if ans > dp[N][ca][cb]:\n ans = dp[N][ca][cb]\n \nif ans == 10**18:\n print(-1)\nelse:\n print(ans)\n", "jacc_sim": 0.9347826086956522, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [231, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u001024152", "n_user": "u001024152", "pos": "from math import isinf\n\nN, Ma, Mb = map(int, input().split())\na = [0]*N\nb = [0]*N\nc = [0]*N\nfor i in range(N):\n a[i],b[i],c[i] = map(int, input().split())\n\nW_MAX = 40*10\ndp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]\ndp[0][0] = 0\n\nfor i in range(N):\n for wa in reversed(range(W_MAX+1)):\n for wb in reversed(range(W_MAX+1)):\n if isinf(dp[wa][wb]): continue\n if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:\n dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],\n dp[wa][wb]+c[i])\n\nans = float('inf')\nfor wa in range(1, W_MAX+1):\n for wb in range(1, W_MAX+1):\n if wa*Mb == wb*Ma:\n ans = min(ans, dp[wa][wb])\n\nif isinf(ans): ans = -1\nprint(ans)", "neg": "from math import isinf\n\nN, Ma, Mb = map(int, input().split())\na = [0]*N\nb = [0]*N\nc = [0]*N\nfor i in range(N):\n a[i],b[i],c[i] = map(int, input().split())\n\nW_MAX = 40*10\ndp = [[float('inf')]*(W_MAX+1) for _ in range(W_MAX+1)]\ndp[0][0] = 0\n\nfor i in range(N):\n for wa in range(W_MAX):\n for wb in range(W_MAX):\n if isinf(dp[wa][wb]): continue\n if wa+a[i]<=W_MAX and wb+b[i]<=W_MAX:\n dp[wa+a[i]][wb+b[i]] = min(dp[wa+a[i]][wb+b[i]],\n dp[wa][wb]+c[i])\nans = float('inf')\nfor wa in range(1, W_MAX+1):\n for wb in range(1, W_MAX+1):\n if wa*Mb == wb*Ma:\n ans = min(ans, dp[wa][wb])\nprint(ans)", "jacc_sim": 0.9591836734693877, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [337, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u690536347", "n_user": "u690536347", "pos": "n,Ma,Mb=map(int,input().split())\ninf=float(\"inf\")\ndp=[[[inf]*401 for _ in range(401)] for _ in range(n+1)]\ndp[0][0][0]=0\n\nl=[tuple(map(int,input().split())) for _ in range(n)]\n\nfor i in range(1,n+1):\n for j in range(401):\n for k in range(401):\n a,b,c=l[i-1]\n dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])\n if j-a>=0 and k-b>=0:\n dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a][k-b]+c)\n\nans=inf\nfor i in range(1,401):\n for j in range(1,401):\n if i*Mb==j*Ma:\n ans=min(ans,dp[n][i][j])\n\nprint(ans if ans!=inf else -1)", "neg": "n,Ma,Mb=map(int,input().split())\ninf=float(\"inf\")\ndp=[[[inf]*401 for _ in range(401)] for _ in range(n+1)]\ndp[0][0][0]=0\n\nl=[tuple(map(int,input().split())) for _ in range(n)]\n\nfor i in range(1,n+1):\n for j in range(401):\n for k in range(401):\n a,b,c=l[i-1]\n dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])\n if j-a>=0 and k-b>=0:\n dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a][k-b]+c)\n\nans=inf\nfor i in range(1,1+max(400//Ma,400//Mb)):\n ans=min(ans,dp[n][Ma*i][Mb*i])\n\nprint(ans if ans!=inf else -1)", "jacc_sim": 0.9375, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [278, 273], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u375616706", "n_user": "u375616706", "pos": "N, Ma, Mb = (list)(map(int, input().split()))\nl = []\ninf = 10**6\ndp = [[[inf]*401 for _ in range(401)] for _ in range(41)]\n\n\nfor _ in range(N):\n l.append((list)(map(int, input().split())))\n\ndp[0][0][0] = 0\n\nfor i in range(N):\n for ca in range(401):\n for cb in range(401):\n if dp[i][ca][cb] != inf:\n dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])\n t_a = l[i][0]\n t_b = l[i][1]\n dp[i+1][ca+t_a][cb+t_b] =\\\n min(dp[i+1][ca+t_a][cb+t_b], dp[i][ca][cb]+l[i][2])\n\nans = inf\nfor i in range(1, 401):\n for j in range(1, 401):\n if i*Mb == j*Ma:\n ans = min(ans, dp[N][i][j])\n\nif ans == inf:\n ans = -1\nprint(ans)\n", "neg": "N, Ma, Mb = (list)(map(int, input().split()))\nN_max = 40\nabmax = 10\nl = []\ninf = 10**6\ndp = [[[inf]*401 for _ in range(401)] for _ in range(40)]\n\n\nfor _ in range(N):\n l.append((list)(map(int, input().split())))\n\ndp[0][0][0] = 0\n\nfor i in range(N):\n for ca in range(401):\n for cb in range(401):\n if dp[i][ca][cb] != inf:\n dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])\n t_a = l[i][0]\n t_b = l[i][1]\n dp[i+1][ca+t_a][cb+t_b] =\\\n min(dp[i+1][ca+t_a][cb+t_b], dp[i][ca][cb]+l[i][2])\n\nans = inf\nfor i in range(401):\n for j in range(401):\n if i*Mb == j*Ma:\n ans = min(ans, dp[N][i][j])\n\nif ans == inf:\n ans = -1\nprint(ans)\n", "jacc_sim": 0.9183673469387755, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [321, 328], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u427344224", "n_user": "u427344224", "pos": "N, Ma, Mb = map(int, input().split())\nitems = []\nfor i in range(N):\n a, b, c = map(int, input().split())\n items.append((a, b, c))\n\na_sum = sum([item[0] for item in items])\nb_sum = sum([item[1] for item in items])\ninf = float(\"inf\")\ndp = [[[inf for _ in range(401)] for _ in range(401)] for i in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n for a in range(a_sum + 1):\n for b in range(b_sum + 1):\n dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])\n dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],\n dp[i][a][b] + items[i][2])\nans = inf\nfor a in range(1, a_sum + 1):\n for b in range(1, b_sum + 1):\n if a * Mb == b * Ma:\n ans = min(ans, dp[N][a][b])\nif ans != inf:\n print(ans)\nelse:\n print(-1)", "neg": "N, Ma, Mb = map(int, input().split())\nitems = []\nfor i in range(N):\n a, b, c = map(int, input().split())\n items.append((a, b, c))\n\ninf = float(\"inf\")\ndp = [[[inf for _ in range(401)] for _ in range(401)] for i in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n for a in range(401):\n for b in range(401):\n dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])\n dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],\n dp[i][a][b] + items[i][2])\nans = inf\nfor a in range(1, 401):\n for b in range(1, 401):\n if a * Mb == b * Ma:\n ans = min(ans, dp[N][a][b])\nif ans != inf:\n print(ans)\nelse:\n print(-1)", "jacc_sim": 0.9130434782608695, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [357, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u427344224", "n_user": "u427344224", "pos": "N, Ma, Mb = map(int, input().split())\nitems = []\nfor i in range(N):\n a, b, c = map(int, input().split())\n items.append((a, b, c))\n\na_sum = sum([item[0] for item in items])\nb_sum = sum([item[1] for item in items])\ninf = float(\"inf\")\ndp = [[[inf for _ in range(a_sum + 100)] for _ in range(b_sum + 100)] for i in range(N+1)]\ndp[0][0][0] = 0\n\nfor i in range(N):\n for a in range(a_sum + 1):\n for b in range(b_sum + 1):\n dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b])\n dp[i + 1][a + items[i][0]][b + items[i][1]] = min(dp[i + 1][a + items[i][0]][b + items[i][1]],\n dp[i][a][b] + items[i][2])\nans = inf\nfor a in range(1, a_sum + 1):\n for b in range(1, b_sum + 1):\n if a * Mb == b * Ma:\n ans = min(ans, dp[N][a][b])\nif ans != inf:\n print(ans)\nelse:\n print(-1)", "neg": "N, Ma, Mb = map(int, input().split())\nitems = []\nfor i in range(N):\n a, b, c = map(int, input().split())\n items.append((a, b, c))\n\na_sum = sum([item[0] for item in items])\nb_sum = sum([item[1] for item in items])\ninf = float(\"inf\")\ndp = [[[inf for _ in range(b_sum + 11)] for _ in range(a_sum + 11)] for i in range(N + 1)]\ndp[0][0][0] = 0\nprint(a_sum, b_sum)\nfor i in range(N):\n for a in range(a_sum):\n for b in range(b_sum):\n if dp[i + 1][a][b] > dp[i][a][b]:\n dp[i + 1][a][b] = dp[i][a][b]\n if dp[i + 1][a + items[i][0]][b + items[i][1]] > dp[i][a][b] + items[i][2]:\n dp[i + 1][a + items[i][0]][b + items[i][1]] = dp[i][a][b] + items[i][2]\n\nans = inf\nfor a in range(1, a_sum + 1):\n for b in range(1, b_sum + 1):\n if a * Mb == b * Ma:\n ans = min(ans, dp[N][a][b])\nif ans != inf:\n print(ans)\nelse:\n print(-1)\n", "jacc_sim": 0.9375, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [365, 396], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u658993896", "n_user": "u658993896", "pos": "N,Ma,Mb=list(map(int,input().split()))\n\nmix=set([(0,0)])\nans=10**9\ncost={(0,0):0}\nfor i in range(N):\n a,b,c=list(map(int,input().split()))\n tmp=mix.copy()\n tmp2=cost.copy()\n for x in tmp:\n d=x[0]+a\n e=x[1]+b\n f=min(tmp2.get((d,e),10**9),tmp2[x]+c)\n cost[(d,e)]=f\n mix.add((d, e))\n if d*Mb==e*Ma and f 0:\n if Masum/Mbsum == Ma/Mb:\n if minicost > cost:\n minicost = cost\n if cost < minicost:\n dvector(Masum,Mbsum,cost,vector+[1])\n return 0\n \ndvector(0,0,0,[])\nif minicost == 10000000:\n print(\"-1\")\nelse:\n print(minicost)", "neg": "global N\nglobal Nlist\nglobal Ma\nglobal Mb\nglobal minicost\nminicost = 10000000\nN, Ma, Mb = map(int,input().split()) \nNlist = []\nfor i in range(N):\n a,b,c = map(int,input().split())\n Nlist.append([a,b,c])\ndef dvector(Masum,Mbsum,cost,vector):\n print(vector)\n global Ma\n global Mb\n global Nlist\n global minicost\n if len(vector) == len(Nlist):\n return 0\n dvector(Masum,Mbsum,cost,vector+[0])\n Masum+= Nlist[len(vector)-1][0]\n Mbsum+= Nlist[len(vector)-1][1]\n cost += Nlist[len(vector)-1][2]\n if Mbsum > 0:\n if Masum/Mbsum == Ma/Mb:\n if minicost > cost:\n minicost = cost\n print(vector,cost,minicost)\n if cost < minicost:\n dvector(Masum,Mbsum,cost,vector+[1])\n return 0\n \ndvector(0,0,0,[])\nif minicost == 10000000:\n print(\"-1\")\nelse:\n print(minicost)", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [329, 346], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03806", "p_user": "u425351967", "n_user": "u425351967", "pos": "import copy\n\nN, Ma, Mb = [int(n) for n in input().split()]\npd = {(0,0):0}\nfor i in range(N):\n a, b, c = [int(n) for n in input().split()]\n pdcopy = copy.deepcopy(pd)\n for k, v in pdcopy.items():\n nk = (k[0]+a, k[1]+b)\n if nk in pd:\n if pd[nk] > v + c :\n pd[nk] = v + c\n else:\n pd[nk] = v + c\n\nmp = 1000000\nfor i in range(1,401):\n if (Ma*i, Mb*i) in pd:\n mp = min(pd[(Ma*i, Mb*i)], mp)\n\nif mp == 1000000:\n print(-1)\nelse:\n print(mp)\n", "neg": "import copy\n\nN, Ma, Mb = [int(n) for n in input().split()]\npd = {(0,0):0}\nfor i in range(N):\n a, b, c = [int(n) for n in input().split()]\n pdcopy = copy.deepcopy(pd)\n for k, v in pdcopy.items():\n nk = (k[0]+a, k[1]+b)\n if nk in pd:\n if pd[nk] > c :\n pd[nk] = c\n else:\n pd[nk] = c\n\nmp = 1000000\nfor i in range(1,401):\n if (Ma*i, Mb*i) in pd:\n mp = min(pd[(Ma*i, Mb*i)], mp)\n\nif mp == 1000000:\n print(-1)\nelse:\n print(mp)\n", "jacc_sim": 1.0, "nl": "Dolphin plans to create a chemical substance C by mixing two substances A and B in a specific ratio. He needs to purchase chemicals from a local pharmacy to achieve this. Each chemical package contains a certain amount of A and B and is sold at a specific price. Dolphin must use all the contents of the purchased packages to create C. The task is to find the minimum amount of money required to generate C. If it's not possible to create C with any combination of packages, the output should be -1. The input consists of the number of chemicals available, the desired ratio of A to B, and the details of each chemical package. The output should indicate the minimum amount of money needed or -1 if it's not possible to create C.", "before_after_length": [226, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u026788530", "n_user": "u026788530", "pos": "n = int(input())\n\na = [int(_) for _ in input().split()]\n\n\nif sum(a) % (n*(n+1)//2) != 0:\n print(\"NO\")\n exit()\n\nm = sum(a)//(n*(n+1)//2)\n# print(m)\nd = [a[i]-a[i-1]-m for i in range(n)]\n\n# print(d)\nfor D in d:\n if D % n == 0:\n m += D//n\n if D % n != 0 or D > 0:\n print(\"NO\")\n exit()\nif m == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "n = int(input())\n\na = [int(_) for _ in input().split()]\n\n\nif sum(a) % (n*(n+1)//2) != 0:\n print(\"NO\")\n exit()\n\nm = sum(a)//(n*(n+1)//2)\n# print(m)\nd = [a[i]-a[i-1]-m for i in range(n)]\n\n# print(d)\nfor D in d:\n if D % n == 0:\n m += D//n\n if D % n != 0 or D < 0:\n print(\"NO\")\n exit()\nif m == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 0.9512195121951219, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [177, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u571969099", "n_user": "u571969099", "pos": "n = int(input())\na = [int(i) for i in input().split()]\nif sum(a) % (n * (n + 1) // 2) != 0:\n print(\"NO\")\n exit()\n\nk = sum(a) // (n * (n + 1) // 2)\n\nl = 0\nfor i in range(n):\n j = (i + 1) % n\n m = a[i]-a[j]\n if (m + k) % n != 0 or (m + k) // n < 0:\n print(\"NO\")\n exit()\n l += (m + k) // n\nif k == l:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "n = int(input())\na = [int(i) for i in input().split()]\nif sum(a) % (n * (n + 1) // 2) != 0:\n print(\"NO\")\n exit()\nif n == 1:\n print(\"YES\")\n exit()\n\nk = sum(a) // (n * (n + 1) // 2)\n\nif n == 2:\n if min(a) >= k:\n print(\"YES\")\n else:\n print(\"NO\")\n exit()\n\nl = 0\nfor i in range(n):\n j = (i + 1) % n\n m = a[j]-a[i]\n if (m - k) % n != 0 or (m - k) // n <= 0:\n print(\"NO\")\n exit()\n l -= (m - k) // n\nif k == l:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 0.9512195121951219, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [176, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u476604182", "n_user": "u476604182", "pos": "N, *A = map(int, open(0).read().split())\nM = (N+1)*N//2\nS = sum(A)\nif S%M!=0:\n print('NO')\n exit()\ncnt = S//M\nfor i in range(N):\n df = A[(i+1)%N]-A[i]\n if (cnt-df)%N!=0 or cnt0:\n ans = \"NO\"\n ope = sumA//oneA\n #\u5404A\u306b\u3064\u3044\u3066\u4f55\u56de\u59cb\u70b9\u3068\u3057\u305f\u304b\u4e8c\u5206\u63a2\u7d22\n cur = 0\n for i in range(N):\n now = ope - (A[i]-A[i-1])\n if now%N>0:\n# print(now,i)\n ans = \"NO\"\n break\n cur += now//N\n if cur==ope:\n ans = \"NO\"\n print(ans)\n return\n\nimport sys,copy,bisect,itertools,heapq,math\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nglobal mod,inf\nmod = 10**9 + 7\ninf = 10**18\n\nif __name__ == '__main__':\n examB()\n", "jacc_sim": 0.9591836734693877, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [467, 460], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u039623862", "n_user": "u039623862", "pos": "n = int(input())\na = list(map(int, input().split()))\nif n == 1:\n print('YES')\n exit()\nsuma = sum(a)\nif sum(a) % (n*(n+1)//2) > 0:\n print('NO')\n exit()\nk = 2*suma//(n*(n+1))\ndiffs = [a[i+1] - a[i] - k for i in range(-1, n-1)]\nif all([d<=0 and -d % n == 0 for d in diffs]):\n print('YES')\nelse:\n print('NO')\n", "neg": "n = int(input())\na = list(map, input().split())\nsuma = sum(a)\nif sum(a) % (n*(n+1)//2) > 0:\n print('NO')\n exit()\nk = 2*suma//(n*(n+1))\ndiffs = [a[i+1] - a[i] + k for i in range(n-1)]\nif all([d % n == 0 for d in diffs]):\n print('YES')\nelse:\n print('NO')\n", "jacc_sim": 0.9534883720930233, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [155, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u827202523", "n_user": "u827202523", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n\ndef getN():\n return int(input())\ndef getList():\n return list(map(int, input().split()))\nimport math\n\nn = getN()\nnums = getList()\nif sum(nums) % ((n * (n+1)) // 2) != 0:\n print(\"NO\")\n sys.exit()\nn_operate = sum(nums) // ((n * (n+1)) // 2)\n\nv_valid = n_operate\nv_sign = n\n\nfor i, j in zip(nums, nums[1:] + [nums[0]]):\n diff = j - i\n if diff > v_valid:\n print(\"NO\")\n sys.exit()\n if (v_valid - diff) % v_sign != 0:\n print(\"NO\")\n sys.exit()\n n_operate -= (v_valid - diff) // v_sign\n # print(n_operate)\nif n_operate == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n# print(\"YES\")", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n\ndef getN():\n return int(input())\ndef getList():\n return list(map(int, input().split()))\nimport math\n\nn = getN()\nnums = getList()\nif sum(nums) % ((n * (n+1)) // 2) != 0:\n print(\"NO\")\n sys.exit()\nn_operate = sum(nums) // ((n * (n+1)) // 2)\n\nv_valid = n_operate\nv_sign = n\n\nfor i, j in zip(nums, nums[1:] + [nums[0]]):\n diff = j - i\n if diff > v_valid:\n print(\"NO\")\n sys.exit()\n if (v_valid - diff) % v_sign != 0:\n print(\"NO\")\n sys.exit()\n n_operate -= (v_valid - diff) // v_sign\n print(n_operate)\nif n_operate == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n# print(\"YES\")", "jacc_sim": 1.0, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [273, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u163320134", "n_user": "u163320134", "pos": "n=int(input())\narr=list(map(int,input().split()))\nif n==1:\n print('YES')\nelse:\n sum1=sum(arr)\n sum2=(n*(n+1))//2\n moves=sum1//sum2\n cnt=0\n if sum1%sum2!=0:\n print('NO')\n else:\n flag=True\n arr2=[]\n for i in range(n-1):\n tmp=arr[i]+moves\n if arr[i+1]==tmp:\n continue\n else:\n diff=tmp-arr[i+1]\n if diff%n!=0:\n flag=False\n else:\n arr2.append(n-i)\n cnt+=diff//n\n tmp=arr[i+1]-diff//n\n if tmp>n*(moves-diff//n):\n flag=False\n if flag==False:\n print('NO')\n else:\n if len(arr2)==moves:\n if arr[0]==sum(arr2):\n print('YES')\n else:\n print('NO')\n elif len(arr2)>moves:\n print('NO')\n else:\n if 1*(moves-len(arr2))<=arr[0]-sum(arr2)<=n*(moves-len(arr2)):\n print('YES')\n else:\n print('NO')", "neg": "n=int(input())\narr=list(map(int,input().split()))\nif n==1:\n print('YES')\nelse:\n sum1=sum(arr)\n sum2=(n*(n+1))//2\n moves=sum1//sum2\n cnt=0\n if sum1%sum2!=0:\n print('NO')\n else:\n flag=True\n for i in range(n-1):\n tmp=arr[i]+moves\n if arr[i+1]==moves:\n continue\n else:\n diff=tmp-arr[i+1]\n if diff%moves!=0:\n flag=False\n else:\n cnt+=diff//moves\n if flag==False:\n print('NO')\n else:\n if cnt<=moves:\n print('YES')\n else:\n print('NO')", "jacc_sim": 0.9019607843137255, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [361, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u623819879", "n_user": "u623819879", "pos": "#n,a,b,c,d=map(int,input().split())\nn=int(input())\na=[int(i) for i in input().split()]\nans=True\nc=[]\n\nt=sum(a)//((n*(n+1))//2)\n\nif sum(a)%((n*(n+1))//2)!=0:\n ans=False\nelse:\n for i in range(n):\n if i==0:\n d=a[0]-a[-1]\n else:\n d=a[i]-a[i-1]\n if (t-d)%n!=0 or d-t>0:\n ans=False\n break\n s=(t-d)//n\n c.append(s)\n #if sum(c)==t:\n #ans=True\nif n==1:\n ans=True\nprint('YES' if ans else 'NO')", "neg": "#n,a,b,c,d=map(int,input().split())\nn=int(input())\na=[int(i) for i in input().split()]\nans=False\nc=[]\n\nt=sum(a)//((n*(n+1))//2)\n\nif sum(a)%((n*(n+1))//2)!=0:\n ans=False\nelse:\n if n==1:\n ans=True\n break\n for i in range(n):\n if i==0:\n d=a[0]-a[-1]\n else:\n d=a[i]-a[i-1]\n if (t-d)%n!=0:\n ans=False\n break\n s=(t-d)//n\n c.append(s)\n if sum(c)==t:\n ans=True\nprint('YES' if ans else 'NO')", "jacc_sim": 0.9574468085106383, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [231, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u620480037", "n_user": "u620480037", "pos": "n=int(input())\nA=list(map(int,input().split()))\nN=((n)*(n+1))//2\n\nif sum(A)%N!=0:\n print(\"NO\")\n exit()\nelif n==1:\n print(\"YES\")\nelif n==2:\n if sum(A)%3==0 and max(A)<=2*min(A):\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n T=(sum(A)//N)\n A+=[A[0]]\n cnt=0\n for i in range(1,len(A)):\n if (A[i]-A[i-1])==T:\n #print(A[i],A[i-1])\n continue\n else:\n if A[i-1]>A[i]-T:\n B=((A[i-1]-A[i])//n)+1\n cnt+=B\n #print(A[i],A[i-1],n*B)\n if (A[i]-A[i-1]+n*B)==T:\n continue\n else:\n print(\"NO\")\n exit()\n else:\n print(\"NO\")\n exit()\n if T==cnt:\n print(\"YES\")\n else:\n print(\"NO\")\n \n", "neg": "n=int(input())\nA=list(map(int,input().split()))\nN=((n)*(n+1))//2\n\nif sum(A)%N!=0:\n print(\"NO\")\n exit()\nelif n==1:\n print(\"YES\")\nelif n==2:\n if (A[1]+A[0])%3==0:\n print(\"YES\")\n exit()\n else:\n print(\"NO\")\n exit()\nelse:\n T=(sum(A)//N)\n A+=[A[0]]\n cnt=0\n for i in range(1,len(A)):\n if (A[i]-A[i-1])==T:\n #print(A[i],A[i-1])\n continue\n else:\n if A[i-1]>A[i]-T:\n B=((A[i-1]-A[i])//n)+1\n cnt+=B\n print(A[i],A[i-1],n*B)\n if (A[i]-A[i-1]+n*B)==T:\n continue\n else:\n print(\"NO\")\n exit()\n else:\n print(\"NO\")\n exit()\n if T==cnt:\n print(\"YES\")\n else:\n print(\"NO\")\n ", "jacc_sim": 0.92, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [339, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u062147869", "n_user": "u062147869", "pos": "import sys\nN=int(input())\nA=[int(i) for i in input().split()]\nif sum(A)%((N*(N+1))//2)!=0:\n print('NO')\n sys.exit()\nk=sum(A)//((N*(N+1))//2)\nB=[0]*N\nfor i in range(N):\n B[i]=A[i]-A[i-1]\nfor a in B:\n if a-k<=0 and (k-a)%N==0:\n continue\n print('NO')\n sys.exit()\nprint('YES')", "neg": "import sys\nN=int(input())\nA=[int(i) for i in input().split()]\nif sum(A)%((N*(N+1))//2)!=0:\n print('NO')\n sys.exit()\nk=sum(A)//((N*(N+1))//2)\nfor a in A:\n if a-k<0 and (k-a)%N==0:\n continue\n print('NO')\n sys.exit()\nprint('YES')", "jacc_sim": 0.95, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [153, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u190405389", "n_user": "u190405389", "pos": "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\n\nif s%(n*(n+1)//2)!=0:\n print('NO')\n exit()\n\nss = s//(n*(n+1)//2)\n\nb = [0 for i in range(n)]\n\n# a[i]-a[i-1] = ss-b[i-1]*n\nfor i in range(n):\n b[i-1] = (ss-a[i]+a[i-1])//n\n if b[i-1]<0:\n print('NO')\n exit()\n\nc = [0 for i in range(n)]\nfor i in range(n):\n c[0]+=b[i]*(n-i)\n\nfor i in range(1,n):\n c[i] = c[i-1] + ss - b[i-1]*n\n\nif a==c:\n print('YES')\nelse:\n print('NO')\n\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\n\nif s%(n*(n+1)//2)!=0:\n print('NO')\n exit()\n\nss = s//(n*(n+1)//2)\n\nb = [0 for i in range(n)]\n\n# a[i]-a[i-1] = ss-b[i-1]*n\nfor i in range(n):\n b[i-1] = (ss-a[i]+a[i-1])//n\n if b[i-1]<0:\n print('NO')\n exit()\n\nc = [0 for i in range(n)]\nfor i in range(n):\n c[0]+=b[i]*(n-i)\n\nfor i in range(1,n):\n c[i] = c[i-1] + ss - b[i-1]*n\n\nif a==c:\n print('YES')\nelse:\n print('NO')\n\nprint(b)\n", "jacc_sim": 1.0, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [258, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u375616706", "n_user": "u375616706", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n N = int(input())\n A = list(map(int, input().split()))\n\n k = sum(A)//(N*(N+1)//2)\n if sum(A) % (N*(N+1)//2) != 0:\n return \"NO\"\n\n D = [0]*N\n for i in range(N-1):\n D[i] = A[i+1]-A[i]-k\n D[-1] = A[0]-A[-1]-k\n\n cnt = sum([v//N for v in D])\n if all(x <= 0 and -x % N == 0 for x in D)and -cnt == k:\n return \"YES\"\n else:\n return \"NO\"\n\n\nprint(solve())\n", "neg": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n N = int(input())\n A = list(map(int, input().split()))\n\n k = sum(A)//(N*(N+1)//2)\n if sum(A) % (N*(N+1)//2) != 0 or True:\n return \"NO\"\n\n D = [0]*N\n for i in range(N-1):\n D[i] = A[i+1]-A[i]-k\n D[-1] = A[0]-A[-1]-k\n\n cnt = sum([v//N for v in D])\n if all(x <= 0 and -x % N == 0 for x in D)and -cnt == k:\n return \"YES\"\n else:\n return \"NO\"\n\n\nprint(solve())\n", "jacc_sim": 0.9661016949152542, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [229, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u505830998", "n_user": "u505830998", "pos": "# -*- coding: utf-8 -*-\n\ndef io_generator():\n\treturn input()\n\n#+++++++++++++++++++\n\ndef main(io):\n\tret_ng='NO'\n\tret_ok='YES'\n\t\n\tn=int(io())\n\tl= list(map(int, io().split()))\n\t\n\tv_one_act =n*(n+1)/2\n\t\n\tif sum(l)%v_one_act != 0:\n\t\treturn ret_ng\n\t\t\n\tact_num=sum(l)//v_one_act\t\n\tst_num=0\n\t\n\tfor a,b in zip(l, l[1:]+l):\n\t\tdiff = b - a\n\t\tif (act_num-diff)%(n)!=0:\n\t\t\treturn ret_ng\n\t\tif (act_num-diff)<0:\n\t\t\treturn ret_ng\n\t\tst= (act_num-diff)//(n)\n\t\tst_num+=st\n\t\n\tif act_num!=st_num:\n\t\treturn ret_ng\n\t\t\n\t\n\t\t\n\treturn ret_ok\n\n#++++++++++++++++++++\n\nif __name__ == \"__main__\":\n\tio= lambda : io_generator()\n\tprint (main(io))\n", "neg": "# -*- coding: utf-8 -*-\n\ndef io_generator():\n\treturn input()\n\n#+++++++++++++++++++\n\ndef main(io):\n\tret_ng='NO'\n\tret_ok='YES'\n\treturn ret_ng\n\t\n\tn=int(io())\n\tl= list(map(int, io().split()))\n\t\n\tv_one_act =n*(n+1)/2\n\t\n\tif sum(l)%v_one_act != 0:\n\t\treturn ret_ng\n\t\t\n\tact_num=sum(l)//v_one_act\t\n\tst_num=0\n\tfor a,b in zip(l, l[1:]+l):\n\t\tdiff = b - a\n\t\tif (diff - act_num)%(n)!=0:\n\t\t\treturn ret_ng\n\t\tst=-1*(diff-act_num)//(n)\n\t\tst_num+=st\n\t\n\t#if act_num!=st_num:\n\t#\treturn ret_ng\n\t\t\n\treturn ret_ok\n\n#++++++++++++++++++++\n\nif __name__ == \"__main__\":\n\tio= lambda : io_generator()\n\tprint (main(io))\n", "jacc_sim": 0.9818181818181818, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [319, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u284854859", "n_user": "u284854859", "pos": "n = int(input())\na = list(map(int,input().split()))\n\nb = [] #\u5dee\nfor i in range(1,n):\n b.append(a[i]-a[i-1])\nb.append(a[0]-a[n-1])\n\nw = n*(n+1)//2 #\u4e00\u56de\u306e\u64cd\u4f5c\u3067\u53d6\u308a\u9664\u304f\u77f3\u306e\u6570\n\n\nif sum(a)%w != 0:\n print('NO')\nelse:\n res = 0\n c = sum(a)//w #\u64cd\u4f5c\u56de\u6570\n for i in range(n):\n b[i]-=c\n \n for i in range(n):\n if (-b[i]) % n == 0 and b[i] <= 0:\n res += (-b[i])//n\n else:\n res = c+1\n break\n \n if res == c:\n print('YES')\n else:\n\n print('NO')", "neg": "n = int(input())\na = list(map(int,input().split()))\n\nb = [] #\u5dee\nfor i in range(1,n):\n b.append(a[i]-a[i-1])\nb.append(a[0]-a[n-1])\n\nw = n*(n+1)//2 #\u4e00\u56de\u306e\u64cd\u4f5c\u3067\u53d6\u308a\u9664\u304f\u77f3\u306e\u6570\n\nif sum(a)%w != 0:\n print('NO')\nelse:\n res = 0\n c = sum(a)//w #\u64cd\u4f5c\u56de\u6570\n for i in range(n):\n b[i]-=c\n \n for i in range(1,n):\n if (-b[i]) % 5 == 0 and b[i] <= 0:\n res += (-b[i])//5\n else:\n print('NO')\n break\n \n if res == c:\n print('Yes')\n else:\n\n print('NO')", "jacc_sim": 0.9491525423728814, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [274, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u667024514", "n_user": "u667024514", "pos": "n=int(input())\nlis=list(map(int,input().split()))\nnum=(n*(n+1))//2\nll=sum(lis)\nif ll%num!=0:\n print(\"NO\")\n exit()\nans=0\nfor i in range(n):\n if abs(lis[i]-lis[i-1]-ll//num)%n!=0:\n print(\"NO\")\n exit()\n ans+=abs(lis[i]-lis[i-1]-ll//num)//n\nif ans == ll//num:print(\"YES\")\nelse:print(\"NO\")\n", "neg": "n=int(input())\nlis=list(map(int,input().split()))\nnum=(n*(n+1))//2\nif sum(lis)%num!=0:\n print(\"NO\")\n exit()\nans=0\nfor k in range(n):\n if -(lis[i]-lis[i-1]-sum(lis)//num)%n!=0:\n print(\"NO\")\n exit()\n ans+=-(lis[i]-lis[i-1]-sum(lis)//num)//n\nif ans == sum(lis)//num:print(\"YES\")\nelse:print(\"NO\")\n", "jacc_sim": 0.926829268292683, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [157, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u075012704", "n_user": "u075012704", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\nK = sum(A) / sum(range(1, N+1))\nD = [A[i+1] - A[i] - K for i in range(-1, N-1)]\nfor d in D:\n if not (d <= 0 and d % N == 0):\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\nK = sum(A) // sum(range(1, N+1))\nD = [A[i+1] - A[i] - K for i in range(-1, N-1)]\n\nfor d in D:\n if not (d <= 0 and d % N == 0):\n print(d)\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "jacc_sim": 1.0, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [106, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u667084803", "n_user": "u667084803", "pos": "import sys\nN=int(input())\nA=list(map(int,input().split()))\ntotal=0\nfor i in range(N):\n total+=A[i]\nif total*2/((N+1)*N)%1!=0:\n print(\"NO\")\n sys.exit()\ntimes=int(total*2/((N+1)*N))\nif (times-A[0]+A[N-1])/N%1!=0 or times-A[0]+A[N-1]<0:\n print(\"NO\")\n sys.exit()\nB=(times-A[0]+A[N-1])/N\nfor i in range(N-1):\n B+=(times-A[i+1]+A[i])/N\n if (times-A[i+1]+A[i])/N%1!=0 or times-A[i+1]+A[i]<0:\n print(\"NO\")\n sys.exit()\nif B==times:\n print(\"YES\")\nelse:\n print(\"NO\")", "neg": "import sys\nN=int(input())\nA=list(map(int,input().split()))\ntotal=0\nfor i in range(N):\n total+=A[i]\nif total*2/((N+1)*N)%1!=0:\n print(\"NO\")\n sys.exit()\ntimes=int(total*2/((N+1)*N))\nif (times-A[0]+A[N-1])/N%1! or times-A[0]+A[N-1]<0=0:\n print(\"NO\")\n sys.exit()\nB=(times-A[0]+A[N-1])/N\nfor i in range(N-1):\n B+=(times-A[i+1]+A[i])/N\n if (times-A[i+1]+A[i])/N%1!=0 or times-A[i+1]+A[i]<0:\n print(\"NO\")\n sys.exit()\nif B==times:\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [259, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u663710122", "n_user": "u663710122", "pos": "N = int(input())\nA = list(map(int, input().split()))\nD = [A[i + 1] - A[i] for i in range(N - 1)] + [A[0] - A[N - 1]]\nk = int(sum(A) / (N * (N + 1) / 2))\nif sum(A) % (N * (N + 1) / 2) != 0:\n print(\"NO\")\n exit()\n\nfor d in D:\n if d - k > 0 or (d - k) % N != 0:\n print(\"NO\")\n exit()\n\nprint(\"YES\")\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\nD = [A[i + 1] - A[i] for i in range(N - 1)] + [A[0] - A[N - 1]]\nk = int(sum(A) * 2 / N / (N + 1))\nfor d in D:\n if d - k > 0 or (d - k) % N != 0:\n print(d - k)\n print(\"NO\")\n exit()\n\nprint(\"YES\")\n", "jacc_sim": 1.0, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [152, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03808", "p_user": "u583826716", "n_user": "u583826716", "pos": "def main():\n N = int(input())\n A = [int(a) for a in input().rstrip().split()]\n sum_A = sum(A)\n sum_N = (N + 1) * N // 2\n if sum_A % sum_N:\n print('NO')\n return\n\n ope_num = sum_A // sum_N\n diffs = [r - l - ope_num for l, r in zip(A[:-1], A[1:])] + [A[0] - A[-1] - ope_num]\n if all([d % N == 0 and d <= 0 for d in diffs]):\n print('YES')\n else:\n print('NO')\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n N = int(input())\n A = [int(a) for a in input().rstrip().split()]\n sum_A = sum(A)\n sum_N = (N + 1) * N // 2\n if sum_A % sum_N:\n print('NO')\n\n ope_num = sum_A // sum_N\n diffs = [0] * N\n diffs = [r - l for l, r in zip(A[:-1], A[1:])] + [A[0] - A[-1]]\n if all([d % N and d < 0 for d in diffs]):\n print('YES')\n else:\n print('NO')\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9791666666666666, "nl": "You are given N boxes arranged in a circle, each containing a certain number of stones. You need to determine if it's possible to remove all the stones by repeatedly performing an operation: select a box, then for each subsequent box, remove an increasing number of stones. If it's not possible to perform the operation due to insufficient stones in a box, print \"NO\"; otherwise, print \"YES\".", "before_after_length": [192, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03809", "p_user": "u467736898", "n_user": "u467736898", "pos": "import sys\nsys.setrecursionlimit(500000)\nN = int(input())\nA = [0] + list(map(int, input().split()))\nE = [[] for _ in range(N+1)]\nfor _ in range(N-1):\n a, b = map(int, input().split())\n E[a].append(b)\n E[b].append(a)\n\ndef dfs(v, p=0):\n a = A[v]\n b = []\n for u in E[v]:\n if u!=p:\n b.append(dfs(u, v))\n if len(b)==0:\n return a\n sum_b, max_b = sum(b), max(b)\n if a < max_b or 2 * a < sum_b or a > sum_b:\n print(\"NO\")\n exit()\n return 2 * a - sum_b\n\nv = 1\nans = dfs(v)\nif (ans==0 and len(E[v])>1) or (ans==A[v] and len(E[v])==1):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "import sys\nsys.setrecursionlimit(500000)\nN = int(input())\nA = [0] + list(map(int, input().split()))\nE = [[] for _ in range(N+1)]\nfor _ in range(N-1):\n a, b = map(int, input().split())\n E[a].append(b)\n E[b].append(a)\n\ndef dfs(v, p=0):\n a = A[v]\n b = []\n for u in E[v]:\n if u!=p:\n b.append(dfs(u, v))\n if len(b)==0:\n return a\n sum_b, max_b = sum(b), max(b)\n if a < 2*max_b-sum_b or a < 2*sum_b or a > sum_b:\n print(\"NO\")\n exit()\n return 2 * a - sum_b\n\nans = dfs(1)\nif (ans==0 and len(E[1])>1) or (ans==A[1] and len(E[1])==1):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 through N. Each of the N-1 edges connects vertices a_i and b_i. There are A_i stones placed on vertex i. Determine if it's possible to remove all stones by repeatedly selecting a pair of different leaves and removing one stone from every vertex on the path between those two vertices. The operation cannot be performed if there is a vertex with no stone on the path. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N, 0 \u2264 A_i \u2264 10^9, and the given graph is a tree. Input is given in the format: N, A_1, A_2, ..., A_N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"YES\" if it's possible to remove all stones, otherwise output \"NO\".", "before_after_length": [285, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03809", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\ndef main():\n n = I()\n a = LI()\n e = collections.defaultdict(list)\n for _ in range(n-1):\n b,c = LI_()\n e[b].append(c)\n e[c].append(b)\n\n if n == 2:\n if a[0] == a[1]:\n return 'YES'\n return 'NO'\n\n def f(c, p):\n t = []\n ac = a[c]\n for d in e[c]:\n if d == p:\n continue\n r = f(d, c)\n if not r and r != 0:\n return\n t.append(r)\n\n if not t:\n return ac\n\n ts = sum(t)\n ma = min(ts//2, ts-max(t))\n at = ts - ac\n if at > ma or at < 0 or at > ac:\n return\n return ac - at\n\n for i in range(n):\n if len(e[i]) == 1:\n continue\n r = f(i,-1)\n if r == 0:\n return 'YES'\n return 'NO'\n\n return 'NO'\n\n\n\n\nprint(main())\n\n\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\ndef main():\n n = I()\n a = LI()\n e = collections.defaultdict(list)\n for _ in range(n-1):\n b,c = LI_()\n e[b].append(c)\n e[c].append(b)\n\n if n == 2:\n if a[0] == a[1]:\n return 'YES'\n return 'NO'\n\n def f(c, p):\n t = []\n ac = a[c]\n for d in e[c]:\n if d == p:\n continue\n r = f(d, c)\n if not r:\n return\n t.append(r)\n\n if not t:\n return ac\n\n ts = sum(t)\n ma = min(ts//2, max(t))\n at = ts - ac\n if at > ma or at < 0:\n return\n return ac - at\n\n for i in range(n):\n if len(e[i]) == 1:\n continue\n r = f(i,-1)\n if r == 0:\n return 'YES'\n return 'NO'\n\n return 'NO'\n\n\n\n\nprint(main())\n\n\n\n\n", "jacc_sim": 0.978494623655914, "nl": "You are given a tree with N vertices, numbered 1 through N. Each of the N-1 edges connects vertices a_i and b_i. There are A_i stones placed on vertex i. Determine if it's possible to remove all stones by repeatedly selecting a pair of different leaves and removing one stone from every vertex on the path between those two vertices. The operation cannot be performed if there is a vertex with no stone on the path. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N, 0 \u2264 A_i \u2264 10^9, and the given graph is a tree. Input is given in the format: N, A_1, A_2, ..., A_N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"YES\" if it's possible to remove all stones, otherwise output \"NO\".", "before_after_length": [509, 499], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03811", "p_user": "u156163787", "n_user": "u156163787", "pos": "import sys\nsys.setrecursionlimit(1000000000)\n\ndef gcd(a: int, b:int):\n while b:\n a,b=b,a%b\n return a\n\ndef merge(a,us,vs):\n i,j,res=0,0,[]\n while i=a[vs[j]]:\n res.append(us[i])\n i+=1\n else:\n res.append(vs[j])\n j+=1\n return res+us[i:]+vs[j:]\n\ndef dfs(g,a,u,vis):\n vis[u]=True\n res=[]\n for v in g[u]:\n if not vis[v]:\n res=merge(a,res,dfs(g,a,v,vis))\n return [u]+res\n\nwhile 1:\n try:\n n=int(input())\n a=sorted(map(int,input().split()))\n except: break\n\n g=[[] for _ in range(n)]\n for i in range(n):\n for j in range(i+1,n):\n if gcd(a[i],a[j])!=1:\n g[i].append(j)\n g[j].append(i)\n\n vis=[False]*n\n res=[]\n for u in range(n):\n if not vis[u]:\n res=merge(a,res,dfs(g,a,u,vis))\n print(' '.join(str(a[u]) for u in res))\n", "neg": "def gcd(a,b):\n return gcd(b,a%b) if b else a\n\ndef merge(a,us,vs):\n i,j,res=0,0,[]\n while i=a[vs[j]]:\n res.append(us[i])\n i+=1\n else:\n res.append(vs[j])\n j+=1\n return res+us[i:]+vs[j:]\n\ndef dfs(g,a,u,vis):\n vis[u]=True\n res=[]\n for v in g[u]:\n if not vis[v]:\n res=merge(a,res,dfs(g,a,v,vis))\n return [u]+res\n\nwhile 1:\n try:\n n=int(input())\n a=sorted(map(int,input().split()))\n except: break\n\n g=[[j for j in range(n) if i!=j and gcd(a[i],a[j])!=1] for i in range(n)]\n #vis=[False]*n\n #res=[]\n #for u in range(n):\n # if not vis[u]:\n # res=merge(a,res,dfs(g,a,u,vis))\n #print(' '.join(str(a[u]) for u in res))\n", "jacc_sim": 0.9047619047619048, "nl": "Score: 1600 points\nProblem Statement:\nThere are N integers written on a blackboard. The i-th integer is A_i. Takahashi and Aoki will arrange these integers in a row. First, Takahashi will arrange the integers as he wishes. Then, Aoki will repeatedly swap two adjacent integers that are coprime, as many times as he wishes. Find the eventual sequence that will be produced.\n\nConstraints:\n1 \u2264 N \u2264 2000\n1 \u2264 A_i \u2264 10^8\n\nInput:\nThe input is given from Standard Input in the following format:\nN\nA_1 A_2 \u2026 A_N\n\nOutput:\nPrint the eventual sequence that will be produced, in a line.\n\nSample Input 1:\n5\n1 2 3 4 5\n\nSample Output 1:\n5 3 2 4 1\nIf Takahashi arranges the given integers in the order (1,2,3,4,5), they will become (5,3,2,4,1) after Aoki optimally manipulates them.\n\nSample Input 2:\n4\n2 3 4 6\n\nSample Output 2:\n2 4 6 3", "before_after_length": [401, 354], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u190875453", "n_user": "u475179653", "pos": "x = int(input());\n\nif(x >= 1200):\n print(\"ARC\")\nelse:\n print(\"ABC\")", "neg": "x=int(input())\nif(x>1200):\n print('ABC')\nelse:\n print('ARC')", "jacc_sim": 0.9375, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [30, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u891516200", "n_user": "u716314620", "pos": "if 1200 > int(input()):\n print('ABC')\nelse:\n print('ARC')\n", "neg": "if input() > 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "jacc_sim": 0.9230769230769231, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [25, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u623819879", "n_user": "u367130284", "pos": "print('A'+'RB'[int(input())<1200]+'C')", "neg": "print(\"A\"+\"RB\"[input()<1200]+\"C\")", "jacc_sim": 0.9285714285714286, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [18, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u697696097", "n_user": "u697696097", "pos": "import sys\n\ndef yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return\n\ndef resolve():\n readline=sys.stdin.readline\n x=int(readline().strip())\n if x<1200:\n print(\"ABC\")\n else:\n print(\"ARC\")\n #n,m,k=list(map(int, readline().strip().split()))\n #arr=list(map(int, readline().strip().split()))\n #n=int(readline().strip())\n #yn(1)\n\n return\n\n\nresolve()\n", "neg": "import sys\n\ndef yn(b):\n print(\"Yes\" if b==1 else \"No\")\n return\n\ndef resolve():\n readline=sys.stdin.readline\n x=int(readline().strip())\n if x>1200:\n print(\"ABC\")\n else:\n print(\"ARC\")\n #n,m,k=list(map(int, readline().strip().split()))\n #arr=list(map(int, readline().strip().split()))\n #n=int(readline().strip())\n #yn(1)\n\n return\n\n\nresolve()", "jacc_sim": 0.9473684210526315, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [146, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u161693347", "n_user": "u161693347", "pos": "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\n# from fractions import gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n N = INT()\n print(\"ABC\" if N < 1200 else \"ARC\")\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\n# from fractions import gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: map(int, INPUT().split())\nS_MAP = lambda: map(str, INPUT().split())\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n N = INT()\n print(\"ARC\" if N < 1200 else \"ARC\")\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9886363636363636, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [271, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u780206746", "n_user": "u153419200", "pos": "a = int(input(), 10)\nif a < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "neg": "a=int,input()\nif a<1200:\n print('ABC')\nelse:\n print('ARC')", "jacc_sim": 0.9411764705882353, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [31, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u696444274", "n_user": "u696444274", "pos": "#x,t=list(map(int,input().split()))\nx = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n \n", "neg": "#x,t=list(map(int,input().split()))\nx = int(input())\nif x <= 1200:\n print(\"ABC\")\nelse:\n prit(\"ARC\")\n \n", "jacc_sim": 0.9565217391304348, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [48, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u236193715", "n_user": "u405256066", "pos": "X=int(input())\nif(X<1200):\n print(\"ABC\")\nelse:\n print(\"ARC\")", "neg": "x = int(input())\nif X < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "jacc_sim": 0.9375, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [29, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u699780320", "n_user": "u287431190", "pos": "x, = map(int , input().split())\nif( x < 1200 ):\n print('ABC')\nelse:\n print('ARC')", "neg": "x = map(int, input().split())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [35, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u167908302", "n_user": "u167908302", "pos": "#coding:utf-8\n\nx = int(input())\n\nif x >= 1200:\n print('ARC')\nelse:\n print('ABC')\n", "neg": "#coding:utf-8\n\nx = int(input())\n\nif x >= 120:\n print('ARC')\nelse:\n print('ABC')", "jacc_sim": 0.9047619047619048, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [38, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u075367840", "n_user": "u835575472", "pos": "rate = int(input())\n\nprint(\"ABC\") if rate < 1200 else print(\"ARC\")", "neg": "rate = int(input())\nif rate < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC)", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [22, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u374974389", "n_user": "u374974389", "pos": "s = int(input())\nif s < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "neg": "z = int(input())\nif s < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "jacc_sim": 0.9375, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [29, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u644778646", "n_user": "u559651225", "pos": "n = int(input())\nif n >= 1200:\n print(\"ARC\")\nelse:\n print(\"ABC\")", "neg": "n = input()\nif n > = 1200:\n print \"ARC\"\nelse:\n print \"ABC\"", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [28, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u041075929", "n_user": "u041075929", "pos": "import sys, os\n\nf = lambda:list(map(int,input().split()))\nif 'local' in os.environ :\n sys.stdin = open('./input.txt', 'r')\n\ndef solve():\n x = f()[0]\n if x >= 1200:\n print(\"ARC\")\n else:\n print(\"ABC\")\n\nsolve()\n", "neg": "import sys, os\n\nf = lambda:list(map(int,input().split()))\nif 'local' in os.environ :\n sys.stdin = open('./input.txt', 'r')\n\ndef solve():\n x = f()[0]\n if x >= 1200:\n print(\"ARC\")\n else print(\"ABC\")\n\nsolve()\n", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [91, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u294376483", "n_user": "u607920888", "pos": "sumeke = int(input())\n\nif sumeke < 1200 :\n print(\"ABC\")\nelse :\n print(\"ARC\")", "neg": "sumeke=input()\nsumeke=int(sumeke)\nsumeke=1200\nif sumeke < 1200:\n\tprint(\"ABC\")\nelse:\n\tprint(\"ARC\")", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [33, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u794173881", "n_user": "u794173881", "pos": "x = int(input())\nprint(\"ABC\" if x<=1199 else \"ARC\")", "neg": "x = int(input())\nprint(\"ABC\" if x<=1199 else \"ARC )", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [21, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u933214067", "n_user": "u933214067", "pos": "from statistics import mean, median,variance,stdev\nimport sys\nimport math\n\nx = input().split()\n#y = input().split()\na = []\nfor i in range(len(x)):\n a.append(int(x[i]))\nif a[0] <1200:print(\"ABC\")\nelse:print(\"ARC\")", "neg": "from statistics import mean, median,variance,stdev\nimport sys\nimport math\n\nx = input().split()\n#y = input().split()\na = []\n#for i in range(len(x)):\n # a.append(int(x[i]))\nif a[0] <1200:print(\"ABC\")\nelse:print(\"ARC\")", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [81, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u548624367", "n_user": "u716314620", "pos": "print(\"ABC\" if 1200>int(input()) else \"ARC\")", "neg": "if int(input()) > 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "jacc_sim": 0.9230769230769231, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [16, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u111365959", "n_user": "u111365959", "pos": "a = int(input())\nprint('ARC') if a>=1200 else print('ABC')\n", "neg": "a = int(input())\nprint('ABC') if a>=1200 else print('ARC')\n", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [23, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u320325426", "n_user": "u612721349", "pos": "print([\"ARC\", \"ABC\"][int(input()) < 1200])", "neg": "print((\"ABC\",\"ARC\")[int(input())<1200])", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [17, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u729133443", "n_user": "u729133443", "pos": "print('ABC'*(int(input())<1200)or'ARC')", "neg": "print('ABC'(int(input())<1200)or'ARC')", "jacc_sim": 0.9166666666666666, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [17, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u562016607", "n_user": "u371763408", "pos": "if int(input())<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "neg": "print('ABC' if int(input() < 1200 else 'ARC'))", "jacc_sim": 0.9230769230769231, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [25, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u451017206", "n_user": "u039623862", "pos": "print('ARC') if int(input()) >= 1200 else print('ABC')", "neg": "x = int(input()\nprint('ARC' if x >= 1200 else 'ABC')\n", "jacc_sim": 0.9285714285714286, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [17, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u190405389", "n_user": "u886907961", "pos": "n = int(input())\nprint('ABC' if n <1200 else 'ARC')", "neg": "n = int(input)\nif n<1200:\n print(\"ABC\")\n else:\n print(\"ARC\")", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [20, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u778700306", "n_user": "u367393577", "pos": "\na = int(input())\n\nif a >= 1200:\n print(\"ARC\");\nelse:\n print(\"ABC\");", "neg": "a = int(input())\n if a >= 1200:\n print(\"ARC\");\nelse:\n print(\"ABC\");", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u526532903", "n_user": "u869728296", "pos": "a = int(input())\n\nif a < 1200 : print (\"ABC\")\nelse : print (\"ARC\")\n", "neg": "a=int(input())\n\nif(a<1200):\n print(\"ABC\")\nelse:\n print(\"ARC)\n", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [26, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u210440747", "n_user": "u210440747", "pos": "if __name__==\"__main__\":\n s = int(input())\n if(s < 1200):\n print(\"ABC\")\n else:\n print(\"ARC\")", "neg": "if __name__==\"__main__\":\n s = int(input())\n if(s < 1200):\n\tprint(\"ABC\")\n else:\n print(\"ARC\")", "jacc_sim": 1.0, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [42, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u631914718", "n_user": "u000123984", "pos": "n = int(input())\nif n < 1200:\n\tprint('ABC')\nelse:\n\tprint('ARC')", "neg": "rate = int(input())\nif n < 1200: print(\"ABC\")\nelse: print(\"ARC\")", "jacc_sim": 0.9375, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [28, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u882200107", "n_user": "u312078744", "pos": "score = int(input())\nif score < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "neg": "score = input()\nif (score < 1200):\n print(\"ABC\")\nelse:\n print(\"ARC\")", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [28, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u788681441", "n_user": "u972398652", "pos": "x = int(input())\nans = 'ABC' if x<1200 else 'ARC'\nprint(ans)", "neg": "x = int(input)\nprint(\"ABC\") if x < 1200 else print(\"ARC\")", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [26, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u161703388", "n_user": "u754120791", "pos": "x = int(input())\n\nif x < 1200:\n string = \"ABC\"\nelse:\n string = \"ARC\"\n\nprint(string)", "neg": "x = int(input())\nif x < 1200:\nprint('ABC')\n\nelse:\nprint('ARC')", "jacc_sim": 0.9375, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [37, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u112002050", "n_user": "u181215519", "pos": "rate = int(input())\nif rate < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "neg": "rate = input()\nif rate < 1200 :\n print( \"ABC\" )\nelse :\n print( \"ARC\" )", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [28, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u455505352", "n_user": "u277373937", "pos": "x = int(input())\nif x<1200:\n\tprint(\"ABC\")\nelse:\n\tprint(\"ARC\")", "neg": "x = input()\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [28, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03813", "p_user": "u781758937", "n_user": "u152638361", "pos": "\nrate = int(input())\nif rate >= 1200:\n print('ARC')\nelse:\n print('ABC')\n\n", "neg": "if int(input())>=1200:\n\tprint(\"ARC\")\nelse print(\"ABC\")", "jacc_sim": 0.9333333333333333, "nl": "Smeke decides to join AtCoder Beginner Contest (ABC) if his current rating is less than 1200, otherwise, he participates in AtCoder Regular Contest (ARC). Given Smeke's current rating, x, print ABC if he participates in ABC, and print ARC otherwise.\n\nConstraints:\n1 \u2264 x \u2264 3,000\nx is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nx\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n1000\n\nSample Output 1:\nABC\nSmeke's current rating is less than 1200, so the output should be ABC.\n\nSample Input 2:\n2000\n\nSample Output 2:\nARC\nSmeke's current rating is not less than 1200, so the output should be ARC.", "before_after_length": [31, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u813387707", "n_user": "u813387707", "pos": "from collections import defaultdict\nn = int(input())\na_list = [int(x) for x in input().split()]\nd = defaultdict(int)\nfor a in a_list:\n d[a] += 1\nprint(len(d.keys()) - sum([1 for v in d.values() if v % 2 == 0]) % 2)", "neg": "from collections import defaultdict\nn = int(input())\na_list = [int(x) for x in input().split()]\nd = defaultdict(int)\nfor a in a_list:\n d[a] += 1\nprint(len(d.keys()) - sum([v % 2 for v in d.values()]) % 2)", "jacc_sim": 0.9411764705882353, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [82, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u190178779", "n_user": "u190178779", "pos": "import sys\nimport math\nN = int(input())\narray = list(map(int,input().split()))\nset_array = set(array)\n\nif not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()\n\nprint(len(list(set_array))) if len(list(set_array)) % 2 == 1 else print(len(list(set_array)) - 1)", "neg": "import sys\nimport math\nN = int(input())\narray = list(map(int,input().split()))\nset_array = set(array)\n\nif not ( 3 <= N <= 10**5 and N % 2 == 1 ): sys.exit()\nif len(array) == len(list(set_array)): print(0);sys.exit()\n\nprint(len(list(set_array))) if len(list(set_array) % 2 == 1 else print(len(list(set_array) - 1)", "jacc_sim": 0.9444444444444444, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [98, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u995062424", "n_user": "u995062424", "pos": "from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\n\na = Counter(A)\nl_a = len(a)\nif(l_a%2 == 0):\n print(l_a-1)\nelse:\n print(l_a)\n", "neg": "from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\n\n#a = Counter(A)\nl_a = len(a)\nif(l_a%2 == 0):\n print(l_a-1)\nelse:\n print(l_a)", "jacc_sim": 0.9655172413793104, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u855831834", "n_user": "u855831834", "pos": "#D\nimport collections\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nmost = c.most_common()\nans = len(most)\neaten = 0\nfor t in most:\n if t[1] != 1:\n eaten += t[1]-1\nif eaten%2 == 1:\n print(ans-1)\nelse:\n print(ans)", "neg": "#D\nimport collections\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nmost = c.most_common()\nans = len(most)\neaten = 0\nfor t in most:\n if t[1] != 1:\n eaten += t[1]-1\nif eaten%2 == 1:\n print(ans-2)\nelse:\n print(ans)", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [110, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u017415492", "n_user": "u017415492", "pos": "n=int(input())\na=list(map(int,input().split()))\nd=[0]*(10**5+1)\nsa=set(a)\nfor i in a:\n d[i]+=1\nfor j in range(len(d)):\n if d[j]>2 and d[j]%2==0:\n d[j]=2\n elif d[j]>2 and d[j]%2!=0:\n d[j]=1\nni=d.count(2)\nif ni%2==0:\n print(len(sa))\nelse:\n print(len(sa)-1)", "neg": "n=int(input())\na=list(map(int,input().split()))\nd=[0]*(10**5+1)\nsa=set(a)\nfor i in a:\n d[i]+=1\nfor j in range(len(d)):\n if d[j]>2 and d[j]%2==0:\n d[j]=2\n elif d[j]>2 and d[j]%2!=0:\n d[j]=1\niti=d.count(1)\ndsum=sum(d)-iti\nif dsum%2==0:\n print(len(sa))\nelse:\n print(len(sa)-1)", "jacc_sim": 0.9111111111111111, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [157, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u405256066", "n_user": "u405256066", "pos": "from sys import stdin\nN = int(stdin.readline().rstrip())\nA = [int(x) for x in stdin.readline().rstrip().split()]\ns = len(set(A))\nif s % 2 != 0:\n print(s)\nelse:\n print(s-1)", "neg": "from sys import stdin\nfrom collections import Counter\nN = int(stdin.readline().rstrip())\nA = [int(x) for x in stdin.readline().rstrip().split()]\ns = len(set(A))\nif s % 2 == 0:\n print(s)\nelse:\n print(s-1)", "jacc_sim": 0.9117647058823529, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [73, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u852790844", "n_user": "u852790844", "pos": "n = int(input())\na = set(map(int,input().split()))\nans = len(a) if len(a)%2 == n%2 else len(a)-1\nprint(ans)", "neg": "n = int(input())\na = set(map, input().split())\nans = len(a) if len(a)%2 == n%2 else len(a)-1\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [49, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u111555888", "n_user": "u111555888", "pos": "from collections import defaultdict\nN=int(input())\nh=[]\na=list(map(int,input().split()))\ncnt_dic=defaultdict(int)\nfor i in range(N):\n cnt_dic[a[i]]+=1\ncnt_l=sorted(cnt_dic.values(),reverse=True)\nans=len(cnt_l)\ntmp=0\nfor i in range(ans):\n if cnt_l[i]%2==0:\n tmp+=1\nif tmp%2==0:\n pass\nelse:\n ans-=1\nprint(ans)", "neg": "N=int(input())\nh=[]\na=list(map(int,input().split()))\ncnt_dic=defaultdict(int)\nfor i in range(N):\n cnt_dic[a[i]]+=1\ncnt_l=sorted(cnt_dic.values(),reverse=True)\nans=len(cnt_l)\ntmp=0\nfor i in range(ans):\n if cnt_l[i]%2==0:\n tmp+=1\nif tmp%2==0:\n pass\nelse:\n ans-=1\nprint(ans)", "jacc_sim": 0.9302325581395349, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [143, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u237362582", "n_user": "u237362582", "pos": "from collections import Counter\nfrom operator import itemgetter\nN = int(input())\nA = Counter(map(int, input().split()))\nans = 0\nleft = 0\nfor k, v in sorted(A.items(), key=itemgetter(1))[::-1]:\n if left == 1:\n if v == 1:\n ans += 1\n left = 0\n continue\n else:\n v -= 1\n ans += 1\n left = 0\n if v > 3:\n v = v%2 + 2\n\n if v == 1:\n ans += 1\n elif v == 2:\n left += 1\n elif v == 3:\n ans += 1\n\nprint(ans)\n", "neg": "from collections import Counter\nfrom operator import itemgetter\nN = int(input())\nA = Counter(map(int, input().split()))\nans = 0\nleft = 0\nfor k, v in sorted(A.items(), key=itemgetter(1))[::-1]:\n print(k, v, left, ans)\n if left == 1:\n if v == 1:\n ans += 1\n left = 0\n continue\n else:\n v -= 1\n ans += 1\n left = 0\n if v > 3:\n v = v%2 + 2\n\n if v == 1:\n ans += 1\n elif v == 2:\n left += 1\n elif v == 3:\n ans += 1\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [168, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u088552457", "n_user": "u088552457", "pos": "n = int(input())\n\na = map(int, input().split())\n\nkind = len(set(a))\n\nif kind % 2 == 0:\n print(kind - 1)\nelse:\n print(kind)\n ", "neg": "n = int(input())\n\na = map(int, input().split())\n\nkind = len(set(a))\n\nif kind % 2 == 0:\n print(kind - 1)\nelse:\n print(kin)\n ", "jacc_sim": 0.9583333333333334, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [56, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u268792407", "n_user": "u268792407", "pos": "n=int(input())\na=set(map(int,input().split()))\nk=len(a)\n#\u5c11\u306a\u304f\u3068\u3082n-k\u679a\u6e1b\u3089\u3059\nif (n-k) % 2 == 0:\n print(k)\nelse:\n print(k-1)", "neg": "n=int(input())\na=set(map(int,input().split()))\nk=len(a)\n#\u5c11\u306a\u304f\u3068\u3082n-k\u679a\u6e1b\u3089\u3059\nif n-k % 2 == 0:\n print(k)\nelse:\n print(k-1)", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [88, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u047816928", "n_user": "u047816928", "pos": "N = int(input())\nA = list(map(int, input().split()))\nD = {}\nfor a in A:\n if a not in D: D[a] = 0\n D[a] += 1\n\nn2 = 0\nfor k in D:\n D[k] = 2 if D[k]%2==0 else 1\n if D[k]==2: n2+=1\n\nprint(len(D) - n2%2)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nD = {}\nfor a in A:\n if a not in D: D[a] = 0\n D[a] += 1\n\nn2 = 0\nfor k in D:\n D[k] = 2 if D[k]%2==0 else 1\n if D[k]==2: n2+=1\n\nprint(len(D) + n2%2)", "jacc_sim": 0.9705882352941176, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [112, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u731368968", "n_user": "u731368968", "pos": "#1,1,1 -> (1,1) 1\n\n#1,2,3 -> (1,3) 2\n\n#1,1,3 -> (1,3) 1 <=> 1,1,3,3 -> (1,3) 1,3\n\n#1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1]\n#[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1]\n\n#\u305d\u308c\u305e\u308c1\u307e\u305f\u306f2\u3068\u7b49\u3057\u3044\n#[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1]\n#[1,1,3,3,6,6,8,8]\n#[1,1,3,6,6,8,8]\n#[1,3,6,8]\n\nN = int(input())\nA = list(map(int, input().split()))\nB = [-1 for i in range(100005)]\n\nfor i in range(N):\n if B[A[i]] == -1:\n B[A[i]] = 1\n elif B[A[i]] == 1:\n B[A[i]] = 2\n elif B[A[i]] == 2:\n B[A[i]] = 1\n\nn = len(B) - B.count(-1)\n\nif B.count(2) % 2 == 0:\n print(n)\nelse:\n print(n-1)\n", "neg": "#1,1,1 -> (1,1) 1\n\n#1,2,3 -> (1,3) 2\n\n#1,1,3 -> (1,3) 1 <=> 1,1,3,3 -> (1,3) 1,3\n\n#1,2,1,3,7 == [1:2, 2:1, 3:1, 7:1]\n#[1:4, 2:3, 3:2, 5:1, 6:2, 8:2, 11:1]\n\n#\u305d\u308c\u305e\u308c1\u307e\u305f\u306f2\u3068\u7b49\u3057\u3044\n#[1:2, 2:1, 3:2, 5:1, 6:2, 8:2, 11:1]\n#[1,1,3,3,6,6,8,8]\n#[1,1,3,6,6,8,8]\n#[1,3,6,8]\n\nN = int(input())\nA = list(map(int, input().split()))\nB = [-1 for i in range(100005)]\n\nfor i in range(N):\n if B[A[i]] == -1:\n B[A[i]] = 1\n elif B[A[i]] == 1:\n B[A[i]] = 2:\n elif B[A[i]] == 2:\n B[A[i]] = 1\n\nn = N - B.count(-1)\n\nif B.count(2) % 2 == 0:\n print(n)\nelse:\n print(n-1)\n", "jacc_sim": 0.9811320754716981, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [397, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u923659712", "n_user": "u923659712", "pos": "n=int(input())\na=list(map(int,input().split()))\ni=len(a)\ns=set(a)\nj=len(s)\nif (i-j)%2==0:\n print(n-(i-j))\nelse:\n print(n-(i-j+1))\n", "neg": "n=int(input())\na=list(map(int,input().split()))\ni=len(a)\ns=set(a)\nj=len(s)\n\nif (i-j)%2==0:\n print((i-j)//2)\nelse:\n print((i-j)//2+1)", "jacc_sim": 0.9642857142857143, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u760767494", "n_user": "u760767494", "pos": "import collections\n\nn = int(input())\nl = list(map(int, input().split()))\nl = collections.Counter(l)\nkind = len(l.keys())\nif (n-kind)%2==0:\n print(len(l.keys()))\nelse:\n print(len(l.keys())-1)\n", "neg": "import collections\n\nn = int(input())\nl = list(map(int, input().split()))\nl = collections.Counter(l)\nif n%2==0:\n print(len(l.keys()))\nelse:\n print(len(l.keys())-1)", "jacc_sim": 0.9629629629629629, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [82, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u297109012", "n_user": "u297109012", "pos": "from collections import Counter\n\n\ndef solve(N, As):\n counter = Counter(As)\n if len(counter) % 2 == 0:\n return len(counter) - 1\n return len(counter)\n\nif __name__ == \"__main__\":\n N = int(input())\n As = list(map(int, input().split(\" \")))\n print(solve(N, As))\n", "neg": "from collections import Counter\n\n\ndef solve(N, As):\n print(N, \",\", As)\n counter = Counter(As)\n if len(counter) % 2 == 0:\n return len(counter) - 1\n return len(counter)\n\nif __name__ == \"__main__\":\n N = int(input())\n As = list(map(int, input().split(\" \")))\n print(solve(N, As))\n", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [96, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u004025573", "n_user": "u004025573", "pos": "x=int(input())\na=list(map(int,input().split()))\n\nb=list(set(a))\ny=len(b)\n\nprint(x-(x-y)-(x-y)%2)\n", "neg": "x=int(input())\na=list(map(int,input().split()))\n\nb=list(set(a))\ny=len(b)\n\nprint(x-y-y%2)\n", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [57, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u192908410", "n_user": "u192908410", "pos": "input()\na = list(map(int, input().split()))\nc = {}\nlb = lc = 0\nfor i in a:\n try:\n c[i] += 1\n lb += 1\n except:\n c[i] = 1\n lc += 1\nprint(lc if lb % 2 == 0 else lc-1)", "neg": "input()\na = list(map(int, input().split()))\nc = {}\nlb = lc = 0\nfor i in a:\n try:\n c[i] += 1\n lb += 1\n except:\n c[i] = 1\n lc += 1\nprint(c)\nprint(lc if lb % 2 == 0 else lc-1)", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [81, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u311442150", "n_user": "u311442150", "pos": "n=int(input())\na=list(input().split())\nans=len(set(a))\nif ans%2 == 0:\n ans -= 1\nprint(ans)", "neg": "n=int(input())\na=list(input().split())\nans=len(set(a))\nif ans%2==0:\n ans-1\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [42, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u190405389", "n_user": "u623687794", "pos": "n = int(input())\na = len(set(map(int, input().split())))\nprint(a if (n-a) % 2 == 0 else a-1)\n", "neg": "n=int(input())\na=list(map(int,input().split()))\nb=set(a)\nprint(len(b) if len(b)%2==0 else len(b)-1)", "jacc_sim": 0.9130434782608695, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [42, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u683134447", "n_user": "u665038048", "pos": "n = int(input())\na = list(map(int,input().split()))\n\n\ns = len(a) -len(set(a))\nif s%2 == 1:\n print(len(set(a))-1)\nelse:\n print(len(set(a)))\n \n ", "neg": "n = int(input())\na = list(map(int, input().split()))\nif len(a) % 2 == 1:\n print(len(list(set(a))))\nelse:\n print(len(list(set(a))) - 1)\n", "jacc_sim": 0.9565217391304348, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [74, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u683479402", "n_user": "u109617108", "pos": "N = int(input())\n\nA = len(set(list(map(int, input().split()))))\n\nif A % 2 == 0:\n print(A - 1)\nelse:\n print(A)\n", "neg": "N=int(input())\nA=list(map(int,input().split()))\nm=set(A)\nif m%2==0:\n print(m-1)\nelse:\n print(m)", "jacc_sim": 0.9166666666666666, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [53, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u010110540", "n_user": "u875600867", "pos": "N = int(input())\nA = list(map(int, input().split()))\nsetA = set(A)\nif len(setA) % 2 != 0:\n print(len(setA))\nelse:\n print(len(setA) - 1)", "neg": "N=int(input())\n\nA = list(map(int, input().split()))\nif len(A)-len(set(A))%2==1:\n print(len(set(A))-1)\nelse:\n print(len(set(A)))", "jacc_sim": 0.9166666666666666, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u791838908", "n_user": "u791838908", "pos": "N = int(input())\nA = input()\nlist_A = A.split()\nset_A = set(list_A)\ni = 0\n\nfor a in list_A:\n if a in set_A:\n i += 1\n \ni = i - len(set_A)\nif i % 2 == 0:\n print(N - i)\nelse:\n print(N - (i +1))\n", "neg": "N = int(input())\nA = input()\nlist_A = A.split()\nset_A = set(list_A)\n i = 0\nfor a in list_A:\n if a in set_A:\n i += 1\n i = i - len(set_A)\n if i % 2 == 0:\n print(N - i)\n else:\n print(N - (i +1))", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [102, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u379559362", "n_user": "u379559362", "pos": "n = int(input())\na = list(map(int, input().split()))\na_set = set(a)\n\nif len(a_set) % 2 == 0:\n print(len(a_set) - 1)\nelse:\n print(len(a_set))\n", "neg": "n = int(input())\na = list(map(int, input().split()))\na_set = set(a)\nif len(a) % 2 == 0:\n print(len(a_set) - 1)\nelse:\n print(len(a_set))\n", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [70, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03816", "p_user": "u973712798", "n_user": "u973712798", "pos": "import collections\nn = int(input())\na_list = [int(i) for i in input().split()]\n#\u307e\u305a\u3001\u5947\u6570\u500b\u5b58\u5728\u3059\u308b\u6570\u5b57\u3092\u9664\u53bb\ncnt = collections.Counter(a_list)\nc = 0\nfor key, num in cnt.items():\n # print(cnt)\n if num == 2 or num == 1:\n if num == 2:\n c += 1\n pass\n # 1\u3088\u308a\u5927\u304d\u3044\u5947\u6570\u306a\u3089\n elif num % 2 != 0 and num > 1:\n cnt[key] = 1\n # num = 1\n # 2\u3088\u308a\u5927\u304d\u3044\u5076\u6570\u306a\u3089\n elif num % 2 == 0 and num > 2:\n c += 1\n cnt[key] = 2\n # num = 2\n else:\n pass\n # print(\"?\")\n\n\nresult = 0\n# for key, num in cnt.items():\n# if num == 2:\n# c += 1\n\nif c % 2 == 0:\n result = len(cnt)\nelse:\n result = len(cnt) - 1\n\nprint(result)\n\n# print(\"final:\",cnt)\n", "neg": "import collections\nn = int(input())\na_list = [int(i) for i in input().split()]\n#\u307e\u305a\u3001\u5947\u6570\u500b\u5b58\u5728\u3059\u308b\u6570\u5b57\u3092\u9664\u53bb\ncnt = collections.Counter(a_list)\n\nfor key, num in cnt.items():\n print(cnt)\n if num == 2 or num == 1:\n pass\n # 1\u3088\u308a\u5927\u304d\u3044\u5947\u6570\u306a\u3089\n elif num % 2 != 0 and num > 1:\n cnt[key] = 1\n # num = 1\n # 2\u3088\u308a\u5927\u304d\u3044\u5076\u6570\u306a\u3089\n elif num % 2 == 0 and num > 2:\n cnt[key] = 2\n # num = 2\n else:\n pass\n # print(\"?\")\n\nc = 0\nresult = 0\nfor key, num in cnt.items():\n if num == 2:\n c += 1\n\nif c % 2 == 0:\n result = len(cnt)\nelse:\n result = len(cnt) - 1\n\nprint(result)\n\n# print(\"final:\",cnt)\n", "jacc_sim": 1.0, "nl": "Snuke wants to play a card game with a deck of N cards, each labeled with an integer Ai. He can repeat an operation to remove three cards, eat the highest and lowest value cards, and return the remaining card to the deck. The goal is to find the maximum number of remaining cards with distinct values. Constraints: 3 \u2264 N \u2264 10^5, N is odd, 1 \u2264 Ai \u2264 10^5. Input format: N followed by N integers. Output: Print the answer. Example: Input 1: 5 1 2 1 3 7, Output 1: 3. Example: Input 2: 15 1 3 5 2 1 3 2 8 8 6 2 6 11 1 1, Output 2: 7.", "before_after_length": [345, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03819", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\n\nN,M = map(int,input().split())\nd_to_LR = defaultdict(list)\nfor _ in range(N):\n L,R = map(int,input().split())\n d_to_LR[R-L+1].append((L,R))\n\ndef BIT_update(tree,x,value):\n while x <= M:\n tree[x] += value\n x += x & (-x)\n\ndef BIT_sum(tree,x):\n s = 0\n while x:\n s += tree[x]\n x -= x & (-x)\n return s\n\ntree = [0] * (M+1) # BIT \u3067\u7ba1\u7406\u3002\u5de6\u306b\u3042\u308bL\u306e\u500b\u6570 - (R+1)\u306e\u500b\u6570 \u2192 \u3044\u304f\u3064\u306e[L,R]\u306b\u5165\u3063\u3066\u3044\u308b\u304b\nlong = N # \u9577\u3059\u304e\u3066\u81ea\u52d5\u56de\u53ce\u3067\u304d\u308b\nanswer = [0] * (M+1)\n\nfor m in range(1,M+1):\n for L,R in d_to_LR[m]:\n BIT_update(tree,L,1)\n BIT_update(tree,R+1,-1)\n long -= 1\n answer[m] = sum(BIT_sum(tree,x) for x in range(m,M+1,m)) + long\n\nprint('\\n'.join(map(str, answer[1:])))", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\n\nN,M = map(int,input().split())\nd_to_LR = defaultdict(list)\nfor _ in range(N):\n L,R = map(int,input().split())\n d_to_L[R-L+1].append(L)\n\ntree = [0] * (M+1) # BIT \u3067\u7ba1\u7406\u3002\u5de6\u306b\u3042\u308bL\u306e\u500b\u6570 - (R+1)\u306e\u500b\u6570 \u2192 \u3044\u304f\u3064\u306e[L,R]\u306b\u5165\u3063\u3066\u3044\u308b\u304b\nlong = N # \u9577\u3059\u304e\u3066\u81ea\u52d5\u56de\u53ce\u3067\u304d\u308b\nanswer = [0] * (M+1)\n\nfor m in range(1,M+1):\n for L in d_to_L[m]:\n R = L+m-1\n x = L\n while x <= M:\n tree[x] += 1\n x += x & (-x)\n x = R+1\n while x <= M:\n tree[x] -= 1\n x += x & (-x)\n long -= 1\n s = long\n for x in range(m,M+1,m):\n while x:\n s += tree[x]\n x -= x & (-x)\n answer[m] = s\n\nprint('\\n'.join(map(str, answer[1:])))\n", "jacc_sim": 0.9186046511627907, "nl": "Snuke is playing a game where the player runs a railway company. There are M+1 stations on Snuke Line, numbered 0 through M. A train stops at station 0 and every d-th station thereafter. There are N kinds of souvenirs sold in areas around Snuke Line. Each souvenir can be purchased when the train stops at specific stations. For M values of d, find the number of souvenirs that can be purchased if one takes a train with that value of d at station 0. Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 l_i \u2264 r_i \u2264 M. Input format: N M, followed by l_i r_i for each souvenir. Output: M lines, each containing the maximum number of souvenirs that can be purchased if one takes a train stopping every i-th station.", "before_after_length": [431, 409], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03822", "p_user": "u654470292", "n_user": "u654470292", "pos": "import bisect, copy, heapq, math, sys\nfrom collections import *\nfrom functools import lru_cache\nfrom itertools import accumulate, combinations, permutations, product\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\ndef celi(a,b):\n return -(-a//b)\nsys.setrecursionlimit(5000000)\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\ndef main():\n n=int(input())\n a=[int(input()) for i in range(n-1)]\n # print(a)\n dic={}\n for i in range(n-1):\n p=a[i]\n if p in dic:\n dic[p].append(i+2)\n else:\n dic[p]=[i+2]\n\n\n lst=[-1]*(n+1)\n\n def solve(m):\n if lst[m]!=-1:\n return lst[m]\n tmp=[]\n if m in dic:\n\n for i in dic[m]:\n tmp.append(solve(i))\n tmp.sort(reverse=True)\n rtn=0\n for i in range(len(tmp)):\n rtn=max(rtn,tmp[i]+i+1)\n lst[m]=rtn\n return rtn\n\n solve(1)\n # print(lst)\n print(max(lst))\nmain()", "neg": "import bisect, copy, heapq, math, sys\nfrom collections import *\nfrom functools import lru_cache\nfrom itertools import accumulate, combinations, permutations, product\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\ndef celi(a,b):\n return -(-a//b)\nsys.setrecursionlimit(5000000)\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\ndef main()\n n=int(input())\n a=[int(input()) for i in range(n-1)]\n # print(a)\n dic=defaultdict(list)\n for i in range(n-1):\n p=a[i]\n dic[p].append(i+2)\n # print(dic)\n\n lst=[-1]*(n+1)\n\n def solve(m):\n if lst[m]!=-1:\n return lst[m]\n tmp=[]\n for i in dic[m]:\n tmp.append(solve(i))\n tmp.sort(reverse=True)\n rtn=0\n for i in range(len(tmp)):\n rtn=max(rtn,tmp[i]+i+1)\n lst[m]=rtn\n return rtn\n\n solve(1)\n # print(lst)\n print(max(lst))\nmain()", "jacc_sim": 0.9506172839506173, "nl": "In a competition, N contestants participate in a knockout tournament with N-1 matches. The tournament may not be fair for all contestants, as the number of matches needed to win may vary. The depth of the tournament is the maximum number of matches needed to win. The goal is to find the minimum possible depth of the tournament. The tournament's structure is defined by predetermined contestants playing against each other. The input consists of N and the results of matches, and the output should be the minimum possible depth of the tournament.", "before_after_length": [402, 383], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03822", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\na = [None]*(n-1)\nfrom collections import defaultdict\nc = defaultdict(list)\nfor i in range(n-1):\n num = int(input())\n c[num].append(i+2)\n\ndef sub(winner):\n l = len(c[winner])\n vs = []\n for p in c[winner]:\n vs.append(sub(p))\n vs.sort()\n ans = l\n for i,v in enumerate(vs):\n ans = max(ans, l-(i)+v)\n# print(winner, ans, l, vs)\n return ans\nans = sub(1)\nprint(ans)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\na = [None]*(n-1)\nfrom collections import defaultdict\nc = defaultdict(list)\nfor i in range(n-1):\n num = int(input())\n a[i] = num\n c[num].append(i+2)\n\ndef sub(winner):\n l = len(c[winner])\n vs = []\n for p in c[winner]:\n vs.append(sub(p))\n ans = l\n for i,v in enumerate(vs):\n ans = max(l, l-(i)+v)\n# print(winner, ans, l, vs)\n return ans\nans = sub(1)\nprint(ans)", "jacc_sim": 0.9830508474576272, "nl": "In a competition, N contestants participate in a knockout tournament with N-1 matches. The tournament may not be fair for all contestants, as the number of matches needed to win may vary. The depth of the tournament is the maximum number of matches needed to win. The goal is to find the minimum possible depth of the tournament. The tournament's structure is defined by predetermined contestants playing against each other. The input consists of N and the results of matches, and the output should be the minimum possible depth of the tournament.", "before_after_length": [222, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03822", "p_user": "u287132915", "n_user": "u287132915", "pos": "import sys\nsys.setrecursionlimit(10**5)\n\nn = int(input())\ndic = {}\nfor i in range(n+1):\n if i <= 1: continue\n ai = int(input())\n if ai in dic:\n dic[ai].append(i)\n else:\n dic[ai] = [i]\n\ndef dfs(nxt):\n lst = []\n if nxt in dic:\n while dic[nxt] != []:\n child = dic[nxt].pop()\n tempmax = dfs(child)\n lst.append(tempmax)\n else:\n return 0\n lst.sort(reverse=True)\n for i in range(len(lst)):\n lst[i] += i+1\n return max(lst)\n\nans = dfs(1)\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10**10)\n\nn = int(input())\ndic = {}\nfor i in range(n+1):\n if i <= 1: continue\n ai = int(input())\n if ai in dic:\n dic[ai].append(i)\n else:\n dic[ai] = [i]\n\ndef dfs(nxt):\n lst = []\n if nxt in dic:\n while dic[nxt] != []:\n child = dic[nxt].pop()\n tempmax = dfs(child)\n lst.append(tempmax)\n else:\n return 0\n lst.sort(reverse=True)\n for i in range(len(lst)):\n lst[i] += i+1\n return max(lst)\n\nans = dfs(1)\nprint(ans)", "jacc_sim": 0.9795918367346939, "nl": "In a competition, N contestants participate in a knockout tournament with N-1 matches. The tournament may not be fair for all contestants, as the number of matches needed to win may vary. The depth of the tournament is the maximum number of matches needed to win. The goal is to find the minimum possible depth of the tournament. The tournament's structure is defined by predetermined contestants playing against each other. The input consists of N and the results of matches, and the output should be the minimum possible depth of the tournament.", "before_after_length": [202, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03822", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 6)\nN = int(input())\na = [0]\nreva = [[] for _ in range(N + 1)]\nfor _ in range(N - 1): a.append(int(input()))\nfor i in range(N):\n if a[i] == 0: continue\n reva[a[i]].append(i + 1)\ndp = [-1] * (N + 1)\ndef dfs(x):\n global dp\n if len(reva[x]) == 0:\n dp[x] = 1\n return 1\n t = []\n for y in reva[x]:\n t.append(dfs(y))\n t.sort(reverse = True)\n for i in range(len(t)):\n t[i] += i + 1\n dp[x] = max(t)\n return dp[x]\nprint(dfs(1) - 1)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\na = [0]\nreva = [[] for _ in range(N + 1)]\nfor _ in range(N - 1): a.append(int(input()))\nfor i in range(N):\n if a[i] == 0: continue\n reva[a[i]].append(i + 1)\nexit(0)\ndp = [-1] * (N + 1)\ndef dfs(x):\n global dp\n if len(reva[x]) == 0:\n dp[x] = 1\n return 1\n t = []\n for i in range(len(reva[x])):\n y = reva[x][i]\n t.append(dfs(y))\n t.sort(reverse = True)\n for i in range(len(reva[x])):\n t[i] += i + 1\n dp[x] = max(t)\n return dp[x]\nprint(dfs(1) - 1)", "jacc_sim": 0.9148936170212766, "nl": "In a competition, N contestants participate in a knockout tournament with N-1 matches. The tournament may not be fair for all contestants, as the number of matches needed to win may vary. The depth of the tournament is the maximum number of matches needed to win. The goal is to find the minimum possible depth of the tournament. The tournament's structure is defined by predetermined contestants playing against each other. The input consists of N and the results of matches, and the output should be the minimum possible depth of the tournament.", "before_after_length": [236, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03822", "p_user": "u163320134", "n_user": "u163320134", "pos": "import sys\nsys.setrecursionlimit(10**9)\n\ndef dfs(v):\n if len(g[v])==0:\n return 0\n dic={}\n for u in g[v]:\n tmp=dfs(u)\n if tmp not in dic:\n dic[tmp]=1\n else:\n dic[tmp]+=1\n arr=[]\n for pos in dic.keys():\n arr+=[pos]*dic[pos]\n arr=sorted(arr,reverse=True)\n return max([(i+1)+arr[i] for i in range(len(arr))])\n\nn=int(input())\ng=[[] for _ in range(n+1)]\nfor i in range(n-1):\n v=int(input())\n g[v].append(i+2)\nprint(dfs(1))", "neg": "import sys\nsys.setrecursionlimit(10**9)\n\ndef dfs(v):\n if len(g[v])==0:\n return 0\n dic={}\n for u in g[v]:\n tmp=dfs(u)\n if tmp not in dic:\n dic[tmp]=1\n else:\n dic[tmp]+=1\n arr=list(dic.keys())\n arr=sorted(arr,reverse=True)\n return max([(i+1)+arr[i] for i in range(len(arr))])\n\nn=int(input())\ng=[[] for _ in range(n+1)]\nfor i in range(n-1):\n v=int(input())\n g[v].append(i+2)\nprint(dfs(1))", "jacc_sim": 0.9607843137254902, "nl": "In a competition, N contestants participate in a knockout tournament with N-1 matches. The tournament may not be fair for all contestants, as the number of matches needed to win may vary. The depth of the tournament is the maximum number of matches needed to win. The goal is to find the minimum possible depth of the tournament. The tournament's structure is defined by predetermined contestants playing against each other. The input consists of N and the results of matches, and the output should be the minimum possible depth of the tournament.", "before_after_length": [204, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03829", "p_user": "u672475305", "n_user": "u672475305", "pos": "n,a,b = map(int,input().split())\nX = list(map(int,input().split()))\npos = X[0]\nans = 0\nfor i in range(1, n):\n ans += min(b, (X[i] - pos)*a)\n pos = X[i]\nprint(ans)", "neg": "n,a,b = map(int,input().split())\nX = list(map(int,input().split()))\npos = X[0]\nans = 0\nfor i in range(1, n):\n ans += min(b, X[i] - pos)\n pos = X[i]\nprint(ans)", "jacc_sim": 0.9666666666666667, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi0:\n ans+=B\n else:\n ans+=(xi-pre)*A\n pre=xi\n\nprint(ans)", "neg": "N,A,B=map(int,input().split())\nX=list(map(int,input().split()))\n\nans=0\npre=X[0]\n\nfor xi in X[1:]:\n if (xi-pre)*A-B>0:\n ans+=B\n else:\n ans+=(xi-pre)\n pre=xi\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi=B:\n count+=M\n else:\n count+=B\nprint(count)", "jacc_sim": 0.9090909090909091, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi= B:\n F = F + B\n else:\n F = F + A*(int(X[i+1]) - int(X[i]))\n \n# Output\nprint(F)", "neg": "# -*- coding: utf-8 -*-\n\n# Input\ns = [input() for i in range(2)]\n\nN = int(s[0].split()[0])\nA = int(s[0].split()[1])\nB = int(s[0].split()[2])\nX = s[1].split()\n\n\nF = 0\n\n# \u75b2\u52b4\u5ea6\u306e\u5c11\u306a\u3044\u65b9\u6cd5\u3092\u9010\u6b21\u9078\u629e\u3059\u308b\nfor i in range(0, N-1):\n if A*(int(X[i+1]) - int(X[i])) >= B:\n F = F + B\n else:\n F = F + A*(int(X[i+1]) - int(X[i]))\n print(F)\n\n# Output\nprint(F)\n", "jacc_sim": 1.0, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi= B:\n Ans += B\n else:\n Ans += (X[i]-X[i-1])*A\n\nprint(Ans)", "neg": "N, A, B = map(int, input().split())\nX = list(map(int, input().split()))\nres = 0\nfor i in range(N - 1):\n if X[i + 1] - X[i] > B:\n res += B\n else:\n res += X[i + 1] = X[i]\nprint(res)", "jacc_sim": 0.90625, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi B:\n ans += B\n else:\n ans += d * A\nprint(ans", "jacc_sim": 0.9090909090909091, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi b:\n ans += b\n else:\n ans += (a * x[i])\n\nprint(ans)", "neg": "n,a,b=map(int,input().split())\nx=list(map(int,input().split()))\nans=0\nfor i in range(n):\n if (x[i+1]-x[i])*a>=b:\n ans+=b\n else:\n ans+=(x[i+1]-x[i])*a\nprint(ans)", "jacc_sim": 1.0, "nl": "You have N towns on a line running east-west, each with a one-dimensional coordinate. You start at town 1 and want to visit all other towns. You can walk, increasing fatigue by A per unit distance, or teleport, increasing fatigue by B regardless of distance. Find the minimum total fatigue increase. Constraints: 2\u2264N\u226410^5, 1\u2264Xi\u226410^9, Xi 100: break\n if tx == kx and ty == ky:\n ans = c\n break\n for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:\n tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0]\n kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0]\n if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue\n que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])\n pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))\n print(ans)\n\nif __name__ == \"__main__\":\n # prf = LineProfiler()\n # prf.add_function(main)\n # prf.runcall(main)\n # prf.print_stats()\n main()\n", "neg": "from line_profiler import LineProfiler\nfrom collections import deque\nfrom sys import stdin\n\ndef main():\n while(True):\n W, H = map(int, stdin.readline().split())\n if not W: break\n tx,ty = map(int, stdin.readline().split())\n kx,ky = map(int, stdin.readline().split())\n ma = [[False]*(W+2) for _ in range(H+2)]\n for i in range(1,H+1):\n for j,a in enumerate(stdin.readline().split()):\n ma[i][j+1] = bool(1-int(a))\n que = deque([[tx,ty,kx,ky,0]])\n pas = set()\n ans = \"NA\"\n while(que):\n tx,ty,kx,ky,c = que.popleft()\n if tx == kx and ty == ky:\n ans = c\n break\n for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:\n tdx, tdy = [ dx, dy] if ma[ty+dy][tx+dx] else [0,0]\n kdx, kdy = [-dx,-dy] if ma[ky-dy][kx-dx] else [0,0]\n if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue\n if c+1 > 100: continue\n que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])\n pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))\n print(ans)\n\nif __name__ == \"__main__\":\n prf = LineProfiler()\n prf.add_function(main)\n prf.runcall(main)\n prf.print_stats()\n # main()\n", "jacc_sim": 0.9390243902439024, "nl": "Title: Lost Twins\n\nTakayuki and Kazuyuki are close twins, but their movements are opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently, the two are in a department store at separate locations. To meet as quickly as possible after moving in opposite directions, what should they do?\n\nThe department store is represented by a grid consisting of W columns \u00d7 H rows, and the two can move one square in the cardinal directions per unit time. However, they cannot move outside the grid or into squares with obstacles.\n\nThe grid's positions are represented by coordinates (x, y).\n\nCreate a program that takes the grid information and the initial positions of the two individuals as input and outputs the shortest time for them to meet. If they cannot meet or if it takes more than 100 units of time to meet, output \"NA\". The grid information consists of H rows and W columns of numbers, and the positions of the two individuals are given by coordinates.\n\nIf either Takayuki or Kazuyuki encounters an obstacle or moves outside the grid after moving, they cannot move, and the one encountering the obstacle or moving outside the grid returns to the original position, while the other can continue moving without returning.\n\nWhen the two individuals meet, it means they stop at the same square after moving. Even if they pass each other, it does not count as meeting.\n\nInput:\nMultiple datasets are given as input. The end of input is indicated by two consecutive zero lines. Each dataset is given in the following format:\n\nW H\ntx ty\nkx ky\nd11 d21 ... dW1\nd12 d22 ... dW2\n:\nd1H d2H ... dWH\n\nOutput:\nFor each input dataset, output the shortest time in one line.\n\nSample Input:\n6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 0 0 0 0\n0 1 0 0 0 0\n0 0 0 1 0 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0\n\nOutput for the Sample Input:\n3\nNA", "before_after_length": [476, 485], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00223", "p_user": "u319725914", "n_user": "u319725914", "pos": "# from line_profiler import LineProfiler\nfrom collections import deque\nfrom sys import stdin\n\ndef main():\n while(True):\n W, H = map(int, stdin.readline().split())\n if not W: break\n tx,ty = map(int, stdin.readline().split())\n kx,ky = map(int, stdin.readline().split())\n ma = [[False]+[bool(1-int(a)) for a in stdin.readline().split()]+[False] for i in range(H)]\n ma = [[False]*(W+2)] + ma + [[False]*(W+2)]\n que = deque([[tx,ty,kx,ky,0]])\n pas = set()\n ans = \"NA\"\n while(que):\n tx,ty,kx,ky,c = que.popleft()\n if tx == kx and ty == ky:\n ans = c\n break\n if c+1 > 100: continue\n for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:\n tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0)\n kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0)\n if (tx+tdx,ty+tdy,kx+kdx,ky+kdy) in pas: continue\n que.append([tx+tdx,ty+tdy,kx+kdx,ky+kdy,c+1])\n pas.add((tx+tdx,ty+tdy,kx+kdx,ky+kdy))\n print(ans)\n\nif __name__ == \"__main__\":\n # prf = LineProfiler()\n # prf.add_function(main)\n # prf.runcall(main)\n # prf.print_stats()\n main()\n", "neg": "from line_profiler import LineProfiler\nfrom collections import deque\nfrom sys import stdin\n\ndef main():\n while(True):\n W, H = map(int, stdin.readline().split())\n if not W: break\n tx,ty = map(int, stdin.readline().split())\n kx,ky = map(int, stdin.readline().split())\n ma = [[False]*(W+2) for _ in range(H+2)]\n for i in range(1,H+1):\n for j,a in enumerate(stdin.readline().split()):\n ma[i][j+1] = bool(1-int(a))\n que = deque([[tx,ty,kx,ky,0]])\n pas = set()\n ans = \"NA\"\n while(que):\n tx,ty,kx,ky,c = que.popleft()\n if tx == kx and ty == ky:\n ans = c\n break\n for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:\n tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0)\n kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0)\n ttx,tty,kkx,kky = tx+tdx,ty+tdy,kx+kdx,ky+kdy\n if (ttx,tty,kkx,kky) in pas: continue\n if c+1 > 100: continue\n que.append([ttx,tty,kkx,kky,c+1])\n pas.add((ttx,tty,kkx,kky))\n print(ans)\n\nif __name__ == \"__main__\":\n prf = LineProfiler()\n prf.add_function(main)\n prf.runcall(main)\n prf.print_stats()\n # main()\n", "jacc_sim": 0.9166666666666666, "nl": "Title: Lost Twins\n\nTakayuki and Kazuyuki are close twins, but their movements are opposite. For example, if Takayuki goes west, Kazuyuki goes east, and if Kazuyuki goes north, Takayuki goes south. Currently, the two are in a department store at separate locations. To meet as quickly as possible after moving in opposite directions, what should they do?\n\nThe department store is represented by a grid consisting of W columns \u00d7 H rows, and the two can move one square in the cardinal directions per unit time. However, they cannot move outside the grid or into squares with obstacles.\n\nThe grid's positions are represented by coordinates (x, y).\n\nCreate a program that takes the grid information and the initial positions of the two individuals as input and outputs the shortest time for them to meet. If they cannot meet or if it takes more than 100 units of time to meet, output \"NA\". The grid information consists of H rows and W columns of numbers, and the positions of the two individuals are given by coordinates.\n\nIf either Takayuki or Kazuyuki encounters an obstacle or moves outside the grid after moving, they cannot move, and the one encountering the obstacle or moving outside the grid returns to the original position, while the other can continue moving without returning.\n\nWhen the two individuals meet, it means they stop at the same square after moving. Even if they pass each other, it does not count as meeting.\n\nInput:\nMultiple datasets are given as input. The end of input is indicated by two consecutive zero lines. Each dataset is given in the following format:\n\nW H\ntx ty\nkx ky\nd11 d21 ... dW1\nd12 d22 ... dW2\n:\nd1H d2H ... dWH\n\nOutput:\nFor each input dataset, output the shortest time in one line.\n\nSample Input:\n6 6\n2 4\n6 2\n0 0 0 0 1 0\n0 1 0 0 0 0\n0 1 0 0 0 0\n0 0 0 1 0 0\n0 0 0 0 0 1\n0 0 0 0 0 0\n3 3\n1 1\n3 3\n0 0 0\n0 1 0\n0 0 0\n0 0\n\nOutput for the Sample Input:\n3\nNA", "before_after_length": [479, 492], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00226", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n r, a= input().split()\n if r==a=='0': break\n print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))", "neg": "while True:\n r, a= input().split()\n if r==a==0: break\n print(sum(1 for i, j in zip(r, a) if i==j), sum(1 for i in range(len(r)) for j in range(len(a)) if r[i]==a[j] and i!=j))", "jacc_sim": 0.9666666666666667, "nl": "Title: \u30d2\u30c3\u30c8\u30a2\u30f3\u30c9\u30d6\u30ed\u30fc\n\nTaro and Hanako decided to play a game called \"Hit and Blow.\" The rules are as follows:\n- The game is played between a questioner and an answerer.\n- The questioner selects a 4-digit number (the correct answer) without any duplicate digits.\n- The answerer tries to guess the 4-digit number (the answer).\n- The questioner provides hints in the form of the number of hits and blows in response to the answer.\n- A hit is when both the number and the position of a digit are correct, while a blow is when only the number is correct but the position is wrong. For example, if the correct answer is 1234 and the answer is 1354, the questioner would provide the hint \"2 hits, 1 blow,\" and the process continues until the correct answer is guessed.\n- The questioner and answerer take turns playing the game, and the winner is the one who guesses the correct answer with the fewest attempts.\n\nTaro and Hanako find it a bit cumbersome to judge the number of hits and blows each time. Let's create a program that instantly determines the number of hits and blows for them.\n\nCreate a program that takes the correct answer (r) and the answer (a) as input and outputs the number of hits and blows. r and a are each a sequence of 4 digits ranging from 0 to 9.\n\nInput:\nMultiple datasets are provided as input. The end of the input is indicated by two consecutive zero lines. Each dataset provides r and a separated by a space on a single line.\n\nThe number of datasets does not exceed 12000.\n\nOutput:\nFor each input dataset, output the number of hits and blows on a single line.\n\nSample Input:\n1234 5678\n1234 1354\n1234 1234\n1230 1023\n0123 1234\n0 0\n\nOutput for the Sample Input:\n0 0\n2 1\n4 0\n1 3\n0 3", "before_after_length": [83, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00227", "p_user": "u314832372", "n_user": "u314832372", "pos": "for i in range(1, 101):\n count = 0\n temp = 0\n SetCount = 0\n\n try:\n str1 = input()\n list1 = str1.split(\" \")\n str2 = input()\n list2 = str2.split(\" \")\n list2.sort(key=int, reverse=True)\n for m in range(0, int(list1[0])):\n if (m+1) % int(list1[1]) == 0:\n SetCount = SetCount + 1\n #elif (m+1) % int(list1[1]) != 0 | SetCount == int(list1[0])//int(list1[1]):\n # count = count + int(list2[m])\n else:\n count = count + int(list2[m])\n print(count)\n\n except:\n break\n\n", "neg": "for i in range(1, 101):\n count = 0\n temp = 0\n SetCount = 0\n\n try:\n str1 = input()\n list1 = str1.split(\" \")\n str2 = input()\n list2 = str2.split(\" \")\n list2.sort(reverse=True)\n for m in range(0, int(list1[0])):\n if (m+1) % int(list1[1]) == 0:\n SetCount = SetCount + 1\n #elif (m+1) % int(list1[1]) != 0 | SetCount == int(list1[0])//int(list1[1]):\n # count = count + int(list2[m])\n else:\n count = count + int(list2[m])\n print(count)\n\n except:\n break\n", "jacc_sim": 0.9777777777777777, "nl": "Title: Customer Appreciation Festival\n\nIn the midst of soaring vegetable prices due to bad weather, Seven Mart is conducting a bulk purchase sale for its customers. Even vegetables that are not usually available in the store are now attracting attention due to their affordable prices, resulting in a bustling atmosphere within the store.\n\nOne day, a trio of friends living in Matsunaga Housing Estate were discussing the advertisement for Seven Mart. This sale, named \"Customer Appreciation Festival,\" features a highlight where the cheapest vegetable in a bag of up to M vegetables becomes free. Upon reading the advertisement, it appears to be a sale structured as follows:\n\n- Each bag can contain up to M vegetables.\n- In a bag with M vegetables, the cheapest vegetable becomes free.\n- Bags with fewer than M vegetables are not eligible for the discount.\n\nThe trio promptly went shopping at Seven Mart.\n\nAfter finishing their shopping and meeting outside the store, the three friends, satisfied with their affordable and plentiful purchases, realized that they had all bought the same vegetable. One of them exclaimed, \"It's really cheap, only XXX yen!\" Another friend, surprised, said, \"Huh? I paid more than that! Why?\" Meanwhile, the remaining friend, upon checking the receipt, realized that they had made the cheapest purchase.\n\nNow, how should they pack the bags to minimize the purchase price? Create a program that takes input for the number of vegetables to be purchased, the number of vegetables per bag, and the price of each vegetable, and outputs the lowest purchase price.\n\nInput:\nMultiple datasets are provided as input. The end of input is indicated by two consecutive zeros. Each dataset is given in the following format:\n\nn m\np1 p2 ... pn\n\nThe first line provides the number of vegetables to be purchased, n (1 \u2264 n \u2264 1000), and the number of vegetables per bag, m (1 \u2264 m \u2264 1000). The second line provides the price of each vegetable, pi (10 \u2264 pi \u2264 10000).\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each input dataset, output the lowest purchase price on a new line.\n\nSample Input:\n4 2\n50 40 100 80\n7 3\n400 300 100 700 200 600 500\n0 0\n\nOutput for the Sample Input:\n150\n2100", "before_after_length": [214, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00228", "p_user": "u350508326", "n_user": "u350508326", "pos": "#!/usr/bin/env python3\n\nseven_seg = {\n 0: '0111111',\n 1: '0000110',\n 2: '1011011',\n 3: '1001111',\n 4: '1100110',\n 5: '1101101',\n 6: '1111101',\n 7: '0100111',\n 8: '1111111',\n 9: '1101111'\n }\n\nwhile True:\n seven_seg_state = ['0'] * 7\n n = int(input())\n if n == -1:\n break\n for _ in range(n):\n in_data = int(input())\n for i in range(7):\n if seven_seg[in_data][i] == seven_seg_state[i]:\n print(\"0\", end=\"\")\n else:\n print(\"1\", end=\"\")\n seven_seg_state[i] = seven_seg[in_data][i]\n\n print()", "neg": "#!/usr/bin/env python3\n\nseven_seg = {\n 0: '0111111',\n 1: '0000110',\n 2: '1011011',\n 3: '1001111',\n 4: '1100110',\n 5: '1101101',\n 6: '1111101',\n 7: '0100111',\n 8: '1111111',\n 9: '1101111'\n }\n\nwhile True:\n seven_seg_state = ['0'] * 7\n n = int(input())\n if n == -1:\n break\n for _ in range(n):\n in_data = int(input())\n for i, s in enumerate(seven_seg_state):\n if seven_seg[in_data][i] == s:\n print(\"0\", end=\"\")\n else:\n print(\"1\", end=\"\")\n s = seven_seg[in_data][i]\n\n print()", "jacc_sim": 0.9661016949152542, "nl": "Title: 7 Segment\n\nDigital displays showing numbers often seen on calculators are composed of 7 segments, hence called \"7-segment displays.\"\n\nA new product from Wakamatsu Corporation will incorporate a 7-segment display. As an employee, you are tasked to create a program to display given numbers on the 7-segment display.\n\nThe display remains unchanged until a switching instruction is received. A 7-bit signal is used to switch the corresponding segment display information. Here, 1 represents \"switch\" and 0 represents \"as is.\"\n\nThe correspondence between each bit and segment is shown in the figure below. The signal consists of 7 bits sent in the order \"gfedcba.\" For example, to display \"0\" from a hidden state, \"0111111\" must be sent. To change from \"0\" to \"5,\" \"1010010\" is sent. Subsequently, to change \"5\" to \"1,\" \"1101011\" is sent.\n\nThe program should take as input the number of digits to be displayed, followed by the digits themselves (1 \u2264 n \u2264 100, 0 \u2264 di \u2264 9), and output the required signal sequence to display these numbers correctly on the 7-segment display.\n\nInput:\nMultiple datasets are given. The input ends with a single -1. Each dataset is in the format:\nn\nd1\nd2\n:\ndn\nThe number of datasets does not exceed 120.\n\nOutput:\nFor each input dataset, output the required signal sequence to display the numbers correctly.\n\nSample Input:\n3\n0\n5\n1\n1\n0\n-1\n\nOutput for the Sample Input:\n0111111\n1010010\n1101011\n0111111", "before_after_length": [247, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00231", "p_user": "u621997536", "n_user": "u621997536", "pos": "while True:\n N = int(input())\n if not N:\n break\n e = []\n for i in range(N):\n m, a, b = map(int, input().split())\n e.append((a, m))\n e.append((b, -m))\n\n M = 0\n ot = 0\n for t, m in sorted(e):\n if M > 150 and ot != t:\n print('NG')\n break\n M += m\n ot = t\n else:\n print('OK')", "neg": "while True:\n N = int(input())\n if not N:\n break\n e = []\n for i in range(N):\n m, a, b = map(int, input().split())\n e.append((a, m))\n e.append((b, -m))\n\n M = 0\n ot = -1\n for t, m in sorted(e):\n M += m\n if M >= 150 and ot != t:\n print('NG')\n break\n ot = t\n else:\n print('OK')", "jacc_sim": 0.9772727272727273, "nl": "Title: Dangerous Bridge\n\nIn Aizuwakamatsu City, located much further north from Aizukomatsumura, there is a bridge called \"Yabashi\" which serves as the only means of transportation to the surrounding villages. Despite heavy foot traffic, the bridge has deteriorated to the point of imminent collapse.\n\nYabashi can withstand a maximum weight of 150 [kg]. For instance, an 80 [kg] person and a 50 [kg] person can cross simultaneously, but if a 90 [kg] person starts crossing while an 80 [kg] person is already on the bridge, the bridge will break.\n\nIf the bridge collapses, the people of Aizukomatsumura will lose their means of transportation to the surrounding villages. As the village's sole programmer, you have decided to create a program to determine the bridge's structural integrity and the method of crossing to protect the villagers' livelihood.\n\nThe program should take as input the number of people crossing the bridge n> (1 \u2264 n> \u2264 100), the weight of each person crossing mi> (1 \u2264 mi> \u2264 100), the time they start crossing ai>, and the time they finish crossing bi> (0 \u2264 ai>, bi> < 2^31). It should output \"OK\" if the bridge remains intact and \"NG\" if it breaks. The total weight of people on the bridge exceeding 150 [kg] will cause the bridge to collapse. Additionally, at time ai>, people are on the bridge, but at time bi>, they are not.\n\nInput:\nMultiple datasets are provided as input, ending with a single line containing zero. Each dataset is in the following format:\nn>\nm1> a1> b1>\nm2> a2> b2>\n...\nmn> an> bn>\n\nThe number of datasets does not exceed 1200.\n\nOutput:\nFor each input dataset, output whether the bridge will break or not in a single line.\n\nSample Input:\n3\n80 0 30\n50 5 25\n90 27 50\n3\n80 0 30\n70 5 25\n71 30 50\n0\n\nOutput for the Sample Input:\nNG\nOK", "before_after_length": [133, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00231", "p_user": "u829501316", "n_user": "u829501316", "pos": "from operator import itemgetter\n\nwhile 1:\n n = int(input())\n if n == 0:\n break\n t_w = []\n for _ in range(n):\n m, a, b = map(int, input().split())\n t_w.append((a, m, 5))\n t_w.append((b, -m, 3))\n t_w.sort(key=itemgetter(0, 2))\n ans, cur = 'OK', 0\n for t, w, pri in t_w:\n cur += w\n # print('t', t, 'w', w, 'cur', cur)\n if cur > 150:\n ans = 'NG'\n break\n print(ans)\n\n", "neg": "\nfrom operator import itemgetter\n\nwhile 1:\n n = int(input())\n if n == 0:\n break\n t_w = []\n for _ in range(n):\n m, a, b = map(int, input().split())\n t_w.append((a, m, 5))\n t_w.append((b, -m, 3))\n t_w.sort(key=itemgetter(0, 2))\n ans, cur = 'OK', 0\n for t, w, pri in t_w:\n cur += w\n # print('t', t, 'w', w, 'cur', cur)\n if cur > 150:\n ans = 'NG'\n break\n print(ans)\n", "jacc_sim": 1.0, "nl": "Title: Dangerous Bridge\n\nIn Aizuwakamatsu City, located much further north from Aizukomatsumura, there is a bridge called \"Yabashi\" which serves as the only means of transportation to the surrounding villages. Despite heavy foot traffic, the bridge has deteriorated to the point of imminent collapse.\n\nYabashi can withstand a maximum weight of 150 [kg]. For instance, an 80 [kg] person and a 50 [kg] person can cross simultaneously, but if a 90 [kg] person starts crossing while an 80 [kg] person is already on the bridge, the bridge will break.\n\nIf the bridge collapses, the people of Aizukomatsumura will lose their means of transportation to the surrounding villages. As the village's sole programmer, you have decided to create a program to determine the bridge's structural integrity and the method of crossing to protect the villagers' livelihood.\n\nThe program should take as input the number of people crossing the bridge n> (1 \u2264 n> \u2264 100), the weight of each person crossing mi> (1 \u2264 mi> \u2264 100), the time they start crossing ai>, and the time they finish crossing bi> (0 \u2264 ai>, bi> < 2^31). It should output \"OK\" if the bridge remains intact and \"NG\" if it breaks. The total weight of people on the bridge exceeding 150 [kg] will cause the bridge to collapse. Additionally, at time ai>, people are on the bridge, but at time bi>, they are not.\n\nInput:\nMultiple datasets are provided as input, ending with a single line containing zero. Each dataset is in the following format:\nn>\nm1> a1> b1>\nm2> a2> b2>\n...\nmn> an> bn>\n\nThe number of datasets does not exceed 1200.\n\nOutput:\nFor each input dataset, output whether the bridge will break or not in a single line.\n\nSample Input:\n3\n80 0 30\n50 5 25\n90 27 50\n3\n80 0 30\n70 5 25\n71 30 50\n0\n\nOutput for the Sample Input:\nNG\nOK", "before_after_length": [177, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00232", "p_user": "u631023380", "n_user": "u631023380", "pos": "def solve(X, Y, Z, V, E, A):\n dp = [[0.0] * 6001 for _ in range(Y + 11)]\n dp[0][0] = 1.0\n for i in range(Y):\n for j in range(5001):\n if dp[i][j] <= 0.0:\n continue\n for k in V:\n t = i + k\n if t > Y:\n dp[Y][j] += dp[i][j]/X\n elif E[t] == 1:\n dp[min(Y, t+A[t])][j] += dp[i][j]/X\n else:\n dp[t][max(0, j+A[t])] += dp[i][j]/X\n\n s = 0\n for i in range(5001):\n s += i * dp[Y][i]\n print(int(s))\n\nif __name__ == \"__main__\":\n\n while True:\n X, Y, Z = map(int, input().split())\n if X | Y | Z == 0:\n break\n V = list(map(int, input().split()))\n E = [0] * 100\n A = [0] * 100\n for _ in range(Z):\n n, e, a = map(int, input().split())\n E[n] = e\n if e == 3:\n A[n] = -a\n else:\n A[n] = a\n solve(X, Y, Z, V, E, A)", "neg": "def solve(X, Y, Z, V, E, A):\n dp = [[0.0] * 6001 for _ in range(Y + max(V) + 1)]\n dp[0][0] = 1.0\n for i in range(Y):\n for j in range(5001):\n if dp[i][j] <= 0.0:\n continue\n for k in V:\n t = i + k\n if t > Y:\n dp[Y][j] += dp[i][j]/X\n elif E[t] == 1:\n dp[min(Y, t+A[t])][j] += dp[i][j]/X\n else:\n dp[t][max(0, j+A[t])] += dp[i][j]/X\n\n s = 0\n for i in range(5001):\n if dp[Y][i] <= 0.0:\n continue\n s += i * dp[Y][i]\n print(int(s))\n\nif __name__ == \"__main__\":\n import sys\n\n while True:\n X, Y, Z = map(int, input().split())\n if X | Y | Z == 0:\n sys.exit()\n V = map(int, input().split())\n E = [0] * 100\n A = [0] * 100\n for _ in range(Z):\n n, e, a = map(int, input().split())\n E[n] = e\n if e == 3:\n A[n] = -a\n else:\n A[n] = a\n solve(X, Y, Z, V, E, A)", "jacc_sim": 0.90625, "nl": "Title: Life Game\n\nTaro went to a toy store to buy a life game made by Aizu Hobby Company. The game involves using a board with marked squares and a roulette. The board has a start and a goal square, connected in a continuous sequence. Initially, a piece is placed on the start square, and its movement is determined by the number spun on the roulette. Some squares provide money or trigger events that change the piece's position. The winner is determined by the amount of money held when the piece reaches the goal.\n\nThe interesting aspect of this game is that the size of the roulette outcomes, the number of squares to the goal, and the arrangement of event squares vary for each package. These details are written on the package, allowing players to check them. Taro wants to choose the game that yields the most money on average. Your task is to help Taro select the game.\n\nThe roulette is divided into X equal parts, each with values V1, V2, ..., VX. The board has squares numbered from 0 to Y, connected in order. There are Z special squares called event squares, each denoted by Ni. These event squares have 3 types (Ei) with specific actions based on a value (Ai).\n\nThe initial money is 0 yen, starting from square 0, and the goal is to reach square Y. There are no events at the start and goal, and multiple events do not overlap on a single square. If the money becomes less than 0, it is considered as 0.\n\nThe expected money from a particular life game can be calculated. The input includes roulette and board information, and the program should output the expected money at the goal for each dataset.", "before_after_length": [378, 404], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00238", "p_user": "u737311644", "n_user": "u737311644", "pos": "while True:\n t=int(input())\n if t == 0:\n break\n n=int(input())\n b=0\n for i in range(n):\n s,f=map(int,input().split())\n a=f-s\n b+=a\n if t<=b:\n print(\"OK\")\n else:\n print(t-b)\n", "neg": "t=int(input())\nn=int(input())\nb=0\nfor i in range(n):\n s,f=map(int,input().split())\n a=f-s\n b+=a\nif t<=b:\n print(\"OK\")\nelse:\n print(t-b)\n", "jacc_sim": 0.90625, "nl": "DaiGo, a high school senior, loves games and struggles to manage study time during exam preparation. A program is needed to check if the total study time meets the daily goal, and if not, to calculate the shortfall based on study start and end times. The program should handle multiple datasets, each containing the daily study goal, the number of study sessions, and the start and end times for each session. The output should indicate \"OK\" if the goal is met, or the shortfall time if not.", "before_after_length": [97, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00242", "p_user": "u724548524", "n_user": "u724548524", "pos": "while 1:\n n = int(input())\n if n == 0:break\n c = {}\n for _ in range(n):\n s = input().split()\n for e in s:\n if e in c:c[e] += 1\n else:c[e] = 1\n c = [(e, c[e]) for e in c.keys()]\n c.sort(key = lambda x:x[0])\n c.sort(key = lambda x:x[1], reverse = True)\n s = input()\n a = []\n for i in range(len(c)):\n if c[i][0][0] == s:a.append(c[i][0])\n if a == []:print(\"NA\")\n else:print(*a[:5])\n", "neg": "while 1:\n n = int(input())\n if n == 0:break\n c = {}\n for _ in range(n):\n s = input().split()\n for e in s:\n if e in c:c[e] += 1\n else:c[e] = 1\n c = [(e, c[e]) for e in c.keys()]\n c.sort(key = lambda x:x[1], reverse = True)\n c.sort(key = lambda x:x[0])\n s = input()\n a = []\n for i in range(len(c)):\n if c[i][0][0] == s:a.append(c[i][0])\n if a == []:print(\"NA\")\n else:print(*a)\n", "jacc_sim": 0.9772727272727273, "nl": "Title: Input Candidates\n\nMobile phones are equipped with a feature that displays input candidates to efficiently input text such as emails. This feature records frequently used words and suggests words that start with the input characters as input candidates. For example, if the word \"computer\" is frequently input, simply entering \"c\" will prompt \"computer\" as a candidate. Let's create the basic part of this functionality.\n\nCreate a program that takes input as text or characters and outputs words starting with those characters in order of occurrence. If multiple words have the same occurrence, output them in lexicographical order. Output up to 5 words. If no matching words exist, output \"NA\".\n\nInput:\nMultiple datasets are provided. The end of input is represented by a single zero. Each dataset is given in the following format:\n- The first line contains the number of lines in the text, n (1 \u2264 n \u2264 10). The following n lines contain the text. The text consists of lowercase English characters and spaces, with each line containing 1 to 1024 characters. Words separated by spaces are 1 to 20 characters long.\n- The next line contains the initial character k in lowercase English.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each dataset, output words that start with the specified character or \"NA\".\n\nInput Example:\n1\nben likes bananas the best among many fruits because bananas are sweet and cheap\nb\n1\nwinners get to visit aizu and the university of aizu and make many friends as well\na\n3\nask alex about\nthe answer for the\nassignment on android apps\na\n2\nprogramming is both\na sport and an intellectual puzzle\nc\n0\n\nOutput Example:\nbananas because ben best\naizu and as\nabout alex android answer apps\nNA", "before_after_length": [194, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00251", "p_user": "u799016206", "n_user": "u775586391", "pos": "print(sum([int(input()) for i in range(10)]))\n", "neg": "print(sum([int(input()) for i in range(10)])", "jacc_sim": 1.0, "nl": "Title: Scoring After Solving 10 Questions\n\nPlayers, welcome to the Computer Koshien. The number of questions and total points vary each year. Each question has a designated score based on its difficulty. Given the scores for 10 questions, create a program to output their total.\n\nInput:\nThe input consists of 10 lines, where each line contains an integer s_i (0 \u2264 s_i \u2264 100) representing the score for question i.\n\nOutput:\nOutput the total score on a single line.\n\nExample 1:\nInput\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\nOutput\n55\n\nExample 2:\nInput\n4\n4\n8\n8\n8\n10\n10\n12\n16\n20\nOutput\n100", "before_after_length": [17, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00252", "p_user": "u577978368", "n_user": "u498511622", "pos": "a,b,c=map(int,input().split())\nif a+b==2 or c==1:\n print(\"Open\")\nelse:\n print(\"Close\")\n\n\n", "neg": "a,b,c=map(int,input().split())\nif a+b+c==1:\n print(\"Close\")\nelif a+b+c==2:\n print(\"Open\")\nelse:\n print(\"Close\")", "jacc_sim": 0.9166666666666666, "nl": "Title: Ticketing\n\nTo ride the Shinkansen, two tickets are required: a \"boarding ticket\" and an \"express ticket.\" As there are routes where the Shinkansen is not used, these tickets are separate. However, for routes exclusively using the Shinkansen, a single \"boarding and express ticket\" may be issued.\n\nAt the automatic ticket gate, the correct ticket must be inserted to open the gate. A program is needed to determine if one \"boarding ticket,\" one \"express ticket,\" both, or a \"boarding and express ticket\" has been inserted, and to decide whether to open or close the gate.\n\nInput:\nThe input consists of a single line containing three integers separated by a single space: b1, b2, and b3. b1 represents the state of the \"boarding ticket\" insertion, b2 represents the state of the \"express ticket\" insertion, and b3 represents the state of the \"boarding and express ticket\" insertion. The insertion state is represented by 0 or 1, where 0 indicates not inserted and 1 indicates inserted. The expected combinations of insertion states are as follows:\n\nInput\tState of Insertion\tDoor Operation\n1 0 0\t\"Boarding ticket\" only inserted\tClose\n0 1 0\t\"Express ticket\" only inserted\tClose\n1 1 0\t\"Boarding ticket\" and \"Express ticket\" inserted\tOpen\n0 0 1\t\"Boarding and express ticket\" inserted\tOpen\n0 0 0\tNo insertion\tClose\n\nOutput:\nOutput \"Open\" or \"Close\" on a single line to represent the operation of the automatic ticket gate.\n\nExample Input 1:\n0 0 1\n\nExample Output 1:\nOpen\n\nExample Input 2:\n0 1 0\n\nExample Output 2:\nClose", "before_after_length": [44, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00254", "p_user": "u221679506", "n_user": "u221679506", "pos": "from functools import reduce\nwhile True:\n\tn = input()\n\tif n == \"0000\":\n\t\tbreak\n\tn = n if len(n) >= 4 else n.zfill(4)\n\tif reduce(lambda x,y:x and y,[n[0] == i for i in n]):\n\t\tprint(\"NA\")\n\telse:\n\t\tcnt = 0\n\t\twhile n != \"6174\":\n\t\t\ts = ''.join(sorted(n))\n\t\t\tl = ''.join(sorted(n,reverse = True))\n\t\t\tn = str(int(l)-int(s))\n\t\t\tn = n if len(n) >= 4 else n.zfill(4)\n\t\t\tcnt += 1\n\t\tprint(cnt)", "neg": "from functools import reduce\nwhile True:\n\tn = input()\n\tif n == \"0000\":\n\t\tbreak\n\tn = n if len(n) >= 4 else n.zfill(4)\n\tif reduce(lambda x,y:x and y,[n[0] == i for i in n]):\n\t\tprint(\"NA\")\n\telse:\n\t\tcnt = 0\n\t\twhile n != \"6174\":\n\t\t\ts = ''.join(sorted(n))\n\t\t\tl = ''.join(sorted(n,reverse = True))\n\t\t\tn = str(int(l)-int(s))\n\t\t\tn = n if len(n) >= 4 else n.zfill(4)\n\t\t\tprint(n)\n\t\t\tcnt += 1\n\t\tprint(cnt)", "jacc_sim": 1.0, "nl": "Title: All Numbers Lead to 6174\n\nGiven a four-digit number N composed of digits from 0 to 9, perform the following operations:\n1. Arrange the digits of N in descending order to obtain L.\n2. Arrange the digits of N in ascending order to obtain S.\n3. Set the new N as the absolute difference between L and S.\n4. Repeat steps 1-3 with the new N.\n\nEvery four-digit number, except those with identical digits (e.g., 0000, 1111), is known to eventually reach 6174. For example, with N = 2012:\n1st iteration (N = 2012): L = 2210, S = 0122, L-S = 2088\n2nd iteration (N = 2088): L = 8820, S = 0288, L-S = 8532\n3rd iteration (N = 8532): L = 8532, S = 2358, L-S = 6174\nThus, it takes 3 iterations to reach 6174.\n\nCreate a program to calculate the number of iterations required to reach 6174 for a given four-digit number composed of digits from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. The end of input is indicated by a single line containing 0000. Each dataset is provided in the following format:\nN\n\nEach dataset is a single line, where N (1 \u2264 N \u2264 9999) represents a four-digit number. If N < 1000, the leading digits are padded with 0.\n\nThe number of datasets does not exceed 10000.\n\nOutput:\nFor each dataset, output the number of iterations required to reach 6174 in a single line. If the input number consists of identical digits, output NA.\n\nInput Example:\n6174\n2012\n3333\n0000\n\nOutput Example:\n0\n3\nNA", "before_after_length": [179, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00256", "p_user": "u849555829", "n_user": "u849555829", "pos": "from datetime import date, timedelta\n\nst = date(2012, 12, 21)\nwhile True:\n s = input()\n if s == '#':\n break\n d = list(map(int, s.split('.')))\n if len(d) == 3:\n r = 0\n while d[0] > 3000:\n d[0] -= 400\n r += 365*400+97\n\n ed = date(d[0], d[1], d[2])\n r += (ed-st).days\n ki = r%20\n r//=20\n w = r%18\n r//=18\n t = r%20\n r//=20\n ka = r%20\n r//=20\n b = r%13\n print(str(b)+'.'+str(ka)+'.'+str(t)+'.'+str(w)+'.'+str(ki))\n else:\n r = d[0]\n r *= 20\n r += d[1]\n r *= 20\n r += d[2]\n r *= 18\n r += d[3]\n r *= 20\n r += d[4]\n ed = st+timedelta(days=r)\n print(str(ed.year)+'.'+str(ed.month)+'.'+str(ed.day))", "neg": "from datetime import date, timedelta\n\nst = date(2012, 12, 21)\nwhile True:\n s = input()\n if s == '#':\n break\n d = list(map(int, s.split('.')))\n if len(d) == 3:\n r = 0\n while d[0] > 3000:\n d[0] -= 400\n r += 365*400+97\n\n ed = date(d[0], d[1], d[2])\n r += (ed-st).days\n ki = r%20\n r//=20\n w = r%18\n r//=18\n t = r%20\n r//=20\n ka = r%20\n r//=20\n b = r%13\n print(str(b)+'.'+str(ka)+'.'+str(t)+'.'+str(w)+'.'+str(ki))\n else:\n r = d[0]\n r *= 20\n r += d[1]\n r *= 20\n r += d[2]\n r *= 18\n r += d[3]\n r *= 20\n r += d[4]\n print((st+timedelta(days=r)).strftime(\"%Y.%m.%d\"))", "jacc_sim": 0.9090909090909091, "nl": "Title: The Mayan Great Prophecy\n\nMaya's Long Count Calendar consists of 13 Baktun (1,872,000 days) and is believed to have started on August 11, 3114 BC and end on December 21, 2012. The program aims to convert dates between the Gregorian calendar and the Maya Long Count calendar. The input consists of multiple datasets, each in the format b.ka.t.w.ki or y.m.d, representing the Maya Long Count date or the Gregorian date, respectively. The output should be in the same format as the input. The maximum values for the Gregorian date depend on the type of month and leap years. The range for the Maya Long Count date is from 0.0.0.0.0 to 12.19.19.17.19, and for the Gregorian date is from 2012.12.21 to 10,000,000.12.31. The number of datasets does not exceed 500. If the input Gregorian date results in the next cycle of the Maya Long Count, it should be output in the b.ka.t.w.ki format.", "before_after_length": [325, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00271", "p_user": "u162292165", "n_user": "u498511622", "pos": "i=0\nfor i in range(7):\n a,b=map(int,input().split())\n print(a-b)\n", "neg": "for i in range(0,7):\n a,b=map(int,input(),split())\n print(a-b)", "jacc_sim": 0.95, "nl": "Title: Temperature Difference\n\nAthletes, welcome to the Computer Koshien. It's important to manage your health to participate in the event. During the season when the temperature fluctuates greatly, it is said that the body is burdened and susceptible to catching a cold. The most important days to be careful are those with the greatest difference between the highest and lowest temperatures. When given the highest and lowest temperatures for 7 days, create a program to output the difference between the highest and lowest temperatures for each day.\n\nInput:\nThe input data is given in the following format:\na1 b1\na2 b2\n:\na7 b7\n\nThe input consists of 7 lines, where the i-th line provides integers representing the highest temperature ai (-40 \u2264 ai \u2264 40) and the lowest temperature bi (-40 \u2264 bi \u2264 40) for the i-th day. For all days, the highest temperature ai is always greater than or equal to the lowest temperature bi.\n\nOutput:\nOutput the temperature differences for 7 days on 7 separate lines.\n\nInput Example:\n30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n\nOutput Example:\n11\n19\n1\n5\n1\n13\n20", "before_after_length": [34, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00271", "p_user": "u003684951", "n_user": "u498511622", "pos": "for i in range(7):\n a, b = map(int, input().split())\n print(a-b)\n", "neg": "for i in range(7):\n a,b=map(int,input(),split())\n print(a-b)", "jacc_sim": 0.9473684210526315, "nl": "Title: Temperature Difference\n\nAthletes, welcome to the Computer Koshien. It's important to manage your health to participate in the event. During the season when the temperature fluctuates greatly, it is said that the body is burdened and susceptible to catching a cold. The most important days to be careful are those with the greatest difference between the highest and lowest temperatures. When given the highest and lowest temperatures for 7 days, create a program to output the difference between the highest and lowest temperatures for each day.\n\nInput:\nThe input data is given in the following format:\na1 b1\na2 b2\n:\na7 b7\n\nThe input consists of 7 lines, where the i-th line provides integers representing the highest temperature ai (-40 \u2264 ai \u2264 40) and the lowest temperature bi (-40 \u2264 bi \u2264 40) for the i-th day. For all days, the highest temperature ai is always greater than or equal to the lowest temperature bi.\n\nOutput:\nOutput the temperature differences for 7 days on 7 separate lines.\n\nInput Example:\n30 19\n39 20\n19 18\n25 20\n22 21\n23 10\n10 -10\n\nOutput Example:\n11\n19\n1\n5\n1\n13\n20", "before_after_length": [30, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00275", "p_user": "u766477342", "n_user": "u766477342", "pos": "while 1:\n ba = 0\n\n p = [0 for i in range(int(input()))]\n if len(p) == 0:break\n\n for i,v in enumerate(list(input())):\n p[i%len(p)] += 1\n if v == 'L':\n p[i%len(p)] += ba\n ba = 0\n elif v== 'S':\n ba += p[i%len(p)] \n p[i%len(p)] = 0\n\n result = ''\n for v in sorted(p):\n result += '%d ' % v\n result += str(ba)\n print(result)", "neg": "while 1:\n ba = 0\n\n p = [0 for i in range(int(input()))]\n if len(p) == 0:break\n\n for i,v in enumerate(list(input())):\n p[i%len(p)] += 1\n if v == 'L':\n p[i%len(p)] += ba\n ba = 0\n elif v== 'S':\n ba += p[i%len(p)] \n p[i%len(p)] = 0\n\n result = ''\n for v in p:\n result += '%d ' % v\n result += str(ba)\n print(result)", "jacc_sim": 0.9714285714285714, "nl": "Title: The Conclusion of \"Bouzu Mekuri\"\n\nIn the game using the cards from the Hyakunin Isshu, there is a game called \"Bouzu Mekuri\" which uses picture cards and is widely enjoyed due to its simplicity. While there are various derivative types, the Bouzu Mekuri we consider here involves N participants and follows the rules below:\n\n- 64 \"men\", 15 \"bouzu\", and 21 \"hime\" cards, totaling 100 cards, are used.\n- The cards are shuffled with their backs facing up to create a \"card mountain\" so that the pictures are not visible.\n- Participants draw one card at a time from the card mountain in order, starting from the first person. After the Nth person, the cycle repeats from the first person.\n - If the drawn card is a \"man\", the person who drew it keeps the card.\n - If the drawn card is a \"bouzu\", the person who drew it, along with all the cards they have, places them in the \"field\".\n - If the drawn card is a \"hime\", the person who drew it, along with all the cards in the field, collects them.\n- The game ends when there are no more cards in the card mountain, and the person with the most cards wins.\n\nGiven the number of participants and the order of cards in the card mountain, create a program that outputs the number of cards held by each participant in ascending order at the end of the game, as well as the number of cards remaining in the field.\n\nInput:\nThe input consists of multiple datasets. The end of the input is indicated by a single line containing zero. Each dataset is given in the following format:\n- N (an integer representing the number of participants, where 2 \u2264 N \u2264 10) on the first line.\n- A string representing the order of cards in the card mountain on the second line. Each character c_i represents the i-th drawn card, where M represents \"man\", S represents \"bouzu\", and L represents \"hime\". There are no spaces between the characters.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each dataset, output the sequence of card numbers at the end of the game on one line. The sequence of card numbers should be followed by the number of cards remaining in the field. Separate each card number with a single space. Do not output a space at the end of the line.\n\nSample Input:\n2\nSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n2\nSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL\n5\nMMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSMLMSMMMMMMMSMMMMMMLMMMMMSMMMLMMLMMMMMMMMMSSM\n0\n\nSample Output:\n42 58 0\n0 100 0\n0 0 3 10 59 28", "before_after_length": [161, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00275", "p_user": "u724548524", "n_user": "u724548524", "pos": "while 1:\n n = int(input())\n if n == 0:break\n p = [0] * n\n s = 0\n f = input()\n for i in range(100):\n if f[i] == \"M\":p[i % n] += 1\n elif f[i] == \"S\":\n s += p[i % n] + 1\n p[i % n] = 0\n else:\n p[i % n] += s + 1\n s = 0\n p.sort()\n p += [s]\n print(*p)\n", "neg": "while 1:\n n = int(input())\n if n == 0:break\n p = [0] * n\n s = 0\n f = input()\n for i in range(100):\n if f[i] == \"M\":p[i % n] += 1\n elif f[i] == \"S\":\n s += p[i % n] + 1\n p[i % n] = 0\n else:\n p[i % n] += s + 1\n s = 0\n p += [s]\n print(*p)\n", "jacc_sim": 0.9393939393939394, "nl": "Title: The Conclusion of \"Bouzu Mekuri\"\n\nIn the game using the cards from the Hyakunin Isshu, there is a game called \"Bouzu Mekuri\" which uses picture cards and is widely enjoyed due to its simplicity. While there are various derivative types, the Bouzu Mekuri we consider here involves N participants and follows the rules below:\n\n- 64 \"men\", 15 \"bouzu\", and 21 \"hime\" cards, totaling 100 cards, are used.\n- The cards are shuffled with their backs facing up to create a \"card mountain\" so that the pictures are not visible.\n- Participants draw one card at a time from the card mountain in order, starting from the first person. After the Nth person, the cycle repeats from the first person.\n - If the drawn card is a \"man\", the person who drew it keeps the card.\n - If the drawn card is a \"bouzu\", the person who drew it, along with all the cards they have, places them in the \"field\".\n - If the drawn card is a \"hime\", the person who drew it, along with all the cards in the field, collects them.\n- The game ends when there are no more cards in the card mountain, and the person with the most cards wins.\n\nGiven the number of participants and the order of cards in the card mountain, create a program that outputs the number of cards held by each participant in ascending order at the end of the game, as well as the number of cards remaining in the field.\n\nInput:\nThe input consists of multiple datasets. The end of the input is indicated by a single line containing zero. Each dataset is given in the following format:\n- N (an integer representing the number of participants, where 2 \u2264 N \u2264 10) on the first line.\n- A string representing the order of cards in the card mountain on the second line. Each character c_i represents the i-th drawn card, where M represents \"man\", S represents \"bouzu\", and L represents \"hime\". There are no spaces between the characters.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each dataset, output the sequence of card numbers at the end of the game on one line. The sequence of card numbers should be followed by the number of cards remaining in the field. Separate each card number with a single space. Do not output a space at the end of the line.\n\nSample Input:\n2\nSSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM\n2\nSSSSSSSSSSSSSSLLLLLLLLLLLLLLLLLLLLMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMSL\n5\nMMMMMMSLSLLMMMSMMSLMMMLMMMMLSLLLLMLSMMLMMLLMSSSLMMMMLMLSMLMSMMMMMMMSMMMMMMLMMMMMSMMMLMMLMMMMMMMMMSSM\n0\n\nSample Output:\n42 58 0\n0 100 0\n0 0 3 10 59 28", "before_after_length": [141, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00276", "p_user": "u766477342", "n_user": "u766477342", "pos": "for i in range(int(input())):\n res = 0\n c,a,n = list(map(int,input().split()))\n res = min(n,a,c)\n c -= res\n a -= res\n if c >= 2 and a >= 1:\n cca = min(c//2,a)\n c -= cca*2\n res += cca\n\n if c >=3:\n res += c//3\n\n print(res)", "neg": "for i in range(int(input())):\n res = 0\n c,a,n = list(map(int,input().split()))\n res = min(n,a,c)\n c -= res\n a -= res\n if c >= 2 and a >= 1:\n cca += min(c//2,a)\n c -= cca*2\n\n if c >=3:\n res += c//3\n\n print(res)", "jacc_sim": 1.0, "nl": "Title: Team Formation\n\nAt Akabe High School, a programmer training school, the roles of competitive programmers are divided into three types: \n\n- C: Coder - Proficient in a programming language and writes code.\n- A: Algorithmist - Skilled in logical thinking and devises algorithms.\n- N: Navigator - Strong in reading comprehension and performs problem analysis and debugging.\n\nTeams of three are formed in one of the following formations:\n\n- CCCA: Balanced and stable\n- CCCC: High-risk, high-speed offensive type\n- CCAN: Cautious type, solving problems accurately\n\nAs the coach of the competitive programming club, your task is to form as many teams as possible by combining these members. Given the number of Coders, Algorithmists, and Navigators as input, create a program to output the maximum number of teams that can be formed.\n\nInput:\nA single dataset is provided in the following format:\nQ\nc1 a1 n1\nc2 a2 n2\n...\ncQ aQ nQ\n\nThe first line contains Q (0 \u2264 Q \u2264 100), the number of years for which the team count is to be determined. The following Q lines provide the number of members for each role in each year. Each line includes the number of Coders ci (0 \u2264 ci \u2264 1000), Algorithmists ai (0 \u2264 ai \u2264 1000), and Navigators ni (0 \u2264 ni \u2264 1000).\n\nOutput:\nFor each year, output the maximum number of teams that can be created in a single line.\n\nInput Example:\n4\n3 0 0\n1 1 1\n9 4 1\n0 1 2\n\nOutput Example:\n1\n1\n4\n0", "before_after_length": [117, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00276", "p_user": "u221679506", "n_user": "u221679506", "pos": "for i in range(int(input())):\n\tc,a,n = map(int,input().split())\n\tcnt1 = min(c,a,n)\n\tc -= cnt1\n\ta -= cnt1\n\tcnt2 = min(c//2,a)\n\tc -= cnt2*2\n\tcnt3 = c//3\n\tprint(cnt1+cnt2+cnt3)\n\n#for i in range(int(input())):\n#\tc,a,n = map(int,input().split())\n#\tcnt = 0\n#\twhile True:\n#\t\tif c<1 or a<1 or n<1:\n#\t\t\tbreak\n#\t\tc -= 1\n#\t\ta -= 1\n#\t\tn -= 1\n#\t\tcnt += 1\n#\twhile True:\n#\t\tif c<2 or a<1:\n#\t\t\tbreak\n#\t\tc -= 2\n#\t\ta -= 1\n#\t\tcnt += 1\n#\twhile True:\n#\t\tif c<3:\n#\t\t\tbreak\n#\t\tc -= 3\n#\t\tcnt += 1\n#\tprint(cnt)", "neg": "for i in range(int(input())):\n\tc,a,n = map(int,input().split())\n cnt1 = min(c,a,n)\n c -= cnt1\n a -= cnt1\n cnt2 = min(c//2,a)\n c -= cnt2*2\n cnt3 = c//3\n print(cnt1+cnt2+cnt3)\n \n#for i in range(int(input())):\n#\tc,a,n = map(int,input().split())\n#\tcnt = 0\n#\twhile True:\n#\t\tif c<1 or a<1 or n<1:\n#\t\t\tbreak\n#\t\tc -= 1\n#\t\ta -= 1\n#\t\tn -= 1\n#\t\tcnt += 1\n#\twhile True:\n#\t\tif c<2 or a<1:\n#\t\t\tbreak\n#\t\tc -= 2\n#\t\ta -= 1\n#\t\tcnt += 1\n#\twhile True:\n#\t\tif c<3:\n#\t\t\tbreak\n#\t\tc -= 3\n#\t\tcnt += 1\n#\tprint(cnt)", "jacc_sim": 1.0, "nl": "Title: Team Formation\n\nAt Akabe High School, a programmer training school, the roles of competitive programmers are divided into three types: \n\n- C: Coder - Proficient in a programming language and writes code.\n- A: Algorithmist - Skilled in logical thinking and devises algorithms.\n- N: Navigator - Strong in reading comprehension and performs problem analysis and debugging.\n\nTeams of three are formed in one of the following formations:\n\n- CCCA: Balanced and stable\n- CCCC: High-risk, high-speed offensive type\n- CCAN: Cautious type, solving problems accurately\n\nAs the coach of the competitive programming club, your task is to form as many teams as possible by combining these members. Given the number of Coders, Algorithmists, and Navigators as input, create a program to output the maximum number of teams that can be formed.\n\nInput:\nA single dataset is provided in the following format:\nQ\nc1 a1 n1\nc2 a2 n2\n...\ncQ aQ nQ\n\nThe first line contains Q (0 \u2264 Q \u2264 100), the number of years for which the team count is to be determined. The following Q lines provide the number of members for each role in each year. Each line includes the number of Coders ci (0 \u2264 ci \u2264 1000), Algorithmists ai (0 \u2264 ai \u2264 1000), and Navigators ni (0 \u2264 ni \u2264 1000).\n\nOutput:\nFor each year, output the maximum number of teams that can be created in a single line.\n\nInput Example:\n4\n3 0 0\n1 1 1\n9 4 1\n0 1 2\n\nOutput Example:\n1\n1\n4\n0", "before_after_length": [273, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00298", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\nn = int(f.readline())\ns = [list(map(int, line.split())) for line in f]\n\np = [[i==j for j in range(n + 1)] for i in range(n + 1)]\nc = [0] + [c for c,w in s]\nsum_w = [0] + [w for c,w in s]\nfor i in range(1, len(sum_w)):\n sum_w[i] += sum_w[i - 1]\n \nfor length in range(n):\n for i in range(1, n + 1 - length):\n j = i + length\n if not p[i][j]:\n continue\n if j + 1 <= n:\n if sum_w[j] - sum_w[i - 1] <= c[j + 1]:\n p[i][j + 1] = True\n if sum_w[j] - sum_w[i - 1] <= c[i - 1]:\n p[i - 1][j] = True\n\ndp = [999999999] * (n + 1)\ndp[0] = 0\nfor b in range(1,n + 1):\n for e in range(1,n + 1):\n if p[b][e]:\n dp[e] = min(dp[e], dp[b - 1] + 1)\n\nprint(dp[-1])", "neg": "import sys\nf = sys.stdin\n\nn = int(f.readline())\ns = [list(map(int, line.split())) for line in f]\n\np = [[i==j for j in range(n + 1)] for i in range(n + 1)]\nc = [0] + [c for c,w in s]\nsum_w = [0] + [w for c,w in s]\nfor i in range(1, len(sum_w)):\n sum_w[i] += sum_w[i - 1]\n \nfor length in range(n):\n for i in range(1, n + 1 - length):\n j = i + length\n if not p[i][j]:\n continue\n if j + 1 <= n:\n if sum_w[j] - sum_w[i - 1] <= c[j + 1]:\n p[i][j + 1] = True\n if sum_w[j] - sum_w[i - 1] <= c[i - 1]:\n p[i - 1][j] = True\nfor pi in p:\n print(pi)\ndp = [999999999] * (n + 1)\ndp[0] = 0\nfor b in range(1,n + 1):\n for e in range(1,n + 1):\n if p[b][e]:\n dp[e] = min(dp[e], dp[b - 1] + 1)\n\nprint(dp[-1])", "jacc_sim": 0.9791666666666666, "nl": "The Mighty Men\n\nThere was a school called Mighty Men Academy where strong people gathered. During the school's sports festival, the strong people formed a line and marched. While they always wanted to show off their strength, most of them didn't want to walk by themselves. So, some of them decided to carry others on their shoulders to reduce the number of people actually walking.\n\nInitially, N strong people were lined up horizontally on the ground, each numbered from 1 to N. The ith strong person can carry a weight of up to ci and has a weight of wi.\n\nA strong person can lift the person next to them only if the following conditions are met:\n- There are no strong people above or below them.\n- The weight of the person next to them is at most the maximum weight they can carry. If the person next to them is already carrying someone, the total weight of the stacked people must be within the maximum weight the lifter can carry.\n\nFor example, consider a line of 3 strong people. If the second person can carry a weight greater than or equal to w3, the second person can lift the third person. Then, if the first person can carry a weight greater than or equal to w2 + w3, the first person can lift the second person.\n\nThe task is to find the minimum number of people who will walk at the bottom.\n\nInput:\nThe input consists of:\nN\nc1 w1\nc2 w2\n...\ncN wN\n\nOutput:\nOutput the minimum number of people in a single line.\n\nExample:\nInput\n3\n150 120\n100 50\n80 100\n\nOutput\n1", "before_after_length": [344, 355], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00310", "p_user": "u737311644", "n_user": "u737311644", "pos": "while True:\n try:\n a,b,c=map(int,input().split())\n print(a+b+c)\n except:break\n", "neg": "while True:\n try:\n a,b,c=map(int,input().split)\n print(a+b+c)\n except:break\n", "jacc_sim": 1.0, "nl": "Welcome participants to the Computer Koshien. The competition consists of three categories: programming, mobile, and a single art/CG category. Given the number of participants in each category, create a program to calculate the total number of participants. Input consists of three integers representing the number of participants in each category. Output the total number of participants. For example, given 10 participants in programming, 10 in mobile, and 20 in art/CG, the total is 40.", "before_after_length": [39, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00310", "p_user": "u546285759", "n_user": "u546285759", "pos": "print(sum(map(int, input().split())))\n\n", "neg": "print(sum(map(int, input().split()))", "jacc_sim": 1.0, "nl": "Welcome participants to the Computer Koshien. The competition consists of three categories: programming, mobile, and a single art/CG category. Given the number of participants in each category, create a program to calculate the total number of participants. Input consists of three integers representing the number of participants in each category. Output the total number of participants. For example, given 10 participants in programming, 10 in mobile, and 20 in art/CG, the total is 40.", "before_after_length": [15, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00311", "p_user": "u546285759", "n_user": "u546285759", "pos": "h1, h2 = map(int, input().split())\nk1, k2 = map(int, input().split())\na, b, c, d = map(int, input().split())\nhiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)\nkenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)\nprint(\"even\" if hiroshi == kenjiro else [\"hiroshi\", \"kenjiro\"][hiroshi < kenjiro])", "neg": "h1, h2 = map(int, input().split())\nk1, k2 = map(int, input().split())\na, b, c, d = map(int, input().split())\nhiroshi = (a * h1) + (b * h2) + (divmod(h1, 10)[0] * c) + (divmod(h2, 20)[0] * d)\nkenjiro = (a * k1) + (b * k2) + (divmod(k1, 10)[0] * c) + (divmod(k2, 20)[0] * d)\nprint(\"even\" if hiroshi else [\"hiroshi\", \"kenjiro\"][hiroshi < kenjiro])", "jacc_sim": 1.0, "nl": "Title: Fishing Competition\n\nHiro and Kenjiro, two brothers, have come to Lake Inawashiro for a fishing competition. They have decided to determine points as follows and compete based on the total points of the fish they catch:\n\n- One Char (Iwana) is worth a points\n- One Trout (Yamame) is worth b points\n- For every 10 Char caught, c points are added\n- For every 20 Trout caught, d points are added\n\nCreate a program to determine who wins or if it's a tie based on the number of fish caught by Hiro and Kenjiro.\n\nInput:\nThe input is given in the following format:\nh1 h2\nk1 k2\na b c d\n\nOutput:\nIf Hiro wins, output \"hiroshi\", if Kenjiro wins, output \"kenjiro\", if it's a tie, output \"even\" in a single line.\n\nSample Input 1:\n5 1\n3 1\n1 2 5 5\n\nSample Output 1:\nhiroshi\n\nSample Input 2:\n5 1\n4 2\n1 2 5 5\n\nSample Output 2:\nkenjiro\n\nSample Input 3:\n0 20\n10 0\n1 1 10 0\n\nSample Output 3:\neven", "before_after_length": [181, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u477023447", "n_user": "u477023447", "pos": "while 1:\n try:\n sum = input()\n sum_list = sum.split()\n print(len(str(int(sum_list[0]) + int(sum_list[1]))))\n except EOFError:\n break\n \n", "neg": "while 1:\n sum = input()\n sum_list = sum.split(\" \")\n print(len(str(int(sum_list[0]) + int(sum_list[1]))))\n except EOFError:\n break\n", "jacc_sim": 0.9166666666666666, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [61, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u308369184", "n_user": "u308369184", "pos": "while True:\n try:\n s=input().split(\" \")\n num=int(s[0])+int(s[1])\n print(len(str(num)))\n except:\n break\n ", "neg": "while True:\n try:\n s=input().split(\" \")\n num=int(s[0])+int(s[1])\n print(len(str(num)))\n escept:\n break\n ", "jacc_sim": 0.92, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [52, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u915343634", "n_user": "u915343634", "pos": "try:\n s = []\n while True:\n t = input()\n s.append(t)\nexcept EOFError:\n for i in range(len(s)):\n a = int(s[i].split(' ')[0])\n b = int(s[i].split(' ')[1])\n print(len(str(a + b)))", "neg": "try:\n s = []\n while True:\n t = raw_input()\n s.append(t)\nexcept EOFError:\n for i in range(len(s)):\n a = int(s[i].split(' ')[0])\n b = int(s[i].split(' ')[1])\n print(len(str(a + b)))", "jacc_sim": 0.9375, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [87, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u412890344", "n_user": "u412890344", "pos": "# -*-coding:utf-8-*-\n\ndef get_input():\n \n while True:\n try:\n yield \"\".join(input())\n except EOFError:\n break\n \nif __name__==\"__main__\":\n array = list(get_input())\n for i in range(len(array)):\n \n temp = array[i].split()\n \n a = int(temp[0])\n b = int(temp[1])\n \n ans = a + b\n \n print(len(str(ans)))", "neg": "# -*-coding:utf-8-*-\n\ndef get_input():\n \n while True:\n try:\n yield \"\".join(input())\n except EOFError:\n break\n \nif __name__==\"__main__\":\n array = list(get_input())\n for i in range(len(array)):\n \n temp = array[i].split()\n \n a = int(temp[0])\n b = int(temp[1])\n\n \n \n ans = a + b\n \n print(ans)", "jacc_sim": 0.9782608695652174, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [137, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u500396695", "n_user": "u500396695", "pos": "import sys\nL = sys.stdin.readlines()\nfor line in L:\n\tN = line[:-1].split()\n\tsums = int(N[0]) + int(N[1])\n\tprint(len(str(sums)))", "neg": "import sys\nL = sys.stdin.readlines()\nfor line in L:\n\tN = line.split()\n\tsums = int(N[0]) + int(N[1])\n\tprint(len(str(sums))+1)", "jacc_sim": 0.9615384615384616, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [58, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u500396695", "n_user": "u500396695", "pos": "import sys\nL = sys.stdin.readlines()\nfor line in L: ##line?????????????????????\n\tN = line.split() ##N??????????????\u00a8????????????\n\tsums = int(N[0]) + int(N[1])\n\tprint(len(str(sums)))", "neg": "import sys\nL = sys.stdin.readlines()\nfor line in L: ##line?????????????????????\n\tN = line.split() ##N??????????????\u00a8????????????\n\tsums = int(N[0]) + int(N[1])\n\tprint(len(str(sums))+1)", "jacc_sim": 1.0, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [87, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u731896389", "n_user": "u114472050", "pos": "import sys\nfor line in sys.stdin:\n a,b = line.split(\" \")\n print(len(str(int(a)+int(b))))", "neg": "import sys\n\nfor line in sys.stdin:\n a, b = line.split()\n print(len(str(a + b)))", "jacc_sim": 0.9047619047619048, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [38, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u318658123", "n_user": "u318658123", "pos": "import sys\n\nif __name__ == '__main__':\n\n nums = []\n\n for line in sys.stdin:\n if line == \"\\n\":\n break\n else :\n nums.append([int(item) for item in line.split(\" \")])\n\n for n in nums:\n sum = n[0] + n[1]\n print(len(str(sum)))\n ", "neg": "if __name__ == '__main__':\n\n nums = []\n\n for line in sys.stdin:\n if line == \"\\n\":\n break\n else :\n nums.append([int(item) for item in line.split(\" \")])\n\n for n in nums:\n sum = n[0] + n[1]\n print(len(str(sum)))\n ", "jacc_sim": 0.9696969696969697, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [96, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u362104929", "n_user": "u362104929", "pos": "def main():\n def inputs():\n li = []\n count = 0\n try:\n while count < 200:\n li.append(input())\n count += 1\n except EOFError:\n return li\n return li\n\n li = inputs()\n for x in li:\n a = x.split(\" \")\n result = len(str(int(a[0]) + int(a[1])))\n print(result)\n return None\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n def inputs():\n li = []\n count = 0\n try:\n while count < 200:\n li.append(input())\n count += 1\n except EOFError:\n return li\n return li\n\n li = inputs()\n for x in li:\n a = x.split(\" \")\n print(int(a[0]) + int(a[1]))\n return None\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9230769230769231, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [126, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u905313459", "n_user": "u905313459", "pos": "import fileinput\n\nif __name__ == \"__main__\":\n for line in fileinput.input():\n v = line.split(\" \")\n print(len(str(sum([int(i) for i in v]))))", "neg": "import fileinput\n\nif __name__ == \"__main__\":\n for line in fileinput.input():\n v = line.split(\" \")\n print(sum([int(i) for i in v]))", "jacc_sim": 0.92, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [53, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u144068724", "n_user": "u144068724", "pos": "# coding: utf-8\n# Here your code !\n\nwhile 1:\n try:\n a,b = map(int,input().split())\n su = a+b\n print(len(str(su)))\n except:\n break", "neg": "# coding: utf-8\n# Here your code !\n\nwhile 1:\n try:\n a,b = map(int,input().split())\n print(a+b)\n except:\n break", "jacc_sim": 0.9032258064516129, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [59, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u748033250", "n_user": "u990459103", "pos": "while (1):\n\ttry:\n\t\ta, b = map(int, input().split())\n\texcept:\n\t\tbreak\n\tc = a+b\n\tprint( len(str(c)) )\n\t", "neg": "while 1:\n try:\n a,b = int(input().split())\n c = a + b\n print(len(str(c)))\n except EOFError:\n break\n", "jacc_sim": 0.9130434782608695, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [51, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u551456712", "n_user": "u551456712", "pos": "import sys\na = [print(len(str(sum(map(int, line.split()))))) for line in sys.stdin]", "neg": "import sys\na = [print(len(sum(map(int, line.split())))) for line in sys.stdin]", "jacc_sim": 0.9523809523809523, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [31, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u877201735", "n_user": "u877201735", "pos": "while True:\n try:\n x = list(map(int, input().split(' ')))\n n = x[0] + x[1]\n print(len(str(n)))\n except EOFError:\n break", "neg": "while True:\n try:\n x = list(map(int, input().split(' ')))\n n = x[0] * x[1]\n print(len(str(n)))\n except EOFError:\n break", "jacc_sim": 0.9310344827586207, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [55, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u659034691", "n_user": "u659034691", "pos": "while True:\n try:\n a,b=(int(i) for i in input().split())\n print(len(str(a+b)))\n except EOFError:\n break", "neg": "while True:\n try:\n a,b=(int(i) for i in input().split())\n print(len(str(a+b)))\n except EOFError:", "jacc_sim": 0.9583333333333334, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [45, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u531482846", "n_user": "u531482846", "pos": "import sys\n\nfor line in sys.stdin:\n x, y = map(int, line.split())\n print(len(str(x+y)))", "neg": "import sys\n\nfor line in sys.stdin:\n x, y = map(int, line.split())\n print(x+y)", "jacc_sim": 0.9047619047619048, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [37, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u506705885", "n_user": "u506705885", "pos": "answers=[]\nwhile True:\n try:\n nums=input().split()\n answers.append(len(str(int(nums[0])+int(nums[1]))))\n except :\n break\nfor i in range(len(answers)):\n print(answers[i])", "neg": "answers=[]\nwhile True:\n try:\n nums=input().split()\n answers.append(len(nums[0]+nums[1]))\n except :\n break\nfor i in range(len(answers)):\n print(answers[i])", "jacc_sim": 0.9285714285714286, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [69, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u742178809", "n_user": "u742178809", "pos": "import sys\nfor line in sys.stdin:\n s=sum([int(num) for num in line.split(' ')])\n print(len(str(s)))", "neg": "import os\nfor line in sys.stdin:\n s=sum([int(num) for num in line.split(' ')])\n print(len(str(s)))", "jacc_sim": 0.9565217391304348, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [39, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u150984829", "n_user": "u803045841", "pos": "import sys\nfor e in sys.stdin.readlines():\n print(len(str(sum(map(int,e.split())))))\n", "neg": "import sys\nfor e in sys.stdin.readlines():\n print(len(sum(map(int,e.split()))))\n", "jacc_sim": 0.9473684210526315, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [33, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfor e in sys.stdin:print(len(str(sum(map(int,e.split())))))\n", "neg": "import sys\nfor e in sys.stdin.readlines():\n print(len(str(sum(map(int,e.split()))))\n", "jacc_sim": 0.9473684210526315, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [29, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u002010345", "n_user": "u002010345", "pos": "def main():\n while True:\n try:\n a, b = (int(x) for x in input().split())\n print(len(str(a+b)))\n except EOFError:\n break\nmain()\n", "neg": "def main():\n while True:\n try:\n a, b = (int(x) for x in input().split())\n print(len(str(a+b)))\n except EOFError:\n break\n", "jacc_sim": 1.0, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [55, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u841567836", "n_user": "u841567836", "pos": "while True:\n try:\n a, b = (int(x) for x in input().split())\n print(len(str(a + b)))\n except:\n break;\n", "neg": "while True:\n try:\n a, b = (int(x) for x in input().split())\n print(a + b)\n except:\n break;\n", "jacc_sim": 0.9166666666666666, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [46, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u774946823", "n_user": "u982618289", "pos": "import sys\nfor e in sys.stdin:\n a, b = map(int, e.split())\n print(len(str(a+b)))\n", "neg": "import sys\n\nfor s in sys.stdin:\n a,b = map(int,s.split())\n print len(str(a+b))", "jacc_sim": 0.9090909090909091, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [37, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u800408401", "n_user": "u047988051", "pos": "while True:\n try:\n a,b = map(int,input().split(\" \"))\n except:break\n print(len(str(a+b)))\n", "neg": "while True:\n\ttry:\n\t\ta,b = map(int,input().split(\" \"))\n\t\tprint(a+b)\n\texcept: break ", "jacc_sim": 0.9090909090909091, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [41, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u614095715", "n_user": "u775586391", "pos": "import sys\nfor line in sys.stdin.readlines():\n a, b = list(map(int, line.split()))\n print(len(str(a+b)))\n\n", "neg": "import sys.stdin.readlines\nfor line in sys.stdin.readlines():\n a,b = map(int,line.split())\n print(len(str(a+b)))\n ", "jacc_sim": 0.9565217391304348, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [44, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u506537276", "n_user": "u327704389", "pos": "while True:\n try:\n a, b = map(int, input().split())\n c = a + b\n cc = str(c)\n print(len(cc))\n \n except EOFError:\n break\n", "neg": "while True:\n try:\n a,b = map(int,input().split())\n print (len(str(a+b)))\n except EOFError:\n break:", "jacc_sim": 0.9166666666666666, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [56, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u657361950", "n_user": "u436634575", "pos": "while True:\n\ttry:\n\t\ta,b=map(int,input().split())\n\t\tprint(len(str(a+b)))\n\texcept:\n\t\tbreak\n\t\n\n", "neg": "while True:\n try:\n line = input()\n except:\n break\n a, b = map(int, input().strip().split())\n print(len(str(a + b)))", "jacc_sim": 0.9130434782608695, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [47, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u319725914", "n_user": "u842823276", "pos": "import sys\nfor line in sys.stdin:\n a,b = line.split()\n a,b = int(a),int(b)\n print(len(str(a+b)))\n", "neg": "import sys\n\nfor line in sys.stdin:\n a, b = map(str, line.split())\n print(len(a+b))", "jacc_sim": 0.9047619047619048, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [47, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00002", "p_user": "u896746547", "n_user": "u123596571", "pos": "while True:\n try: a,b = map(int,input().split())\n except EOFError: break\n print(len(str(a+b)))\n", "neg": "while True:\n\ttry:\n\t\ta,b = map(int, input().split())\n\texcept:\n\t\tbreak\n\nprint(len(str(a+b)))", "jacc_sim": 0.9545454545454546, "nl": "**Digit Number**\n\nWrite a program to calculate the number of digits in the sum of two non-negative integers, a and b.\n\n**Input**\n\nThe input consists of several test cases, each containing two non-negative integers a and b separated by a space on a single line. The input terminates with EOF.\n\n**Constraints**\n\n- 0 \u2264 a, b \u2264 1,000,000\n- The number of datasets \u2264 200\n\n**Output**\n\nFor each dataset, print the number of digits in the sum of a and b.\n\n**Sample Input**\n\n5 7\n1 99\n1000 999\n\n**Output for the Sample Input**\n\n2\n3\n4", "before_after_length": [39, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u040533857", "n_user": "u040533857", "pos": "while True:\n try:\n spam=map(int, input().split(' '))\n spam = [i for i in spam]\n spam.sort()\n cola = spam[0] * spam[1]\n while True:\n if spam[0] == 0:\n print('{} {}'.format(spam[1],int(cola/spam[1])))\n break\n pre = spam[0]\n spam[0] = spam[1] % spam[0]\n spam[1] = pre\n except:\n break", "neg": "while True:\n try:\n spam=map(int, input().split(' '))\n spam = [i for i in spam]\n spam.sort()\n cola = spam[0] * spam[1]\n while True:\n if spam[0] == 0:\n print(spam[1])\n print(int(cola/spam[1]))\n break\n pre = spam[0]\n spam[0] = spam[1] % spam[0]\n spam[1] = pre\n except:\n break", "jacc_sim": 0.9142857142857143, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [134, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u776559258", "n_user": "u776559258", "pos": "def gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nwhile True:\n try:\n a,b=[int(i) for i in input().split()]\n print(gcd(a,b),(a*b)//gcd(a,b))\n except EOFError:\n break\n ", "neg": "def gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\nwhile True:\n try:\n a,b=[int(i) for i in input().split()]\n except EOFError:\n break\n ", "jacc_sim": 0.9032258064516129, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [87, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u459418423", "n_user": "u459418423", "pos": "import sys\n\ndef gcd(m, n):\n if n != 0:\n return gcd(n, m % n)\n else:\n return m\n\nfor line in sys.stdin.readlines():\n m, n = map(int, line.split())\n g = gcd(m, n)\n l = m * n // g # LCM\n print(g, l)", "neg": "import sys\n\ndef gcd(m, n):\n if n != 0:\n return gcd(n, m % n)\n else:\n return m\n\nfor line in sys.stdin.readlines():\n m, n = map(int, line.split())\n g = gcd(m, n)\n l = m * n // g # LCM\n print(g, ' ', l)", "jacc_sim": 0.9705882352941176, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [94, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u184989919", "n_user": "u184989919", "pos": "import sys\ndef GcdLCM():\n for line in sys.stdin:\n x,y=map(int,line.split())\n if x==None:\n break\n \n gcd = Gcd(x,y)\n lcm = int(x*y/gcd)\n\n print(\"{} {}\".format(gcd,lcm))\n \ndef Gcd(x,y):\n while x!=0:\n x,y=y%x,x\n return y\n \n \nGcdLCM()", "neg": "def GcdLCM():\n \n for line in sys.stdin:\n x,y=map(int,line.split())\n if x==None:\n break\n \n gcd = Gcd(x,y)\n lcm = int(x*y/gcd)\n\n print(\"{} {}\".format(gcd,lcm))\n \ndef Gcd(x,y):\n while x!=0:\n x,y=y%x,x\n return y\n \n \nGcdLCM()", "jacc_sim": 0.972972972972973, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [129, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u806182843", "n_user": "u806182843", "pos": "def main():\n\timport sys\n\n\tfor line in sys.stdin:\n\t\ta, b = map(int, line.split())\n\t\tc = a*b\n\n\t\twhile a % b != 0:\n\t\t\ta, b = b, a%b\n\n\t\tprint(b, c//b)\n\nif __name__ == '__main__':\n\tmain()", "neg": "def main():\n\timport sys\n\n\tfor line in sys.stdin:\n\t\ta, b = map(int, line.split())\n\t\tc = a*b\n\n\t\twhile a % b != 0:\n\t\t\ta, b = b, a%b\n\n\t\tprint(b, c*b)\n\nif __name__ == '__main__':\n\tmain()", "jacc_sim": 0.967741935483871, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [90, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u234052535", "n_user": "u234052535", "pos": "# This program computes GCD and LCM\n# -*- coding: utf-8\nimport sys\n\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\n\nfor i in sys.stdin:\n try:\n line = [int(k) for k in i.split(\" \")]\n g = gcd(min(line), max(line))\n print(str(g) + \" \" + str(line[0]*line[1]//g))\n except:\n exit()", "neg": "# This program computes GCD and LCM\n# -*- coding: utf-8\nimport sys\n\n\ndef gcd(a, b):\n while b:\n\ta, b = b, a % b\n return a\n\n\ndef lcm(a, b):\n for i in range(max([a, b]), a*b + 1):\n if(i % a == 0 and i % b == 0):\n return i\n return a*b\n\n\nfor i in sys.stdin:\n try:\n line = [int(k) for k in i.split(\" \")]\n g = gcd(max(line), min(line))\n print(str(g) + \" \" + str(line[0]*line[1]/g)) # + str(lcm(line[0], line[1]))\n except:\n raise\n exit()", "jacc_sim": 0.9090909090909091, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [133, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u508732591", "n_user": "u508732591", "pos": "import sys\n \nfor s in sys.stdin:\n m,n = map(int,s.split())\n g,r = m,n\n while r!=0:\n g,r = r,g%r\n print(g,m//g*n)", "neg": "import sys\n \nfor s in sys.stdin:\n g,r=m,n = map(int,s.split())\n while r!=0:\n g,r = r,g%r\n print(g,m//g*n)", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [66, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u877201735", "n_user": "u877201735", "pos": "def gcd(a, b):\n if (a % b) == 0:\n return b\n return gcd(b, a%b)\n\ndef lcd(a, b):\n return a * b // gcd(a, b)\n\n\nwhile True:\n try:\n nums = list(map(int, input().split()))\n print(gcd(nums[0], nums[1]), lcd(nums[0], nums[1]))\n\n except EOFError:\n break", "neg": "def gcd(a, b):\n if (a % b) == 0:\n return b\n return gcd(b, a%b)\n\n\nwhile True:\n try:\n nums = list(map(int, input().split()))\n print(gcd(nums[0], nums[1]))\n\n except EOFError:\n break", "jacc_sim": 0.9090909090909091, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [116, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u424041287", "n_user": "u424041287", "pos": "t = 0\nwhile t == 0:\t\n\ttry:\n\t\tx,y=[int(i) for i in input().split()]\n\texcept:\n\t\tbreak\n\telse:\n\t\ta = x * y\n\t\tif x < y:\n\t\t\tx,y =y,x\n\t\twhile y > 0:\n\t\t\tr = x % y\n\t\t\tx = y\n\t\t\ty = r\n\tprint(str(x) + \" \" + str(int(a / x)))", "neg": "t = 0\nwhile t == 0:\t\n\ttry:\n\t\tx,y=[int(i) for i in input().split()]\n\texcept:\n\t\tbreak\n\telse:\n\t\ta = x * y\n\t\tif x < y:\n\t\t\tx,y =y,x\n\t\twhile y > 0:\n\t\t\tr = x % y\n\t\t\tx = y\n\t\t\ty = r\n\tprint(str(x) + \" \" + str(a / x))", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [119, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u471400255", "n_user": "u471400255", "pos": "from math import gcd\nfrom sys import stdin\n\nfor line in stdin:\n a,b = [int(i) for i in line.split()]\n g = gcd(a,b)\n print(g,int(a*b/g))", "neg": "from math import gcd\nfrom sys import stdin\n\nfor line in stdin:\n a,b = [int(i) for i in line.split()]\n g = gcd(a,b)\n print(g,int(a*b/g)", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [59, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u183079216", "n_user": "u183079216", "pos": "def gcd(a,b):\n if a > b:\n x = a\n y = b\n else:\n x = b\n y = a\n while y > 0:\n r = x % y\n x = y\n y = r\n return x\n\ndef lcm(a,b,c):\n return int(a*b/c)\n\nwhile 1:\n try:\n a,b = [int(x) for x in input().split()]\n res_gcd = gcd(a,b)\n res_lcm = lcm(a,b,res_gcd)\n print('{} {}'.format(res_gcd,res_lcm))\n except:\n break", "neg": "def gcd(a,b):\n if a > b:\n x = a\n y = b\n else:\n x = b\n y = a\n while y > 0:\n r = x % y\n x = y\n y = r\n return x\n\ndef lcm(a,b,gcd):\n return a*b/gcd\n\nwhile 1:\n try:\n a,b = [int(x) for x in input().split()]\n gcd = gcd(a,b)\n lcm = lcm(a,b,gcd)\n print('{} {}'.format(gcd,lcm))\n except:\n break", "jacc_sim": 0.9285714285714286, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [175, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u803045841", "n_user": "u803045841", "pos": "import sys \nfor e in sys.stdin:\n a, b = map(int, e.split())\n p = a * b\n while b:\n a, b = b, a%b\n pass\n print (a,p//a)\n", "neg": "import sys \nfor e in sys.stdin:\n a, b = map(int, e.split())\n p = a * b\n while b:\n a, b = b, a%b\n pass\n print (a,p/a)\n", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [62, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u136916346", "n_user": "u136916346", "pos": "import sys\ndef gcd(a,b):\n if a%b==0:\n return b\n return gcd(b,a%b)\n\nr=[list(map(int,line.split())) for line in sys.stdin]\nfor i in r:\n o=gcd(i[0],i[1])\n p=i[0]*i[1]/o\n print(o,int(p))\n\n", "neg": "import sys\ndef gcd(a,b):\n if a%b==0:\n return b\n return gcd(b,a%b)\n\nr=[list(map(int,line.split())) for line in sys.stdin]\nfor i in r:\n o=gcd(i[0],i[i])\n p=i[0]*i[1]/o\n print(o,p)\n\n", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [102, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u986478725", "n_user": "u986478725", "pos": "# Vol0005.\nimport sys\n\n\ndef intinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef get_gcd(x, y):\n if x < y: return get_gcd(y, x)\n # x >= y\u306e\u3068\u304d\u306fx % y\u3092\u8a08\u7b97\u3057\u3066y\u3068x % y\u306e\u8a71\u306b\u3059\u308b\u3002\n # \u3053\u3053\u3067x % y\u306e\u3068\u3053\u308d\u304c0\u306a\u3089\u3070y\u304c\u6c42\u3081\u308b\u7b54\u3048\u3068\u306a\u308b\u3002\n if y == 0: return x\n return get_gcd(y, x % y)\n\ndef main():\n data = []\n lines = sys.stdin.readlines()\n\n for line in lines:\n data.append(line.split())\n\n N = len(data)\n for i in range(N):\n a = int(data[i][0]); b = int(data[i][1])\n gcd = get_gcd(a, b)\n lcm = (a // gcd) * b\n print('%d %d' % (gcd, lcm))\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# Vol0005.\nimport sys\n\n\ndef intinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef get_gcd(x, y):\n if x < y: return get_gcd(y, x)\n # x >= y\u306e\u3068\u304d\u306fx % y\u3092\u8a08\u7b97\u3057\u3066y\u3068x % y\u306e\u8a71\u306b\u3059\u308b\u3002\n # \u3053\u3053\u3067x % y\u306e\u3068\u3053\u308d\u304c0\u306a\u3089\u3070y\u304c\u6c42\u3081\u308b\u7b54\u3048\u3068\u306a\u308b\u3002\n if y == 0: return x\n return get_gcd(y, x % y)\n\ndef main():\n data = []\n lines = sys.stdin.readlines()\n for line in lines:\n data.append(line.split())\n\n N = len(data)\n for i in range(N):\n a = int(data[i][0]); b = int(data[i][1])\n gcd = get_gcd(a, b)\n lcm = (a // gcd) * b\n print('%d %d' % (a, b))\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [373, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u328733599", "n_user": "u328733599", "pos": "from sys import stdin\nimport math\n\ndef GCD(a,b):\n if(a%b==0):\n return b\n else:\n c = a%b\n return GCD(b,c)\n\ndef LCM(a,b):\n gcd = GCD(a,b)\n return int(a*b/gcd)\n\nfor line in stdin:\n a,b = line.split(\" \")\n a = int(a)\n b = int(b)\n gcd = GCD(a,b)\n lcm = LCM(a,b)\n\n print(str(gcd)+\" \"+str(lcm))\n\n\n", "neg": "from sys import stdin\nimport math\n\ndef GCD(a,b):\n if(a%b==0):\n return b\n else:\n c = a%b\n return GCD(b,c)\n\ndef LCM(a,b):\n gcd = GCD(a,b)\n return int(a*b/gcd)\n\nfor line in stdin:\n a,b = line.split(\" \")\n a = int(a)\n b = int(b)\n gcd = GCD(a,b)\n lcm = LCM(a,b)\n\n print(str(gcd)+\" \"+str(lcm))\n print()\n\n", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [162, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u436634575", "n_user": "u777299405", "pos": "def gcd(a, b):\n while b: a, b = b, a % b\n return a\n\nwhile True:\n try:\n line = input()\n except:\n break\n a, b = map(int, line.strip().split())\n g = gcd(a, b)\n print(g, a * b // g)", "neg": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\nwhile True:\n try:\n a, b = map(int, (input.split()))\n except:\n break\n g = gcd(a, b)\n print(g, a * b // g)", "jacc_sim": 0.9259259259259259, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [85, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u297517978", "n_user": "u533681846", "pos": "import math\nwhile 1:\n try:\n a,b,=map(int,input().split())\n print(math.gcd(a,b),a*b//math.gcd(a,b))\n except:\n break\n", "neg": "import math\nwhile 1:\n try:\n a,b = map(int, input().split())\n print(math.gcd(a,b))\n except:\n break\n", "jacc_sim": 0.9130434782608695, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [59, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u525395303", "n_user": "u847467233", "pos": "# AOJ 0005 GCD and LCM\n# Python3 2018.6.9 bal4u\n \ndef lcm(a, b):\n return a // gcd(a, b) * b\n \ndef gcd(a, b):\n while b != 0:\n r = a % b\n a = b\n b = r\n return a\n \nwhile True:\n try:\n a = list(map(int, input().split()))\n print(gcd(a[0], a[1]), lcm(a[0], a[1]))\n except EOFError:\n break\n", "neg": "# AOJ 0005 GCD and LCM\n# Python3 2018.6.9 bal4u\n\ndef lcm(a, b):\n\treturn a/gcd(a, b)*b\n\ndef gcd(a, b):\n\twhile b != 0:\n\t\tr = a % b\n\t\ta = b\n\t\tb = r\n\treturn a\n\nwhile True:\n try:\n a = list(map(int, input().split()))\n print(gcd(a[0], a[1]), lcm(a[0], a[1]))\n except EOFError:\n break\n", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [148, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u804558166", "n_user": "u506705885", "pos": "while(True):\n try:\n (a, b) = map(int, input().split(\" \"))\n (x, y) = (a, b)\n while (x != 0):\n (x, y) = (y%x, x)\n print(\"%s %s\" %(y, a*b//y))\n except:\n break\n", "neg": "\nwhile True:\n????????try:\n????????????????(a, b) = map(int, input().split(\" \"))\n????????????????(x, y) = (a, b)\n????????????????while (x != 0):\n????????????????????????(x, y) = (y%x, x)\n????????????????print(\"%s %s\" %(y, a*b//y))\n????????except:\n????????????????break", "jacc_sim": 0.9642857142857143, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [87, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u427219397", "n_user": "u777299405", "pos": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\nwhile True:\n try:\n a,b = map(int,input().split())\n print (gcd(a,b),a *b // gcd(a,b))\n except:\n break\n \n \n", "neg": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\nwhile True:\n try:\n a, b = map(int, input().split())\n print(gcd(a, b), a * b // gcd(a, b))\n except:\n break", "jacc_sim": 1.0, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [82, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u051789695", "n_user": "u896025703", "pos": "def gcd(a,b):\n if b==0:\n return a\n return gcd(b,a%b)\n\ndef lcm(a,b):\n return (a*b)//gcd(a,b)\n\nwhile True:\n try:\n a,b=map(int,input().split())\n except:\n break\n print(gcd(a,b),lcm(a,b))\n", "neg": "def gcd(a, b):\n\tif b == 0: return a\n\telse: return gcd(b, a % b)\n\ndef lcm(a, b):\n\treturn a * b / gcd(a, b)\n\nwhile True:\n\ttry:\n\t\ta, b = map(int, input().split())\n\t\tprint(gcd(a, b), lcm(a, b))\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 0.9310344827586207, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [104, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00005", "p_user": "u158979022", "n_user": "u498511622", "pos": "import math\n\nwhile True:\n try:\n a, b = map(int, input().split())\n print(math.gcd(a, b), a * b // math.gcd(a, b))\n except:\n break\n", "neg": "import math\n\ntry:\nwhile True:\n a,b=map(int,input().split())\n print(math.gcd(a,b),a*b// math.gcd(a, b))\n except:\n pass\n ", "jacc_sim": 0.9166666666666666, "nl": "Title: GCD and LCM\n\nWrite a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.\n\nInput:\nSeveral data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.\n\nConstraints:\n- 0 < a, b \u2264 2,000,000,000\n- LCM(a, b) \u2264 2,000,000,000\n- The number of data sets \u2264 50\n\nOutput:\nFor each data set, print GCD and LCM separated by a single space in a line.\n\nSample Input:\n8 6\n50000000 30000000\n\nOutput for the Sample Input:\n2 24\n10000000 150000000", "before_after_length": [59, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00006", "p_user": "u619400176", "n_user": "u619400176", "pos": "string = input()\nsize = len(string)\nst = []\nfor i in range(size):\n st.append(string[size-i-1])\nprint(''.join(st))\n\n", "neg": "string = input(\"input data\")\nsize = len(string)\nst = []\nfor i in range(size):\n st.append(string[size-i-1])\n\nprint(''.join(st))\n", "jacc_sim": 0.9565217391304348, "nl": "Reverse Sequence\n\nWrite a program that reverses a given string \"str\".\n\nInput\n\n\"str\" (the size of \"str\" is less than or equal to 20) is given in a line.\n\nOutput\n\nPrint the reversed \"str\" in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "before_after_length": [47, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00006", "p_user": "u328733599", "n_user": "u328733599", "pos": "txt = input(\"\")\nfor i in range(0,len(txt)):\n print(txt[(len(txt)-i-1)],end=\"\")\nprint()\n", "neg": "txt = input(\"\")\nfor i in range(0,len(txt)):\n print(txt[(len(txt)-i-1)],end=\"\")\n print()\n", "jacc_sim": 1.0, "nl": "Reverse Sequence\n\nWrite a program that reverses a given string \"str\".\n\nInput\n\n\"str\" (the size of \"str\" is less than or equal to 20) is given in a line.\n\nOutput\n\nPrint the reversed \"str\" in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "before_after_length": [40, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00006", "p_user": "u427219397", "n_user": "u803045841", "pos": "\t\nprint(input()[::-1])\n", "neg": "print(input[::-1])\n", "jacc_sim": 1.0, "nl": "Reverse Sequence\n\nWrite a program that reverses a given string \"str\".\n\nInput\n\n\"str\" (the size of \"str\" is less than or equal to 20) is given in a line.\n\nOutput\n\nPrint the reversed \"str\" in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "before_after_length": [12, 9], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00006", "p_user": "u080014366", "n_user": "u743065194", "pos": "s=input()\nnew_str = s[::-1]\nprint(new_str)\n", "neg": "s=input()\nprint s[::-1]", "jacc_sim": 0.9166666666666666, "nl": "Reverse Sequence\n\nWrite a program that reverses a given string \"str\".\n\nInput\n\n\"str\" (the size of \"str\" is less than or equal to 20) is given in a line.\n\nOutput\n\nPrint the reversed \"str\" in a line.\n\nSample Input\n\nw32nimda\n\nOutput for the Sample Input\n\nadmin23w", "before_after_length": [23, 12], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u696166817", "n_user": "u696166817", "pos": "# \u7d2f\u7a4d\u8a08\u7b97\n\nif __name__ == \"__main__\":\n n = int(input())\n # print(n)\n\n y = 100000 # 10\u4e07\u3000100,000\n y2 = y / 1000\n for i in range(0, n):\n\n y4 = y2 * 1.05\n # y3 = round(y2 * 1.05 -0.5, 0)\n y3 = float(int(y2 * 1.05))\n #print(\" {} {}\".format(y4, y3))\n if y4 - y3 > 0:\n y4 += 1\n y2 = int(y4)\n #print(\"{} {}\".format(i, y2 * 1000))\n\n print(y2 * 1000)\n\n # 0 105,000\n # 1 110,250 -> 111,000\n # 2 116,550 -> 117,000\n # 3 122,850 -> 123,000\n #4 129,150 -> 130,000", "neg": "# \u7d2f\u7a4d\u8a08\u7b97\n\nif __name__ == \"__main__\":\n n = int(input())\n # print(n)\n\n y = 100000 # 10\u4e07\u3000100,000\n y2 = y / 1000\n for i in range(0, n):\n\n y4 = y2 * 1.05\n # y3 = round(y2 * 1.05 -0.5, 0)\n y3 = float(int(y2 * 1.05))\n print(\" {} {}\".format(y4, y3))\n if y4 - y3 > 0:\n y4 += 1\n y2 = int(y4)\n print(\"{} {}\".format(i, y2 * 1000))\n\n print(y2 * 1000)\n\n # 0 105,000\n # 1 110,250 -> 111,000\n # 2 116,550 -> 117,000\n # 3 122,850 -> 123,000\n #4 129,150 -> 130,000", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [253, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u422939201", "n_user": "u422939201", "pos": "# -*- coding: utf-8 -*-\nfrom math import ceil\nn=int(input())\nd=int(1e5)\nfor x in range(n):\n d=(1.05*d)\n d=int(int(ceil(d/1e3))*1e3)\nprint(d)", "neg": "# -*- coding: utf-8 -*-\nfrom math import ceil \nn = int(input())\nd = int(1e5)\nfor x in range(n):\n d = (1.05*d)\n d + int(int(ceil(d/1e3))*1e3)\nprint (d)", "jacc_sim": 0.9666666666666667, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [78, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u745277023", "n_user": "u745277023", "pos": "x = int(input())\n\nn = 100000\nwhile x > 0:\n n *= 1.05\n mod = n % 1000\n if mod:\n n += 1000 - mod\n x -= 1\n\nprint(int(n))", "neg": "x = input()\n\nn = 100000\nwhile x > 0:\n n *= 1.05\n mod = n % 1000\n if mod != 0:\n n = n + 1000 - mod\n x -= 1\n\nprint(int(n))", "jacc_sim": 0.9583333333333334, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [56, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u868716420", "n_user": "u868716420", "pos": "n = 10 ** 2\nfor i in range(int(input())) :\n n = float(n) * 1.05\n if n - int(n) > 0 : n = int(n) + 1\n else : n = int(n)\nprint(n * (10 ** 3))", "neg": "n = 10 ** 2\nfor i in range(int(input())) :\n n = float(n) * 1.05\n if n - int(n) > 0 : n = int(n) + 1\n else : n = int(n)\nprint(n * (10 ** 4))", "jacc_sim": 0.9259259259259259, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [69, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u123596571", "n_user": "u123596571", "pos": "n = int(input())\ndebt = 100000\n\nfor i in range(n):\n\tdebt = debt * 1.05\n\tround = debt % 1000\n\tif round != 0:\n\t\tdebt = (debt // 1000 + 1) * 1000\n\nprint(int(debt))", "neg": "n = int(input())\ndebt = 100000\n\nfor i in range(n):\n\tdebt = debt * 1.05\n\tround = debt % 1000\n\tif round != 0:\n\t\tdebt = (debt // 1000 + 1) * 1000\nprint(int(debt)", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [71, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u399647870", "n_user": "u399647870", "pos": "import math\nshuu = input()\nnum = int(shuu)\nganpon = 100000\ni = 1\nwhile i <= num:\n ganpon *= 1.05\n ganpon /= 1000\n ganpon = math.ceil(ganpon)\n ganpon *= 1000\n i += 1\n pass\n#ganpon /= 1000\n#ganpon = math.ceil(ganpon)\n#ganpon *= 100000\nprint(ganpon)", "neg": "import math\nshuu = input()\nnum = int(shuu)\nganpon = 100000\ni = 1\nwhile i < num:\n ganpon *= 1.05\n ganpon /= 1000\n ganpon = math.ceil(ganpon)\n ganpon *= 1000\n i += 1\n pass\nprint(ganpon)", "jacc_sim": 0.9615384615384616, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [114, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u234052535", "n_user": "u234052535", "pos": "def Round(ip, dg): # ip???dg?????\u00a7?????\u00a8?????\\????????\u00a2??\u00b0\n ip = ip / 10**dg\n if(ip-int(ip) != 0):\n return (int(ip) + 1)*10**dg\n else:\n return int(ip)*10**dg\n\n\nn=int(input())\nsum=100000\nfor i in range(0, n):\n sum=Round(sum*1.05, 3)\nprint(sum)", "neg": "ef Round(ip, dg): # ip???dg?????\u00a7?????\u00a8?????\\????????\u00a2??\u00b0\n ip = ip / 10**dg\n if(ip-int(ip) != 0):\n return (int(ip) + 1)*10**dg\n else:\n return int(ip)*10**dg\n\n\nn=int(input())\nsum=100000\nfor i in range(0, n):\n sum=Round(sum*1.05)\nprint(sum)", "jacc_sim": 0.926829268292683, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [132, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u506705885", "n_user": "u506705885", "pos": "week=int(input())\nmoney=100000\nfor i in range(week):\n money=money*1.05\n if money%1000!=0:\n money=1000*(money//1000+1)\n\nprint(int(money))", "neg": "week=int(input())\nmoney=100000\nfor i in range(week):\n money=money*1.05\n if money%1000!=0:\n money=1000*(money//1000+1)\n\nprint(money)", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [62, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u742505495", "n_user": "u742505495", "pos": "import sys\nimport math\n\nn = int(input())\ndebt = 100000\nfor i in range(1,n+1):\n\tdebt = math.ceil((debt*1.05)/1000)*1000\nprint(debt)", "neg": "import sys\nimport math\n\nn = int(input())\ndebt = 100000\nfor i in range(1,n+1):\n\tdebt = math.floor((debt*1.05)/1000)*1000\nprint(debt)", "jacc_sim": 0.9259259259259259, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [56, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u424041287", "n_user": "u424041287", "pos": "import math\na = 100000\nfor n in range(int(input())):\n\ta = math.ceil(a*105/100000)*1000\nprint(int(a))", "neg": "import math\na = 100000\nfor n in range(int(input())):\n\ta = math.ceil(a*105/100)\nprint(int(a))", "jacc_sim": 0.9090909090909091, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [42, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u488038316", "n_user": "u488038316", "pos": "# -*-coding:utf-8\n#???????\u00a8????\n\nimport math\n\ndef main():\n\n debtTime = int(input())\n\n ans = int(culcDebt(debtTime))\n\n print(ans)\n\ndef culcDebt(t):\n debt = 100000\n for i in range(t):\n debt = debt * 1.05\n debt = 1000 * math.ceil(debt/1000)\n\n return debt\n\n\nif __name__ == '__main__':\n main()", "neg": "# -*-coding:utf-8\n#???????\u00a8????\n\nimport math\n\ndef main():\n\n debtTime = int(input())\n\n ans = int(culcDebt(debtTime))\n\n print(ans)\n\ndef culcDebt(t):\n debt = 100000\n for i in range(t):\n print('debt = {0}'.format(debt))\n debt = debt * 1.05\n debt = 1000 * math.ceil(debt/1000)\n\n return debt\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9111111111111111, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [138, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u742178809", "n_user": "u742178809", "pos": "x = 100000\nfor i in range(int(input())):\n x*=1.05\n x+=999\n x=x//1000*1000\nprint(int(x))", "neg": "x = 100000\nfor i in range(int(input())):\n x*=1.05\n x+=999\n x=x//1000*1000\nprint(x)", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [45, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u028347703", "n_user": "u028347703", "pos": "import math\n\nn = int(input())\nb = 100\nfor i in range(n):\n b += b * 0.05\n b = math.ceil(b)\nb *= 1000\nprint(\"%d\" % b)", "neg": "import math\n\nn = int(input())\nb = 100\nfor i in range(n):\n b += b * 0.05\n b = math.ceil(b)\nprint(\"%d\" % b * 1000)", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [54, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u150984829", "n_user": "u150984829", "pos": "import math\nd=100\nfor _ in[0]*int(input()):d=math.ceil(d*1.05)\nprint(int(d*1e3))\n", "neg": "import math\nd=100\nfor _ in[0]*int(input()):\n d=math.ceil(d*1.05)\nprint(d*1e3)\n", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [43, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u803045841", "n_user": "u150984829", "pos": "import math\na = 100\nfor _ in [0]*int(input()):\n a = math.ceil(a * 1.05)\nprint (a*1000)\n", "neg": "import math\na=100\nfor _ in[0]*int(input()):a=int(a*1.05)\nprint(a*1000)\n", "jacc_sim": 0.9565217391304348, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [42, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u706217959", "n_user": "u706217959", "pos": "import math\ndef int_ceil(src,range):\n return int(math.ceil(src/float(range)) * range)\n\ndef main():\n week = int(input())\n debt = 100000\n for i in range(week):\n risi = debt * 0.05\n debt = int_ceil(debt+ risi,1000)\n\n print(debt)\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import math\n\ndef int_ceil(src,range):\n return int(math.ceil(src/float(range)) * range)\n\ndef main():\n week = int(input())\n debt = 100000\n for i in range(week):\n risi = debt * 0.05\n debt = int_ceil(debt+ risi,1000)\n\n print(math)\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [115, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u533681846", "n_user": "u780025254", "pos": "import math\ndebt = 100000\nrate = 1.05\nweek = int(input())\nfor i in range(week):\n debt = math.ceil(debt*1.05/1000)*1000\nprint(debt)\n", "neg": "import math\nweek = int(input())\ndebt = 100000\nfor i in range(week):\n debt = math.ceil(debt*1.05/1000)*1000\n print(int(debt))\nprint(int(debt))\n", "jacc_sim": 0.9583333333333334, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [55, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u436634575", "n_user": "u915343634", "pos": "from math import ceil\n\nn = int(input())\nx = 100\nfor i in range(n): x = ceil(x * 1.05)\nprint(x * 1000)", "neg": "from math import ceil\n\nn = int(input())\nx = 100\nfor i in range(n):\n x = ceil(x * 1.05)\n print(x * 1000)", "jacc_sim": 1.0, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [41, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u453677662", "n_user": "u217408867", "pos": "import math\nr=100\nn=int(input())\nfor i in range(n):\n r=math.ceil(r*1.05)\nprint(r*1000)\n", "neg": "import math\n\nr = 100\nn = input()\nfor i in range(n):\n r = math.ceil(r * 1.05)\nprint(r * 1000)\n", "jacc_sim": 0.9545454545454546, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [44, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u257570657", "n_user": "u885889402", "pos": "n=int(input())\na=100000\nfor i in range(n):\n a*=1.05\n if a%1000>0:\n a=a//1000*1000+1000\nprint(int(a))\n", "neg": "n = input()\na = 100000\nfor i in range(1,int(n)+1):\n a = int(a*1.05)\n print(a)\n if(a%1000 > 0):\n a = 1000*int(a/1000) + 1000\n print(a)\n\nprint(a)", "jacc_sim": 0.9615384615384616, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [55, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u056263240", "n_user": "u901080241", "pos": "import math\na = 100\nfor i in range (int(input())):\n a = math.ceil(a*1.05)\nprint(a*1000)\n\n\n", "neg": "import math\n\ndebt = 100\nfor i in range(int(input())):\n ceil = math.ceil(debt*1.05)\nprint(debt*1000)", "jacc_sim": 0.9090909090909091, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [43, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u614095715", "n_user": "u500396695", "pos": "import math\ndebt = 100000\nfor n in range(int(input())):\n debt = math.ceil(debt*1.05/1000)*1000\nprint(str(debt))\n\n", "neg": "import math\nn = int(input())\ndebt = 100000\nfor i in range(n):\n\tdebt = int(math.ceil((debt * 1.05 / 1000) * 1000))\nprint(debt)", "jacc_sim": 0.9166666666666666, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [49, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u990228206", "n_user": "u858885710", "pos": "import math\nn=int(input())\ndebt=100000\nfor i in range(n):\n debt=math.ceil(debt*1.05/1000)*1000\nprint(debt)\n", "neg": "import math\ndebt = 100000\nfor i in range(n):\n debt = math.ceil(debt*1.05/1000)*1000\nprint int(debt)", "jacc_sim": 0.9565217391304348, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [50, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u573115711", "n_user": "u328199937", "pos": "import math\n\nn = int(input())\nresult = 100\nfor i in range(n):\n result = math.ceil(result*1.05)\nprint(result*1000)\n\n", "neg": "import math\nn = int(input())\nprint(n)\nmoney = int(100)\nfor i in range(n):\n money *= 1.05\n money = math.ceil(money)\nprint(int(money) * 1000)\nprint()\n\n", "jacc_sim": 0.9130434782608695, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [46, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u221424603", "n_user": "u298999032", "pos": "n=int(input())\n\nzandaka=100000\n\nfor i in range(n):\n zandaka=zandaka*1.05\n if zandaka%1000!=0:\n zandaka=zandaka+1000-zandaka%1000\n\nprint(int(zandaka))\n\n", "neg": "x=100000\nn=int(input())\nfor i in range(n):\n x*=1.05\n if x%1000!=0:\n x+=1000-x%1000\nprint(x)\n", "jacc_sim": 0.9230769230769231, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [85, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00007", "p_user": "u252700163", "n_user": "u779627195", "pos": "import math\nn = int(input())\n\nbase = 100000\nfor i in range(n):\n base *= 1.05\n\n base /= 1000\n\n base = math.ceil(base)\n\n base *= 1000\n\nprint(base)\n", "neg": "import math\nn = input()\nm = 100000\nfor i in range(n):\n m *= 1.05\n print m\n m = math.ceil(m/1000)*1000\nprint int(m)", "jacc_sim": 0.9166666666666666, "nl": "Title: Debt Hell\n\nYour friend, who lives in an undisclosed country, is involved in debt. He is borrowing 100,000 yen from a loan shark. The loan shark adds 5% interest to the debt and rounds it to the nearest 1,000 yen above week by week.\n\nWrite a program that calculates the amount of the debt after n weeks.\n\nInput:\nAn integer n (0 <= n <= 100) is given in a line.\n\nOutput:\nPrint the amount of the debt in a line.\n\nSample Input:\n5\n\nOutput for the Sample Input:\n130000", "before_after_length": [60, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u885889402", "n_user": "u885889402", "pos": "while(True):\n a = 0\n try:\n n = input()\n except EOFError:\n break\n\n n=int(n)\n\n if n > 36:\n print(0)\n continue\n elif n==36:\n print(1)\n continue\n b = n\n for i in range(10):\n if n-i==0:\n a=a+1\n #print(\"(%d,0,0,0)\"%(i))\n break\n for j in range(10):\n if n-i-j==0:\n a=a+1\n #print(\"(%d,%d,0,0)\"%(i,j))\n break\n for k in range(10):\n b = n-i-j-k\n if b>=0 and b<=9:\n a=a+1\n #print(\"(%d,%d,%d,%d)\"%(i,j,k,b))\n continue\n elif b > 9:\n continue\n else:\n break\n\n\n print(a)", "neg": "while(True):\n a = 0\n n = int(input())\n\n if n > 36:\n print(0)\n continue\n elif n==36:\n print(1)\n continue\n b = n\n for i in range(10):\n if n-i==0:\n a=a+1\n #print(\"(%d,0,0,0)\"%(i))\n break\n for j in range(10):\n if n-i-j==0:\n a=a+1\n #print(\"(%d,%d,0,0)\"%(i,j))\n break\n for k in range(10):\n b = n-i-j-k\n if b>=0 and b<=9:\n a=a+1\n #print(\"(%d,%d,%d,%d)\"%(i,j,k,b))\n continue\n elif b > 9:\n continue\n else:\n break\n \n \n print(a)\nreturn 0", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [260, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u075836834", "n_user": "u075836834", "pos": "\nwhile True:\n\ttry:\n\t\tn=int(input())\n\t\tcnt=0\n\t\tfor a in range(10):\n\t\t\tif a<=n:\n\t\t\t\tfor b in range(10):\n\t\t\t\t\tif b<=n:\n\t\t\t\t\t\tfor c in range(10):\n\t\t\t\t\t\t\tif c<=n:\n\t\t\t\t\t\t\t\td = n-(a+b+c)\n\t\t\t\t\t\t\t\tif 0<=d<=9:\n\t\t\t\t\t\t\t\t\tcnt+=1\n\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tbreak\n\t\tprint(cnt)\n\texcept EOFError:\n\t\tbreak", "neg": "\nwhile True:\n\ttry:\n\t\tn=int(input())\n\t\tcnt=0\n\t\tfor a in range(10):\n\t\t\tif a<=n:\n\t\t\t\tfor b in range(10):\n\t\t\t\t\tif b<=n:\n\t\t\t\t\t\tfor c in range(10):\n\t\t\t\t\t\t\tif c<=n:\n\t\t\t\t\t\t\t\td = n-(a+b+c)\n\t\t\t\t\t\t\t\tif 0<=d<=9:\n\t\t\t\t\t\t\t\t\tcnt+=1\n\t\t\t\t\t\t\t\telse:\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\telse:\n\t\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tbreak\n\t\tprint(cnt)\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 1.0, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [163, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u776559258", "n_user": "u776559258", "pos": "import itertools\ndef combination(n):\n m=0\n for i in itertools.product(range(10),repeat=4):\n (a,b,c,d)=i\n if a+b+c+d==n:\n m+=1\n return m\n\nwhile True:\n try:\n n=int(input())\n print(combination(n))\n except EOFError:\n break", "neg": "import itertools\ndef combination(n):\n m=0\n for i in itertools.product(range(10),repeat=4):\n (a,b,c,d)=i\n if a+b+c+d==n:\n m+=1\n return m\n\nwhile True:\n try:\n n=int(input())\n combination(n)\n except EOFError:\n break", "jacc_sim": 0.9736842105263158, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [96, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u661290476", "n_user": "u661290476", "pos": "memo=[[-1]*51 for i in range(5)]\ndef rec(i,n):\n if memo[i][n]!=-1:\n return memo[i][n]\n r=0\n if i==4:\n return 1 if n==0 else 0\n for m in range(10):\n r+=rec(i+1,n-m)\n memo[i][n]=r\n return r\n \nwhile True:\n try:\n n=int(input())\n print(rec(0,n))\n except:\n break", "neg": "\nmemo=[[-1]*51 for i in range(5)]\ndef rec(i,n):\n if memo[i][n]!=-1:\n return memo[i][n]\n memo[i][n]=0\n if i==4:\n return 1 if n==0 else 0\n for m in range(10):\n memo[i][n]+=rec(i+1,n-m)\n return memo[i][n]\n \nwhile True:\n try:\n n=int(input())\n print(rec(0,n))\n except:\n break", "jacc_sim": 0.9736842105263158, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [138, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u435300817", "n_user": "u435300817", "pos": "import sys\nvalues = []\nfor line in sys.stdin:\n values.append(int(line))\n \nfor v in values:\n ans = [1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if v == i + j + k + l]\n print(ans.count(1))", "neg": "import sys\nvalues = []\nfor line in sys.stdin:\n values.append(int(line))\nans = [1 for i in range(10) for j in range(10) for k in range(10) for l in range(10) if n == i + j + k + l]\nprint(ans.count(1))", "jacc_sim": 0.9333333333333333, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [87, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\na=[0]*51;x=range(10)\nfor i in range(51):\n a[i]=sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==i])\nfor e in sys.stdin:\n print(a[int(e)])\n", "neg": "import sys\na=[0]*51\nfor i in range(51):\n a[i]=sum([1 for a in x for b in x for c in x for d in x if a+b+c+d==e]))\nfor e in sys.stdin:\n print(a[int(e)])\n", "jacc_sim": 0.9354838709677419, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [78, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u553148578", "n_user": "u553148578", "pos": "ans=[0]*51\nfor a in range(10):\n\tfor b in range(10):\n\t\tfor c in range(10):\n\t\t\tfor d in range(10):\n\t\t\t\tans[sum([a,b,c,d])] += 1 \nwhile True:\n\ttry:print(ans[int(input())])\n\texcept:break\t\n", "neg": "ans=[0]*51\nfor a in range(10):\n\tfor b in range(10):\n\t\tfor c in range(10):\n\t\t\tfor d in range(10):\n\t\t\t\tans[sum([a,b,c,d])] += 1 \nwhile True:\n\ttry:print(sum[int(imput())])\n\texcept:break\n", "jacc_sim": 0.9354838709677419, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [85, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u533681846", "n_user": "u533681846", "pos": "lst=[0 for i in range(51)]\nfor a in range(10):\n for b in range(10):\n for c in range(10):\n for d in range(10):\n lst[a+b+c+d] += 1\nwhile 1:\n try:\n print(lst[int(input())])\n except:\n break\n", "neg": "lst=[0 for i in range(50)]\nfor a in range(10):\n for b in range(10):\n for c in range(10):\n for d in range(10):\n lst[a+b+c+d] += 1\nwhile i:\n try:\n print(lst[int(input())])\n except:\n break\n", "jacc_sim": 0.9285714285714286, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [86, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00008", "p_user": "u436634575", "n_user": "u777299405", "pos": "from itertools import product\n\nwhile True:\n try:\n n = int(input())\n except:\n break\n\n count = sum(a+b+c+d == n for a, b, c, d in product(range(10), repeat=4))\n print(count)", "neg": "from itertools import product\n\nwhile True:\n try:\n n = int(input)\n except:\n break\n count = sum(a + b + c + d == n for a, b, c, d in product(range(10), repeat=4))\n print(count)", "jacc_sim": 1.0, "nl": "Title: Sum of 4 Integers\n\nWrite a program that takes an integer 'n' as input and identifies the number of combinations of 'a, b, c, and d' (where 0 <= a, b, c, d <= 9) that satisfy the equation: a + b + c + d = n.\n\nFor example, if n = 35, there are 4 different combinations of (a, b, c, d): (8, 9, 9, 9), (9, 8, 9, 9), (9, 9, 8, 9), and (9, 9, 9, 8).\n\nInput:\nThe input consists of several datasets. Each dataset contains a value of n (1 <= n <= 50) on a separate line. The number of datasets is less than or equal to 50.\n\nOutput:\nPrint the number of combinations for each dataset on a separate line.\n\nSample Input:\n35\n1\n\nOutput for the Sample Input:\n4\n4", "before_after_length": [69, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u631800466", "n_user": "u631800466", "pos": "import sys\nfrom math import floor, sqrt\nfrom bisect import bisect_right\n\nprimes = [2]\n\ndef isPrime(v):\n threshold = floor(sqrt(v))\n for p in primes:\n if p > threshold:\n break\n if v % p == 0:\n return False\n return True\n\nfor v in range(3, 1000000, 2):\n if isPrime(v):\n primes.append(v)\n\nvalues = []\nfor line in sys.stdin:\n values.append(int(line))\n\nfor v in values:\n print(bisect_right(primes, v))\n\n", "neg": "import sys\nfrom math import floor, sqrt\nfrom bisect import bisect_right\n\nprimes = [2]\n\ndef isPrime(v):\n threshold = floor(sqrt(v))\n for p in primes:\n if p > threshold:\n break\n if v % p == 0:\n return False\n return True\n\nfor v in range(3, 1000000, 2):\n if isPrime(v):\n primes.append(v)\n\nprint(len(primes))\n\nvalues = []\nfor line in sys.stdin:\n values.append(int(line))\n\nfor v in values:\n print(bisect_right(primes, v))\n\n", "jacc_sim": 0.9772727272727273, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [154, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150414576", "n_user": "u150414576", "pos": "# -*- coding;utf-8 -*-\n\ndef sieve(n):\n p = 0\n primes = []\n is_prime = [True]*(n+1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, n+1):\n if(is_prime[i]):\n primes.append(i)\n p += 1\n for j in range(i*2,n+1,i):#i\u3054\u3068\u306b\u5897\u3048\u308b\n is_prime[j] = False\n return p\n\nif(__name__ == \"__main__\"):\n while(True):\n try:\n n = int(input())\n except:\n break\n print(sieve(n))\n ", "neg": "# -*- coding;utf-8 -*-\n\ndef sieve(n):\n p = 0\n primes = []\n is_prime = [True]*(n+1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, n+1):\n if(is_prime[i]):\n primes.append(i)\n p += 1\n for j in range(i*2,n,i):#i\u3054\u3068\u306b\u5897\u3048\u308b\n is_prime[j] = False\n return p\n\nif(__name__ == \"__main__\"):\n while(True):\n try:\n n = int(input())\n except:\n break\n print(sieve(n) + \"\\n\")", "jacc_sim": 0.9807692307692307, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [202, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u672822075", "n_user": "u672822075", "pos": "while True:\n\ttry:\n\t\tn=int(input())\n\t\ta=[True]*(n+1)\n\t\ta[0]=a[1]=False\n\t\tfor i in range(2,int(n**0.5)+1):\n\t\t\tif a[i]:\n\t\t\t\tfor j in range(i**2,n+1,i):\n\t\t\t\t\ta[j]=False\n\t\tprint(a.count(True))\n\texcept:\n\t\tbreak", "neg": "while True:\n\ttry:\n\t\tn=int(input())\n\t\ta=[True]*(n+1)\n\t\ta[0]=a[1]=False\n\t\tfor i in range(2,int(n**0.5)+1):\n\t\t\tif a[i]:\n\t\t\t\tfor j in range(i**2,n,i):\n\t\t\t\t\ta[j]=False\n\t\tprint(a.count(True))\n\texcept:\n\t\tbreak", "jacc_sim": 1.0, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [116, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u744114948", "n_user": "u744114948", "pos": "def pri(s,n): \n tab=[i for i in range(n+1) if s[i] and i>=2]\n return(tab)\n \ns=[True for _ in range(999999+1)]\ni=2\nwhile i**2<=999999:\n if s[i]:\n j=i*2\n while j<=999999:\n s[j]=False\n j+=i\n i+=1\n\nwhile True:\n try:\n print(len(pri(s,int(input()))))\n except:\n break", "neg": "def pri(n):\n s=[True for _ in range(n+1)]\n i=2\n while i**2<=n:\n if s[i]:\n j=i*2\n while j<=n:\n s[j]=False\n j+=i\n i+=1\n\n tab=[i for i in range(n+1) if s[i] and i>=2]\n return(tab)\n\nwhile True:\n try;\n print(len(pri(int(input()))))\n except\n break", "jacc_sim": 0.9230769230769231, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [140, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u766477342", "n_user": "u766477342", "pos": "def mk_table(n):\n res = [1] * (n + 1)\n res[:2] = 0, 0\n\n for i in range(2, n):\n if i ** 2 > n:\n break\n\n if res[i] == 1:\n for j in range(i*2, n + 1, i):\n res[j] = 0\n\n return res\n\n\ntbl = mk_table(999999)\ntry:\n while 1:\n print(len([x for x in tbl[:int(input())+1] if x == 1]))\nexcept Exception:\n pass", "neg": "def mk_table(n):\n res = [1] * (n + 1)\n res[:2] = 0, 0\n\n for i in range(2, n):\n if i ** 2 > n:\n break\n\n if res[i] == 1:\n for j in range(2, n // i + 1, i):\n res[i * j] = 0\n\n return res\n\n\ntbl = mk_table(999999)\ntry:\n while 1:\n print(len([x for x in tbl[:int(input())+1] if x == 1]))\nexcept Exception:\n pass", "jacc_sim": 0.9736842105263158, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [145, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u075836834", "n_user": "u075836834", "pos": "def sieve(n):\n\tp=[True for i in range(n+1)]\n\tp[0]=p[1]=False\n\tfor i in range(2,n+1):\n\t\tif p[i]==True:\n\t\t\tfor j in range(i*i,n+1,i):\n\t\t\t\tp[j]=False\n\treturn p\n\ndef solve(n):\n\t\tif n<2:return 0\n\t\tc=1\n\t\tfor i in range(3,n+1,2):\n\t\t\tif p[i]==1:\n\t\t\t\tc+=1\n\t\treturn c\n\np=sieve(1000000)\nwhile True:\n\ttry:\n\t\tn = int(input())\n\t\tprint(solve(n))\n\texcept EOFError:\n\t\tbreak", "neg": "def sieve(n):\n\tp=[True]*(n+1)\n\tp[0]=p[1]=False\n\tfor i in range(2,n+1,2):\n\t\tif p[i]==True:\n\t\t\tfor j in range(i*i,n+1,i):\n\t\t\t\tp[j]=False\n\treturn p\n\ndef solve(n):\n\t\tif n<2:return 0\n\t\tc=1\n\t\tfor i in range(3,n+1,2):\n\t\t\tif p[i]==1:\n\t\t\t\tc+=1\n\t\treturn c\n\np=sieve(1e6)\nwhile True:\n\ttry:\n\t\tn = int(input())\n\t\tprint(solve(n))\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 0.9487179487179487, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [196, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u661290476", "n_user": "u661290476", "pos": "prime=[True]*1000000\nfor i in range(2,1000):\n if prime[i]:\n for j in range(i*2,1000000,i):\n prime[j]=False\n\nwhile True:\n try:\n n=int(input())\n except:\n break\n print(sum(prime[2:n+1]))", "neg": "prime=[False]*1000000\nnp=[0]*1000000\nfor i in range(2,1000):\n if not prime[i]:\n for j in range(i*2,1000000,i):\n prime[j]=True\n\nwhile True:\n try:\n n=int(input())\n except:\n break\n print(sum(prime[2:n+1]))", "jacc_sim": 0.9117647058823529, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [85, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u508732591", "n_user": "u508732591", "pos": "import sys\nimport math\n\nN = 1000000\nprimes = [1] * N\nprimes[0] = 0\nprimes[1] = 0\nprimes[4::2] = [0] * len(primes[4::2])\n\nfor i in range(3,int(math.sqrt(N)),2):\n if primes[i]:\n primes[i*i::i*2] = [0] * len(primes[i*i::i*2])\n\nfor i in sys.stdin:\n n = int(i)\n print(sum(primes[0:n+1]))", "neg": "import sys\nimport math\n\nN = 1000000\nprimes = [1] * N\nprimes[0] = 0\nprimes[1] = 0\nprimes[4::2] = [0] * len(primes[4::2])\n\nfor i in range(3,int(math.sqrt(N)),2):\n if primes[i]:\n primes[i*i::i*2] = [0] * len(primes[i*i::i*2])\n\nfor i in sys.stdin:\n n = int(i)\n print(sum(primes[0:n]))", "jacc_sim": 0.9696969696969697, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [148, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u745277023", "n_user": "u745277023", "pos": "import sys\n \n \nf = [0, 1] * 500000\n \ni = 3\nwhile i <= 1000:\n if f[i] == 1:\n j = i * i\n while j <= 1000000:\n f[j] = 0\n j += i + i\n i += 2\n \nf.pop(0)\nf.pop(1)\n \nfor n in sys.stdin:\n i = int(n)\n if i < 2:\n print(0)\n else:\n print(sum(f[:i - 1]))", "neg": "import sys\n\nf = [0, 1] * 500000\ni = 3\nwhile i * i <= 2 * xx:\n if f[i] == 1:\n j = i * i\n while j <= 2 * xx:\n f[j] = 0\n j += i + i\n i += 2\n\nf.pop(0)\nf.pop(1)\n \nfor n in sys.stdin:\n i = int(n)\n if i < 2:\n print(0)\n else:\n print(sum(f[:i - 1]))", "jacc_sim": 0.9166666666666666, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [135, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u745277023", "n_user": "u745277023", "pos": "import sys\n\nf = [1, 0, 0, 0, 1, 0] * (1000000 // 6 + 1)\nf = [0, 0, 1, 1] + f[3:-2]\n\ni = 5\nwhile i < 1000:\n if f[i] == 1:\n j = i * i\n while j <= 1000000:\n f[j] = 0\n j += i + i\n i += 2\n\nfor n in sys.stdin:\n i = int(n)\n print(sum(f[:i + 1]))", "neg": "import sys\n lalala = 1000000 // 6 + 1\nf = [1, 0, 0, 0, 1, 0] * lalala\nf = [0, 0, 1, 1] + f[3:-2]\n\ni = 5\nwhile i < 1000:\n if f[i] == 1:\n j = i * i\n while j <= 1000000:\n f[j] = 0\n j += i + i\n i += 2\n\nfor n in sys.stdin:\n i = int(n)\n print(sum(f[:i + 1]))", "jacc_sim": 0.9722222222222222, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [132, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u459418423", "n_user": "u459418423", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\n\nLIMIT = 1000000\nis_prime = [True] * (LIMIT+1)\np = 2\nwhile p**2 <= LIMIT:\n if is_prime[p]:\n for i in range(p*2, LIMIT+1, p):\n is_prime[i] = False\n p += 1\n\nfor line in sys.stdin.readlines():\n n = int(line.strip())\n if n <= 1:\n print(0)\n continue\n if n == 2:\n print(1)\n continue\n num_prime = 1\n for i in range(3, n+1):\n if is_prime[i]:\n num_prime += 1\n print(num_prime)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\nimport sys\n\nLIMIT = 1000000\nis_prime = [True] * (LIMIT+1)\np = 2\nwhile p**2 <= LIMIT:\n if is_prime[p]:\n for i in range(p*2, n+1, p):\n is_prime[i] = False\n p += 1\n\nfor line in sys.stdin.readlines():\n n = int(line.strip())\n if n <= 1:\n print(0)\n continue\n if n == 2:\n print(1)\n continue\n num_prime = 1\n for i in range(3, n+1):\n if is_prime[i]:\n num_prime += 1\n print(num_prime)", "jacc_sim": 1.0, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [195, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u728901930", "n_user": "u728901930", "pos": "import sys\nimport math as mas\n\ndef sieve(n):\n\tp=[True for i in range(n+1)]\n\tp[0]=p[1]=False\n\tend=int(n**0.5)\n\tfor i in range(2,end+1):\n\t\tif p[i]:\n\t\t\tfor j in range(i*i,n+1,i):\n\t\t\t\tp[j]=False\n\treturn p\n\t\nsosu=sieve(1000010)\nfor i in sys.stdin:\n\tt=int(i)\n\tif t<2:print(0)\n\telif t==2:print(1)\n\telse:print(1+sum(sosu[t] for t in range(3,int(i)+1,2)))\n\n#\ta,b=map(int,i.split())\n#\tprint(gcd(a,b),lcm(a,b))", "neg": "import sys\nimport math as mas\n\ndef sieve(n):\n\tp=[True for i in range(n+1)]\n\tp[0]=p[1]=False\n\tend=int(n**0.5)\n\tfor i in range(2,end+1):\n\t\tif p[i]:\n\t\t\tfor j in range(i*i,n+1,i):\n\t\t\t\tp[j]=False\n\treturn p\n\t\nsosu=sieve(1000010)\nfor i in sys.stdin:\n\tprint(sum(sosu[t] for t in range(int(i))))\n\n#\ta,b=map(int,i.split())\n#\tprint(gcd(a,b),lcm(a,b))", "jacc_sim": 0.9215686274509803, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [224, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u806182843", "n_user": "u806182843", "pos": "def main():\n\timport sys\n\n\tMAX = 1000000\n\n\ttable = [True]*1000000\n\ttable[0] = table[1] = False\n\n\tprimes = []\n\tcounted = 0\n\n\tfor i in range(MAX):\n\t\tif table[i]:\n\t\t\tprimes.append(i)\n\t\t\tfor j in range(2*i, MAX, i):\n\t\t\t\ttable[j] = False\n\n\tfor line in sys.stdin:\n\t\tn = int(line)\n\n\t\tcnt = 0\n\t\tfor prime in primes:\n\t\t\tif prime > n:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcnt += 1\n\t\tprint(cnt)\n\n\nif __name__ == '__main__':\n\tmain()", "neg": "def main():\n\timport sys\n\n\tMAX = 1000000\n\n\ttable = [True]*1000000\n\ttable[0] = table[1] = False\n\n\tprimes = []\n\tcounted = 0\n\n\tfor line in sys.stdin:\n\t\tn = int(line)\n\t\tif n > counted:\n\t\t\tfor i in range(int(n+1)):\n\t\t\t\tif table[i] and not i in primes:\n\t\t\t\t\tprimes.append(i)\n\t\t\t\t\tfor j in range(2*i, MAX, i):\n\t\t\t\t\t\ttable[j] = False\n\t\t\tcounted = n\n\n\t\tcnt = 0\n\t\tfor prime in primes:\n\t\t\tif prime > n:\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tcnt += 1\n\t\tprint(primes)\n\t\tprint(cnt)\n\n\nif __name__ == '__main__':\n\tmain()", "jacc_sim": 0.9565217391304348, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [183, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u970743870", "n_user": "u508732591", "pos": "import sys\nimport math\nM = 1000000\nB = int(math.sqrt(M)+1)//6+1\nN = M//6\nN1 = N+1 if M % 6 == 5 else N\nN2 = N+1 if M % 6 >= 1 else N\nl = [1] * N1\nm = [1] * N2\ni = 5\nini = 4\nfor p in range(B):\n if l[p] == 1:\n l[p+i::i] = [0] * len(l[p+i::i])\n m[ini-1::i] = [0] * len(m[ini-1::i])\n if m[p] == 1:\n m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])\n l[ini+1::i+2] = [0] * len(l[ini+1::i+2])\n i += 6\n ini += 5\n \nfor i in sys.stdin:\n n = int(i)\n r = n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2\n print(r)", "neg": "import sys\nimport math\nfrom array import array\n\nM = 1000000\nB = int(math.sqrt(M)+1)//6+1\nN = M//6\nN1 = N+1 if M % 6 == 5 else N\nN2 = N+1 if M % 6 >= 1 else N\nl = array('I',[1]) * N1\nm = array('I',[1]) * N2\ni = 5\nini = 4\nfor p in range(B):\n if l[p] == 1:\n l[p+i::i] = [0] * len(l[p+i::i])\n m[ini-1::i] = [0] * len(m[ini-1::i])\n if m[p] == 1:\n m[p+i+2::i+2] = [0] * len(m[p+i+2::i+2])\n l[ini+1::i+2] = [0] * len(l[ini+1::i+2])\n i += 6\n ini += 5\n \nfor i in sys.stdin:\n n = int(i)\n r = n-1 if n < 3 else sum(l[0:(n+1)//6])+sum(m[0:(n-1)//6])+2\n print(r)", "jacc_sim": 0.9056603773584906, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [306, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nm=10**6;a=[1]*m;a[0:2]=0,0\nfor i in range(2,1000):\n if a[i]>0:\n for j in range(i*2,m,i):a[j]=0\nfor i in range(m):a[i]+=a[i-1]\nfor e in sys.stdin:print(a[int(e)])\n", "neg": "import sys\nm=10**6;a=[1]*m;a[0:2]=0,0\nfor i in range(2,999):\n if a[i]>0:\n for j in range(i*2,,i):a[j]=0\nfor i in range(m):a[i]+=a[i-1]\nfor e in sys.stdin:print(a[int(e)])\n", "jacc_sim": 0.9411764705882353, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [102, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nm=10**6;a=[1]*m;a[0:2]=0,0\nfor i in range(2,999):\n if a[i]>0:\n for j in range(i*2,m,i):a[j]=0\nfor i in range(m):a[i]+=a[i-1]\nfor e in sys.stdin:print(a[int(e)])\n", "neg": "import sys\nm=10**6;a=[1]*m;a[0:2]=0,0\nfor i in range(2,999):\n if a[i]>0:\n for j in range(i*2,m,i):a[j]=0\nfor e in sys.stdin:print(sum(a[:int(e)]))\n", "jacc_sim": 0.9117647058823529, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [102, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nm=10**6;a=[0,0]+[1]*m\nfor i in range(999):\n if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]\nfor e in sys.stdin:print(sum(a[:int(e)+1]))\n", "neg": "import sys\na=[0,0]+[1]*10**6\nfor i in range(999):\n if a[i]:\n for j in range(i*2,m,i):a[j]=0\nfor e in sys.stdin:print(sum(a[:int(e)+1]))\n", "jacc_sim": 0.96875, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [75, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\na=[0,0]+[1]*10**6\nfor i in range(999):\n if a[i]:a[i*2::i]=[0 for j in[0]*len(a[i*2::i])]\nfor e in sys.stdin:print(sum(a[:int(e)+1]))\n", "neg": "import sys\na=[0,0]+[1]*10**6\nfor i in range(999):\n if a[i]:a[i*2::i]=[0 for j in a[i*2::i]]\nfor e in sys.stdin:print(int(e)-len([i for i in a[:int(e)]if i]))\n", "jacc_sim": 0.9375, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [77, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\na=[0,0]+[1]*10**6\nfor i in range(999):\n if a[i]:a[i*2::i]=[0]*len(a[i*2::i])\nfor e in sys.stdin:print(sum(a[:int(e)+1]))\n", "neg": "import sys\na=[0,0,1]+[1,0]*5*10**5\nfor i in range(4,999):\n if a[i]:a[i*2::i]=[0]*len(a[i*2::i])\nfor e in sys.stdin:print(sum(a[:int(e)+1]))\n", "jacc_sim": 0.90625, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [71, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nm=166666;s=[1]*m;t=[1]*m\nfor i in range(m):\n for j in range(2):\n if (s[i],t[i])[j]:\n k=6*i+[5,7][j];n=[i+k,k-i-2]\n s[n[j]::k]=[0]*len(s[n[j]::k])\n t[n[1-j]::k]=[0]*len(t[n[1-j]::k])\nfor e in map(int,sys.stdin):\n print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])\n", "neg": "import sys\nm=166666;s=[1]*m;t=[1]*m\nfor i in range(m):\n for j in range(2):\n if (s[i],t[i])[j]:\n k=6*i+[5,7][j];n=[i+k,k-i-2]\n s[n[i]::k]=[0]*len(s[n[i]::k])\n t[n[1-i]::k]=[0]*len(t[n[1-i]::k])\nfor e in map(int,sys.stdin):\n print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])\n", "jacc_sim": 1.0, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [183, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\na=[1]*500000\nfor i in range(3,999,2):\n if a[i//2]:a[i*i//2::i]=[0]*((499999-i*i//2)//i+1)\nfor e in map(int,sys.stdin):print([e-1,sum(a[:(e+1)//2])][e>3])\n", "neg": "import sys\na=[1]*500000\n[a[(i*i)//2::i]=[0]*len(a[(i*i)//2::i])for i in range(3,999,2)if a[i//2]]\n[print([e-1,sum(a[:(e+1)//2])][e>3])for e in map(int,sys.stdin)]\n", "jacc_sim": 0.9428571428571428, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [93, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00009", "p_user": "u821561321", "n_user": "u500396695", "pos": "import sys\narray = []\nfor i in sys.stdin:\n array.append(int(i))\nm=max(array)\nprime = [1]*(m+1)\nprime[0] = prime[1] = 0\nfor i in range(2,int(m**0.5)+1):\n if prime[i] == 1:\n for j in range(i*i, m+1, i):\n prime [j] = 0\nfor i in range(len(array)):\n print(sum(prime[:array[i] + 1]))\n", "neg": "import sys\n??\nary=[]\nfor i in sys.stdin:\n????????ary.append(int(i))\nm = max(ary)\nprime=[1] * (m + 1)\nprime[0] = prime[1] = 0\nfor i in range(2, int(m ** 0.5) + 1):\n????????if prime[i] == 1:\n????????????????for j in range(i*2, m + 1, i):\n????????????????????????prime[j] = 0\nfor i in range(len(ary)):\n????????print(sum(prime[:ary[i] + 1]))", "jacc_sim": 0.9117647058823529, "nl": "Title: Prime Number\n\nWrite a program that takes an integer 'n' as input and outputs the count of prime numbers less than or equal to 'n'. A prime number has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, and 7.\n\nInput:\nThe input consists of several datasets. Each dataset contains an integer 'n' (1 <= n <= 999,999) on a separate line. The number of datasets is less than or equal to 30.\n\nOutput:\nFor each dataset, print the number of prime numbers.\n\nSample Input:\n10\n3\n11\n\nOutput for the Sample Input:\n4\n2\n5", "before_after_length": [134, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u915343634", "n_user": "u379956761", "pos": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n \nimport sys\nimport math\n \nn = int(input())\n \nfor data in sys.stdin:\n x1, y1, x2, y2, x3, y3 = map(float, data.split())\n a1 = x2 - x1\n b1 = y2 - y1\n a2 = x3 - x1\n b2 = y3 - y1\n px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))\n py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))\n r = math.sqrt(px * px + py * py)\n px += x1\n py += y1\n print(\"{0:.3f} {1:.3f} {2:.3f}\".format(px, py, r))", "neg": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\n\nn = int(input())\n\nfor data in sys.stdin:\n if n <= 0:\n break\n n--\n x1, y1, x2, y2, x3, y3 = map(float, data.split())\n a1 = x2 - x1\n b1 = y2 - y1\n a2 = x3 - x1\n b2 = y3 - y1\n px = (b2 * (a1 * a1 + b1 * b1) - b1 * (a2 * a2 + b2 * b2)) / (2 * (a1 * b2 - a2 * b1))\n py = (a1 * (a2 * a2 + b2 * b2) - a2 * (a1 * a1 + b1 * b1)) / (2 * (a1 * b2 - a2 * b1))\n r = math.sqrt(px * px + py * py)\n px += x1\n py += y1\n print(\"{0:.3f} {1:.3f} {2:.3f}\".format(px, py, r))", "jacc_sim": 0.9482758620689655, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [286, 297], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u896025703", "n_user": "u896025703", "pos": "import math\n\ndef solve(a,b,c,d,e,f):\n\tx = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))\n\ty = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))\n\tr = math.hypot(x-a, y-b) \n\treturn x,y,r\n\nn = int(input())\nfor _ in range(n):\n\ta,b,c,d,e,f = map(float, input().split())\n\tx,y,r = solve(a,b,c,d,e,f)\n\tprint(\"{:.3f} {:.3f} {:.3f}\".format(x, y, r))", "neg": "import math\n\ndef solve(a,b,c,d,e,f):\n\tx = - (d*(f**2+e**2-b**2-a**2) + b*(-f**2-e**2) + b**2*f + a**2*f + d**2*(b-f) + c**2*(b-f)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a-2*e))\n\ty = (c*(f**2+e**2-b**2-a**2) + a*(-f**2-e**2) + b**2*e + a**2*e + d**2*(a-e) + c**2*(a-e)) / (c*(2*f-2*b) - 2*a*f + 2*b*e + d*(2*a - 2*e))\n\tr = math.hypot(x-a, y-b) \n\treturn x,y,r\n\nn = int(input())\nfor _ in range(n):\n\ta,b,c,d,e,f = map(float, input().split())\n\tx,y,r = solve(a,b,c,d,e,f)\n\tx += 0.0005\n\ty += 0.0005\n\tr += 0.0005\n\tprint(\"{:.3f} {:.3f} {:.3f}\".format(x, y, r))", "jacc_sim": 0.9545454545454546, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [332, 356], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u252368621", "n_user": "u252368621", "pos": "import math\n\nn=int(input())\nfor i in range(n):\n deta=[float(i) for i in input().split()]\n h1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)\n h2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)\n h3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)\n sub=(h1+h2+h3)/2\n s=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))\n sum=((h1*h2*h3)/s)/4\n a=2*deta[2]-2*deta[0]\n b=2*deta[3]-2*deta[1]\n c=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))\n d=2*deta[4]-2*deta[2]\n e=2*deta[5]-2*deta[3]\n f=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))\n \n x=(e*c-b*f)/(a*e-b*d)\n y=(a*f-c*d)/(a*e-b*d)\n print(\"{0:.3f} {1:.3f} {2:.3f}\".format(x,y,sum))", "neg": "import math\ndeta=[float(i) for i in input().split()]\nh1=math.sqrt((deta[2]-deta[0])**2+(deta[3]-deta[1])**2)\nh2=math.sqrt((deta[4]-deta[2])**2+(deta[5]-deta[3])**2)\nh3=math.sqrt((deta[0]-deta[4])**2+(deta[1]-deta[5])**2)\nsub=(h1+h2+h3)/2\ns=math.sqrt(sub*(sub-h1)*(sub-h2)*(sub-h3))\nsum=((h1*h2*h3)/s)/4\n\na=2*deta[2]-2*deta[0]\nb=2*deta[3]-2*deta[1]\nc=-(deta[0]**2+deta[1]**2-(deta[2]**2)-(deta[3]**2))\nd=2*deta[4]-2*deta[2]\ne=2*deta[5]-2*deta[3]\nf=-(deta[2]**2+deta[3]**2-(deta[4]**2)-(deta[5]**2))\n\nx=(e*c-b*f)/(a*e-b*d)\ny=(a*f-c*d)/(a*e-b*d)\nprint(\"{0:.3f} {1:.3f} {2:.3f}\".format(x,y,sum))", "jacc_sim": 0.9411764705882353, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [436, 404], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u519227872", "n_user": "u519227872", "pos": "from math import sqrt\nn = int(input())\n\nfor i in range(n):\n l = input()\n x1,y1,x2,y2,x3,y3=map(float,l.split(' '))\n a_2 = (x1 - x2)**2 + (y1 - y2)**2\n b_2 = (x2 - x3)**2 + (y2 - y3)**2\n c_2 = (x3 - x1)**2 + (y3 - y1)**2\n cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)\n sin_a_2 = 1 - cos_a_2\n r = round(sqrt(a_2/sin_a_2)/2,3)\n a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)\n b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)\n c = (y2 - y1)*(x3 - x1)\n d = (y3 - y1)*(x2 - x1)\n py = round((a-b)/(c-d)/2,3) + 0\n a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)\n b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)\n c = (x2 - x1)*(y3 - y1)\n d = (x3 - x1)*(y2 - y1)\n px = round((a-b)/(c-d)/2,3) + 0\n print('%.3f %.3f %.3f' %(px, py, r))", "neg": "from math import sqrt\nn = int(input())\n\nfor i in range(n):\n l = input()\n x1,y1,x2,y2,x3,y3=map(float,l.split(' '))\n a_2 = (x1 - x2)**2 + (y1 - y2)**2\n b_2 = (x2 - x3)**2 + (y2 - y3)**2\n c_2 = (x3 - x1)**2 + (y3 - y1)**2\n cos_a_2 = (b_2 + c_2 - a_2)**2/(4* b_2 * c_2)\n sin_a_2 = 1 - cos_a_2\n r = round(sqrt(a_2/sin_a_2)/2,3)\n a = (x1**2 - x3**2 + y1**2 - y3**2)*(x2 - x1)\n b = (x1**2 - x2**2 + y1**2 - y2**2)*(x3 - x1)\n c = (y2 - y1)*(x3 - x1)\n d = (y3 - y1)*(x2 - x1)\n py = round((a-b)/(c-d)/2,3)\n a = (x1**2 - x3**2 + y1**2 - y3**2)*(y2 - y1)\n b = (x1**2 - x2**2 + y1**2 - y2**2)*(y3 - y1)\n c = (x2 - x1)*(y3 - y1)\n d = (x3 - x1)*(y2 - y1)\n px = round((a-b)/(c-d)/2,3)\n print('%s %s %s' %(px, py, r))", "jacc_sim": 0.9444444444444444, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [466, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u150984829", "n_user": "u150984829", "pos": "for _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print('%.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))\n", "neg": "for _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n x=((a*a+b*b)*(d-f)+(c*c+d*d)*(f-b)+(e*e+f*f)*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=((a*a+b*b)*(c-e)+(c*c+d*d)*(e-a)+(e*e+f*f)*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print('.3f %.3f %.3f'%(x,y,((x-a)**2+(y-b)**2)**.5))\n", "jacc_sim": 1.0, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [205, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u150984829", "n_user": "u150984829", "pos": "import math\nfor _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n s,t,u=a*a+b*b,c*c+d*d,e*e+f*f\n x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print('%.3f %.3f %.3f'%(x,y,math.hypot(x-a,y-b)))\n", "neg": "import math\nfor _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n s,t,u=a*a+b*b,c*c+d*d,e*e+f*f\n x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print('%.3f %.3f %.3f'%(x,y,math.hypot\u001c(x-a,y-b)))\n", "jacc_sim": 1.0, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [184, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u150984829", "n_user": "u150984829", "pos": "for _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n s,t,u=a*a+b*b,c*c+d*d,e*e+f*f\n x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print(f'{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5:.3f}')\n", "neg": "for _ in[0]*int(input()):\n a,b,c,d,e,f=map(float,input().split())\n s,t,u=a*a+b*b,c*c+d*d,e*e+f*f\n x=(s*(d-f)+t*(f-b)+u*(b-d))/2/(a*(d-f)+c*(f-b)+e*(b-d))\n y=(s*(c-e)+t*(e-a)+u*(a-c))/2/(b*(c-e)+d*(e-a)+f*(a-c))\n print(f'{x:.3f} {y:.3f} {((x-a)**2+(y-b)**2)**.5.3f}')\n", "jacc_sim": 1.0, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [190, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u724548524", "n_user": "u724548524", "pos": "import math\nfor _ in range(int(input())):\n x1, y1, x2, y2, x3, y3 = map(float, input().split())\n p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))\n q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))\n r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)\n p = abs(p) if abs(p) < 10e-5 else p\n q = abs(q) if abs(q) < 10e-5 else q\n print(\"{:.3f} {:.3f} {:.3f}\".format(p, q, r))\n", "neg": "import math\nfor _ in range(int(input())):\n x1, y1, x2, y2, x3, y3 = map(float, input().split())\n p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))\n q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))\n r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)\n p = abs(p) if abs(p) < 10e-5 else p\n q = abs(q) if abs(q) < 10e-5 else q\n print(\"{:.4f} {:.4f} {:.4f}\".format(p, q, r))\n", "jacc_sim": 0.9555555555555556, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [318, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00010", "p_user": "u427219397", "n_user": "u724548524", "pos": "import math\nfor _ in range(int(input())):\n x1, y1, x2, y2, x3, y3 = map(float, input().split())\n p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))\n q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))\n r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)\n print(\"{:.3f} {:.3f} {:.3f}\".format(p, q, r))\n\n", "neg": "import math\nfor _ in range(int(input())):\n x1, y1, x2, y2, x3, y3 = map(float, input().split())\n p = ((y1-y3)*(y1**2 -y2**2 +x1**2 -x2**2) -(y1-y2)*(y1**2 -y3**2 +x1**2 -x3**2)) / 2/ ((y1-y3)*(x1-x2)-(y1-y2)*(x1-x3))\n q = ((x1-x3)*(x1**2 -x2**2 +y1**2 -y2**2) -(x1-x2)*(x1**2 -x3**2 +y1**2 -y3**2)) / 2/ ((x1-x3)*(y1-y2)-(x1-x2)*(y1-y3))\n r = math.sqrt((x1 - p) ** 2 + (y1 - q) ** 2)\n print(\"{:.4f} {:.4f} {:.4f}\".format(p, q, r))\n", "jacc_sim": 0.9487179487179487, "nl": "Title: Circumscribed Circle of A Triangle\n\nWrite a program to calculate and print the central coordinate (px, py) and the radius r of a circumscribed circle of a triangle constructed by three points (x1, y1), (x2, y2), and (x3, y3) on a plane surface.\n\nInput:\nThe input consists of several datasets. The first line contains the number of datasets, n. Each dataset consists of the coordinates x1, y1, x2, y2, x3, y3 in a single line. All inputs are real numbers.\n\nOutput:\nFor each dataset, print px, py, and r separated by a space in a line. The solution should be rounded off to three decimal places.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3 \u2264 100\nn \u2264 20\n\nSample Input:\n1\n0.0 0.0 2.0 0.0 2.0 2.0\n\nOutput for the Sample Input:\n1.000 1.000 1.414", "before_after_length": [279, 278], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u379956761", "n_user": "u379956761", "pos": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\n\nw = int(input())\nn = int(input())\ns = []\n\nfor _ in range(n):\n x = input().split(',')\n s.append((int(x[0]), int(x[1])))\n\nresult = [i for i in range(1, w+1)]\n\nfor x, y in s:\n result[x-1], result[y-1] = result[y-1], result[x-1]\n\nfor x in result:\n print(x)", "neg": "#!/usr/bin/env python\n#-*- coding:utf-8 -*-\n\nimport sys\nimport math\n\nw = int(input())\nn = int(input())\ns = []\n\nfor _ in range(n):\n x = input().split(',')\n s.append((int(x[0]), int(x[1])))\n\nresult = [i for i in range(1, w+1)]\nprint(len(result))\n\nfor x, y in s:\n result[x-1], result[y-1] = result[y-1], result[x-1]\n\nfor x in result:\n print(x)", "jacc_sim": 0.9772727272727273, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [153, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u775586391", "n_user": "u775586391", "pos": "w = int(input())\nn = int(input())\nl = [i for i in range(1,w+1)]\nwhile n > 0:\n a,b = map(int,input().split(','))\n l[a-1],l[b-1] = l[b-1],l[a-1]\n n -= 1\nfor i in l:\n print(i)", "neg": "w = int(raw_input())\nn = int(raw_input())\nl = [i for i in range(1,w+1)]\nwhile n > 0:\n a,b = map(int,raw_input().split(','))\n l[a-1],l[b-1] = l[b-1],l[a-1]\n n -= 1\nfor i in l:\n print(i)", "jacc_sim": 0.9333333333333333, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [95, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u300946041", "n_user": "u300946041", "pos": "# -*- coding: utf-8 -*-\n\n\ndef solve():\n w = int(input())\n n = int(input())\n l = [i for i in range(1, w+1)]\n\n for _ in range(n):\n a, b = map(int, input().split(','))\n a -= 1\n b -= 1\n l[a], l[b] = l[b], l[a]\n\n print(*l, sep='\\n')\n\nsolve()", "neg": "# -*- coding: utf-8 -*-\n\ndef solve():\n w = int(input())\n n = int(input())\n l = [i for i in range(1, w+1)]\n\n for _ in range(n):\n a, b = map(int, input().split(','))\n l[a], l[b] = l[b], l[a]\n\n print(*l, sep='\\n')\n\nsolve()", "jacc_sim": 1.0, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [122, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u301729341", "n_user": "u301729341", "pos": "w = int(input())\nn = int(input())\nAmi = []\nNum = []\nfor i in range(n):\n Ami.append(list(map(int,input().split(\",\"))))\nfor i in range(1,w+1):\n pos = i\n for j in range(n):\n if pos == Ami[j][0]:\n pos = Ami[j][1]\n elif pos == Ami[j][1]:\n pos = Ami[j][0]\n Num.append([pos,i])\nNum = sorted(Num)\nfor k in range(0,w):\n print(Num[k][1])", "neg": "w = int(input())\nn = int(input())\nAmi = []\nNum = []\nfor i in range(n):\n Ami.append(list(map(int,input().split(\",\"))))\nprint(Ami)\nfor i in range(1,w+1):\n pos = i\n for j in range(n):\n if pos == Ami[j][0]:\n pos = Ami[j][1]\n elif pos == Ami[j][1]:\n pos = Ami[j][0]\n Num.append([pos,i])\nNum = sorted(Num)\nfor k in range(0,w):\n print(Num[k][1])", "jacc_sim": 1.0, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [159, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u922489088", "n_user": "u922489088", "pos": "import sys\nn = int(sys.stdin.readline().rstrip())\nm = int(sys.stdin.readline().rstrip())\nl = []\nfor i in range(m):\n l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))\nfor i in range(n):\n cur = i+1\n for d in l[::-1]:\n if cur in d:\n cur = d[0] if cur == d[1] else d[1]\n print(cur)", "neg": "import sys\nn = int(sys.stdin.readline().rstrip())\nm = int(sys.stdin.readline().rstrip())\nl = []\nfor i in range(m):\n l.append(list(map(int, sys.stdin.readline().rstrip().split(','))))\nprint(l)\nfor i in range(n):\n cur = i+1\n for d in l[::-1]:\n if cur in d:\n cur = d[0] if cur == d[1] else d[1]\n print(cur)", "jacc_sim": 1.0, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [130, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u354053070", "n_user": "u354053070", "pos": "w = int(input())\nnums = list(range(w + 1))\nfor _ in range(int(input())):\n a, b = map(int, input().split(\",\"))\n nums[a], nums[b] = nums[b], nums[a]\nfor x in nums[1:]:\n print(x)", "neg": "w = int(input())\nn = int(input())\nnums = list(range(w + 1))\nfor _ in range(n):\n a, b = map(int, input().split(\", \"))\n nums[a], nums[b] = nums[b], nums[a]\nfor x in nums[1:]:\n print(x)", "jacc_sim": 0.9629629629629629, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [79, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u584777171", "n_user": "u584777171", "pos": "user = input()\nw = int(user)\nuser = input()\nn = int(user)\na = []\nb = []\nnow = 0\nfor i in range(n):\n user = input()\n users = user.split(\",\")\n a.append(int(users[0]))\n b.append(int(users[1]))\n\nfor j in range(1, w+1):\n now = j\n for k in reversed(range(n)):\n if now == a[k]:\n now = b[k]\n elif now == b[k]:\n now = a[k]\n print(now)", "neg": "user = input()\nw = int(user)\nuser = input()\nn = int(user)\na = []\nb = []\nnow = 0\nfor i in range(n):\n user = input()\n users = user.split(\",\")\n a.append(int(users[0]))\n b.append(int(users[1]))\nprint(a)\nprint(b)\n\nfor j in range(1, w+1):\n now = j\n for k in reversed(range(n)):\n if now == a[k]:\n now = b[k]\n elif now == b[k]:\n now = a[k]\n print(now)", "jacc_sim": 1.0, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [153, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u069727578", "n_user": "u069727578", "pos": "tate =int(input())\nyoko=int(input())\narr = [i+1 for i in range(tate)]\nfor j in range(yoko):\n rep1,rep2=input().split(\",\")\n rep1=int(rep1)-1\n rep2=int(rep2)-1\n arr[rep1],arr[rep2] = arr[rep2],arr[rep1]\n\nfor k in range(tate):\n print(arr[k])\n", "neg": "tate =int(input());\nyoko=int(input());\narr = [i+1 for i in range(tate)]\nfor j in range(yoko):\n rep1,rep2=input().split();\n rep1=int(rep1)-1\n rep2=int(rep2)-1\n arr[rep1],arr[rep2] = arr[rep2],arr[rep1]\nfor k in range(tate):\n print(arr[k])\n", "jacc_sim": 0.9285714285714286, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [119, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u166871988", "n_user": "u166871988", "pos": "w=int(input())\nl=[i+1 for i in range(w)]\nn=int(input())\nfor _ in range(n):\n a,b=[int(i)-1 for i in input().split(\",\")]\n t=l[a]\n l[a]=l[b]\n l[b]=t\nfor i in l:\n print(i)\n", "neg": "w=int(input())\nl=[i+1 for i in range(w)]\nn=int(input())\nfor _ in range(n):\n a,b=[int(i)-1 for i in input().split(\",\")]\n t=l[a]\n l[a]=l[b]\n l[b]=t\nfor i in w:\n print(i)\n", "jacc_sim": 1.0, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [95, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u150984829", "n_user": "u150984829", "pos": "a=list(range(int(input())+1))\nfor _ in[0]*int(input()):s,t=map(int,input().split(','));a[s],a[t]=a[t],a[s]\n[print(s)for s in a if s]\n", "neg": "a=list(range(int(input())+1))\nfor _ in[0]*int(input()):s,t=map(int,input().split(','));a[s],a[t]=a[t],a[s]\nfor s in a:s*print(s)\n", "jacc_sim": 0.9642857142857143, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [71, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u138224929", "n_user": "u138224929", "pos": "w = int(input())\nn = int(input())\n\namida = []\n\nfor i in range(0,w+1):\n amida.append(i)\n \nfor i in range(n):\n ai,bi = map(int,input().split(\",\"))\n aa = amida[ai]\n bb = amida[bi]\n amida[ai] = bb\n amida[bi] = aa\n \nfor i in range(1,w+1):\n print(amida[i])\n \n", "neg": "w = int(input())\nn = int(input())\n\namida = []\n\nfor i in range(0,w+1):\n amida.append(i)\n \nfor i in range(n):\n ai,bi = map(int,input().split())\n aa = amida[ai]\n bb = amida[bi]\n amida[ai] = bb\n amida[bi] = aa\n \nfor i in range(1,w+1):\n print(w[i])\n \n", "jacc_sim": 0.9655172413793104, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [136, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u158979022", "n_user": "u273843182", "pos": "w = int(input())\nn = int(input())\nl = list(range(1, w+1))\nfor i in range(n):\n a, b = map(int, input().split(','))\n a -= 1\n b -= 1\n l[a], l[b] = l[b], l[a]\nfor i in l:\n print(i)\n", "neg": "w = int(input())\nn = int(input())\nl = list(range(1,w+1))\nfor i in range(n):\n\ta,b = map(int,input().split(','))\n\ta -= 1\n\tb - = 1\n\tl[a],l[b] = l[b],l[a]\nfor x in l:\n\tprint(x)\n\n\n", "jacc_sim": 0.9642857142857143, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [92, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00011", "p_user": "u205574338", "n_user": "u075836834", "pos": "w=int(input())\nn=int(input())\nlst=[i+1 for i in range(w)]\nfor i in range(n):\n x,y=map(int,input().split(\",\"))\n lst[x-1],lst[y-1]=lst[y-1],lst[x-1]\nfor i in lst:print(i)\n\n", "neg": "w=int(input())\nn=int(input())\nA=[int(i+1) for i in range(w)]\nfor i in range(n):\n\tx,y=map(int,input().split(','))\n\tA[x-1],A[y-1]=A[y-1],A[x-1]\nprint(A)", "jacc_sim": 0.9259259259259259, "nl": "Drawing Lots\n\nLet's play Amidakuji. In the following example, there are five vertical lines and four horizontal lines. The horizontal lines can intersect (jump across) the vertical lines.\n\nIn the starting points (top of the figure), numbers are assigned to vertical lines in ascending order from left to right. At the first step, 2 and 4 are swapped by the first horizontal line which connects the second and fourth vertical lines (we call this operation (2, 4)). Likewise, we perform (3, 5), (1, 2), and (3, 4), then obtain \"4 1 2 5 3\" at the bottom.\n\nYour task is to write a program which reads the number of vertical lines w and configurations of horizontal lines and prints the final state of the Amidakuji. In the starting points, numbers 1, 2, 3, ..., w are assigned to the vertical lines from left to right.\n\nInput\nw\nn\na1,b1\na2,b2\n.\n.\nan,bn\n\nw (w \u2264 30) is the number of vertical lines. n (n \u2264 30) is the number of horizontal lines. A pair of two integers ai and bi delimited by a comma represents the i-th horizontal line.\n\nOutput\nThe number which should be under the 1st (leftmost) vertical line\nThe number which should be under the 2nd vertical line\n:\nThe number which should be under the w-th vertical line\n\nSample Input\n5\n4\n2,4\n3,5\n1,2\n3,4\n\nOutput for the Sample Input\n4\n1\n2\n5\n3", "before_after_length": [89, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00012", "p_user": "u572790226", "n_user": "u572790226", "pos": "import sys\n\ndef crossMulti(p1, p2):\n return p1[0] * p2[1] - p1[1] * p2[0]\n \nlines = sys.stdin.readlines()\nfor line in lines:\n Zd = []\n x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())\n Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]\n Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]\n for p in range(3):\n Zd.append(crossMulti(Ps[p], Px[p]))\n Zd = [x > 0 for x in Zd]\n\n if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):\n print('YES')\n else:\n print('NO')\n ", "neg": "import sys\n\ndef crossMulti(p1, p2):\n return p1[0] * p2[1] - p1[1] * p2[0]\n \nlines = sys.stdin.readlines()\nfor line in lines:\n Zd = []\n x1, y1, x2, y2, x3, y3, xp, yp = map(float, line.split())\n Ps = [(x2-x1, y2-y1),(x3-x2, y3-y2),(x1-x3, y1-y3)]\n Px = [(xp-x1, yp-y1),(xp-x2, yp-y2),(xp-x3, yp-y3)]\n for p in range(3):\n Zd.append(crossMulti(Ps[p], Px[p]))\n Zd = [x > 0 for x in Zd]\n\n if (Zd[0] and Zd[1] and Zd[2]) or not(Zd[0] or Zd[1] or Zd[2]):\n print('Yes')\n else:\n print('No')\n ", "jacc_sim": 0.9310344827586207, "nl": "Title: A Point in a Triangle\n\nThere is a triangle formed by three points (x1, y1), (x2, y2), (x3, y3) on a plane. Write a program that prints \"YES\" if a point P (xp, yp) is inside the triangle, and \"NO\" if not.\n\nInput:\nInput consists of several datasets, each containing x1, y1, x2, y2, x3, y3, xp, and yp. All inputs are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3, xp, yp \u2264 100\nLength of each side of a triangle \u2265 1.0\nDistance between P and each side of a triangle \u2265 0.001\n\nOutput:\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input:\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [283, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00012", "p_user": "u536280367", "n_user": "u536280367", "pos": "import sys\n\ndef cross_product(a, b):\n ax, ay = a\n bx, by = b\n return ax * by - ay * bx\n\n\ndef sub(a, b):\n a1, a2 = a\n b1, b2 = b\n return b1 - a1, b2 - a2\n\n\ndef judge(p1, p2, p3, pp):\n\n cnt = 0\n for a, b in ((p1, p2), (p2, p3), (p3, p1)):\n vec1 = sub(a, b)\n vec2 = sub(a, pp)\n if cross_product(vec2, vec1) > 0:\n cnt += 1\n if cnt == 0 or cnt == 3:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == '__main__':\n for line in sys.stdin:\n inputs = [float(s) for s in line.split()]\n p1 = (inputs.pop(0), inputs.pop(0))\n p2 = (inputs.pop(0), inputs.pop(0))\n p3 = (inputs.pop(0), inputs.pop(0))\n pp = (inputs.pop(0), inputs.pop(0))\n judge(p1, p2, p3, pp)\n", "neg": "def cross_product(a, b):\n ax, ay = a\n bx, by = b\n return ax * by - ay * bx\n\n\ndef sub(a, b):\n a1, a2 = a\n b1, b2 = b\n return b1 - a1, b2 - a2\n\n\ndef judge(p1, p2, p3, pp):\n\n cnt = 0\n for a, b in ((p1, p2), (p2, p3), (p3, p1)):\n vec1 = sub(a, b)\n vec2 = sub(a, pp)\n if cross_product(vec2, vec1) >= 0:\n cnt += 1\n if cnt == 0 or cnt == 3:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nif __name__ == '__main__':\n inputs = [float(s) for s in input().split()]\n p1 = (inputs.pop(0), inputs.pop(0))\n p2 = (inputs.pop(0), inputs.pop(0))\n p3 = (inputs.pop(0), inputs.pop(0))\n pp = (inputs.pop(0), inputs.pop(0))\n\n judge(p1, p2, p3, pp)\n", "jacc_sim": 0.9137931034482759, "nl": "Title: A Point in a Triangle\n\nThere is a triangle formed by three points (x1, y1), (x2, y2), (x3, y3) on a plane. Write a program that prints \"YES\" if a point P (xp, yp) is inside the triangle, and \"NO\" if not.\n\nInput:\nInput consists of several datasets, each containing x1, y1, x2, y2, x3, y3, xp, and yp. All inputs are real numbers. Input ends with EOF. The number of datasets is less than or equal to 100.\n\nConstraints:\n-100 \u2264 x1, y1, x2, y2, x3, y3, xp, yp \u2264 100\nLength of each side of a triangle \u2265 1.0\nDistance between P and each side of a triangle \u2265 0.001\n\nOutput:\nFor each dataset, print \"YES\" or \"NO\" in a line.\n\nSample Input:\n0.0 0.0 2.0 0.0 2.0 2.0 1.5 0.5\n0.0 0.0 1.0 4.0 5.0 3.0 -1.0 3.0\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [328, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u648595404", "n_user": "u567380442", "pos": "import sys\ncars = []\nfor line in sys.stdin:\n car = int(line)\n if car:\n cars.append(car)\n else:\n print(cars.pop())", "neg": "import sys\ncars = []\nfor line in sys.stdin:\n car = int(line)\n if car:\n cars.append(num)\n else:\n print(cars.pop())", "jacc_sim": 0.9545454545454546, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [50, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u776559258", "n_user": "u776559258", "pos": "# coding: utf-8\nL=[]\nwhile True:\n try:\n n=int(input())\n if n==0:\n print(L[-1])\n L.pop()\n else:\n L.append(n)\n except EOFError:\n break", "neg": "# coding: utf-8\nL=[]\nwhile True:\n try:\n n=int(input())\n if n==0:\n L.pop()\n else:\n L.append(n)\n except EOFError:\n break", "jacc_sim": 0.9310344827586207, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [68, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u203261375", "n_user": "u203261375", "pos": "arr = []\n\nwhile True:\n try:\n n = int(input())\n except:\n break\n\n if n == 0:\n print(arr[-1])\n arr = arr[:-1]\n else:\n arr.append(n)", "neg": "while True:\n try:\n n = int(input())\n except:\n break\n\n arr = []\n if n == 0:\n print(arr[-1])\n arr = arr[:-1]\n else:\n arr.append(n)", "jacc_sim": 1.0, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u150984829", "n_user": "u150984829", "pos": "a=[]\nwhile 1:\n try:n=int(input());a.append(n)if n else print(a.pop())\n except:break\n", "neg": "a=[]\nwhile 1:\n try:n=int(input());a.append(e)if e else print(a.pop())\n except:break\n", "jacc_sim": 0.9565217391304348, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u503263570", "n_user": "u503263570", "pos": "import sys\na=[int(i)for i in sys.stdin]\n\nb=[]\nfor j in a:\n\tif j == 0:\n\t\tprint(b.pop())\n\telse:\n\t\tb.append(j)\n\n", "neg": "import sys\na=[int(i)for i in sys.stdin]\n\nb=[]\nprint(a)\nfor j in a:\n\tif j == 0:\n\t\tprint(b.pop())\n\telse:\n\t\tb.append(j)\n", "jacc_sim": 1.0, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [58, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00013", "p_user": "u436634575", "n_user": "u777299405", "pos": "stack = []\n\nwhile True:\n try:\n n = int(input())\n except:\n break\n\n if n:\n stack.append(n)\n else:\n print(stack.pop())", "neg": "stack = []\nwhile True:\n try:\n n = int(input)\n except:\n break\n stack.append(n) if n else print(stack.pop())", "jacc_sim": 1.0, "nl": "Title: Switching Railroad Cars\n\nThe figure shows railway tracks for reshuffling cars. The rail tracks end at the bottom, with the top-left track used for entrance and the top-right track for exit. Ten cars, numbered from 1 to 10, use the rail tracks.\n\nMovement of cars is simulated as follows:\n- Entry of a car is represented by its number.\n- Exit of a car is represented by 0.\n\nFor example, the sequence:\n1\n6\n0\n8\n10\n\ndemonstrates that car 1 and car 6 enter in that order, car 6 exits, and then car 8 and car 10 enter.\n\nWrite a program to simulate the comings and goings of cars represented by the sequence of car numbers. The program should read the sequence of car numbers and 0, and print the numbers of cars that exit from the rail tracks in order. Initially, there are no cars on the rail tracks. It can be assumed that 0 will not be given when there are no cars on the rail tracks.\n\nInput:\n- Car number\n- Car number or 0\n- ...\n- Car number or 0\n\nThe number of input lines is less than or equal to 100.\n\nOutput:\nFor each 0, print the car number.\n\nSample Input:\n1\n6\n0\n8\n10\n0\n0\n0\n\nOutput for the Sample Input:\n6\n10\n8\n1", "before_after_length": [53, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u032662562", "n_user": "u032662562", "pos": "def integral(d):\n n = 600//d\n s = 0.0\n for i in range(n):\n s += (d*i)**2\n return(s*d)\n\nif __name__ == '__main__':\n while True:\n try: \n d = int(input())\n print(int(integral(d)))\n except:\n break", "neg": "def integral(d):\n print(\"d=%d\" % d)\n n = 600//d\n print(\"n=%d\" % n)\n \n s = 0.0\n for i in range(n):\n s += (d*i)**2\n return(s*d)\n\nif __name__ == '__main__':\n while True:\n try: \n d = int(input())\n print(int(integral(d)))\n except:\n break", "jacc_sim": 0.9705882352941176, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [94, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u810591206", "n_user": "u810591206", "pos": "import sys\n \ndef f(x):\n return x ** 2\n \ndef integral(d):\n s = 0\n for i in range(600 // d - 1):\n s += f(d * (i + 1)) * d\n return s\n \nlines = sys.stdin.readlines()\nfor line in lines:\n print(integral(int(line)))", "neg": "import sys\n\ndef f(x):\n return x ** 2\n\ndef integral(d):\n s = f(d) * d\n for i in range(600 // d - 1):\n s += f(d * (i + 1)) * d\n return s\n\nlines = sys.stdin.readlines()\nfor line in lines:\n print(integral(int(line)))", "jacc_sim": 0.96875, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [90, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u354053070", "n_user": "u354053070", "pos": "import sys\n\nfor line in sys.stdin:\n d = int(line)\n S = 0\n for x in range(0, 600, d):\n S += (x ** 2) * d\n print(S)", "neg": "import sys\n\nfor line in sys.stdin:\n d = int(line)\n S = 0\n for x in range(1, 600, d):\n S += (x ** 2) * d\n print(S)", "jacc_sim": 0.9583333333333334, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [54, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u424041287", "n_user": "u424041287", "pos": "t = 0\nwhile t == 0:\n try:\n d = int(input())\n except:\n break\n else:\n print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))", "neg": "t = 0\nwhile t == 0:\n\ttry:\n\t\td = int(input())\n\texcept:\n\t\tbreak\n\telse:\n print(sum(d * ((i * d) ** 2) for i in range(int(600/d))))", "jacc_sim": 1.0, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [60, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u136916346", "n_user": "u136916346", "pos": "import sys\nS=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])\n[print(i) for i in [S(int(line)) for line in sys.stdin]]\n\n", "neg": "import sys\nS=lambda s:sum([((i*s)**2)*s for i in range(int(600/s))])\n[print(S[int(line)]) for line in sys.stdin]\n\n", "jacc_sim": 1.0, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [56, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00014", "p_user": "u847467233", "n_user": "u847467233", "pos": "# AOJ 0014 Integral\n# Python3 2018.6.10 bal4u\n\nimport sys\n\nfor d in sys.stdin:\n a = int(d)\n print(sum(a * x**2 for x in range(a, 600, a)))\n", "neg": "# AOJ 0014 Integral\n# Python3 2018.6.10 bal4u\n\nimport sys\n\nfor d in sys.stdin:\n print(sum(x**2 for x in range(int(d), 600, int(d))))\n", "jacc_sim": 0.9333333333333333, "nl": "Write a program to calculate the area of a shape defined by the equations y = x^2, y = 0, and x = 600. The area can be approximated by summing the areas of many rectangles within the shape. The program should read an integer d (a divisor of 600) and output the area s for each dataset.", "before_after_length": [66, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u990228206", "n_user": "u990228206", "pos": "n=int(input())\nfor i in range(n):\n a=int(input())\n b=int(input())\n if a+b>=10**80:print(\"overflow\")\n else:print(a+b)\n", "neg": "n=int(input())\nfor i in range(n):\n a=int(input())\n b=int(input())\n if a+b>=10**79:print(\"overflow\")\n else:print(a+b)\n", "jacc_sim": 0.9166666666666666, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [57, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u886122084", "n_user": "u886122084", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nn = int(input())\nans = []\nfor _ in range(n):\n a = int(input())\n b = int(input())\n s = a+b\n if s > 10**80-1:\n ans.append(\"overflow\")\n else:\n ans.append(str(s))\nprint(\"\\n\".join(ans))\n\n", "neg": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nn = int(input())\nans = []\nfor _ in range(n):\n a = int(input())\n b = int(input())\n s = a+b\n if s >= 10**79:\n ans.append(\"overflow\")\n else:\n ans.append(str(s))\nprint(\"\\n\".join(ans))\n\n", "jacc_sim": 0.9111111111111111, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [117, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u408260374", "n_user": "u408260374", "pos": "n = int(input())\nfor _ in range(n):\n a = sum([int(input()) for _ in range(2)])\n print(a if a < 10**80 else 'overflow')", "neg": "n = int(input())\nfor _ in range(n):\n a = sum([int(input()) for _ in range(n)])\n print(a if a < 10**80 else 'overflow')", "jacc_sim": 0.96, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [47, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u408260374", "n_user": "u408260374", "pos": "for _ in range(int(input())):\n a=int(input())+int(input())\n print(a if a < 10**80 else 'overflow')", "neg": "for _ in range(int(input()):\n a=int(input())+int(input())\n print(a if a < 10**80 else 'overflow')", "jacc_sim": 1.0, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [39, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\nn = int(f.readline())\nfor _ in range(n):\n a = f.readline().strip()\n b = f.readline().strip()\n c = int(a) + int(b)\n c = '{}'.format(c)\n print(c if len(c) <= 80 else 'overflow')", "neg": "import sys\nf = sys.stdin\nn = int(f.readline())\nfor _ in range(n):\n a = f.readline().strip()\n b = f.readline().strip()\n c = int(a) + int(b)\n c = '{}'.format(c)\n print(c if len(c) else 'overflow')", "jacc_sim": 0.9375, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [87, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u071010747", "n_user": "u071010747", "pos": "# -*- coding:utf-8 -*-\n\ndef main():\n for i in range(int(input())):\n a=int(input())+int(input())\n if a>=10**80:\n print(\"overflow\")\n else:\n print(a)\n \n \nif __name__ == '__main__':\n main()", "neg": "# -*- coding:utf-8 -*-\n\ndef main():\n for i in range(int(input())):\n a=int(input())+int(input())\n if a>=10**80:\n print(\"overflow\")\n print(a)\n \n \nif __name__ == '__main__':\n main()", "jacc_sim": 0.9666666666666667, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [87, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u529386725", "n_user": "u529386725", "pos": "import math\n\nN = int(input())\nfor i in range(N):\n a = int(input())\n b = int(input())\n if a >= 10 ** 80 or b >= 10 ** 80 or a + b >= 10 ** 80:\n print(\"overflow\")\n else:\n print(a + b)", "neg": "import math\n\nN = int(input())\nfor i in range(N):\n a = int(input())\n b = int(input())\n if a >= 10**79 or b >= 10 ** 79 or a + b >= 10 ** 79:\n print(\"overflow\")\n else:\n print(a + b)", "jacc_sim": 0.9259259259259259, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u881668270", "n_user": "u881668270", "pos": "n = int(input())\n\nfor i in range(0, n):\n a = int(input())\n b = int(input())\n if a + b >= 10 ** 80:\n print(\"overflow\")\n elif a >= 10 ** 80:\n print(\"overflow\")\n elif b >= 10 ** 80:\n print(\"overflow\")\n else :\n print(a + b)", "neg": "n = int(input())\n\nfor i in range(0, n):\n a = int(input())\n b = int(input())\n if a + b > 10 ** 80:\n print(\"overflow\")\n elif a > 10 ** 80:\n print(\"overflow\")\n elif b > 10 ** 80:\n print(\"overflow\")\n else :\n print(a + b)", "jacc_sim": 1.0, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [92, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u589886885", "n_user": "u579833671", "pos": "n = int(input())\n\nfor i in range(n):\n a = input()\n b = input()\n c = int(a) + int(b)\n if len(a) > 80 or len(b) > 80 or len(str(c)) > 80:\n print('overflow')\n else:\n print(c)", "neg": "n = input()\nfor i in range(n):\n a = input()\n b = input()\n c = str(a + b)\n if(len(c) >= 80):\n print(\"overflow\")\n else:\n print(c)", "jacc_sim": 0.92, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [82, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u364509382", "n_user": "u364509382", "pos": "n = int(input())\nfor i in range(n):\n\ts = int(input())+int(input())\n\tif len(str(s))>80:\n\t\tprint(\"overflow\")\n\telse:\n\t\tprint(s)", "neg": "n = int(input())\nfor i in range(n):\n\ts = int(input())+int(input())\n\tif len(str(s))>=10**80:\n\t\tprint(\"overflow\")\n\telse:\n\t\tprint(s)", "jacc_sim": 0.9166666666666666, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [57, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u058433718", "n_user": "u058433718", "pos": "# ?????\u00b6??????????\u00b1???????????????\u00b0??????\nimport sys\n\ndef main():\n n = int(sys.stdin.readline().strip())\n\n for _ in range(n):\n x = sys.stdin.readline().strip()\n y = sys.stdin.readline().strip()\n\n if len(x) > 80 or len(y) > 80:\n print('overflow')\n else:\n ans = int(x) + int(y)\n if len(str(ans)) > 80:\n print('overflow')\n else:\n print(ans)\n\nif __name__ == '__main__':\n main()", "neg": "# ?????\u00b6??????????\u00b1???????????????\u00b0??????\nimport sys\n\ndef main():\n n = int(sys.stdin.readline().strip())\n\n for _ in range(n):\n x = sys.stdin.readline().strip()\n y = sys.stdin.readline().strip()\n\n if len(x) > 80 or len(y) > 80:\n print('overflow')\n else:\n ans = int(x) + int(y)\n if len(str(ans)) > 80:\n print('overflow')\n else:\n print(x + y)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [169, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u252368621", "n_user": "u252368621", "pos": "times=int(input())\nfor i in range(times):\n a=int(input())\n b=int(input())\n if len(str(a))<=80 and len(str(b))<=80 and len(str(a+b))<=80:\n print(a+b)\n else: print(\"overflow\")", "neg": "times=int(input())\nfor i in range(times):\n a=int(input())\n b=int(input())\n if len(str(a))<80 and len(str(b))<80 and len(str(a+b))<80:\n print(a+b)\n else: print(\"overflow\")", "jacc_sim": 1.0, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [81, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u123687446", "n_user": "u123687446", "pos": "upper = 10**80\nn = int(input())\nfor i in range(n):\n n1 = int(input())\n n2 = int(input())\n if n1 >= upper or n2 >= upper:\n print(\"overflow\")\n continue\n print( n1 + n2 if n1+n2 < upper else \"overflow\")", "neg": "upper = 10**81\nn = int(input())\nfor i in range(n):\n n1 = int(input())\n n2 = int(input())\n if n1 >= upper or n2 >= upper:\n print(\"overflow\")\n continue\n print( n1 + n2 if n1+n2 < upper else \"overflow\")", "jacc_sim": 0.9285714285714286, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u661290476", "n_user": "u661290476", "pos": "n=int(input())\nfor _ in range(n):\n a=int(input())\n b=int(input())\n ab=a+b\n print(ab if ab<10**80 else \"overflow\")", "neg": "n=int(input())\nfor _ in range(n):\n a=int(input())\n b=int(input())\n ab=a+b\n print(ab if ab<10**79 else \"overflow\")", "jacc_sim": 0.92, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [52, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u078042885", "n_user": "u078042885", "pos": "for _ in range(int(input())):\n a=int(input())+int(input())\n print(['overflow',a][a<10**80])", "neg": "for _ in range(int(input())):\n a=int(input())+int(input())\n print([a,'overflow'][a>10**80])", "jacc_sim": 0.9130434782608695, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [39, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u957840591", "n_user": "u957840591", "pos": "N = int(input())\nA = []\nB = []\nfor i in range(N):\n a = int(input())\n b = int(input())\n A.append(a)\n B.append(b)\n\nfor i in range(N):\n if A[i] >= 10 ** 80 or B[i] >= 10 ** 80:\n print(\"overflow\")\n elif A[i] + B[i] >= 10 ** 80:\n print(\"overflow\")\n else:\n print(str(A[i] + B[i]))", "neg": "N=int(input())\nA=[]\nB=[]\nfor i in range(N):\n a = int(input())\n b = int(input())\n A.append(a)\n B.append(b)\n\nfor i in range(N):\n if A[i] >= 10 ** 79 or B[i] >= 10 ** 79:\n print(\"overflow\")\n elif A[i] + B[i]>= 10 ** 79:\n print(\"overflow\")\n else:\n print(str(A[i]+B[i]))", "jacc_sim": 0.9393939393939394, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [132, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u700120734", "n_user": "u881668270", "pos": "n = int(input())\nfor i in range(0, n) :\n a = int(input())\n b = int(input())\n sum = a + b\n if len(str(sum)) > 80 :\n print(\"overflow\")\n else :\n print(sum)", "neg": "n = int(input())\n\nfor i in range(0, n):\n a = int(input())\n b = int(input())\n if len(str(a + b)) > 80\n print(\"overflow\")\n elif len(str(a)) > 80:\n print(\"overflow\")\n elif len(str(b)) > 80\n print(\"overflow\")\n else :\n print(a + b)", "jacc_sim": 0.9259259259259259, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [68, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u024715419", "n_user": "u991537731", "pos": "n = int(input())\nfor i in range(n):\n x = int(input())\n y = int(input())\n if len(str(x + y)) > 80:\n print(\"overflow\")\n else:\n print(x + y)\n\n", "neg": "\nn = int(input())\nfor i in range(n):\n x = int(input())\n y = int(input())\n ans = x + y\n if len(str(ans)) > 80 :\n print 'overflow'\n else:\n print ans", "jacc_sim": 0.9583333333333334, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u553148578", "n_user": "u553148578", "pos": "n = int(input())\nfor i in range(n):\n\tx = int(input())\n\ty = int(input())\n\tans = x + y\n\tif(ans < 10**80):\n\t\tprint(ans)\n\telse:\n\t\tprint(\"overflow\")\n", "neg": "n = int(input())\nfor i in range(n):\n\tx = int(input())\n\ty = int(input())\n\tans = x + y\n\tif(ans <= 10**80):\n\t\tprint(ans)\n\telse:\n\t\tprint(\"overflow\")\n", "jacc_sim": 1.0, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [66, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u717526540", "n_user": "u364509382", "pos": "n = int(input())\nfor _ in range(n):\n a = int(input())\n b = int(input())\n s = a + b\n if len(str(s)) > 80:\n print(\"overflow\")\n else:\n print(s)\n\n", "neg": "n = int(input())\nfor i in range(n):\n\ts = int(input())+int(input())\n\tif len(str(s))>=80:\n\t\tprint(\"overflow\")\n\telse\n\t\tprint(a+b)", "jacc_sim": 0.92, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [67, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00015", "p_user": "u252700163", "n_user": "u364509382", "pos": "n = int(input())\n\nfor i in range(n):\n a = int(input())\n b = int(input())\n s = a+b\n\n if len(str(s)) > 80:\n print(\"overflow\")\n else:\n print(s)\n", "neg": "n = int(input())\nfor i in range(n):\n\ts = int(input())+int(input())\n\tif len(str(s))>=80:\n\t\tprint(\"overflow\")\n\telse:\n\t\tprint(s)", "jacc_sim": 0.9166666666666666, "nl": "Title: National Budget\n\nA country has a budget exceeding 81 trillion yen, which conventional 32-bit signed integers cannot represent. Your task is to create a program that reads two integers (both greater than or equal to zero) and prints their sum. If the given integers or their sum have more than 80 digits, the program should print \"overflow\".\n\nInput:\nThe input consists of multiple datasets. The first line contains the number of datasets, N (1 \u2264 N \u2264 50). Each dataset consists of two lines, each containing an integer with at most 100 digits.\n\nOutput:\nFor each dataset, the program should print the sum of the given integers on a new line.\n\nSample Input:\n6\n1000\n800\n9999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n1\n99999999999999999999999999999999999999999999999999999999999999999999999999999999\n0\n100000000000000000000000000000000000000000000000000000000000000000000000000000000\n1\n100000000000000000000000000000000000000000", "before_after_length": [68, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u744114948", "n_user": "u744114948", "pos": "import math\nx=0\ny=0\nangle=0\nwhile True:\n r,c=map(int, input().split(\",\"))\n if r == c == 0:\n break\n\n y += r*math.cos(angle)\n x += r*math.sin(angle)\n angle -= c*math.pi/180\n\n\nprint(int(-x))\nprint(int(y))", "neg": "import math\nx=0\ny=0\nangle=0\nwhile True:\n r,c=map(int, input().split(\",\"))\n if r == c == 0:\n break\n\n x += r*math.cos(-angle)\n y += r*math.sin(-angle)\n angle += c\n\nprint(x)\nprint(y)", "jacc_sim": 0.90625, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [98, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u775586391", "n_user": "u775586391", "pos": "import math\nx,y,r = 0,0,90\nwhile True:\n m,n = map(int,input().split(','))\n if (m,n) == (0,0):\n break\n y += m * math.sin(math.radians(r))\n x += m * math.cos(math.radians(r))\n r -= n\nprint(int(x))\nprint(int(y))", "neg": "import math\nx,y,r = 0,0,90\nwhile True:\n m,n = map(int,raw_input().split(','))\n if (m,n) == (0,0):\n break\n y += m * math.sin(math.radians(r))\n y\n x+= m * math.cos(math.radians(r))\n r -= n\nprint(int(x))\nprint(int(y))", "jacc_sim": 0.9375, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [104, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u777299405", "n_user": "u777299405", "pos": "import math\n\nx, y, r = 0, 0, 90\nwhile True:\n d, t = map(float, input().split(\",\"))\n if d == t == 0:\n break\n x += d * math.cos(math.radians(r))\n y += d * math.sin(math.radians(r))\n r -= t\nprint(int(x))\nprint(int(y))", "neg": "import math\n\nx, y, r = 0, 0, 90\nwhile True:\n d, t = map(float, input().split(\",\"))\n if d == t == 0:\n break\n x += r * math.cos(math.radians(r))\n y += r * math.sin(math.radians(r))\n r -= t\nprint(int(x))\nprint(int(y))", "jacc_sim": 1.0, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [100, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u966364923", "n_user": "u966364923", "pos": "import math\nx = 0\ny = 0\nr = 90\nwhile True:\n d,t=map(int, input().split(','))\n if d==0 and t==0:\n print(int(x),int(y),sep='\\n')\n exit()\n x += math.cos(math.radians(r)) * d\n y += math.sin(math.radians(r)) * d\n r -= t", "neg": "import math\nx = 0\ny = 0\nr = 90\nwhile True:\n d,t=map(int, input().split())\n if d==0 and t==0:\n print(int(x),int(y),sep='\\n')\n exit()\n x += math.cos(math.radians(r)) * d\n y += math.sin(math.radians(r)) * d\n r -= t", "jacc_sim": 1.0, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [105, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u896025703", "n_user": "u896025703", "pos": "import math\n\ndef calc(x, y, r, d, nd):\n\tx = x + r * math.cos(math.radians(d))\n\ty = y + r * math.sin(math.radians(d))\n\td -= nd\n\treturn x, y, d\n\nx = y = 0\nd = 90\n\nwhile True:\n\tr, nd = map(int, input().split(\",\"))\n\tif r == nd == 0: break\n\tx, y, d = calc(x, y, r, d, nd)\n\nprint(int(x))\nprint(int(y))", "neg": "import math\n\ndef calc(x, y, r, d, nd):\n\tx = x + r * math.cos(math.radians(d))\n\ty = y + r * math.sin(math.radians(d))\n\td -= nd\n\treturn x, y, d\n\nx = y = 0\nd = 90\n\nwhile True:\n\tr, nd = map(int, input().split(\",\"))\n\tif r == nd == 0: break\n\tx, y, d = calc(x, y, r, d, nd)\n\nprint(int(x), \"\\n\", int(y))", "jacc_sim": 0.9444444444444444, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [145, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u123687446", "n_user": "u123687446", "pos": "from math import sin,cos,pi\nx = 0\ny = 0\nca = 90\nwhile True:\n d, a = list(map(int, input().split(\",\")))\n if d or a:\n x += d*cos(ca*pi/180)\n y += d*sin(ca*pi/180)\n ca -= a\n else:\n break\n\nprint(int(x))\nprint(int(y))", "neg": "from math import sin,cos,pi\nx = 0\ny = 0\nca = 90\nwhile True:\n d, a = list(map(int, input().split(\",\")))\n if d or a:\n x += d*cos(ca*pi/180)\n y += d*sin(ca*pi/180)\n ca -= a\n else:\n break\n\nprint(\"{0:.0f}\".format(x))\nprint(\"{0:.0f}\".format(y))", "jacc_sim": 0.9024390243902439, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [104, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u728901930", "n_user": "u728901930", "pos": "import sys\nimport math as mas\n\nx,y,d=0,0,90\nfor t in sys.stdin:\n\ta,b=map(int,t.split(','))\n\tif a==b==0:break\n\tx+=a*mas.cos(mas.radians(d))\n\ty+=a*mas.sin(mas.radians(d))\n\td-=b\nprint(int(x))\nprint(int(y))\n#for i in sys.stdin:\n#\ta,b=map(int,i.split())\n#\tprint(gcd(a,b),lcm(a,b))", "neg": "import sys\nimport math as mas\n\nx,y,d=0,0,90\nfor t in sys.stdin:\n\ta,b=map(int,t.split(','))\n\tif a==b==0:break\n\tx+=a*mas.cos(mas.radians(d))\n\ty+=a*mas.sin(mas.radians(d))\n\td-=b\nprint(x)\nprint(y)\n#for i in sys.stdin:\n#\ta,b=map(int,i.split())\n#\tprint(gcd(a,b),lcm(a,b))", "jacc_sim": 1.0, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [153, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u957840591", "n_user": "u957840591", "pos": "from math import *\n\nx = 0\ny = 0\nD = []\nA = []\nsum_a = -90\nwhile True:\n d, a = map(int, input().split(\",\"))\n if a == 0 and d == 0:\n break\n else:\n D.append(d)\n A.append(a)\nfor i in range(len(A)):\n x = x + D[i] * cos(sum_a * pi / 180)\n y = y - D[i] * sin(sum_a * pi / 180)\n if abs(x-round(x))<10**(-7):\n x=round(x)\n if abs(y - round(y)) < 10 ** (-7):\n y=round(y)\n sum_a += A[i]\nif x >= 0:\n print(floor(x))\nelse:\n print(floor(x)+1)\nif y >= 0:\n print(floor(y))\nelse:\n print(floor(y)+1)", "neg": "from math import *\n\nx = 0\ny = 0\nD = []\nA = []\nsum_a = -90\nwhile True:\n d, a = map(int, input().split(\",\"))\n if a == 0 and d == 0:\n break\n else:\n D.append(d)\n A.append(a)\nfor i in range(len(A)):\n x = x + D[i] * cos(sum_a * pi / 180)\n y = y - D[i] * sin(sum_a * pi / 180)\n if abs(x-round(x))<10**(-7):\n x=round(x)\n if abs(y - round(y)) < 10 ** (-7):\n y=round(y)\n sum_a += A[i]\nprint(floor(x))\nprint(floor(y))", "jacc_sim": 0.9629629629629629, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [253, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u184989919", "n_user": "u184989919", "pos": "import sys\nimport math\n\ndef TreasureHunt():\n x,y=(0.0,0.0)\n alpha=90\n \n for line in sys.stdin:\n a,b=list(map(int,line.split(',')))\n if a==0 and b==0:\n break\n \n x+=a*math.cos(alpha/180.0*math.pi)\n y+=a*math.sin(alpha/180.0*math.pi)\n alpha=(alpha-b+360)%360\n\n print(int(x))\n print(int(y))\n\n \n \n \nTreasureHunt()", "neg": "import sys\nimport math\n\ndef TreasureHunt():\n x,y=(0.0,0.0)\n alpha=90\n \n for line in sys.stdin:\n a,b=list(map(int,line.split(',')))\n if a==0 and b==0:\n break\n \n x+=a*math.cos(alpha/180.0*math.pi)\n y+=a*math.sin(alpha/180.0*math.pi)\n alpha=(alpha-b+360)%360\n\n print(int(x),'\\n',int(y))\n\n \n \n \nTreasureHunt()", "jacc_sim": 0.9545454545454546, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [163, 162], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u203261375", "n_user": "u203261375", "pos": "from math import cos, sin, pi\n\ntreasure_x, treasure_y = 0, 0\nangle = pi / 2\n\nwhile True:\n d, a = map(int, input().split(','))\n\n if d == 0 and a == 0:\n break\n\n treasure_x += d * cos(angle)\n treasure_y += d * sin(angle)\n\n angle -= a * pi / 180\n\nprint(int(treasure_x))\nprint(int(treasure_y))", "neg": "from math import cos, sin, pi\n\ntreasure_x, treasure_y = 0, 0\nangle = pi / 2\n\nwhile True:\n d, a = map(int, input().split(','))\n\n if d == 0 and a == 0:\n break\n\n treasure_x += d * cos(angle)\n treasure_y += d * sin(angle)\n\n angle += a * 2 * pi / 180\n\n\nprint(int(treasure_x))\nprint(int(treasure_y))", "jacc_sim": 0.9714285714285714, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [123, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u150984829", "n_user": "u150984829", "pos": "import cmath,math,sys\nz=0;p=90\nfor e in sys.stdin:\n r,d=map(int,e.split(','))\n z+=cmath.rect(r,math.radians(p))\n p-=d\nprint(int(z.real),'\\n',int(z.imag),sep='')\n", "neg": "import cmath,math,sys\nz=0;p=90\nfor e in sys.stdin:\n r,d=map(int,e.split(','))\n z+=cmath.rect(r,math.radians(p))\n p-=d\nprint(int(z.real),'\\n',int(z.imag))\n", "jacc_sim": 0.9714285714285714, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [83, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u553148578", "n_user": "u553148578", "pos": "import math\nx = y = n= 0\nwhile True:\n\td,a = map(int,input().split(','))\n\tif d == a == 0: break\n\tx += d*math.sin(math.radians(n))\n\ty += d*math.cos(math.radians(n))\n\tn+=a\nprint(*map(int,(x,y)),sep='\\n')\n", "neg": "import math\nx = y = n= 0\nwhile True:\n\td,a = map(int,input().split(','))\n\tif d == a == 0: break\n\tx += d*math.sin(math.radians(n))\n\ty += d*math.cos(math.radians(n))\n\tn+=a\nprint(*map(int,(x,y)),sep=',')\n", "jacc_sim": 0.967741935483871, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [99, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u724548524", "n_user": "u724548524", "pos": "import math\nx = y = 0\nh = math.radians(90)\nwhile True:\n d, t = map(int, input().split(\",\"))\n if d == t == 0:\n break\n x += d * math.cos(h)\n y += d * math.sin(h)\n h -= math.radians(t)\nprint(int(x))\nprint(int(y))\n", "neg": "import math\nx = y = 0\nh = math.radians(90)\nwhile True:\n d, t = map(int, input().split(\",\"))\n if d == t == 0:\n break\n x += d * math.cos(h)\n y += d * math.sin(h)\n h -= math.radians(t)\nprint(\"{} {}\".format(int(x), int(y)))\n", "jacc_sim": 0.9117647058823529, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [100, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00016", "p_user": "u436634575", "n_user": "u436634575", "pos": "from math import radians\nfrom cmath import rect\n\nz = 0\ndeg = 90\nwhile True:\n r, d = map(float, input().split(','))\n if r == d == 0: break\n z += rect(r, radians(deg))\n deg -= d\nprint(int(z.real))\nprint(int(z.imag))", "neg": "from math import radians\nfrom cmath import rect\n\nz = 0\ndeg = 90\nwhile True:\n r, d = map(float, input().split(','))\n if r == d == 0: break\n z += rect(r, radians(deg))\n deg -= d\nprint(int(z.real), int(z.imag))", "jacc_sim": 1.0, "nl": "Title: Treasure Hunt\n\nWhen a boy was cleaning up after his grandfather's passing, he found an old paper with instructions. The paper indicated that starting from \"Sanbonmatsu,\" one should take a number of steps equal to the first integer and then turn clockwise by degrees equivalent to the second integer. His grandmother mentioned that Sanbonmatsu was once at the center of town, but now, due to buildings and congestion, it's impossible to follow the paper's instructions exactly. The task is to write a program to find the treasure indicated on the paper.\n\nFor simplicity, 1 step is equivalent to 1 meter. The input consists of pairs of two integers, d (the first integer) and t (the second integer), separated by a comma. The program should print the coordinates (x, y) of the endpoint, where the treasure is located x meters to the east and y meters to the north from the center of town.\n\nConstraints: d \u2264 100, -180 \u2264 t \u2264 180.\n\nInput:\nA sequence of pairs of integers d and t, ending with \"0,0\".\n\nOutput:\nPrint the integer portion of x and y in a line respectively.\n\nSample Input:\n56,65\n97,54\n64,-4\n55,76\n42,-27\n43,80\n87,-86\n55,-6\n89,34\n95,5\n0,0\n\nOutput for the Sample Input:\n171\n-302", "before_after_length": [84, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u244742296", "n_user": "u244742296", "pos": "import string\nimport sys\n\nalpha = string.ascii_lowercase\n\nfor line in sys.stdin:\n for i in range(len(alpha)):\n cipher_str = \"\"\n for s in line:\n if s in alpha:\n cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]\n else:\n cipher_str += s\n\n if \"the\" in cipher_str or \"this\" in cipher_str or \"that\" in cipher_str:\n print(cipher_str, end=\"\")\n break\n else:\n print(line, end=\"\")", "neg": "import string\nimport sys\n\nline = input()\nalpha = string.ascii_lowercase\n\nfor line in sys.stdin:\n for i in range(len(alpha)):\n cipher_str = \"\"\n for s in line:\n if s in alpha:\n cipher_str += alpha[(alpha.index(s)+i) % len(alpha)]\n else:\n cipher_str += s\n\n if (\"the\" or \"this\" or \"that\") in cipher_str:\n print(cipher_str)\n break\n else:\n print(line)", "jacc_sim": 0.9166666666666666, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [145, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u650459696", "n_user": "u650459696", "pos": "while True:\n try:\n b = input()\n except:\n break\n if 'the' in b or 'this' in b or 'that' in b:\n print(b)\n for i in range(1,26):\n c = ''\n for j in b:\n if(j == 'z'):\n c += ('a')\n elif(str.isalpha(j) == 1):\n c += (chr(ord(j) + 1))\n else:\n c += j\n if 'the' in c or 'this' in c or 'that' in c:\n print(c)\n break\n b = c", "neg": "while True:\n try:\n b = input()\n except:\n break\n if 'the' in c or 'this' in c or 'that' in b:\n print(c)\n for i in range(1,26):\n c = ''\n for j in b:\n if(j == 'z'):\n c += ('a')\n elif(str.isalpha(j) == 1):\n c += (chr(ord(j) + 1))\n else:\n c += j\n if 'the' in c or 'this' in c or 'that' in c:\n print(c)\n break\n b = c", "jacc_sim": 1.0, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [159, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u681787924", "n_user": "u681787924", "pos": "#!/usr/bin/env python\nimport sys\nimport re\n\ndef move(char, num):\n if ord(char) + num <= ord('z'):\n return ord(char) + num\n else:\n return ord(char) + num - (ord('z') - ord('a') + 1)\n\ndef shift(s, num):\n new = \"\"\n for i in range(0, len(s)):\n if s[i].isalpha():\n new += str(chr(move(s[i], num)));\n else:\n new += s[i]\n return new\n\ndef decrypt(s):\n for i in range(0, 26):\n decrypted = shift(s, i)\n if re.search('the|this|that', decrypted):\n return decrypted\n\nif __name__ == '__main__':\n lines = []\n for line in sys.stdin:\n lines.append(line)\n for line in lines:\n print(decrypt(line), end=\"\")", "neg": "#!/usr/bin/env python\nimport sys\nimport re\n\ndef move(char, num):\n if ord(char) + num <= ord('z'):\n return ord(char) + num\n else:\n return ord(char) + num - (ord('z') - ord('a') + 1)\n\ndef shift(s, num):\n new = \"\"\n for i in range(0, len(s)):\n if s[i].isalpha():\n new += str(chr(move(s[i], num)));\n else:\n new += s[i]\n return new\n\ndef decrypt(s):\n for i in range(1, 26):\n decrypted = shift(s, i)\n if re.search('the|this|that', decrypted):\n print(decrypted)\n\nif __name__ == '__main__':\n for line in sys.stdin:\n print(decrypt(line))", "jacc_sim": 0.9516129032258065, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [244, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u519227872", "n_user": "u519227872", "pos": "from sys import stdin\n\ndef ascii2num(ascii):\n return ord(ascii) - 96\n\ndef num2ascii(num):\n return chr(num + 96)\n\ndef slide(word,num):\n return ''.join([num2ascii((ascii2num(ascii) - num) % 26 + 1) if ascii != '.' else '.' for ascii in word])\n\ndef includekeyword(words):\n for word in words:\n if word in keywords:\n return True\n return False\n\nkeywords = ['the', 'this', 'that']\n\ndecode = []\nfor row in stdin:\n words = row.split()\n for num in range(1,27):\n tmp = [slide(word,num) for word in words]\n if includekeyword(tmp):\n decode = tmp\n print(' '.join(decode))\n break", "neg": "def ascii2num(ascii):\n return ord(ascii) - 96\n\ndef num2ascii(num):\n return chr(num + 96)\n\ndef slide(word,num):\n return ''.join([num2ascii((ascii2num(ascii) + num) % 26) if ascii != '.' else '.' for ascii in word])\n\ndef includekeyword(words):\n for word in words:\n if word in keywords:\n return True\n return False\n\nkeywords = ['the', 'this', 'that']\n\n\ndecode = []\nfor row in stdin:\n words = row.split()\n for num in range(1,27):\n tmp = [slide(word,num) for word in words]\n if includekeyword(tmp):\n decode = tmp\n print(' '.join(decode))", "jacc_sim": 0.9215686274509803, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [199, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u184989919", "n_user": "u184989919", "pos": "\nimport string\nimport sys\n\ndef CaesarCipher():\n \n low=string.ascii_lowercase\n \n for cry in sys.stdin: \n for i in range(1,27):\n \n dec=cry.translate(str.maketrans(low,low[i:]+low[:i]))\n \n if 'this' in dec or 'that' in dec or 'the' in dec:\n print(dec[:-1])\n \n \n \nCaesarCipher()", "neg": "\nimport string\ndef CaesarCipher():\n \n low=string.ascii_lowercase\n \n for cry in sys.stdin: \n for i in range(1,27):\n \n dec=cry.translate(str.maketrans(low,low[i:]+low[:i]))\n \n if 'this' in dec or 'that' in dec or 'the' in dec:\n print(dec)\n \n \n \nCaesarCipher()", "jacc_sim": 0.972972972972973, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [122, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u546285759", "n_user": "u546285759", "pos": "import string\nstrings = string.ascii_lowercase\nclues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)]\nwhile True:\n try:\n data = input()\n except:\n break\n for word in data.split():\n if len(word) == 4 or 3:\n dif = 19 - (ord(word[0]) - 97)\n enc = [\"\" for _ in range(26)]\n for k, v in zip([i for i in range(dif, dif+26)], strings):\n enc[k%26] = v\n candidate = tuple(enc.index(c) for c in word)\n try:\n clues.index(candidate)\n except:\n continue\n break\n ans = \"\"\n for c in data:\n try:\n ans += strings[enc.index(c)]\n except:\n ans = ans + \".\" if c == \".\" else ans + \" \"\n print(ans)\n\n", "neg": "import string\nstrings = string.ascii_lowercase\nclues = [(19, 7, 8, 18), (19, 7, 0, 19), (19, 7, 4)]\nwhile True:\n try:\n data = input()\n except:\n break\n for word in data.split():\n if len(word) == 4 or 3:\n dif = 19 - (ord(word[0]) - 97)\n enc = [\"\" for _ in range(26)]\n for k, v in zip([i for i in range(dif, dif+26)], strings):\n enc[k%26] = v\n candidate = tuple(enc.index(c) for c in word)\n try:\n clues.index(candidate)\n except:\n continue\n break\n ans = \"\"\n for c in data:\n try:\n ans += strings[enc.index(c)]\n except:\n ans += \" \"\n print(ans)\n\n", "jacc_sim": 0.9824561403508771, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [242, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00017", "p_user": "u436634575", "n_user": "u299798926", "pos": "import sys\na = 'abcdefghijklmnopqrstuvwxyz'\n\nfor s in sys.stdin:\n for n in range(1, 27):\n t = s[:-1].translate(str.maketrans(a, a[n:] + a[:n]))\n if 'the' in t or 'this' in t or 'that' in t: break\n print(t)", "neg": "import sys\na = 'abcdefghijklmnopqrstuvwxyz'\n \nfor s in sys.stdin:\n\tfor n in range(1, 27):\n\t\tt = s[:-1].translate(str.maketrans(a, a[n:] + a[:n]))\n\t\tprint(t)\n\t\tif 'the' in t or 'this' in t or 'that' in t: break\n\tprint(t)", "jacc_sim": 1.0, "nl": "Caesar Cipher is a simple encryption method where each letter in the text is replaced by a letter a fixed number of positions down the alphabet. For example, with a shift of 1, 'a' becomes 'b', 'b' becomes 'c', 'y' becomes 'z', and 'z' becomes 'a'. Write a program to decrypt a text encrypted by Caesar Cipher. The number of shifts is secret and varies by dataset, but the decoded text will include either \"the\", \"this\", or \"that\". Input consists of several datasets, each with encrypted texts. The input ends with EOF. The text contains lowercase letters, periods, spaces, and end-of-lines, with lines being at most 80 characters long. Output the decoded texts in a line.", "before_after_length": [94, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00020", "p_user": "u548155360", "n_user": "u548155360", "pos": "# coding=utf-8\n\nsentence = input()\nsentence = sentence.upper()\nprint(sentence)", "neg": "# coding=utf-8\n\nsentence = input()\nsentence.upper()\nprint(sentence)", "jacc_sim": 1.0, "nl": "Capitalize\n\nWrite a program that replaces all the lowercase letters in a given text with their corresponding capital letters.\n\nInput\n\nA line of text containing lowercase letters, periods, and spaces. The text has a maximum length of 200 characters.\n\nOutput\n\nPrint the converted text.\n\nSample Input\n\nthis is a pen.\n\nOutput for the Sample Input\n\nTHIS IS A PEN.", "before_after_length": [24, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00020", "p_user": "u814278309", "n_user": "u452212317", "pos": "x = input()\nprint(x.upper())\n", "neg": "x = input().upper()\nprint x", "jacc_sim": 1.0, "nl": "Capitalize\n\nWrite a program that replaces all the lowercase letters in a given text with their corresponding capital letters.\n\nInput\n\nA line of text containing lowercase letters, periods, and spaces. The text has a maximum length of 200 characters.\n\nOutput\n\nPrint the converted text.\n\nSample Input\n\nthis is a pen.\n\nOutput for the Sample Input\n\nTHIS IS A PEN.", "before_after_length": [12, 9], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00021", "p_user": "u964040941", "n_user": "u964040941", "pos": "N = int(input())\nEPS = 1e-9\nfor i in range(N):\n x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())\n if x2 == x1 and x4 == x3:\n print('YES')\n continue\n elif x2 == x1 or x4 == x3:\n print('NO')\n continue\n f = (y2 - y1) / (x2 - x1)\n g = (y4 - y3) / (x4 - x3)\n if g - EPS <= f <= g + EPS:\n print('YES')\n else:\n print('NO')", "neg": "N = int(input())\nEPS = 1e-6\nfor i in range(N):\n x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())\n if x2 == x1 and x4 == x3:\n print('YES')\n continue\n elif x2 == x1 or x4 == x3:\n print('NO')\n continue\n f = abs((y2 - y1) / (x2 - x1))\n g = abs((y4 - y3) / (x4 - x3))\n if g - EPS <= f <= g + EPS:\n print('YES')\n else:\n print('NO')", "jacc_sim": 0.9333333333333333, "nl": "The task is to create a program that determines if two given lines, AB and CD, are parallel. The input consists of the number of datasets followed by the coordinates of the four points for each dataset. The program should output \"YES\" if the lines are parallel and \"NO\" if they are not. The coordinates are real numbers with at most 5 digits after the decimal point, ranging from -100 to 100.", "before_after_length": [173, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00021", "p_user": "u901080241", "n_user": "u901080241", "pos": "for i in range(int(input())):\n x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())\n det = abs((y1-y2) * (x3-x4) - (x1-x2) * (y3-y4))\n if det<1e-12 :\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "for i in range(int(input())):\n x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())\n det = (y1-y2) * (x3-x4) - (x1-x2) * (y3-y4)\n if det<1e-12 :\n print(\"YES\")\n else:\n print(\"NO\")", "jacc_sim": 0.9722222222222222, "nl": "The task is to create a program that determines if two given lines, AB and CD, are parallel. The input consists of the number of datasets followed by the coordinates of the four points for each dataset. The program should output \"YES\" if the lines are parallel and \"NO\" if they are not. The coordinates are real numbers with at most 5 digits after the decimal point, ranging from -100 to 100.", "before_after_length": [107, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00021", "p_user": "u179694829", "n_user": "u179694829", "pos": "from fractions import Fraction\n\ndef sroap(x1,y1,x2,y2):\n\tif x2 - x1 == 0:\n\t\treturn float(\"inf\")\n\telse:\n\t\treturn Fraction(y2 - y1,x2 - x1)\n\t\t\nN = int(input())\nfor n in range(N):\n\tAx,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))\n\tif sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "neg": "from fractions import Fraction\ndef sroap(x1,y1,x2,y2):\n\tif x2 - x1 == 0:\n\t\treturn float(\"inf\")\n\telse:\n\t\treturn Fraction(y2 - y1,x2 - x1)\n\t\t\nN = int(input())\nfor n in range(N):\n\tAx,Ay,Bx,By,Cx,Cy,Dx,Dy = map(lambda x: round(x * 10 ** 5),(map(float,input().split())))\n\tif sroap(Ax,Ay,Bx,By) == sroap(Cx,Cy,Dx,Dy):\n ????????????print(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "jacc_sim": 0.9803921568627451, "nl": "The task is to create a program that determines if two given lines, AB and CD, are parallel. The input consists of the number of datasets followed by the coordinates of the four points for each dataset. The program should output \"YES\" if the lines are parallel and \"NO\" if they are not. The coordinates are real numbers with at most 5 digits after the decimal point, ranging from -100 to 100.", "before_after_length": [181, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00021", "p_user": "u319725914", "n_user": "u436634575", "pos": "n = int(input())\nfor _ in range(n):\n x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split())\n if abs((x2-x1)*(y4-y3)-(x4-x3)*(y2-y1)) <= 10**(-10): print(\"YES\")\n else: print(\"NO\")\n", "neg": "n = int(input())\nfor i in range(n):\n x1, y1, x2, y2, x3, y3, x4, y4 = map(float, input().split())\n print('YES' if abs(x2 - x1)*(y4 - y3) - (x4 - x3)*(y2 - y1)) < 1e-10 else 'NO')", "jacc_sim": 0.918918918918919, "nl": "The task is to create a program that determines if two given lines, AB and CD, are parallel. The input consists of the number of datasets followed by the coordinates of the four points for each dataset. The program should output \"YES\" if the lines are parallel and \"NO\" if they are not. The coordinates are real numbers with at most 5 digits after the decimal point, ranging from -100 to 100.", "before_after_length": [99, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u647694976", "n_user": "u647694976", "pos": "while True:\n N=int(input())\n \n if N==0:\n break\n \n num=0\n res=-11111111\n for i in range(N):\n a=int(input())\n num=max(num+a, a)\n #print(num)\n res=max(num, res)\n #print(res)\n\n print(res)\n\n", "neg": "while True:\n N=int(input())\n if N==0:\n break\n num=0\n res=-11111111\n for i in range(N):\n a=int(input())\n num=max(num+a,a)\n res=max(num,res)\n\n print(num)\n\n", "jacc_sim": 0.9615384615384616, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [98, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u744114948", "n_user": "u744114948", "pos": "while True:\n n=int(input())\n if n == 0: break\n\n ans=-1e100\n l=[]\n\n for _ in range(n):\n l.append(int(input()))\n for i in range(n):\n s=0\n for j in range(i,n):\n s+=l[j]\n if ans < s: ans = s\n print(ans)", "neg": "while True:\n n=int(input())\n if n == 0: break\n\n ans=0\n l=[]\n\n for _ in range(n):\n l.append(int(input()))\n for i in range(n):\n s=-1e100\n for j in range(i,n):\n s+=l[j]\n if ans < s: ans = s\n print(ans)", "jacc_sim": 1.0, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [103, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u618637847", "n_user": "u618637847", "pos": "\n\nwhile True:\n num = int(input())\n\n if num == 0: \n break\n \n list = []\n for i in range(num):\n list.append(int(input()))\n\n for i in range(1, num):\n list[i] = max(list[i - 1] + list[i], list[i])\n\n print(max(list))", "neg": "\n\nwhile True:\n num = int(input())\n\n if num == 0: \n break\n \n list = []\n for i in range(num):\n list.append(int(input()))\n\n for i in range(1, num):\n list[i] = max(list[i - 1] + list[i], list[i])\n\n print((list))", "jacc_sim": 1.0, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [96, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u519227872", "n_user": "u519227872", "pos": "from sys import stdin\n\ndef getMax(array):\n mx = mx2 = array[0]\n for i in array[1:]:\n mx2 = max(i, mx2 + i)\n mx = max(mx, mx2)\n return mx\n\nfor line in stdin:\n n = int(line)\n if n == 0:\n break\n array = []\n for line in stdin:\n line = int(line)\n array.append(line)\n if len(array) == n:\n break\n print(getMax(array))", "neg": "from sys import stdin\n\ndef getMax(array):\n mx = mx2 = array[0]\n for i in array[1:]:\n mx2 = max(i, mx2 + i)\n print(mx2,mx)\n mx = max(mx, mx2)\n return mx\n\nfor line in stdin:\n n = int(line)\n if n == 0:\n break\n array = []\n for line in stdin:\n line = int(line)\n array.append(line)\n if len(array) == n:\n break\n print(getMax(array))", "jacc_sim": 1.0, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [136, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u150984829", "n_user": "u150984829", "pos": "while 1:\n n=int(input())\n if n==0:break\n a=[int(input())for _ in[0]*n]\n for i in range(1,n):a[i]=max(a[i],a[i]+a[i-1])\n print(max(a))\n", "neg": "while 1:\n n=int(input())\n if n==0:break\n a=[int(input())for _ in[0]*n]\n for i in range(n-1):a[i]=max(a[i],a[i]+a[i-1])\n print(max(a))\n", "jacc_sim": 1.0, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [71, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00022", "p_user": "u436634575", "n_user": "u811773570", "pos": "while True:\n n = int(input())\n if n == 0: break\n a = []\n for i in range(n):\n a.append(int(input()))\n for i in range(1, n):\n a[i] = max(a[i - 1] + a[i], a[i])\n print(max(a))", "neg": "while True:\n n = int(input())\n if n==0:\n break\n l = []\n for i in range(n):\n l.append(int(input()))\n for i in range(1,n):\n l[i]=max()l[i-1]+l[i],l[i])\n print(max(l))", "jacc_sim": 0.9285714285714286, "nl": "Title: Maximum Sum Sequence\n\nGiven a sequence of numbers a1, a2, a3, ..., an, find the maximum sum of a contiguous subsequence of those numbers. Note that a subsequence of one element is also a contiguous subsequence.\n\nInput:\nThe input consists of multiple datasets. Each data set consists of:\nn\na1\na2\n...\nan\n\nYou can assume that 1 \u2264 n \u2264 5000 and -100000 \u2264 ai \u2264 100000.\n\nThe input ends with a line consisting of a single 0.\n\nOutput:\nFor each dataset, print the maximum sum in a line.\n\nSample Input:\n7\n-5\n-1\n6\n4\n9\n-6\n-7\n13\n1\n2\n3\n2\n-2\n-1\n1\n2\n3\n2\n1\n-2\n1\n3\n1000\n-200\n201\n0\n\nOutput for the Sample Input:\n19\n14\n1001", "before_after_length": [87, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00023", "p_user": "u379956761", "n_user": "u379956761", "pos": "import sys\nimport math\n\nn = int(input())\n\nfor _ in range(n):\n xa, ya, ra, xb, yb, rb = map(float, input().split())\n\n distance = math.sqrt((xa-xb)**2 + (ya-yb)**2)\n if ra + rb >= distance:\n if (distance + ra < rb):\n print(-2)\n elif (distance + rb < ra):\n print(2)\n else:\n print(1)\n else:\n print(0)", "neg": "import sys\nimport math\n\nn = int(input())\n\nfor _ in range(n):\n xa, ya, ra, xb, yb, rb = map(float, input().split())\n\n distance = math.sqrt((xa-xb)**2 + (ya-yb)**2)\n if ra + rb < distance:\n if (ra < rb and distance + ra < rb):\n print(-2)\n elif (rb < ra and distance + rb < ra):\n print(2)\n else:\n print(1)\n else:\n print(0)", "jacc_sim": 0.95, "nl": "Title: Circles Intersection\n\nYou are given two circles, A and B, each defined by their radius and central coordinates. Write a program to determine the relationship between these circles and print the following:\n- \"2\" if circle B is inside circle A\n- \"-2\" if circle A is inside circle B\n- \"1\" if the circumferences of circles A and B intersect\n- \"0\" if circles A and B do not overlap\n\nAssume that circles A and B are not identical.\n\nInput:\nThe input consists of multiple datasets. The first line contains an integer N (N \u2264 50), representing the number of datasets. The following N lines each represent a dataset, consisting of real numbers: xa ya ra xb yb rb\n\nOutput:\nFor each dataset, print 2, -2, 1, or 0 on a new line.\n\nSample Input:\n2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0\n\nOutput for the Sample Input:\n2\n0", "before_after_length": [132, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00023", "p_user": "u621997536", "n_user": "u140201022", "pos": "n = int(input())\nfor i in range(n):\n xa, ya, ra, xb, yb, rb = map(float, input().split())\n d = ((xa - xb)**2 + (ya - yb)**2)**0.5\n if d > ra + rb:\n print(0)\n elif ra + d < rb:\n print(-2)\n elif rb + d < ra:\n print(2)\n else:\n print(1)", "neg": "n=int(raw_input())\nfor i in range(n):\n xa,ya,ra,xb,yb,rb=map(float,raw_input().split())\n d=((xa-xb)**2+(ya-yb)**2)**0.5\n if ra+rbrb:\n print 2\n elif ra= r2:\n print(1);\n elif d=br:\n print(2)\n elif d < r2 and ar <= br:\n print(-2)\n else:\n print(0)\n ", "neg": "\n\nimport math\n\n\nnum = int(input())\n\nfor i in range(num):\n ax,ay,ar,bx,by,br = map(float,input().split(' '))\n d = (ax - bx)*(ax - bx) + (ay * by)\n if d < abs(br - ar):\n if ar > br:\n print(2)\n else:\n print(-2)\n elif d <= r1 + r2:\n print(1)\n else:\n print(0)", "jacc_sim": 0.9069767441860465, "nl": "Title: Circles Intersection\n\nYou are given two circles, A and B, each defined by their radius and central coordinates. Write a program to determine the relationship between these circles and print the following:\n- \"2\" if circle B is inside circle A\n- \"-2\" if circle A is inside circle B\n- \"1\" if the circumferences of circles A and B intersect\n- \"0\" if circles A and B do not overlap\n\nAssume that circles A and B are not identical.\n\nInput:\nThe input consists of multiple datasets. The first line contains an integer N (N \u2264 50), representing the number of datasets. The following N lines each represent a dataset, consisting of real numbers: xa ya ra xb yb rb\n\nOutput:\nFor each dataset, print 2, -2, 1, or 0 on a new line.\n\nSample Input:\n2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0\n\nOutput for the Sample Input:\n2\n0", "before_after_length": [167, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00023", "p_user": "u236679854", "n_user": "u633068244", "pos": "import math\n\nn = int(input())\nfor i in range(n):\n xa, ya, ra, xb, yb, rb = map(float, input().split())\n d = math.sqrt((xb - xa) ** 2 + (yb - ya) ** 2)\n if d < ra - rb:\n print(2)\n elif d < rb - ra:\n print(-2)\n elif d <= ra + rb:\n print(1)\n else:\n print(0)", "neg": "import math\nn = int(raw_input())\n\nfor i in range(n):\n xa,ya,ra,xb,yb,rb = map(float, raw_input().split())\n d = math.sqrt((xa-xb)**2+(ya-yb)**2)\n if ra+rb < d:\n print 0\n elif ra > rb:\n if d+rb < ra:\n print 2\n else:\n print 1\n elif ra < rb:\n if d+ra < rb:\n print -2\n else:\n print 1", "jacc_sim": 0.9230769230769231, "nl": "Title: Circles Intersection\n\nYou are given two circles, A and B, each defined by their radius and central coordinates. Write a program to determine the relationship between these circles and print the following:\n- \"2\" if circle B is inside circle A\n- \"-2\" if circle A is inside circle B\n- \"1\" if the circumferences of circles A and B intersect\n- \"0\" if circles A and B do not overlap\n\nAssume that circles A and B are not identical.\n\nInput:\nThe input consists of multiple datasets. The first line contains an integer N (N \u2264 50), representing the number of datasets. The following N lines each represent a dataset, consisting of real numbers: xa ya ra xb yb rb\n\nOutput:\nFor each dataset, print 2, -2, 1, or 0 on a new line.\n\nSample Input:\n2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0\n\nOutput for the Sample Input:\n2\n0", "before_after_length": [120, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00023", "p_user": "u024715419", "n_user": "u898097781", "pos": "import math\n\nn = int(input())\nfor i in range(n):\n xa, ya, ra, xb, yb, rb = map(float, input().split())\n\n d = math.sqrt((xa - xb)**2 + (ya - yb)**2)\n\n if ra > d + rb:\n print(\"2\")\n elif rb > d + ra:\n print(\"-2\")\n elif d > ra + rb:\n print(\"0\")\n else:\n print(\"1\")\n\n", "neg": "import math\nn = int(raw_input())\n\nfor i in range(n):\n xa, ya, ra, xb, yb, rb = map(float, raw_input().split(' '))\n d = math.sqrt((xa-xb)**2 + (ya-yb)**2)\n if d+rb <= ra:\n print 2\n elif d+ra <= rb:\n print -2\n elif d > ra+rb:\n print 0\n else:\n print 1\n ", "jacc_sim": 0.925, "nl": "Title: Circles Intersection\n\nYou are given two circles, A and B, each defined by their radius and central coordinates. Write a program to determine the relationship between these circles and print the following:\n- \"2\" if circle B is inside circle A\n- \"-2\" if circle A is inside circle B\n- \"1\" if the circumferences of circles A and B intersect\n- \"0\" if circles A and B do not overlap\n\nAssume that circles A and B are not identical.\n\nInput:\nThe input consists of multiple datasets. The first line contains an integer N (N \u2264 50), representing the number of datasets. The following N lines each represent a dataset, consisting of real numbers: xa ya ra xb yb rb\n\nOutput:\nFor each dataset, print 2, -2, 1, or 0 on a new line.\n\nSample Input:\n2\n0.0 0.0 5.0 0.0 0.0 4.0\n0.0 0.0 2.0 4.1 0.0 2.0\n\nOutput for the Sample Input:\n2\n0", "before_after_length": [126, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00024", "p_user": "u766477342", "n_user": "u766477342", "pos": "try:\n while 1:\n y = 4.9 * (float(input()) / 9.8) ** 2\n N = 1\n while N * 5 - 5 < y:\n N += 1\n print(N)\nexcept:\n pass", "neg": "while 1:\n try:\n y = 4.9 * (float(input()) / 9.8) ** 2\n N = 1\n while N * 5 - 5 < y:\n N += 1\n print(N)\n except:\n pass", "jacc_sim": 1.0, "nl": "Title: Physical Experiments\n\nIgnoring air resistance, the velocity of a freely falling object (v) after t seconds and its drop (y) in t seconds are represented by the following formulas:\nv = 9.8t\ny = 4.9t^2\n\nA person is conducting an experiment to drop a glass ball and determine if it will crack. Your task is to write a program to assist in this experiment.\n\nGiven the minimum velocity required to crack the ball, your program should output the lowest possible floor of a building where the ball will crack. The height of the Nth floor of the building is defined by 5N - 5.\n\nInput:\nThe input consists of multiple datasets. Each dataset contains the minimum velocity (v) (0 < v < 200) required to crack the ball. The value is given as a decimal fraction, with at most 4 digits after the decimal point. The input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the lowest possible floor where the ball cracks.\n\nSample Input:\n25.4\n25.4\n\nOutput for the Sample Input:\n8\n8", "before_after_length": [60, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00024", "p_user": "u150984829", "n_user": "u150984829", "pos": "import math,sys\nfor e in sys.stdin:print(int(float(e)**2/98+2))\n", "neg": "import math,sys\nfor e in sys.stdin:print(int(float(input())**2/98+2))\n", "jacc_sim": 0.9523809523809523, "nl": "Title: Physical Experiments\n\nIgnoring air resistance, the velocity of a freely falling object (v) after t seconds and its drop (y) in t seconds are represented by the following formulas:\nv = 9.8t\ny = 4.9t^2\n\nA person is conducting an experiment to drop a glass ball and determine if it will crack. Your task is to write a program to assist in this experiment.\n\nGiven the minimum velocity required to crack the ball, your program should output the lowest possible floor of a building where the ball will crack. The height of the Nth floor of the building is defined by 5N - 5.\n\nInput:\nThe input consists of multiple datasets. Each dataset contains the minimum velocity (v) (0 < v < 200) required to crack the ball. The value is given as a decimal fraction, with at most 4 digits after the decimal point. The input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the lowest possible floor where the ball cracks.\n\nSample Input:\n25.4\n25.4\n\nOutput for the Sample Input:\n8\n8", "before_after_length": [28, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u555040407", "n_user": "u555040407", "pos": "# -*- coding: utf-8 -*-\n\nwhile True:\n try:\n A, B = input().split(), input().split()\n hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ])\n blow = sum([ 1 for i in range(len(A)) if B[i] in A ]) - hit\n print(str(hit) + ' ' +str(blow))\n except:\n break\n", "neg": "# -*- coding: utf-8 -*-\n\nwhile True:\n try:\n A, B = input().split(), input().split()\n hit = sum([ 1 for i in range(len(A)) if A[i]==B[i] ])\n blow = sum([ 1 for i in range(len(A)) if B[i] in A ])\n print(str(hit) + ' ' +str(blow))\n except:\n break\n", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [116, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u071010747", "n_user": "u071010747", "pos": "# -*- coding:utf-8 -*-\n\ndef main():\n while True:\n try:\n A=input().split()\n B=input().split()\n\n Hit=0\n Blow=0\n\n for b in B:\n if b in A:\n index=B.index(b)\n if b==A[index]:\n Hit+=1\n\n else:\n Blow+=1\n print(Hit,Blow)\n\n except:\n break\n \n \n \nif __name__ == '__main__':\n main()", "neg": "# -*- coding:utf-8 -*-\n\ndef main():\n while True:\n try:\n A=input().split()\n B=input().split()\n\n Hit=0\n Blow=0\n\n for b in B:\n if b in A:\n index=B.index(b)\n print(index)\n if b==A[index]:\n Hit+=1\n\n else:\n Blow+=1\n print(Hit,Blow)\n\n except:\n break\n \n \n \nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [145, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u966364923", "n_user": "u966364923", "pos": "import sys\ninputs = []\nfor line in sys.stdin:\n inputs.append(line)\n\nn = len(inputs)\nfor _ in range(n // 2):\n a = list(map(int, inputs[_ * 2].split()))\n b = list(map(int, inputs[_ * 2 + 1].split()))\n hit = 0\n blow = 0\n for i in range(4):\n if b[i] == a[i]:\n hit += 1\n elif b[i] in a:\n blow += 1\n print(hit, blow)", "neg": "import sys\ninputs = []\nfor line in sys.stdin:\n inputs.append(line)\nn = len(inputs)\nfor _ in range(n // 2):\n for line in sys.stdin:\n a = list(map(int, inputs[_ * 2].split()))\n b = list(map(int, inputs[_ * 2 + 1].split()))\n hit = 0\n blow = 0\n for i in range(4):\n if b[i] == a[i]:\n hit += 1\n elif b[i] in a:\n blow += 1\n print(hit, blow)", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [142, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u661290476", "n_user": "u661290476", "pos": "while True:\n try:\n a=[int(i) for i in input().split()]\n b=[int(i) for i in input().split()]\n except:\n break\n hit,blow=0,0\n for i,j in zip(a,b):\n if i==j:\n hit+=1\n elif j in a:\n blow+=1\n print(hit,blow)", "neg": "while True:\n try:\n a=[int(i) for i in input().split()]\n b=[int(i) for i in input().split()]\n except:\n break\n hit,blow=0,0\n for i,j in zip(a,b):\n if j in a:\n blow+=1\n if i==j:\n hit+=1\n print(hit,blow)", "jacc_sim": 0.967741935483871, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [105, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u498511622", "n_user": "u350064373", "pos": "try:\n while True:\n l1=list(map(int,input().split()))\n l2=list(map(int,input().split()))\n hit=blow=0\n for i in l1:\n for s in l2:\n if i==s:\n if l1.index(i)==l2.index(s):\n hit+=1\n else:\n blow+=1\n print(hit,blow)\nexcept:\n pass\n ", "neg": "try:\n while True:\n l1 = list(map(int, input().split()))\n l2 = list(map(int, input().split()))\n hit = blow = 0\n for i in l1:\n for s in l2:\n if i == s:\n if l1.index(i) == l2.index(s):\n hit += 1\n else:\n blow += 1\n print hit, blow\nexcept:\n pass", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [121, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u548155360", "n_user": "u548155360", "pos": "# coding=utf-8\n\n\ndef hit_and_blow(answer: list, expect: list) -> tuple:\n hit, blow = 0, 0\n for (i, j) in zip(answer, expect):\n if i == j:\n hit += 1\n answer_set = set(answer)\n expect_set = set(expect)\n blow_set = answer_set & expect_set\n blow = len(blow_set) - hit\n return hit, blow\n\n\nif __name__ == '__main__':\n while True:\n try:\n answer_number = list(map(int, input().split()))\n expected_number = list(map(int, input().split()))\n except EOFError:\n break\n h, b = hit_and_blow(answer_number, expected_number)\n print(h, b)", "neg": "# coding=utf-8\n\n\ndef hit_and_blow(answer: list, expect: list) -> tuple:\n hit, blow = 0, 0\n for (i, j) in zip(answer, expect):\n if i == j:\n hit += 1\n answer_set = set(answer)\n expect_set = set(expect)\n blow_set = answer_set & expect_set\n print(blow_set)\n blow = len(blow_set) - hit\n return hit, blow\n\n\nif __name__ == '__main__':\n while True:\n try:\n answer_number = list(map(int, input().split()))\n expected_number = list(map(int, input().split()))\n except EOFError:\n break\n h, b = hit_and_blow(answer_number, expected_number)\n print(h, b)", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [213, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u737311644", "n_user": "u737311644", "pos": "while True:\n hit=0\n bro=0\n try:\n a = [int(i) for i in input().split()]\n b= [int(j) for j in input().split()]\n for g in range(4):\n for p in range(4):\n if a[g]==b[p]:\n bro+=1\n for l in range(4):\n if a[l]==b[l]:\n hit+=1\n bro-=1\n print(hit,bro)\n except:break\n", "neg": "while True:\n hit=0\n bro=0\n try:\n a = [int(i) for i in input().split()]\n b= [int(j) for j in input().split()]\n for l in range(4):\n if a[l]==b[l]:\n hit+=1\n for g in range(4):\n for p in range(4):\n if a[g]==a[p]:\n bro+=1\n bro=bro-hit\n bro-=1\n print(hit,bro)\n except:break\n\n", "jacc_sim": 1.0, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [134, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00025", "p_user": "u436634575", "n_user": "u777299405", "pos": "import sys\n\nstate = True\nfor s in sys.stdin:\n if state:\n state = not state\n a = list(map(int, s.split()))\n else:\n state = not state\n b = list(map(int, s.split()))\n hit = sum(a[i] == b[i] for i in range(4))\n blow = sum(b[i] in a for i in range(4)) - hit\n print(hit, blow)", "neg": "import sys\n\neven = True\nfor s in sys.stdin:\n if even:\n even = not even\n a = list(map(int, s.split()))\n else:\n b = list(map(int, s.split()))\n hit = sum(a[i] == b[i] for i in range(4))\n blow = sum(b[i] in a for i in range(4)) - hit\n print(hit, blow)", "jacc_sim": 0.9411764705882353, "nl": "Title: Hit and Blow\n\nLet's play Hit and Blow game. A imagines four numbers and B guesses the numbers. After B picks out four numbers, A answers:\n\n- The number of numbers which have the same place with numbers A imagined (Hit)\n- The number of numbers included (but different place) in the numbers A imagined (Blow)\n\nFor example, if A imagined numbers:\n9 1 8 2\nand B chose:\n4 1 5 9\nA should say 1 Hit and 1 Blow.\n\nWrite a program which reads four numbers A imagined and four numbers B chose and prints the number of Hit and Blow respectively. You may assume that the four numbers are all different and within from 0 to 9.\n\nInput:\nThe input consists of multiple datasets. Each dataset set consists of:\na1 a2 a3 a4\nb1 b2 b3 b4\n, where ai (0 \u2264 ai \u2264 9) is i-th number A imagined and bi (0 \u2264 bi \u2264 9) is i-th number B chose.\n\nThe input ends with EOF. The number of datasets is less than or equal to 50.\n\nOutput:\nFor each dataset, print the number of Hit and Blow in a line. These two numbers should be separated by a space.\n\nSample Input:\n9 1 8 2\n4 1 5 9\n4 6 8 2\n4 6 3 2\n\nOutput for the Sample Input:\n1 1\n3 0", "before_after_length": [119, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u766477342", "n_user": "u766477342", "pos": "d = [[0] * 10 for i in range(10)]\n\ndef b(x, y):\n for i in range(x - 2, x + 3):\n a = 3 - abs(x - i)\n for a in range(y - a + 1, y + a):\n if 0 <= i < 10 and 0 <= a < 10:\n d[a][i] += 1\n\n\ndef m(x, y):\n for i in range(x - 1, x + 2):\n for j in range(y - 1, y + 2):\n if 0 <= i < 10 and 0 <= j < 10:\n d[j][i] += 1\n\n\ndef s(x, y):\n r = (1, 0)\n for i in range(x - 1, x + 2):\n a = abs(x - i)\n for j in range(y - r[a], y + r[a] + 1):\n if 0 <= i < 10 and 0 <= j < 10:\n d[j][i] += 1\n\nwhile 1:\n try:\n f = (None, s, m, b)\n x, y, size = list(map(int, input().split(',')))\n f[size](x, y)\n except:\n break\n\n\nr1 = r2 = 0\nfor i in range(10):\n for j in range(10):\n r1 += 1 if d[i][j] == 0 else 0\n r2 = max(r2, d[i][j])\n\nprint(r1)\nprint(r2)", "neg": "d = [[0] * 10 for i in range(10)]\n\ndef b(x, y):\n for i in range(x - 2, x + 3):\n a = 3 - abs(x - i)\n for a in range(y - a + 1, y + a):\n if 0 <= i < 10 and 0 <= a < 10:\n d[a][i] += 1\n\n\ndef m(x, y):\n for i in range(x - 1, x + 2):\n for j in range(y - 1, y + 2):\n if 0 <= i < 10 and 0 <= j < 10:\n d[j][i] += 1\n\n\ndef s(x, y):\n r = (1, 0)\n for i in range(x - 1, x + 2):\n a = abs(x - i)\n for j in range(y - r[a], y + r[a] + 1):\n if 0 <= i < 10 and 0 <= j < 10:\n d[j][i] += 1\n\nwhile 1:\n try:\n f = (None, s, m, b)\n x, y, size = list(map(int, input().split(',')))\n f[size](x, y)\n\n except:\n break\n\n\nr1 = r2 = 0\nfor i in range(10):\n for j in range(10):\n r1 += 1 if d[i][j] == 0 else 0\n r2 = max(r2, d[i][j])\n\nprint(r1, r2)", "jacc_sim": 1.0, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [380, 378], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u358919705", "n_user": "u358919705", "pos": "a = [[0] * 14 for _ in range(14)]\nwhile True:\n try:\n x, y, s = map(int, input().split(','))\n except:\n break\n x += 2\n y += 2\n for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]:\n a[x + d[0]][y + d[1]] += 1\n if s >= 2:\n for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]:\n a[x + d[0]][y + d[1]] += 1\n if s == 3:\n for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]:\n a[x + d[0]][y + d[1]] += 1\nprint(sum(a[i][2:12].count(0) for i in range(2, 12)))\nprint(max(max(a[i][2:12]) for i in range(2, 12)))", "neg": "a = [[0] * 14 for _ in range(14)]\nwhile True:\n try:\n x, y, s = map(int, input().split(','))\n except:\n break\n x += 2\n y += 2\n for d in [(0, 0), (0, -1), (0, 1), (-1, 0), (1, 0)]:\n a[x + d[0]][y + d[1]] += 1\n if s >= 2:\n for d in [(1, 1), (1, -1), (-1, 1), (-1, -1)]:\n a[x + d[0]][y + d[1]] += 1\n if s == 3:\n for d in [(0, 2), (0, -2), (2, 0), (-2, 0)]:\n a[x + d[0]][y + d[1]] += 1\nprint(sum(a[i][2:12].count(0) for i in range(2, 12)))\nprint(max(max(a[i][2:12]) for i in range(2, 12)))\nprint(a)", "jacc_sim": 1.0, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [268, 273], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u301729341", "n_user": "u301729341", "pos": "Masu = []\ndef access(x,y):\n if x < 0 or y < 0 or x > 9 or y > 9:\n return\n Masu[y][x] += 1\n\nfor i in range(10):\n Masu.append([0,0,0,0,0,0,0,0,0,0])\nkosu = 0\nkomax = 0\nwhile True:\n try:\n \n x,y,s = map(int,input().split(\",\"))\n if s == 1:\n for j in range(3):\n access(y +1 - j,x)\n access(y,x - 1)\n access(y,x + 1)\n\n elif s == 2:\n for k in range(3):\n for l in range(3):\n access(y + 1 - k,x + 1 -l)\n elif s == 3:\n for k in range(3):\n for l in range(3):\n access(y + 1 - k,x + 1 -l)\n access(y - 2,x)\n access(y + 2,x)\n access(y,x + 2)\n access(y,x - 2)\n \n except (EOFError,ValueError):\n for i in range(10):\n kosu += Masu[i].count(0)\n for j in range(10):\n if komax < max(Masu[j]):\n komax = max(Masu[j])\n print(kosu)\n print(komax)\n break", "neg": "Masu = []\ndef access(x,y):\n if x < 0 or y < 0 or x > 9 or y > 9:\n return\n Masu[y][x] += 1\n\nfor i in range(10):\n Masu.append([0,0,0,0,0,0,0,0,0,0])\nkosu = 0\nkomax = 0\nwhile True:\n try:\n \n x,y,s = map(int,input().split(\",\"))\n if s == 1:\n for j in range(3):\n access(y +1 - j,x)\n access(y,x - 1)\n access(y,x + 1)\n\n elif s == 2:\n for k in range(3):\n for l in range(3):\n access(y + 1 - k,x + 1 -l)\n elif s == 3:\n for k in range(3):\n for l in range(3):\n access(y + 1 - k,x + 1 -l)\n access(y - 2,x)\n access(y + 2,x)\n access(y,x + 2)\n access(y,x - 2)\n print(Masu)\n \n except (EOFError,ValueError):\n for i in range(10):\n kosu += Masu[i].count(0)\n for j in range(10):\n if komax < max(Masu[j]):\n komax = max(Masu[j])\n print(kosu)\n print(komax)\n break", "jacc_sim": 1.0, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [389, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u661290476", "n_user": "u661290476", "pos": "\nboard=[[0]*10 for i in range(10)]\nink=[[[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0]],\n[[0,0,0,0,0],[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0],[0,0,0,0,0]],\n[[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]]]\n\nwhile True:\n try:\n x,y,s=map(int,input().split(\",\"))\n except:\n break\n for i in range(5):\n for j in range(5):\n if 0<=i+y-2<=9 and 0<=j+x-2<=9:\n board[i+y-2][j+x-2]+=ink[s-1][i][j]\n \nflat=sum(board,[])\nprint(flat.count(0))\nprint(max(flat))", "neg": "\nboard=[[0]*10 for i in range(10)]\nink=[[[0,0,0,0,0],[0,0,1,0,0],[0,1,1,1,0],[0,0,1,0,0],[0,0,0,0,0]],\n[[0,0,0,0,0],[0,1,1,1,0],[0,1,1,1,0],[0,1,1,1,0],[0,0,0,0,0]],\n[[0,0,1,0,0],[0,1,1,1,0],[1,1,1,1,1],[0,1,1,1,0],[0,0,1,0,0]]]\n\nwhile True:\n try:\n x,y,s=map(int,input().split(\",\"))\n except:\n break\n for i in range(5):\n for j in range(5):\n if 0<=i+y-2<=9 and 0<=j+x-2<=9:\n board[i+y-2][j+x-2]+=ink[s-1][i][j]\n\nflat=sum(board,[])\nprint(flat.count(0))\nprint(flat.count(max(flat)))", "jacc_sim": 1.0, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [320, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u905313459", "n_user": "u905313459", "pos": "import sys\nn1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]\nn2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]]\nn3 = n2 + [[a*2, b*2] for a, b in n1]\nmas = [[0]*10 for i in range(10)]\nfor i in sys.stdin:\n try:\n x, y, a = list(map(int, i.split(\",\")))\n mas[y][x] += 1\n for k,l in eval(\"n\"+str(a)):\n try:\n if y+l >= 0 and x+k >= 0:\n mas[y+l][x+k] += 1\n except IndexError:\n continue\n except ValueError:\n break\nprint(len([i for x in mas for i in x if not i]))\nprint(max([max(v) for v in mas]))", "neg": "import sys\nn1 = [[0, 1], [1, 0], [-1, 0], [0, -1]]\nn2 = n1 + [[a, b] for a in [-1, 1] for b in [-1, 1]]\nn3 = n2 + [[a*2, b*2] for a, b in n1]\nmas = [[0]*10 for i in range(10)]\nfor i in sys.stdin:\n try:\n x, y, a = list(map(int, i.split(\",\")))\n mas[y][x] += 1\n for k,l in eval(\"n\"+str(a)):\n try:\n if y+l>= 0 and x+k >= 0:\n mas[y+l][x+k] += 1\n except IndexError:\n continue\n except ValueError:\n break\nprint(mas)\nprint(len([i for x in mas for i in x if not i]))\nprint(max([max(v) for v in mas]))", "jacc_sim": 1.0, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [233, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00026", "p_user": "u898097781", "n_user": "u898097781", "pos": "import sys\n\nlines = []\nfor line in sys.stdin:\n lines.append(line.strip().split(','))\n\nfield = [[0 for i in range(10)] for j in range(10)]\n\ndef drop(x, y, z):\n if z==1:\n for i in range(-1,2):\n for j in range(-1,2):\n if abs(i)+abs(j)<2 and 0<=y+j<=9 and 0<=x+i<=9:\n field[y+j][x+i] += 1\n elif z==2:\n for i in range(-1,2):\n for j in range(-1,2):\n if 0<=y+j<=9 and 0<=x+i<=9:\n field[y+j][x+i] += 1\n else:\n for i in range(-2,3):\n for j in range(-2,3):\n if abs(i)+abs(j)<3 and 0<=y+j<=9 and 0<=x+i<=9:\n field[y+j][x+i] += 1\n\n\n\nfor line in lines:\n x,y,z = map(int, line)\n drop(x,y,z)\n\nn = 0\nm = 0\nfor f in field:\n for e in f:\n if e > m:\n m = e\n if e==0:\n n+=1\n\nprint(n)\nprint(m)\n\n", "neg": "import sys\n\nlines = []\nfor line in sys.stdin:\n lines.append(line.strip().split(','))\n\nfield = [[0 for i in range(10)] for j in range(10)]\n\ndef drop(x, y, z):\n if z==1:\n for i in range(-1,2):\n for j in range(-1,2):\n if abs(i)+abs(j)<2 and 0<=y+j<=10 and 0<=x+i<=10:\n field[y+j][x+i] += 1\n elif z==2:\n for i in range(-1,2):\n for j in range(-1,2):\n if 0<=y+j<=10 and 0<=x+i<=10:\n field[y+j][x+i] += 1\n else:\n for i in range(-2,3):\n for j in range(-2,3):\n if abs(i)+abs(j)<3 and 0<=y+j<=10 and 0<=x+i<=10:\n field[y+j][x+i] += 1\n\n\n\nfor line in lines:\n x,y,z = map(int, line)\n drop(1,1,1)\n\nn = 0\nm = 0\nfor f in field:\n for e in f:\n if e > m:\n m = e\n if e==0:\n n+=1\n\nprint(n)\nprint(m)\n\n", "jacc_sim": 0.98, "nl": "Dropping Ink\n\nAs depicted in the figure, a paper grid has cells identified by (x, y) coordinates. Drops of ink come in three sizes: Large, Medium, and Small. When a drop falls, the ink spreads to surrounding cells based on its size. The paper starts white, with a density value of 0 for each cell. The density increases by 1 as ink spreads. The task is to create a program that reads drop points (x, y) and size (1 for Small, 2 for Medium, 3 for Large), then prints the number of cells with density 0 and the maximum density value. The paper is always 10x10, with 0 \u2264 x < 10 and 0 \u2264 y < 10. Input consists of x, y, and size for each drop, and the output should display the number of cells with density 0 on the first line and the maximum density value on the second line. The number of drops is at most 50.\n\nSample Input:\n2,5,3\n3,6,1\n3,4,2\n4,5,2\n3,6,3\n2,4,1\n\nOutput for the Sample Input:\n77\n5", "before_after_length": [370, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u560214129", "n_user": "u560214129", "pos": "from datetime import date\nimport sys\nfor line in sys.stdin.readlines():\n m , d = map(int,line.split())\n if m != 0 and d != 0 :\n val = date(2004,m,d)\n day = val.isoweekday()\n if day == 7:\n print(\"Sunday\")\n elif day == 1:\n print(\"Monday\")\n elif day == 2:\n print(\"Tuesday\")\n elif day == 3:\n print(\"Wednesday\")\n elif day == 4:\n print(\"Thursday\")\n elif day == 5:\n print(\"Friday\")\n else:\n print(\"Saturday\")\n else:\n break", "neg": "from datetime import date\nimport sys\nfor line in sys.stdin.readlines():\n m , d = map(int,line.split())\n if m != 0 and d != 0 :\n val = date(2004,m,d)\n day = val.isoweekday()\n if day == 0:\n print(\"Sunday\")\n elif day == 1:\n print(\"Monday\")\n elif day == 2:\n print(\"Tuesday\")\n elif day == 3:\n print(\"Wednesday\")\n elif day == 4:\n print(\"Thursday\")\n elif day == 5:\n print(\"Friday\")\n else:\n print(\"Saturday\")\n else:\n break", "jacc_sim": 0.9787234042553191, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [175, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u075836834", "n_user": "u075836834", "pos": "def day(x,y):\n\tstart=0\n\tif x==2 or x==8 :\n\t\tstart=0\n\telif x==3 or x==11:\n\t\tstart=1\n\telif x==6:\n\t\tstart=2\n\telif x==9 or x==12:\n\t\tstart=3\n\telif x==1 or x==4 or x==7:\n\t\tstart=4\n\telif x==10:\n\t\tstart=5\n\telif x==5:\n\t\tstart=6 \n\n\n\n\tday=(start+y)%7\n\tif day==1:\n\t\treturn \"Sunday\"\n\telif day==2:\n\t\treturn \"Monday\"\n\telif day==3:\n\t\treturn \"Tuesday\"\n\telif day==4:\n\t\treturn \"Wednesday\"\n\telif day==5:\n\t\treturn \"Thursday\"\n\telif day==6:\n\t\treturn \"Friday\"\n\telse:#0\n\t\treturn \"Saturday\"\n\n\nwhile True:\t\n\tx,y=map(int,input().split())\n\tif x==y==0:\n\t\tbreak\n\tprint(day(x,y))", "neg": "def day(x,y):\n\tstart=0\n\tif (x==1 or x==10):\n\t\tstart=3\n\telif (x==2 or x==3 or x==11):\n\t\tstart=6\n\telif (x==4 or x==7):\n\t\tstart=2\n\telif x==5:\n\t\tstart=4\n\telif x==6:\n\t\tstart=0\n\telif x==8:\n\t\tstart=5\n\telse:\n\t\tstart=1\n\tday=(start+y)%7\n\tif day==1:\n\t\treturn \"Sunday\"\n\telif day==2:\n\t\treturn \"Monday\"\n\telif day==3:\n\t\treturn \"Tuesday\"\n\telif day==4:\n\t\treturn \"Wednesday\"\n\telif day==5:\n\t\treturn \"Thursday\"\n\telif day==6:\n\t\treturn \"Friday\"\n\telse:#0\n\t\treturn \"Saturday\"\n\n\nwhile True:\t\n\tx,y=map(int,input().split())\n\tif x==y==0:\n\t\tbreak\n\tprint(day(x,y))", "jacc_sim": 0.9583333333333334, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [300, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u650459696", "n_user": "u759949288", "pos": "month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30]\nday = ['Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'Monday', 'Tuesday']\nwhile True:\n m, d = map(int, input().split())\n if m == 0:\n break\n print(day[(sum(month[:m - 1]) + d) % 7])", "neg": "day = [\"Thursday\", \"Friday\", \"Saturday\", \"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\"]\nmonth = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 31, 31]\nwhile True:\n\tm, d = map(int, raw_input().split())\n\tif m == d == 0: break\n\tprint day[(sum(month[0:m-1]) + d - 1) % 7]", "jacc_sim": 0.95, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [111, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u299798926", "n_user": "u299798926", "pos": "lis=[0 for i in range(7)]\nlis[0]=\"Wednesday\"\nlis[1]=\"Thursday\"\nlis[2]=\"Friday\"\nlis[3]=\"Saturday\"\nlis[4]=\"Sunday\"\nlis[5]=\"Monday\"\nlis[6]=\"Tuesday\"\nwhile 1:\n date=0\n x,y=map(int,input().split())\n if x!=0 and y!=0:\n for i in range(1,x):\n if i==4 or i==6 or i==9 or i==11:\n date=date+30\n elif i==2:\n date =date+29\n else:\n date=date+31\n k=(date+y)%7\n print(lis[k])\n else:\n break", "neg": "lis=[0 for i in range(7)]\nlis[0]=\"Wednesday\"\nlis[1]=\"Thursday\"\nlis[2]=\"Friday\"\nlis[3]=\"Saturday\"\nlis[4]=\"Sunday\"\nlis[5]=\"Monday\"\nlis[6]=\"Tuesday\"\nwhile 1:\n date=0\n x,y=map(int,input().split())\n if x!=0 and y!=0:\n for i in range(1,x):\n if i==4 or i==6 or i==9 or i==11:\n date=date+30\n elif i==2:\n date =date+29\n else:\n date=date+31\n print(date)\n k=(date+y)%7\n print(date+y)\n print(lis[k])\n else:\n break", "jacc_sim": 1.0, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [211, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u024715419", "n_user": "u024715419", "pos": "import datetime\n\ndate_list = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n\nwhile True:\n m, d = map(int, input().split())\n if m == 0 and d == 0:\n break\n print(date_list[datetime.date(2004, m, d).weekday()])\n\n", "neg": "import datetime\n\ndate_list = [\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\"]\n\nwhile True:\n m, d = map(int, input().split())\n if m == 0 and d == 0:\n break\n print(date_list[datetime.date(204, m, d).weekday()])\n\n", "jacc_sim": 0.9444444444444444, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [100, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00027", "p_user": "u553148578", "n_user": "u553148578", "pos": "while 1:\n\tday = ['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues']\n\tmonth = [0,31,60,91,121,152,182,213,244,274,305,335]\n\tm,d=map(int,input().split())\n\tif m == 0:\n\t\tbreak\n\tprint(day[(month[m-1]+d)%7]+'day')\n", "neg": "while 1:\n\tday = ['Wednes','Thurs','Fri','Satur','Sun','Mon','Tues']\n\tmonth = [0,31,60,91,121,152,182,213,244,274,305,335]\n\ttry: m,d=map(int,input().split())\n\texcept: break\n\tprint(day[(month[m-1]+d)%7]+'day')\n", "jacc_sim": 0.9361702127659575, "nl": "What day of the week corresponds to a given date in the year 2004? Write a program that takes a date (ranging from January 1, 2004, to December 31, 2004) as input and outputs the day of the week for that date. The input consists of a sequence of datasets, each containing two integers representing the month and the day. The input sequence ends with a line containing a single zero. The program should handle up to 50 datasets. For each dataset, the program should output the corresponding day of the week. For example, given the input \"1 1\" and \"2 29\", the output should be \"Thursday\" and \"Sunday\" respectively.", "before_after_length": [108, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u966364923", "n_user": "u966364923", "pos": "import collections\nimport sys\ncntr = collections.Counter()\nfor line in sys.stdin:\n cntr[int(line)] += 1\nlst = []\nfor k,v in cntr.items():\n lst.append((v,k))\nlst.sort()\nt = len(lst)-1\nwhile t>0 and lst[t][0] == lst[t-1][0]:\n t -= 1\nfor i in range(t,len(lst)):\n print(lst[i][1])", "neg": "import collections\nimport sys\ncntr = collections.Counter\nfor line in sys.stdin:\n cntr[int(line)] += 1\nlst = []\nfor k,v in cntr.items():\n lst.append((v,k))\nlst.sort()\nt = len(lst)-1\nwhile t>0 and lst[t][0] == lst[t-1][0]:\n t -= 1\nfor i in range(t,len(lst)):\n print(lst[i][1])", "jacc_sim": 1.0, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [119, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u301729341", "n_user": "u301729341", "pos": "kosu = [0] * 100\nk = 1\nwhile True:\n try:\n n = int(input())\n kosu[n - 1] += 1\n except (EOFError,ValueError):\n ma = max(kosu)\n num = kosu.index(ma) + k\n print(num)\n \n \n kosu.remove(max(kosu))\n while True:\n if ma > max(kosu):\n break\n k += 1\n num = kosu.index(ma) + k\n kosu.remove(max(kosu))\n print(num)\n break", "neg": "kosu = [0] * 100\nk = 1\nwhile True:\n try:\n n = int(input())\n kosu[n - 1] += 1\n except (EOFError,ValueError):\n ma = max(kosu)\n num = kosu.index(ma) + k\n print(num)\n \n \n kosu.remove(max(kosu))\n while True:\n if ma > max(kosu):\n break\n k += 1\n num = kosu.index(ma) + k\n kosu.remove(max(kosu))\n print(num)", "jacc_sim": 1.0, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [159, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u811733736", "n_user": "u811733736", "pos": "import sys\nfrom collections import Counter\n\n\nif __name__ == '__main__':\n # ??????????????\\???\n # data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4]\n data = []\n for line in sys.stdin:\n data.append(int(line.strip()))\n # print(data)\n\n # ?????????????\u00a2????\n c = Counter(data)\n max_freq = c.most_common(1)[0][1] # ???????????????????????\u00b0????\u00a8???\u00b6\n modes = []\n for val, freq in c.most_common():\n if freq != max_freq:\n break\n modes.append(val)\n\n # ???????????\u00a8???\n modes.sort()\n for i in modes:\n print(i)", "neg": "import sys\nfrom collections import Counter\n\n\nif __name__ == '__main__':\n # ??????????????\\???\n # data = [5, 6, 3, 5, 8, 7, 5, 3, 9, 7, 3, 4]\n data = []\n for line in sys.stdin:\n data.append(int(line.strip()))\n print(data)\n\n # ?????????????\u00a2????\n c = Counter(data)\n max_freq = c.most_common(1)[0][1] # ???????????????????????\u00b0????\u00a8???\u00b6\n modes = []\n for val, freq in c.most_common():\n if freq != max_freq:\n break\n modes.append(val)\n\n # ???????????\u00a8???\n modes.sort()\n for i in modes:\n print(i)", "jacc_sim": 1.0, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [232, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u546285759", "n_user": "u546285759", "pos": "import sys\nfrom itertools import dropwhile\na = []\nfor v in sys.stdin:\n a.append(int(v))\n\nm = max([a.count(v) for v in set(a)])\ntry:\n next(dropwhile(lambda x: True, (print(v) for v in set(a) if a.count(v) == m)))\nexcept StopIteration:\n pass", "neg": "import sys\nfrom itertools import dropwhile\na = []\ntry:\n for v in sys.stdin:\n a.append(int(v))\n\nexcept:\n m = max([a.count(v) for v in set(a)])\n next(dropwhile(lambda x: True, (print(v) for v in set(a) if a.count(v) == m)))", "jacc_sim": 0.9142857142857143, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [94, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u518711553", "n_user": "u518711553", "pos": "import sys\nfrom collections import defaultdict\nd = defaultdict(int)\nfor i in sys.stdin:\n d[int(i)] +=1\nm = max(v for v in d.values())\nfor i in sorted([k for k, v in d.items() if v == m]):\n print(i)", "neg": "import sys\nfrom collections import defaultdict\nd = defaultdict(int)\nfor i in sys.stdin:\n d[i] +=1\nm = max(v for v in d.values())\nfor _ in sorted([k for k, v in d.items() if v == m]):\n print(_)", "jacc_sim": 0.967741935483871, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [73, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u184989919", "n_user": "u184989919", "pos": "import sys\n \ndef ModeValue():\n mode=[0 for i in range(0,101)]\n \n for n in sys.stdin:\n mode[int(n)]+=1\n\n maxN=max(mode)\n\n for i in range(0,101):\n if mode[i]==maxN:\n print(i)\n \nModeValue()", "neg": "import sys\n \ndef ModeValue():\n mode=[0 for i in range(0,101)]\n \n for n in sys.stdin:\n mode[int(n)]+=1\n\n maxN=max(mode)\n\n for i in mode:\n if mode[i]==maxN:\n print(i)\n \nModeValue()", "jacc_sim": 1.0, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [90, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u933096856", "n_user": "u933096856", "pos": "d={}\ntry:\n while True:\n n=int(input())\n if n in d:\n d[n]+=1\n else:\n d[n]=1\nexcept EOFError:\n pass\na=[]\nm=max(d.values())\nfor key, value in d.items():\n if value == m:\n a.append(key)\na.sort()\nfor i in a:\n print(i)", "neg": "d={}\ntry:\n while True:\n n=int(input())\n if n in d:\n d[n]+=1\n else:\n d[n]=1\nexcept EOFError:\n pass\na=[]\nm=max(d.value())\nfor key, value in d:\n if value == m:\n a.append(key)\na.sort()\nfor i in a:\n print(i)", "jacc_sim": 0.9459459459459459, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [108, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u845643816", "n_user": "u845643816", "pos": "# 0028\narray = []\nwhile True:\n try:\n a = input()\n array.append(int(a))\n except EOFError:\n break\ncount = list(map(lambda a: array.count(a), set(array)))\nmodes = list(filter(lambda a: array.count(a) == max(count), set(array)))\nprint(*modes, sep = '\\n')", "neg": "# 0028\narray = []\nwhile True:\n try:\n a = input()\n array.append(int(a))\n except EOFError:\n break\ns = set(array)\nmx = max(list(map(lambda a: array.count(a), s)))\nmodes = list(filter(lambda a: array.count(a) == mx), sorted(s))\nprint(*modes, sep = '\\n')", "jacc_sim": 0.9210526315789473, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [96, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00028", "p_user": "u845643816", "n_user": "u845643816", "pos": "# 0028\narray = []\nwhile True:\n try:\n a = input()\n array.append(int(a))\n except EOFError:\n break\ns = set(array)\nmx = max(list(map(lambda a: array.count(a), s)))\nmodes = list(filter(lambda a: array.count(a) == mx, sorted(s)))\nprint(*modes, sep = '\\n')", "neg": "# 0028\narray = []\nwhile True:\n try:\n a = input()\n if a == '': break\n array.append(int(a))\n except EOFError:\n break\ns = set(array)\nmx = max(list(map(lambda a: array.count(a), s)))\nmodes = list(filter(lambda a: array.count(a) == mx), sorted(s))\nprint(*modes, sep = '\\n')", "jacc_sim": 0.9743589743589743, "nl": "Title: Mode Value\n\nYour task is to write a program that reads a sequence of integers and prints the mode values of the sequence. The mode value is the element that occurs most frequently.\n\nInput:\nA sequence of integers ai (1 <= ai <= 100). The number of integers is less than or equal to 100.\n\nOutput:\nPrint the mode values. If there are several mode values, print them in ascending order.\n\nSample Input:\n5\n6\n3\n5\n8\n7\n5\n3\n9\n7\n3\n4\n\nOutput for the Sample Input:\n3\n5\n\nFor example, 3 and 5 respectively occur three times, 7 occurs two times, and others occur only once. So, the mode values are 3 and 5.", "before_after_length": [101, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00029", "p_user": "u300946041", "n_user": "u300946041", "pos": "# -*- coding: utf-8 -*-\nfrom collections import defaultdict\n\nd = defaultdict(int)\n_input = input()\n\nfor word in _input.split():\n d[word] += 1\n\ntimes = sorted(d.items(), key=lambda item: item[1], reverse=True)\nlengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)\n\nprint(times[0][0], end=' ')\nprint(lengths[0][0])", "neg": "# -*- coding: utf-8 -*-\nfrom collections import defaultdict\n\nd = defaultdict(int)\n_input = input()\nsentence = [e for e in _input.split()]\nl = []\n\nfor word in sentence:\n d[word] += 1\n\ntimes = sorted(d.items(), key=lambda item: item[1], reverse=True)\nlengths = sorted(d.items(), key=lambda item: len(item[0]), reverse=True)\n\nprint(times[0][1], end=' ')\nprint(lengths[0][0])", "jacc_sim": 0.9333333333333333, "nl": "Write a program that reads a text and prints two words: the most frequently occurring word in the text and the word with the maximum number of letters. The text contains only alphabetical characters and spaces, with words separated by spaces. The input text will have a maximum of 1000 letters, and each word will have a maximum of 32 letters. The output should be the two words separated by a space. For example, given the input \"Thank you for your mail and your lectures,\" the output should be \"your lectures.\"", "before_after_length": [119, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00029", "p_user": "u798803522", "n_user": "u798803522", "pos": "targ = input().split(' ')\nmostfre = {}\nansfre = \"\"\nlongest = [0,\"\"]\nfor t in targ:\n if len(t) > longest[0]:\n longest[0],longest[1] = len(t),t\n mostfre[t] = mostfre.get(t,0) + 1\ntemp = 0\nfor k,v in mostfre.items():\n if v > temp:\n temp = v\n ansfre = k\nprint(ansfre + ' ' + longest[1])", "neg": "targ = input().split(' ')\nmostfre = {}\nansfre = \"\"\nlongest = [0,\"\"]\nfor t in targ:\n if len(t) > longest[0]:\n longest[0],longest[1] = len(t),t\n mostfre[t] = mostfre.get(t,0) + 1\ntemp = 0\nprint(mostfre)\nfor k,v in mostfre.items():\n if v > temp:\n temp = v\n ansfre = k\nprint(ansfre + ' ' + longest[1])", "jacc_sim": 1.0, "nl": "Write a program that reads a text and prints two words: the most frequently occurring word in the text and the word with the maximum number of letters. The text contains only alphabetical characters and spaces, with words separated by spaces. The input text will have a maximum of 1000 letters, and each word will have a maximum of 32 letters. The output should be the two words separated by a space. For example, given the input \"Thank you for your mail and your lectures,\" the output should be \"your lectures.\"", "before_after_length": [134, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00029", "p_user": "u811733736", "n_user": "u811733736", "pos": "import sys\nfrom collections import Counter\n\nif __name__ == '__main__':\n # ??????????????\\???\n # line = 'Thank you for your mail and your lectures'\n data = []\n for line in sys.stdin:\n data = line.strip().strip('.').lower().split(' ')\n\n # print(data)\n\n # ??????????\u00a2??????????\n c = Counter(data) # ????????????????\u00a2????\n most_frequent_word = c.most_common(1)[0][0]\n # ???????????????????????\u00a2???\n max_length_word = ''\n for w, freq in c.most_common():\n if len(w) > len(max_length_word):\n max_length_word = w\n\n # ???????????\u00a8???\n print('{0} {1}'.format(most_frequent_word, max_length_word))", "neg": "import sys\nfrom collections import Counter\n\nif __name__ == '__main__':\n # ??????????????\\???\n # line = 'Thank you for your mail and your lectures'\n data = []\n for line in sys.stdin:\n data = line.strip().lower().split(' ')\n\n print(data)\n\n # ??????????\u00a2??????????\n c = Counter(data) # ????????????????\u00a2????\n most_frequent_word = c.most_common(1)[0][0]\n # ???????????????????????\u00a2???\n max_length_word = ''\n for w, freq in c.most_common():\n if len(w) > len(max_length_word):\n max_length_word = w\n\n # ???????????\u00a8???\n print('{0} {1}'.format(most_frequent_word, max_length_word))", "jacc_sim": 1.0, "nl": "Write a program that reads a text and prints two words: the most frequently occurring word in the text and the word with the maximum number of letters. The text contains only alphabetical characters and spaces, with words separated by spaces. The input text will have a maximum of 1000 letters, and each word will have a maximum of 32 letters. The output should be the two words separated by a space. For example, given the input \"Thank you for your mail and your lectures,\" the output should be \"your lectures.\"", "before_after_length": [255, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00029", "p_user": "u584777171", "n_user": "u584777171", "pos": "s = list(input().split())\nmaxLen = 0\nmaxNum = 0\ndic = {}\nfor word in s:\n if not (word in dic):\n dic[word] = 1\n else:\n dic[word] += 1\n if maxNum < dic[word]:\n maxNum = dic[word]\n ansNum = word\n if maxLen < len(word):\n maxLen = len(word)\n ansLen = word\nprint(ansNum, ansLen)", "neg": "s = list(input().split())\nmaxLen = 0\nmaxNum = 0\ndic = {}\nfor word in s:\n if not (word in dic):\n dic[word] = 1\n else:\n dic[word] += 1\n if maxNum < dic[word]:\n maxNum = dic[word]\n ansNum = word\n if maxLen < len(word):\n maxLen = len(word)\n ansLen = word\nprint(ansNum, ansLen)\nprint(dic)", "jacc_sim": 1.0, "nl": "Write a program that reads a text and prints two words: the most frequently occurring word in the text and the word with the maximum number of letters. The text contains only alphabetical characters and spaces, with words separated by spaces. The input text will have a maximum of 1000 letters, and each word will have a maximum of 32 letters. The output should be the two words separated by a space. For example, given the input \"Thank you for your mail and your lectures,\" the output should be \"your lectures.\"", "before_after_length": [114, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00030", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\nimport itertools\n\nwhile True:\n n, s = map(int, f.readline().split())\n if n == 0:\n break\n print(sum(1 for nums in itertools.combinations([i for i in range(10)], n) if sum(nums) == s))", "neg": "import sys\nf = sys.stdin\n\nwhile True:\n n, s = map(int, f.readline().split())\n if n == 0:\n break\n print(sum(1 for nums in itertools.combinations([i for i in range(10)], n) if sum(nums) == s))", "jacc_sim": 1.0, "nl": "Title: Sum of Integers\n\nFind the number of combinations of n distinct numbers from 0 to 9 whose sum is s. For each dataset, the input consists of n (1 \u2264 n \u2264 9) and s (0 \u2264 s \u2264 100) separated by a single space. When both n and s are 0, it marks the end of input. The number of datasets does not exceed 50.\n\nFor each dataset, output the number of combinations of n integers whose sum is s on a single line.\n\nSample Input:\n3 6\n3 1\n0 0\n\nOutput for the Sample Input:\n3\n0", "before_after_length": [79, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00030", "p_user": "u775586391", "n_user": "u775586391", "pos": "def f(n,s,x):\n if n == s == 0:\n return 1\n elif n == 0 or x == 0:\n return 0\n else:\n a = 0\n for i in range(x):\n a += f(n-1,s-i,i)\n return a\nwhile True:\n n,s = map(int,input().split())\n if n == s == 0:\n break\n print(f(n,s,10))", "neg": "def f(n,s,x):\n if n == s == 0:\n return 1\n elif n == 0 or x == 0:\n return 0\n else:\n a = 0\n for i in range(x):\n a += f(n-1,s-i,i)\n return a\nwhile True:\n n,s = map(int,raw_input().split())\n if n == s == 0:\n break\n print(f(n,s,10))", "jacc_sim": 0.9428571428571428, "nl": "Title: Sum of Integers\n\nFind the number of combinations of n distinct numbers from 0 to 9 whose sum is s. For each dataset, the input consists of n (1 \u2264 n \u2264 9) and s (0 \u2264 s \u2264 100) separated by a single space. When both n and s are 0, it marks the end of input. The number of datasets does not exceed 50.\n\nFor each dataset, output the number of combinations of n integers whose sum is s on a single line.\n\nSample Input:\n3 6\n3 1\n0 0\n\nOutput for the Sample Input:\n3\n0", "before_after_length": [117, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00030", "p_user": "u650459696", "n_user": "u650459696", "pos": "def decSum(n, sm, mn):\n #print(n,sm,mn)\n if mn + n > 10 :\n return 0\n elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:\n return 0\n elif n == 1:\n return 1\n else:\n a = 0\n for i in range(mn, 10 if sm >= 10 else sm):\n a += decSum(n - 1, sm - i, i + 1)\n return a\nwhile True:\n n, sm = map(int, input().split())\n if n == 0:\n break\n print(decSum(n, sm, 0))", "neg": "def decSum(n, sm, mn):\n print(n,sm,mn)\n if mn + n > 10 :\n return 0\n elif sum(range(mn, mn + n)) > sm or sum(range(10 - n, 10)) < sm:\n return 0\n elif n == 1:\n return 1\n else:\n a = 0\n for i in range(mn, 10 if sm >= 10 else sm):\n a += decSum(n - 1, sm - i, i + 1)\n return a\nwhile True:\n n, sm = map(int, input().split())\n if n == 0:\n break\n print(decSum(n, sm, 0))", "jacc_sim": 0.9743589743589743, "nl": "Title: Sum of Integers\n\nFind the number of combinations of n distinct numbers from 0 to 9 whose sum is s. For each dataset, the input consists of n (1 \u2264 n \u2264 9) and s (0 \u2264 s \u2264 100) separated by a single space. When both n and s are 0, it marks the end of input. The number of datasets does not exceed 50.\n\nFor each dataset, output the number of combinations of n integers whose sum is s on a single line.\n\nSample Input:\n3 6\n3 1\n0 0\n\nOutput for the Sample Input:\n3\n0", "before_after_length": [168, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00030", "p_user": "u436634575", "n_user": "u150984829", "pos": "from itertools import combinations\n\nwhile True:\n n, s = map(int, input().split())\n if n == s == 0: break\n\n print(sum(1 for x in combinations(range(10), n) if sum(x) == s))", "neg": "from itertools import combinations\nwhile 1:\n n,s=map(int,input().split())\n if n+x==0:break\n print(sum(1 for p in combinations(range(10),n)if sum(p)==s))\n", "jacc_sim": 0.9032258064516129, "nl": "Title: Sum of Integers\n\nFind the number of combinations of n distinct numbers from 0 to 9 whose sum is s. For each dataset, the input consists of n (1 \u2264 n \u2264 9) and s (0 \u2264 s \u2264 100) separated by a single space. When both n and s are 0, it marks the end of input. The number of datasets does not exceed 50.\n\nFor each dataset, output the number of combinations of n integers whose sum is s on a single line.\n\nSample Input:\n3 6\n3 1\n0 0\n\nOutput for the Sample Input:\n3\n0", "before_after_length": [60, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u744114948", "n_user": "u744114948", "pos": "while True:\n try:\n n=int(input())\n except:\n break\n\n l=list(format(n,'b'))\n \n for i in range(len(l)):\n if l[-i-1] == \"1\":\n print(2**i, end=\"\")\n if i != len(l)-1:\n print(\" \",end=\"\")\n \n print()", "neg": "while True:\n try:\n n=int(input())\n except:\n break\n\n l=list(format(n,'b'))\n \n for i in range(len(l)):\n if l[-i-1] == \"1\":\n print(2**i, end=\"???\")\n \n print()", "jacc_sim": 0.9411764705882353, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [98, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u777299405", "n_user": "u777299405", "pos": "import sys\n\n\nfor line in sys.stdin:\n waight = [\"1\", \"2\", \"4\", \"8\", \"16\", \"32\", \"64\", \"128\", \"256\", \"512\"]\n ans = []\n n = bin(int(line))[2:].zfill(10)\n for i, x in enumerate(n[::-1]):\n if x == \"1\":\n ans.append(waight[i])\n print(\" \".join(ans))", "neg": "import sys\n\n\nwaight = [\"1\", \"2\", \"4\", \"8\", \"16\", \"32\", \"64\", \"128\", \"256\", \"512\"]\nfor n in sys.stdin:\n ans = []\n n = bin(n)[2:].zfill(10)\n for i, x in enumerate(n[::-1]):\n if x == \"1\":\n ans.append(waight[i])\n print(\" \".join(ans))", "jacc_sim": 0.95, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [115, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u868716420", "n_user": "u868716420", "pos": "g = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n\nwhile True :\n try :\n c = -1\n left, right = int(input()), []\n while True :\n if left <= 0 : break\n else :\n if left - g[c] < 0 : c += -1\n else :\n left -= g[c]\n right.append(g[c])\n right.sort()\n print(*right)\n except : break", "neg": "g = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n\nwhile True :\n try :\n c = -1\n left, right = int(input()), []\n while True :\n if left <= 0 : break\n else :\n if left - g[c] < 0 : c += -1\n else :\n left -= g[c]\n right.append(g[c])\n right.sort()\n print(right)\n except : break", "jacc_sim": 0.9743589743589743, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [122, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u024715419", "n_user": "u024715419", "pos": "w_a = [1,2,4,8,16,32,64,128,256,512]\n\nwhile True:\n try:\n w_b = int(input())\n b = list(bin(w_b))[::-1]\n w_c = []\n for i in range(len(b)):\n if b[i] == \"b\":\n break\n elif b[i] == \"1\":\n w_c.append(w_a[i])\n print(*w_c)\n except:\n break\n\n", "neg": "w_a = [2,4,8,16,32,64,128,256,512]\n\nwhile True:\n try:\n w_b = int(input())\n b = list(bin(w_b))[::-1]\n w_c = []\n for i in range(len(b)):\n if b[i] == \"b\":\n break\n elif b[i] == \"1\":\n w_c.append(w_a[i])\n print(*w_c)\n except:\n break\n\n", "jacc_sim": 1.0, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [136, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u352394527", "n_user": "u647694976", "pos": "#2\u9032\u6570\u5316\ndef bin(w, l):\n if w == 0:\n return l\n\n l.append(w % 2)\n return bin(w // 2, l)\n\nwhile True:\n try:\n w = int(input())\n w_bin = bin(w, [])\n ans = \"\"\n for i, v in enumerate(w_bin):\n if v:\n ans += str(2 ** i) + \" \"\n print(ans.rstrip())\n\n except EOFError:\n break\n", "neg": "def bin(w, l):\n\u00a0\u00a0if w == 0:\n\u00a0\u00a0\u00a0\u00a0return l\n\u00a0\n\u00a0\u00a0l.append(w % 2)\n\u00a0\u00a0return bin(w // 2, l)\n\u00a0\nwhile True:\n\u00a0\u00a0try:\n\u00a0\u00a0\u00a0\u00a0w = int(input())\n\u00a0\u00a0\u00a0\u00a0w_bin = bin(w, [])\n\u00a0\u00a0\u00a0\u00a0ans = \"\"\n\u00a0\u00a0\u00a0\u00a0for i, v in enumerate(w_bin):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if v:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ans += str(2 ** i) + \" \"\n\u00a0\u00a0\u00a0\u00a0print(ans.rstrip())\n\u00a0\n\u00a0\u00a0except EOFError:\n\u00a0\u00a0\u00a0\u00a0break\n", "jacc_sim": 0.9090909090909091, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [137, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u197615397", "n_user": "u197615397", "pos": "import sys\nprint(\"\\n\".join((\" \".join(str(2**i)for i, n in enumerate(bin(int(s))[:1:-1])if n==\"1\")for s in sys.stdin.readlines())))\n", "neg": "import sys\nprint(\"\\n\".join((\" \".join(str(2**i)for i, n in enumerate(bin(int(s))[:1:-1])if n)for s in sys.stdin.readlines())))\n", "jacc_sim": 0.9666666666666667, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [55, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00031", "p_user": "u548155360", "n_user": "u548155360", "pos": "# coding=utf-8\n\n\ndef calc_weights(weight):\n weights_list = []\n counter = 0\n while weight > 0:\n if weight % 2 == 0:\n weight /= 2\n else:\n weights_list.append(2**counter)\n weight = (weight - 1)/2\n counter += 1\n print(' '.join(map(str, weights_list)))\n\n\nif __name__ == '__main__':\n while True:\n try:\n W = int(input())\n calc_weights(W)\n except EOFError:\n break\n\n", "neg": "# coding=utf-8\n\n\ndef calc_weights(weight):\n weights_list = []\n counter = 0\n while weight > 0:\n if weight % 2 == 0:\n weight /= 2\n else:\n weights_list.append(2**counter)\n counter += 1\n print(' '.join(map(str, weights_list)))\n\n\nif __name__ == '__main__':\n while True:\n try:\n W = int(input())\n calc_weights(W)\n except EOFError:\n break\n\n", "jacc_sim": 1.0, "nl": "Title: Weight\n\nGrandmother uses a balance scale. When the same weight is placed on both sides of the scale, it balances; otherwise, it tilts towards the heavier side. The weights of 10 weights are in ascending order: 1g, 2g, 4g, 8g, 16g, 32g, 64g, 128g, 256g, 512g.\n\nGrandmother says, \"I can measure in grams up to about 1kg.\" When asked to weigh the juice, she places the juice on the left side and 8g, 64g, and 128g weights on the right side. She then concludes, \"The total weight of the weights is 200g, so the weight of the juice is 200g. How's that for accuracy?\"\n\nCreate a program that, given the weight of an item to be placed on the left side, outputs the weights of the weights to be placed on the right side in ascending order. The weight of the item to be measured is at most the sum of all weights (1023g).\n\nInput:\nMultiple datasets are given. The weight of the item to be placed on the left side is given in a single line for each dataset. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the weights to be placed on the right side (in ascending order) separated by a single space on a single line.\n\nSample Input:\n5\n7\n127\n\nOutput for the Sample Input:\n1 4\n1 2 4\n1 2 4 8 16 32 64\n\nHint:\nThe weight of the weights is 2 to the power of n (n = 0, 1, .... 9) grams.", "before_after_length": [143, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u744114948", "n_user": "u744114948", "pos": "s=0\nn=0\nwhile True:\n try:\n a,b,c = map(int, input().split(\",\"))\n except:\n break\n \n if a == b:\n n+=1\n elif c**2 == a**2 + b**2:\n s+=1\n \nprint(str(s) + \"\\n\" + str(n))", "neg": "s=0\nn=0\nwhile True:\n try:\n a,b,c = map(int, input().split())\n except:\n break\n\n if a == b:\n n+=1\n elif c**2 == a**2 + b**2:\n s+=1\n\n print(str(s) + \"\\n\" + str(n))", "jacc_sim": 1.0, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [93, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u651428295", "n_user": "u651428295", "pos": "import sys\n\nt = 0\nh = 0\nfor line in sys.stdin :\n line = list(map(int, line.split(',')))\n if line[2]**2 == line[0] ** 2 + line[1] ** 2 :\n t += 1\n elif line[0] == line[1] :\n h += 1\nprint(t)\nprint(h)", "neg": "import sys\n\nt = 0\nh = 0\nfor line in sys.stdin :\n line = list(map(int, line.split(',')))\n if line[2]**2 == line[0] ** 2 + line[1] ** 2 :\n t += 1\n else :\n h += 1\nprint(t)\nprint(h)", "jacc_sim": 0.9333333333333333, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [92, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u301729341", "n_user": "u647694976", "pos": "hisi = 0\ntyou = 0\nwhile True:\n try:\n a,b,c = map(int,input().split(\",\"))\n if a == b:\n hisi += 1\n elif a ** 2 + b ** 2 == c ** 2:\n tyou += 1\n except EOFError:\n print(tyou)\n print(hisi)\n break\n ", "neg": "hisi=0\ntyou=0\nwhile True:\n try:\n a,b,c=map(int,input().split(\",\"))\n if a**2+b**2==c**2:\n tyou +=1\n elif a==b:\n hisi +=1\n except:\n print(tyou)\n print(hisi)\n", "jacc_sim": 0.9333333333333333, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [96, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u777299405", "n_user": "u777299405", "pos": "import sys\n\nrhombus = rectangle = 0\nfor line in sys.stdin:\n a, b, c = map(int, line.split(\",\"))\n if c ** 2 == a ** 2 + b ** 2:\n rectangle += 1\n elif a == b:\n rhombus += 1\nprint(rectangle)\nprint(rhombus)", "neg": "import sys\n\nrhombus = rectangle = 0\nfor line in sys.stdin:\n a, b, c = map(int, line.split(\",\"))\n if c ** 2 == a ** 2 + b ** 2:\n rectangle += 1\n if a == b and c ** 2 != a ** 2 + b ** 2:\n rhombus += 1\nprint(rectangle, rhombus)", "jacc_sim": 0.9032258064516129, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [84, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u436634575", "n_user": "u436634575", "pos": "import sys\n\nc1 = c2 = 0\nfor line in sys.stdin:\n a, b, c = map(int, line.split(','))\n if a**2 + b**2 == c**2:\n c1 += 1\n elif a == b:\n c2 += 1\nprint(c1)\nprint(c2)", "neg": "import sys\n\nc1 = c2 = 0\nfor line in sys.stdin:\n a, b, c = map(int, line.split(','))\n if a**2 + b**2 == c**2:\n c1 += 1\n elif a == b:\n c2 += 1\nprint(c1, c2)", "jacc_sim": 1.0, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [83, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00032", "p_user": "u312033355", "n_user": "u352394527", "pos": "rect_cnt = dia_cnt = 0\n \nwhile True:\n try:\n a, b, c = map(int, input().split(\",\"))\n \n rect_cnt += (a ** 2 + b ** 2 == c ** 2)\n dia_cnt += (a == b)\n \n except EOFError:\n break\nprint(rect_cnt)\nprint(dia_cnt)\n", "neg": "while True:\n try:\n a, b, c = map(int, input().split(\",\"))\n \n rect_cnt += (a ** 2 + b ** 2 == c ** 2)\n dia_cnt += (a == b)\n\n except EOFError:\n break\n\nprint(rect_cnt)\nprint(dia_cnt)\n", "jacc_sim": 0.9629629629629629, "nl": "Title: Plastic Sheets\n\nIn a factory, data on the lengths of sides and diagonals are input into a machine for cutting plastic sheets into parallelogram shapes. The factory produces various sizes, but only cuts parallelograms. You are tasked with counting the number of rectangles and rhombuses among the cut parallelograms.\n\nCreate a program that reads the input data and outputs the number of rectangles and rhombuses.\n\nInput:\nThe input is given in the following format:\na1, b1, c1\na2, b2, c2\n...\n\nThe input data for the machine is given on multiple lines. The i-th line contains integers a_i, b_i representing the lengths of adjacent sides of the i-th parallelogram, and c_i representing the length of the diagonal, separated by commas (1 \u2264 ai, bi, ci \u2264 1000, ai + bi > ci). The number of data entries does not exceed 100.\n\nOutput:\nOutput the number of rectangles and rhombuses on separate lines.\n\nSample Input:\n3,4,5\n5,5,8\n4,4,4\n5,4,3\n\nOutput for the Sample Input:\n1\n2", "before_after_length": [98, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u203261375", "n_user": "u845643816", "pos": "n = int(input())\nfor i in range(n):\n str = input().split()\n arr = [int(str[j]) for j in range(len(str))]\n b,c = 0,0\n flag = True\n for i in range(len(arr)):\n if b < arr[i]:\n b = arr[i]\n continue\n if c < arr[i]:\n c = arr[i]\n continue\n print(\"NO\")\n flag = False\n break\n if flag:\n print(\"YES\")", "neg": "n = int(input())\nfor i in range(n):\n arr = map(int, input().split())\n b,c = 0,0\n flag = True\n for i in range(len(arr)):\n if b < arr[i]:\n b = arr[i]\n continue\n if c < arr[i]:\n c = arr[i]\n continue\n print(\"NO\")\n flag = False\n break\n if flag:\n print(\"YES\")", "jacc_sim": 0.9142857142857143, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [134, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u777299405", "n_user": "u777299405", "pos": "n = int(input())\nfor i in range(n):\n left, right = [], []\n arr = map(int, input().split())\n for a in arr:\n if len(left) == 0 or left[-1] < a:\n left.append(a)\n elif len(right) == 0 or right[-1] < a:\n right.append(a)\n else:\n break\n if len(left) + len(right) == 10:\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "n = int(input())\nfor i in range(n):\n left = right = []\n arr = map(int, input().split())\n for a in arr:\n if len(left) == 0 or left[-1] < a:\n left.append(a)\n elif len(right) == 0 or right[-1] < a:\n right.append(a)\n else:\n break\n if len(left) + len(right) == 10:\n print(\"YES\")\n else:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [130, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u661290476", "n_user": "u661290476", "pos": "ans=0\ndef solve(n,left,right):\n global ans\n if n==10:\n ans=1\n else:\n if a[n]>left:\n ans=solve(n+1,a[n],right)\n if a[n]>right:\n ans=solve(n+1,left,a[n])\n return ans\n\nn=int(input())\nfor _ in range(n):\n a=[int(i) for i in input().split()]\n print(\"YES\" if solve(0,0,0) else \"NO\")\n ans=0", "neg": "ans=0\ndef solve(n,left,right):\n if n==10:\n ans=1\n else:\n if a[n]>left:\n ans=solve(n+1,a[n],right)\n if a[n]>right:\n ans=solve(n+1,left,a[n])\n return ans\n\nn=int(input())\nfor _ in range(n):\n a=[int(i) for i in input().split()]\n print(\"YES\" if solve(0,0,0) else \"NO\")\n ", "jacc_sim": 0.9722222222222222, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [145, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u945345165", "n_user": "u945345165", "pos": "import sys\n\ndef solve(balls):\n ans = distribute(balls, [], [])\n if ans is True: print('YES')\n else: print(\"NO\")\n \ndef distribute(balls, R, L): \n if len(balls) != 0:\n next = balls[0]\n ans = False\n #case R\n if isMutch(next, R):\n neoR = R\n neoR.append(next)\n ans = distribute(balls[1:], neoR, L)\n if ans: return True\n \n if isMutch(next, L):\n neoL = L\n neoL.append(next)\n ans =distribute(balls[1:], R, neoL)\n if ans: return True\n else:\n return isOrdered(R) and isOrdered(L)\n\ndef isMutch(next, lis):\n if len(lis) != 0:\n return next >= lis[len(lis)-1]\n return True\n \ndef isOrdered(lis):\n #check both R and L are ordered\n checker = sorted(lis)\n return checker == lis\n \nlimit = 2**11\nsys.setrecursionlimit(limit)\n \nline = input()\nsize = -1;\nwhile True:\n if size == -1:\n size = int(line)\n else:\n balls = []\n for a in line.split(' '):\n balls.append(int(a)) \n solve(balls)\n size -= 1\n if size == 0: break\n line = input()", "neg": "import sys\n\ndef solve(balls):\n ans = distribute(balls, [], [])\n if ans is True: print('YES')\n else: print(\"NO\")\n \ndef distribute(balls, R, L):\n if len(balls) != 0:\n next = balls[0]\n ans = False\n #case R\n if isMutch(next, R):\n neoR = R\n neoR.append(next)\n ans = distribute(balls[1:], neoR, L)\n if isMutch(next, L):\n neoL = L\n neoL.append(next)\n ans =distribute(balls[1:], R, neoL)\n if ans: return True\n else:\n return isOrdered(R) and isOrdered(L)\n\ndef isMutch(next, lis):\n if len(lis) != 0:\n return next >= lis[len(lis)-1]\n return True\n \ndef isOrdered(lis):\n #check both R and L are ordered\n checker = sorted(lis)\n return checker == lis\n \nlimit = 2**11\nsys.setrecursionlimit(limit)\n \nline = input()\nsize = -1;\nwhile True:\n if size == -1:\n size = int(line)\n else:\n solve(line.split(' '))\n size -= 1\n print(size)\n if size == 0: break\n line = input()", "jacc_sim": 0.953125, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [399, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u695154284", "n_user": "u695154284", "pos": "N = int(input())\n\nfor testCase in range(N):\n A = list(map(int, input().split()))\n ok = False\n for i in range(2 ** 10):\n x = []\n y = []\n for j in range(10):\n if i & (1 << j):\n x.append(A[j])\n else:\n y.append(A[j])\n if x == sorted(x) and y == sorted(y):\n ok = True\n if ok:\n print('YES')\n else:\n print('NO')", "neg": "N = int(input())\n\nfor testCase in range(N):\n A = list(map(int, input().split()))\n ok = False\n for i in range(2 ** 10):\n x = []\n y = []\n for j in range(10):\n print(j)\n if i & (1 << j):\n x.append(A[j])\n else:\n y.append(A[j])\n if x == sorted(x) and y == sorted(y):\n ok = True\n if ok:\n print('YES')\n else:\n print('NO')", "jacc_sim": 1.0, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [142, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u695154284", "n_user": "u695154284", "pos": "def dfs(i, b, c):\n if i == 11:\n return (b == sorted(b) and c == sorted(c))\n\n if dfs(i + 1, b + [balls[i - 1]], c):\n return True\n\n if dfs(i + 1, b, c + [balls[i - 1]]):\n return True\n\n return False\n\n\nif __name__ == '__main__':\n N = int(input())\n for i in range(N):\n balls = list(map(int, input().split()))\n if dfs(1, [], []):\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "def dfs(i, b, c):\n if i == 11:\n print(b)\n print(c)\n return (b == sorted(b) and c == sorted(c))\n\n if dfs(i + 1, b + [balls[i - 1]], c):\n return True\n\n if dfs(i + 1, b, c + [balls[i - 1]]):\n return True\n\n return False\n\n\nif __name__ == '__main__':\n N = int(input())\n for i in range(N):\n balls = list(map(int, input().split()))\n if dfs(1, [], []):\n print(\"YES\")\n else:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [164, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u845643816", "n_user": "u845643816", "pos": "n = int(input())\nfor i in range(n):\n a = list(map(int, input().split()))\n b,c = 0,0\n for i in range(len(a)):\n if b < a[i]:\n b = a[i]\n continue\n if c < a[i]:\n c = a[i]\n continue\n print(\"NO\")\n break\n else:\n print(\"YES\")", "neg": "n = int(input())\nfor i in range(n):\n arr = map(int, input().split())\n b,c = 0,0\n for i in range(len(arr)):\n if b < arr[i]:\n b = arr[i]\n continue\n if c < arr[i]:\n c = arr[i]\n continue\n print(\"NO\")\n break\n else:\n print(\"YES\")", "jacc_sim": 0.9090909090909091, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [109, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u845643816", "n_user": "u845643816", "pos": "def ball(nums):\n b, c = 0, 0\n for i in range(len(nums)):\n if b < nums[i]:\n b = nums[i]\n continue\n if c < nums[i]:\n c = nums[i]\n continue\n return \"NO\"\n return \"YES\"\n\nN = int(input())\n\nfor _ in range(N):\n a = list(map(int, input().split()))\n print(ball(a))", "neg": "def ball(nums):\n????????b,c = 0,0\n for i in range(len(a)):\n if b < a[i]:\n b = a[i]\n continue\n if c < a[i]:\n c = a[i]\n continue\n return \"NO\"\n return \"YES\"\n??\nN = int(input())\n??\nfor _ in range(N):\n????????a = list(map(int, input().split()))\n????????print(ball(a))", "jacc_sim": 0.9722222222222222, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [118, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u600263347", "n_user": "u600263347", "pos": "def main():\n n = int(input())\n for i in range(n):\n Ball = map(int,input().split())\n l = r = 0\n for value in Ball:\n if value > r:\n r = value\n elif value > l:\n l = value\n else:\n print(\"NO\")\n r = -777\n break\n if r < l:\n r,l = l,r\n \n if r == -777:\n continue\n else:\n print(\"YES\")\n\nif __name__ == '__main__':\n main()\n\n", "neg": "def main():\n n = int(input())\n for i in range(n):\n Ball = map(int,input().split())\n l = r = 0\n for value in Ball:\n if value > r:\n r = value\n elif value > l:\n l = value\n else:\n print(\"NO\")\n r = -777\n break\n if r < l:\n r,l = l,r\n \n if r == -777:\n continue\n else:\n print(\"Yes\")\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 0.9473684210526315, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [147, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00033", "p_user": "u299798926", "n_user": "u299798926", "pos": "x=int(input())\nfor _ in range(x):\n\tnum=list(map(int,input().split()))\n\tb,c=0,0\n\tflag=True\n\tfor i in num:\n\t\tif b b: b = a[j]\n elif a[j] > c: c = a[j]\n else: yes = False\n print('YES' if yes else 'NO')\n", "neg": "n=int(input())\nfor i in range(n):\n a=list(map(int,input().aplit()))\n b,c=0,0\n yes = True\n for j in range(10):\n if a[j]>b:b=a[j]\n elif a[j]>c:c=a[j]\n else:yes=False\n print(\"YES\" if yes else \"NO\")\n", "jacc_sim": 0.9444444444444444, "nl": "There is a container with two openings, B and C. Ten balls numbered 1 to 10 are dropped from opening A and placed into either B or C. A board, D, can rotate around pivot E to determine which tube to drop the balls into. Given the sequence of dropped balls, determine if both tubes can stack the balls with smaller numbers on top of larger ones. Output YES if possible, NO if not. Assume the order of the balls cannot be changed within the container and that both tubes have enough space for all 10 balls.\n\nInput:\nMultiple datasets are given. The first line contains the dataset count, N. The following N lines contain 10 numbers each, separated by spaces.\n\nOutput:\nFor each dataset, output YES or NO on a separate line.\n\nSample Input:\n2\n3 1 4 2 5 6 7 8 9 10\n10 9 8 7 6 5 4 3 2 1\n\nOutput for the Sample Input:\nYES\nNO", "before_after_length": [102, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00034", "p_user": "u647694976", "n_user": "u647694976", "pos": "while True:\n try:\n l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2=map(int,input().split(\",\"))\n kyo=0\n for i in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10:\n kyo +=i\n v=v1+v2\n x=kyo/v\n ans=v1*x\n flag=0\n for j in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,0:\n if ans>0:\n ans -=j\n flag +=1\n else:\n print(flag)\n break\n except:break\n", "neg": "while True:\n try:\n l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2=map(int,input().split(\",\"))\n kyo=0\n for i in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10:\n kyo +=i\n v=v1+v2\n x=kyo/v\n ans=v1*x\n flag=0\n for j in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,0:\n if ans>0:\n ans -=j\n flag +=1\n print(ans)\n else:\n print(flag)\n break\n except:break\n", "jacc_sim": 1.0, "nl": "Title: Railway Lines\n\nThere is a railway line with double tracks (up and down tracks allowing trains to pass each other anywhere). The line has 11 stations, including terminal stations, and each section between stations is referred to by a segment number shown in the diagram.\n\nTwo trains depart simultaneously from both terminal stations and run without stopping. Create a program that reads the length of each section and the speeds of the two trains, and outputs the segment number where the trains pass each other for each case. If they pass exactly at a station, output the smaller segment number. Ignore the length of the trains and stations.\n\nInput:\nMultiple datasets are given in the following format:\nl1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2\nli (1 \u2264 li \u2264 2,000) represents the length of segment i in kilometers. v1 is the speed of the train departing from terminal 1 (km/h), and v2 is the speed of the train departing from terminal 10 (km/h) (1 \u2264 v1, v2 \u2264 2,000). The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the segment number where the trains pass each other on a single line.\n\nSample Input:\n1,1,1,1,1,1,1,1,1,1,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49\n\nOutput for the Sample Input:\n4\n7\n6", "before_after_length": [207, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00034", "p_user": "u964040941", "n_user": "u964040941", "pos": "while True:\n try:\n A = list(map(int,input().split(',')))\n except EOFError:\n break\n V1 = A [-2]\n V2 = A [-1]\n del A [-1]\n del A [-1]\n\n for i in range(len(A)):\n A [i] *= V1 + V2\n\n point = sum(A) // (V1 + V2) * V1\n for i in range(len(A)):\n if sum(A [0:i + 1]) >= point:\n print(i + 1)\n break", "neg": "while True:\n try:\n A = list(map(int,input().split(',')))\n except EOFError:\n break\n V1 = A [-2]\n V2 = A [-1]\n del A [-1]\n del A [-1]\n\n for i in range(len(A)):\n A [i] *= V1 + V2\n\n point = sum(A) // (V1 + V2) * V1\n print(point)\n for i in range(len(A)):\n if sum(A [0:i + 1]) >= point:\n print(i + 1)\n break", "jacc_sim": 1.0, "nl": "Title: Railway Lines\n\nThere is a railway line with double tracks (up and down tracks allowing trains to pass each other anywhere). The line has 11 stations, including terminal stations, and each section between stations is referred to by a segment number shown in the diagram.\n\nTwo trains depart simultaneously from both terminal stations and run without stopping. Create a program that reads the length of each section and the speeds of the two trains, and outputs the segment number where the trains pass each other for each case. If they pass exactly at a station, output the smaller segment number. Ignore the length of the trains and stations.\n\nInput:\nMultiple datasets are given in the following format:\nl1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2\nli (1 \u2264 li \u2264 2,000) represents the length of segment i in kilometers. v1 is the speed of the train departing from terminal 1 (km/h), and v2 is the speed of the train departing from terminal 10 (km/h) (1 \u2264 v1, v2 \u2264 2,000). The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the segment number where the trains pass each other on a single line.\n\nSample Input:\n1,1,1,1,1,1,1,1,1,1,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49\n\nOutput for the Sample Input:\n4\n7\n6", "before_after_length": [148, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00034", "p_user": "u905313459", "n_user": "u905313459", "pos": "import sys\nfor line in sys.stdin:\n v = list(map(int, line.split(\",\")))\n k = [sum(v[:i]) for i,j in enumerate(v[:-1])]\n l = v[-2]/(v[-1]+v[-2]) * k[-1]\n n = [a-l if a-l >= 0 else 1e10 for a in k]\n print(n.index(min(n)))", "neg": "import sys\nfor line in sys.stdin:\n v = list(map(int, line.split(\",\")))\n k = [sum(v[:i]) for i,j in enumerate(v[:-1])]\n l = v[-2]/(v[-1]+v[-2]) * k[-1]\n n = [a-l if a-l >= 0 else 1e10 for a in k]\n print(n)\n print(n.index(min(n)))", "jacc_sim": 1.0, "nl": "Title: Railway Lines\n\nThere is a railway line with double tracks (up and down tracks allowing trains to pass each other anywhere). The line has 11 stations, including terminal stations, and each section between stations is referred to by a segment number shown in the diagram.\n\nTwo trains depart simultaneously from both terminal stations and run without stopping. Create a program that reads the length of each section and the speeds of the two trains, and outputs the segment number where the trains pass each other for each case. If they pass exactly at a station, output the smaller segment number. Ignore the length of the trains and stations.\n\nInput:\nMultiple datasets are given in the following format:\nl1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2\nli (1 \u2264 li \u2264 2,000) represents the length of segment i in kilometers. v1 is the speed of the train departing from terminal 1 (km/h), and v2 is the speed of the train departing from terminal 10 (km/h) (1 \u2264 v1, v2 \u2264 2,000). The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the segment number where the trains pass each other on a single line.\n\nSample Input:\n1,1,1,1,1,1,1,1,1,1,40,60\n1,1,1,1,1,3,3,3,3,3,50,50\n10,10,10,10,10,10,10,10,10,10,50,49\n\nOutput for the Sample Input:\n4\n7\n6", "before_after_length": [107, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00035", "p_user": "u964040941", "n_user": "u901080241", "pos": "def f(x1,y1,x2,y2,x3,y3,x4,y4):\n p = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1)\n q = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2)\n r = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3)\n s = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4)\n return p * q < 0 and r * s < 0\n\nwhile True:\n try:\n x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split(','))\n except EOFError:\n break\n if f(x1,y1,x3,y3,x2,y2,x4,y4):\n print('YES')\n else:\n print('NO')", "neg": "while True:\n try:\n x1,y1,x2,y2,x3,y3,x4,y4 = map(float,input().split(','))\n p = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1)\n q = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2)\n r = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3)\n s = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4)\n if p * q < 0 and r * s < 0:\n print(\"YES\")\n else:\n print(\"NO\")\n except EOFError: break", "jacc_sim": 0.9302325581395349, "nl": "Given the coordinates of four distinct points on a plane, namely $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, and $D(x_d, y_d)$, create a program to determine if the quadrilateral formed by these points (ABCD) is convex. If it is convex, output YES; otherwise, output NO. A convex quadrilateral is one without any indentations, as shown in Figure 1. The input consists of multiple datasets, each containing the coordinates $x_a$, $y_a$, $x_b$, $y_b$, $x_c$, $y_c$, $x_d$, and $y_d, all within the range of -100 to 100. It is guaranteed that no three points are collinear, and the input order of the points forms a valid quadrilateral. The number of datasets does not exceed 100. For each dataset, output YES or NO on a separate line. Example input and output are provided.", "before_after_length": [280, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00035", "p_user": "u905313459", "n_user": "u905313459", "pos": "import sys\nfor line in sys.stdin:\n try:\n p = list(map(float, line.split(',')))\n except:\n break\n v = [p[i] - p[(i + 2) % 8] for i in range(8)]\n ip = [v[j] * v[(j + 3) % 8] - v[j + 1] * v[(j + 2) % 8] > 0 for j in range(0,8,2)]\n if sum(ip) == 0 or sum(ip) == 4:\n print('YES')\n else:\n print('NO')", "neg": "import sys\nfor line in sys.stdin():\n p = list(map(float, line.split(',')))\n v = [p[i] - p[(i + 2) % 8] for i in range(8)]\n ip = [v[j] * v[(j + 3) % 8] - v[j + 1] * v[(j + 2) % 8] > 0 for j in range(0,8,2)]\n if sum(ip) == 0 or sum(ip) == 4:\n print('YES')\n else:\n print('NO')", "jacc_sim": 0.9347826086956522, "nl": "Given the coordinates of four distinct points on a plane, namely $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, and $D(x_d, y_d)$, create a program to determine if the quadrilateral formed by these points (ABCD) is convex. If it is convex, output YES; otherwise, output NO. A convex quadrilateral is one without any indentations, as shown in Figure 1. The input consists of multiple datasets, each containing the coordinates $x_a$, $y_a$, $x_b$, $y_b$, $x_c$, $y_c$, $x_d$, and $y_d, all within the range of -100 to 100. It is guaranteed that no three points are collinear, and the input order of the points forms a valid quadrilateral. The number of datasets does not exceed 100. For each dataset, output YES or NO on a separate line. Example input and output are provided.", "before_after_length": [148, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00035", "p_user": "u299798926", "n_user": "u299798926", "pos": "def judge(p1,p2,p3,p4):\n t1 = (p3[0] - p4[0]) * (p1[1] - p3[1]) + (p3[1] - p4[1]) * (p3[0] - p1[0])\n t2 = (p3[0] - p4[0]) * (p2[1] - p3[1]) + (p3[1] - p4[1]) * (p3[0] - p2[0])\n t3 = (p1[0] - p2[0]) * (p3[1] - p1[1]) + (p1[1] - p2[1]) * (p1[0] - p3[0])\n t4 = (p1[0] - p2[0]) * (p4[1] - p1[1]) + (p1[1] - p2[1]) * (p1[0] - p4[0])\n return t1*t2>0 and t3*t4>0 \nwhile True:\n\ttry:\n\t\tx1,y1,x2,y2,x3,y3,x4,y4=map(float, input().split(\",\"))\n\t\tA=[x1,y1]\n\t\tB=[x2,y2]\n\t\tC=[x3,y3]\n\t\tD=[x4,y4]\n\t\tif judge(A,B,C,D)==False :\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")\n\texcept EOFError:\n\t\tbreak\n", "neg": "def judge(p1,p2,p3,p4):\n t1 = (p1[0] - p3[0]) * (p2[1] - p1[1]) + (p1[1] - p3[1]) * (p1[0] - p2[0])\n t2 = (p1[0] - p3[0]) * (p4[1] - p1[1]) + (p1[1] - p3[1]) * (p1[0] - p4[0])\n t3 = (p2[0] - p4[0]) * (p1[1] - p2[1]) + (p2[1] - p4[1]) * (p2[0] - p1[0])\n t4 = (p2[0] - p4[0]) * (p3[1] - p2[1]) + (p2[1] - p4[1]) * (p2[0] - p3[0])\n return t1*t2<0 and t3*t4<0\nwhile True:\n\ttry:\n\t\tx1,y1,x2,y2,x3,y3,x4,y4=map(float, input().split(\",\"))\n\t\tA=[x1,y1]\n\t\tB=[x2,y2]\n\t\tC=[x3,y3]\n\t\tD=[x4,y4]\n\t\tprint(A,B,C,D)\n\t\tif judge(A,B,C,D)==True or judge(A,D,B,C)==True :\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\texcept EOFError:\n\t\tbreak\n", "jacc_sim": 0.9298245614035088, "nl": "Given the coordinates of four distinct points on a plane, namely $A (x_a, y_a)$, $B (x_b, y_b)$, $C (x_c, y_c)$, and $D(x_d, y_d)$, create a program to determine if the quadrilateral formed by these points (ABCD) is convex. If it is convex, output YES; otherwise, output NO. A convex quadrilateral is one without any indentations, as shown in Figure 1. The input consists of multiple datasets, each containing the coordinates $x_a$, $y_a$, $x_b$, $y_b$, $x_c$, $y_c$, $x_d$, and $y_d, all within the range of -100 to 100. It is guaranteed that no three points are collinear, and the input order of the points forms a valid quadrilateral. The number of datasets does not exceed 100. For each dataset, output YES or NO on a separate line. Example input and output are provided.", "before_after_length": [396, 422], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00037", "p_user": "u024715419", "n_user": "u024715419", "pos": "def move(position):\n x = position[0]\n y = position[1]\n d = position[2]\n if d == \"L\":\n p = \"DLUR\"\n elif d == \"R\":\n p = \"URDL\"\n elif d == \"U\":\n p = \"LURD\"\n else:\n p = \"RDLU\"\n for i in range(4):\n if p[i] in grid[y][x]:\n d = p[i]\n if d == \"L\":\n print(\"L\",end=\"\")\n x -= 1\n break\n elif d == \"R\":\n print(\"R\",end=\"\")\n x += 1\n break\n elif d == \"U\":\n print(\"U\",end=\"\")\n y -= 1\n break\n else:\n print(\"D\",end=\"\")\n y += 1\n break\n return [x, y, d]\n\npos = [1,1,\"R\"]\ngrid = [[\"\" for i in range(6)] for j in range(6)]\nfor i in range(9):\n inp = input()\n if i%2 == 0:\n for j in range(4):\n if inp[j] == \"1\":\n grid[i//2 + 1][j + 1] += \"R\"\n grid[i//2 + 1][j + 2] += \"L\"\n else:\n for j in range(5):\n if inp[j] == \"1\":\n grid[i//2 + 1][j + 1] += \"D\"\n grid[i//2 + 2][j + 1] += \"U\"\nwhile True:\n pos = move(pos)\n if pos[0] == 1 and pos[1] == 1:\n break\nprint(\"\")\n", "neg": "def move(position):\n x = position[0]\n y = position[1]\n d = position[2]\n if d == \"L\":\n p = \"DLUR\"\n elif d == \"R\":\n p = \"URDL\"\n elif d == \"U\":\n p = \"LURD\"\n else:\n p = \"RDLU\"\n for i in range(4):\n if p[i] in grid[y][x]:\n d = p[i]\n if d == \"L\":\n print(\"L\",end=\"\")\n x -= 1\n break\n elif d == \"R\":\n print(\"R\",end=\"\")\n x += 1\n break\n elif d == \"U\":\n print(\"U\",end=\"\")\n y -= 1\n break\n else:\n print(\"D\",end=\"\")\n y += 1\n break\n return [x, y, d]\n\npos = [1,1,\"R\"]\ngrid = [[\"\" for i in range(6)] for j in range(6)]\nfor i in range(9):\n inp = input()\n if i%2 == 0:\n for j in range(4):\n if inp[j] == \"1\":\n grid[i//2 + 1][j + 1] += \"R\"\n grid[i//2 + 1][j + 2] += \"L\"\n else:\n for j in range(5):\n if inp[j] == \"1\":\n grid[i//2 + 1][j + 1] += \"D\"\n grid[i//2 + 2][j + 1] += \"U\"\nprint(*grid,sep=\"\\n\")\nwhile True:\n pos = move(pos)\n if pos[0] == 1 and pos[1] == 1:\n break\n\n", "jacc_sim": 0.9298245614035088, "nl": "Title: Path on a Grid\n\nThere is a square grid-shaped plaza as shown in Figure 1. Each edge of this grid is represented by a sequence of 0s and 1s, indicating the presence or absence of a \"wall\". Starting at point A, with the right hand on the wall, create a program to output the path by continuously walking in the direction of the arrows while keeping the right hand on the wall until returning to point A.\n\nInput:\nConsists of 9 lines, representing the presence of walls as 1 and absence as 0, as shown in Figure 2.\n\nOutput:\nRepresent \"move one unit to the left\" as 'L', \"move one unit to the right\" as 'R', \"move one unit upwards\" as 'U', and \"move one unit downwards\" as 'D'. Output the sequence of movements in the order of 'L', 'R', 'U', 'D' on a single line.\n\nSample Input:\n1111\n00001\n0110\n01011\n0010\n01111\n0010\n01001\n0111\n\nOutput for the Sample Input:\nRRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL", "before_after_length": [434, 441], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00037", "p_user": "u150984829", "n_user": "u150984829", "pos": "g=[[0]*5 for _ in[0]*5]\nfor i in range(9):\n e=input()\n for j in range(4+i%2):\n if int(e[j]):\n if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1\n else:r=g[i//2];r[j]+=2;r[j+1]+=8\ny,x=0,1\nk=1\na=[1]\nwhile 1:\n k+=2\n for _ in[0]*4:\n k+=1\n if g[y][x]&int(2**(k%4)):a+=[k%4];break\n if k%2:x+=1-2*((k%4)>1)\n else:y+=2*((k%4)>0)-1\n if x+y<1:break\nprint(''.join('URDL'[c]for c in a))\n", "neg": "g=[[0]*5 for _ in[0]*5]\nfor i in range(9):\n e=input()\n for j in range(4+i%2):\n if int(e[j]):\n if i%2:g[i//2][j]+=4;g[i//2+1][j]+=1\n else:r=g[i//2];r[j]+=2;r[j+1]+=8\ny,x=0,1\nk=1\na=[1]\nwhile 1:\n k+=2\n for _ in[0]*4:\n k+=1\n if g[y][x]&int(2**(k%4)):a+=[k%4];break\n if k%2:x+=1-2*((k%4)>0)\n else:y+=2*((k%4)>0)-1\n if x+y==0:break\nprint(''.join('URDL'[c]for c in a))\n", "jacc_sim": 0.9791666666666666, "nl": "Title: Path on a Grid\n\nThere is a square grid-shaped plaza as shown in Figure 1. Each edge of this grid is represented by a sequence of 0s and 1s, indicating the presence or absence of a \"wall\". Starting at point A, with the right hand on the wall, create a program to output the path by continuously walking in the direction of the arrows while keeping the right hand on the wall until returning to point A.\n\nInput:\nConsists of 9 lines, representing the presence of walls as 1 and absence as 0, as shown in Figure 2.\n\nOutput:\nRepresent \"move one unit to the left\" as 'L', \"move one unit to the right\" as 'R', \"move one unit upwards\" as 'U', and \"move one unit downwards\" as 'D'. Output the sequence of movements in the order of 'L', 'R', 'U', 'D' on a single line.\n\nSample Input:\n1111\n00001\n0110\n01011\n0010\n01111\n0010\n01001\n0111\n\nOutput for the Sample Input:\nRRRRDDDDLLLUUURRDDLURULLDDDRRRUUUULLLL", "before_after_length": [240, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00038", "p_user": "u379956761", "n_user": "u379956761", "pos": "import sys\n\ndef is_onepair(x):\n for i in range(4):\n if x.count(x[i]) == 2:\n return True\n\n return False\n\ndef is_twopair(x):\n count = 0\n i = 0\n x.sort()\n while i < 5:\n if x.count(x[i]) == 2:\n i += 2\n count += 1\n else:\n i += 1\n if count == 2:\n return True\n\n return False\n\ndef is_threecard(x):\n for i in range(3):\n if x.count(x[i]) == 3:\n return True\n\n return False\n\ndef is_straight(x):\n x.sort()\n if x[0] == 1 and x[1:] == [10, 11, 12, 13]:\n return True\n for i in range(4):\n if x[i]+1 != x[i+1]:\n return False\n \n return True\n\ndef is_fullhouse(x):\n if is_threecard(x) and is_onepair(x):\n return True\n\n return False\n \ndef is_fourcard(x):\n for i in range(2):\n if x.count(x[i]) == 4:\n return True\n\n return False\n\nfor line in sys.stdin.readlines():\n hand = list(map(int, line.split(',')))\n if is_fourcard(hand):\n print(\"four card\")\n elif is_fullhouse(hand):\n print(\"full house\")\n elif is_straight(hand):\n print(\"straight\")\n elif is_threecard(hand):\n print(\"three card\")\n elif is_twopair(hand):\n print(\"two pair\")\n elif is_onepair(hand):\n print(\"one pair\")\n else:\n print(\"null\")", "neg": "import sys\n\ndef is_onepair(x):\n for i in range(4):\n if x.count(x[i]) == 2:\n return True\n\n return False\n\ndef is_twopair(x):\n count = 0\n for e in x:\n for e2 in x:\n if e == e2:\n count += 1\n if count == 2:\n return True\n\n return False\n\ndef is_threecard(x):\n for i in range(3):\n if x.count(x[i]) == 3:\n return True\n\n return False\n\ndef is_straight(x):\n x.sort()\n if x[0] == 1 and x[1:] == [10, 11, 12, 13]:\n return True\n for i in range(4):\n if x[i]+1 != x[i+1]:\n return False\n \n return True\n\ndef is_fullhouse(x):\n if is_threecard(x) and is_onepair(x):\n return True\n\n return False\n \ndef is_fourcard(x):\n for i in range(2):\n if x.count(x[i]) == 4:\n return True\n\n return False\n\nfor line in sys.stdin.readlines():\n hand = list(map(int, line.split(',')))\n if is_fourcard(hand):\n print(\"four card\")\n elif is_fullhouse(hand):\n print(\"full house\")\n elif is_straight(hand):\n print(\"straight\")\n elif is_threecard(hand):\n print(\"three card\")\n elif is_twopair(hand):\n print(\"two pair\")\n elif is_onepair(hand):\n print(\"one pair\")\n else:\n print(\"null\")", "jacc_sim": 0.9253731343283582, "nl": "Poker\n\nCreate a program that reads hand data for poker and outputs the corresponding hand ranking for each hand. The rules for this problem are as follows:\n\n- Poker is a game played with 5 cards.\n- There are no more than 5 cards of the same number.\n- There are no jokers.\n- Consider only the following poker hands (higher numbers indicate higher ranks):\n 1. No hand (none of the below)\n 2. One pair (2 cards of the same number)\n 3. Two pair (2 sets of 2 cards of the same number)\n 4. Three of a kind (3 cards of the same number)\n 5. Straight (5 cards with consecutive numbers)\n 6. Full house (3 cards of the same number and 2 cards of another same number)\n 7. Four of a kind (4 cards of the same number)\n\nInput:\nMultiple datasets, each in the format: card1,card2,card3,card4,card5\nCards are represented as J for Jack (11), Q for Queen (12), K for King (13), A for Ace (1), and other numbers as their respective values.\n\nOutput:\nFor each dataset, output the highest possible hand that can be formed from the given hand. Follow the output example for hand representation.\n\nSample Input:\n(As provided)\n\nOutput for the Sample Input:\n(As provided)\n\nNote: For the hand 3 3 2 3 3, the correct hand is \"four card\" instead of \"two pair\".", "before_after_length": [478, 455], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00038", "p_user": "u075836834", "n_user": "u075836834", "pos": "def function(a,b,c,d,e):\n\tA=[a,b,c,d,e]\n\tA.sort()\n\tif A[0]==A[3] or A[1]==A[4]:\n\t\tprint(\"four card\")\n\telif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]):\n\t\tprint(\"full house\")\n\telif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]:\n\t\tprint(\"three card\")\n\n\telif (A[0]==A[1] and A[2]==A[3]) or (A[0]==A[1] and A[3]==A[4]) or (A[1]==A[2] and A[3]==A[4]):\n\t\tprint(\"two pair\")\n\telif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]:\n\t\tprint(\"one pair\")\n\telif A==[1,10,11,12,13]:\n\t\tprint(\"straight\")\n\telif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4:\n\t\tprint(\"straight\")\n\telse:\n\t\tprint(\"null\")\n\nwhile True:\n\ttry:\n\t\ta,b,c,d,e=map(int,input().split(','))\n\t\tfunction(a,b,c,d,e)\n\texcept EOFError:\n\t\tbreak", "neg": "def function(a,b,c,d,e):\n\tA=[a,b,c,d,e]\n\tA.sort()\n\tprint(A)\n\t#4card\n\tif A[0]==A[3] or A[1]==A[4]:\n\t\tprint(\"four card\")\n\t#Full house\n\telif (A[0]==A[1] and A[2]==A[4]) or (A[0]==A[2] and A[3]==A[4]):\n\t\tprint(\"full house\")\n\t#three card\n\telif A[0]==A[2] or A[1]==A[3] or A[2]==A[4]:\n\t\tprint(\"three card\")\n\telif (A[0]==A[1] and A[2]==A[3]) or (A[0]==A[1] and A[3]==A[4]) or (A[1]==A[2] and A[3]==A[4]):\n\t\tprint(\"two pair\")\n\telif A[0]==A[1] or A[1]==A[2] or A[2]==A[3] or A[3]==A[4]:\n\t\tprint(\"one pair\")\n\t#straight A?????????\n\telif A==[1,10,11,12,13]:\n\t\tprint(\"straight\")\n\t#straight A???????????????\n\telif A[0]==A[1]-1==A[2]-2==A[3]-3==A[4]-4:\n\t\tprint(\"straight\")\n\telse:\n\t\tprint(\"null\")\n\nwhile True:\n\ttry:\n\t\ta,b,c,d,e=map(int,input().split(','))\n\t\tfunction(a,b,c,d,e)\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 0.9310344827586207, "nl": "Poker\n\nCreate a program that reads hand data for poker and outputs the corresponding hand ranking for each hand. The rules for this problem are as follows:\n\n- Poker is a game played with 5 cards.\n- There are no more than 5 cards of the same number.\n- There are no jokers.\n- Consider only the following poker hands (higher numbers indicate higher ranks):\n 1. No hand (none of the below)\n 2. One pair (2 cards of the same number)\n 3. Two pair (2 sets of 2 cards of the same number)\n 4. Three of a kind (3 cards of the same number)\n 5. Straight (5 cards with consecutive numbers)\n 6. Full house (3 cards of the same number and 2 cards of another same number)\n 7. Four of a kind (4 cards of the same number)\n\nInput:\nMultiple datasets, each in the format: card1,card2,card3,card4,card5\nCards are represented as J for Jack (11), Q for Queen (12), K for King (13), A for Ace (1), and other numbers as their respective values.\n\nOutput:\nFor each dataset, output the highest possible hand that can be formed from the given hand. Follow the output example for hand representation.\n\nSample Input:\n(As provided)\n\nOutput for the Sample Input:\n(As provided)\n\nNote: For the hand 3 3 2 3 3, the correct hand is \"four card\" instead of \"two pair\".", "before_after_length": [425, 471], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00038", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfor e in sys.stdin:\n e=list(map(int,e.split(',')))\n c=[e.count(i+1)for i in range(13)];d=c+c\n if 4 in c:s='four card'\n elif 3 in c:\n if 2 in c:s='full house'\n else:s='three card'\n elif 2 in c:\n if c.count(2)-1:s='two pair'\n else:s='one pair'\n elif sum([1]*5==d[i:i+5]for i in range(10)):s='straight'\n else:s='null'\n print(s)\n", "neg": "import sys\nfor e in sys.stdin:\n c=[list(map(int,e.split(','))).count(i+1)for i in range(13)];d=c+c\n print('four card'if 4 in c else'full house'if 2 in c else'three card'if 3 in c else'two pair'if c.count(2)-1 else'one pair'if 2 in c else'straight'if sum([1]*5==d[i:i+5]for i in range(10)) else'null')\n", "jacc_sim": 0.9607843137254902, "nl": "Poker\n\nCreate a program that reads hand data for poker and outputs the corresponding hand ranking for each hand. The rules for this problem are as follows:\n\n- Poker is a game played with 5 cards.\n- There are no more than 5 cards of the same number.\n- There are no jokers.\n- Consider only the following poker hands (higher numbers indicate higher ranks):\n 1. No hand (none of the below)\n 2. One pair (2 cards of the same number)\n 3. Two pair (2 sets of 2 cards of the same number)\n 4. Three of a kind (3 cards of the same number)\n 5. Straight (5 cards with consecutive numbers)\n 6. Full house (3 cards of the same number and 2 cards of another same number)\n 7. Four of a kind (4 cards of the same number)\n\nInput:\nMultiple datasets, each in the format: card1,card2,card3,card4,card5\nCards are represented as J for Jack (11), Q for Queen (12), K for King (13), A for Ace (1), and other numbers as their respective values.\n\nOutput:\nFor each dataset, output the highest possible hand that can be formed from the given hand. Follow the output example for hand representation.\n\nSample Input:\n(As provided)\n\nOutput for the Sample Input:\n(As provided)\n\nNote: For the hand 3 3 2 3 3, the correct hand is \"four card\" instead of \"two pair\".", "before_after_length": [162, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00038", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfor e in sys.stdin:\n e=sorted(map(int,e.split(',')))\n print([['null','straight'][e[0]*10==e[1]or e[4]-e[0]==4],'one pair','two pair','three card','full house',0,'four card'][sum(e.count(s)for s in e)//2-2])\n", "neg": "import sys\nfor e in sys.stdin:\n e=sorted(map(int,e.split(',')))\n print([['null','straight'][e[4]-e[0]==4 or e[0]*10==e[1]],'one pair','two pair','three card','full house',0,'four card'][(sum(e.count(s)for s in e)//2-2])\n", "jacc_sim": 1.0, "nl": "Poker\n\nCreate a program that reads hand data for poker and outputs the corresponding hand ranking for each hand. The rules for this problem are as follows:\n\n- Poker is a game played with 5 cards.\n- There are no more than 5 cards of the same number.\n- There are no jokers.\n- Consider only the following poker hands (higher numbers indicate higher ranks):\n 1. No hand (none of the below)\n 2. One pair (2 cards of the same number)\n 3. Two pair (2 sets of 2 cards of the same number)\n 4. Three of a kind (3 cards of the same number)\n 5. Straight (5 cards with consecutive numbers)\n 6. Full house (3 cards of the same number and 2 cards of another same number)\n 7. Four of a kind (4 cards of the same number)\n\nInput:\nMultiple datasets, each in the format: card1,card2,card3,card4,card5\nCards are represented as J for Jack (11), Q for Queen (12), K for King (13), A for Ace (1), and other numbers as their respective values.\n\nOutput:\nFor each dataset, output the highest possible hand that can be formed from the given hand. Follow the output example for hand representation.\n\nSample Input:\n(As provided)\n\nOutput for the Sample Input:\n(As provided)\n\nNote: For the hand 3 3 2 3 3, the correct hand is \"four card\" instead of \"two pair\".", "before_after_length": [98, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00038", "p_user": "u136916346", "n_user": "u136916346", "pos": "from collections import Counter\nimport sys\n\nfor t in sys.stdin:\n l=sorted(map(int,t[:-1].split(\",\")))\n s=False\n p1=Counter(l)\n p2=Counter(p1.values())\n\n if 3 in p2 and 2 in p2:\n print(\"full house\")\n elif 2 in p2:\n if p2[2]==1:\n print(\"one pair\")\n elif p2[2]==2:\n print(\"two pair\")\n elif 3 in p2:\n print(\"three card\")\n elif 4 in p2:\n print(\"four card\")\n else:\n for i in range(1,10):\n if list(range(i,i+5))==l:\n print(\"straight\")\n s=True\n break\n if [1,10,11,12,13]==l:\n print(\"straight\")\n s=True\n if not s:\n print(\"null\")\n\n", "neg": "from collections import Counter\nimport sys\n\nfor t in sys.stdin:\n l=sorted(map(int,t[:-1].split(\",\")))\n s=False\n p1=Counter(l)\n p2=Counter(p1.values())\n\n if 3 in p2 and 2 in p2:\n print(\"full house\")\n elif 2 in p2:\n if p2[2]==1:\n print(\"one pair\")\n elif p2[2]==2:\n print(\"two pair\")\n elif 3 in p2:\n print(\"three card\")\n elif 4 in p2:\n print(\"four card\")\n else:\n for i in range(1,10):\n if list(range(i,i+5))==l:\n print(\"straight\")\n s=True\n break\n if [1,10,11,12,13]==i:\n print(\"straight\")\n s=True\n if not s:\n print(\"null\")\n\n", "jacc_sim": 1.0, "nl": "Poker\n\nCreate a program that reads hand data for poker and outputs the corresponding hand ranking for each hand. The rules for this problem are as follows:\n\n- Poker is a game played with 5 cards.\n- There are no more than 5 cards of the same number.\n- There are no jokers.\n- Consider only the following poker hands (higher numbers indicate higher ranks):\n 1. No hand (none of the below)\n 2. One pair (2 cards of the same number)\n 3. Two pair (2 sets of 2 cards of the same number)\n 4. Three of a kind (3 cards of the same number)\n 5. Straight (5 cards with consecutive numbers)\n 6. Full house (3 cards of the same number and 2 cards of another same number)\n 7. Four of a kind (4 cards of the same number)\n\nInput:\nMultiple datasets, each in the format: card1,card2,card3,card4,card5\nCards are represented as J for Jack (11), Q for Queen (12), K for King (13), A for Ace (1), and other numbers as their respective values.\n\nOutput:\nFor each dataset, output the highest possible hand that can be formed from the given hand. Follow the output example for hand representation.\n\nSample Input:\n(As provided)\n\nOutput for the Sample Input:\n(As provided)\n\nNote: For the hand 3 3 2 3 3, the correct hand is \"four card\" instead of \"two pair\".", "before_after_length": [247, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00039", "p_user": "u379956761", "n_user": "u379956761", "pos": "import sys\n\ndef dec_num(x):\n for i in range(len(x)):\n if x[i] == 2:\n x[i] = 5\n elif x[i] == 3:\n x[i] = 10\n elif x[i] == 4:\n x[i] = 50\n elif x[i] == 5:\n x[i] = 100\n elif x[i] == 6:\n x[i] = 500\n elif x[i] == 7:\n x[i] = 1000\n\ndef to_index(x):\n if x == 1:\n return 1\n elif x == 5:\n return 2\n elif x == 10:\n return 3\n elif x == 50:\n return 4\n elif x == 100:\n return 5\n elif x == 500:\n return 6\n elif x == 1000:\n return 7\n\n\ndef toNum(x):\n result = 0\n tmp = x[0]\n for i in range(len(x)):\n if tmp < x[i]:\n result += x[i]-tmp\n elif i < len(x)-1 and x[i] < x[i+1]:\n result += 0\n else:\n result += x[i]\n tmp = x[i] \n\n return result\n\nfor line in sys.stdin.readlines():\n line = line.translate(str.maketrans('IVXLCDM', '1234567'))\n num = list(map(int, (' '.join(line)).split()))\n dec_num(num)\n print(toNum(num))", "neg": "import sys\n\ndef dec_num(x):\n for i in range(len(x)):\n if x[i] == 2:\n x[i] = 5\n elif x[i] == 3:\n x[i] = 10\n elif x[i] == 4:\n x[i] = 50\n elif x[i] == 5:\n x[i] = 100\n elif x[i] == 6:\n x[i] = 500\n elif x[i] == 7:\n x[i] = 1000\n\ndef to_index(x):\n if x == 1:\n return 1\n elif x == 5:\n return 2\n elif x == 10:\n return 3\n elif x == 50:\n return 4\n elif x == 100:\n return 5\n elif x == 500:\n return 6\n elif x == 1000:\n return 7\n\n\ndef toNum(x):\n result = 0\n tmp = x[0]\n for i in range(len(x)):\n if tmp < x[i]:\n result += x[i]-tmp\n elif i <= len(x) and x[i] < x[i+1]:\n result += 0\n else:\n result += x[i]\n tmp = x[i] \n\n return result\n\nfor line in sys.stdin.readlines():\n line = line.translate(str.maketrans('IVXLCDM', '1234567'))\n num = list(map(int, (' '.join(line)).split()))\n dec_num(num)\n print(toNum(num))", "jacc_sim": 1.0, "nl": "Title: Roman Numerals\n\nIn ancient Rome, counting numbers was a challenging task. The Arabic numerals 0, 1, 2, 3, ..., 9 were not yet in use. Instead, the following symbols were used:\n\nArabic Numeral | Roman Numeral | Arabic Numeral | Roman Numeral | Arabic Numeral | Roman Numeral\n--- | --- | --- | --- | --- | ---\n1 | I | 11 | XI | 30 | XXX\n2 | II | 12 | XII | 40 | XL\n3 | III | 13 | XIII | 50 | L\n4 | IV | 14 | XIV | 60 | LX\n5 | V | 15 | XV | 70 | LXX\n6 | VI | 16 | XVI | 80 | LXXX\n7 | VII | 17 | XVII | 90 | XC\n8 | VIII | 18 | XVIII | 100 | C\n9 | IX | 19 | XIX | 500 | D\n10 | X | 20 | XX | 1000 | M\n\nI represents 1, V represents 5, X represents 10, L represents 50, C represents 100, D represents 500, and M represents 1000. For other examples, refer to the table above. When a smaller number follows a larger number (i.e., on the right), they are added. When a smaller number precedes a larger number (i.e., on the left), the smaller number is subtracted from the larger number. A smaller number before a larger number for subtraction can only occur once.\n\nCreate a program to convert Roman numerals to Arabic numerals (standard numbers) and output the result. The given Roman numerals follow the rules mentioned above (although actual Roman numerals have more detailed rules, which are not considered here).\n\nInput:\nMultiple datasets are provided. Each dataset consists of a single line containing a Roman numeral represented by uppercase letters (I, V, X, L, C, D, M). The length of the Roman numeral string does not exceed 100 characters. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the Arabic numeral (integer) on a single line.\n\nSample Input:\nIV\nCCCCLXXXXVIIII\nCDXCIX\n\nOutput for the Sample Input:\n4\n499\n499", "before_after_length": [395, 394], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00039", "p_user": "u661290476", "n_user": "u661290476", "pos": "nums={\"I\":1,\"V\":5,\"X\":10,\"L\":50,\"C\":100,\"D\":500,\"M\":1000}\nwhile True:\n try:\n s=input()\n except:\n break\n ans=nums[s[0]]\n for i in range(1,len(s)):\n if nums[s[i-1]]= 0:\n DP[i][j] = max(DP[i-1][j],DP[i - 1][j - Nap[i - 1][1]] + Nap[i - 1][0])\n else:\n DP[i][j] = DP[i-1][j]\n omo = DP[N].index(DP[N][W])\n print(\"Case \",C_num,\":\",sep = \"\",end = \"\\n\")\n print(DP[N][W])\n print(omo)\n C_num += 1", "neg": "C_num = 1\nwhile True:\n Nap = []\n W = int(input())\n\n if W == 0:\n break\n N = int(input())\n for i in range(N):\n v,w = map(int,input().split(\",\"))\n Nap.append([v,w])\n DP = [[0 for j in range(W + 1)] for i in range(N + 1)]\n for i in range(1,N+1):\n for j in range(W+1):\n if j - Nap[i-1][1] >= 0:\n DP[i][j] = max(DP[i-1][j],DP[i - 1][j - Nap[i - 1][1]] + Nap[i - 1][0])\n else:\n DP[i][j] = DP[i-1][j]\n omo = DP[N].index(DP[N][W])\n print(\"Case \",C_num,\":\",sep = \"\",end = \"\\n\")\n print(DP[N][W])\n print(omo)", "jacc_sim": 1.0, "nl": "Title: Thief\n\nIn a museum where many treasures are stored, a thief sneaks in with a large cloth. There are many items the thief wants to steal, but the cloth can only withstand a limited weight. If exceeded, the cloth will tear. Therefore, the thief needs to consider a combination of treasures that does not exceed the cloth's weight limit and maximizes the total value without tearing the cloth.\n\nGiven the cloth's weight limit W and the value and weight of each individual treasure in the museum, create a program to output the total value and weight of the treasures that maximize the total value within the weight limit W. If there are multiple combinations with the maximum value, output the one with the smallest weight.\n\nInput:\nMultiple datasets are provided in the following format:\nW\nN\nv1, w1\nv2, w2\n...\nvN, wN\n\nThe first line contains an integer W representing the cloth's weight limit (W \u2264 1,000), and the second line contains an integer N representing the number of treasures (1 \u2264 N \u2264 1,000). The next N lines each contain the value vi (0 \u2264 vi \u2264 10,000) and the weight wi (0 \u2264 wi \u2264 W) of the i-th treasure.\n\nThe input ends when W is 0. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output as follows:\nCase dataset number:\nTotal value of treasures in the cloth\nTotal weight of the treasures in the cloth\n\nSample Input:\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n50\n5\n60,10\n100,20\n120,30\n210,45\n10,4\n0\n\nOutput for the Sample Input:\nCase 1:\n220\n49\nCase 2:\n220\n49", "before_after_length": [276, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00043", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\ndef f(c,h=0):\n if 2 in c and sum(c)==2:return 1\n if 5 in c:return 0 # sum(c)==2\n if 4 in c:\n k=c.index(4);c[k]-=3\n if f(c,h+1):return 1\n c[k]+=3\n if 3 in c:\n k=c.index(3);c[k]-=3\n if f(c,h+1):return 1\n c[k]+=3\n for i in range(7):\n if c[i]and c[i+1]and c[i+2]:\n c[i]-=1;c[i+1]-=1;c[i+2]-=1\n if f(c,h+1):return 1\n c[i]+=1;c[i+1]+=1;c[i+2]+=1\nn='123456789'\nfor e in sys.stdin:\n e=list(e)\n a=[i for i in n if f([(e+[i]).count(j)for j in n])]\n if a:print(*a)\n else:print(0)\n", "neg": "import sys\ndef f(c,h=0):\n if 2 in c and sum(c)==2:return 1\n if 5 in c:return 0 # sum(c)==2\n if 4 in c:\n k=c.index(4);c[k]-=3\n if f(c,h+1):return 1\n c[k]+=3\n if 3 in c:\n k=c.index(3);c[k]-=3\n if f(c,h+1):return 1\n c[k]+=3\n for i in range(7):\n if c[i]and c[i+1]and c[i+2]:\n c[i]-=1;c[i+1]-=1;c[i+2]-=1\n if f(c,h+1):return 1\n c[i]+=1;c[i+1]+=1;c[i+2]+=1\nn='123456789'\nfor e in sys.stdin:\n e=list(e.strip())\n a=[i for i in n if f([(e+[i]).count(j)for j in n])]\n print(*a if a else 0)\n", "jacc_sim": 0.9791666666666666, "nl": "Title: Puzzle\n\nThere is a puzzle to complete by combining 14 numbers from 1 to 9. Given 13 numbers, add one more to complete the puzzle.\n\nCompletion conditions:\n- Two of the same number are required.\n- The remaining 12 numbers are combined into four sets of three numbers.\n- The combination is either three of the same number or three consecutive numbers, excluding sequences like 9 1 2.\n- The same number can be used up to 4 times.\n\nCreate a program that reads a string of 13 numbers and outputs all the numbers in ascending order that can complete the puzzle. Output 0 if no number can complete the puzzle.\n\nFor example, given the string 3456666777999:\n- If \"2\" is added: 234 567 666 77 999\n- If \"3\" is added: 33 456 666 777 999\n- If \"5\" is added: 345 567 666 77 999\n- If \"8\" is added: 345 666 678 77 999\n\nInput:\nMultiple datasets, each with 13 numbers on a single line. No more than 50 datasets.\n\nOutput:\nFor each dataset, output the numbers that can complete the puzzle in ascending order, separated by a space.\n\nSample Input:\n3649596966777\n6358665788577\n9118992346175\n9643871425498\n7755542764533\n1133557799246\n\nOutput for the Sample Input:\n2 3 5 8\n3 4\n1 2 3 4 5 6 7 8 9\n7 8 9\n1 2 3 4 6 7 8\n0", "before_after_length": [293, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00044", "p_user": "u024715419", "n_user": "u024715419", "pos": "n = 50021\nc = [1 for i in range(n)]\nc[0] = 0\ni = 2\nwhile i**2 <= n:\n j = i*2\n while j <= n:\n c[j - 1] = 0\n j += i\n i += 1\n\nwhile True:\n try:\n n = int(input())\n i, a, b = 0, 0, 0\n while a == 0 or b == 0:\n i += 1\n if n - i - 1 >= 0 and a == 0 and c[n - i - 1] == 1:\n a = n - i\n if n + i - 1 < 50021 and b == 0 and c[n + i - 1] == 1:\n b = n + i\n print(a,b)\n except:\n break\n\n", "neg": "n = 50000\nc = [1 for i in range(n)]\nc[0] = 0\ni = 2\nwhile i**2 <= n:\n j = i*2\n while j <= n:\n c[j - 1] = 0\n j += i\n i += 1\n\nwhile True:\n try:\n n = int(input())\n i, a, b = 0, 0, 0\n while a == 0 and b == 0:\n i += 1\n if n - i >= 0 and a == 0 and c[n - i] == 1:\n a = n - i\n if n + i < 50000 and b == 0 and c[n + i] == 1:\n b = n + i\n print(a,b)\n except:\n break\n\n", "jacc_sim": 0.918918918918919, "nl": "Title: Prime Numbers II\n\nPrime numbers are integers greater than 1 that can only be divided by 1 and themselves. For example, 2 is a prime number because it can only be divided by 2 and 1, whereas 12 can be divided by 2, 3, 4, and 6 in addition to 12 and 1, so it is not a prime number.\n\nGiven an integer n, create a program to output the largest prime number smaller than n and the smallest prime number larger than n.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (3 <= n <= 50,000) on a single line. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the largest prime number smaller than n and the smallest prime number larger than n separated by a single space on a single line.\n\nSample Input:\n19\n3517\n\nOutput for the Sample Input:\n17 23\n3511 3527", "before_after_length": [199, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00045", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\n\nsum_price = sum_amount = kind = 0\nfor line in f:\n price, amount = map(int, line.split(','))\n sum_price += price * amount\n sum_amount += amount\n kind += 1\n \nprint(sum_price)\nprint(int(sum_amount / kind + 0.5))", "neg": "import sys\nf = sys.stdin\n\nsum_price = sum_amount = kind = 0\nfor line in f:\n price, amount = map(int, line.split(','))\n sum_price += price * amount\n sum_amount += amount\n kind += 1\n \nprint(sum_price, round(sum_amount / kind))", "jacc_sim": 0.9333333333333333, "nl": "Title: Sum and Average\n\nPlease create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.\n\nInput:\nThe input is given in the following format:\nUnit price, quantity sold\nUnit price, quantity sold\n...\n\nMultiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.\n\nOutput:\nOutput the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.\n\nSample Input:\n100,20\n50,10\n70,35\n\nOutput for the Sample Input:\n4950\n22", "before_after_length": [89, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00045", "p_user": "u964040941", "n_user": "u964040941", "pos": "A = []\nB = []\nwhile True:\n try:\n x,y = map(int,input().split(','))\n A.append(x)\n B.append(y)\n except EOFError:\n break\n\nN = len(A)\nprint(sum(A [i] * B [i] for i in range(N)))\nprint(sum(B) * 2 // N - sum(B) // N)", "neg": "A = []\nB = []\nwhile True:\n try:\n x,y = map(int,input().split(','))\n A.append(x)\n B.append(y)\n except EOFError:\n break\n\nN = len(A)\nprint(sum(A [i] * B [i] for i in range(N)),sum(B) * 2 // N - sum(B) // N)", "jacc_sim": 1.0, "nl": "Title: Sum and Average\n\nPlease create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.\n\nInput:\nThe input is given in the following format:\nUnit price, quantity sold\nUnit price, quantity sold\n...\n\nMultiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.\n\nOutput:\nOutput the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.\n\nSample Input:\n100,20\n50,10\n70,35\n\nOutput for the Sample Input:\n4950\n22", "before_after_length": [104, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00045", "p_user": "u868716420", "n_user": "u868716420", "pos": "Sum, Ave, Cou = 0, 0, 0\nwhile True :\n try :\n a, b = input().split(',')\n Sum += int(a) * int(b)\n Ave += int(b)\n Cou += 1\n except : break\nprint(Sum)\nif Ave / Cou - Ave // Cou >= 0.5 : print(Ave // Cou+1)\nelse : print(Ave//Cou)", "neg": "Sum, Ave, Cou = 0, 0, 0\nwhile True :\n try :\n a, b = input().split(',')\n Sum += int(a) * int(b)\n Ave += int(b)\n Cou += 1\n except : break\nif Ave / Cou - Ave // Cou > 0.5 : print(Sum, Ave // Cou+1)\nelse : print(Sum,Ave//Cou)", "jacc_sim": 1.0, "nl": "Title: Sum and Average\n\nPlease create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.\n\nInput:\nThe input is given in the following format:\nUnit price, quantity sold\nUnit price, quantity sold\n...\n\nMultiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.\n\nOutput:\nOutput the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.\n\nSample Input:\n100,20\n50,10\n70,35\n\nOutput for the Sample Input:\n4950\n22", "before_after_length": [110, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00045", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\ns=[list(map(int,e.split(',')))for e in sys.stdin]\nprint(sum(a*n for a,n in s))\nprint(int([sum(x)for x in zip(*s)][1]/len(s)+.5))\n", "neg": "import sys\ns=[list(map(int,e.split(',')))for e in sys.stdin]\nprint(sum(a*n for a,n in s),int([sum(x)for x in zip(*s)][1]/len(s)+.5))\n", "jacc_sim": 1.0, "nl": "Title: Sum and Average\n\nPlease create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.\n\nInput:\nThe input is given in the following format:\nUnit price, quantity sold\nUnit price, quantity sold\n...\n\nMultiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.\n\nOutput:\nOutput the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.\n\nSample Input:\n100,20\n50,10\n70,35\n\nOutput for the Sample Input:\n4950\n22", "before_after_length": [66, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00045", "p_user": "u724548524", "n_user": "u724548524", "pos": "from decimal import Decimal, ROUND_HALF_UP\nc = p = i = 0\nwhile 1:\n try:\n v, n = map(int, input().split(\",\"))\n i += 1\n c += n\n p += n * v\n except:break\nprint(p)\nprint(Decimal(c / i).quantize(Decimal('0'), rounding=ROUND_HALF_UP))\n", "neg": "from decimal import Decimal, ROUND_HALF_UP\nc = p = 0\nwhile 1:\n try:\n n, v = map(int, input().split(\",\"))\n c += n\n p += n * v\n except:break\nprint(p)\nprint(Decimal(p / c).quantize(Decimal('0'), rounding=ROUND_HALF_UP))\n", "jacc_sim": 0.9696969696969697, "nl": "Title: Sum and Average\n\nPlease create a program that reads unit price and quantity sold, and outputs the total sales amount and the average quantity sold.\n\nInput:\nThe input is given in the following format:\nUnit price, quantity sold\nUnit price, quantity sold\n...\n\nMultiple lines of comma-separated unit prices and quantities sold are provided. All input values are between 0 and 1,000, and the number of unit price and quantity sold pairs does not exceed 100.\n\nOutput:\nOutput the total sales amount (an integer) on the first line and the average quantity sold (an integer) on the second line. If there are decimal points in the average quantity sold, please round to the nearest tenth.\n\nSample Input:\n100,20\n50,10\n70,35\n\nOutput for the Sample Input:\n4950\n22", "before_after_length": [96, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00049", "p_user": "u078042885", "n_user": "u078042885", "pos": "a={'A':0,'B':0,'O':0,'AB':0}\nwhile 1:\n try:\n _,b=input().split(\",\")\n a[b]+=1\n except:\n for i in ['A','B','AB','O']:print(a[i])\n break", "neg": "a={'A':0,'B':0,'O':0,'AB':0}\nwhile 1:\n try:\n _,b=input().split(\",\")\n a[b]+=1\n except:\n for i in a:print(a[i])\n break", "jacc_sim": 1.0, "nl": "Blood Type\n\nRead data containing the attendance numbers and ABO blood types of students in a class, and create a program to output the number of individuals for each blood type. The ABO blood types include A, B, AB, and O.\n\nInput\n\nMultiple lines containing comma-separated pairs of attendance numbers and blood types. The attendance numbers are integers between 1 and 50, and the blood types are strings \"A\", \"B\", \"AB\", or \"O\". The number of students does not exceed 50.\n\nOutput\n\nOutput the number of individuals for each blood type in the following order:\n1st line: Number of individuals with blood type A\n2nd line: Number of individuals with blood type B\n3rd line: Number of individuals with blood type AB\n4th line: Number of individuals with blood type O\n\nSample Input\n\n1,B\n2,A\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A\n\nOutput for the Sample Input\n\n5\n4\n3\n2", "before_after_length": [75, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00049", "p_user": "u024715419", "n_user": "u024715419", "pos": "a = 0\nb = 0\no = 0\nab = 0\nwhile True:\n try:\n n, bt = input().split(\",\")\n if bt ==\"A\":\n a += 1\n elif bt ==\"B\":\n b += 1\n elif bt ==\"O\":\n o += 1\n elif bt ==\"AB\":\n ab += 1\n except:\n break\nprint(a, b, ab, o, sep=\"\\n\")\n\n", "neg": "a = 0\nb = 0\no = 0\nab = 0\nwhile True:\n try:\n n, bt = input().split(\",\")\n if bt ==\"A\":\n a += 1\n elif bt ==\"B\":\n b += 1\n elif bt ==\"O\":\n o += 1\n elif bt ==\"AB\":\n ab += 1\n except:\n break\nprint(a, b, o, ab, sep=\"\\n\")\n\n", "jacc_sim": 1.0, "nl": "Blood Type\n\nRead data containing the attendance numbers and ABO blood types of students in a class, and create a program to output the number of individuals for each blood type. The ABO blood types include A, B, AB, and O.\n\nInput\n\nMultiple lines containing comma-separated pairs of attendance numbers and blood types. The attendance numbers are integers between 1 and 50, and the blood types are strings \"A\", \"B\", \"AB\", or \"O\". The number of students does not exceed 50.\n\nOutput\n\nOutput the number of individuals for each blood type in the following order:\n1st line: Number of individuals with blood type A\n2nd line: Number of individuals with blood type B\n3rd line: Number of individuals with blood type AB\n4th line: Number of individuals with blood type O\n\nSample Input\n\n1,B\n2,A\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A\n\nOutput for the Sample Input\n\n5\n4\n3\n2", "before_after_length": [112, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00049", "p_user": "u553148578", "n_user": "u553148578", "pos": "ac = bc = oc = abc = 0\nwhile 1:\n\ttry: n, bt = input().split(\",\")\n\texcept: break\n\tif bt == \"A\": ac += 1\n\telif bt == \"B\": bc += 1\n\telif bt == \"O\": oc += 1\n\telif bt == \"AB\": abc +=1\nprint(ac)\nprint(bc)\nprint(abc)\nprint(oc)\n", "neg": "ac = bc = oc = abc = 0\nwhile 1:\n\ttry: n, bt = input().split(\",\")\n\texcept: break\n\tif bt == \"A\": ac += 1\n\telif bt == \"B\": bc += 1\n\telif bt == \"O\": oc += 1\n\telif bt == \"AB\": abc +=1\nprint(ac)\nprint(bc)\nprint(oc)\nprint(abc)\n", "jacc_sim": 1.0, "nl": "Blood Type\n\nRead data containing the attendance numbers and ABO blood types of students in a class, and create a program to output the number of individuals for each blood type. The ABO blood types include A, B, AB, and O.\n\nInput\n\nMultiple lines containing comma-separated pairs of attendance numbers and blood types. The attendance numbers are integers between 1 and 50, and the blood types are strings \"A\", \"B\", \"AB\", or \"O\". The number of students does not exceed 50.\n\nOutput\n\nOutput the number of individuals for each blood type in the following order:\n1st line: Number of individuals with blood type A\n2nd line: Number of individuals with blood type B\n3rd line: Number of individuals with blood type AB\n4th line: Number of individuals with blood type O\n\nSample Input\n\n1,B\n2,A\n3,B\n4,AB\n5,B\n6,O\n7,A\n8,O\n9,AB\n10,A\n11,A\n12,B\n13,AB\n14,A\n\nOutput for the Sample Input\n\n5\n4\n3\n2", "before_after_length": [100, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u990228206", "n_user": "u990228206", "pos": "w=str(input())\nfor i in range(len(w)):\n if i>len(w):break\n if w[i]==\"a\" and w[i+1]==\"p\" and w[i+2]==\"p\" and w[i+3]==\"l\" and w[i+4]==\"e\":\n w=w[:i]+\"peach\"+w[i+5:]\n continue\n if w[i]==\"p\" and w[i+1]==\"e\" and w[i+2]==\"a\" and w[i+3]==\"c\" and w[i+4]==\"h\":\n w=w[:i]+\"apple\"+w[i+5:]\nprint(w)\n", "neg": "w=str(input())\nprint(len(w))\nfor i in range(len(w)):\n if i>len(w):break\n if w[i]==\"a\" and w[i+1]==\"p\" and w[i+2]==\"p\" and w[i+3]==\"l\" and w[i+4]==\"e\":\n w=w[:i]+\"peach\"+w[i+5:]\n continue\n if w[i]==\"p\" and w[i+1]==\"e\" and w[i+2]==\"a\" and w[i+3]==\"c\" and w[i+4]==\"h\":\n w=w[:i]+\"apple\"+w[i+5:]\nprint(w)\n", "jacc_sim": 1.0, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [174, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u075836834", "n_user": "u075836834", "pos": "string=input()\nstring1=string.replace('peach','tmp')\nstring2=string1.replace('apple','peach')\nstring3=string2.replace('tmp','apple')\nprint(string3)", "neg": "string=input()\nprint(string)\nstring1=string.replace('peach','tmp')\nstring2=string1.replace('apple','peach')\nstring3=string2.replace('tmp','apple')\nprint(string3)", "jacc_sim": 1.0, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [52, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u886766186", "n_user": "u886766186", "pos": "s = input()\ns = s.replace(\"apple\", \"temp\")\ns = s.replace(\"peach\", \"apple\")\ns = s.replace(\"temp\", \"peach\");\nprint(s)", "neg": "s = input()\ns.replace(\"apple\", \"temp\")\ns.replace(\"peach\", \"apple\")\ns.replace(\"temp\", \"apple\");\nprint(s)", "jacc_sim": 1.0, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [49, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u868716420", "n_user": "u868716420", "pos": "from collections import deque\n\nresult = deque()\nfor _ in input().split():\n if 'apple' in _ : \n if _ == 'apple' : result.append('peach') \n else : result.append(_.replace('apple', 'peach'))\n elif 'peach' in _ : \n if _ == 'peach' : result.append('apple')\n else : result.append(_.replace('peach', 'apple'))\n else : result.append(_)\nprint(*result)", "neg": "from collections import deque\n\nresult = deque()\nfor _ in input().split():\n if 'apple' in _ : result.append(_.replace('peach', 'apple'))\n elif 'peach' in _ : result.append(_.replace('apple', 'peach'))\n else : result.append(_)\nprint(*result)", "jacc_sim": 1.0, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [122, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u519227872", "n_user": "u519227872", "pos": "s = input().split()\nss = []\nfor w in s:\n a = w.find('apple')\n p = w.find('peach')\n if a != -1:\n w = w.replace('apple','peach')\n elif p != -1:\n w = w.replace('peach','apple')\n ss.append(w)\nprint(' '.join(ss))", "neg": "s = input().split()\nss = []\nfor w in s:\n a = w.find('apple')\n p = w.find('peach')\n if a != -1:\n w = w.replace('apple','peach')\n elif p != -1:\n w = w.replace('peach','apple')\n ss.append(word)\nprint(' '.join(ss))", "jacc_sim": 0.967741935483871, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [98, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u546285759", "n_user": "u546285759", "pos": "ans = []\nfor word in input().split():\n if \"apple\" in word:\n ans.append(word.replace(\"apple\", \"peach\"))\n elif \"peach\" in word:\n ans.append(word.replace(\"peach\", \"apple\"))\n else:\n ans.append(word)\nprint(*ans)", "neg": "ans = []\nfor word in input().split():\n if \"apple\" in word:\n ans.append(word.replace(\"apple\", \"peach\"))\n elif \"peach\" in word:\n ans.append(word.replace(\"peach\", \"apple\"))\n else:\n ans.append(word)\nprint(*word)", "jacc_sim": 1.0, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [84, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u024715419", "n_user": "u024715419", "pos": "inp = input()\ntmp = inp.replace(\"apple\", \"XXX\")\ntmp = tmp.replace(\"peach\", \"apple\")\nprint(tmp.replace(\"XXX\", \"peach\"))\n\n", "neg": "inp = input()\ntmp = inp.replace(\"apple\", \"XXX\")\ntmp = tmp.replace(\"pearch\", \"apple\")\nprint(tmp.replace(\"XXX\", \"peach\"))\n\n", "jacc_sim": 0.9333333333333333, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [47, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u136916346", "n_user": "u136916346", "pos": "import re\ns=input()\ns=re.sub(\"peach\",\"!!!!!\",s)\ns=re.sub(\"apple\",\"peach\",s)\ns=re.sub(\"!!!!!\",\"apple\",s)\nprint(s)\n\n\n", "neg": "import re\ns=input()\nprint(re.sub(\"peach\",\"apple\",s))\n\n", "jacc_sim": 0.9333333333333333, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [60, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00050", "p_user": "u108130680", "n_user": "u150984829", "pos": "print(input().replace('apple','*').replace('peach','apple').replace('*','peach'))\n", "neg": "print(input().replace('apple','peach'))\n", "jacc_sim": 0.9090909090909091, "nl": "Title: Apples and Peaches\n\nFukushima Prefecture is famous for its fruit production, particularly for its high production of peaches and apples. However, a mistake was made in a sales brochure, swapping the descriptions of apples and peaches.\n\nYour task is to create a program that takes a single line of English text as input and outputs the same text with all instances of \"apple\" replaced by \"peach\" and all instances of \"peach\" replaced by \"apple\".\n\nInput:\nA single line of English text containing alphanumeric characters, spaces, and symbols. The length of the input string is at most 1000 characters.\n\nOutput:\nOutput the modified English text with \"apple\" and \"peach\" swapped.\n\nSample Input:\nthe cost of one peach is higher than that of one apple.\n\nOutput for the Sample Input:\nthe cost of one apple is higher than that of one peach.", "before_after_length": [27, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00052", "p_user": "u990228206", "n_user": "u990228206", "pos": "while 1:\n zero=0\n number=1\n n=int(input())\n if n==0:break\n for i in range(1,n+1):\n number*=i\n while len(str(number))>7:number=int(str(number)[1:])\n while number%10==0:\n zero+=1\n number=int(number/10)\n print(zero)\n", "neg": "while 1:\n try:\n zero=0\n number=1\n n=int(input())\n for i in range(1,n+1):\n number*=i\n while len(str(number))>7:number=int(str(number)[1:])\n while number%10==0:\n zero+=1\n number=int(number/10)\n print(zero)\n except:break\n", "jacc_sim": 0.9090909090909091, "nl": "Factorial II\n\nn! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1\n\nThis is called the factorial of n. For example, the factorial of 12 is 479001600, which ends with two consecutive zeros.\n\nCreate a program that takes an integer n as input and outputs the number of consecutive zeros at the end of n!.\n\nInput\nMultiple data sets are provided. Each data set contains n (n \u2264 20000) on a single line. The input ends when n is 0.\n\nThere are no more than 20 data sets.\n\nOutput\nFor each data set, output the number of consecutive zeros at the end of n! on a single line.\n\nSample Input\n2\n12\n10000\n0\n\nOutput for the Sample Input\n0\n2\n2499", "before_after_length": [103, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00052", "p_user": "u994049982", "n_user": "u994049982", "pos": "def fac(a):\n i=0\n b=5\n while b<=a:\n i+=(a//b)\n b*=5\n return i\nwhile True:\n a=int(input())\n if a!=0:\n print(fac(a))\n else:\n break", "neg": "def fac(a):\n i=0\n b=5\n c=1\n while b<=a:\n i+=c*(a//b)\n b*=5\n c+=1\n return i\nwhile True:\n a=int(input())\n if a!=0:\n print(fac(a))\n else:\n break", "jacc_sim": 0.9259259259259259, "nl": "Factorial II\n\nn! = n * (n - 1) * (n - 2) * ... * 3 * 2 * 1\n\nThis is called the factorial of n. For example, the factorial of 12 is 479001600, which ends with two consecutive zeros.\n\nCreate a program that takes an integer n as input and outputs the number of consecutive zeros at the end of n!.\n\nInput\nMultiple data sets are provided. Each data set contains n (n \u2264 20000) on a single line. The input ends when n is 0.\n\nThere are no more than 20 data sets.\n\nOutput\nFor each data set, output the number of consecutive zeros at the end of n! on a single line.\n\nSample Input\n2\n12\n10000\n0\n\nOutput for the Sample Input\n0\n2\n2499", "before_after_length": [77, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00053", "p_user": "u744114948", "n_user": "u744114948", "pos": "import math\ndef pri(n):\n if n < 2:\n return False\n elif n == 2:\n return True\n elif n % 2 == 0:\n return False\n\n i = 3\n while i <= math.sqrt(n):\n if n % i == 0:\n return False\n i += 2\n return True\n\nl=[i for i in range(110000)if pri(i) ]\n\nwhile True:\n n = int(input())\n if n == 0: break\n print(sum(l[:n]))", "neg": "import math\ndef pri(n):\n if n < 2:\n return False\n elif n == 2:\n return True\n elif n % 2 == 0:\n return False\n\n i = 3\n while i <= math.sqrt(n):\n if n % i == 0:\n return False\n i += 2\n return True\n\nl=[i for i in range(110000)if pri(i) ]\n\nprint(len(l))\n\nwhile True:\n n = int(input())\n if n == 0: break\n sum = 0\n for i in range(n):\n sum += l[i]\n print(sum)", "jacc_sim": 0.972972972972973, "nl": "Title: Sum of Prime Numbers\n\nGiven a positive integer n, find the sum of the first n prime numbers. For example, when n = 9, the sum is 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (n \u2264 10000). The input ends when n equals 0. There are no more than 50 datasets.\n\nOutput:\nFor each dataset, output the sum s on a new line.\n\nSample Input:\n2\n9\n0\n\nOutput for the Sample Input:\n5\n100", "before_after_length": [132, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00053", "p_user": "u150984829", "n_user": "u150984829", "pos": "from itertools import *\nn=104730;a=list(range(n));a[:2]=0,0\nfor i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])\np=list(compress(range(n),a))\nfor e in iter(input,'0'):print(sum(p[:int(e)]))\n", "neg": "import itertools\nn=104730;a=list(range(n));a[:2]=0,0\nfor i in range(2,323):\n a[i*2::i]=[0]*len(a[i*2::i])\np=list(itertools.compress(range(n),a))\nprint(len(p))\nfor e in iter(input,'0'):print(sum(p[:int(e)]))\n", "jacc_sim": 0.9411764705882353, "nl": "Title: Sum of Prime Numbers\n\nGiven a positive integer n, find the sum of the first n prime numbers. For example, when n = 9, the sum is 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (n \u2264 10000). The input ends when n equals 0. There are no more than 50 datasets.\n\nOutput:\nFor each dataset, output the sum s on a new line.\n\nSample Input:\n2\n9\n0\n\nOutput for the Sample Input:\n5\n100", "before_after_length": [95, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00053", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfrom itertools import *\nn=104730;a=list(range(n));a[:2]=0,0\nfor i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])\np=list(compress(range(n),a))\nfor e in sys.stdin:\n if'0\\n'!=e:print(sum(p[:int(e)]))\n", "neg": "import sys\nfrom itertools import *\nn=104730;a=list(range(n));a[:2]=0,0\nfor i in range(2,323):a[i*2::i]=[0]*len(a[i*2::i])\np=list(compress(range(n),a))\nfor e in sys.stdin:\n if'0'!=e:print(sum(p[:int(e)]))\n", "jacc_sim": 0.972972972972973, "nl": "Title: Sum of Prime Numbers\n\nGiven a positive integer n, find the sum of the first n prime numbers. For example, when n = 9, the sum is 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (n \u2264 10000). The input ends when n equals 0. There are no more than 50 datasets.\n\nOutput:\nFor each dataset, output the sum s on a new line.\n\nSample Input:\n2\n9\n0\n\nOutput for the Sample Input:\n5\n100", "before_after_length": [106, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00053", "p_user": "u093607836", "n_user": "u093607836", "pos": "import sys\n\nn = 104729\na = [True] * n\na[0] = False\nfor i in range(2,n):\n\tif(a[i-1]):\n\t\tfor j in range(i**2-1, n, i):\n\t\t\ta[j] = False\na = [i[0]+1 for i in enumerate(a) if i[1]]\n\nfor s in sys.stdin:\n\tn = int(s)\n\tif n == 0:\n\t\texit()\n\tprint(sum(a[:n]))", "neg": "import sys\n\nn = 104729\na = [True] * n\na[0] = False\nfor i in range(2,n):\n\tif(a[i-1]):\n\t\tfor j in range(i**2-1, n, i):\n\t\t\ta[j] = False\na = [i[0]+1 for i in enumerate(a) if i[1]]\n\nfor s in sys.stdin:\n\tif s == '0':\n\t\texit()\n\tprint(sum(a[:int(s)]))", "jacc_sim": 0.9714285714285714, "nl": "Title: Sum of Prime Numbers\n\nGiven a positive integer n, find the sum of the first n prime numbers. For example, when n = 9, the sum is 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (n \u2264 10000). The input ends when n equals 0. There are no more than 50 datasets.\n\nOutput:\nFor each dataset, output the sum s on a new line.\n\nSample Input:\n2\n9\n0\n\nOutput for the Sample Input:\n5\n100", "before_after_length": [132, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00053", "p_user": "u436634575", "n_user": "u436634575", "pos": "N = 104743\np = [1]*(N + 1)\nfor i in range(4, N + 1, 2): p[i] = 0\na = [2]\nfor i in range(3, N + 1, 2):\n if p[i] == 1:\n a.append(a[-1] + i)\n for j in range(3*i, N + 1, 2*i): p[j] = 0\n\nwhile True:\n n = int(input())\n if n == 0: break\n print(a[n - 1])", "neg": "N = 104723\np = [1]*(N + 1)\nfor i in range(4, N + 1, 2): p[i] = 0\na = [2]\nfor i in range(3, N + 1, 2):\n if p[i] == 1:\n a.append(a[-1] + i)\n for j in range(3*i, N + 1, 2*i): p[j] = 0\nprint(len(a))\n\nwhile True:\n n = int(input())\n if n == 0: break\n print(a[n - 1])", "jacc_sim": 0.9166666666666666, "nl": "Title: Sum of Prime Numbers\n\nGiven a positive integer n, find the sum of the first n prime numbers. For example, when n = 9, the sum is 2 + 3 + 5 + 7 + 11 + 13 + 17 + 19 + 23 = 100.\n\nInput:\nMultiple datasets are provided. Each dataset contains an integer n (n \u2264 10000). The input ends when n equals 0. There are no more than 50 datasets.\n\nOutput:\nFor each dataset, output the sum s on a new line.\n\nSample Input:\n2\n9\n0\n\nOutput for the Sample Input:\n5\n100", "before_after_length": [134, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u619819312", "n_user": "u619819312", "pos": "n,k=map(int,input().split())\nb=[0]*(n+1)\nfor i in range(n):\n b[i+1]=b[i]+int(input())-k\na=sorted(set(b))\ns={a[i-1]:i for i in range(1,len(a)+1)}\nc=[]\nfor i in b:\n c.append(s[i])\nb=[0]*(len(a)+1)\ndef f(x):\n c=0\n while x>0:\n c+=b[x]\n x-=x&-x\n return c\ndef g(x):\n while x0:\n c+=b[x]\n x-=x&-x\n return c\ndef g(x):\n while x 0:\n s += bit[i]\n i -= i & (-i)\n return s\n\n def add(i, x):\n while i <= N:\n bit[i] += x\n i += i & (-i)\n\n ans = 0\n for i, l in enumerate(L_comp):\n if l == 0:\n ans += N-i\n continue\n ans += sum_bit(l)\n add(l, 1)\n print(ans)\n\n\nsolve()\n", "neg": "import bisect\nfrom itertools import accumulate\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef brute():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n ans = 0\n for i in range(N):\n for j in range(i, N):\n if sum(L[i:j+1])/(j+1-i) >= K:\n ans += 1\n\n print(ans)\n\n\ndef solve():\n N, K = map(int, input().split())\n L = [int(input()) for _ in range(N)]\n\n L_acc = [0]+list(accumulate(L))\n for i in range(N+1):\n L_acc[i] -= (i)*K\n\n L_sort = list(set(sorted(L_acc)))\n L_comp = [-1]*(N+1)\n for i in range(N+1):\n key = L_acc[i]\n ind = bisect.bisect_left(L_sort, key)\n L_comp[i] = ind\n # BIT\n bit = [0]*(N+1)\n\n def sum_bit(i):\n s = 0\n while i > 0:\n s += bit[i]\n i -= i & (-i)\n return s\n\n def add(i, x):\n while i <= N:\n bit[i] += x\n i += i & (-i)\n\n ans = 0\n for i, l in enumerate(L_comp):\n if l == 0:\n ans += N-i\n continue\n ans += sum_bit(l)\n add(l, 1)\n print(ans)\n\n\nsolve()\n", "jacc_sim": 0.9444444444444444, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [354, 452], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u631277801", "n_user": "u631277801", "pos": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom itertools import accumulate\n\nclass BIT(object):\n def __init__(self, size):\n self.size = size+1\n self.bitree = [0]*self.size\n \n def addval(self, idx:int, val:int):\n while idx < self.size:\n self.bitree[idx] += val\n idx += idx&(-idx)\n \n def getsum(self, idx:int):\n ret = 0\n while idx > 0:\n ret += self.bitree[idx]\n idx -= idx&(-idx)\n \n return ret\n \n def reset(self):\n self.bitree = [0]*self.size\n\n\ndef val2ord(a: list, rev=False):\n dic = {ai: i for i, ai in enumerate(sorted(a, reverse=rev))}\n return [dic[ai] for ai in a]\n\n\nn,k = li()\na = [ni() for _ in range(n)]\n\nacc = [0] + list(accumulate(a))\n\nb = [acci - i*k for i,acci in enumerate(acc)]\nc = val2ord(b)\n\nbitree = BIT(n+1)\n\nans = 0\nfor ci in c:\n bitree.addval(ci+1, 1)\n ans += bitree.getsum(ci+1)-1\n\nprint(ans)", "neg": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom itertools import accumulate\n\nclass BIT(object):\n def __init__(self, size):\n self.size = size+1\n self.bitree = [0]*self.size\n \n def addval(self, idx:int, val:int):\n if idx < self.size:\n self.bitree[idx] += val\n self.addval(idx + idx&(-idx), val)\n \n def getsum(self, idx:int):\n if idx <= 0:\n return 0\n else:\n return self.bitree[idx] + self.getsum(idx - idx&(-idx))\n \n def reset(self):\n self.bitree = [0]*self.size\n\n\ndef val2ord(a: list, rev=False):\n dic = {ai: i for i, ai in enumerate(sorted(a, reverse=rev))}\n return [dic[ai] for ai in a]\n\n\nn,k = li()\na = [ni() for _ in range(n)]\n\nacc = [0] + list(accumulate(a))\n\nb = [acci - i*k for i,acci in enumerate(acc)]\n\nc = val2ord(b)\n\nbitree = BIT(n+1)\n\nans = 0\n\nfor ci in c:\n bitree.addval(ci+1, 1)\n ans += bitree.getsum(ci+1)-1\n\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [481, 490], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u839537730", "n_user": "u839537730", "pos": "N, K = map(int, input().split())\na = []\nfor _ in range(N):\n a.append(int(input())-K)\n \nsu = 0\nv = [(0, 0)]\nfor i in range(N):\n su += a[i]\n v.append((su, i+1))\nv = sorted(v)\n\ndata = [0]*(N+5)\n\ndef sumation(i):\n s = 0\n while i > 0:\n s += data[i]\n i -= i & -i\n return s\n \ndef add(i, x):\n while i <= N+2:\n data[i] += x\n i += i & -i\nans = 0\nfor e, i in v:\n ans += sumation(i+1)\n add(i+1, 1)\n \nprint(ans)", "neg": "N, K = map(int, input().split())\na = []\nfor _ in range(N):\n a.append(int(input())-K)\n \nsu = 0\nv = [(0, 0)]\nfor i in range(N):\n su += a[i]\n v.append((su, i+1))\nv = sorted(v)\n\ndata = [0]*(N+1)\n\ndef sumation(i):\n s = 0\n while i > 0:\n s += data[i]\n i -= i & -i\n return s\n \ndef add(i, x):\n while i <= N:\n data[i] += x\n i += i & -i\nans = 0\nfor e, i in v:\n ans += sumation(i+1)\n add(i+1, 1)\n \nprint(ans)", "jacc_sim": 0.9555555555555556, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [214, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u582577761", "n_user": "u582577761", "pos": "n,k=map(int,input().split())\na=[0]+[int(input())-k for i in range(n)]\nfor i in range(1,n+1):\n\ta[i]+=a[i-1]\nb=sorted(a)+[-2e9-1]\nc,d=0,dict()\nfor i in range(n+1):\n\tif b[i]!=b[i-1]:\n\t\tc+=1\n\t\td[b[i]]=c\nbit=[0]*(n+5)\ndef sum(i):\n\tres=0\n\twhile i>0:\n\t\tres+=bit[i]\n\t\ti-=i&-i\n\treturn res\ndef add(i):\n\twhile i<=c:\n\t\tbit[i]+=1\n\t\ti+=i&-i\nans=0\nfor i in range(n+1):\n\tans+=sum(d[a[i]])\n\tadd(d[a[i]])\nprint(ans)", "neg": "n,k=map(int,input().split())\na=[0]+[int(input())-k for i in range(n)]\nfor i in range(1,n+1):\n\ta[i]+=a[i-1]\nb=sorted(a)+[-2e9-1]\nc,d=0,dict()\nfor i in range(n+1):\n\tif b[i]!=b[i-1]:\n\t\tc+=1\n\t\td[b[i]]=c\nbit=[0]*n\ndef sum(i):\n\tres=0\n\twhile i>0:\n\t\tres+=bit[i]\n\t\ti-=i&-i\n\treturn res\ndef add(i):\n\twhile i<=c:\n\t\tbit[i]+=1\n\t\ti+=i&-i\nans=0\nfor i in range(n+1):\n\tans+=sum(d[a[i]])\n\tadd(d[a[i]])\nprint(ans)", "jacc_sim": 0.9777777777777777, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [251, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u327466606", "n_user": "u327466606", "pos": "class BinaryIndexedTree:\n def __init__(self, size):\n self.data = [0] * (size+1)\n self.size = size\n \n def add(self, i, w):\n while i <= self.size:\n self.data[i] += w\n i += i & -i\n\n def sum(self, i):\n result = 0\n while i > 0:\n result += self.data[i]\n i -= i & -i\n return result\n\nfrom itertools import accumulate,repeat\n\nN,K = map(int, input().split())\n\nB = [0] + [sa-sk for sa,sk in zip(accumulate(int(input()) for _ in range(N)), accumulate(repeat(K)))]\n\nlookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))\n\nresult = 0\nbit = BinaryIndexedTree(N+1)\n\nfor b in B:\n c = lookup[b]\n result += bit.sum(c)\n bit.add(c,1)\n\nprint(result)", "neg": "class BinaryIndexedTree:\n def __init__(self, size):\n self.data = [0] * (size+1)\n self.size = size\n \n def add(self, i, w):\n while i <= self.size:\n self.data[i] += w\n i += i & -i\n\n def sum(self, i):\n result = 0\n while i > 0:\n result += self.data[i]\n i -= i & -i\n return result\n\nfrom itertools import accumulate,repeat\n\nN,K = map(int, input().split())\n\nB = [0] + [sa-sk for sa,sk in zip(accumulate(int(input())), accumulate(repeat(K, N)))]\n\nlookup = dict(((b,i+1) for i,b in enumerate(sorted(B))))\n\nresult = 0\nbit = BinaryIndexedTree(N+1)\n\nfor b in B:\n c = lookup[b]\n result += bit.sum(c)\n bit.add(c,1)\n\nprint(result)", "jacc_sim": 0.9661016949152542, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [266, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03703", "p_user": "u332385682", "n_user": "u332385682", "pos": "import sys\nfrom itertools import accumulate\n\ninf = 1<<60\nans = 0\n\ndef solve():\n n, k = map(int, sys.stdin.readline().split())\n a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]\n s = [0] + list(accumulate(a))\n\n MergeSort(s)\n\n print(ans)\n\ndef MergeSort(a):\n if len(a) == 1:\n return a\n\n apre = MergeSort(a[:len(a)//2])\n asuf = MergeSort(a[len(a)//2:])\n\n res = merge(apre, asuf)\n\n return res\n\ndef merge(a, b):\n global ans\n na = len(a)\n nb = len(b)\n\n a.append(-inf)\n b.append(-inf)\n\n la = 0\n lb = 0\n\n res = []\n\n for i in range(na + nb):\n if a[la] <= b[lb]:\n ans += na - la\n res.append(b[lb])\n lb += 1\n else:\n res.append(a[la])\n la += 1\n\n return res\n\nif __name__ == '__main__':\n solve()", "neg": "import sys\nfrom itertools import accumulate\n\ninf = 1<<60\nans = 0\n\ndef solve():\n n, k = map(int, sys.stdin.readline().split())\n a = [int(sys.stdin.readline().rstrip()) - k for i in range(n)]\n s = [0] + list(accumulate(a))\n\n print(ans)\n\ndef MergeSort(a):\n if len(a) == 1:\n return a\n\n apre = MergeSort(a[:len(a)//2])\n asuf = MergeSort(a[len(a)//2:])\n\n res = merge(apre, asuf)\n\n return res\n\ndef merge(a, b):\n global ans\n na = len(a)\n nb = len(b)\n\n a.append(-inf)\n b.append(-inf)\n\n la = 0\n lb = 0\n\n res = []\n\n for i in range(na + nb):\n if a[la] <= b[lb]:\n ans += na - la\n res.append(b[lb])\n lb += 1\n else:\n res.append(a[la])\n la += 1\n\n return res\n\nif __name__ == '__main__':\n solve()", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N, a = {a_1, a_2, \u2026, a_N}, and an integer K. Determine the number of non-empty contiguous subsequences of a with an arithmetic mean greater than or equal to K. Constraints: All input values are integers, 1 \u2264 N \u2264 2 * 10^5, 1 \u2264 K \u2264 10^9, 1 \u2264 a_i \u2264 10^9. Input is given as N K followed by the elements of the sequence a. Output the number of contiguous subsequences with an arithmetic mean greater than or equal to K. For example, given input 3 6 and sequence 7 5 7, the output is 5.", "before_after_length": [322, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03704", "p_user": "u236127431", "n_user": "u236127431", "pos": "from collections import deque\nD=int(input())\ndef f(d,k):\n if 0<=k<=1:\n if d!=0:\n return \"Unko\"\n if k==1:\n return deque([0])\n else:\n return deque([])\n if d>=0:\n s=10-(d%10)\n else:\n s=-(d%10)\n if s==10:\n A=f(d//10,k-2)\n s=0\n #print(d,s,d-s*(10**(k-1))+s)\n else:\n A=f((d-s*(10**(k-1))+s)//10,k-2)\n \n if A==\"Unko\":\n return \"Unko\"\n A.appendleft(s)\n A.append(-s)\n\n return A\nans=0\nfor k in range(1,50):\n A=f(D,k)\n if A==\"Unko\":\n continue\n # print(A)\n res=1\n for j in range((k+1)//2):\n if j==0:\n res*=9-abs(A[j])\n else:\n if A[j]==0:\n res*=10\n else:\n res*=10-abs(A[j])\n ans+=res\nprint(ans)", "neg": "from collections import deque\nD=int(input())\ndef f(d,k):\n if 0<=k<=1:\n if d!=0:\n return \"Unko\"\n if k==1:\n return deque([0])\n else:\n return deque([])\n s=10-(d%10)\n if s==10:\n A=f(d//10,k-2)\n s=0\n #print(d,s,d-s*(10**(k-1))+s)\n else:\n A=f((d-s*(10**(k-1))+s)//10,k-2)\n if A==\"Unko\":\n return \"Unko\"\n A.appendleft(s)\n A.append(-s)\n return A\nans=0\nfor k in range(1,50):\n A=f(D,k)\n if A==\"Unko\":\n continue\n print(A)\n res=1\n for j in range((k+1)//2):\n if j==0:\n res*=9-abs(A[j])\n else:\n if A[j]==0:\n res*=10\n else:\n res*=9-abs(A[j]-1)\n ans+=res\nprint(ans)", "jacc_sim": 0.9807692307692307, "nl": "You are given a positive integer D. Determine how many positive integers N satisfy the equation rev(N) = N + D, where rev(N) denotes the integer obtained by reversing the decimal notation of N (without leading zeroes). The input is a single integer D, and the output should be the number of positive integers N that satisfy the given equation.", "before_after_length": [348, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03708", "p_user": "u905582793", "n_user": "u905582793", "pos": "a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n abin=abin[1:]\n bbin=bbin[1:]\n while len(abin)>1 and abin[0]==\"0\":\n abin=abin[1:]\ncbin=bbin[1:]\nwhile cbin and cbin[0]==\"0\":\n cbin=cbin[1:]\nc=2**(len(cbin))-1\na=int(abin,2)\nb=int(bbin,2)\nlb=len(bbin)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(2**lb-a)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)\n", "neg": "a=int(input())\nb=int(input())\nif a==b:\n print(1)\n exit()\nabin=bin(a)[2:]\nbbin=bin(b)[2:]\nla=len(abin)\nlb=len(bbin)\nif la==lb:\n while abin[0]==bbin[0]:\n del abin[0]\n del bbin[0]\n while abin[0]==\"0\":\n del abin[0]\ncbin=bbin[1:]\nwhile cbin[0]==\"0\":\n del cbin[0]\nc=2**(len(cbin))\na=int(abin,2)\nlbnd=2**(lb-1)+c\nhbnd=2**(lb-1)+a\nif lbnd>=hbnd:\n print(lbnd-a+1)\nelse:\n print(2**(lb-1)-a+lbnd-a+1)", "jacc_sim": 0.9444444444444444, "nl": "Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). The task is to find the number of possible candidates for the value of Nukes's integer. The input consists of two integers, A and B, and the output should be the number of possible candidates for the value of Nukes's integer.", "before_after_length": [276, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03708", "p_user": "u211742028", "n_user": "u211742028", "pos": "\nimport math\nA = int(input())\nB = int(input())\nif B < A: A,B = B,A\n\nif A == B:\n print(1)\nelse:\n t = int(math.floor(math.log2(B)))\n while (A & 2**t) == (B & 2**t):\n if A & 2**t:\n A -= 2**t\n B -= 2**t\n t-=1\n ans = 2**t - A # [A,2^t-1]\n r = t-1\n while 2**t + 2**r > B and r>=0:\n r-=1\n # [2^t,2^t+2^{r+1}-1] \\cup [2^t+A,2^{t+1}-1]\n C = 2**(r+1)\n if C < A:\n ans += C + 2**t - A\n else:\n ans += 2**t\n print(ans)\n", "neg": "\nimport math\nA = int(input())\nB = int(input())\nif B < A: A,B = B,A\n\nif A == B:\n print(1)\nelse:\n t = int(math.floor(math.log2(B)))\n while (A & 2**t) == (B & 2**t):\n if A & 2**t:\n A -= 2**t\n B -= 2**t\n t-=1\n ans = 2**t - A # [A,2^t-1]\n r = t-1\n while 2**t + 2**r > B and r>=0:\n r-=1\n print(r)\n # [2^t,2^t+2^{r+1}-1] \\cup [2^t+A,2^{t+1}-1]\n C = 2**(r+1)\n if C < A:\n ans += C + 2**t - A\n else:\n ans += 2**t\n print(ans)\n", "jacc_sim": 1.0, "nl": "Nukes has an integer that can be represented as the bitwise OR of one or more integers between A and B (inclusive). The task is to find the number of possible candidates for the value of Nukes's integer. The input consists of two integers, A and B, and the output should be the number of possible candidates for the value of Nukes's integer.", "before_after_length": [249, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u523130469", "n_user": "u523130469", "pos": "import heapq\n\nn = int(input().strip())\na = list(map(int, input().split()))\npre = a[:n]\nheapq.heapify(pre)\nsuf = list(map(lambda x: -x, a[(2 * n):]))\nheapq.heapify(suf)\nleft = {}\nright = {}\npre_sum = sum(pre)\nsuf_sum = -sum(suf)\nleft[n - 1] = pre_sum\nright[2 * n] = suf_sum\nfor i in range(n, 2 * n):\n heapq.heappush(pre, a[i])\n pre_sum = pre_sum + a[i] - heapq.heappop(pre)\n left[i] = pre_sum\nfor i in range(2 * n - 1, n - 1, -1):\n heapq.heappush(suf, -a[i])\n suf_sum = suf_sum + a[i] + heapq.heappop(suf)\n right[i] = suf_sum\nans = -float('inf')\nfor i in range(n - 1, 2 * n):\n ans = max(ans, left[i] - right[i + 1])\nprint(ans)\n", "neg": "import heapq\n\nn = int(input().strip())\na = list(map(int, input().split()))\npre = a[:n]\nheapq.heapify(pre)\nsuf = list(map(lambda x: -x, a[(2 * n):]))\nheapq.heapify(suf)\nleft = {}\nright = {}\npre_sum = sum(pre)\nsuf_sum = -sum(suf)\nleft[n - 1] = pre_sum\nright[2 * n] = suf_sum\nfor i in range(n, 2 * n):\n heapq.heappush(pre, a[i])\n pre_sum = pre_sum + a[i] - heapq.heappop(pre)\n left[i] = pre_sum\nfor i in range(2 * n - 1, n - 1, -1):\n heapq.heappush(suf, -a[i])\n suf_sum = suf_sum + a[i] + heapq.heappop(suf)\n right[i] = suf_sum\nans = -float('inf')\nprint(left)\nprint(right)\nfor i in range(n - 1, 2 * n - 1):\n ans = max(ans, left[i] - right[i + 1])\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [309, 321], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u892487306", "n_user": "u892487306", "pos": "from collections import deque\nfrom heapq import heapify, heappop, heappush\nN = int(input())\ntmp = list(map(int, input().split(' ')))\nformer_A = deque(tmp)\nlatter_A = deque(tmp.copy())\nformer_heap = list()\nlatter_heap = list()\nfor _ in range(N):\n former_heap.append(former_A.popleft())\n latter_heap.append(- latter_A.pop())\nheapify(former_heap)\nheapify(latter_heap)\n\nformer_sum = sum(former_heap)\nformer_sum_list = [former_sum]\nfor k in range(N):\n new_a = former_A.popleft()\n heappush(former_heap, new_a)\n min_a = heappop(former_heap)\n former_sum += new_a - min_a\n former_sum_list.append(former_sum)\n\nlatter_sum = sum(latter_heap)\nlatter_sum_list = [latter_sum]\nfor k in range(N):\n new_a = - latter_A.pop()\n heappush(latter_heap, new_a)\n min_a = heappop(latter_heap)\n latter_sum += new_a - min_a\n latter_sum_list.append(latter_sum)\nlatter_sum_list.reverse()\n\nanswer = max([former + latter for former, latter in zip(former_sum_list, latter_sum_list)])\nprint(answer)", "neg": "N = int(input())\ntmp = list(map(int, input().split(' ')))\nformer_A = deque(tmp)\nlatter_A = deque(tmp.copy())\nformer_heap = list()\nlatter_heap = list()\nfor _ in range(N):\n former_heap.append(former_A.popleft())\n latter_heap.append(- latter_A.pop())\nheapify(former_heap)\nheapify(latter_heap)\n\nformer_sum = sum(former_heap)\nformer_sum_list = [former_sum]\nfor k in range(N):\n new_a = former_A.popleft()\n heappush(former_heap, new_a)\n min_a = heappop(former_heap)\n former_sum += new_a - min_a\n former_sum_list.append(former_sum)\n\nlatter_sum = sum(latter_heap)\nlatter_sum_list = [latter_sum]\nfor k in range(N):\n new_a = - latter_A.pop()\n heappush(latter_heap, new_a)\n min_a = heappop(latter_heap)\n latter_sum += new_a - min_a\n latter_sum_list.append(latter_sum)\nlatter_sum_list.reverse()\n\nanswer = max([former + latter for former, latter in zip(former_sum_list, latter_sum_list)])\nprint(answer)", "jacc_sim": 0.9245283018867925, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [382, 362], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u547167033", "n_user": "u547167033", "pos": "import heapq\nn=int(input())\na=list(map(int,input().split()))\ns1=sum(a[:n])\nhq1=a[:n]\nheapq.heapify(hq1)\nA=[s1]\nfor i in range(n,2*n):\n s1+=a[i]\n heapq.heappush(hq1,a[i])\n x=heapq.heappop(hq1)\n s1-=x\n A.append(s1)\na=a[::-1]\ns2=sum(a[:n])\nhq2=[-a[i] for i in range(n)]\nheapq.heapify(hq2)\nB=[s2]\nfor i in range(n,2*n):\n s2+=a[i]\n heapq.heappush(hq2,-a[i])\n x=heapq.heappop(hq2)\n s2-=-x\n B.append(s2)\nB=B[::-1]\nans=-10**18\nfor i in range(len(A)):\n ans=max(ans,A[i]-B[i])\nprint(ans)", "neg": "import heapq\nn=int(input())\na=list(map(int,input().split()))\ns1=sum(a[:n])\nhq1=a[:n]\nheapq.heapify(hq1)\nA=[s1]\nfor i in range(n,2*n):\n s1+=a[i]\n heapq.heappush(hq1,a[i])\n x=heapq.heappop(hq1)\n s1-=x\n A.append(s1)\na=a[::-1]\ns2=sum(a[:n])\nhq2=a[:n]\nheapq.heapify(hq2)\nB=[s2]\nfor i in range(n,2*n):\n s2+=a[i]\n heapq.heappush(hq2,a[i])\n x=heapq.heappop(hq2)\n s2-=x\n B.append(s2)\nB=B[::-1]\nans=-10**18\nfor i in range(len(A)):\n ans=max(ans,A[i]-B[i])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [302, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u390193191", "n_user": "u390193191", "pos": "import heapq\n\nn = int(input())\nA = list(map(int, input().split()))\n\npre = [0]*(n+1)\npre_list = [e for e in A[:n]]\nheapq.heapify(pre_list)\npre_sum = sum(pre_list)\npre[0] = pre_sum\nfor i in range(n, 2*n):\n small = heapq.heappushpop(pre_list, A[i])\n pre_sum += A[i] - small\n pre[i-n+1] = pre_sum\n\nsuf = [0]*(n+1)\nsuf_list = [-e for e in A[2*n:]]\nheapq.heapify(suf_list)\nsuf_sum = -sum(suf_list)\nsuf[-1] = suf_sum\nfor i in range(2*n-1, n-1, -1):\n large = -heapq.heappushpop(suf_list, -A[i])\n suf_sum += A[i] - large\n suf[i-n] = suf_sum\n\n# print(pre)\n# print(suf)\n\nprint(max([pre[i] - suf[i] for i in range(n+1)]))\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\n\npre = [0]*(n+1)\npre_list = [e for e in A[:n]]\nheapq.heapify(pre_list)\npre_sum = sum(pre_list)\npre[0] = pre_sum\nfor i in range(n, 2*n):\n small = heapq.heappushpop(pre_list, A[i])\n pre_sum += A[i] - small\n pre[i-n+1] = pre_sum\n\nsuf = [0]*(n+1)\nsuf_list = [-e for e in A[2*n:]]\nheapq.heapify(suf_list)\nsuf_sum = -sum(suf_list)\nsuf[-1] = suf_sum\nfor i in range(2*n-1, n-1, -1):\n large = -heapq.heappushpop(suf_list, A[i])\n suf_sum += A[i] - large\n suf[i-n] = suf_sum\n\n# print(pre)\n# print(suf)\n\nprint(max([pre[i] - suf[i] for i in range(n+1)]))\n", "jacc_sim": 0.9761904761904762, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [318, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u844646164", "n_user": "u844646164", "pos": "\nimport heapq \nn = int(input())\nAn = list(map(int, input().split()))\nformer = An[:n]\nlatter = An[2*n:]\nlatter = list(map(lambda x:-x, latter))\nheapq.heapify(former)\nheapq.heapify(latter)\n\nsum_former = sum(former)\nsum_latter = sum(latter)\n\nformer_list = [0]*(n+1) \nlatter_list = [0]*(n+1) \nformer_list[0] = sum_former \nlatter_list[0] = sum_latter \n\nfor i in range(n, 2*n):\n heapq.heappush(former, An[i])\n m = heapq.heappop(former)\n former_list[i-n+1] = former_list[i-n] + An[i] - m \n\nfor i in range(2*n-1, n-1, -1):\n heapq.heappush(latter, -An[i])\n m = heapq.heappop(latter)\n latter_list[2*n-i] = latter_list[2*n-i-1] - An[i] - m\n\nlatter_list.reverse()\nans = -float('inf')\nfor i in range(n+1):\n ans = max(ans, former_list[i]+latter_list[i])\nprint(ans)", "neg": "\nimport heapq \nn = int(input())\nAn = list(map(int, input().split()))\nformer = An[:n]\nlatter = An[2*n:]\nlatter = list(map(lambda x:-x, latter))\nheapq.heapify(former)\nheapq.heapify(latter)\n\nsum_former = sum(former)\nsum_latter = sum(latter)\n\nformer_list = [0]*(n+1) \nlatter_list = [0]*(n+1) \nformer_list[0] = sum_former \nlatter_list[0] = sum_latter \n\nfor i in range(n, 2*n):\n heapq.heappush(former, An[i])\n m = heapq.heappop(former)\n former_list[i-n+1] = former_list[i-n] + An[i] - m \n\nfor i in range(2*n-1, n-1, -1):\n heapq.heappush(latter, -An[i])\n m = heapq.heappop(latter)\n latter_list[2*n-i] = latter_list[2*n-i-1] - An[i] - m\n\nans = 0\nfor i in range(n):\n ans = max(ans, former_list[i]+latter_list[n-i])\nprint(ans)", "jacc_sim": 0.9148936170212766, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [359, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u223904637", "n_user": "u223904637", "pos": "import heapq\nn=int(input())\nl=list(map(int,input().split()))\nq=[]\nfor i in range(n):\n heapq.heappush(q,l[i])\na1=[0]*(n+1)\na1[0]=sum(l[:n])\nfor i in range(n):\n p=heapq.heappop(q)\n a1[i+1]=a1[i]-p+max(p,l[i+n])\n heapq.heappush(q,max(p,l[i+n]))\n#print(a1)\nq=[]\nl.reverse()\nfor i in range(n):\n heapq.heappush(q,-l[i])\na1.reverse()\na1[0]-=sum(l[:n])\nz=sum(l[:n])\nfor i in range(n):\n p=heapq.heappop(q)\n z=z+p+min(-p,l[i+n])\n a1[i+1]-=z\n heapq.heappush(q,max(p,-l[i+n]))\nprint(max(a1))\n", "neg": "import heapq\nn=int(input())\nl=list(map(int,input().split()))\nq=[]\nfor i in range(n):\n heapq.heappush(q,l[i])\na1=[0]*(n+1)\na1[0]=sum(l[:n])\nfor i in range(n):\n p=heapq.heappop(q)\n a1[i+1]=a1[i]-p+max(p,l[i+n])\n heapq.heappush(q,max(p,l[i+n]))\nq=[]\nl.reverse()\nfor i in range(n):\n heapq.heappush(q,-l[i])\na1.reverse()\na1[0]-=sum(l[:n])\nz=sum(l[:n])\nfor i in range(n):\n p=heapq.heappop(q)\n z=z-min(-p,l[i+n])\n a1[i+1]-=z\n heapq.heappush(q,max(p,-l[i+n])\nprint(max(a1))", "jacc_sim": 0.9736842105263158, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [296, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u593590006", "n_user": "u593590006", "pos": "maxi=-10**99 \nn=int(input())\nimport heapq \nl=[int(i) for i in input().split()]\nk=n\nsm=sum(l[0:n])\nz1=[0]*(n+1)\nz2=[0]*(n+1)\nh=[]\nz1[0]=sm \nj=1 \nheapq.heapify(h)\nfor i in range(n):\n heapq.heappush(h,l[i])\nfor i in range(n,2*n):\n p=l[i]\n if p>h[0]: \n sm+=p \n sm-=h[0]\n heapq.heappop(h)\n heapq.heappush(h,p)\n else:\n pass \n z1[j]=sm \n j+=1 \nsm=sum(l[2*n:3*n])\nh=[]\nheapq.heapify(h)\nsm=0 \nfor i in range(2*n,3*n):\n heapq.heappush(h,-l[i])\n sm+=(l[i])\nj=n \nz2[j]=sm \nj-=1 \n#print(h[0])\n#print(sm)\nfor i in range(2*n-1,n-1,-1): \n p=-l[i]\n if p>h[0]:\n #print('jif')\n sm=sm+h[0]-p\n heapq.heappop(h)\n heapq.heappush(h,p)\n \n else:\n pass \n z2[j]=sm \n j-=1 \nmaxi=-(10**99)\n#print(z1)\n#print(z2)\nfor i in range(n+1):\n maxi=max(maxi,z1[i]-z2[i])\nprint(maxi)", "neg": "maxi=-10**99 \nn=int(input())\nimport heapq \nl=[int(i) for i in input().split()]\nk=n\nsm=sum(l[0:n])\nz1=[0]*(n+1)\nz2=[0]*(n+1)\nh=[]\nz1[0]=sm \nj=1 \nheapq.heapify(h)\nfor i in range(n):\n heapq.heappush(h,l[i])\nfor i in range(n,2*n):\n p=l[i]\n if p>h[0]: \n sm+=p \n sm-=h[0]\n heapq.heappop(h)\n heapq.heappush(h,p)\n else:\n pass \n z1[j]=sm \n j+=1 \nsm=sum(l[2*n:3*n])\nh=[]\nheapq.heapify(h)\nsm=0 \nfor i in range(2*n,3*n):\n heapq.heappush(h,-l[i])\n sm+=(l[i])\nj=n \nz2[j]=sm \nj-=1 \n#print(h[0])\n#print(sm)\nfor i in range(2*n-1,n-1,-1): \n p=-l[i]\n if p>h[0]:\n #print('jif')\n sm=sm+h[0]-p\n heapq.heappop(h)\n heapq.heappush(h,p)\n \n else:\n pass \n z2[j]=sm \n j-=1 \nmaxi=0 \n#print(z1)\n#print(z2)\nfor i in range(n+1):\n maxi=max(maxi,z1[i]-z2[i])\nprint(maxi)", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [483, 480], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u163320134", "n_user": "u163320134", "pos": "import heapq\n\nn=int(input())\narr=list(map(int,input().split()))\nq1=[]\ntmp=0\nfor val in arr[:n]:\n heapq.heappush(q1,val)\n tmp+=val\nsum1=[tmp]\nfor val in arr[n:2*n]:\n tmp=heapq.heappop(q1)\n if val>tmp:\n heapq.heappush(q1,val)\n sum1.append(sum1[-1]+(val-tmp))\n else:\n heapq.heappush(q1,tmp)\n sum1.append(sum1[-1])\nq2=[]\ntmp=0\nfor val in arr[2*n:]:\n heapq.heappush(q2,-val)\n tmp+=val\nsum2=[tmp]\nfor val in arr[2*n-1:n-1:-1]:\n tmp=-heapq.heappop(q2)\n if valtmp:\n heapq.heappush(q1,val)\n sum1.append(sum1[-1]+(val-tmp))\n else:\n heapq.heappush(q1,tmp)\n sum1.append(sum1[-1])\nprint(sum1)\nq2=[]\ntmp=0\nfor val in arr[2*n:]:\n heapq.heappush(q2,-val)\n tmp+=val\nsum2=[tmp]\nfor val in arr[2*n-1:n-1:-1]:\n tmp=-heapq.heappop(q2)\n if valq[0]:\n S1.append(S1[-1] + a - q[0])\n heapq.heapreplace(q,a)\n else:\n S1.append(S1[-1])\nq = []\nfor a in A[2*N:]:\n heapq.heappush(q,-a)\nS2 = [sum(q)]\nfor a in A[N:N*2][::-1]:\n if a<-q[0]:\n S2.append(S2[-1] - a - q[0])\n heapq.heapreplace(q,-a)\n else:\n S2.append(S2[-1])\nS2 = S2[::-1]\nprint(max(map(sum,zip(S1,S2))))", "neg": "N = int(input())\n*A, = map(int,input().split())\nq = []\nfor a in A[:N]:\n heapq.heappush(q,a)\nS1 = [sum(q)]\nfor a in A[N:N*2]:\n if a>q[0]:\n S1.append(S1[-1] + a - q[0])\n heapq.heapreplace(q,a)\n else:\n S1.append(S1[-1])\nq = []\nfor a in A[2*N:]:\n heapq.heappush(q,-a)\nS2 = [sum(q)]\nfor a in A[N:N*2][::-1]:\n if a<-q[0]:\n S2.append(S2[-1] - a - q[0])\n heapq.heapreplace(q,-a)\n else:\n S2.append(S2[-1])\nS2 = S2[::-1]\nprint(max(map(sum,zip(S1,S2))))", "jacc_sim": 0.9743589743589743, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [266, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u367130284", "n_user": "u367130284", "pos": "def f(x):\n y=x[:n];heapify(y);z=sum(y);s=[z]\n for i in x[n:n*2]:z+=i-heappushpop(y,i);s+=[z]\n return s\nfrom heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f([-i for i in a[n:][::-1]]),f(a)[::-1]))))", "neg": "def f(x):\n y=x[:n];heapify(y);z=sum(y);s=t=z\n for i in x[n:n*2]:z+=i-heappushpop(y,i);s,t=min(s,z),max(t,z);\n return s,t\nfrom heapq import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f([-i for i in a[n:][::-1]]),f(a)[::-1]))))", "jacc_sim": 0.9534883720930233, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [124, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u309977459", "n_user": "u309977459", "pos": "import heapq\nN = int(input())\nA = list(map(int, input().split()))\n\nal = A[:N]\nheapq.heapify(al)\nsal = sum(al)\nsuml = [sal]\nfor i in range(N, 2*N):\n if al[0] < A[i]:\n tmp = heapq.heappop(al)\n heapq.heappush(al, A[i])\n sal += A[i]-tmp\n suml.append(sal)\n\nar = [-a for a in A[2*N:]]\nheapq.heapify(ar)\nsar = -sum(ar)\nsumr = [sar]\n\nans = -10**15\nfor i in range(N, 2*N):\n if -ar[0] > A[3*N-1-i]:\n tmp = -heapq.heappop(ar)\n heapq.heappush(ar, -A[3*N-1-i])\n sar += A[3*N-1-i]-tmp\n sumr.append(sar)\nfor i in range(len(suml)):\n ans = max(ans, suml[i]-sumr[-(i+1)])\nprint(ans)\n", "neg": "import heapq\nN = int(input())\nA = list(map(int, input().split()))\n\nal = A[:N]\nheapq.heapify(al)\nsal = sum(al)\nsuml = [sal]\nfor i in range(N, 2*N):\n if al[0] < A[i]:\n tmp = heapq.heappop(al)\n heapq.heappush(al, A[i])\n sal += A[i]-tmp\n suml.append(sal)\n\nar = [-a for a in A[2*N:]]\nheapq.heapify(ar)\nsar = -sum(ar)\nsumr = [sar]\n\nans = -10**15\nfor i in range(N, 2*N):\n if -ar[0] > A[3*N-1-i]:\n tmp = -heapq.heappop(ar)\n heapq.heappush(ar, -A[3*N-1-i])\n sar += A[3*N-1-i]-tmp\n sumr.append(sar)\nfor i in range(len(suml)):\n ans = max(ans, suml[i]-sumr[-i])\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [311, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u099566485", "n_user": "u099566485", "pos": "import heapq\nimport copy\nn=int(input())\na=list(map(int,input().split()))\nca=copy.deepcopy(a)\nf=ca[:n]\nheapq.heapify(f)\nfs=sum(f)\nfsl=[0 for i in range(n+1)]\nfsl[0]=fs\nfor i in range(n,2*n):\n heapq.heappush(f,a[i])\n fs=fs+a[i]-heapq.heappop(f)\n fsl[i-n+1]=fs\nl=list(map(lambda x:-x,ca[2*n:]))\nheapq.heapify(l)\nls=sum(l)\nlsl=[0 for i in range(n+1)]\nlsl[-1]=ls\nfor i in range(n,2*n):\n heapq.heappush(l,-a[3*n-i-1])\n ls=ls-a[3*n-i-1]-heapq.heappop(l)\n lsl[2*n-i-1]=ls\nans=-float('inf')\nfor i in range(n+1):\n ans=max(ans,fsl[i]+lsl[i])\nprint(ans)", "neg": "#062-D\nimport heapq\nimport copy\nn=int(input())\na=list(map(int,input().split()))\nca=copy.deepcopy(a)\nf=ca[:n]\nheapq.heapify(f)\nfs=sum(f)\nfsl=[0 for i in range(n+1)]\nfsl[0]=fs\nfor i in range(n,2*n):\n heapq.heappush(f,a[i])\n fs=fs+a[i]-heapq.heappop(f)\n fsl[i-n+1]=fs\nl=list(map(lambda x:-x,ca[2*n:]))\nheapq.heapify(l)\nls=sum(l)\nlsl=[0 for i in range(n+1)]\nlsl[0]=ls\nfor i in range(n,2*n):\n heapq.heappush(l,-a[3*n-i-1])\n ls=ls-a[3*n-i-1]-heapq.heappop(l)\n lsl[2*n-i]=ls\nans=-float('inf')\nfor i in range(n+1):\n ans=max(ans,fsl[i]-lsl[i])\nprint(ans)", "jacc_sim": 0.9423076923076923, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [315, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u069838609", "n_user": "u069838609", "pos": "import sys\nfrom heapq import heapify, heappushpop\nfrom heapq import _heapify_max as heapify_max, _siftup_max\n\n\ndef heappushpop_max(heap, item):\n if heap and heap[0] > item:\n item, heap[0] = heap[0], item\n _siftup_max(heap, 0)\n return item\n\n\nfin = sys.stdin.readline\nN = int(fin())\na_list = [int(elem) for elem in fin().split()]\n\nleft_pq = a_list[:N]\nright_pq = a_list[2 * N:]\nheapify(left_pq)\nheapify_max(right_pq)\n\nleft_sum = [sum(left_pq)]\nright_sum = [sum(right_pq)]\nfor k in range(N, 2 * N):\n left_item = a_list[k]\n right_item = a_list[-k - 1]\n left_sum.append(left_sum[-1] - heappushpop(left_pq, left_item) + left_item)\n right_sum.append(right_sum[-1] - heappushpop_max(right_pq, right_item) + right_item)\n\nmax_sum = max(map(sum, zip(left_sum, [-item for item in right_sum[::-1]])))\nprint(max_sum)\n", "neg": "#import sys\nfrom heapq import heapify, heappushpop\nfrom heapq import _heapify_max as heapify_max, _siftup_max\n\n\ndef heappushpop_max(heap, item):\n if heap and heap[0] > item:\n item, heap[0] = heap[0], item\n _siftup_max(heap, 0)\n return item\n\n\nfin = sys.stdin.readline\nN, *a_list = map(int, open(0).read().split())\n\nleft_pq = a_list[:N]\nright_pq = a_list[2 * N:]\nheapify(left_pq)\nheapify_max(right_pq)\n\nleft_sum = [sum(left_pq)]\nright_sum = [sum(right_pq)]\nfor k in range(N, 2 * N):\n left_item = a_list[k]\n right_item = a_list[-k - 1]\n left_sum.append(left_sum[-1] - heappushpop(left_pq, left_item) + left_item)\n right_sum.append(right_sum[-1] - heappushpop_max(right_pq, right_item) + right_item)\n\nmax_sum = max(map(sum, zip(left_sum, [-item for item in right_sum[::-1]])))\nprint(max_sum)\n", "jacc_sim": 0.9333333333333333, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [352, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u826263061", "n_user": "u826263061", "pos": "import heapq\nn = int(input())\na = list(map(int, input().split()))\n\na1 = a[:n]\nax = a[n:2*n]\na2 = list(map(lambda x: -x, a[2*n:]))\n#print('a2', a2)\n\nsum_a1 = sum(a1)\nfdif1 = [sum_a1]\nheapq.heapify(a1)\nfor i in range(n):\n p = heapq.heappushpop(a1,ax[i])\n fdif1.append(fdif1[-1]+ax[i]-p)\n \nsum_a2 = sum(a2)\nfdif2 = [sum_a2]\nheapq.heapify(a2)\n#print('a2', a2)\nfor i in range(n):\n p = heapq.heappushpop(a2,-ax[-1-i])\n fdif2.append(fdif2[-1]-ax[-1-i]-p)\nfdif2.reverse()\n\nfdif = [fdif1[i]+fdif2[i] for i in range(n+1)]\nprint(max(fdif))", "neg": "import heapq\nn = int(input())\na = list(map(int, input().split()))\n\na1 = a[:n]\nax = a[n:2*n]\na2 = list(map(lambda x: -x, a[2*n:]))\nprint('a2', a2)\n\nsum_a1 = sum(a1)\nfdif1 = [sum_a1]\nheapq.heapify(a1)\nfor i in range(n):\n p = heapq.heappushpop(a1,ax[i])\n fdif1.append(fdif1[-1]+ax[i]-p)\n \nsum_a2 = sum(a2)\nfdif2 = [sum_a2]\nheapq.heapify(a2)\nprint('a2', a2)\nfor i in range(n):\n p = heapq.heappushpop(a2,-ax[-1-i])\n fdif2.append(fdif2[-1]-ax[-1-i]-p)\nfdif2.reverse()\n\nfdif = [fdif1[i]+fdif2[i] for i in range(n)]\nprint(max(fdif))", "jacc_sim": 0.9782608695652174, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [296, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u884982181", "n_user": "u884982181", "pos": "import heapq\nn = int(input())\na = list(map(int,input().split()))\naka = a[:n]\nheapq.heapify(aka)\nakasum = [0] * (n+1)\nakasum[0] = sum(aka)\nao = a[2*n:]\naosum = [0] * (n+1)\naosum[-1] = sum(ao)\nfor i in range(len(ao)):\n ao[i] = -ao[i]\nheapq.heapify(ao)\nfor i in range(n,2*n):\n b = heapq.heappop(aka)\n if b >= a[i]:\n heapq.heappush(aka, b)\n akasum[i-n+1] = akasum[i-n] \n else:\n heapq.heappush(aka, a[i])\n akasum[i-n+1] = akasum[i-n] + a[i] - b\n b = heapq.heappop(ao)\n if b >= -a[-i-1]:\n heapq.heappush(ao, b)\n aosum[-i+n-2] = aosum[-i+n-1]\n else:\n heapq.heappush(ao, -a[-i-1])\n aosum[-i+n-2] = aosum[-i+n-1] + a[-i-1] + b\nans = - float(\"inf\")\nfor i in range(n+1):\n kota = akasum[i] - aosum[i]\n ans = max(kota,ans)\nprint(ans)", "neg": "import heapq\nn = int(input())\na = list(map(int,input().split()))\naka = a[:n]\nheapq.heapify(aka)\nakasum = [0] * (n+1)\nakasum[0] = sum(aka)\nfor i in range(n,2*n):\n b = heapq.heappop(aka)\n if b >= a[i]:\n heapq.heappush(aka, b)\n else:\n heapq.heappush(aka, a[i])\n akasum[i-n+1] = sum(aka)\nao = a[2*n:]\naosum = [0] * (n+1)\naosum[-1] = sum(ao)\nfor i in range(n,2*n):\n b = heapq.heappop(ao)\n if b >= a[-i-1]:\n heapq.heappush(ao, b)\n else:\n heapq.heappush(ao, a[-i-1])\n aosum[-i+n-2] = sum(ao)\nans = - float(\"inf\")\nfor i in range(n+1):\n kota = akasum[i] - aosum[i]\n ans = max(kota,ans)\nprint(ans)", "jacc_sim": 0.9787234042553191, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [422, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u467736898", "n_user": "u467736898", "pos": "import bisect\nN = int(input())\nA = list(map(int, input().split()))\nL = sorted(A[:2*N])\nsumL = sum(L[N:])\nR = sorted(A[N:])\nsumR = sum(R[:N])\nAL = [sumL]\np = N\nBL = [False] * (2*N)\nfor a in reversed(A[N:2*N]): # sumL\u306f\u3060\u3093\u3060\u3093\u6e1b\u308b\n ind = bisect.bisect_left(L, a)\n if BL[ind] != False:\n BL[ind] += 1\n ind += BL[ind] - 1\n if ind >= p:\n sumL -= L[ind]\n p -= 1\n while BL[p] != False:\n p -= 1\n sumL += L[p]\n AL.append(sumL)\n BL[ind] = 1\nAR = [sumR]\np = N-1\nBR = [False] * (2*N)\nfor a in A[N:2*N]: # sumR\u306f\u3060\u3093\u3060\u3093\u5897\u3048\u308b\n ind = bisect.bisect_left(R, a)\n if BR[ind] != False:\n BR[ind] += 1\n ind += BR[ind] - 1\n if ind <= p:\n sumR -= R[ind]\n p += 1\n while BR[p] != False:\n p += 1\n sumR += R[p]\n AR.append(sumR)\n BR[ind] = 1\nAL.reverse()\nC = [AL[i] - AR[i] for i in range(N+1)]\nprint(max(C))\n", "neg": "import bisect\nN = int(input())\nA = list(map(int, input().split()))\n\nL = sorted(A[:2*N])\nsumL = sum(L[N:])\nR = sorted(A[N:])\nsumR = sum(R[:N])\n\nAL = [sumL]\np = N\nBL = [True] * (2*N)\nfor a in reversed(A[N:2*N]): # sumL\u306f\u3060\u3093\u3060\u3093\u6e1b\u308b\n ind = bisect.bisect_left(L, a)\n if ind >= p:\n sumL -= L[ind]\n p -= 1\n while BL[p] == False:\n p -= 1\n sumL += L[p]\n AL.append(sumL)\n BL[ind] = False\nAR = [sumR]\np = N-1\nBR = [True] * (2*N)\nfor a in A[N:2*N]: # sumR\u306f\u3060\u3093\u3060\u3093\u5897\u3048\u308b\n ind = bisect.bisect_left(R, a)\n if ind <= p:\n sumR -= R[ind]\n p += 1\n while BR[p] == False:\n p += 1\n sumR += R[p]\n AR.append(sumR)\n BR[ind] = False\nAL.reverse()\nC = [AL[i] - AR[i] for i in range(N+1)]\nprint(AL)\nprint(AR)\nprint(max(C))\n", "jacc_sim": 0.9661016949152542, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [440, 396], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u490724687", "n_user": "u490724687", "pos": "import heapq\n\nn = int(input())\na = list(map(int, input().split()))\n\nred, blue = a[:n], [-1*i for i in a[2*n:]]\nsr, sb = sum(red), sum(blue)\n\nresults = [0] * (n + 1)\nresults[0] = sr\nresults[-1] = sb\n\nheapq.heapify(red)\nheapq.heapify(blue)\n\nfor k in range(n, 2*n):\n v = a[k]\n p = heapq.heappushpop(red, v)\n sr += v - p\n results[k-n+1] += sr\n\nfor k in range(2*n-1, n-1, -1):\n v = -1 * a[k]\n p = heapq.heappushpop(blue, v)\n sb += v - p\n results[k-n] += sb\n\nprint(max(results))\n", "neg": "import heapq\n\nn = int(input())\na = list(map(int, input().split()))\n\nred, blue = a[:n], [-1*i for i in a[2*n:]]\nsr, sb = sum(red), sum(blue)\n\nresults = [0] * (n + 1)\nresults[0] = sr\nresults[-1] = sb\n\nheapq.heapify(red)\nheapq.heapify(blue)\n\nfor k in range(n, 2*n):\n v = a[k]\n p = heapq.heappushpop(red, v)\n sr += v - p\n results[i-n+1] += sr\n\nfor k in range(2*n-1, n-1, -1):\n v = -1 * a[k]\n p = heapq.heappushpop(blue, v)\n sb += v - p\n results[i-n] += sb\n\nprint(max(results))\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [237, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u667084803", "n_user": "u667084803", "pos": "import heapq\nN=int(input())\na=list(map(int,input().split()))\nearl=[]\nlate=[]\nfor i in range(N):\n heapq.heappush(earl,a[i])\n heapq.heappush(late,-a[2*N+i])\nE=0\nL=0\nfor i in range(N):\n E+=a[i]\n L-=a[2*N+i]\ne=[E]*(N+1)\nl=[L]*(N+1)\nfor i in range(N):\n e[i+1]=e[i]+a[N+i]-heapq.heappushpop(earl,a[N+i])\n l[N-1-i]=l[N-i]-a[2*N-1-i]-heapq.heappushpop(late,-a[2*N-1-i])\n\nans=e[N]+l[N]\nfor i in range(N):\n ans=max(ans,e[i]+l[i])\nprint(ans)", "neg": "import heapq\nN=int(input())\na=list(map(int,input().split()))\nearl=[]\nlate=[]\nfor i in range(N):\n heapq.heappush(earl,a[i])\n heapq.heappush(late,-a[2*N+i])\nE=0\nL=0\nfor i in range(N):\n E+=a[i]\n L-=a[2*N+i]\ne=[E]*(N+1)\nl=[L]*(N+1)\nfor i in range(N):\n e[i+1]=e[i]+a[N+i]-heapq.heappushpop(earl,a[N+i])\n l[N-1-i]=l[N-i]-a[2*N-1-i]-heapq.heappushpop(late,-a[2*N-1-i])\n\nans=e[N]+l[N]\nfor i in range(N):\n ans=max(ans,a[i]+l[i])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [271, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u119303585", "n_user": "u119303585", "pos": "N = int(input())\narray = [int(n) for n in input().split()]\nimport copy\nimport heapq\nlst = [None for i in range(N + 1)]\nleft_lst = copy.deepcopy(lst)\nright_lst = copy.deepcopy(lst)\nleft_array = array[:N]\nright_array= [-n for n in array[-N:]]\nl_sum = sum(left_array)\nr_sum = sum(right_array)\nheapq.heapify(left_array)\nheapq.heapify(right_array)\nleft_lst[0] = l_sum\nright_lst[0] = r_sum\n\nfor k in range(N, 2 * N):\n new_a, new_b = array[k], array[-k - 1]*-1\n heapq.heappush(left_array,new_a)\n heapq.heappush(right_array,new_b)\n old_a = heapq.heappop(left_array)\n l_sum += (new_a - old_a)\n left_lst[k - N + 1] = l_sum\n old_b = heapq.heappop(right_array)\n r_sum += (new_b - old_b)\n right_lst[k - N + 1] = r_sum\nlst = [ a + b for a, b in zip(left_lst, list(reversed(right_lst)))]\nprint(max(lst))", "neg": "N = int(input())\narray = [int(n) for n in input().split()]\nimport copy\nimport heapq\n\nlst = [None for i in range(N + 1)]\nleft_lst = copy.deepcopy(lst)\nright_lst = copy.deepcopy(lst)\nright_array = heapq.heapify(array[:N])\nleft_array = heapq.heapify([-n for n in array[-N:]])\nl_sum = sum(left_array)\nr_sum = sum(right_array)\nleft_lst[0] = l_sum\nright_lst[0] = r_sum\n\nfor k in range(N, 2 * N):\n new_a, new_b = array[k], array[-k - 1]*-1\n heapq.heappush(left_array,new_a)\n heapq.heappush(right_array,new_b)\n old_a = heapq.heappop(left_array)\n l_sum += (new_a - old_a)\n left_lst[k - N + 1] = l_sum\n right_array.append(new_b)\n old_b = heapq.heappop(right_array)\n r_sum += (new_b - old_b)\n right_lst[k - N + 1] = r_sum\nlst = [a + b for a, b in zip(left_lst, list(reversed(right_lst)))]\nprint(max(lst))", "jacc_sim": 0.9811320754716981, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [357, 360], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u280667879", "n_user": "u280667879", "pos": "def f(a):\n\ts=0;q=a[:n];s=sum(q);heapify(q);r=[s]\n\tfor e in a[n:2*n]:s+=e-heappushpop(q,e);r+=[s]\n\treturn r\nfrom heapq import*;r=reversed;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))", "neg": "def f(a):\n\ts=0;q=a[:n];s=sum(q);heapify(q);yield s\n\tfor e in a[n:2*n]:s+=e-heappushpop(q,e);yield s\nfrom heapq import*;r=reversed;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),r(f([-e for e in r(a)]))))))", "jacc_sim": 0.9512195121951219, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [127, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03714", "p_user": "u280667879", "n_user": "u280667879", "pos": "def f(a):\n\ts=0;q=[]\n\tfor i in range(n):s+=a[i];heappush(q,a[i])\n\tr=[s]\n\tfor i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]\n\treturn r\nimport sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(map(sum,zip(f(a),list(reversed(f(list(reversed([-e for e in a])))))))))", "neg": "def f(a):\n\ts=0;q=[]\n\tfor i in range(n):s+=a[i];heappush(q,a[i])\n\tr=[s]\n\tfor i in range(n,2*n):s+=a[i];s-=heappushpop(q,a[i]);r+=[s]\n\treturn r\nimport sys;from heapq import*;n,*a=list(map(int,sys.stdin.read().split()));print(max(x+y for x,y in zip(f(a),f(reversed(-e for e in a)))))", "jacc_sim": 0.9347826086956522, "nl": "You are given a positive integer N and a numerical sequence of length 3N. You need to construct a new sequence of length 2N by removing exactly N elements from the original sequence without changing the order of the remaining elements. The score of the new sequence is defined as the sum of the elements in the first half minus the sum of the elements in the second half. Find the maximum possible score of the new sequence. Constraints: 1 \u2264 N \u2264 10^5, ai is an integer, 1 \u2264 ai \u2264 10^9. In the input, you are given N followed by the elements of the sequence. Output the maximum possible score of the new sequence.", "before_after_length": [155, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u668785999", "n_user": "u668785999", "pos": "N,M = map(int,input().split())\ncntNode = [0]*N\nfor i in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n cntNode[a] += 1\n cntNode[b] += 1\n\nflag = True\nfor i in range(N):\n if(cntNode[i] % 2 != 0):\n flag = False\n break\nif(flag):\n print('YES')\nelse:\n print('NO')", "neg": "N,M = map(int,input().split())\ncntNode = [0]*N\nfor i in range(N):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n cntNode[a] += 1\n cntNode[b] += 1\n\nflag = True\nfor i in range(N):\n if(cntNode[i] % 2 != 0):\n flag = False\n break\nif(flag):\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9047619047619048, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [125, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u225388820", "n_user": "u225388820", "pos": "import sys\ninput = sys.stdin.readline\nn, m = map(int, input().split())\na = [0] * (n + 1)\nfor _ in range(m):\n x, y = map(int, input().split())\n a[x] = (a[x] + 1) & 1\n a[y] = (a[y] + 1) & 1\nprint(\"YES\" if sum(a) == 0 else \"NO\")\n", "neg": "import sys\ninput = sys.stdin.readline\nn, m = map(int, input().split())\na = [0] * n\nfor _ in range(m):\n x, y = map(int, input().split())\n a[x] = (a[x] + 1) & 1\n a[y] = (a[y] + 1) & 1\nprint(\"YES\" if sum(a) == 0 else \"NO\")\n", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [109, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u106778233", "n_user": "u106778233", "pos": "n,m=map(int,input().split())\ng=[0]*(n+1)\nfor _ in range(m):\n a,b=map(int,input().split())\n g[a]+=1\n g[b]+=1\n g[a]%=2\n g[b]%=2\n \nprint(\"YES\" if 1-max(g) else \"NO\")\n", "neg": "n,m=map(int,input().split())\ng=[0]*(n+1)\nfor _ in range(m):\n a,b=map(int,input().split())\n g[a]+=1\n g[b]+=1\n g[a]%=2\n g[b]%=2\n \nprint(\"YES\" if max(g) else \"NO\")\n", "jacc_sim": 0.9714285714285714, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [97, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u538632589", "n_user": "u538632589", "pos": "n, m = map(int, input().split())\nc_list = [0]*n\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n c_list[a] += 1\n c_list[b] += 1\n\nok = True\nfor c in c_list:\n if c % 2 != 0:\n ok = False\nif ok:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "n, m = map(int, input().split())\nc_list = [0]*n\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n c_list[a] += 1\n c_list[b] += 1\n\nok = True\nfor c in c_list:\n if c % 2 != 0:\n ok = False\nif ok:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9024390243902439, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [120, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u798818115", "n_user": "u798818115", "pos": "N,M=map(int,input().split())\n\ncount=[0]*N\nfor _ in range(M):\n a,b=map(int,input().split())\n count[a-1]+=1\n count[b-1]+=1\n\nfor c in count:\n if c%2==1:\n print(\"NO\")\n exit()\n\nprint(\"YES\")", "neg": "N,M=map(int,input().split())\n\ncount=[0]*N\nfor _ in range(M):\n a,b=map(int,input().split())\n count[a-1]+=1\n count[b-1]+=1\n\nfor c in count:\n if c%2==0:\n print(\"NO\")\n exit()\n\nprint(\"YES\")", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [93, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n, m = LI()\n l = [0] * n\n for i in range(m):\n a, b = LI_()\n l[a] ^= 1\n l[b] ^= 1\n print(\"NO\" if sum(l) else \"YES\")\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n, m = LI()\n l = [0] * n\n for i in range(m):\n a, b = LI_()\n l[a] ^= 1\n l[b] ^= 1\n print(\"No\" if sum(l) else \"Yes\")\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 0.956989247311828, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [403, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u186838327", "n_user": "u186838327", "pos": "n, m = map(int, input().split())\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n g[a].append(b)\n g[b].append(a)\n\n#print(g)\nfor i in range(n):\n if len(g[i])%2 == 1:\n print('NO')\n exit()\nelse:\n print('YES')\n", "neg": "n, m = map(int, input().split())\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n g[a].append(b)\n g[b].append(a)\n\n#print(g)\nfor i in range(n):\n if len(g)%2 == 1:\n print('NO')\n exit()\nelse:\n print('Yes')", "jacc_sim": 0.9459459459459459, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [128, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u095426154", "n_user": "u095426154", "pos": "# coding: utf-8\nN,M=map(int,input().split())\nNL=[0 for i in range(N)]\nfor i in range(M):\n a,b=map(int,input().split())\n NL[a-1]+=1\n NL[b-1]+=1\n\nflg=True\n\nfor i in range(N):\n if NL[i]%2==1:\n flg=False\n\nif flg:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "# coding: utf-8\nN,M=map(int,input().split())\nNL=[0 for i in range(N)]\nfor i in range(M):\n a,b=map(int,input().split())\n NL[a-1]+=1\n NL[b-1]+=1\n\nflg=True\n\nfor i in range(N):\n if NL[i]%2==1:\n flg=False\n\nif flg:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9047619047619048, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [127, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u937642029", "n_user": "u937642029", "pos": "import sys, bisect, math, itertools, string, queue, copy\n# import numpy as np\n# import scipy\nfrom collections import Counter,defaultdict,deque\nfrom itertools import permutations, combinations\nfrom heapq import heappop, heappush\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(input()) # n=1\ndef inpm(): return map(int,input().split()) # x=1,y=2\ndef inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]\ndef inpls(): return list(input().split()) # a=['1','2','3',...,'n']\ndef inplm(n): return list(int(input()) for _ in range(n)) # x=[] \u8907\u6570\u884c\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] \ndef graph():\n n=inp()\n g=[[] for _ in range(n)]\n for i in range(n):\n a = inp()\n a -= 1\n g[i].append(a)\n g[a].append(i)\n return n,g\n\ndef main():\n n,m = inpm()\n cnt = [0 for _ in range(n)]\n for _ in range(m):\n a,b = inpm()\n a -= 1\n b -= 1\n cnt[a] += 1\n cnt[b] += 1\n for i in range(n):\n if cnt[i]%2 == 1:\n print('NO')\n return\n print('YES')\n \nif __name__ == \"__main__\":\n main()", "neg": "import sys, bisect, math, itertools, string, queue, copy\n# import numpy as np\n# import scipy\nfrom collections import Counter,defaultdict,deque\nfrom itertools import permutations, combinations\nfrom heapq import heappop, heappush\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\ndef inp(): return int(input()) # n=1\ndef inpm(): return map(int,input().split()) # x=1,y=2\ndef inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]\ndef inpls(): return list(input().split()) # a=['1','2','3',...,'n']\ndef inplm(n): return list(int(input()) for _ in range(n)) # x=[] \u8907\u6570\u884c\ndef inplL(n): return [list(input()) for _ in range(n)]\ndef inplT(n): return [tuple(input()) for _ in range(n)]\ndef inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] \ndef graph():\n n=inp()\n g=[[] for _ in range(n)]\n for i in range(n):\n a = inp()\n a -= 1\n g[i].append(a)\n g[a].append(i)\n return n,g\n\ndef main():\n n,m = inp()\n cnt = [0 for _ in range(n)]\n for _ in range(m):\n a,b = inpm()\n a -= 1\n b -= 1\n cnt[a] += 1\n cnt[b] += 1\n for i in range(n):\n if cnt[i]%2 == 1:\n print('NO')\n return\n print('YES')\n \nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [507, 506], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u619819312", "n_user": "u619819312", "pos": "import numpy as np\nn,m=map(int,input().split())\ns=np.zeros(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a]+=1\n s[b]+=1\nprint(\"NO\" if sum(s%2)else\"YES\")", "neg": "import numpy as np\nn,m=map(int,input().split())\ns=np.zeros(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a]+=1\n s[b]+=1\nprint(s%2,s)\nprint(\"NO\" if sum(s%2)else\"YES\")", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [82, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u102960641", "n_user": "u102960641", "pos": "n,m = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(m)]\ns = [0] * (10 ** 5+1)\nfor a,b in ab:\n s[a] += 1\n s[b] += 1\nif any([i % 2 for i in s]):\n print(\"NO\")\nelse:\n print(\"YES\")", "neg": "n,m = map(int, input().split())\nab = list(map(int, input().split()))\ns = [0] * (10 ** 5+1)\nfor a,b in ab:\n s[a] += 1\n s[b] += 1\nif any([s % 2 for i in s]):\n print(\"NO\")\nelse:\n print(\"YES\")\n \n", "jacc_sim": 0.9736842105263158, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [100, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u518042385", "n_user": "u518042385", "pos": "n,m=map(int,input().split())\nl=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n l[a-1]+=1\n l[b-1]+=1\nb=True\nfor i in range(n):\n if l[i]%2==1:\n b=False\nif b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "n,m=map(int,input().split())\nl=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n l[a-1]+=1\n l[b-1]+=1\nb=True\nfor i in range(m):\n if l[i]%2!=1:\n b=False\nif b:\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 0.972972972972973, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u879870653", "n_user": "u879870653", "pos": "N,M = map(int,input().split())\n\nG = [[] for i in range(N)]\n\nfor i in range(M) :\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n G[a].append(b)\n G[b].append(a)\n\nans = \"NO\" if any(len(g)%2 for g in G) else \"YES\"\n\nprint(ans)\n", "neg": "N,M = map(int,input().split())\n\nG = [[] for i in range(N)]\n\nfor i in range(M) :\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n G[a].append(b)\n G[b].append(a)\n\nans = \"NO\" if any(len(g) for g in G) else \"YES\"\n\nprint(ans)\n", "jacc_sim": 0.9444444444444444, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [111, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u708255304", "n_user": "u708255304", "pos": "N, M = map(int, input().split()) # N\u9802\u70b9, M\u500b\u306e\u30af\u30a8\u30ea\n\ncounter = [0] * N\n\nfor _ in range(M):\n a, b = map(lambda x: int(x) - 1, input().split())\n counter[a] += 1\n counter[b] += 1\n\nflag = True\nfor i in range(len(counter)):\n if counter[i] % 2 != 0:\n flag = False\n\n\nif flag:\n print('YES')\nelse:\n print('NO')\n", "neg": "N, M = map(int, input().split()) # N\u9802\u70b9, M\u500b\u306e\u30af\u30a8\u30ea\n\ncounter = [0] * N\n\nfor _ in range(M):\n a, b = map(lambda x: int(x) - 1, input().split())\n counter[a] += 1\n counter[b] += 1\n\nflag = True\nfor i in range(len(counter)):\n if counter[i] % 2 != 0:\n flag = False\n\n\nif flag:\n print('Yes')\nelse:\n print('No')\n", "jacc_sim": 0.9230769230769231, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [149, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u736729525", "n_user": "u736729525", "pos": "def main():\n import sys\n input = sys.stdin.readline\n N, M = map(int, input().split())\n C = [0]*(N+1)\n for i in range(M):\n a, b = map(int, input().split())\n C[a]+=1\n C[b]+=1\n for i in range(N+1):\n if C[i] % 2 == 1:\n return \"NO\"\n return \"YES\"\n\nprint(main())\n", "neg": "def main():\n import sys\n input = sys.stdin.readline\n N, M = map(int, input().split())\n C = [0]*(N+1)\n for i in range(M):\n a, b = map(int, input().split())\n C[a]+=1\n C[b]+=1\n for i in range(N+1):\n if C[i] % 2 == 1:\n return \"NO\"\n return \"YES\"\n\nmain()\n", "jacc_sim": 0.9743589743589743, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [124, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u426108351", "n_user": "u426108351", "pos": "N, M = map(int, input().split())\nnum = [0] * (N+1)\nfor i in range(M):\n a, b = map(int, input().split())\n num[a] += 1\n num[b] += 1\n\nflag = 1\nfor i in num:\n if i % 2 != 0:\n flag = 0\n\nif flag == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "N, M = map(int, input().split())\nnum = [0] * (N+1)\nfor i in range(M):\n a, b = map(int, input().split())\n num[a] += 1\n num[b] += 1\n\nflag = 1\nfor i in num:\n if num % 2 != 0:\n flag = 0\n\nif flag = 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [110, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u727801592", "n_user": "u727801592", "pos": "n,m=map(int,input().split())\ncnt=[]\nfor i in range(n):\n cnt.append(0)\nfor i in range(m):\n a,b=map(int,input().split())\n cnt[a-1]+=1\n cnt[b-1]+=1\nfor i in range(n):\n if cnt[i]%2==1:\n print('NO')\n exit()\nprint('YES')", "neg": "n,m=map(int,input().split())\ncnt=[]\nfor i in range(n):\n cnt.append(0)\nfor i in range(m):\n a,b=map(int,input().split())\n cnt[a-1]+=1\n cnt[b-1]+=1\nfor i in range(n):\n if cnt[i]%2==1:\n print('NO')\n exit()\nprint('Yes')", "jacc_sim": 0.9428571428571428, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u497046426", "n_user": "u497046426", "pos": "N, M = map(int, input().split())\ncnt = [True]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n cnt[a-1] = not cnt[a-1]; cnt[b-1] = not cnt[b-1];\nprint('YES' if all(cnt) else 'NO')", "neg": "N, M = map(int, input().split())\ncnt = [True]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n cnt[a-1] = ~cnt[a-1]; cnt[b-1] = ~cnt[b-1]\nprint('YES' if all(cnt) else 'NO')", "jacc_sim": 0.9428571428571428, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [85, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u163320134", "n_user": "u163320134", "pos": "n,m=map(int,input().split())\ng=[[] for _ in range(n+1)]\nfor _ in range(m):\n u,v=map(int,input().split())\n g[u].append(v)\n g[v].append(u)\nflag=True\nfor i in range(1,n+1):\n if len(g[i])%2==0:\n continue\n else:\n flag=False\n break\nif flag==True:\n print('YES')\nelse:\n print('NO')", "neg": "n,m=map(int,input().split())\ng=[[]*for _ in range(n+1)]\nfor _ in range(m):\n u,v=map(int,input().split())\n g[u].append(v)\n g[v].append(u)\nflag=True\nfor i in range(1,n+1):\n if g[i]%2==0:\n continue\n else:\n flag=False\n break\nif flag==True:\n print('YES')\nelse:\n print('NO')", "jacc_sim": 0.9512195121951219, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [133, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u785578220", "n_user": "u785578220", "pos": "N,M=map(int,input().split())\nimport collections\ne =[]\nfor i in range(M):\n ta,tb =map(int,input().split())\n e.extend([ta,tb])\nc = collections.Counter(e)\n#print(c)\nans = \"YES\"\nfor i in c:\n if c[i]%2 != 0:\n ans = \"NO\"\nprint(ans)\n", "neg": "N,M=map(int,input().split())\nimport collections\ne =[]\nfor i in range(N):\n ta,tb =map(int,input().split())\n e.extend([ta,tb])\nc = collections.Counter(e)\nprint(c)\nans = \"YES\"\nfor i in c:\n if c[i]%2 != 0:\n ans = \"NO\"\nprint(ans)\n", "jacc_sim": 0.972972972972973, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [103, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u375616706", "n_user": "u375616706", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN, M = map(int, input().split())\nnode = [0]*(N+1)\nfor _ in range(M):\n a, b = map(lambda x: int(x)-1, input().split())\n node[a] += 1\n node[b] += 1\n\nif all(x % 2 == 0 for x in node):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, M = int(input())\nnode = [0]*(N+1)\nfor _ in range(M):\n a, b = map(lambda x: int(x)-1, input().split())\n node[a] += 1\n node[b] += 1\n\nif all(x % 2 == 0 for x in node):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [130, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u054106284", "n_user": "u054106284", "pos": "N, M = (int(i) for i in input().split())\nDP = [False]*N\nfor i in range(M):\n a, b = (int(k) for k in input().split())\n for j in (a, b):\n DP[j-1] = not DP[j-1]\nfor i in range(N):\n if DP[i]:\n print('NO')\n break\nelse:\n print('YES')", "neg": "N, M = (int(i) for i in input().split())\nDP[N] = [False]*N\nfor i in range(M):\n a, b = (int(i) for i in input().split())\n for i in (a, b):\n DP[i-1] = not DP[i-1]\nfor i in range(N):\n if DP[i]:\n print(NO)\n break\nelse:\n print(YES)", "jacc_sim": 0.9117647058823529, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [111, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u884982181", "n_user": "u884982181", "pos": "n,m = map(int,input().split())\nans = [0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n a-=1;b-=1\n ans[a] +=1\n ans[b] +=1\nfor i in range(n):\n if ans[i]%2 ==1:\n print(\"NO\")\n exit()\nprint(\"YES\")", "neg": "n,m = map(int,input().split())\nans = [0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n a-=1,b-=1\n ans[a] +=1\n ans[b] +=1\nfor i in range(n):\n if ans[i]%2 ==1:\n print(\"NO\")\n exit()\nprint(\"YES\")", "jacc_sim": 0.9714285714285714, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [103, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03724", "p_user": "u816116805", "n_user": "u816116805", "pos": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n\n\"\"\"\nagc014 B\n\"\"\"\n\nfrom collections import Counter\nn, m = map(int, input().split())\n\ncnt = Counter()\nfor i in range(m):\n a, b = map(int, input().split())\n cnt[a] += 1\n cnt[b] += 1\n\nfor a in range(1, n+1):\n if cnt[a] % 2 == 1:\n print('NO')\n exit()\n\nprint('YES')\n", "neg": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n\n\"\"\"\nagc014 B\n\"\"\"\n\nfrom collections import Counter\nn, m = map(int, input().split())\n\ncnt = Counter()\nfor i in range(m):\n a, b = map(int, input().split())\n cnt[a] += 1\n cnt[b] += 1\n\nfor a in range(1, n+1):\n if cnt[a] % 2 == 1:\n print('No')\n exit()\n\nprint('Yes')\n", "jacc_sim": 0.9245283018867925, "nl": "Score: 500 points\nProblem Statement:\nTakahashi struggles with tree problems in programming contests, so Aoki helps him practice. Takahashi creates a tree with N vertices numbered 1 to N, initially writing 0 on each edge. Aoki then gives him M queries, each incrementing the number on each edge along the path connecting vertices a_i and b_i by one. Takahashi claims that after executing all queries, the number on every edge becomes even. However, Aoki forgot to confirm if the graph Takahashi created was actually a tree, so it's possible Takahashi made a mistake. Determine if there exists a tree with the property mentioned by Takahashi.\nConstraints:\n2 \u2264 N \u2264 10^5\n1 \u2264 M \u2264 10^5\n1 \u2264 a_i, b_i \u2264 N\na_i \u2260 b_i\nInput:\nGiven from Standard Input in the format: N M a_1 b_1 ... a_M b_M\nOutput:\nPrint \"YES\" if there exists a tree with the property mentioned by Takahashi; otherwise, print \"NO\".\nSample Input 1:\n4 4\n1 2\n2 4\n1 3\n3 4\nSample Output 1:\nYES\nFor example, Takahashi's graph has the property mentioned by him if it has the following edges: 1-2, 1-3, and 1-4. In this case, the number written at every edge will become 2.\nSample Input 2:\n5 5\n1 2\n3 5\n5 1\n3 4\n2 3\nSample Output 2:\nNO", "before_after_length": [150, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u968404618", "n_user": "u968404618", "pos": "n, time = map(int, input().split())\nT = list(map(int, input().split()))\n\ncnt = time\ntmp = T[0]\nfor t in T[1:]:\n if t <= tmp + time:\n cnt += t - tmp\n else:\n cnt += time\n tmp = t\n\nprint(cnt)", "neg": "n, time = map(int, input().split())\nT = list(map(int, input().split()))\n\ncnt = time\ntmp = T[0]\nfor t in T[1:]:\n if t <= time + time:\n cnt += t - tmp\n else:\n cnt += time\n tmp = t\n\nprint(cnt)", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [83, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u212328220", "n_user": "u212328220", "pos": "import itertools\nn, t = map(int,input().split())\ntl = list(map(int,input().split()))\n\nwater = 0\nfor i in range(1,n):\n diff = tl[i]-tl[i-1]\n if diff <= t:\n water += diff\n else:\n water += t\nwater += t\nprint(water)", "neg": "import itertools\nn, t = map(int,input().split())\ntl = list(map(int,input().split()))\n\nwater = 0\nfor i in range(n):\n if tl[i] <= t:\n water += tl[i]\n else:\n water += t\nwater += t\nprint(water)", "jacc_sim": 0.90625, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [92, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u616489782", "n_user": "u616489782", "pos": "N,T = map(int,input().split());\nt = [int(x) for x in input().split()];\n\nend = 0;\nans = 0;\nfor i in range(N) :\n if end > t[i] :\n ans += t[i] + T - end;\n else :\n ans += T;\n end = t[i] + T;\n #print(ans,end);\n\nprint(ans); ", "neg": "N,T = map(int,input().split());\nt = [int(x) for x in input().split()];\n\nend = 0;\nans = 0;\nfor i in range(N) :\n if end > t[i] :\n ans += t[i] + T - end;\n else :\n ans += T;\n end += t[i] + T;\n #print(ans,end);\n\nprint(ans); ", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [108, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u674588203", "n_user": "u674588203", "pos": "N,T=map(int,input().split())\na=list(input().split())\nts=[]\nfor _ in range (len(a)):\n ts.append(int(a[_]))\n\nYU=T\n\nfor i in range(1,N):\n if ts[i]-ts[i-1]=T:\n ans+=T\n else:\n loss=T-space\n ans+=T-loss\n\nprint(ans)", "neg": "N, T=map(int, input().split())\na=list(map(int, input().split()))\n\nans=T\n\nfor i in range(N-1):\n space=a[i+1]-a[i]\n if space>=T:\n ans+=T\n else:\n loss=T-space\n ans+=T-loss\n", "jacc_sim": 0.9666666666666667, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [96, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u056358163", "n_user": "u056358163", "pos": "N, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nans = 0\ns = 0\ne = T\nfor n in t[1:]:\n if e < n:\n ans += e - s\n s = n\n e = n + T\nans += e - s\nprint(ans)", "neg": "N, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nans = 0\ne = 0\ns = 0\nfor n in t[1:]:\n if s + T < n:\n s = n\n ans += e + T\n e = n\nans += (e - s) + T\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [85, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u373047809", "n_user": "u373047809", "pos": "n, T, *t = map(int, open(0).read().split())\nprint(sum(min(t[i+1] - t[i], T) for i in range(n-1)) + T)", "neg": "n, T, *t = map(int, open(0).read().split())\nprint(sum(min(t[i+1] - t[i], T) for i in range(n)))", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [51, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u268792407", "n_user": "u760961723", "pos": "n,T=map(int,input().split())\nt=list(map(int,input().split()))\nt.append(t[-1]+T+1)\nans=0\nfor i in range(n):\n ans += min(T,t[i+1]-t[i])\nprint(ans)", "neg": "N, T = map(int,input().split())\nt = list(map(int,input().split()))\nt.append(T)\n\nans = 0\nfor n in range(N):\n ans += min(t[n+1]-t[n],T)\nprint(ans)", "jacc_sim": 0.9310344827586207, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [75, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u597455618", "n_user": "u943314973", "pos": "n, T = map(int, input().split())\nt = list(map(int, input().split()))\nans = 0\ntmp = t[0]\nfor i in range(1, n):\n if t[i] > t[i-1] + T:\n ans += t[i-1] - tmp + T\n tmp = t[i]\nans += t[n-1] - tmp + T\nprint(ans)", "neg": "n,T = map(int, input().split())\nt = list(map(int, input().split()))\nans = 0\nfor i in range (n-1):\n if T >= t[i+1]-t[i]:\n ans=+(t[i+1]-t[i])\n else:\n ans=+T\n \nprint(ans+T)", "jacc_sim": 0.9333333333333333, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [104, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u183896397", "n_user": "u780698286", "pos": "n,tmax = map(int,input().split())\nt = list(map(int,input().split()))\nans = 0\nfor i in range(n-1):\n if t[i+1] - t[i]< tmax:\n ans += t[i+1] - t[i]\n else:\n ans += tmax\nans += tmax\nprint(ans)", "neg": "n, tx = map(int, input().split())\nt = list(map(int, input().split()))\nans = 0\nfor i in range(n-1):\n if t[i+1] <= tx:\n ans += t[i+1]\n else:\n ans += tx\nprint(ans+tx)", "jacc_sim": 0.9333333333333333, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [91, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u623687794", "n_user": "u623687794", "pos": "n,t=map(int,input().split())\noyu=list(map(int,input().split()))\ninl=[]\nans=n*t\nfor i in range(n-1):\n inl.append(oyu[i+1]-oyu[i])\nfor i in range(n-1):\n if inl[i] 0:\n ans -= rest\n p = t - f\n\nprint(ans)\n", "neg": "N, T = input().split()\n\nf = None\np = None\nans = 0\nfor t in map(int, input().split())\n if f is None:\n f = t\n p = t - f\n\n ans += T\n rest = p + T - (t - f)\n if rest > 0:\n ans -= rest\n\n p = t - f\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [102, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u706695185", "n_user": "u351892848", "pos": "N,T=map(int, input().split())\nt=list(map(int, input().split()))\nans=T\nfor i in range(1, N):\n x = (t[i]-t[i-1]) - T\n if x > 0:\n ans += T\n else:\n ans += T+x\nprint(ans)", "neg": "N, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n if i == N - 1:\n ans += T\n else:\n ans += min(T, t[i + 1])\nprint(ans)\n", "jacc_sim": 0.9032258064516129, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [86, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u782654209", "n_user": "u782654209", "pos": "N,T=map(int,input().split(' '))\ntimes=list(map(int,input().split(' ')))\nprint(sum([min(T, times[i+1]-times[i]) for i in range(N-1)])+T)\n", "neg": "N,T=map(int,input().split(' '))\ntimes=[int(input()) for i in range(N)]\nprint(sum([min(T, times[i+1]-times[i] for i in range(N-1))])+times[-1])", "jacc_sim": 0.9615384615384616, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [63, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u669696235", "n_user": "u669696235", "pos": "N,T=map(int,input().split())\nt=list(map(int,input().split()))\n\nans=0\nfor i in range(0,len(t)-1):\n ans+=min(t[i+1]-t[i],T)\nans+=T\nprint(ans)", "neg": "N,T=map(int,input().split())\nt=list(map(int,input().split()))\n\nfor i in range(0,len(t)-1):\n ans+=min(t[i+1]-t[i],T)\nans+=T\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [75, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u810735437", "n_user": "u810735437", "pos": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport array\nfrom bisect import *\nfrom collections import *\nimport fractions\nimport heapq\nfrom itertools import *\nimport math\nimport random\nimport re\nimport string\nimport sys\n\nN, T = map(int, input().split())\n\nprev = None\nans = 0\nfor t in map(int, input().split()):\n if prev is not None:\n if t - prev < T:\n ans += t - prev\n else:\n ans += T\n prev = t\nans += T\nprint(ans)\n", "neg": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport array\nfrom bisect import *\nfrom collections import *\nimport fractions\nimport heapq\nfrom itertools import *\nimport math\nimport random\nimport re\nimport string\nimport sys\n\nN, T = map(int, input().split())\n\nprev = None\nans = 0\nfor t in map(int, input().split()):\n if prev is not None:\n if t - prev < T:\n ans += t - prev\n else:\n ans += T\n prev = t\n print(\"ans:\", ans)\nans += T\n", "jacc_sim": 0.9807692307692307, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [149, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u856232850", "n_user": "u375616706", "pos": "N,T = list(map(int,input().split()))\n\nt = list(map(int,input().split()))\n\nans = T\n\nfor i in range(N-1):\n ans += min(T,t[i+1]-t[i])\nprint(ans)", "neg": "N, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nans = T\n\nfor i in range(1, N):\n ans = min(T, t[i]-t[i-1])\nprint(ans)\n", "jacc_sim": 0.9615384615384616, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [70, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u667024514", "n_user": "u217627525", "pos": "n,t = map(int,input().split())\nlis = list(map(int,input().split()))\nans = 0\nfor i in range(n-1):\n ans += min(t,lis[i+1]-lis[i])\nans += t\nprint(ans)", "neg": "n,t=map(int,input().split())\na=list(map(int,input().split()))\nans=0\nfor i in range(n-1):\n ans=min(a[i+1]-a[i],t)\nans+=t\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [71, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u143492911", "n_user": "u015467545", "pos": "n,t=map(int,input().split())\na=list(map(int,input().split()))\nans=0\nfor i in range(1,n):\n if a[i]-a[i-1]=t:\n ans+=4\n else:\n ans+=(a[i+1]-a[i])\nprint(ans+t)", "jacc_sim": 0.9032258064516129, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [94, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u063979080", "n_user": "u063979080", "pos": "def main():\n line = input()\n line = line.split(' ')\n n = int(line[0])\n t = int(line[1])\n line = input()\n line = line.split(' ')\n total = 0\n for i in range(1, n):\n total += min(t, int(line[i]) - int(line[i - 1]))\n print(total+t)\n\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n line=input()\n line=line.split(' ')\n n=line[0]\n t=line[1]\n line=input()\n line=line.split(' ')\n total=0\n for i in range(1,n):\n total+=min(t,line[i]-line[i-1])\n print(total)\n \n\nif __name__=='__main__':\n main()", "jacc_sim": 0.967741935483871, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [116, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u039623862", "n_user": "u063073794", "pos": "N,T = map(int, input().split())\nt = list(map(int, input().split()))\ntotal = 0 \n\nfor i in range(N-1):\n if t[i+1] - t[i] < T:\n total += t[i+1] - t[i]\n else:\n total += T\ntotal += T\nprint(total)", "neg": "satooh\nN, T = map(int, input().split())\nt = list(map(int, input().split()))\nans = 0\nfor i in range(N - 1):\n\tif t[i] + T <= t[i + 1]:\n\t\tans += T\n\telse:\n\t\tans += t[i + 1] - t[i]\nans += T\nprint(ans)\n", "jacc_sim": 0.9032258064516129, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [91, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03733", "p_user": "u402629484", "n_user": "u513434790", "pos": "N, T = map(int, input().split())\n\nt = list(map(int, input().split()))\n\na = 0\n\nfor i in range(N-1):\n a += min(T, t[i+1]-t[i])\n\na += T\n\nprint(a)", "neg": "N, T = map(int, input().split())\nt = list(map(int, input().split()))\n\nans = 0\nfor i in range(1,N):\n ans += min(T, t[i] - t[i-1])\n\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given a public bath with a shower that emits water for T seconds when the switch is pushed. If the switch is pushed while the shower is already emitting water, it will continue emitting water for T seconds from that moment. N people will push the switch at different times. You need to determine the total duration for which the shower emits water. The constraints are 1 \u2264 N \u2264 200,000, 1 \u2264 T \u2264 10^9, and 0 \u2264 t_1 < t_2 < t_3 < ... < t_{N-1} < t_N \u2264 10^9. The input is given in the format N T t_1 t_2 ... t_N, and the output should be the total duration X for which the shower emits water.", "before_after_length": [73, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u645250356", "n_user": "u645250356", "pos": "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush\nfrom bisect import bisect_left,bisect_right \nimport sys,math,itertools,fractions,pprint\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,W = inpl()\na = [inpl() for _ in range(n)]\ngds = [[0] for _ in range(4)]\na.sort(key = lambda x:x[1], reverse = True)\na.sort(key = lambda x:x[0])\n# print(a)\nmi = a[0][0]\nfor i,(w,v) in enumerate(a):\n ind = w - mi\n gds[ind].append(v)\nwe = [i+mi for i in range(4)]\ncnt = [0] * 4\nfor i in range(4):\n cnt[i] = len(gds[i])\n tmp = itertools.accumulate(gds[i])\n gds[i] = list(tmp)\n# print(gds)\nit = itertools.product(range(cnt[0]),range(cnt[1]),range(cnt[2]),range(cnt[3]))\nres = 0\nfor ww in it:\n if sum(we[i]*ww[i] for i in range(4)) > W: continue\n now = sum(gds[i][ww[i]] for i in range(4))\n res = max(now, res)\nprint(res)", "neg": "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush\nfrom bisect import bisect_left,bisect_right \nimport sys,math,itertools,fractions,pprint\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nn,W = inpl()\na = [inpl() for _ in range(n)]\ngds = [[0] for _ in range(4)]\na.sort()\na.sort(key = lambda x:x[1], reverse = True)\n# print(a)\nmi = a[0][0]\nfor i,(w,v) in enumerate(a):\n ind = w - mi\n gds[ind].append(v)\nwe = [i+mi for i in range(4)]\ncnt = [0] * 4\nfor i in range(4):\n cnt[i] = len(gds[i])\n tmp = itertools.accumulate(gds[i])\n gds[i] = list(tmp)\n# print(gds)\nit = itertools.product(range(cnt[0]),range(cnt[1]),range(cnt[2]),range(cnt[3]))\nres = 0\nfor ww in it:\n if sum(we[i]*ww[i] for i in range(4)) > W: continue\n now = sum(gds[i][ww[i]] for i in range(4))\n res = max(now, res)\nprint(res)", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [410, 401], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u814986259", "n_user": "u814986259", "pos": "import collections\nN, W = map(int, input().split())\nwv = collections.defaultdict(list)\nw = 0\nfor i in range(N):\n a, b = map(int, input().split())\n wv[a].append(b)\n if i == 0:\n w = a\ns = [[0]*(len(wv[w+i])+1) for i in range(4)]\n\nfor i in range(4):\n wv[w + i].sort(reverse=True)\n for j, x in enumerate(wv[w + i]):\n s[i][j+1] = s[i][j] + x\nans = 0\nL = len(wv[w+3])\nfor i in range(min(len(wv[w]), N)+1):\n tmp1 = s[0][i]\n weight1 = w * i\n if weight1 > W:\n break\n for j in range(min(len(wv[w+1])+1, N+1 - i)):\n\n tmp2 = tmp1 + s[1][j]\n weight2 = weight1 + (w+1)*j\n if weight2 > W:\n break\n for k in range(min(len(wv[w+2])+1, N+1 - i - j)):\n tmp3 = tmp2 + s[2][k]\n weight3 = weight2 + (w+2)*k\n if weight3 > W:\n break\n d = W - weight3\n\n ans = max(ans, tmp3 + s[3][min(L, d//(w+3))])\nprint(ans)\n", "neg": "import collections\nN, W = map(int, input().split())\nwv = collections.defaultdict(list)\nw = 0\nfor i in range(N):\n a, b = map(int, input().split())\n wv[a].append(b)\n if i == 0:\n w = a\ns = [[0]*(len(wv[w+i])+1) for i in range(4)]\n\nfor i in range(4):\n wv[w + i].sort(reverse=True)\n for j, x in enumerate(wv[w + i]):\n s[i][j+1] = s[i][j] + x\nans = 0\nL = len(wv[3])\nfor i in range(min(len(wv[w]), N)+1):\n tmp1 = s[0][i]\n weight1 = w * i\n if weight1 > W:\n break\n for j in range(min(len(wv[w+1])+1, N+1 - i)):\n\n tmp2 = tmp1 + s[1][j]\n weight2 = weight1 + (w+1)*j\n if weight2 > W:\n break\n for k in range(min(len(wv[w+2])+1, N+1 - i - j)):\n tmp3 = tmp2 + s[2][k]\n weight3 = weight2 + (w+2)*k\n if weight3 > W:\n break\n d = W - weight3\n\n ans = max(ans, tmp3 + s[3][min(L, d//(w+3))])\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [397, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u561083515", "n_user": "u561083515", "pos": "N,W = map(int, input().split())\nWV = [[int(i) for i in input().split()] for _ in range(N)]\n\nMINW = WV[0][0]\n\nW0,W1,W2,W3 = [],[],[],[]\nfor w,v in WV:\n if w == MINW: W0.append(v)\n elif w == MINW + 1: W1.append(v)\n elif w == MINW + 2: W2.append(v)\n elif w == MINW + 3: W3.append(v)\n\nW0.sort(reverse=True)\nW1.sort(reverse=True)\nW2.sort(reverse=True)\nW3.sort(reverse=True)\n\nW0 = [0] + W0\nW1 = [0] + W1\nW2 = [0] + W2\nW3 = [0] + W3\n\nfrom itertools import accumulate\n\nW0 = list(accumulate(W0))\nW1 = list(accumulate(W1))\nW2 = list(accumulate(W2))\nW3 = list(accumulate(W3))\n\nans = 0\nfor cnt0 in range(len(W0)):\n for cnt1 in range(len(W1)):\n for cnt2 in range(len(W2)):\n for cnt3 in range(len(W3)):\n SUMW = cnt0 * MINW\n SUMW += cnt1 * (MINW + 1)\n SUMW += cnt2 * (MINW + 2)\n SUMW += cnt3 * (MINW + 3)\n\n if SUMW <= W:\n SUMV = W0[cnt0]\n SUMV += W1[cnt1]\n SUMV += W2[cnt2]\n SUMV += W3[cnt3]\n ans = max(ans, SUMV)\n\nprint(ans)", "neg": "N,W = map(int, input().split())\nWV = [[int(i) for i in input().split()] for _ in range(N)]\n\nMINW = WV[0][0]\n\nW0,W1,W2,W3 = [],[],[],[]\nfor w,v in WV:\n if w == MINW: W0.append(v)\n elif w == MINW + 1: W1.append(v)\n elif w == MINW + 2: W2.append(v)\n elif w == MINW + 3: W3.append(v)\n\nW0.sort(reverse=True)\nW1.sort(reverse=True)\nW2.sort(reverse=True)\nW3.sort(reverse=True)\n\nW0 = [0] + W0\nW0 = [0] + W1\nW0 = [0] + W2\nW0 = [0] + W3\n\nfrom itertools import accumulate\n\nW0 = list(accumulate(W0))\nW1 = list(accumulate(W1))\nW2 = list(accumulate(W2))\nW3 = list(accumulate(W3))\n\nans = 0\nfor cnt0 in range(len(W0)):\n for cnt1 in range(len(W1)):\n for cnt2 in range(len(W2)):\n for cnt3 in range(len(W3)):\n SUMW = cnt0 * MINW\n SUMW += cnt1 * (MINW + 1)\n SUMW += cnt2 * (MINW + 2)\n SUMW += cnt3 * (MINW + 3)\n\n if SUMW <= W:\n SUMV = W0[cnt0]\n SUMV += W1[cnt1]\n SUMV += W2[cnt2]\n SUMV += W3[cnt3]\n ans = max(ans, SUMV)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [463, 463], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u312025627", "n_user": "u312025627", "pos": "def main():\n N, W = (int(i) for i in input().split())\n WV = [[int(i) for i in input().split()] for j in range(N)]\n for i in range(1, N):\n WV[i][0] -= WV[0][0]\n w_base = WV[0][0]\n WV[0][0] = 0\n V = {i: [0] for i in range(4)}\n for w, v in WV:\n V[w].append(v)\n for i in range(4):\n V[i].sort(reverse=True)\n ans = 0\n from itertools import product\n for p in product(range(len(V[0])), range(len(V[1])),\n range(len(V[2])), range(len(V[3]))):\n w_cur = w_base*p[0] + (w_base+1)*p[1] + \\\n (w_base+2)*p[2] + (w_base+3)*p[3]\n if W < w_cur:\n continue\n ans = max(ans, sum(sum(V[i][:min(p[i], len(V[i]))]) for i in range(4)))\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n N, W = (int(i) for i in input().split())\n WV = [[int(i) for i in input().split()] for j in range(N)]\n for i in range(1, N):\n WV[i][0] -= WV[0][0]\n w_base = WV[0][0]\n WV[0][0] = 0\n V = {i: [] for i in range(4)}\n for w, v in WV:\n V[w].append(v)\n for i in range(4):\n V[i].sort(reverse=True)\n ans = 0\n from itertools import product\n for p in product(range(len(V[0])), range(len(V[1])),\n range(len(V[2])), range(len(V[3]))):\n w_cur = w_base*p[0] + (w_base+1)*p[1] + \\\n (w_base+2)*p[2] + (w_base+3)*p[3]\n if W < w_cur:\n continue\n ans = max(ans, sum(sum(V[i][:min(p[i], len(V[i]))]) for i in range(4)))\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [337, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u540761833", "n_user": "u540761833", "pos": "from itertools import accumulate\nN,W = map(int,input().split())\nw = [[] for i in range(4)]\nw1,v1 = map(int,input().split())\nw[0].append(v1)\nfor i in range(N-1):\n wi,vi = map(int,input().split())\n w[wi-w1].append(vi)\nnum = []\nfor i in range(4):\n w[i].sort(reverse= 1)\n w[i] = [0]+list(accumulate(w[i]))\n num.append(len(w[i]))\nans = 0\nfor n1 in range(num[0]):\n for n2 in range(num[1]):\n for n3 in range(num[2]):\n for n4 in range(num[3]):\n wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4\n if wc <= W:\n vc = w[0][n1]+w[1][n2]+w[2][n3]+w[3][n4]\n ans = max(ans,vc)\nprint(ans)\n ", "neg": "from itertools import accumulate\nN,W = map(int,input().split())\nw = [[] for i in range(4)]\nw1,v1 = map(int,input().split())\nw[0].append(v1)\nfor i in range(N-1):\n wi,vi = map(int,input().split())\n w[wi-w1].append(vi)\nnum = []\nfor i in range(4):\n w[i].sort(reverse= 1)\n w[i] = [0]+list(accumulate(w[i]))\n num.append(len(w[i]))\nans = 0\nfor n1 in range(num[0]+1):\n for n2 in range(num[1]+1):\n for n3 in range(num[2]+1):\n for n4 in range(num[3]+1):\n wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4\n if wc <= W:\n vc = w[0][n1]+w[1][n2]+w[2][n3]+w[3][n4]\n ans = max(ans,vc)\nprint(ans)", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [290, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u508486691", "n_user": "u508486691", "pos": "import sys\nimport math\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10**7)\ndef input():\n return sys.stdin.readline()[:-1]\n\nmod = 10**9 + 7\n\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef LIR(row,col):\n if row <= 0:\n return [[] for _ in range(col)]\n elif col == 1:\n return [I() for _ in range(row)]\n else:\n read_all = [LI() for _ in range(row)]\n return map(list, zip(*read_all))\n\n#################\n\nfrom bisect import bisect_right\n\nN,W = LI()\nw,v = LIR(N,2)\n\nw_list = []\nfor i in range(N+1):\n for j in range(i*w[0],i*(w[0]+3)+1):\n w_list.append(j)\nw_list = sorted(list(set(w_list)))\nM = len(w_list)\n\nd = {}\ntemp = 0\nfor wl in w_list:\n d[temp] = wl\n temp += 1\n\ndp = [[0]*M for _ in range(N)]\nfor i in range(N):\n for j in range(M):\n dp[i][j] = dp[i-1][j]\n x = d[j]-w[i]\n if x >= 0:\n p = bisect_right(w_list,x)\n dp[i][j] = max(dp[i][j], dp[i-1][p-1]+v[i])\n\np = bisect_right(w_list,W)\nprint(dp[N-1][p-1])", "neg": "import sys\nimport math\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10**7)\ndef input():\n return sys.stdin.readline()[:-1]\n\nmod = 10**9 + 7\n\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef LIR(row,col):\n if row <= 0:\n return [[] for _ in range(col)]\n elif col == 1:\n return [I() for _ in range(row)]\n else:\n read_all = [LI() for _ in range(row)]\n return map(list, zip(*read_all))\n\n#################\n\nfrom bisect import bisect_right\n\nN,W = LI()\nw,v = LIR(N,2)\n\nw_list = []\nfor i in range(N+1):\n for j in range(i*w[0],i*(w[0]+3)+1):\n w_list.append(j)\nw_list = sorted(list(set(w_list)))\nM = len(w_list)\n\ndw = defaultdict(int)\ndwi = defaultdict(int)\ntemp = 0\nfor wl in w_list:\n dw[temp] = wl\n dwi[wl] = temp\n temp += 1\n\ndp = [[0]*M for _ in range(N)]\nfor i in range(1,N):\n for j in range(M):\n dp[i][j] = dp[i-1][j]\n x = dw[j]-w[i]\n if x >= 0:\n dp[i][j] = max(dp[i][j], dp[i-1][dwi[x]]+v[i])\n\np = bisect_right(w_list,W)\nprint(dp[N-1][p-1])", "jacc_sim": 0.9358974358974359, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [433, 443], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u077291787", "n_user": "u077291787", "pos": "# ARC073D - Simple Knapsack (ABC060D)\nfrom itertools import accumulate\n\n\ndef main():\n N, W, *A = map(int, open(0).read().split())\n V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 \u2264 wi \u2264 w1 + 3)\n for i in range(0, 2 * N, 2):\n w, v = A[i : i + 2]\n V[w - x] += [v]\n for i in range(4):\n V[i] = tuple(accumulate([0] + sorted(V[i], reverse=1)))\n L = [len(v) for v in V]\n ans = 0\n for i in range(L[0]):\n for j in range(L[1]):\n for k in range(L[2]):\n w = i * x + j * (x + 1) + k * (x + 2)\n if w > W:\n break\n l = min(L[3] - 1, (W - w) // (x + 3))\n v = V[0][i] + V[1][j] + V[2][k] + V[3][l]\n ans = max(ans, v)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# ARC073D - Simple Knapsack (ABC060D)\nfrom itertools import accumulate\n\n\ndef main():\n N, W, *A = map(int, open(0).read().split())\n V, x = [[] for _ in range(4)], A[0] # x: w1 (W1 \u2264 wi \u2264 w1 + 3)\n for i in range(0, 2 * N, 2):\n w, v = A[i : i + 2]\n V[w - x] += [v]\n for i in range(4):\n V[i] = tuple(accumulate([0] + sorted(V[i], reverse=1)))\n L = [len(v) for v in V]\n print(V, L)\n ans = 0\n for i in range(L[0]):\n for j in range(L[1]):\n for k in range(L[2]):\n for l in range(L[3]):\n w = i * x + j * (x + 1) + k * (x + 2) + l * (x + 3)\n if w > W:\n break\n v = V[0][i] + V[1][j] + V[2][k] + V[3][l]\n ans = max(ans, v)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9701492537313433, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [343, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u091051505", "n_user": "u196697332", "pos": "from itertools import accumulate\nn, w = map(int, input().split())\nw_0, v_0 = map(int, input().split())\nv_list = [[] for _ in range(4)]\nv_list[0].append(v_0)\nfor _ in range(n - 1):\n w_in, v_in = map(int, input().split())\n v_list[w_in - w_0].append(v_in)\nv_list = [[0] + list(accumulate(sorted(v, reverse=True))) for v in v_list]\nans = 0\nfor i in range(len(v_list[0])):\n for j in range(len(v_list[1])):\n for k in range(len(v_list[2])):\n for l in range(len(v_list[3])):\n if ((i) * w_0) + ((j) * (w_0 + 1)) + ((k) * (w_0 + 2)) + (((l) * (w_0 + 3))) <= w:\n ans = max(ans, v_list[0][i] + v_list[1][j] + v_list[2][k] + v_list[3][l])\n else:\n break\nprint(ans)", "neg": "from itertools import accumulate\nN, W = map(int, input().split())\nw_0, v_0 = map(int, input().split())\nv_list = [[] for _ in range(4)]\nv_list[0].append(v_0)\n\nfor _ in range(n - 1):\n w_in, v_in = map(int, input().split())\n v_list[w_in - w_0].append(v_in)\nv_list = [[0] + list(accumulate(sorted(v, reverse=True))) for v in v_list]\nans = 0\n\n#print(v_list)\n\nfor i in range(len(v_list[0])):\n for j in range(len(v_list[1])):\n for k in range(len(v_list[2])):\n for l in range(len(v_list[3])):\n if (i * w_0) + (j * (w_0 + 1)) + (k * (w_0 + 2)) + (l * (w_0 + 3)) <= W:\n ans = max(ans, v_list[0][i] + v_list[1][j] + v_list[2][k] + v_list[3][l])\n else:\n break\nprint(ans)\n\n", "jacc_sim": 0.9285714285714286, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [311, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u543954314", "n_user": "u543954314", "pos": "n, w = map(int, input().split())\ndi = dict()\nm = 0\nfor _ in range(n):\n x,y = map(int, input().split())\n if x not in di:\n di[x] = []\n di[x].append(y)\nfor i in di:\n di[i].sort(reverse=True)\na = min(di.keys())\nb,c,d = a+1,a+2,a+3\nfor i in b,c,d:\n if i not in di:\n di[i] = []\nfor i in range(len(di[a])+1):\n for j in range(len(di[b])+1):\n for k in range(len(di[c])+1):\n for l in range(len(di[d])+1):\n if i*a + j*b + k*c + l*d <= w:\n m = max(m, sum(di[a][:i] + di[b][:j] + di[c][:k] + di[d][:l]))\nprint(m)", "neg": "n, w = map(int, input().split())\ndi = dict()\nm = 0\nfor _ in range(n):\n x,y = map(int, input().split())\n if x not in di:\n di[x] = []\n di[x].append(y)\nfor i in di:\n di[i].sort(reverse=True)\na,b,c,d = di.keys()\nfor i in range(len(di[a])):\n for j in range(len(di[b])):\n for k in range(len(di[c])):\n for l in range(len(di[d])):\n if i*a + j*b + k*c + l*d <= w:\n m = max(m, sum(di[a][:i+1] + di[b][:j+1] + di[c][:k+1] + di[d][:l+1]))\nprint(m)", "jacc_sim": 0.94, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [270, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u803848678", "n_user": "u803848678", "pos": "n,w = map(int, input().split())\nw4 = [[] for i in range(4)]\nw1 = None\nfor i in range(n):\n ws, vs = map(int,input().split())\n if i == 0:\n w1 = ws\n ws -= w1\n w4[ws].append(vs)\n\nfor i in range(4):\n w4[i].sort(reverse=True)\n tmp = [0]\n for j in w4[i]:\n tmp.append(tmp[-1]+j)\n w4[i] = tmp\nans = 0\nfor i in range(len(w4[0])):\n for j in range(len(w4[1])):\n for k in range(len(w4[2])):\n for l in range(len(w4[3])):\n if w >= w1*(i+j+k+l) + j + 2*k + 3*l:\n ans = max(ans, w4[0][i]+w4[1][j]+w4[2][k]+w4[3][l])\nprint(ans)", "neg": "n,w = map(int, input().split())\nw4 = [[] for i in range(4)]\nw1 = None\nfor i in range(n):\n ws, vs = map(int,input().split())\n if i == 0:\n w1 = ws\n ws -= w1\n w4[ws].append(vs)\n\nfor i in range(4):\n w4[i].sort(reverse=True)\n tmp = [0]\n for j in w4[i]:\n tmp.append(tmp[-1]+j)\n w4[i] = tmp\nans = 0\nfor i in range(len(w4[0])):\n for j in range(len(w4[1])):\n for k in range(len(w4[2])):\n for l in range(len(w4[3])):\n if w >= w1*(i+j+k+l) + j + 2*k + 3*l:\n print(i,j,k,l)\n ans = max(ans, w4[0][i]+w4[1][j]+w4[2][k]+w4[3][l])\nprint(ans)", "jacc_sim": 1.0, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [273, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u375616706", "n_user": "u375616706", "pos": "from itertools import accumulate\nimport heapq\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, W = map(int, input().split())\nfirst_item = list(map(int, input().split()))\nbasew = first_item[0]\nw0 = []\nw1 = []\nw2 = []\nw3 = []\nw0.append(first_item[1])\nfor _ in range(N-1):\n w, v = map(int, input().split())\n w -= basew\n if w == 0:\n w0.append(v)\n elif w == 1:\n w1.append(v)\n elif w == 2:\n w2.append(v)\n elif w == 3:\n w3.append(v)\n\nw0_acc = [0]+list(accumulate(sorted(w0, reverse=True)))\nw1_acc = [0]+list(accumulate(sorted(w1, reverse=True)))\nw2_acc = [0]+list(accumulate(sorted(w2, reverse=True)))\nw3_acc = [0]+list(accumulate(sorted(w3, reverse=True)))\nv = 0\nfor i0 in range(len(w0)+1):\n for i1 in range(len(w1)+1):\n for i2 in range(len(w2)+1):\n for i3 in range(len(w3)+1):\n if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:\n break\n else:\n v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])\nprint(v)\n", "neg": "from itertools import accumulate\nimport heapq\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, W = map(int, input().split())\nfirst_item = list(map(int, input().split()))\nbasew = first_item[0]\nw0 = []\nw1 = []\nw2 = []\nw3 = []\nheapq.heappush(w0, first_item[1])\nfor _ in range(N-1):\n w, v = map(int, input().split())\n w -= basew\n if w == 0:\n heapq.heappush(w0, v)\n elif w == 1:\n heapq.heappush(w1, v)\n elif w == 2:\n heapq.heappush(w2, v)\n elif w == 3:\n heapq.heappush(w3, v)\n\nw0_acc = [0]+list(accumulate(reversed(w0)))\nw1_acc = [0]+list(accumulate(reversed(w1)))\nw2_acc = [0]+list(accumulate(reversed(w2)))\nw3_acc = [0]+list(accumulate(reversed(w3)))\nv = 0\nfor i0 in range(len(w0)):\n for i1 in range(len(w1)):\n for i2 in range(len(w2)):\n for i3 in range(len(w3)):\n if basew*(i0+i1+i2+i3)+3*i3 + 2*i2 + i1 > W:\n break\n else:\n v = max(v, w0_acc[i0]+w1_acc[i1]+w2_acc[i2]+w3_acc[i3])\nprint(v)\n", "jacc_sim": 0.9154929577464789, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [447, 456], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u054106284", "n_user": "u054106284", "pos": "N, W = (int(i) for i in input().split())\nw = [0]*N\nv = [0]*N\nfor i in range(N):\n w[i], v[i] = (int(j) for j in input().split())\nw0 = w[0]\nwh = [a - w0 for a in w]\ndp = [[[-1]*(N+1) for i in range(3*N+1)] for j in range(N+1)]\ndp[0][0][0] = 0\nfor i in range(N):\n for j in range(3*N+1):\n for k in range(N+1):\n if dp[i][j][k] != -1:\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])\n if j - wh[i] >=0 and k-1 >=0 and dp[i][j-wh[i]][k-1] != -1:\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i])\nres = 0\nfor j in range(3*N+1):\n for k in range(N+1):\n if j + w0*k <= W:\n res = max(dp[N][j][k], res)\nprint(res)\n", "neg": "N, W = (int(i) for i in input().split())\nw = [0]*N\nw0 = w[0]\nwh = [a - w0 for a in W]\nv = [0]*N\nfor i in range(N):\n w[i], v[i] = (int(i) for i in input().split())\ndp = [[[0]*(N+1) for i in range(3N+1)] for j in range(N+1)]\nfor i in range(N):\n for j in range(3N+1):\n for k in range(N+1):\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])\n if j - wh[i] >=0 and k-1 >=0:\n dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i])\nres = 0\nfor k in range(N+1):\n if w0*k <= W <= (w0+3)*k:\n Wk = W - w0*k\n ans = 0\n for j in range(Wk+1):\n ans = max(dp[N][j][k], ans)\n res = max(res, ans)\nprint(res)", "jacc_sim": 0.9047619047619048, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [347, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03734", "p_user": "u458617779", "n_user": "u458617779", "pos": "ints = input().split(\" \")\nN = int(ints[0])\nmaxW = int(ints[1])\nints = input().split(\" \")\na = int(ints[0])\nb = int(ints[1])\nweight = [a, a+1, a+2, a+3] \nva = [[b],[],[],[]]\nfor i in range(1, N):\n\tins = input().split(\" \")\n\tw = int(ins[0])\n\tv = int(ins[1])\n\tfor j in range(0, 4):\n\t\tif w == weight[j]:\n\t\t\tva[j].append(v)\nfor i in range(0, len(va)):\n\tva[i].sort(reverse=True)\n\tva[i].insert(0,0)\n#print(va)\nsum = [[0],[0],[0],[0]]\nfor j in range(0, 4):\n\tfor i in range(1, len(va[j])):\n\t\ttry:\n\t\t\tsum[j].append(sum[j][i-1] + va[j][i])\n\t\texcept:\n\t\t\tpass\nans = 0\n#print(sum)\nfor i in range(0, len(va[0])):\n\tfor j in range(0, len(va[1])):\n\t\tfor k in range(0, len(va[2])):\n\t\t\tfor l in range(0, len(va[3])):\n\t\t\t\tsumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l\n\t\t\t\tif(sumw <= maxW):\n\t\t\t\t\tans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)\nprint(ans)", "neg": "ints = input().split(\" \")\nN = int(ints[0])\nmaxW = int(ints[1])\nints = input().split(\" \")\na = int(ints[0])\nb = int(ints[1])\nweight = [a, a+1, a+2, a+3] \nva = [[0,b],[0],[0],[0]]\nfor i in range(1, N):\n\tins = input().split(\" \")\n\tw = int(ins[0])\n\tv = int(ins[1])\n\tfor j in range(0, 4):\n\t\tif w == weight[j]:\n\t\t\tva[j].append(v)\nva.sort()\nsum = [[0],[0],[0],[0]]\nfor j in range(0, 4):\n\tfor i in range(1, len(va[j])):\n\t\ttry:\n\t\t\tsum[j].append(sum[j][i-1] + va[j][i])\n\t\texcept:\n\t\t\tpass\nans = 0\nfor i in range(0, len(va[0])):\n\tfor j in range(0, len(va[1])):\n\t\tfor k in range(0, len(va[2])):\n\t\t\tfor l in range(0, len(va[3])):\n\t\t\t\tsumw = weight[0]*i + weight[1]*j +weight[2]*k + weight[3]*l\n\t\t\t\tif(sumw <= maxW):\n\t\t\t\t\tans = max(sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l],ans)\nprint(ans)", "jacc_sim": 0.9259259259259259, "nl": "You have N items and a bag with a weight limit of W. Each item has a weight (w_i) and a value (v_i). You need to select items to put in the bag such that the total weight does not exceed W, while maximizing the total value of the selected items. Constraints: 1 \u2264 N \u2264 100, 1 \u2264 W \u2264 10^9, 1 \u2264 w_i \u2264 10^9, 1 \u2264 v_i \u2264 10^7. Input format: N W, followed by N lines of w_i and v_i. Output the maximum possible total value of the selected items.", "before_after_length": [429, 390], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03735", "p_user": "u062147869", "n_user": "u062147869", "pos": "import sys\ninput = sys.stdin.readline\nN=int(input())\nA=[]\nC=[]\nD=[]\nfor i in range(N):\n a,b=map(int,input().split())\n c,d=min(a,b),max(a,b)\n A.append((c,d))\n C.append(c)\n D.append(d)\nA.sort()\n#print(A,C,D,si,ti)\nif N==1:\n print(0)\n sys.exit()\nans=(max(C)-min(C))*(max(D)-min(D))\ncur=max(C)\nma=min(D)\nT=10**19\nfor a,b in A:\n if a>ma:\n T=min(T,cur-ma)\n break\n T=min(T,cur-a)\n cur=max(cur,b)\nprint(min(ans,(max(D)-min(C))*T))", "neg": "import sys\ninput = sys.stdin.readline\nN=int(input())\nA=[]\nC=[]\nD=[]\nfor i in range(N):\n a,b=map(int,input().split())\n c,d=min(a,b),max(a,b)\n A.append((c,d))\n C.append(c)\n D.append(d)\n#print(A,C,D,si,ti)\nif N==1:\n print(0)\n sys.exit()\nans=(max(C)-min(C))*(max(D)-min(D))\ncur=min(D)\nma=min(D)\nT=10**19\nfor a,b in A:\n if a>ma:\n T=min(best,cur-ma)\n break\n T=min(T,cur-a)\n cur=max(cur,b)\n\nprint(min(ans,(max(D)-min(C))*T))", "jacc_sim": 0.9607843137254902, "nl": "You have N bags, each containing two white balls with integers written on them. You need to paint one ball in each bag red and the other blue. After painting, the 2N balls will be classified by color. Find the minimum possible value of (R_max - R_min) * (B_max - B_min), where R_max and R_min are the maximum and minimum integers written on red balls, and B_max and B_min are the maximum and minimum integers written on blue balls. Constraints: 1 \u2264 N \u2264 200,000, 1 \u2264 xi, yi \u2264 10^9. Input is given as N followed by pairs of xi and yi. Output the minimum possible value.", "before_after_length": [244, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03735", "p_user": "u327466606", "n_user": "u327466606", "pos": "N = int(input())\nballs = sorted(tuple(sorted(map(int,input().split()))) for i in range(N))\n\n# Rmin=MIN, Bmax=MAX\nmaxmin = balls[-1][0]\nminmin = balls[0][0]\nmaxmax = max(b[1] for b in balls)\nminmax = min(b[1] for b in balls)\n\nv1 = (maxmin-minmin)*(maxmax-minmax)\n\n# Rmin=MIN, Rmax=MAX\nbest = float('inf')\ncur_max = maxmin\nfor b in balls:\n if b[0] > minmax:\n best = min(best, cur_max-minmax)\n break\n best = min(best, cur_max-b[0])\n cur_max = max(cur_max, b[1])\n \nv2 = (maxmax-minmin)*best\n\nprint(min(v1,v2))", "neg": "N = int(input())\nballs = sorted(tuple(sorted(map(int,input().split()))) for i in range(N))\n\n# Rmin=MIN, Bmax=MAX\nmaxmin = balls[-1][0]\nminmin = balls[0][0]\nmaxmax = max(b[1] for b in balls)\nminmax = min(b[1] for b in balls)\n\nv1 = (maxmin-minmin)*(maxmax-minmax)\n\n# Rmin=MIN, Rmax=MAX\nbest = float('inf')\ncur_max = maxmin\nfor b in balls:\n if b[0] > minmax:\n break\n best = min(best, cur_max-b[0])\n cur_max = max(cur_max, b[1])\n\nv2 = (maxmax-minmin)*best\n\nprint(min(v1,v2))", "jacc_sim": 1.0, "nl": "You have N bags, each containing two white balls with integers written on them. You need to paint one ball in each bag red and the other blue. After painting, the 2N balls will be classified by color. Find the minimum possible value of (R_max - R_min) * (B_max - B_min), where R_max and R_min are the maximum and minimum integers written on red balls, and B_max and B_min are the maximum and minimum integers written on blue balls. Constraints: 1 \u2264 N \u2264 200,000, 1 \u2264 xi, yi \u2264 10^9. Input is given as N followed by pairs of xi and yi. Output the minimum possible value.", "before_after_length": [236, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03735", "p_user": "u902500155", "n_user": "u902500155", "pos": "# coding: utf-8\n# \u6574\u6570\u306e\u5165\u529b\n#a = int(raw_input())\n# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\nimport heapq\nN = int(input())\n\nRmax = 0\nRmin = 1000000001\nBmax = 0\nBmin = 1000000001\n\ndata = sorted([sorted(list(map(int, input().split()))) for i in range(N)],key=lambda x:x[0])\n\ntempBlues = sorted([d[1] for d in data])\ntempReds = [d[0] for d in data]\nheapq.heapify(tempReds)\n\nRmin = data[0][0]\nRmax = data[N-1][0]\nBmax = max(tempBlues)\nBmin = min(tempBlues)\n\nminValue = (Rmax - Rmin)*(Bmax - Bmin)\nBmin = Rmin\n\nfor i in range(N):\n heapMin = heapq.heappop(tempReds)\n if heapMin == data[i][0]:\n heapq.heappush(tempReds, data[i][1])\n if data[i][1] > Rmax:\n Rmax = data[i][1]\n if (Rmax - tempReds[0])*(Bmax - Bmin) < minValue:\n minValue = (Rmax - tempReds[0])*(Bmax - Bmin)\n else:\n break\n\nprint(minValue)", "neg": "# coding: utf-8\n# \u6574\u6570\u306e\u5165\u529b\n#a = int(raw_input())\n# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\nimport heapq\nN = int(input())\n\nRmax = 0\nRmin = 1000000001\nBmax = 0\nBmin = 1000000001\n\ndata = sorted([sorted(list(map(int, input().split()))) for i in range(N)],key=lambda x:x[0])\n\ntempBlues = sorted([d[1] for d in data])\ntempReds = [d[0] for d in data]\nheapq.heapify(tempReds)\nprint(tempReds)\n\nRmin = data[0][0]\nRmax = data[N-1][0]\nBmax = max(tempBlues)\nBmin = min(tempBlues)\n\nminValue = (Rmax - Rmin)*(Bmax - Bmin)\nBmin = Rmin\n\nfor i in range(N):\n heapMin = heapq.heappop(tempReds)\n if heapMin == data[i][0]:\n heapq.heappush(tempReds, data[i][1])\n if data[i][1] > Rmax:\n Rmax = data[i][1]\n if (Rmax - tempReds[0])*(Bmax - Bmin) < minValue:\n minValue = (Rmax - tempReds[0])*(Bmax - Bmin)\n else:\n break\n\nprint(minValue)", "jacc_sim": 1.0, "nl": "You have N bags, each containing two white balls with integers written on them. You need to paint one ball in each bag red and the other blue. After painting, the 2N balls will be classified by color. Find the minimum possible value of (R_max - R_min) * (B_max - B_min), where R_max and R_min are the maximum and minimum integers written on red balls, and B_max and B_min are the maximum and minimum integers written on blue balls. Constraints: 1 \u2264 N \u2264 200,000, 1 \u2264 xi, yi \u2264 10^9. Input is given as N followed by pairs of xi and yi. Output the minimum possible value.", "before_after_length": [398, 405], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u814419162", "n_user": "u814419162", "pos": "a,b=[int(x) for x in input().split()]\nif abs(a-b)<=1:\n \tprint(\"Brown\")\nelse:\n \tprint(\"Alice\")", "neg": "a,b=[int(x) for x in input().split()]\nif abs(a-b)<=1:\n \tprint(\"Brown):\nelse:\n print(\"Alice\")", "jacc_sim": 1.0, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [47, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u107639613", "n_user": "u107639613", "pos": "import sys\nfrom itertools import accumulate\ndef input(): return sys.stdin.readline().strip()\n\ndef main():\n X, Y = map(int, input().split())\n \"\"\"\n \u5fc5\u52dd\u6cd5\u306f\u300c\u76f8\u624b\u306b\u5c71\u306e\u5dee\u304c\uff11\u306b\u306a\u308b\u3088\u3046\u306b\u30bf\u30fc\u30f3\u3092\u6e21\u3059\u3053\u3068\u300d\n \u305d\u3057\u305f\u3089\u76f8\u624b\u304c\u3069\u3093\u306a\u64cd\u4f5c\u3092\u3057\u3066\u304d\u3066\u3082\u518d\u3073\u5c71\u306e\u5dee\u3092\uff11\u306b\u3067\u304d\u308b\u306e\u3067\u3001\n \u6700\u7d42\u7684\u306b\u306f(0, 0), (0, 1), (1, 0)\u306e\u3069\u308c\u304b\u306e\u72b6\u614b\u3092\u76f8\u624b\u306b\u308f\u305f\u3059\u3053\u3068\u306b\u306a\u308b\u3002\n\n \u3053\u308c\u3069\u3046\u3084\u3063\u305f\u3089\u6c17\u3065\u3051\u308b\u306e\uff1f\u5b9a\u5e38\u72b6\u614b\u304c\u3042\u308b\u306e\u304c\u3053\u306e\u624b\u306e\u554f\u984c\u306e\u5b9a\u77f3\uff1f\n \"\"\"\n if abs(X - Y) <= 1:\n print(\"Brown\")\n else:\n print(\"Alice\")\n \n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\nfrom itertools import accumulate\ndef input(): return sys.stdin.readline().strip()\n\ndef main():\n X, Y = map(int, input().split())\n \"\"\"\n \u5fc5\u52dd\u6cd5\u306f\u300c\u76f8\u624b\u306b\u5c71\u306e\u5dee\u304c\uff11\u306b\u306a\u308b\u3088\u3046\u306b\u30bf\u30fc\u30f3\u3092\u6e21\u3059\u3053\u3068\u300d\n \u305d\u3057\u305f\u3089\u76f8\u624b\u304c\u3069\u3093\u306a\u64cd\u4f5c\u3092\u3057\u3066\u304d\u3066\u3082\u518d\u3073\u5c71\u306e\u5dee\u3092\uff11\u306b\u3067\u304d\u308b\u306e\u3067\u3001\n \u6700\u7d42\u7684\u306b\u306f(0, 0), (0, 1), (1, 0)\u306e\u3069\u308c\u304b\u306e\u72b6\u614b\u3092\u76f8\u624b\u306b\u308f\u305f\u3059\u3053\u3068\u306b\u306a\u308b\u3002\n\n \u3053\u308c\u3069\u3046\u3084\u3063\u305f\u3089\u6c17\u3065\u3051\u308b\u306e\uff1f\u5b9a\u5e38\u72b6\u614b\u304c\u3042\u308b\u306e\u304c\u3053\u306e\u624b\u306e\u554f\u984c\u306e\u5b9a\u77f3\uff1f\n \"\"\"\n if abs(X - Y) == 1:\n print(\"Brown\")\n else:\n print(\"Alice\")\n \n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9897959183673469, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [476, 476], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u075595666", "n_user": "u075595666", "pos": "n,m = map(int,input().split())\nif abs(n-m) < 2:\n print('Brown')\nelse:\n print('Alice')", "neg": "n,m = map(int(input().split()))\nif abs(n-m) < 2:\n print('Brown')\nelse:\n print('Alice')", "jacc_sim": 1.0, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [40, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u931173291", "n_user": "u931173291", "pos": "a,b=map(int,input().split())\ncnt=1\nif abs(a-b)<=1:\n print('Brown')\nelse:\n print('Alice')\n\n\n# if b>a:\n# a,b=b,a\n# a=a-b\n# b=0\n# mod_a=a%3\n# if a==3:\n# print('Alice')\n# elif mod_a==2:\n# print('Alice')\n# elif mod_a==1:\n# print('Brown')\n# elif (mod_a==0)and(a!=3):\n# print('Brown')\n# if (mod_a==3)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==3)and(mod_b==1):\n# print('Alice')\n# elif (mod_a==1)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==2)and(mod_b==0):\n# print('Alice') \n# elif (mod_a==0)and(mod_b==2):\n# print('Alice')\n# else:\n# print('Brown')", "neg": "a,b=map(int,input().split())\ncnt=1\nif b>a:\n a,b=b,a\na=a-b\nb=0\nmod_a=a%3\nif mod_a==2:\n print('Alice')\nelif mod_a==1:\n print('Brown')\nelif mod_a==0:\n print('Brown')\n# if (mod_a==3)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==3)and(mod_b==1):\n# print('Alice')\n# elif (mod_a==1)and(mod_b==3):\n# print('Alice')\n# elif (mod_a==2)and(mod_b==0):\n# print('Alice') \n# elif (mod_a==0)and(mod_b==2):\n# print('Alice')\n# else:\n# print('Brown')", "jacc_sim": 0.9117647058823529, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [302, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u780962115", "n_user": "u780962115", "pos": "#\u4e00\u554f\u76ee\nx,y=map(int,input().split())\nif abs(x-y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")\n", "neg": "#\u4e00\u554f\u76ee\nx,y=map(int,input().split())\nif abs(x-y)<=1:\n print(\"Blown\")\nelse:\n print(\"Alice\")", "jacc_sim": 0.9259259259259259, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [53, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nX, Y = lr()\n\nif abs(Y - X) >= 2:\n print('Alice')\nelse:\n print('Brown')\n\n# 24", "neg": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nX, Y = lr()\n\nif abs(Y - X) >= 2:\n print('Alice')\nelse:\n print('Bob')\n\n# 24", "jacc_sim": 0.9411764705882353, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [84, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u886747123", "n_user": "u497952650", "pos": "X, Y = map(int, input().split())\nprint(\"Alice\" if abs(X-Y)>=2 else \"Brown\")", "neg": "X,Y = map(int,input().split())\n\nprint(\"Alice\" if abs(X-Y)>=1 else \"Brown\")", "jacc_sim": 0.9090909090909091, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [33, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u595893956", "n_user": "u595893956", "pos": "a,b = map(int,input().split())\nprint(\"ABlriocwen\"[not abs(a-b)>1 :: 2])\n", "neg": "a,b = map(int,input())\nprint(\"ABlriocwen\"[not abs(a-b)>1 :: 2])", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [36, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u281303342", "n_user": "u931938233", "pos": "X,Y = map(int,input().split())\nprint(\"Brown\" if abs(X-Y)<2 else \"Alice\")", "neg": "X,Y=map(int,input().split())\nprint('Alice' if abs(X-Y) < 2 else 'Brown')", "jacc_sim": 1.0, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [32, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u608088992", "n_user": "u497952650", "pos": "X, Y = map(int, input().split())\nprint(\"Alice\" if abs(X- Y) > 1 else \"Brown\")", "neg": "X,Y = map(int,input().split())\n\nprint(\"Alice\" if abs(X-Y)>=1 else \"Bob\")\n", "jacc_sim": 0.9090909090909091, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [32, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u761320129", "n_user": "u211160392", "pos": "X,Y = map(int,input().split())\nif X > Y:\n X,Y = Y,X\nif Y-X >= 2:\n print('Alice')\nelse:\n print('Brown')", "neg": "X,Y = map(int,input().split())\nif X >= 2 and Y >= 2:\n print(\"Alice\")\nelse:\n print(\"Brown\")", "jacc_sim": 0.9090909090909091, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [52, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u205561862", "n_user": "u205561862", "pos": "x,y=map(int,input().split());print(['Alice','Brown'][abs(x-y)<2])\n", "neg": "x,y=map(int,input().split());print(['Alice','Blown'][abs(x-y)<2])\n", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [32, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u232852711", "n_user": "u824237520", "pos": "x, y = list(map(int, input().split()))\n\nif abs(x-y) > 1:\n print('Alice')\nelse:\n print('Brown')\n", "neg": "x, y = map(int, input().split())\n\nif abs(x - y) == 1:\n print('Brown')\nelse:\n print('Alice')", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [45, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u391475811", "n_user": "u391475811", "pos": "X,Y=map(int,input().split())\nif max(X,Y)-min(X,Y) > 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")\n", "neg": "X,Y=map(int,input())\nif max(X,Y)-min(X,Y) > 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [47, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u667024514", "n_user": "u884982181", "pos": "x,y= map(int,input().split())\nif abs(x-y) > 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")", "neg": "x,y = map(int,input().split())\nif abs(x-y) <= 1:\n print(\"Alice\")\nelse:\n print(\"Brown\")", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [40, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u761320129", "n_user": "u925364229", "pos": "X,Y = map(int,input().split())\nprint('Brown' if abs(X-Y) <= 1 else 'Alice')\n", "neg": "X,Y = map(int,input().split(\" \"))\n\nif abs(X-Y) < 1:\n\tprint(\"Alice\")\nelse:\n\tprint(\"Brown\")\n\n", "jacc_sim": 0.9545454545454546, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [33, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u579170193", "n_user": "u579170193", "pos": "a,b=map(int,input().split());print(abs(a-b)<2and'Brown'or'Alice')", "neg": "a,b=map(int,raw_input().split());print(abs(a-b)<2and'Brown'or'Alice')", "jacc_sim": 0.9090909090909091, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [32, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u009102496", "n_user": "u009102496", "pos": "a,b=map(int,input().split())\n \nif abs(a-b)<2:\n print(\"Brown\")\nelse:\n print(\"Alice\")", "neg": "a,b=map(int,input().split())\n\nif abs(a-b)<2:\n print(\"Brown\")\nelif:\n print(\"Alice\")", "jacc_sim": 0.9130434782608695, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [42, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u533084327", "n_user": "u533084327", "pos": "import numpy as np\n\nX,Y = list(map(int,input().split()))\n'''\nprint(X)\nprint(Y)\nZ = np.sort(Z)[::-1]\n#print(Z)\ncount = 0\nif Z[0]==1 or Z[0]==0:\n print ('Brown')\nelse:\n while Z[0] != 1:\n Z[1] += int(Z[0]/2)\n Z[0] -= int(Z[0]/2)*2\n Z = np.sort(Z)[::-1]\n count += 1\n print (Z)\n if (count%2) == 1:\n print ('Alice')\n else: print ('Brown')\n'''\n\nif np.abs(X-Y)<=1:\n print('Brown')\nelse:\n print('Alice')", "neg": "import numpy as np\n\nZ = list(map(int,input().split()))\n'''\nprint(X)\nprint(Y)\n'''\nZ = np.sort(Z)[::-1]\n#print(Z)\ncount = 0\nif Z[0]==1 or Z[0]==0:\n print ('Brown')\nelse:\n while Z[0] != 1:\n Z[1] += int(Z[0]/2)\n Z[0] -= int(Z[0]/2)*2\n Z = np.sort(Z)[::-1]\n count += 1\n print (Z)\n if (count%2) == 1:\n print ('Alice')\n else: print ('Brown')", "jacc_sim": 0.9523809523809523, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [209, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u382423941", "n_user": "u382423941", "pos": "x, y = map(int, input().split())\nprint('Brown' if abs(x-y) <= 1 else 'Alice')\n", "neg": "x, y = map(int, input().split())\nprint('Alice' if abs(x-y) else 'Brown')\n", "jacc_sim": 0.9047619047619048, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [33, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03740", "p_user": "u256260242", "n_user": "u382423941", "pos": "x, y = map(int, input().split())\nif abs(x-y)<=1:\n print(\"Brown\")\nelse:\n print(\"Alice\")", "neg": "x, y = map(int, input().split())\nprint('Alice' if abs(x-y) < 1 else 'Brown')\n", "jacc_sim": 0.9545454545454546, "nl": "In this game, Alice and Bob take turns removing stones from two piles. They can take 2i stones from one pile, discard i stones, and place the remaining i stones in the other pile. The player who can't perform this operation loses. Given X and Y stones in the initial piles, determine the winner if both players play optimally. Constraints: 0 \u2264 X, Y \u2264 10^18. Input format: X Y. Output the winner: Alice or Bob.", "before_after_length": [41, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03743", "p_user": "u209551477", "n_user": "u315897868", "pos": "N, D = map( int, input().split() )\nd = list( map( int, input().split() ) )\nQ = int( input() )\nq = list( map( int, input().split() ) )\n\ndis = [ 0 for i in range( N + 1 ) ]\ndis[ 0 ] = D\nfor i in range( N ):\n dis[ i + 1 ] = min( dis[ i ], abs( dis[ i ] - d[ i ] ) )\n\ndp = [ 0 for i in range( N + 1 ) ]\ndp[ N ] = 1\nfor i in range( N - 1, -1, -1 ):\n if dp[ i + 1 ] <= d[ i ] // 2:\n dp[ i ] = dp[ i + 1 ]\n else:\n dp[ i ] = dp[ i + 1 ] + d[ i ]\n\nfor qi in range( Q ):\n print( [ \"NO\", \"YES\" ][ dis[ q[ qi ] - 1 ] >= dp[ q[ qi ] ] ] )\n", "neg": "N, D = map(int, input().split())\nd = list(map(int, input().split()))\nQ = int(input())\nq = list(map(lambda x : int(x)-1 , input().split()))\n\ndis = [0 for i in range(N+1)]\ndis[0] = D\nfor i in range(0, N):\n dis[i+1] = min(dis[i], abs(dis[i] - d[i]))\n\ndp = [0 for i in range(N+1)]\ndp[N] = 1\nfor i in range(N-1, -1, -1):\n if d[i] // 2 >= dp[i+1]:\n dp[i] = dp[i+1]\n else:\n dp[i] = dp[i+1] + d[i]\n\nfor i in range(Q):\n print([\"YES\", \"NO\"][dis[q[i]] <= dp[q[i] + 1]])", "jacc_sim": 0.9302325581395349, "nl": "Alice lives on a line and will travel to a destination using a vehicle. Initially, the distance between Alice and her destination is D. When she inputs a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would shorten the distance, and it will stay at its position otherwise. The vehicle may go past the destination when the distance between the vehicle and the destination is less than x. Alice has a list of N numbers, and she will insert these numbers to the vehicle one by one. A mischievous witch wants to rewrite one number in the list so that Alice will not reach the destination after N moves. The program should determine whether each plan is feasible. Constraints: 1\u2264N\u22645*10^5, 1\u2264Q\u22645*10^5, 1\u2264D\u226410^9, 1\u2264d_i\u226410^9(1\u2264i\u2264N), 1\u2264q_i\u2264N(1\u2264i\u2264Q). The input is given in the format: N D, followed by N numbers, then Q, and finally Q numbers. The output should contain Q lines, each indicating whether the corresponding plan is feasible (YES) or not (NO).", "before_after_length": [250, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u583507988", "n_user": "u583507988", "pos": "n,l,t=map(int,input().split())\ndata=[]\ns=0\nfor i in range(n):\n x,w=map(int,input().split())\n if w==1:\n data.append((x+t)%l)\n s+=(x+t)//l\n else:\n data.append((x-t)%l)\n s+=(x-t)//l\ndata.sort()\nres=s%n\ndata=data[res:]+data[:res]\nfor i in data:\n print(i)", "neg": "n,l,t=map(int,input().split())\ndata=[0]*n\ns=0\nfor i in range(n):\n x,w=map(int,input().split())\n if w==1:\n data[i]=(x+t)%l\n s+=(x+t)//l\n else:\n data[i]==(x-t)%l\n s+=(x-t)//l\ndata.sort()\nres=s%n\ndata=data[res:]+data[:res]\nfor i in data:\n print(i)", "jacc_sim": 0.9444444444444444, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [138, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u146346223", "n_user": "u146346223", "pos": "n, l, t = map(int,input().split())\n\nc = []\ns = 0\n\nfor i in range(n):\n x, w = map(int,input().split())\n if w == 1:\n c.append((x+t)%l)\n s += (x+t)//l\n else: # w == 2\n c.append((x-t)%l)\n s += (x-t)//l\n\nc.sort()\ns %= n\nc = c[s:] + c[:s]\nprint(*[i for i in c], sep='\\n')", "neg": "n, l, t = map(int, input().split())\n\narr = []\nfor i in range(n):\n x, w = map(int, input().split())\n\n if w == 1:\n arr.append((x+t) % l)\n s += (x+t) // l\n else: # W == 2:\n arr.append((x-t) % l)\n s += (x-t) // l\n\narr.sort()\ns %= n\narr = arr[s:] + arr[:s]\nprint(*[i for i in arr], sep='\\n')", "jacc_sim": 0.9047619047619048, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [146, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u193264896", "n_user": "u193264896", "pos": "import sys\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, L, T = map(int, readline().split())\n position = []\n #0\u3092L-1\u304b\u3089\u30fc\u306b\u6642\u8a08\u56de\u308a\u306b\u8d85\u3048\u308b\u5834\u5408\u306f+1\n #0\u304b\u3089L-1\u306b\u53cd\u6642\u8a08\u56de\u308a\u306b\u8d85\u3048\u308b\u5834\u5408\u306f-1\n count = 0\n for i in range(N):\n x,w = map(int, readline().split())\n if w==1:\n count += (x+T)//L\n position.append((x+T)%L)\n else:\n if x-T<0:\n count += (x-T)//L\n position.append((x-T)%L)\n position.sort()\n count %= N\n ans = position[count:] + position[:count]\n for i in range(N):\n print(ans[i])\n\n\nif __name__ == '__main__':\n main()", "neg": "import sys\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\ndef main():\n N, L, T = map(int, readline().split())\n position = []\n #0\u3092L-1\u304b\u3089\u30fc\u306b\u6642\u8a08\u56de\u308a\u306b\u8d85\u3048\u308b\u5834\u5408\u306f+1\n #0\u304b\u3089L-1\u306b\u53cd\u6642\u8a08\u56de\u308a\u306b\u8d85\u3048\u308b\u5834\u5408\u306f-1\n count = 0\n for i in range(N):\n x,w = map(int, readline().split())\n if w==1:\n count += (x+T)//L\n position.append((x+T)%L)\n else:\n if x-T<0:\n count += (x-T+1)//L\n position.append((x-T)%L)\n position.sort()\n if count>=0:\n ans = position[count:] + position[:count]\n print(ans)\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9863013698630136, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [330, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u075595666", "n_user": "u146346223", "pos": "n,l,t = map(int,input().split())\nc = []\ns = 0\nfor i in range(n):\n x,w = map(int,input().split())\n if w == 1:\n c.append((x+t)%l)\n s += (x+t)//l\n else:\n c.append((x-t)%l)\n s += (x-t)//l\n \nc.sort()\ns %= n\nc = c[s:] + c[:s]\nprint(*[i for i in c], sep='\\n')", "neg": "n, l, t = map(int,input().split())\n\nc = []\ns = 0\n\nfor i in range(n):\n x, w = map(int,input().split())\n if w == 1:\n c.append((x+t)%l)\n s += (x+t)//l\n else: # w == 2:\n c.append((x-t)%l)\n s += (x-t)//l\n\nc.sort()\ns %= n\nc = c[s:] + c[:s]\nprint(c)\n\nprint([i for i in c], sep='\\n')", "jacc_sim": 0.925, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [141, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u095021077", "n_user": "u095021077", "pos": "N, L, T=map(int, input().split())\nXW=[list(map(int, input().split())) for _ in range(N)]\nX_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]\nX_.sort()\nA0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L\nP0_=X_.index(A0_)\nif P0_>0:\n X_=X_[P0_:]+X_[:P0_]\n \nif XW[0][1]==1:\n C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)\nelse:\n C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)\n \nif N>1 and X_[0]==X_[1] and XW[0][1]==1:\n C0_=round((C0_-1)%N)\n\nif C0_>0:\n X_=X_[N-C0_:]+X_[:N-C0_]\n\nprint(*X_, sep='\\n')", "neg": "N, L, T=map(int, input().split())\nXW=[list(map(int, input().split())) for _ in range(N)]\nX_=[(XW[i][0]+T)%L if XW[i][1]==1 else (XW[i][0]-T)%L for i in range(N)]\nX_.sort()\nA0_=(XW[0][0]+T)%L if XW[0][1]==1 else (XW[0][0]-T)%L\nP0_=X_.index(A0_)\nif P0_>0:\n X_=X_[P0_:]+X_[:P0_]\n \nif XW[0][1]==1:\n C0_=round(sum([(T-(XW[i][0]-XW[0][0])/2)//(L/2)+1 if XW[i][1]!=1 and (XW[i][0]-XW[0][0])/2<=T else 0 for i in range(1, N)])%N)\nelse:\n C0_=round(N-sum([(T-(XW[0][0]+L-XW[i][0])/2)//(L/2)+1 if XW[i][1]!=2 and (XW[0][0]+L-XW[i][0])/2<=T else 0 for i in range(1, N)])%N)\n \nif X_[0]==X_[1] and XW[0][1]==1:\n C0_=round((C0_-1)%N)\n'''\nif C0_>0:\n X_=X_[N-C0_:]+X_[:N-C0_]\n'''\nprint(*X_, sep='\\n')", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [456, 454], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u747220349", "n_user": "u747220349", "pos": "n,l,t=map(int,input().split())\ninf=[]\ns=0\nfor _ in range(n):\n x,y=map(int,input().split())\n if y==1:\n x+=t\n else:\n x-=t\n inf.append(x%l)\n s+=x//l\ninf.sort()\nfor i in range(n):\n print(inf[(i+s)%n])", "neg": "n,l,t=map(int,input().split())\ninf=[]\ns=0\nfor _ in range(n)\nx,y=map(int,input().split())\n if y==1:\n x+=t\n else:\n x-=t\n inf.append(x%l)\n s+=x//l\ninf.sort()\ns%n\nfor i in range(n):\n print(inf[(i+p)%n])", "jacc_sim": 0.9722222222222222, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [112, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u219157465", "n_user": "u219157465", "pos": "from collections import deque\n\nn, l, t = map(int, input().split())\nants = [list(map(int, input().split())) for i in range(n)]\n# print(ants)\n\nants_t = []\ncount = 0\nfor ant in ants:\n ant_t = ant\n if ant[1] == 1:\n c, ant_t[0] = divmod(t + ant[0], l)\n # count += c\n else:\n c, ant_t[0] = divmod(-t + ant[0], l)\n # count -= c\n ants_t.append(ant_t)\n count += c\n# print(ants_t, count)\nants_d = deque(sorted(ants_t))\n# print(ants_d)\n\n# if ants_d[0][1] == 1:\n# ants_d.rotate(count)\n# else:\n# ants_d.rotate(-count)\nants_d.rotate(-count)\n# print(ants_d)\nfor ant in ants_d:\n print( (ant[0]) % l )\n", "neg": "from collections import deque\n\nn, l, t = map(int, input().split())\nants = [list(map(int, input().split())) for i in range(n)]\n\nants_t = [0]*n\ncount = 0\nfor i in range(n):\n ant = ants[i]\n if ant[1] == 1:\n c, ant_t = divmod(t + ant[0], l)\n else:\n c, ant_t = divmod(-t + ant[0], l)\n ants_t.append(ant_t)\n count += c\n# print(ants_t, count)\nants_d = deque(sorted(ants_t))\n# print(ants_d)\n\nants_d.rotate(-count)\n# print(ants_d)\nfor ant in ants_d:\n print( (ant) % l )\n", "jacc_sim": 0.9777777777777777, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [273, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u208052792", "n_user": "u208052792", "pos": "N, L, T = map(int, input().split())\nx = [\"\" for i in range(N)]\nw = [\"\" for i in range(N)]\nfor i in range(N):\n x[i], w[i] = map(int, input().split())\n\ny = [[i, \"\"] for i in range(N)]\nfor i in range(N):\n y[i][1] = (x[i] + (-1)**(w[i]+1)*T) % L\n\ncount = 0\nfor i in range(N):\n if w[0] < w[i]:\n count += (2 * T + L - x[i] + x[0]) // L\n elif w[0] > w[i]:\n count += (2 * T + x[i] - x[0]) // L\n\nif w[0] == 1:\n num = count % N\nelse:\n num = -count % N\n\nif w[0] == 1:\n y.sort(key=lambda x: (x[1], -x[0]))\nelse:\n y.sort(key=lambda x: (x[1], x[0]))\n\nfor i in range(N):\n if y[i][0] == 0:\n index = i\n break\n\nfor i in range(N):\n print(y[(index-num+i) % N][1])\n", "neg": "N, L, T = map(int, input().split())\nx = [\"\" for i in range(N)]\nw = [\"\" for i in range(N)]\nfor i in range(N):\n x[i], w[i] = map(int, input().split())\n\ny = [[i, \"\"] for i in range(N)]\nfor i in range(N):\n y[i][1] = (x[i] + (-1)**(w[i]+1)*T) % L\n\ncount = 0\nfor i in range(N):\n if w[0] < w[i]:\n count += (2 * T + L - x[i] + x[0]) // L\n elif w[0] > w[i]:\n count += (2 * T + x[i] - x[0]) // L\n\nif w[0] == 1:\n num = count % N\nelse:\n num = -count % N\n\ny.sort(key=lambda x: (x[1], -x[0]))\n\nfor i in range(N):\n if y[i][0] == 0:\n index = i\n break\n\nfor i in range(N):\n print(y[(index-num+i) % N][1])\n", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [337, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u884982181", "n_user": "u884982181", "pos": "n,l,t = map(int,input().split())\nx = [list(map(int,input().split())) for i in range(n)]\nlas = [0]*n\nfor i in range(n):\n las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l\nhan = []\nfor i in range(1,n):\n if x[i][1] != x[0][1]:\n if x[0][1] ==1:\n han.append(x[i][0]-x[0][0])\n else:\n han.append(l-x[i][0]+x[0][0])\nsu = 0\nt*=2\nsu += (len(han))*(t//l)\nt%=l\nfor i in han:\n if t> i:\n su+=1\nif x[0][1] == 2:\n su=(-su)%n\nelse:\n su%=(n)\nii = las[0]\nlas.sort()\nbasyo = las.index(ii)\nfor i in range(basyo+1,n):\n if las[basyo] == las[i]:\n if x[0][1] == 2:\n basyo+=1\n break\nlas.extend(las)\nans = [0]*n\nz = 0\nfor i in range(basyo,basyo+n):\n ans[(su+z)%n] = las[i]\n z += 1\nfor i in ans:\n print(i)", "neg": "n,l,t = map(int,input().split())\nx = [list(map(int,input().split())) for i in range(n)]\nlas = [0]*n\nfor i in range(n):\n las[i] = (x[i][0]+(t if x[i][1]==1 else -t))%l\nhan = []\nfor i in range(1,n):\n if x[i][1] != x[0][1]:\n if x[0][1] ==1:\n han.append(x[i][1]-x[0][0])\n else:\n han.append(l-x[i][0]+x[0][0])\nsu = 0\nt*=2\nsu += len(han)*(t//l)\nt%=l\nfor i in han:\n if t> i:\n su+=1\nsu%=(n)\nii = las[0]\nlas.sort()\nbasyo = las.index(ii)\nfor i in range(basyo,n):\n if las[basyo] == las[i]:\n basyo+=1\n break\nlas.extend(las)\nans = [0]*n\nz = 0\nfor i in range(basyo,basyo+n):\n ans[(su+z)%n] = las[i]\n z += 1\nfor i in ans:\n print(i)", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [389, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u582577761", "n_user": "u941407962", "pos": "n,l,t=map(int,input().split())\na,cs=[0]*n,0\nfor i in range(n):\n\tx,y=map(int,input().split())\n\tx+=(t if y==1 else -t)\n\tcs=(cs+x//l)%n\n\tx%=l\n\tif x<0:\n\t\tx+=l\n\t\tcs-=1\n\ta[i]=x\na.sort()\nprint('\\n'.join([str(a[(i+cs+n)%n]) for i in range(n)]))", "neg": "n,l,t=map(int,input().split())\na,cs=[0]*n,0\nfor i in range(n):\n\tx,y=map(int,input().split())\n\tx+=(t if y==1 else -t)\n\tcs=(cs+x//l)%n\n\tx%=l\n\ta[i]=x\na.sort()\nprint('\\n'.join([str(a[(i+cs)%n]) fori in range(n)]))\n", "jacc_sim": 0.95, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [142, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u692632484", "n_user": "u975024434", "pos": "import math\ntemp=input().split()\nN=int(temp[0])\nL=int(temp[1])\nT=int(temp[2])\nXW=[[int(j) for j in input().split()] for i in range(N)]\ncount=0\nfor i in range(N):\n\tif XW[i][1]==1:\n\t\tXW[i][0]+=T\n\telse:\n\t\tXW[i][0]-=T\n\tcount+=math.floor(XW[i][0]/L)\nnewX=[]\nfor i in range(N):\n\tnewX.append(XW[i][0]%L)\nnewX.sort()\n#print(newX)\nfor i in range(N):\n\tprint(newX[(i+count)%N]%L)", "neg": "import math\ntemp=input().split()\nN=int(temp[0])\nL=int(temp[1])\nT=int(temp[2])\nXW=[[int(j) for j in input().split()] for i in range(N)]\ncount=0\nfor i in range(N):\n\tif XW[i][1]==1:\n\t\tXW[i][0]+=T\n\telse:\n\t\tXW[i][0]-=T\n\t# count+=math.floor(XW[i][0]/L)\n\nif XW[0][1]==1:\n\tfor i in range(1,N):\n\t\tif XW[i][0]XW[0][0]:\n\t\t\tcount+=int((XW[i][0]-XW[0][0])/L)+1\n\n#print(count)\n#print(len())\nnewX=[]\nfor i in range(N):\n\tnewX.append(XW[i][0]%L)\nnewX.sort()\n#print(newX)\nfor i in range(N):\n\tprint(newX[(i+count)%N]%L)\n", "jacc_sim": 0.9069767441860465, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [202, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u602860891", "n_user": "u602860891", "pos": "N, L, T = list(map(int, input().split()))\n\nX = []\nW = []\nX_after = []\nfor _ in range(N):\n x, w = list(map(int, input().split()))\n if w == 1:\n x_a = (x + T) % L\n else:\n x_a = (x - T) % L\n x_a = x_a if x_a >= 0 else L + x_a\n X.append(x)\n W.append(w)\n X_after.append(x_a)\n\nn_colide = 0\nfor i in range(1, N):\n if W[0] == 1 and W[i] == 2:\n dist = X[i] - X[0]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n elif W[0] == 2 and W[i] == 1:\n dist = (L + X[0]) - X[i]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n\nif W[0] == 1:\n num_a0 = n_colide % N\nelse:\n num_a0 = N - (n_colide % N)\n\nnum_a0 = int(num_a0)\n\nx_a0 = X_after[0]\nX_after = sorted(X_after)\ni = X_after.index(x_a0)\nif W[0] == 1 and X_after.count(x_a0) == 2:\n i += 1\nX_after = X_after[i-num_a0:] + X_after[:i-num_a0]\n\nfor x_a in X_after:\n print(x_a)\n", "neg": "N, L, T = list(map(int, input().split()))\n\nX = []\nW = []\nX_after = []\nfor _ in range(N):\n x, w = list(map(int, input().split()))\n if w == 1:\n x_a = (x + T) % L\n else:\n x_a = (x - T) % L\n x_a = x_a if x_a >= 0 else L + x_a\n X.append(x)\n W.append(w)\n X_after.append(x_a)\n\nn_colide = 0\nfor i in range(1, N):\n if W[0] == 1 and W[i] == 2:\n dist = X[i] - X[0]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n elif W[0] == 2 and W[i] == 1:\n dist = (L + X[0]) - X[i]\n n_colide += 2 * (T - (dist / 2)) // L + 1\n\nif W[0] == 1:\n num_a0 = n_colide % N\nelse:\n num_a0 = N - (n_colide % N)\n\nnum_a0 = int(num_a0)\n\nx_a0 = X_after[0]\nX_after = sorted(X_after)\ni = X_after.index(x_a0)\nif X_after.count(x_a0) == 2:\n i += 1\nX_after = X_after[i-num_a0:] + X_after[:i-num_a0]\n\nfor x_a in X_after:\n print(x_a)\n", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [437, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u854685751", "n_user": "u854685751", "pos": "N, L, T = list(map(int, input().split(\" \")))\n\n# N,L,T = 3,10,6\n# a = [1,2,3]\n# b = [2,1,1]\n\na = []\nb = []\nfor i in range(N):\n an, ve = map(int, input().split(\" \"))\n a.append(an)\n b.append(ve)\n\ncrash = 0\n\nfor i in range(1, N):\n if b[0] != b[i]:\n if b[0] == 1:\n crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1\n else:\n crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1\n\nfor i in range(N):\n if b[i] == 1:\n a[i] += T\n else:\n a[i] -= T\n a[i] %= L\n\n\nif b[0] == 1:\n where = int(crash) % N\nelse:\n where = int(-crash) % N\n\nnowplace = a[0]\n\na.sort()\n\nif b[0] == 1:\n\twhere0 = max([i for i in range(N) if a[i] == nowplace])\nelse:\n\twhere0 = min([i for i in range(N) if a[i] == nowplace])\n\nwhere0 = (where0 - where) % N\n\nres = a[where0:] + a[:where0]\nres = map(str, res)\n\nfor i in res:\n print(i)\n", "neg": "N, L, T = list(map(int, input().split(\" \")))\n\n# N,L,T = 3,10,6\n# a = [1,2,3]\n# b = [2,1,1]\n\na = []\nb = []\nfor i in range(N):\n an, ve = map(int, input().split(\" \"))\n a.append(an)\n b.append(ve)\n\ncrash = 0\n\nfor i in range(1, N):\n if b[0] != b[i]:\n if b[0] == 1:\n crash += (T - ((a[i] - a[0]) / 2)) // (L / 2) + 1\n else:\n crash += (T - (L - (a[i] - a[0])) / 2) // (L / 2) + 1\n\nfor i in range(N):\n if b[i] == 1:\n a[i] += T\n else:\n a[i] -= T\n a[i] %= L\n\n\nif b[0] == 1:\n where = int(crash) % N\nelse:\n where = int(-crash) % N\n\nnowplace = a[where]\na.sort()\n\nif b[0] == 1:\n\tif crash % 2 == 1:\n\t\twhere0 = min([i for i in range(N) if a[i] == nowplace])\n\telse:\n\t\twhere0 = max([i for i in range(N) if a[i] == nowplace])\t\t\nelse:\n\tif crash % 2 == 1:\n\t\twhere0 = max([i for i in range(N) if a[i] == nowplace])\n\telse:\n\t\twhere0 = min([i for i in range(N) if a[i] == nowplace])\n\nwhere0 = (where0 - crash) % N\n\nres = a[where0:] + a[:where0]\nres = map(str, res)\n\nfor i in res:\n print(i)\n", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [415, 493], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u104282757", "n_user": "u104282757", "pos": "# C\nN, L, T = map(int, input().split())\nX = list()\nW = list()\npositions = list()\nfor _ in range(N):\n x, w = map(int, input().split())\n X.append(x)\n W.append(w)\n if w == 1:\n positions.append((x + T) % L)\n else:\n positions.append((x - T) % L)\n\n# find which is the position\ncnt_conf = 0\nif W[0] == 1:\n for i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[i] - X[0])) // L + 1\n n0 = cnt_conf % N\n p0 = (X[0] + T) % L\nelse:\n for i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[0] + L - X[i])) // L + 1\n n0 = -cnt_conf % N\n p0 = (X[0] - T) % L\n\npositions.sort()\n\n# find index\nif W[0] == 1:\n num = max([n for n in range(N) if positions[n]==p0])\nelse:\n num = min([n for n in range(N) if positions[n]==p0])\n\nfor i in range(N):\n print(positions[(num - n0 + i) % N])", "neg": "# C\nimport numpy as np\nN, L, T = map(int, input().split())\nX = list()\nW = list()\npositions = list()\nfor _ in range(N):\n x, w = map(int, input().split())\n X.append(x)\n W.append(w)\n if w == 1:\n positions.append((x + T) % L)\n else:\n positions.append((x - T) % L)\n\n# find which is the position\ncnt_conf = 0\nfor i in range(N):\n if W[i] != W[0]:\n cnt_conf += (2*T - (X[i] - X[0])) // L + 1\nn0 = cnt_conf % N\nif W[0] == 1:\n p0 = (X[0] + T) % L\nelse:\n p0 = (X[0] - T) % L\n\npositions.sort()\n\n# find index\nif W[0] == 1:\n num = min([n for n in range(N) if positions[n]==p0])\nelse:\n num = max([n for n in range(N) if positions[n]==p0])\n\nfor i in range(N):\n print(positions[(num - n0 + i) % N])", "jacc_sim": 0.9322033898305084, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [373, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03747", "p_user": "u692632484", "n_user": "u692632484", "pos": "import math\ntemp=input().split()\nN=int(temp[0])\nL=int(temp[1])\nT=int(temp[2])\nXW=[[int(j) for j in input().split()] for i in range(N)]\ncount=0\nfor i in range(N):\n\tif XW[i][1]==1:\n\t\tXW[i][0]+=T\n\telse:\n\t\tXW[i][0]-=T\n\tcount+=math.floor(XW[i][0]/L)\n\"\"\"\nif XW[0][1]==1:\n\tfor i in range(1,N):\n\t\tif XW[i][0]XW[0][0]:\n\t\t\tcount+=int((XW[i][0]-XW[0][0])/L)+1\n\"\"\"\n#print(count)\n#print(len())\nnewX=[]\nfor i in range(N):\n\tnewX.append(XW[i][0]%L)\nnewX.sort()\n#print(newX)\nfor i in range(N):\n\tprint(newX[(i+count)%N]%L)", "neg": "import math\ntemp=input().split()\nN=int(temp[0])\nL=int(temp[1])\nT=int(temp[2])\nXW=[[int(j) for j in input().split()] for i in range(N)]\ncount=0\nfor i in range(N):\n\tif XW[i][1]==1:\n\t\tXW[i][0]+=T\n\telse:\n\t\tXW[i][0]-=T\n\tcount+=math.floor(XW[i][0]/L)\n\"\"\"\nif XW[0][1]==1:\n\tfor i in range(1,N):\n\t\tif XW[i][0]XW[0][0]:\n\t\t\tcount+=int((XW[i][0]-XW[0][0])/L)+1\n\"\"\"\n#print(count)\n#print(len())\nnewX=[]\nfor i in range(N):\n\tnewX.append(XW[i][0]%L)\nnewX.sort()\nprint(newX)\nfor i in range(N):\n\tprint(newX[(i+count)%N]%L)", "jacc_sim": 1.0, "nl": "You are given a circle with a circumference of L. Each point on the circumference has a coordinate value representing the arc length from a reference point clockwise. There are N ants on the circumference, numbered 1 through N in increasing coordinate order. Each ant starts walking in a given direction and may change direction if it collides with another ant. Find the position of each ant after T seconds. Constraints: N (number of ants) \u2264 10^5, L (circumference length) \u2264 10^9, T (time) \u2264 10^9, 0 \u2264 X1 < X2 < ... < XN \u2264 L - 1, 1 \u2264 Wi (direction) \u2264 2. Input format: N L T, followed by N lines of X and W values. Output: N lines containing the final coordinates of each ant after T seconds. Example input and output are provided.", "before_after_length": [347, 346], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03751", "p_user": "u535125086", "n_user": "u535125086", "pos": "n = int(input())\ns_list = list()\nfor i in range(n):\n s_list.append(input())\nt = input()\n\ns_list_a = [s.replace(\"?\",\"a\") for s in s_list]\ns_list_a.append(t)\ns_list_a.sort()\nindex_a = [i+1 for i,x in enumerate(s_list_a) if x == t]\n\ns_list_z = [s.replace(\"?\",\"z\") for s in s_list]\ns_list_z.append(t)\ns_list_z.sort()\nindex_z = [i+1 for i,x in enumerate(s_list_z) if x == t]\n\nindexes = [str(i) for i in range(index_z[0],index_a[-1]+1)]\n\nanswer = ' '.join(indexes)\n\nprint(answer)", "neg": "n = int(input())\ns_list = list()\nfor i in range(n):\n s_list.append(input())\nt = input()\n\ns_list_a = [s.replace(\"?\",\"a\") for s in s_list]\ns_list_a.append(t)\ns_list_a.sort()\nindex_a = [i+1 for i,x in enumerate(s_list_a) if x == t]\n\ns_list_z = [s.replace(\"?\",\"z\") for s in s_list]\ns_list_z.append(t)\ns_list_z.sort()\nindex_z = [i+1 for i,x in enumerate(s_list_z) if x == t]\n\nindexes = [i for i in range(index_z[0],index_a[-1]+1)]\n\nprint(indexes)", "jacc_sim": 0.9285714285714286, "nl": "Max Score: 250 Points\nProblem Statement:\nMr.X, whose handle name is T, looked at a list containing N handle names, S_1, S_2, ..., S_N. However, some parts of the list are invisible and denoted by \"?\". Calculate all possible indices of Mr.X's handle name when sorting N+1 handle names (S_1, S_2, ..., S_N, and T) in lexicographical order. Note: If there are people with the same handle name, either one may come first.\nInput:\nThe input is given from standard input in the following format:\nN\nS_1\nS_2\n...\nS_N\nT\nOutput:\nCalculate the possible indices and print them in sorted order. The output should be separated by a space. Put a line break at the end.\nConstraints:\n1 \u2264 N \u2264 10000\n1 \u2264 |S_i|, |T| \u2264 20 (|A| is the length of A.)\nS_i consists of lowercase alphabets and \"?\".\nT consists of lowercase alphabets.\nScoring:\nSubtask 1 [130 points]: No \"?\"s.\nSubtask 2 [120 points]: No additional constraints.\nSample Input 1:\n2\ntourist\npetr\ne\nSample Output 1:\n1\nThere are no invisible parts, so there is only one possibility. The sorted handle names are \"e\", \"petr\", \"tourist\", so \"e\" comes first.\nSample Input 2:\n2\n?o?r?s?\n?et?\ne", "before_after_length": [222, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u771383254", "n_user": "u771383254", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\nans = float('inf')\nfor bit in range(1<<(n-1)):\n cand = [0]*(n-1)\n for i in range(n-1):\n if bit & 1<>j & 1 for j in range(n)]) :\n continue\n kijun = a[0]\n cost = 0\n for j in range(1,n):\n if ((i>>j) & 1) :\n if a[j] <= kijun :\n cost += (kijun + 1 - a[j])\n kijun = kijun + 1\n else :\n kijun = a[j]\n else :\n kijun = max(kijun,a[j])\n ans = min(ans,cost)\nprint(ans)\n", "neg": "n,k = map(int,input().split())\na = list(map(int,input().split()))\n# \u5c0f\u8ab2\u984c\uff11\n# cost = 0\n# for i in range(1,n):\n# if a[i] < a[i-1] + 1 :\n# cost += a[i-1] + 1 - a[i]\n# a[i] = a[i-1] + 1\n# print(cost)\n\nans = 10**100\nfor i in range(1,2**n,2):\n if k != sum([ i>>j & 1 for j in range(n)]) :\n continue\n kijun = a[0]\n cost = 0\n for j in range(1,n):\n if ((i>>j) & 1) :\n if a[j] <= kijun :\n cost += (kijun + 1 - a[j])\n kijun = a[j] + cost\n else :\n kijun = a[j]\n ans = min(ans,cost)\nprint(ans)\n", "jacc_sim": 0.9791666666666666, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [286, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u523087093", "n_user": "u523087093", "pos": "import itertools\n\nN, K = map(int, input().split()) # N\u306f\u5efa\u7269\u306e\u6570\u3001K\u8272\u4ee5\u4e0a\u306b\u5857\u308b\nA = list(map(int, input().split()))\nN_index = list(range(1,N))\n\nmin_cost = float('inf')\nfor target_indexes in itertools.combinations(N_index, K-1): # N_index\u304b\u3089K\u500b\u9078\u3076\u65b9\u6cd5\u3092\u5168\u901a\u308a\u8a66\u3059\n cost = 0\n copy_A = A.copy()\n for i in range(1, N):\n if i in target_indexes:\n if copy_A[i] <= max(copy_A[:i]):\n diff = max(copy_A[:i]) - copy_A[i] # \u30bf\u30fc\u30b2\u30c3\u30c8\u306e\u5efa\u7269\u306e\u5834\u5408\u306f\u305d\u308c\u3088\u308a\u5de6\u5074\u306e\u5efa\u7269\u306emax\u3088\u308a1\u3060\u3051\u5927\u304d\u304f\u3059\u308b\n copy_A[i] += diff + 1\n cost += diff + 1\n\n min_cost = min(min_cost, cost)\n\nprint(min_cost)\n", "neg": "import itertools\n\nN, K = map(int, input().split()) # N\u306f\u5efa\u7269\u306e\u6570\u3001K\u8272\u4ee5\u4e0a\u306b\u5857\u308b\nA = list(map(int, input().split()))\nN_index = list(range(1,N))\n\nmin_cost = float('inf')\nfor target_indexes in itertools.combinations(N_index, K): # N_index\u304b\u3089K\u500b\u9078\u3076\u65b9\u6cd5\u3092\u5168\u901a\u308a\u8a66\u3059\n cost = 0\n copy_A = A.copy()\n for i in range(1, N):\n if i in target_indexes:\n diff = max(max(copy_A[:i]) - copy_A[i], 0) # \u30bf\u30fc\u30b2\u30c3\u30c8\u306e\u5efa\u7269\u306e\u5834\u5408\u306f\u305d\u308c\u3088\u308a\u5de6\u5074\u306e\u5efa\u7269\u306emax\u3088\u308a1\u3060\u3051\u5927\u304d\u304f\u3059\u308b\n copy_A[i] += diff + 1\n cost += diff + 1\n\n min_cost = min(min_cost, cost)\n\nprint(min_cost)\n", "jacc_sim": 0.9882352941176471, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [369, 352], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u489691149", "n_user": "u489691149", "pos": "from itertools import combinations\n\nn,k=map(int,input().split())\nlst=list(map(int,input().split()))\n\nwork=lst[0]\nini=[x-work for x in lst]\nini_seen=[0]\nwork=0\nfor i in range(1,n):\n if ini[i]>work:\n work=ini[i]\n ini_seen.append(i)\n\nmn=None\nfor x in combinations(range(n-len(ini_seen)),k-len(ini_seen)):\n sm=0\n work=0\n xtoken=0\n count=1\n for i in range(1,n):\n if i in ini_seen:\n count+=1\n if worksm : mn=sm\nprint(mn)", "neg": "from itertools import combinations\n\nn,k=map(int,input().split())\nlst=list(map(int,input().split()))\n\nwork=lst[0]\nini=[x-work for x in lst]\nini_seen=[0]\nwork=0\nfor i in range(1,n):\n if ini[i]>work:\n work=ini[i]\n ini_seen.append(i)\n\nmn=None\nfor x in combinations(range(n-len(ini_seen)),k-len(ini_seen)):\n sm=0\n work=0\n xtoken=0\n count=1\n for i in range(1,n):\n print(i,work,sm)\n if i in ini_seen:\n count+=1\n if worksm : mn=sm\nprint(mn)\n", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [283, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u404629709", "n_user": "u404629709", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nans=10010010010010010\n\nfor i in range(1<=a[j+1]:\n cost+=prevh+1-a[j+1]\n prevh+=1\n #print(\"cost\",j,cost)\n else:\n prevh=a[j+1]\n else:\n prevh=max(prevh,a[j+1])\n ans=min(ans,cost)\n #print(\"ans\",ans)\nprint(ans)", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nans=10010010010010010\n\nfor i in range(1<=a[j+1]:\n cost+=prevh+1-a[j+1]\n prevh+=1\n print(\"cost\",j,cost)\n else:\n prevh=a[j+1]\n ans=min(ans,cost)\n #print(\"ans\",ans)\nprint(ans)", "jacc_sim": 0.9772727272727273, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [223, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u262801165", "n_user": "u262801165", "pos": "import sys\nimport math\nimport collections\nimport decimal\nimport itertools\nfrom collections import deque\nfrom functools import reduce\nimport heapq\n#n = int(input())\nn, k = map(int, sys.stdin.readline().split())\n#n = input()\na = list(map(int, sys.stdin.readline().split()))\n\nl = list(itertools.combinations(range(n), k))\n\nans = 10 ** 18\nfor i in range(len(l)):\n cost = 0\n m1 = 0\n p = 20\n for j in range(l[i][0]+1):\n if a[j] > m1:\n m1 = a[j]\n p = j\n\n if j == l[i][0]:\n if m1 == a[j]:\n if p != j:\n cost += 1\n else:\n cost += (m1 - a[j] + 1)\n\n \n r = 1\n if len(l[0]) >= 2:\n q = l[i][r]\n else:\n q = 20\n\n m2 = a[l[i][0]] + cost\n\n for j in range(l[i][0]+1, n):\n if j == q:\n if a[j] > m2:\n m2 = a[j]\n else:\n m2 += 1\n cost += (m2 - a[j])\n\n if r != len(l[0])-1:\n r += 1\n q = l[i][r]\n \n else:\n if a[j] > m2:\n cost += a[j] - m2\n m2 = a[j]\n \n\n if cost < ans:\n ans = cost\n\n\nprint(ans)\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "neg": "import sys\nimport math\nimport collections\nimport decimal\nimport itertools\nfrom collections import deque\nfrom functools import reduce\nimport heapq\n#n = int(input())\nn, k = map(int, sys.stdin.readline().split())\n#n = input()\na = list(map(int, sys.stdin.readline().split()))\n\nl = list(itertools.combinations(range(n), k))\nprint(a)\nprint(l)\n\nans = 10 ** 18\nfor i in range(len(l)):\n cost = 0\n m1 = 0\n p = 20\n for j in range(l[i][0]+1):\n if a[j] > m1:\n m1 = a[j]\n p = j\n\n if j == l[i][0]:\n if m1 == a[j]:\n if p != j:\n cost += 1\n else:\n cost += (m1 - a[j] + 1)\n\n \n r = 1\n if len(l[0]) >= 2:\n q = l[i][r]\n else:\n q = 20\n\n m2 = a[l[i][0]] + cost\n\n for j in range(l[i][0]+1, n):\n if j == q:\n if a[j] > m2:\n m2 = a[j]\n else:\n m2 += 1\n cost += (m2 - a[j])\n\n if r != len(l[0])-1:\n r += 1\n q = l[i][r]\n \n else:\n if a[j] > m2:\n cost += a[j] - m2\n m2 = a[j]\n \n\n if cost < ans:\n ans = cost\n\n\nprint(ans)\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [458, 468], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u459419927", "n_user": "u459419927", "pos": "N, K = list(map(int, input().split()))\nheight = list(map(int, input().split()))\nheight2=height.copy()\nans = 10 ** 10\nif N==K:\n cost=0\n for i in range(1,N):\n tarou=max(height2[:i])\n if tarou>=height2[i]:\n cost+=tarou-height2[i]+1\n height2[i]=tarou+1\n print(cost)\n exit()\nfor i in range(2 ** N):\n cost = 0\n height2 = height.copy()\n if bin(i).count(\"1\")==K:\n for j in range(1,N):\n if i >> j & 1:\n if N==K:\n if height2[j-1]>=height2[j]:\n cost+=height2[j-1]-height2[j]+1\n height2[j]+=height2[j-1]-height2[j]+1\n else:\n tarou=max(height2[:j])\n if height2[j]<=tarou:\n cost+=tarou-height2[j]+1\n height2[j]=tarou+1\n\n if ans > cost:\n ans = cost\n\nprint(ans)", "neg": "N, K = list(map(int, input().split()))\nheight = list(map(int, input().split()))\nheight2=height.copy()\nans = 10 ** 10\n# if N==K:\n# cost=0\n# for i in range(1,N):\n# if height2[i-1]>=height2[i]:\n# cost+=height2[i-1]-height2[i]+1\n# height2[i]+=height2[i-1]-height2[i]+1\n# print(cost)\nfor i in range(2 ** N):\n count=1\n cost = 0\n height2 = height.copy()\n if bin(i).count(\"1\")>=K:\n for j in range(N):\n if i >> j & 1:\n if j!=0:\n tarou=max(height2[:j])\n if height2[j]<=tarou:\n cost+=tarou-height2[j]+1\n height2[j]+=tarou-height2[j]+1\n\n if ans > cost\n ans = cost\n\nprint(ans)", "jacc_sim": 0.9130434782608695, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [322, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u847923740", "n_user": "u847923740", "pos": "# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b\n\nfrom itertools import combinations\n\nN,K=map(int,input().split())\na=list(map(int,input().split()))\n\nminc=10**12\nai=[i for i in range(N)]\nfor i in combinations(ai,K):\n ac=a[:]\n cost=0\n i=list(i)\n for j in range(1,K):\n costt=max(max(ac[:i[j]])-ac[i[j]]+1,0)\n ac[i[j]]+=costt\n cost+=costt\n minc=min(cost,minc)\nprint(minc)", "neg": "# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b\n\nfrom itertools import combinations\n\nN,K=map(int,input().split())\na=list(map(int,input().split()))\n\nminc=10**12\nfor i in combinations(a,K):\n cost=0\n for j in range(1,K):\n costt=max(i[j-1]-i[j]+1,0)\n i[j]+=costt\n cost+=costt\n minc=min(cost,minc)\n\nprint(minc)\n", "jacc_sim": 0.96, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [185, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u151785909", "n_user": "u151785909", "pos": "n , k = map(int, input().split())\nx = list(map(int,input().split()))\nb = [list(map(int,bin(x)[2:].zfill(n))) for x in range(2**n)]\nh = [0]*n\n\ndef check(li,n,k):\n c=1\n hi=li[0]\n for i in range(1,n):\n if li[i]>hi:\n c+=1\n hi=li[i]\n if c>=k:\n return True\n else:\n return False\n\nfor i in range(1,n):\n h[i]=max(h[i-1],x[i-1])\n\nmi = float('inf')\nfor bit in b:\n ans = 0\n s1=0\n x2=x.copy()\n if bit[0]==1:\n for i in range(n):\n if bit[i]==1:\n s2=x[i]\n if s2<=s1:\n ans+=s1-s2+1\n s2=s1+1\n if s2<=h[i]:\n ans += h[i]-s2+1\n s2=h[i]+1\n s1=s2\n x2[i]=s2\n else:\n x2[i]=x[i]\n if check(x2,n,k):\n mi=min(mi,ans)\n\nprint(mi)\n", "neg": "n , k = map(int, input().split())\nx = list(map(int,input().split()))\nb = [list(map(int,bin(x)[2:].zfill(n))) for x in range(2**n)]\nh = [0]*n\n\ndef check(li,n,k):\n c=1\n hi=li[0]\n for i in range(1,n):\n if li[i]>hi:\n c+=1\n hi=li[i]\n if c>=k:\n return True\n else:\n return False\n\nfor i in range(1,n):\n h[i]=max(h[i-1],x[i-1])\n\nmi = float('inf')\nfor bit in b:\n ans = 0\n s1=0\n x2=x.copy()\n if bit[0]==1:\n for i in range(n):\n if bit[i]==1:\n s2=x[i]\n if s2<=s1:\n ans+=s1-s2+1\n s2=s1+1\n if s2<=h[i]:\n ans += h[i]-s2+1\n s2=h[i]+1\n s1=s2\n x2[i]=s2\n else:\n x2[i]=x[i]\n if check(x2,n,k):\n mi=min(mi,ans)\n print(x2,ans)\n\nprint(mi)\n", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [374, 383], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u920103253", "n_user": "u920103253", "pos": "def n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\n\nn,k=n1()\na=n1()\n\nimport itertools\nite=itertools.combinations(range(n),k)\n\nans=10**20\nfor line in ite:\n c=0\n b=a.copy()\n for i in range(1,k):\n if b[line[i]]<=b[line[i-1]]:\n plus=b[line[i-1]]-b[line[i]]+1\n b[line[i]]+=plus\n c+=plus\n ok=1\n for i in range(1,n):\n if b[i-1]=k:\n ans=min(ans,c)\nprint(ans)", "neg": "def n0():return int(input())\ndef n1():return [int(x) for x in input().split()]\ndef n2(n):return [int(input()) for _ in range(n)]\ndef n3(n):return [[int(x) for x in input().split()] for _ in range(n)]\n\nn,k=n1()\na=n1()\n\nimport itertools\nite=itertools.combinations(range(n),k)\n\nans=10**20\nfor line in ite:\n c=0\n b=a.copy()\n for i in range(1,k):\n if b[line[i]]<=b[line[i-1]]:\n plus=b[line[i-1]]-b[line[i]]+1\n b[line[i]]+=plus\n c+=plus\n ok=1\n for i in range(n):\n if b[i-1]=3:\n ans=min(ans,c)\nprint(ans)", "jacc_sim": 0.9803921568627451, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [283, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u135454978", "n_user": "u135454978", "pos": "# Square869120Contest #4 B - Buildings are Colorful!\u3000\n# \u5168\u63a2\u63a2\u7d22\u3000ver\n\nimport sys\n\nN, K = map(int, sys.stdin.readline().strip().split())\na = list(map(int, sys.stdin.readline().strip().split()))\n\nans = float('inf')\nfor i in range(2 ** (N - 1)):\n bit = [(i >> j) & 1 for j in range(N - 1)] # \u5de6\u304b\u30892\u756a\u76ee\u4ee5\u964d\u3067\u898b\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u30d3\u30eb\u3092\u9078\u629e\n\n can_see = 0\n cost = 0\n height = a[0]\n for j, b in enumerate(bit):\n if (b == 1) & (height >= a[j + 1]):\n cost += height - a[j + 1] + 1\n height = height + 1\n can_see += 1\n elif (b == 1) & (height < a[j + 1]):\n height = a[j + 1]\n can_see += 1\n elif height < a[j + 1]:\n can_see += 1\n height = a[j + 1]\n\n if can_see >= K - 1:\n ans = min(ans, cost)\n\nprint(ans)\n\n\n\n\n\n", "neg": "# Square869120Contest #4 B - Buildings are Colorful!\u3000\n# \u5168\u63a2\u63a2\u7d22\u3000ver\n\nimport sys\n\nN, K = map(int, sys.stdin.readline().strip().split())\na = list(map(int, sys.stdin.readline().strip().split()))\n\nans = float('inf')\nfor i in range(2 ** (N - 1)):\n bit = [(i >> j) & 1 for j in range(N - 1)] # \u5de6\u304b\u30892\u756a\u76ee\u4ee5\u964d\u3067\u898b\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u30d3\u30eb\u3092\u9078\u629e\n \n can_see = 0 \n cost = 0\n height = a[0]\n for j, b in enumerate(bit):\n if (b == 1) & (height >= a[j+1]):\n cost += height - a[j + 1] + 1\n height = height + 1\n can_see += 1\n elif b == 1:\n height = a[j + 1]\n can_see += 1\n elif height < a[j + 1]:\n can_see += 1\n heigt = max(height, a[j + 1])\n \n if can_see >= K:\n ans = min(ans, cost)\n\nprint(ans)\n\n\n\n\n\n", "jacc_sim": 0.975609756097561, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [372, 367], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u135454978", "n_user": "u135454978", "pos": "# Square869120Contest #4 B - Buildings are Colorful!\u3000\n\nimport sys\n\nN, K = map(int, sys.stdin.readline().strip().split())\na = list(map(int, sys.stdin.readline().strip().split()))\n\n\ndef dfs(height=a[0], cost=0, target=K, can_see=1, i=1):\n if can_see >= target:\n # print('height', height)\n # print('can_see', can_see)\n # print('cost', cost)\n return cost\n\n # \u7aef\u307e\u3067\u63a2\u7d22\u3057\u305f\u3068\u304d\n if i == len(a):\n return float('inf')\n\n # \u5efa\u7269 i \u3092\u9078\u3070\u306a\u3044\u5834\u5408\n if height >= a[i]:\n cost1 = dfs(height=height, cost=cost, target=K, can_see=can_see, i=i+1)\n else:\n cost1 = dfs(height=a[i], cost=cost, target=K, can_see=can_see+1, i=i+1)\n # print('cost1', cost1, 'can_see', can_see, 'i', i)\n\n # \u5efa\u7269\u3000i \u3092\u9078\u3093\u3060\u5834\u5408\n cost += max(0, height + 1 - a[i])\n height = max(a[i], height + 1)\n cost2 = dfs(height=height, cost=cost, target=K, can_see=can_see+1, i=i+1)\n # print('cost2', cost2)\n\n return min(cost1, cost2)\n\n\nprint(dfs(a[0], cost=0, target=K, can_see=1, i=1))\n\n", "neg": "# Square869120Contest #4 B - Buildings are Colorful!\u3000\n \nimport sys\n \nN, K = map(int, sys.stdin.readline().strip().split())\na = list(map(int, sys.stdin.readline().strip().split()))\n\nif K == 0:\n break\n \ndef dfs(height=a[0], cost=0, target=K, can_see=1, i=1):\n if can_see >= target:\n # print('height', height)\n # print('can_see', can_see)\n # print('cost', cost)\n return cost\n \n # \u7aef\u307e\u3067\u63a2\u7d22\u3057\u305f\u3068\u304d\n if i == len(a):\n return float('inf')\n \n # \u5efa\u7269 i \u3092\u9078\u3070\u306a\u3044\u5834\u5408\n if height >= a[i]:\n cost1 = dfs(height=height, cost=cost, target=K, can_see=can_see, i=i+1)\n else:\n cost1 = dfs(height=a[i], cost=cost, target=K, can_see=can_see+1, i=i+1)\n # print('cost1', cost1, 'can_see', can_see, 'i', i)\n \n # \u5efa\u7269\u3000i \u3092\u9078\u3093\u3060\u5834\u5408\n cost += max(0, height + 1 - a[i])\n height = max(a[i], height + 1)\n cost2 = dfs(height=height, cost=cost, target=K, can_see=can_see+1, i=i+1)\n # print('cost2', cost2)\n \n return min(cost1, cost2)\n \n \nprint(dfs(a[0], cost=0, target=K, can_see=1, i=1))", "jacc_sim": 0.9863013698630136, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [483, 494], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u785883180", "n_user": "u785883180", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nans=float(\"inf\")\nfor i in range(2**n):\n bit=[(i>>j)&1 for j in range(n)]\n if sum(bit)==k and bit[0]==1:\n cost=0\n kijun=a[0]\n for j in range(1,n):\n if bit[j]==0:\n kijun=max(kijun,a[j])\n elif a[j]>=kijun+1:\n kijun=a[j]\n else:\n cost+=kijun+1-a[j]\n kijun+=1\n ans=min(ans,cost)\nprint(ans)", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nans=float(\"inf\")\nfor i in range(2**n):\n bit=[(i>>j)&1 for j in range(n)]\n if sum(bit)==k and bit[0]:\n cost,kijun=0,a[0]\n for j in range(n):\n if not bit[j]:\n kijun=max(kijun,a[k+1])\n elif a[k+1]>=kijun+1:\n kijun=a[k+1]\n else:\n cost+=kijun+1-a[k+1]\n kijun+=1\n ans=min(ans,cost)\nprint(ans)", "jacc_sim": 0.9777777777777777, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [197, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u670961163", "n_user": "u670961163", "pos": "def main():\n import copy\n n, k = map(int, input().split())\n takasa_lis = list(map(int, input().split()))\n \n ans = 10**200\n \n for i in range(0, 2 ** n, 2):\n test_lis = copy.deepcopy(takasa_lis)\n cnt = 0\n building_cost = 0\n for j in range(1, n):\n if ((i>>j) & 1):\n cnt += 1\n building_cost += max(max(test_lis[0:j]) - test_lis[j] + 1, 0)\n test_lis[j] = max(max(test_lis[0:j])+1, test_lis[j])\n else:\n if test_lis[j] > max(test_lis[0:j]):\n cnt += 1\n if cnt >= k-1 and ans > building_cost:\n ans = building_cost\n \n print(ans)\n\n\n \n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "def main():\n import copy\n n, k = map(int, input().split())\n takasa_lis = list(map(int, input().split()))\n \n ans = 10**200\n \n for i in range(0, 2 ** n, 2):\n test_lis = copy.deepcopy(takasa_lis)\n print(test_lis)\n cnt = 0\n building_cost = 0\n for j in range(1, n):\n if ((i>>j) & 1):\n cnt += 1\n building_cost += max(max(test_lis[0:j]) - test_lis[j] + 1, 0)\n test_lis[j] = max(max(test_lis[0:j])+1, test_lis[j])\n else:\n if test_lis[j] > max(test_lis[0:j]):\n cnt += 1\n print(test_lis,cnt, building_cost)\n if cnt >= k-1 and ans > building_cost:\n ans = building_cost\n \n print(ans)\n\n\n \n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [275, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u579699847", "n_user": "u935685410", "pos": "def LI(): return list(map(int,input().split()))\nN,K = LI()\na = LI()\nans = float('INF')\nfor i in range(2**(N-1)):\n bit = [i>>j&1 for j in range(N-1)]\n if K-1!=sum(bit):\n continue\n temp,kijun = 0,a[0]\n for k in range(N-1):\n if bit[k]==0:\n kijun = max(kijun,a[k+1])\n else:\n if a[k+1]>=kijun+1:\n kijun = a[k+1]\n continue\n temp += (kijun+1)-a[k+1]\n kijun += 1\n ans = min(ans,temp)\nprint(ans)\n", "neg": "def LI(): return list(map(int,input().split()))\nN,K = LI()\na = LI()\nans = float('INF')\nfor i in range(2**(N-1)):\n bit = [i>>j&1 for j in range(N-1)]\n if K-1!=sum(bit):\n continue\n print(\"bit\",bit)\n cost,kijun = 0,a[0]\n for k in range(N-1):\n if bit[k]==0:\n kijun = max(kijun,a[k+1])\n continue\n if a[k+1]>=kijun+1:\n kijun = a[k+1]\n continue\n cost += (kijun+1)-a[k+1]\n kijun += 1\n ans = min(ans,cost)\nprint(ans)", "jacc_sim": 0.9387755102040817, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [211, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u594803920", "n_user": "u594803920", "pos": "n, k = map(int, input().split())\nli = list(map(int, input().split()))\nmin_ = 10**12\nfor i in range(1<>j)&1:\n can_look += 1\n if li[j] <= max_height:\n li_h.append(max_height+1)\n else:\n li_h.append(li[j])\n else:\n li_h.append(li[j])\n if can_look >= k:\n money = sum(li_h) - sum(li)\n min_ = min(min_, money)\n\nprint(min_)", "neg": "n, k = map(int, input().split())\nli = list(map(int, input().split()))\nmin_ = 10**12\nfor i in range(1<>j)&1:\n can_look += 1\n if li[j] <= max_height:\n li_h.append(max_height+1)\n else:\n li_h.append(li[j])\n else:\n li_h.append(li[j])\n if can_look >= k:\n money = sum(li_h) - sum(li)\n min_ = min(min_, money)\n print(li_h)\n print(li)\n \nprint(min_)", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [293, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u638456847", "n_user": "u638456847", "pos": "from itertools import combinations\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N,K,*A = map(int, read().split())\n\n ans = float('inf')\n for pattern in combinations(range(1,N), K-1):\n height = A[0]\n tmp = 0\n for i in range(1,N):\n if i in pattern:\n height += 1\n if A[i] >= height:\n height = A[i]\n continue\n tmp += height - A[i]\n height = max(height, A[i])\n ans = min(ans, tmp)\n \n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "from itertools import combinations\nimport sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ndef main():\n N,K,*A = map(int, read().split())\n\n ans = 10**30\n for pattern in combinations(range(1,N), K-1):\n height = A[0]\n tmp = 0\n print(pattern)\n for i in pattern:\n height += 1\n if A[i] >= height:\n height = A[i]\n continue\n tmp += height - A[i]\n ans = min(ans, tmp)\n \n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9019607843137255, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [197, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u430247423", "n_user": "u430247423", "pos": "# square869120Contest #4\n# B - Buildings are Colorful!\n# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b\nN, K = map(int, input().split())\n*A, = map(int, input().split())\n\nans = float('inf')\nfor bit in range(2**N):\n cnt = 0\n for i in range(N):\n if bit >> i & 1:\n cnt += 1\n if cnt < K:\n continue\n\n cost = 0\n maxh = 0\n for i, a in enumerate(A):\n if bit >> i & 1 and maxh >= a:\n cost += maxh - a + 1\n maxh += 1\n elif maxh < a:\n maxh = a\n\n\n if cost < ans:\n ans = cost\n\n\nprint(ans)\n", "neg": "# square869120Contest #4\n# B - Buildings are Colorful!\n# https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b\nN, K = map(int, input().split())\n*A, = map(int, input().split())\n\nans = float('inf')\nfor bit in range(2**N):\n cnt = 0\n for i in range(N):\n if bit >> i & 1:\n cnt += 1\n if cnt < K:\n continue\n\n cost = 0\n maxh = 0\n for i, a in enumerate(A):\n if maxh < a:\n maxh = a\n if bit >> i & 1 and maxh >= a:\n cost += maxh - a + 1\n maxh += 1\n\n if cost < ans:\n ans = cost\n\nprint(ans)\n", "jacc_sim": 0.9824561403508771, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [217, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u969277466", "n_user": "u969277466", "pos": "n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nans = 1145141919810364364334\nfor i in range(1,2**n):\n ls = [0] * n\n qq = []\n \n for j in range(n):\n if (i >> j) & 1:\n ls[j] = 1\n qq.append(j)\n \n if sum(ls) < k:\n continue\n \n else:\n mt = a[0]\n cost = 0\n for j in range(1,n) :\n if mt < a[j]:\n mt = a[j]\n else:\n if ls[j] == 1:\n cost += mt + 1 - a[j]\n mt += 1\n ans = min(ans,cost)\n \nprint(ans)", "neg": "n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nans = 1145141919810364364334\nfor i in range(2**n):\n ls = [0] * n\n qq = []\n \n for j in range(n):\n if (i >> j) & 1:\n ls[j] = 1\n qq.append(j)\n print(ls,qq)\n \n cost = 0\n if sum(ls) < k or ls[0] == 0:\n continue\n \n else:\n t = []\n for j in qq:\n t.append(a[j])\n \n mt = t[0]\n cost = 0\n for j in range(len(qq) - 1) :\n if t[j+1] <= mt:\n cost += (mt + 1 - t[j+1])\n mt += 1\n else:\n mt = max(mt,t[j+1])\n \n ans = min(ans,cost)\n \nprint(ans)", "jacc_sim": 0.9148936170212766, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [216, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u627325970", "n_user": "u627325970", "pos": "import itertools\nN, K = list(map(int, input().split()))\nA_orig = list(map(int, input().split()))\n\nres = len(A_orig) * max(A_orig)\nfor pattern in itertools.combinations(range(N), K):\n cnt = 0\n A = A_orig[:]\n for p in pattern:\n if p == 0:\n continue\n extension = max(0, max(A[:p]) - A[p] + 1)\n A[p] += extension\n cnt += extension\n res = min(res, cnt)\n \nprint(res)", "neg": "import itertools\nN, K = list(map(int, input().split()))\nA_orig = list(map(int, input().split()))\n \nres = len(A_orig) * max(A_orig)\nfor pattern in itertools.combinations(range(N), K):\n cnt = 0\n A = A_orig[:]\n for p in pattern:\n if p == 0:\n continue\n extension = max(0, max(A[:p]) - A[p] + 1)\n A[p] += extension\n cnt += extension\n res = min(res, cnt)", "jacc_sim": 0.9743589743589743, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [150, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u639064834", "n_user": "u639064834", "pos": "import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\nnl = lambda: list(map(int, stdin.readline().split()))\n\nn, K = na()\na = na()\nans = float('inf')\nfor i in range(2**(n-1)):\n colors = 1\n cost = 0\n tmp = a[0]\n for k in range(n-1):\n if tmp < a[k+1]:\n colors += 1\n tmp = a[k+1]\n continue\n if (i >> k) & 1:\n cost += tmp - a[k+1] + 1\n colors += 1\n tmp += 1\n if colors >= K:\n ans = min(ans, cost)\nprint(ans)\n", "neg": "import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\nnl = lambda: list(map(int, stdin.readline().split()))\n\nn, k = na()\na = na()\nans = float('inf')\nfor i in range(2**(n-1)):\n colors = 1\n cost = 0\n tmp = a[0]\n for k in range(n-1):\n if tmp < a[k+1]:\n colors += 1\n tmp = a[k+1]\n continue\n if (i >> k) & 1:\n cost += tmp - a[k+1] + 1\n colors += 1\n tmp += 1\n if colors >= k:\n ans = min(ans, cost)\nprint(ans)\n", "jacc_sim": 0.9814814814814815, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [225, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u707444776", "n_user": "u707444776", "pos": "def dfs(index):\n global ans\n if index == N:\n if blst.count(1) >= K - 1:\n tmp = a[0]\n anstmp = 0\n for i in range(1, N):\n if blst[i - 1] == 0:\n if tmp < a[i]:\n tmp = a[i]\n continue\n if tmp >= a[i]:\n anstmp += tmp - a[i] + 1\n tmp += 1\n else:\n tmp = a[i]\n ans = min(ans, anstmp)\n return\n for i in range(2):\n blst[index - 1] = i\n dfs(index + 1)\n return\n\nN, K = map(int, input().split())\na = list(map(int, input().split()))\nblst = [0] * (N - 1)\nans = float('inf')\ndfs(1)\n\nprint(ans)\n", "neg": "def dfs(index):\n global ans\n if index == N:\n if blst.count(1) == K - 1:\n tmp = a[0]\n anstmp = 0\n for i in range(1, N):\n if blst[i - 1] == 0:continue\n if tmp >= a[i]:\n anstmp += tmp - a[i] + 1\n tmp += 1\n else:\n tmp = a[i]\n ans = min(ans, anstmp)\n return\n for i in range(2):\n blst[index - 1] = i\n dfs(index + 1)\n return\n\nN, K = map(int, input().split())\na = list(map(int, input().split()))\nblst = [0] * (N - 1)\nans = float('inf')\ndfs(1)\n\nprint(0)", "jacc_sim": 0.9782608695652174, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [236, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u142888713", "n_user": "u142888713", "pos": "\nN,K = map(int,input().split())\na_list = list(map(int,input().split()))\n\n# \u5efa\u7269i\u3092\u30df\u3089\u308c\u308b\u9ad8\u3055\u306b\u3059\u308b\u304b\u3044\u306a\u304b\u306ebit\u63a2\u7d22\n\nans = 100010001000100010001000\n\nfor byte in range(pow(2,N-1)):\n height = a_list[0]\n cost = 0\n if bin(byte).count(\"1\")>=K-1:\n for i in range(N-1):\n if not (byte & 1<=K-1:\n for i in range(N-1):\n if not (byte & 1<>j) & 1:\n cnt += 1\n total += max(m-a[j]+1, 0)\n m = max(m+1, a[j])\n else:\n m = max(m, a[j])\n if cnt == k:\n res = min(res, total)\n print(res)\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n import sys\n #input = sys.stdin.readline\n sys.setrecursionlimit(10000000)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations\n #from itertools import accumulate, product, permutations\n from math import floor, ceil\n import copy\n\n #mod = 1000000007\n\n n,k = map(int, input().split())\n a = list(map(int, input().split()))\n res = 10**17\n for i in range(2**n):\n total, m, cnt = 0, 0, 0\n for j in range(n):\n if(i>>j) & 1:\n cnt += 1\n total += max(m-a[j]+1, 0)\n m = max(m, a[j])\n else:\n m = max(m, a[j])\n if cnt == k:\n res = min(res, total)\n print(res)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [253, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03752", "p_user": "u644907318", "n_user": "u644907318", "pos": "from itertools import combinations\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\ncmin = 10**12\nfor x in combinations(range(1,N),K-1):\n C = A[:]\n B = [0]\n B += x\n B = sorted(B)\n cnt = 0\n for i in range(1,K):\n j0 = B[i-1]\n j1 = B[i]\n h = 0\n for j in range(j0,j1):\n h = max(h,C[j])\n if C[j1]<=h:\n cnt += h+1-C[j1]\n C[j1] = h+1\n cmin = min(cmin,cnt)\nprint(cmin)", "neg": "import ipdb\nfrom itertools import combinations\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\ncmin = 10**12\nfor x in combinations(range(1,N),K-1):\n C = A[:]\n B = [0]\n B += x\n B = sorted(B)\n cnt = 0\n for i in range(1,K):\n j0 = B[i-1]\n j1 = B[i]\n h = 0\n for j in range(j0,j1):\n h = max(h,C[j])\n if C[j1]<=h:\n cnt += h+1-C[j1]\n C[j1] = h+1\n cmin = min(cmin,cnt)\nprint(cmin)", "jacc_sim": 0.9787234042553191, "nl": "There are N buildings along a line, each colored in a unique color and with a specific height. Chokudai, the city mayor, wants to see at least K buildings from the left. The objective is to calculate the minimum cost of increasing the height of the buildings to satisfy this condition. The cost of increasing the height of a building by 1 meter is 1 yen. The height of a building cannot be decreased. The input consists of N, K, and the heights of the buildings. The output should display the minimum cost. Constraints include 1 \u2264 K \u2264 N \u2264 15 and 1 \u2264 ai \u2264 10^9. The problem has different scoring subtasks based on additional constraints. Two sample inputs with their respective optimal solutions are provided.", "before_after_length": [201, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u493520238", "n_user": "u493520238", "pos": "n,m = map(int, input().split())\nxl = list(map(int, input().split()))\nyl = list(map(int, input().split()))\n\nxdl = []\nydl = []\nfor x2,x1 in zip(xl[1:],xl[:-1]):\n xdl.append(x2-x1)\n\nfor y2,y1 in zip(yl[1:],yl[:-1]):\n ydl.append(y2-y1)\n\n\nMOD = 10**9+7\nys = 0\nfor i,d in enumerate(xdl):\n pattern = (i+1)*(n-1-i)\n ys += pattern*d\n ys%=MOD\n\n# print(ys)\nans = 0\n\nfor i,d in enumerate(ydl):\n pattern = (i+1)*(m-1-i)\n ans += pattern*ys*d\n ans%=MOD\n\nprint(ans)", "neg": "n,m = map(int, input().split())\nxl = list(map(int, input().split()))\nyl = list(map(int, input().split()))\n\nxdl = []\nydl = []\nfor x2,x1 in zip(xl[1:],xl[:-1]):\n xdl.append(x2-x1)\n\nfor y2,y1 in zip(yl[1:],yl[:-1]):\n ydl.append(y2-y1)\n\n\nMOD = 10**9+7\nys = 0\nfor i,d in enumerate(xdl):\n pattern = (i+1)*(m-1-i)\n ys += pattern*d\n ys%=MOD\n\nans = 0\n\nfor i,d in enumerate(ydl):\n pattern = (i+1)*(n-1-i)\n ans += pattern*ys*d\n ans%=MOD\n\nprint(ans)", "jacc_sim": 0.9777777777777777, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [237, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u327466606", "n_user": "u327466606", "pos": "from itertools import product,combinations\nMOD = 10**9+7\n\ndef solve(X,Y):\n DX = [a-b for a,b in zip(X[1:],X)]\n DY = [a-b for a,b in zip(Y[1:],Y)]\n a = sum((i+1)*(len(DX)-i)*dx for i,dx in enumerate(DX))\n b = sum((i+1)*(len(DY)-i)*dy for i,dy in enumerate(DY))\n return (a*b)%MOD\n\n\ndef naive(X,Y):\n a = 0\n for (x1,x2),(y1,y2) in product(combinations(X,2), combinations(Y,2)):\n a += (x2-x1)*(y2-y1)\n a %= MOD\n return a\n\nfrom random import randrange\nfrom itertools import accumulate\n\ndef test():\n for _ in range(10000):\n X = list(accumulate([randrange(1,8) for _ in range(3)]))\n Y = list(accumulate([randrange(1,8) for _ in range(2)]))\n a1 = solve(X,Y)\n a2 = naive(X,Y)\n if a1 != a2:\n print(X,Y)\n print(a1)\n print(a2)\n return\n\nif __name__ == '__main__':\n # test()\n N,M = map(int,input().split())\n X = tuple(map(int,input().split()))\n Y = tuple(map(int,input().split()))\n print(solve(X,Y))\n # print(naive(X,Y))", "neg": "from itertools import product,combinations\nMOD = 10**9+7\n\ndef solve(X,Y):\n DX = [a-b for a,b in zip(X[1:],X)]\n DY = [a-b for a,b in zip(Y[1:],Y)]\n a = sum((i+1)*(len(DX)-i)*dx for i,dx in enumerate(DX))\n b = sum((i+1)*(len(DX)-i)*dy for i,dy in enumerate(DY))\n return a*b\n\n\ndef naive(X,Y):\n a = 0\n for (x1,x2),(y1,y2) in product(combinations(X,2), combinations(Y,2)):\n a += (x2-x1)*(y2-y1)\n a %= MOD\n return a\n\nfrom random import randrange\nfrom itertools import accumulate\n\ndef test():\n for _ in range(10000):\n X = list(accumulate(randrange(1,8) for _ in range(4)))\n Y = list(accumulate(randrange(1,8) for _ in range(4)))\n a1 = solve(X,Y)\n a2 = naive(X,Y)\n if a1 != a2:\n print(X,Y)\n print(a1)\n print(a2)\n return\n\nif __name__ == '__main__':\n # test()\n N,M = map(int,input().split())\n X = tuple(map(int,input().split()))\n Y = tuple(map(int,input().split()))\n print(solve(X,Y))\n # print(naive(X,Y))", "jacc_sim": 0.972972972972973, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [425, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u074220993", "n_user": "u074220993", "pos": "n, m = map(int, input().split())\nx = [x for x in map(int, input().split())]\ny = [y for y in map(int, input().split())]\nsum_x = 0\nsum_y = 0\nans = 0\nfor i in range(n):\n sum_x += (2*i - n + 1) * x[i] \nfor j in range(m):\n sum_y += (2*j - m + 1) * y[j]\nans = sum_x * sum_y\nprint(ans%1000000007)", "neg": "n, m = map(int, input().split())\nx = [x for x in map(int, input().split())]\ny = [y for y in map(int, input().split())]\nsum_x = 0\nsum_y = 0\nans = 0\nfor i in range(n):\n sum_x += (2*i - n + 1) * x[i] \nfor j in range(m-1):\n sum_y += (2*j - m + 1) * y[j]\nans = sum_x * sum_y\nprint(ans%1000000007)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [138, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u119148115", "n_user": "u119148115", "pos": "import sys\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #\u7a7a\u767d\u3042\u308a\n\nn,m = MI()\nx,y = LI(),LI()\nmod = 10**9+7\n\nn,m = n-1,m-1\ndx = [x[i+1]-x[i] for i in range(n)]\ndy = [y[i+1]-y[i] for i in range(m)]\n\nif n % 2 == 0:\n rx = [i*(n+1-i) for i in range(1,n//2+1)] + [i*(n+1-i) for i in range(n//2,0,-1)]\nelse:\n rx = [i*(n+1-i) for i in range(1,n//2+2)] + [i*(n+1-i) for i in range(n//2,0,-1)]\nif m % 2 == 0:\n ry = [i*(m+1-i) for i in range(1,m//2+1)] + [i*(m+1-i) for i in range(m//2,0,-1)]\nelse:\n ry = [i*(m+1-i) for i in range(1,m//2+2)] + [i*(m+1-i) for i in range(m//2,0,-1)]\n\na = 0\nfor i,j in zip(dx,rx):\n a += i*j\n a %= mod\nb = 0\nfor i,j in zip(dy,ry):\n b += i*j\n b %= mod\n\nprint((a*b) % mod)\n", "neg": "import sys\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #\u7a7a\u767d\u3042\u308a\n\nn,m = MI()\nx,y = LI(),LI()\nmod = 10**9+7\n\nn,m = n-1,m-1\ndx = [x[i+1]-x[i] for i in range(n)]\ndy = [y[i+1]-y[i] for i in range(m)]\n\nif n % 2 == 0:\n rx = [n+i for i in range(n//2)] + [n+i for i in range(n//2-1,-1,-1)]\nelse:\n rx = [n+i for i in range(n//2)] + [n+(n//2)] + [n+i for i in range(n//2-1,-1,-1)]\nif m % 2 == 0:\n ry = [m+i for i in range(m//2)] + [m+i for i in range(m//2-1,-1,-1)]\nelse:\n ry = [m+i for i in range(m//2)] + [m+(m//2)] + [m+i for i in range(m//2-1,-1,-1)]\n\na = 0\nfor i,j in zip(dx,rx):\n a += i*j\n a %= mod\nb = 0\nfor i,j in zip(dy,ry):\n b += i*j\n b %= mod\n\nprint((a*b) % mod)\n", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [435, 409], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u813174766", "n_user": "u099566485", "pos": "n,m=map(int,input().split())\nMOD=1000000007\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\nsx=0\nsy=0\nfor i in range(1,n):\n sx += (x[i]-x[i-1]) * i * (n-i)\n sx %= MOD\nfor i in range(1,m):\n sy += (y[i]-y[i-1]) * i * (m-i)\n sy %= MOD\nprint(sx*sy%MOD)", "neg": "n,m=map(int,input().split())\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\nsx=0\nsy=0\nfor i in range(n):\n sx+=i*x[i]-(n-i-1)*x[i]\nfor i in range(n):\n sy+=i*y[i]-(n-i-1)*y[i]\nprint(sx*sy)", "jacc_sim": 0.90625, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [141, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u561083515", "n_user": "u561083515", "pos": "# \u89e3\u8aacAC\nN,M = map(int, input().split())\nX = [int(i) for i in input().split()]\nY = [int(i) for i in input().split()]\n\nMOD = 10 ** 9 + 7\n\ndef f(Z):\n ans = 0\n for k,z in enumerate(Z):\n ans = (ans + k * z - (len(Z) - k - 1) * z) % MOD\n return ans\n\nprint(f(X) * f(Y) % MOD)", "neg": "# \u89e3\u8aacAC\nN,M = map(int, input().split())\nX = [int(i) for i in input().split()]\nY = [int(i) for i in input().split()]\n\nMOD = 10 ** 9 + 7\n\ndef f(Z):\n ans = 0\n for k,z in enumerate(Z):\n ans = (ans + k * z - (N - k - 1) * z) % MOD\n return ans\n\nprint(f(X) * f(Y) % MOD)", "jacc_sim": 0.9767441860465116, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [132, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u067983636", "n_user": "u067983636", "pos": "import sys\n\ninput = sys.stdin.readline\n\n\ndef read_values():\n return map(int, input().split())\n\n\ndef read_list():\n return list(read_values())\n\n\ndef func(N, mod):\n F = [1]\n for i in range(1, N + 1):\n F.append(F[-1] * i % mod)\n return F\n\n\nINV = {}\n\n\ndef inv(a, mod):\n if a in INV:\n return INV[a]\n r = pow(a, mod - 2, mod)\n INV[a] = r\n return r\n\n\ndef C(F, a, b, mod):\n return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod\n\n\ndef main():\n mod = 10 ** 9 + 7\n N, M = read_values()\n X = read_list()\n Y = read_list()\n\n res_x = 0\n for i in range(N - 1):\n res_x += (i + 1) * (N - i - 1) * (X[i + 1] - X[i]) % mod\n res_x %= mod\n\n res_y = 0\n for i in range(M - 1):\n res_y += (i + 1) * (M - i - 1) * (Y[i + 1] - Y[i]) % mod\n res_y %= mod\n print(res_x * res_y % mod)\n\n\nif __name__ == \"__main__\":\n main()\n\n", "neg": "import sys\n\ninput = sys.stdin.readline\n\n\ndef read_values():\n return map(int, input().split())\n\n\ndef read_list():\n return list(read_values())\n\n\ndef func(N, mod):\n F = [1]\n for i in range(1, N + 1):\n F.append(F[-1] * i % mod)\n return F\n\n\nINV = {}\n\n\ndef inv(a, mod):\n if a in INV:\n return INV[a]\n r = pow(a, mod - 2, mod)\n INV[a] = r\n return r\n\n\ndef C(F, a, b, mod):\n return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod\n\n\ndef main():\n mod = 10 ** 9 + 7\n N, M = read_values()\n X = read_list()\n Y = read_list()\n\n res_x = 0\n for i in range(N - 1):\n res_x += (i + 1) * (N - i - 1) * (X[i + 1] - X[i]) % mod\n res_x %= mod\n\n res_y = 0\n for i in range(M - 1):\n res_y += (i + 1) * (M - i - 1) * (Y[i + 1] - Y[i]) % mod\n res_y %= mod\n print(res_x, res_y)\n\n print(res_x * res_y % mod)\n\n\nif __name__ == \"__main__\":\n main()\n\n", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [393, 406], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u989345508", "n_user": "u989345508", "pos": "mod=1000000007\nn,m=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\n\nxc=0\nfor i in range(1,n):\n a=x[i]-x[i-1]\n if i<=((n)//2):\n l=i\n else:\n l=n-i\n xc+=a*(l*n-(l*l))\n xc=xc%mod\n\nyc=0\nfor i in range(1,m):\n a=y[i]-y[i-1]\n if i<=((m)//2):\n l=i\n else:\n l=m-i\n yc+=a*(l*m-(l*l))\n yc=yc%mod\nprint((xc*yc)%mod)\n", "neg": "mod=1000000007\nn,m=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\n\nxc=0\nfor i in range(1,n):\n a=x[i]-x[i-1]\n if i<=((n)//2):\n l=i\n else:\n l=n-i\n xc+=a*(l*n-((l*l+l)//2))\n xc=xc%mod\n\nyc=0\nfor i in range(1,m):\n a=y[i]-y[i-1]\n if i<=((m)//2):\n l=i\n else:\n l=m-i\n yc+=a*(l*m-((l*l+l)//2))\n yc=yc%mod\nprint((xc*yc)%mod)\n", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [224, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u373958718", "n_user": "u373958718", "pos": "n,m=map(int,input().split())\nX=list(map(int,input().split()))\nY=list(map(int,input().split()))\nxsum=0;ysum=0;mod=10**9+7\nfor i,x in enumerate(X): xsum+=x*(i-(n-1-i))\nfor i,y in enumerate(Y): ysum+=y*(i-(m-1-i))\nprint(xsum * ysum % mod)", "neg": "n,m=map(int,input().split())\nX=list(map(int,input().split()))\nY=list(map(int,input().split()))\nxsum=0;ysum=0;mod=10**9+7\nfor i,x in enumerate(X): xsum+=x*(i-(n-1-i))\nfor i,y in enumerate(Y): ysum+=y*(i-(m-1-i))\nprint(xsum, ysum)\nprint(xsum * ysum % mod)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [119, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u623687794", "n_user": "u623687794", "pos": "n,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nX=0;Y=0\nmod=10**9+7\nfor i in range(n-1):\n X+=(a[i+1]-a[i])*(i+1)*(n-i-1)\n X%=mod\nfor i in range(m-1):\n Y+=(b[i+1]-b[i])*(i+1)*(m-i-1)\n Y%=mod\nprint((X*Y)%mod)\n", "neg": "n,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nX=0;Y=0\nmod=10**9+7\nfor i in range(n-1):\n X+=(a[i+1]-a[i])*(i+1)*(n-i-1)\n X%=mod\nfor i in range(n-1):\n Y+=(b[i+1]-b[i])*(i+1)*(n-i-1)\n Y%=mod\nprint(X*Y%mod)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [155, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u038815010", "n_user": "u562016607", "pos": "N,M=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\nP=10**9+7\nX=0\nY=0\nfor i in range(1,N+1):\n X+=x[i-1]*(2*i-1-N)\n X=X%P\nfor j in range(1,M+1):\n Y+=y[j-1]*(2*j-1-M)\n Y=Y%P\nprint((X*Y)%P)\n", "neg": "N,M=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\nP=10**9+7\nX=0\nY=0\nfor i in range(1,M+1):\n X+=x[i-1]*(2*i-1-M)\n X=X%P\nfor j in range(1,N+1):\n Y+=y[j-1]*(2*j-1-N)\n Y=Y%P\nprint((X*Y)%P)\n", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [147, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u015993380", "n_user": "u015993380", "pos": "n, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\ny = [int(i) for i in input().split()]\nmod = 1000000007\nxtot = 0\nytot = 0\nfor i in range(n):\n\txtot += (2*i-n+1)*x[i]\n\txtot %= mod\nfor i in range(m):\n\tytot += (2*i-m+1)*y[i]\n\tytot %= mod\nprint(int((xtot*ytot)%mod))", "neg": "n, m = [int(i) for i in input().split()]\nx = [int(i) for i in input().split()]\ny = [int(i) for i in input().split()]\nmod = 1e9+7\nxtot = 0\nytot = 0\nfor i in range(n):\n\txtot += (2*i-n+1)*x[i]\nfor i in range(m):\n\tytot += (2*i-m+1)*y[i]\nxtot = xtot % mod\nytot = ytot % mod\nprint(int((xtot*ytot)%mod))", "jacc_sim": 0.9090909090909091, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [143, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u623819879", "n_user": "u623819879", "pos": "mo=10**9+7\nn,m=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\nX,Y=0,0\nfor i in range(n):\n X+=x[i]*(n-2*i-1)\n X%=mo\nfor i in range(m):\n Y+=y[i]*(m-2*i-1)\n Y%=mo\nprint(X*Y%mo)", "neg": "mo=10**9+7\nn,m=map(int,input().split())\nx=[int(i) for i in input().split()]\ny=[int(i) for i in input().split()]\nX,Y=0,0\nfor i in range(n):\n X+=x[i]*(n-2*i-1)\n X%=mo\nfor i in range(n):\n Y+=y[i]*(n-2*i-1)\n Y%=mo\nprint(X*Y%mo)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [131, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u619819312", "n_user": "u619819312", "pos": "mod=10**9+7\ndef f(a):\n c=0\n for i in range(len(a)):\n c+=a[i]-a[0]\n d=c\n for i in range(1,len(a)-1):\n d+=c-(len(a)-i)*(a[i]-a[i-1])\n c-=(len(a)-i)*(a[i]-a[i-1])\n return d%mod\nn,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nprint(f(a)*f(b)%mod)", "neg": "mod=10**9+7\ndef f(a):\n c=0\n for i in range(len(a)):\n c+=a[i]-a[0]\n d=c\n for i in range(1,len(a)-1):\n d+=c-(len(a)-i)*(a[i]-a[i-1])\n return d%mod\nn,m=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nprint(f(a)*f(b)%mod)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [174, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u371763408", "n_user": "u371763408", "pos": "n,m = map(int,input().split())\nX = list(map(int,input().split()))\nY = list(map(int,input().split()))\narea=0\nmod=10**9+7\n\nx=0\n\nfor i in range(n):\n x += -(n-i-1)*X[i]+i*X[i]\n\ny = 0\n\nfor i in range(m):\n y += -(m-i-1)*Y[i]+i*Y[i]\n\nprint(x*y%mod)", "neg": "n,m = map(int,input().split())\nX = list(map(int,input().split()))\nY = list(map(int,input().split()))\narea=0\nmod=10**9+7\n\nx=0\n\nfor i in range(n):\n x += -(n-i-1)*X[i]+i*X[i]\n print(\"x\",x)\n\ny = 0\n\nfor i in range(m):\n y += -(m-i-1)*Y[i]+i*Y[i]\n\nprint(x*y%mod)", "jacc_sim": 0.9722222222222222, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [134, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u824237520", "n_user": "u010110540", "pos": "n, m = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nMOD = 10 ** 9 + 7\n\nx_sum = 0\ntemp = 0\nfor i in range(n - 1):\n temp = temp + n - 1 - (2 * i)\n x_sum += (x[i + 1] - x[i]) * temp\n x_sum %= MOD\n\ny_sum = 0\ntemp = 0\nfor i in range(m - 1):\n temp = temp + m - 1 - (2 * i)\n y_sum += (y[i + 1] - y[i]) * temp\n y_sum %= MOD\n\nprint( (x_sum * y_sum) % MOD )\n", "neg": "n, m = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nq = 10**9+7\n\nx_sum = 0\ny_sum = 0\nfor i in range(n):\n x_sum += (2*i - n + 1) * x[i]\n \nfor i in range(m):\n y_sum += (2*i - n + 1) * y[i]\n\nprint( ((x_sum % q) * (y_sum % q) %q) )", "jacc_sim": 0.918918918918919, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [192, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u270681687", "n_user": "u690536347", "pos": "n, m = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nsum_x = 0\nsum_y = 0\n\nfor i in range(n):\n sum_x += (2 * i + 1 - n) * x[i] % mod\nfor j in range(m):\n sum_y += (2 * j + 1 - m) * y[j] % mod\n\nprint((sum_x * sum_y) % mod)\n", "neg": "n,m=map(int,input().split())\n*x,=map(int,input().split())\n*y,=map(int,input().split())\n\nsum_x,sum_y=[0]*(n-1),[0]*(m-1)\nsum_x[0]=x[1]-x[0]\nsum_y[0]=y[1]-y[0]\nmod=10**9+7\n\nfor i in range(1,n-1):\n sum_x[i]=sum_x[i-1]+x[i+1]-x[i]+x[i+1]-x[0]\nfor i in range(1,m-1):\n sum_y[i]=sum_y[i-1]+y[i+1]-y[i]+y[i+1]-y[0]\n\nprint((sum_x[-1]*sum_y[-1])%mod)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [138, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u690536347", "n_user": "u690536347", "pos": "n,m=map(int,input().split())\n*x,=map(int,input().split())\n*y,=map(int,input().split())\nmod=10**9+7\nvx,vy=0,0\nfor i in range(n):\n vx+=(i*x[i]-(n-i-1)*x[i])\nfor j in range(m):\n vy+=(j*y[j]-(m-j-1)*y[j])\nprint(vx*vy%mod)", "neg": "n,m=map(int,input().split())\n*x,=map(int,input().split())\n*y,=map(int,input().split())\nmod=10**9+7\nvx,vy=0,0\nfor i in range(n):\n vx+=(i*x[i]-(n-i-1)*x[i])\nfor j in range(m):\n vy+=(j*x[j]-(m-j-1)*x[j])\nprint(vx*vy%mod)", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [125, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u497625442", "n_user": "u497625442", "pos": "n,m = map(int,input().split())\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\nP = 10**9+7\n\ndef s(n,i):\n\treturn i * (n-(i-1))\n\ndef xx(x,n):\n\tt = 0\n\tfor i in range(n-1):\n\t\tt = (t + s(n-1,i+1) * (x[i+1]-x[i])) % P\n\treturn t\n\nR = (xx(x,n) * xx(y,m)) % P \nprint(R)\n", "neg": "n,m = map(int,input().split())\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\nP = 10**9+7\ndef xx(x,n):\n\tt = 0\n\tfor i in range(n-1):\n\t\tt = (t + i*(n-(i-1)) * (x[i+1]-x[i])) % P\n\treturn t\nprint((xx(x,n) * xx(y,m)) % P)\n", "jacc_sim": 0.9473684210526315, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [160, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u620868411", "n_user": "u620868411", "pos": "# coding=utf-8\n\nline = input().split(\" \")\nn = int(line[0])\nm = int(line[1])\n\nx = 0\nline1 = input().split(\" \")\nfor (k,nn) in enumerate(line1):\n nn = int(nn)\n x += k*nn - (n-k-1)*nn\n\n\ny = 0\nline2 = input().split(\" \")\nfor (k,nn) in enumerate(line2):\n nn = int(nn)\n y += k*nn - (m-k-1)*nn\n\nprint((x*y)%(10**9+7))\n", "neg": "# coding=utf-8\n\nline = input().split(\" \")\nn = int(line[0])\nm = int(line[1])\n\nx = 0\nfor (k,nn) in enumerate(input().split(\" \")):\n nn = int(nn)\n x += k*nn - (n-k-1)*nn\n\ny = 0\nfor (k,nn) in enumerate(input().split(\" \")):\n nn = int(nn)\n y += k*nn - (n-k-1)*nn\n\nprint((x*y)%(10**9+7))\n", "jacc_sim": 0.9473684210526315, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [152, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u010110540", "n_user": "u010110540", "pos": "n, m = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nq = 10**9+7\n\nx_sum = 0\ny_sum = 0\nfor i in range(n):\n x_sum += (2*i - n + 1) * x[i]\n \nfor i in range(m):\n y_sum += (2*i - m + 1) * y[i]\n\nprint( ((x_sum * y_sum )%q) )", "neg": "n, m = map(int, input().split())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nq = 10**9+7\n\nx_sum = 0\ny_sum = 0\nfor i in range(n):\n x_sum += (2*i - n + 1) * x[i]\n \nfor i in range(m):\n y_sum += (2*i - n + 1) * y[i]\n\nprint(x_sum * y_sum)", "jacc_sim": 0.9714285714285714, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [138, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u796424048", "n_user": "u796424048", "pos": "n,m = list(map(int,input().split()))\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\na = 0\nb = 0\nMod = 10**9 + 7\n\nfor k in range(1,n+1):\n a += (k-1)*x[k-1] - (n-k)*x[k-1]\nfor j in range(1,m+1):\n b += (j-1)*y[j-1] - (m-j)*y[j-1]\n\nres = a*b\nprint(a*b%Mod)", "neg": "n,m = list(map(int,input().split()))\nx = list(map(int,input().split()))\ny = list(map(int,input().split()))\na = 0\nb = 0\nMod = 10**9 + 7\n\nfor k in range(1,n+1):\n a += (k-1)*x[k-1] - (n-k)*x[k-1]\nfor j in range(1,m+1):\n b += (j-1)*y[j-1] - (m-j)*y[j-1]\n\nres = a*b\nprint(a*b)", "jacc_sim": 0.9722222222222222, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [154, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u341087021", "n_user": "u341087021", "pos": "import sys\nn,m = [int(x) for x in sys.stdin.readline().split()]\nx = [int(x) for x in sys.stdin.readline().split()]\ny = [int(x) for x in sys.stdin.readline().split()]\nr = 0\nmod = 10**9+7\ndef sumof(a,b):\n\ts = 0\n\tfor i in range(a):\n\t\ts += (2*(i+1)-a-1)*b[i]\n\t\ts %= mod\n\treturn s\nr = (sumof(n,x)*sumof(m,y))%mod\nprint(r)", "neg": "import sys\nn,m = [int(x) for x in sys.stdin.readline().split()]\nx = [int(x) for x in sys.stdin.readline().split()]\ny = [int(x) for x in sys.stdin.readline().split()]\nr = 0\nmod = 10**9+7\ndef sumof(a,b):\n\ts = 0\n\tfor i in range(1,a):\n\t\ts += i*b[i]\n\tfor i in range(a):\n\t\ts -= (n-i)*b[i]\n\treturn s%mod\nr = (sumof(n,x)*sumof(m,y))%mod\nprint(r)", "jacc_sim": 0.975609756097561, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [157, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u821262411", "n_user": "u821262411", "pos": "mod_number=1000000007\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\n\nans_x=0\nans_y=0\n\nfor i in range(n-1):\n ans_x += (x[i+1]-x[i])*(i+1)*(n-i-1) % mod_number\n\n\nfor i in range(m-1):\n ans_y += (y[i+1]-y[i])*(i+1)*(m-i-1) % mod_number\n\nprint(ans_x * ans_y % mod_number)\n", "neg": "mod_number=10000000007\nn,m=map(int,input().split())\nx=list(map(int,input().split()))\ny=list(map(int,input().split()))\n\nans_x=0\nans_y=0\n\nfor i in range(n-1):\n ans_x += (x[i+1]-x[i])*(i+1)*(n-i-1) % mod_number\n\n\nfor i in range(m-1):\n ans_y += (y[i+1]-y[i])*(i+1)*(m-i-1) % mod_number\n\nprint(ans_x * ans_y % mod_number)", "jacc_sim": 0.9393939393939394, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [169, 168], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u996252264", "n_user": "u996252264", "pos": "def rren(): return list(map(int, input().split()))\nn, m = rren()\nx = rren()\ny = rren()\nans = 0\nx_sum = 0\ny_sum = 0\nfor now_x in range(n):\n x_sum += x[now_x] * (now_x - (n-1 - now_x))\nfor now_y in range(m):\n y_sum += y[now_y] * (now_y - (m-1 - now_y))\n\nprint(x_sum * y_sum % 1000000007)\n", "neg": "def rren(): return list(map(int, input().split()))\nn, m = rren()\nx = rren()\ny = rren()\nans = 0\nx_sum = 0\ny_sum = 0\nfor now_x in range(n):\n x_sum += x[now_x] * (now_x - (n-1 - now_x))\nfor now_y in range(m):\n y_sum += y[now_y] * (now_y - (m-1 - now_y))\n\nprint(x_sum * y_sum)\n\n\n\n", "jacc_sim": 0.9444444444444444, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [143, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03762", "p_user": "u466826467", "n_user": "u466826467", "pos": "n, m = list(map(int, input().split()))\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nsum_x = 0\nfor i in range(0, n):\n sum_x += i * x[i] - (n - (i + 1)) * x[i]\n\nsum_y = 0\nfor i in range(0, m):\n sum_y += i * y[i] - (m - (i + 1)) * y[i]\n\nans = sum_x * sum_y\n\ndivide_num = pow(10, 9) + 7\nprint(ans % divide_num)\n", "neg": "n, m = list(map(int, input().split()))\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\n\nsum_x = 0\nfor i in range(0, n):\n sum_x += i * x[i] - (n - (i + 1)) * x[i]\n\nsum_y = 0\nfor i in range(0, m):\n sum_y += i * y[i] - (n - (i + 1)) * y[i]\n\nans = sum_x * sum_y\n\ndivide_num = pow(10, 9) + 7\nprint(ans % divide_num)\n", "jacc_sim": 1.0, "nl": "You are given a set of lines on a two-dimensional plane, with some lines parallel to the x-axis and others parallel to the y-axis. You need to find the total area of all rectangles formed by these lines and print the sum of these areas modulo 10^9+7. The input consists of the number of lines parallel to the x-axis, the number of lines parallel to the y-axis, and the coordinates of these lines. The output should be the total area of the rectangles modulo 10^9+7.", "before_after_length": [165, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u169350228", "n_user": "u169350228", "pos": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n s = input()\n t = input()\n ns = len(s)+1\n nt = len(t)+1\n ssa = [0]*ns\n ssb = [0]*ns\n sta = [0]*nt\n stb = [0]*nt\n for i,si in enumerate(s):\n if si == \"A\":\n da = 1\n db = 0\n else:\n da = 0\n db = 1\n ssa[i+1] = ssa[i]+da\n ssb[i+1] = ssb[i]+db\n for i,ti in enumerate(t):\n if ti == \"A\":\n da = 1\n db = 0\n else:\n da = 0\n db = 1\n sta[i+1] = sta[i]+da\n stb[i+1] = stb[i]+db\n\n q = int(ipt())\n for _ in range(q):\n a,b,c,d = map(int,ipt().split())\n da = ssa[b]-ssa[a-1]-sta[d]+sta[c-1]\n db = ssb[b]-ssb[a-1]-stb[d]+stb[c-1]\n if (da-db)%3 == 0:\n print(\"YES\")\n else:\n print(\"NO\")\n\n return\n\nif __name__ == '__main__':\n main()\n", "neg": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n s = input()\n t = input()\n ns = len(s)+1\n nt = len(t)+1\n ssa = [0]*ns\n ssb = [0]*ns\n sta = [0]*nt\n stb = [0]*nt\n for i,si in enumerate(s):\n if si == \"A\":\n da = 1\n db = 0\n else:\n da = 0\n db = 1\n ssa[i+1] = ssa[i]+da\n ssb[i+1] = ssb[i]+db\n for i,ti in enumerate(t):\n if ti == \"A\":\n da = 1\n db = 0\n else:\n da = 0\n db = 1\n sta[i+1] = sta[i]+da\n stb[i+1] = stb[i]+db\n\n q = int(ipt())\n for _ in range(q):\n a,b,c,d = map(int,ipt().split())\n da = ssa[b]-ssa[a-1]-sta[d]+sta[c-1]\n db = ssb[b]-ssb[a-1]-stb[d]+stb[c-1]\n if (da-db)%3 == 0:\n print(\"Yes\")\n else:\n print(\"No\")\n\n return\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9512195121951219, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [442, 442], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u392319141", "n_user": "u392319141", "pos": "S = input()\nT = input()\n\naccSA = [0] * (len(S) + 1)\naccSB = [0] * (len(S) + 1)\n\nfor i, s in enumerate(S):\n accSA[i + 1] += accSA[i]\n accSB[i + 1] += accSB[i]\n if s == 'A':\n accSA[i + 1] += 1\n else:\n accSB[i + 1] += 1\n\naccTA = [0] * (len(T) + 1)\naccTB = [0] * (len(T) + 1)\n\nfor i, s in enumerate(T):\n accTA[i + 1] += accTA[i]\n accTB[i + 1] += accTB[i]\n if s == 'A':\n accTA[i + 1] += 1\n else:\n accTB[i + 1] += 1\n\nQ = int(input())\nans = []\nfor _ in range(Q):\n a, b, c, d = map(int, input().split())\n\n sA = accSA[b] - accSA[a - 1]\n sB = accSB[b] - accSB[a - 1]\n tA = accTA[d] - accTA[c - 1]\n tB = accTB[d] - accTB[c - 1]\n\n sA = (sA + sB * 2) % 3\n tA = (tA + tB * 2) % 3\n\n ans.append('YES' if sA == tA else 'NO')\nprint(*ans, sep='\\n')\n", "neg": "S = input()\nT = input()\n\naccSA = [0] * (len(S) + 1)\naccSB = [0] * (len(S) + 1)\n\nfor i, s in enumerate(S):\n accSA[i + 1] += accSA[i - 1]\n accSB[i + 1] += accSB[i - 1]\n if s == 'A':\n accSA[i + 1] += 1\n else:\n accSB[i + 1] += 1\n\naccTA = [0] * (len(T) + 1)\naccTB = [0] * (len(T) + 1)\n\nfor i, s in enumerate(T):\n accTA[i + 1] += accTA[i - 1]\n accTB[i + 1] += accTB[i - 1]\n if s == 'A':\n accTA[i + 1] += 1\n else:\n accTB[i + 1] += 1\n\nQ = int(input())\nans = []\nfor _ in range(Q):\n a, b, c, d = map(int, input().split())\n\n sA = accSA[b] - accSA[a - 1]\n sB = accSB[b] - accSB[a - 1]\n tA = accTA[d] - accTA[c - 1]\n tB = accTB[d] - accTB[c - 1]\n\n sA = (sA + sB * 2) % 3\n tA = (tA + tB * 2) % 3\n\n ans.append('YES' if sA == tA else 'NO')\nprint(*ans, sep='\\n')\n\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [399, 408], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u296518383", "n_user": "u296518383", "pos": "from itertools import accumulate\n\nS = input()\nT = input()\nQ = int(input())\nABCD = [list(map(int, input().split())) for _ in range(Q)]\n\nSL = [1 if s == \"A\" else 2 for s in S]\nTL = [1 if t == \"A\" else 2 for t in T]\n\nAcumS = [0] + list(accumulate(SL))\nAcumT = [0] + list(accumulate(TL))\n\nfor a, b, c, d in ABCD:\n s = AcumS[b] - AcumS[a - 1]\n t = AcumT[d] - AcumT[c - 1]\n if (s - t) % 3 == 0:\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "from itertools import accumulate\n\nS = input()\nT = input()\nQ = int(input())\nABCD = [list(map(int, input().split())) for _ in range(Q)]\n\nSL = [1 if s == \"A\" else 2 for s in S]\nTL = [1 if t == \"A\" else 2 for t in T]\n\nAcumS = [0] + list(accumulate(SL))\nAcumT = [0] + list(accumulate(TL))\n\nfor a, b, c, d in ABCD:\n s = AcumS[b] - AcumS[a - 1]\n t = AcumT[d] - AcumT[c - 1]\n if (s - t) % 3 == 0:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 0.92, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [196, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u504836877", "n_user": "u504836877", "pos": "S = input()\nT = input()\nq = int(input())\nL = [[int(l) for l in input().split()] for _ in range(q)]\n\nsumS = [0]*(len(S)+1)\nsumT = [0]*(len(T)+1)\n\nfor i in range(len(S)):\n if S[i] == \"A\":\n sumS[i+1] += 1\n sumS[i+1] += sumS[i]\n\nfor i in range(len(T)):\n if T[i] == \"A\":\n sumT[i+1] += 1\n sumT[i+1] += sumT[i]\n\nfor i in range(q):\n a = (sumT[L[i][3]]-sumT[L[i][2]-1]) - (sumS[L[i][1]]-sumS[L[i][0]-1])\n b = (L[i][3]-L[i][2]+1) - (L[i][1]-L[i][0]+1) - a\n if (a-b)%3 == 0:\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "S = input()\nT = input()\nq = int(input())\nL = [[int(l) for l in input().split()] for _ in range(q)]\n\nsumS = [0]*(len(S)+1)\nsumT = [0]*(len(T)+1)\n\nfor i in range(len(S)):\n if S[i] == \"A\":\n sumS[i+1] += 1\n sumS[i+1] += sumS[i]\n\nfor i in range(len(T)):\n if T[i] == \"A\":\n sumT[i+1] += 1\n sumT[i+1] += sumT[i]\n\nfor i in range(q):\n a = (sumT[L[i][3]]-sumT[L[i][2]-1]) - (sumS[L[i][1]]-sumS[L[i][0]-1])\n b = (L[i][3]-L[i][2]+1) - (L[i][1]-L[i][0]+1) - a\n if (a-b)%3 == 0:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 0.9024390243902439, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [294, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u712768978", "n_user": "u712768978", "pos": "s = input()\nt = input()\nq = int(input())\n\nlen_s = len(s)\nlen_t = len(t)\n\ns_counter= [0]*(len_s+1)\ns_temp = 0\nfor i in range(len_s):\n\tif s[i] == \"A\":\n\t\ts_temp += 1\n\ts_counter[i+1] = s_temp\n\t\nt_counter= [0]*(len_t+1)\nt_temp = 0\nfor i in range(len_t):\n\tif t[i] == \"A\":\n\t\tt_temp += 1\n\tt_counter[i+1] = t_temp\n\nfor _ in range(q):\n\ta, b, c, d = map(int, input().split())\n\t\n\tx = s_counter[b]-s_counter[a-1]\n\ty = t_counter[d]-t_counter[c-1]\n\tprint(['NO', 'YES'][((x+b-a+1)-(y+d-c+1))%3==0]) ", "neg": "s = input()\nt = input()\nq = int(input())\n\nlen_s = len(s)\nlen_t = len(t)\n\ns_counter= [0]*(len_s+1)\ns_temp = 0\nfor i in range(len_s):\n\tif s[i] == \"A\":\n\t\ts_temp += 1\n\ts_counter[i+1] = s_temp\n\t\nt_counter= [0]*(len_t+1)\nt_temp = 0\nfor i in range(len_t):\n\tif t[i] == \"A\":\n\t\tt_temp += 1\n\tt_counter[i+1] = t_temp\n\nfor _ in range(q):\n\ta, b, c, d = map(int, input().split())\n\t\n\tx = s_counter[b]-s_counter[a-1]\n\ty = t_counter[d]-t_counter[c-1]\n\tprint(x,y)\n\tprint(['NO', 'YES'][((x+b-a+1)-(y+d-c+1))%3==0]) ", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [268, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u648212584", "n_user": "u648212584", "pos": "def main():\n S = list(str(input()))\n T = list(str(input()))\n q = int(input())\n S_cum = [0]\n T_cum = [0]\n for i in S:\n if i == \"A\":\n S_cum.append((S_cum[-1]+1)%3)\n else:\n S_cum.append((S_cum[-1]+2)%3)\n for i in T:\n if i == \"A\":\n T_cum.append((T_cum[-1]+1)%3)\n else:\n T_cum.append((T_cum[-1]+2)%3)\n for i in range(q):\n a,b,c,d = map(int,input().split())\n s_ = S_cum[b]-S_cum[a-1]\n t_ = T_cum[d]-T_cum[c-1]\n if s_%3 == t_%3:\n print(\"YES\")\n else:\n print(\"NO\")\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n S = list(str(input()))\n T = list(str(input()))\n q = int(input())\n S_cum = [0]\n T_cum = [0]\n for i in S:\n if i == \"A\":\n S_cum.append((S_cum[-1]+1)%3)\n else:\n S_cum.append((S_cum[-1]+2)%3)\n for i in T:\n if i == \"A\":\n T_cum.append((T_cum[-1]+1)%3)\n else:\n T_cum.append((T_cum[-1]+2)%3)\n for i in range(q):\n a,b,c,d = map(int,input().split())\n s_ = S_cum[b]-S_cum[a-1]\n t_ = T_cum[d]-T_cum[c-1]\n if s_%3 == t_%3:\n print(\"Yes\")\n else:\n print(\"No\")\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.92, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [274, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u054106284", "n_user": "u054106284", "pos": "S = input()\nT = input()\nN = len(S)\nM = len(T)\nSs = [0]*(N+1)\nTs = [0]*(M+1)\nfor i in range(N):\n if S[i] == \"A\":\n temp = 1\n else:\n temp = -1\n Ss[i+1] = Ss[i] + temp\nfor i in range(M):\n if T[i] == \"A\":\n temp = 1\n else:\n temp = -1\n Ts[i+1] = Ts[i] + temp\nQ = int(input())\nfor i in range(Q):\n a, b, c, d = (int(i) for i in input().split())\n if (Ss[b] - Ss[a-1] - Ts[d] + Ts[c-1])%3==0:\n print(\"YES\")\n else:\n print(\"NO\")\n ", "neg": "S = input()\nT = input()\nN = len(S)\nM = len(M)\nSs = [0]*(N+1)\nTs = [0]*(M+1)\nfor i in range(N):\n if S[i] == \"A\":\n temp = 1\n else:\n temp = -1\n Ss[i+1] = Ss[i] + temp\nfor i in range(M):\n if T[i] == \"A\":\n temp = 1\n else:\n temp = -1\n Ts[i+1] = Ts[i] + temp\nQ = int(input())\nfor i in range(Q):\n a, b, c, d = (int(i) for i in input().split())\n if a == b:\n print(\"NO\")\n continue\n else:\n if (Ss[b] - Ss[a-1] - Ts[d] + Ts[c-1])%3==0:\n print(\"YES\")\n else:\n print(\"NO\")\n ", "jacc_sim": 0.9767441860465116, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [235, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03765", "p_user": "u942033906", "n_user": "u942033906", "pos": "S = input()\nT = input()\nq = int(input())\n\ns = [0]\nt = [0]\nv = 0\nfor c in S:\n\tv = (v + (ord(c) - ord(\"A\") + 1)) % 3\n\ts.append(v)\nv = 0\nfor c in T:\n\tv = (v + (ord(c) - ord(\"A\") + 1)) % 3\n\tt.append(v)\nfor i in range(q):\n\ta,b,c,d = map(int, input().split())\n\tx = (3 + s[b] - s[a-1]) % 3\n\ty = (3 + t[d] - t[c-1]) % 3\n\tif x == y:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n", "neg": "S = input()\nT = input()\nq = int(input())\n\ns = [0]\nt = [0]\nv = 0\nfor c in S:\n\tv = (v + (ord(c) - ord(\"A\") + 1)) % 3\n\ts.append(v)\nv = 0\nfor c in T:\n\tv = (v + (ord(c) - ord(\"A\") + 1)) % 3\n\tt.append(v)\n\nfor i in range(q):\n\ta,b,c,d = map(int, input().split())\n\tx = (3 + s[b] - s[a-1]) % 3\n\ty = (3 + t[d] - s[c-1]) % 3\n\tif x == y:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, and q queries (a_i, b_i, c_i, d_i). For each query, determine whether a substring of S can be transformed into a substring of T using specific operations. The operations involve replacing characters and deleting specific substrings. The constraints are: 1 \u2264 |S|, |T| \u2264 10^5, S and T consist of letters A and B, and 1 \u2264 q \u2264 10^5. The input format includes S, T, q, and the queries. The output should indicate whether each query can be transformed (YES) or not (NO). Sample inputs and outputs are provided for reference.", "before_after_length": [201, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03766", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\ninput = sys.stdin.readline\n\nMOD = 10**9 + 7\nN = int(input())\n\ndp = [0] * (N+10)\ndp_cum = [0] * (N+10)\n\ndp[1] = N-1; dp_cum[1] = N-1\ndp[2] = N-1; dp_cum[2] = 2*(N-1)\nfor n in range(3,N+1):\n dp[n] = dp[n-1] + dp_cum[n-3]\n dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD\n\nanswer = sum(dp[1:N])*N + dp[N] + 1\nanswer %= MOD\nprint(answer)", "neg": "import sys\ninput = sys.stdin.readline\n\nMOD = 10**9 + 7\nN = int(input())\n\ndp = [0] * (N+10)\ndp_cum = [0] * (N+10)\n\ndp[1] = N-1; dp_cum[1] = N-1\ndp[2] = N-1; dp_cum[2] = 2*(N-1)\nfor n in range(3,N+1):\n dp[n] = dp[n-1] + dp_cum[n-3]\n dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD\n\nanswer = sum(dp[1:N])*N + dp[-1] + 1\nanswer %= MOD\nprint(answer)", "jacc_sim": 1.0, "nl": "You are given a problem to find the number of infinite sequences consisting of {1, 2, ..., n} that satisfy certain conditions. The conditions are that the n-th and subsequent elements are all equal, and for every integer i, the elements immediately following the i-th element are all equal. You need to find the count of such sequences modulo 10^9+7. The input is an integer n, and the output should be the count of sequences satisfying the conditions, modulo 10^9+7. For example, if the input is 2, the output should be 4, and for input 654321, the output should be 968545283.", "before_after_length": [187, 187], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00312", "p_user": "u737311644", "n_user": "u737311644", "pos": "a,b=map(int,input().split())\nc=a//b\nd=a%b\ne=c+d\nprint(e)\n", "neg": "a,b=map(int,input().split())\nc=a//b\nd=a%b\ne=c+b\nprint(e)\n", "jacc_sim": 1.0, "nl": "Title: Frog's Straight Return\n\nA frog is trying to return to its burrow. The burrow is located D centimeters ahead, and the frog moves straight towards it. The frog has two possible actions:\n- Big jump (moves L centimeters forward)\n- Small jump (moves 1 centimeter forward)\n\nThe frog aims to land exactly at the burrow without jumping over it.\n\nCreate a program to determine the minimum number of jumps the frog needs to make to return to the burrow.\n\nInput:\nThe input is given in the following format:\nD L\n\nThe input consists of a single line, providing the distance to the burrow D (1 \u2264 D \u2264 10000) and the distance the frog moves with a big jump L (2 \u2264 L \u2264 10000).\n\nOutput:\nOutput the minimum number of jumps the frog needs to make on a single line.\n\nSample Input 1:\n10 5\n\nSample Output 1:\n2\n\nSample Input 2:\n7 4\n\nSample Output 2:\n4", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00312", "p_user": "u726971073", "n_user": "u546285759", "pos": "print(sum(divmod(*map(int,input().split()))))\n", "neg": "print(sum(divmod(map(int, input().split())))", "jacc_sim": 0.9166666666666666, "nl": "Title: Frog's Straight Return\n\nA frog is trying to return to its burrow. The burrow is located D centimeters ahead, and the frog moves straight towards it. The frog has two possible actions:\n- Big jump (moves L centimeters forward)\n- Small jump (moves 1 centimeter forward)\n\nThe frog aims to land exactly at the burrow without jumping over it.\n\nCreate a program to determine the minimum number of jumps the frog needs to make to return to the burrow.\n\nInput:\nThe input is given in the following format:\nD L\n\nThe input consists of a single line, providing the distance to the burrow D (1 \u2264 D \u2264 10000) and the distance the frog moves with a big jump L (2 \u2264 L \u2264 10000).\n\nOutput:\nOutput the minimum number of jumps the frog needs to make on a single line.\n\nSample Input 1:\n10 5\n\nSample Output 1:\n2\n\nSample Input 2:\n7 4\n\nSample Output 2:\n4", "before_after_length": [18, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00331", "p_user": "u934460477", "n_user": "u724548524", "pos": "h,r=map(int,input().split())\nif h+r==0:\n print('0')\nelif h+r<0:\n print('-1')\nelse:\n print('1')\n", "neg": "h, r = map(int, input().split())\nif h + r < 0:print(-1)\nelse:print(0 if h == r else 1)\n", "jacc_sim": 0.9090909090909091, "nl": "Title: Sunrise and Sunset\n\nSunrise refers to the appearance of the sun, while sunset refers to its disappearance. The precise timing depends on the sun's position relative to the horizon.\n\nConsider the sun as a circle and the horizon as a straight line. The moments of sunrise and sunset occur when the top of the sun's circle aligns with the horizon line. After sunrise, the period when the top of the circle is above the line is daytime, while the time when the circle is completely below the line is nighttime.\n\nGiven the height from the horizon to the center of the sun and the sun's radius, create a program to determine whether it is daytime, sunrise/sunset, or nighttime.\n\nInput:\nA single line containing an integer H (-1000 \u2264 H \u2264 1000) representing the height from the horizon to the center of the sun at a specific time, and an integer R (1 \u2264 R \u2264 1000) representing the sun's radius. H is 0 when the sun's center is on the horizon, positive when above, and negative when below.\n\nOutput:\nPrint \"1\" for daytime, \"0\" for sunrise/sunset, and \"-1\" for nighttime.\n\nSample Input 1:\n-3 3\n\nSample Output 1:\n0\n\nSample Input 2:\n3 3\n\nSample Output 2:\n1\n\nSample Input 3:\n-4 3\n\nSample Output 3:\n-1", "before_after_length": [52, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00332", "p_user": "u805464373", "n_user": "u805464373", "pos": "E,Y = map(int,input().split())\n\nif E ==0:\n if 1912>Y:\n print(\"M\"+str(Y-1867))\n elif 1926>Y:\n print(\"T\"+str(Y-1911))\n elif 1989>Y:\n print(\"S\"+str(Y-1925))\n else:\n print(\"H\"+str(Y-1988))\nelif E==1:\n print(1867+Y)\nelif E==2:\n print(1911+Y)\nelif E==3:\n print(1925+Y)\nelse:\n print(1988+Y)\n\n", "neg": "E,Y = map(int,input().split())\n\nif E ==0:\n if 1911>Y:\n print(\"M\"+str(Y-1867))\n elif 1925>Y:\n print(\"T\"+str(Y-1911))\n elif 1988>Y:\n print(\"S\"+str(Y-1925))\n else:\n print(\"H\"+str(Y-1988))\nelif E==1:\n print(1868+Y)\nelif E==2:\n print(1912+Y)\nelif E==3:\n print(1926+Y)\nelse:\n print(1989+Y)\n\n", "jacc_sim": 0.972972972972973, "nl": "The problem discusses the conversion between the Western calendar (\"Gregorian calendar\") and the Japanese calendar (\"Imperial calendar\"). It requires creating a program to convert a given year from one calendar system to the other. The input consists of a calendar type (0 for Gregorian, 1-4 for different eras in the Japanese calendar) and a year. The output should display the converted year, with a prefix indicating the era for the Gregorian to Japanese conversion. The problem provides specific era ranges for each calendar type. Four sample inputs and their corresponding outputs are also provided.", "before_after_length": [165, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00334", "p_user": "u451187291", "n_user": "u451187291", "pos": "# encoding: 'utf-8'\n\nN = int(input())\nls = list()\n\nfor _ in range(N):\n e = sorted([int(x) for x in input().split()])\n if e in ls:\n continue\n else:\n ls.append(e)\nprint(N - len(ls))", "neg": "# encoding: 'utf-8'\n\nN = int(input())\nls = list()\nfor _ in range(N):\n e = sorted([int(x) for x in split(input())])\n if e in ls:\n continue\n else:\n ls.append(e)\nprint(N - len(ls))", "jacc_sim": 1.0, "nl": "Title: Shape Data Processing\n\nIn computer graphics, the polygon model is used to represent three-dimensional shapes. This model consists of vertex coordinates and the connections between these vertices to create surfaces.\n\nFor this problem, we consider a polygon model consisting of triangles. Any polygon model can be represented as a collection of surface information representing triangles.\n\nEach surface information is represented by arranging three vertices. However, if the arrangement of vertices is different, but the same three points are used, it is considered the same surface information. For example, in the given tetrahedron, the surface created by connecting vertices 1, 2, and 3 can also be represented as vertices 2, 3, 1 or vertices 3, 2, 1. To avoid redundancy, it is better to consolidate such duplicate surface information.\n\nGiven the surface information, create a program to determine the number of surface information that needs to be removed to eliminate duplicate surfaces.\n\nInput:\nThe input is given in the following format:\nN\np11 p12 p13\np21 p22 p23\n...\npN1 pN2 pN3\n\nThe first line contains the number of surface information N (1 \u2264 N \u2264 1000). The following N lines contain the vertex numbers pij (1 \u2264 pij \u2264 1000) used to create the ith surface. For each surface, the same vertex is not used more than twice (pi1 \u2260 pi2 and pi2 \u2260 pi3 and pi1 \u2260 pi3).\n\nOutput:\nOutput the number of surface information that needs to be removed to eliminate duplicate surfaces in a single line.\n\nSample Input 1:\n4\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n\nSample Output 1:\n0\n\nSample Input 2:\n6\n1 3 2\n1 2 4\n1 4 3\n2 3 4\n3 2 1\n2 3 1\n\nSample Output 2:\n2\n\nIn the second example, the first, fifth, and sixth surfaces use vertices 1, 3, 2 to create a triangle, differing only in the order of points, thus resulting in duplicates. Therefore, removing two surfaces will eliminate the duplicate surfaces.", "before_after_length": [79, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00340", "p_user": "u498511622", "n_user": "u498511622", "pos": "lst=list(input().split())\nlst.sort()\nif lst[0]==lst[1] and lst[2]==lst[3]:\n print('yes')\nelse:\n print('no')", "neg": "lst=list(input().split())\nif lst[0]==lst[1] and lst[2]==lst[3]:\n print('yes')\nelse:\n print('no')", "jacc_sim": 0.9565217391304348, "nl": "Title: Creating a Rectangle\n\nIn the educational program \"Asonde Tsukuro\" by the Japan Broadcasting Corporation (NHK Education), a children's craft program is broadcast. In today's episode, the challenge is to create a rectangle using four sticks without cutting or folding them.\n\nInput:\nThe input consists of a single line containing the lengths of the four sticks represented by integers e1, e2, e3, and e4 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it is possible to create a rectangle using the given sticks, and \"no\" if it is not possible. Note that a square is considered a type of rectangle, so for a square, the output should still be \"yes\".\n\nSample Input 1:\n1 1 3 4\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2\n\nSample Output 2:\nyes\n\nSample Input 3:\n2 1 1 2\n\nSample Output 3:\nyes\n\nSample Input 4:\n4 4 4 10\n\nSample Output 4:\nno", "before_after_length": [49, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00340", "p_user": "u546285759", "n_user": "u546285759", "pos": "e = sorted(map(int, input().split()))\nprint(\"yes\" if e[0] == e[1] and e[2] == e[3] else \"no\")", "neg": "e = sorted(map(int, input().split()))\nprint(\"yes\" if e[0] == e[1] and e[2] == e[3])", "jacc_sim": 0.9166666666666666, "nl": "Title: Creating a Rectangle\n\nIn the educational program \"Asonde Tsukuro\" by the Japan Broadcasting Corporation (NHK Education), a children's craft program is broadcast. In today's episode, the challenge is to create a rectangle using four sticks without cutting or folding them.\n\nInput:\nThe input consists of a single line containing the lengths of the four sticks represented by integers e1, e2, e3, and e4 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it is possible to create a rectangle using the given sticks, and \"no\" if it is not possible. Note that a square is considered a type of rectangle, so for a square, the output should still be \"yes\".\n\nSample Input 1:\n1 1 3 4\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2\n\nSample Output 2:\nyes\n\nSample Input 3:\n2 1 1 2\n\nSample Output 3:\nyes\n\nSample Input 4:\n4 4 4 10\n\nSample Output 4:\nno", "before_after_length": [42, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00341", "p_user": "u350064373", "n_user": "u350064373", "pos": "ls = list(map(int, input().split()))\nls.sort()\nif ls[0]==ls[1]==ls[2]==ls[3] and ls[4]==ls[5]==ls[6]==ls[7] and ls[8]==ls[9]==ls[10]==ls[11]:\n print('yes')\nelse:\n print('no')", "neg": "ls = list(map(int, input().split()))\nls.sort()\nif ls[0]==ls[1]==ls[2]==ls[3] and ls[4==ls[5]==ls[6]==ls[7] and ls[8]==ls[9]==ls[10]==ls[11]:\n print('yes')\nelse:\n print('no')", "jacc_sim": 1.0, "nl": "Title: Making a Rectangular Prism with Sticks\n\nThe educational program \"Assemble and Create\" for children, broadcasted by the Aizu Broadcasting Association (AHK Education), features an episode on making boxes with sticks. The challenge is to determine if it's possible to create a rectangular prism using 12 sticks without cutting or bending them.\n\nInput:\nA single line containing the lengths of 12 sticks represented as integers e1, e2, ..., e12 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it's possible to create a rectangular prism, including a cube, using the given sticks. Otherwise, output \"no\".\n\nSample Input 1:\n1 1 3 4 8 9 7 3 4 5 5 5\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2 3 1 2 3 3 3 1 2\n\nSample Output 2:\nyes", "before_after_length": [94, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00341", "p_user": "u498511622", "n_user": "u498511622", "pos": "l=list(input().split())\nl.sort()\nif l[0]==l[1]==l[2]==l[3] and l[4]==l[5]==l[6]==l[7]and l[8]==l[9]==l[10]==l[11]:\n print('yes')\nelse:\n print('no')", "neg": "lst=list(input().split())\nlst.sort()\nif lst[0]==lst[1]==lst[2]==lst[3] and lst[4]==lst[5]==lst[6]==lst[7] and\nlst[8]==lst[9]==lst[10]==lst[11]:\n print('yes')\nelse:\n print('no')", "jacc_sim": 0.9375, "nl": "Title: Making a Rectangular Prism with Sticks\n\nThe educational program \"Assemble and Create\" for children, broadcasted by the Aizu Broadcasting Association (AHK Education), features an episode on making boxes with sticks. The challenge is to determine if it's possible to create a rectangular prism using 12 sticks without cutting or bending them.\n\nInput:\nA single line containing the lengths of 12 sticks represented as integers e1, e2, ..., e12 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it's possible to create a rectangular prism, including a cube, using the given sticks. Otherwise, output \"no\".\n\nSample Input 1:\n1 1 3 4 8 9 7 3 4 5 5 5\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2 3 1 2 3 3 3 1 2\n\nSample Output 2:\nyes", "before_after_length": [89, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00341", "p_user": "u546285759", "n_user": "u546285759", "pos": "e = sorted(map(int, input().split()))\nprint(\"yes\" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else \"no\")", "neg": "e = list(map(int, input().split()))\nprint(\"yes\" if len(set(e[:4])) == len(set(e[4:8])) == len(set(e[8:])) == 1 else \"no\")", "jacc_sim": 0.9230769230769231, "nl": "Title: Making a Rectangular Prism with Sticks\n\nThe educational program \"Assemble and Create\" for children, broadcasted by the Aizu Broadcasting Association (AHK Education), features an episode on making boxes with sticks. The challenge is to determine if it's possible to create a rectangular prism using 12 sticks without cutting or bending them.\n\nInput:\nA single line containing the lengths of 12 sticks represented as integers e1, e2, ..., e12 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it's possible to create a rectangular prism, including a cube, using the given sticks. Otherwise, output \"no\".\n\nSample Input 1:\n1 1 3 4 8 9 7 3 4 5 5 5\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2 3 1 2 3 3 3 1 2\n\nSample Output 2:\nyes", "before_after_length": [54, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00341", "p_user": "u019169314", "n_user": "u019169314", "pos": "li = list(map(int,input().split()))\nso = sorted(li)\na = so[0]\nb = so[4]\nc = so[8]\nfor n in so[:4]:\n res1= a==n\nfor n in so[4:8]:\n res2= b==n\nfor n in so[8:]:\n res3= c==n\nres = 'yes' if res1 and res3 and res2 else 'no'\nprint(res)\n", "neg": "li = list(map(int,input().split()))\nso = sorted(li)\na = so[0]\nb = so[4]\nc = so[8]\nfor n in so[:4]:\n res1= a==n\nfor n in so[4:8]:\n res2= b==n\nfor n in so[8:]:\n res3= c==n\nres = 'yes' if res1 and res3 and res2 else 'no'\n\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Making a Rectangular Prism with Sticks\n\nThe educational program \"Assemble and Create\" for children, broadcasted by the Aizu Broadcasting Association (AHK Education), features an episode on making boxes with sticks. The challenge is to determine if it's possible to create a rectangular prism using 12 sticks without cutting or bending them.\n\nInput:\nA single line containing the lengths of 12 sticks represented as integers e1, e2, ..., e12 (1 \u2264 ei \u2264 100).\n\nOutput:\nOutput \"yes\" if it's possible to create a rectangular prism, including a cube, using the given sticks. Otherwise, output \"no\".\n\nSample Input 1:\n1 1 3 4 8 9 7 3 4 5 5 5\n\nSample Output 1:\nno\n\nSample Input 2:\n1 1 2 2 3 1 2 3 3 3 1 2\n\nSample Output 2:\nyes", "before_after_length": [119, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00352", "p_user": "u548155360", "n_user": "u548155360", "pos": "# coding=utf-8\n\na, b = map(int, input().split())\nprint((a+b)//2)\n\n", "neg": "# coding=utf-8\n\na, b = map(int, input().split())\nprint((a+b)/2)\n\n", "jacc_sim": 1.0, "nl": "Title: Handsel\nNew Year\u2019s gift money\n\nAlice and Brown, siblings, receive pocket money for the upcoming year. They share the total amount equally, with each receiving a multiple of 1,000 yen. \n\nWrite a program to calculate the share of money for Alice and Brown based on the amounts they receive.\n\nInput:\nTwo values, a and b, representing the money received by Alice and Brown, respectively. (1000 \u2264 a, b \u2264 50000)\n\nOutput:\nDisplay the amount of money each of Alice and Brown receives on a separate line.\n\nSample Input 1:\n1000 3000\n\nSample Output 1:\n2000\n\nSample Input 2:\n5000 5000\n\nSample Output 2:\n5000\n\nSample Input 3:\n1000 2000\n\nSample Output 3:\n1500", "before_after_length": [32, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00352", "p_user": "u678843586", "n_user": "u529013669", "pos": "print(sum(map(int,input().split()))//2)\n\n", "neg": "print(sum(map(int,input().split()))/2)", "jacc_sim": 1.0, "nl": "Title: Handsel\nNew Year\u2019s gift money\n\nAlice and Brown, siblings, receive pocket money for the upcoming year. They share the total amount equally, with each receiving a multiple of 1,000 yen. \n\nWrite a program to calculate the share of money for Alice and Brown based on the amounts they receive.\n\nInput:\nTwo values, a and b, representing the money received by Alice and Brown, respectively. (1000 \u2264 a, b \u2264 50000)\n\nOutput:\nDisplay the amount of money each of Alice and Brown receives on a separate line.\n\nSample Input 1:\n1000 3000\n\nSample Output 1:\n2000\n\nSample Input 2:\n5000 5000\n\nSample Output 2:\n5000\n\nSample Input 3:\n1000 2000\n\nSample Output 3:\n1500", "before_after_length": [18, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00352", "p_user": "u725998488", "n_user": "u108948964", "pos": "a, b = map(int, input().split())\nprint((a + b) // 2) \n", "neg": "a, b = map(int, input().split())\n\n\n\nprint((a + b) / 2)\n", "jacc_sim": 1.0, "nl": "Title: Handsel\nNew Year\u2019s gift money\n\nAlice and Brown, siblings, receive pocket money for the upcoming year. They share the total amount equally, with each receiving a multiple of 1,000 yen. \n\nWrite a program to calculate the share of money for Alice and Brown based on the amounts they receive.\n\nInput:\nTwo values, a and b, representing the money received by Alice and Brown, respectively. (1000 \u2264 a, b \u2264 50000)\n\nOutput:\nDisplay the amount of money each of Alice and Brown receives on a separate line.\n\nSample Input 1:\n1000 3000\n\nSample Output 1:\n2000\n\nSample Input 2:\n5000 5000\n\nSample Output 2:\n5000\n\nSample Input 3:\n1000 2000\n\nSample Output 3:\n1500", "before_after_length": [23, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00353", "p_user": "u725843728", "n_user": "u737311644", "pos": "m,f,b=map(int,input().split())\n\nif m>b:\n print(0)\n\nelif b-m<=f:\n print(b-m)\nelse:\n print(\"NA\")\n", "neg": "m,f,b=map(int,input().split())\nans=0\nif m>b:\n ans=0\nelif mf:\n ans=\"NA\"\nprint(ans)\n", "jacc_sim": 0.9166666666666666, "nl": "Title: Shopping\n\nYou and your friend Alice are in a bookshop to buy a newly released book, \"The Winning Strategy for the Programming Koshien Contest.\" You plan to borrow money from Alice if the amount you have is not enough to cover the book's price. Write a program to calculate the minimum amount of money you need to borrow from Alice, given your current money and the book's price.\n\nInput:\nThree integers representing the money you have (m), the money Alice has (f), and the price of the book (b). (0 \u2264 m, f \u2264 10000, 100 \u2264 b \u2264 20000)\n\nOutput:\nPrint the minimum amount of money you need to borrow from Alice. If Alice's money is insufficient, output \"NA.\"\n\nSample Input 1:\n1000 3000 3000\n\nSample Output 1:\n2000\n\nSample Input 2:\n5000 3000 4500\n\nSample Output 2:\n0\n\nSample Input 3:\n500 1000 2000\n\nSample Output 3:\nNA", "before_after_length": [56, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00353", "p_user": "u717526540", "n_user": "u737311644", "pos": "m, f, b = map(int, input().split())\n\nif m + f < b:\n print(\"NA\")\nelif m >= b:\n print(0)\nelse:\n print(b - m)\n", "neg": "m,f,b=map(int,input().split())\nans=0\nif m>b:\n ans=0\nelif m b:sum_a = sum_a + a + b\n elif a < b:sum_b = sum_b + a + b\n else:\n sum_a = sum_a + a\n sum_b = sum_b + b\n print(sum_a,sum_b)\n\n", "neg": "while True:\n n = int(input())\n if n == 0:break\n sum_a = sum_b = 0\n for i in range(n):\n a,b = map(int, raw_input().split())\n if a > b:sum_a = sum_a + a + b\n elif a < b:sum_b = sum_b + a + b\n else:\n sum_a = sum_a + a\n sum_b = sum_b + b\n print(sum_a,sum_b)\n", "jacc_sim": 0.967741935483871, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [129, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u745360181", "n_user": "u745360181", "pos": "while 1:\n n = int(input())\n if n == 0:\n break\n \n sum_a = 0\n sum_b = 0\n \n for i in range(n):\n a,b = map(int, input().split())\n \n if a > b:\n sum_a = sum_a + a + b\n elif a < b:\n sum_b = sum_b + a + b\n elif a == b:\n sum_a = sum_a + a\n sum_b = sum_b + b\n\n print(sum_a,sum_b)\n\n \n\n", "neg": "while 1:\n n = input()\n if n == 0:\n break\n \n sum_a = 0\n sum_b = 0\n \n for i in range(n):\n a,b = map(int, input().split())\n \n if a > b:\n sum_a = sum_a + a + b\n elif a < b:\n sum_b = sum_b + a + b\n elif a == b:\n sum_a = sum_a + a\n sum_b = sum_b + b\n\n print(\"%s %s\" %(sum_a,sum_b))\n\n \n\n", "jacc_sim": 0.90625, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [151, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u396445852", "n_user": "u396445852", "pos": "x = int(input())\nscore_A = 0\nscore_B = 0\nans = []\nwhile x:\n for i in range(x):\n y = [int(i) for i in input().split()]\n if y[0] > y[1]:\n score_A += sum(y)\n elif y[0] < y[1]:\n score_B += sum(y)\n else:\n score_A += y[0]\n score_B += y[1]\n ans.append([score_A,score_B])\n score_A = 0 ; score_B = 0\n x = int(input())\nfor i in ans:\n print(*i)\n", "neg": "x = int(input())\nscore_A = 0\nscore_B = 0\nans = []\nwhile x:\n for i in range(x):\n y = [int(i) for i in input().split()]\n if y[0] > y[1]:\n score_A += sum(y)\n elif y[0] < y[1]:\n score_B += sum(y)\n else:\n score_A += y[0]\n score_B += y[1]\n ans.append([score_A,score_B])\n score_A = 0 ; score_B = 0\n x = int(input()\nfor i in ans:\n print(*i)\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [169, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u078042885", "n_user": "u078042885", "pos": "while 1:\n n=int(input())\n if n==0: break\n a=b=0\n while n:\n c,d=map(int,input().split())\n if cd:a+=c+d\n else:\n a+=c\n b+=c\n n-=1\n print(a,b)", "neg": "while 1:\n n=int(input())\n if n==0: break\n a=b=0\n while n:\n c,d=map(int,input().split())\n if cd:a+=c+d\n else:\n a+=c\n b+=c\n n-=1\n print(a,b)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [101, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u052758509", "n_user": "u052758509", "pos": "def _resulting(ab):\n a, b = 0, 0\n for itr in ab:\n if itr[0] > itr[1]:\n a = a + (itr[0] + itr[1])\n elif itr[0] < itr[1]:\n b = b + (itr[0] + itr[1])\n else:\n a = a + itr[0]\n b = b + itr[1]\n return a, b\n\n\nif __name__ == '__main__':\n while True:\n N = int(input())\n if N != 0:\n ab = []\n\n for itr in range(0, N):\n ab.append(list(map(int, input().split())))\n\n a, b = _resulting(ab)\n\n print(a, b)\n else:\n break", "neg": "def _resulting(ab):\n a, b = 0, 0\n for itr in ab:\n if itr[0] > itr[1]:\n a = a + (itr[0] + itr[1])\n elif itr[0] < itr[1]:\n b = b + (itr[0] + itr[1])\n else:\n a = a + itr[0]\n b = b + itr[1]\n return a, b\n\n\nif __name__ == '__main__':\n N = int(input())\n ab = []\n\n for itr in range(0, N):\n ab.append(list(map(int, input().split())))\n\n a, b = _resulting(ab)\n print(a, b)", "jacc_sim": 0.9024390243902439, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [206, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u243053043", "n_user": "u243053043", "pos": "while True:\n n_line = input()\n if n_line == \"0\":\n break\n score_a, score_b = (0, 0)\n for i in range(int(n_line)):\n a, b = [int(x) for x in input().split(\" \")]\n if a > b:\n score_a += a + b\n elif a < b:\n score_b += a + b\n else:\n score_a += a\n score_b += b\n print(\"{} {}\".format(score_a, score_b))", "neg": "while True:\n n_line = input()\n if n_line == \"0\":\n break\n score_a, score_b = (0, 0)\n for i in range(int(n_line)):\n a, b = [int(x) for x in input().split(\" \")]\n if a >= b:\n score_a += a\n if a <= b:\n score_b += b\n print(\"{} {}\".format(score_a, score_b))", "jacc_sim": 0.9444444444444444, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [140, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u340500592", "n_user": "u340500592", "pos": "A_cards, B_cards = [], []\nA_result, B_result = 0, 0\n\nwhile True:\n n = int(input())\n \n if n == 0:\n break\n\n for i in range(n):\n A, B = map(int, input().split())\n A_cards.append(A)\n B_cards.append(B)\n if A_cards[i] > B_cards[i]:\n A_result += A_cards[i] + B_cards[i]\n elif A_cards[i] < B_cards[i]:\n B_result += A_cards[i] + B_cards[i]\n elif A_cards[i] == B_cards[i]:\n A_result += A_cards[i]\n B_result += B_cards[i]\n print('{} {}'.format(A_result, B_result))\n \n A_cards, B_cards = [], []\n A_result, B_result = 0, 0", "neg": "A_cards, B_cards = [], []\nA_result, B_result = 0, 0\n\nwhile True:\n n = int(input())\n \n if n == 0:\n break\n\n for i in range(n):\n A, B = map(int, input().split())\n A_cards.append(A)\n B_cards.append(B)\n if A_cards[i] > B_cards[i]:\n A_result += A_cards[i] + B_cards[i]\n elif A_cards[i] < B_cards[i]:\n B_result += A_cards[i] + B_cards[i]\n else:\n A_result += A_cards[i]\n B_result += B_cards[i]\n print('{} {}'.format(A_result, B_result))", "jacc_sim": 0.9743589743589743, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [265, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u928329738", "n_user": "u928329738", "pos": "while True:\n n = int(input())\n if n == 0:break\n sumA = sumB = 0\n for i in range(n):\n c = list(map(int,input().split()))\n if c[0]==c[1]:\n sumA = sumA+c[0]\n sumB = sumB+c[1]\n else:\n sumA = sumA + (c[0]+c[1] if c[0]>c[1] else 0)\n sumB = sumB + (c[0]+c[1] if c[1]>c[0] else 0)\n print(sumA, sumB)", "neg": "while True:\n n = int(input())\n if n == 0:break\n sumA = sumB = 0\n for i in range(n):\n c = list(map(int,input().split()))\n if c[0]==c[1]:\n sumA = sumA+c[0]\n sumB = sumB+c[1]\n else:\n sumA = sumA + (c[0]+c[1] if c[0]>c[1] else 0)\n sumB = sumB + (c[0]+c[1] if c[1]>c[0] else 0)\n print(sumA, \" \" , sumB)", "jacc_sim": 0.9696969696969697, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [162, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n score = {\"A\": 0, \"B\": 0}\n for _ in range(n):\n A, B = map(int, input().split())\n if A > B:\n score[\"A\"] += A+B\n elif A < B:\n score[\"B\"] += A+B\n else:\n score[\"A\"] += A\n score[\"B\"] += B\n print(score[\"A\"], score[\"B\"])", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n score = {\"A\": 0, \"B\": 0}\n for _ in range(n):\n A, B = map(int, input().split())\n if A > B:\n score[\"A\"] += A\n elif A < B:\n score[\"B\"] += B\n else:\n score[\"A\"] += A\n score[\"B\"] += B\n print(score[\"A\"], score[\"B\"])", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [126, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n score = [0, 0]\n for _ in range(n):\n A, B = map(int, input().split())\n if A == B:\n score[0] += A\n score[1] += B\n else:\n score[A < B] += A+B\n print(*score)", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n score = [0, 0]\n for _ in range(n):\n A, B = map(int, input().split())\n if A == B:\n score += [A, B]\n else:\n score[A < B] += A+B\n print(*score)", "jacc_sim": 0.967741935483871, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [98, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u150984829", "n_user": "u150984829", "pos": "while 1:\n a=b=0;n=int(input())\n if n==0:break\n for i in[0]*n:\n s,t=map(int,input().split())\n if s>t:a+=s+t\n if st else b+=t\n print(a,b)\n", "jacc_sim": 0.96875, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [96, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\ne=sys.stdin\nwhile 1:\n a=b=0;n=int(e.readline())\n if n==0:break\n for i in[0]*n:\n s,t=map(int,e.readline().split())\n if s>t:a+=s+t\n elif st:a+=s+t\n elif s cardnum[1]:\n a += sum(cardnum)\n else:\n a += cardnum[0]\n b += cardnum[1]\n print(a,b)\n\n", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n a = 0\n b = 0\n for i in range(n):\n cardnum = [int(i) for i in input().split()]\n if cardnum[0] < cardnum[1]:\n b += sum(cardnum)\n elif cardnum[0] > cardnum[1]:\n a += sum(cardnum)\n else:\n a += cardnum[0]\n b += cardnum[1]\nprint(a,b)\n\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [137, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00423", "p_user": "u316584871", "n_user": "u801346721", "pos": "n = int(input())\nwhile (n != 0):\n A=0\n B=0\n for i in range(n):\n a,b = map(int, input().split())\n if (a>b):\n A+=(a+b)\n elif (b>a):\n B += (a+b)\n else:\n A+=a\n B+=b\n print(\"{} {}\".format(A,B))\n n = int(input())\n", "neg": "n = int(input())\nwhile n != 0:\n A = 0\n B = 0\n for i in range(n):\n a, b = map(int, input().split())\n if a > b:\n A += a + b\n elif a < b:\n B += a + b\n else:\n A += a\n B += b\n print(\"{0} {1}\".format(A, B))\n n = int(input())", "jacc_sim": 0.9411764705882353, "nl": "Title: Card Game\n\nTwo players, A and B, use cards with numbers from 0 to 9 to play a game. Each player is given n cards, which they place face down in a row. They then take turns flipping over one card at a time from left to right. The player with the higher number on their card takes both cards, and the sum of the numbers on the two cards becomes their score. If the two revealed cards have the same number, it's a tie, and each player takes one card. The game ends when all cards are revealed.\n\nThe input consists of multiple datasets, each ending with n=0. The number of datasets does not exceed 5.\n\nFor each dataset, output the scores of players A and B on a single line.\n\nExample:\nInput\n3\n9 1\n5 4\n0 8\n3\n9 1\n5 4\n1 0\n3\n9 1\n5 5\n1 8\n0\n\nOutput\n19 8\n20 0\n15 14", "before_after_length": [118, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u355726239", "n_user": "u355726239", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n dic = {}\n n = int(input())\n if n == 0:\n break\n\n for i in range(n):\n key, value = input().split()\n dic[key] = value\n\n ret = ''\n\n m = int(input())\n for i in range(m):\n s = input().strip()\n ret += dic.get(s, s)\n\n print(ret)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n dic = {}\n n = int(input())\n if n == 0:\n break\n\n for i in range(n):\n key, value = input().split()\n dic[key] = value\n print(dic)\n ret = ''\n\n m = int(input())\n for i in range(m):\n s = input().split()[0]\n ret += dic.get(s, s)\n\n print(ret)", "jacc_sim": 0.9782608695652174, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [129, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n x = int(input())\n if x == 0:\n break\n dcl = {}\n for i in range(x):\n inp = list(map(str, input().split()))\n dcl[inp[0]] = inp[1]\n ans = \"\"\n x = int(input())\n for i in range(x):\n y = str(input()[0])\n if y in dcl:\n ans += dcl[y]\n else:\n ans += y\n print(ans)", "neg": "while True:\n x = int(input())\n if x == 0:\n break\n dcl = dict()\n for i in range(x):\n inp = list(map(str, input().split()))\n dcl[inp[0]] = inp[1]\n ans = \"\"\n x = int(input())\n for i in range(x):\n y = str(input())\n if y in dcl:\n ans += dcl[y]\n else:\n ans += y\n print(ans)\n print()", "jacc_sim": 0.9166666666666666, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [130, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u354053070", "n_user": "u354053070", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n pre = \"\"\n post = \"\"\n for _ in range(n):\n l = input().strip().split()\n pre += l[0]\n post += l[1]\n m = int(input())\n data = \"\"\n for _ in range(m):\n data += input().strip()\n print(data.translate(str.maketrans(pre, post)))", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n pre = \"\"\n post = \"\"\n for _ in range(n):\n l = map(str, input().split())\n pre += l[0]\n post += l[1]\n m = int(input())\n data = \"\"\n for _ in range(m):\n data += input()\n print(data.translate(str.maketrans(pre, post)))", "jacc_sim": 0.9428571428571428, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [115, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u256256172", "n_user": "u256256172", "pos": "import sys\n\nwhile True:\n n = int(input())\n if n == 0:\n break;\n x = {}\n for i in range(n):\n k,v = input().split()\n x[k] = v\n y = []\n for i in range(int(input())):\n a = input()[0]\n if a in x:\n y.append(x[a])\n else:\n y.append(a)\n print(''.join(y))", "neg": "import sys\n\nwhile True:\n n = int(input())\n if n == 0:\n break;\n x = {}\n for i in range(n):\n k,v = sys.stdin.readline().rstrip().split()\n x[k] = v\n y = []\n for i in range(int(input()):\n a = sys.stdin.readline().rstrip()\n if a in x:\n y.append(x[a])\n else:\n y.append(a)\n print(''.join(y))", "jacc_sim": 0.9230769230769231, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [123, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n d = {}\n for _ in range(n):\n a, b = input().split()\n d[a] = b\n tmp = [input().strip() for _ in range(int(input()))]\n ans = [d[a] if a in d.keys() else a for a in tmp]\n print(\"\".join(ans))", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n d = {}\n for _ in range(n):\n a, b = input().split()\n d[a] = b\n m = int(input())\n tmp = [input().strip() for _ in range(int(input()))]\n ans = [d[a] if a in d.keys() else a for a in tmp]\n print(\"\".join(ans))", "jacc_sim": 0.9714285714285714, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [105, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u150984829", "n_user": "u150984829", "pos": "while 1:\n n=int(input())\n if n==0:break\n d={}\n for _ in[0]*n:\n k,v=input().strip().split()\n d[k]=v\n for _ in[0]*int(input()):\n e=input().strip()\n print(d[e]if e in d else e,end='')\n print()\n", "neg": "while 1:\n n=int(input())\n if n==0:break\n d={}\n for _ in[0]*n:\n k,v=input().split()\n d[k]=v\n for _ in[0]*int(input()):\n e=input()\n print(d[e]if e in d else e,end='')\n", "jacc_sim": 0.96875, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [91, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nr=lambda:sys.stdin.readline().strip()\nwhile 1:\n n=int(r())\n if n==0:break\n d={}\n for _ in[0]*n:\n k,v=r().split()\n d[k]=v\n a=''\n for _ in[0]*int(r()):\n e=r()\n a+=d[e]if e in d else e\n print(a)\n", "neg": "import sys\ns=sys.stdin\nr=readline()\nwhile 1:\n n=int(s.r)\n if n==0:break\n d={}\n for _ in[0]*n:\n k,v=s.r.strip().split()\n d[k]=v\n a=''\n for _ in[0]*int(s.readline()):\n e=s.r.strip()\n a+=d[e]if e in d else e\n print(a)\n", "jacc_sim": 0.9487179487179487, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [107, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\ns=sys.stdin.readline\nfor n in iter(s,'0\\n'):\n d={}\n for _ in[0]*int(n):\n k,v=s()[:-1].split()\n d[k]=v\n print(*[d.get(*[s()[0]]*2)for _ in[0]*int(s())],sep='')\n", "neg": "import sys\ns=sys.stdin.readline\nfor n in iter(s,'0\\n'):\n d={}\n for _ in[0]*int(n):\n k,v=s()[:-1].split()\n d[k]=v\n print(d.get(*[s()[0]]*2)for _ in[0]*int(s()),sep='')\n", "jacc_sim": 1.0, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [92, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00424", "p_user": "u847467233", "n_user": "u847467233", "pos": "# AOJ 0501: Data Conversion\n# Python3 2018.6.29 bal4u\n\nwhile True:\n\tn = int(input())\n\tif n == 0: break\n\ttbl = {}\n\tfor i in range(n):\n\t\ta, b = input().split()\n\t\ttbl[a] = b\n\tans = ''\n\tm = int(input())\n\tfor i in range(m):\n\t\ta = input()[0]\n\t\tans += tbl[a] if a in tbl else a\n\tprint(ans)\n", "neg": "# AOJ 0501: Data Conversion\n# Python3 2018.6.29 bal4u\n\nwhile True:\n\tn = int(input())\n\tif n == 0: break\n\ttbl = {}\n\tfor i in range(n):\n\t\ta, b = input().split()\n\t\tprint(\"i=\",i,a,b)\n\t\ttbl[a] = b\n\tans = ''\n\tm = int(input())\n\tfor i in range(m):\n\t\ta = input()[0]\n\t\tif a in tbl: ans += tbl[a]\n\t\telse: ans += a\n\tprint(ans)\n", "jacc_sim": 1.0, "nl": "Create a program to convert data based on a given conversion table. The characters used in the data are alphanumeric, with case sensitivity. The conversion table consists of pairs of characters separated by a space. When a character from the table appears in the data, it is converted to the second character in the pair. If a character does not appear in the table, it remains unchanged. The input file contains the conversion table (first n + 1 lines) followed by the data to be converted (starting from line n + 2). The output should be a single line without any intermediate spaces or line breaks. The input consists of multiple datasets, ending when n equals 0. The number of datasets does not exceed 5. For each dataset, output the converted string on a separate line.", "before_after_length": [131, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00437", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0 0'):\n d=[2]*-~sum(map(int,e.split()))\n f=[]\n for _ in[0]*int(input()):\n s,t,u,v=map(int,input().split())\n if v:d[s]=d[t]=d[u]=1\n else:f+=[(s,t,u)]\n for s,t,u in f:\n if d[t]*d[u]==1:d[s]=0\n if d[u]*d[s]==1:d[t]=0\n if d[s]*d[t]==1:d[u]=0\n for x in d[1:]:print(x)\n", "neg": "for e in iter(input,'0 0 0'):\n d=[2]*-~sum(map(int,e.split()))\n f=[]\n for _ in[0]*int(input()):\n s,t,u,v=map(int,input().split())\n if v:d[s]=d[t]=d[u]=1\n else:f+=[(s,t,u)]\n for s,t,u in f:\n d[s]=2*(d[t]*d[u]!=1)\n d[t]=2*(d[u]*d[s]!=1)\n d[u]=2*(d[s]*d[t]!=1)\n for x in d[1:]:print(x)\n", "jacc_sim": 0.972972972972973, "nl": "Title: Quality Inspection\n\nProblem:\nYou are responsible for quality control at a manufacturing plant for a certain machine. This machine requires power, a motor, and a cable as components. The plant has a total of a power sources, b motors, and c cables, each numbered from 1 to a, a+1 to a+b, and a+b+1 to a+b+c, respectively. Unfortunately, some of these components may be faulty. The plant needs to determine which components are faulty and which are functioning properly.\n\nThe plant conducts inspections by connecting one power source, one motor, and one cable, and testing their operation. If all three components are functioning properly, the test is marked as \"pass.\" If any one of the three components is faulty, the test is marked as \"fail.\" The precision of the machine ensures that faulty components will not accidentally pass the test.\n\nYou are given a list of inspection results. Each line in the list contains the numbers of the power source, motor, and cable used in the inspection, along with whether the test passed or failed.\n\nGiven the inspection results, create a program to categorize each component as definitely faulty, definitely functional, or undetermined based on the inspection results.\n\nInput:\nThe input consists of multiple datasets. Each dataset is formatted as follows:\n- The first line contains three integers separated by spaces: a, b, and c, representing the number of power sources, motors, and cables, respectively.\n- The second line contains a single integer N, representing the number of inspections in the results list.\n- The following N lines represent the inspection results. Each line contains four integers i, j, k, and r separated by spaces, where i, j, and k are the numbers of the power source, motor, and cable used in the inspection, and r indicates whether the test passed (r=1) or failed (r=0).\n\nConstraints: 1 \u2264 a, b, c \u2264 100, 1 \u2264 N \u2264 1000. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the following for each component (a+b+c lines in total):\n- If the component is determined to be faulty based on the inspection results, output 0.\n- If the component is determined to be functional based on the inspection results, output 1.\n- If the status of the component cannot be determined based on the inspection results, output 2.\n\nExample:\nInput\n2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0\n\nOutput\n2\n1\n1\n0\n1\n0", "before_after_length": [183, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00437", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0 0'):\n d=[2]*-~sum(map(int,e.split()))\n f=[]\n for _ in[0]*int(input()):\n s,t,u,v=map(int,input().split())\n if v:d[s]=d[t]=d[u]=1\n else:f+=[(s,t,u)]\n for s,t,u in f:\n if d[t]*d[u]==1:d[s]=0\n if d[u]*d[s]==1:d[t]=0\n if d[s]*d[t]==1:d[u]=0\n print(*d[1:],sep='\\n')\n", "neg": "for e in iter(input,'0 0 0'):\n d=[2]*-~sum(map(int,e.split()))\n f=[]\n for _ in[0]*int(input()):\n s,t,u,v=map(int,input().split())\n if v:d[s]=d[t]=d[u]=1\n else:f+=[(s,t,u)]\n for s,t,u in f:\n if d[t]*d[u]!=1:d[s]=0\n if d[u]*d[s]!=1:d[t]=0\n if d[s]*d[t]!=1:d[u]=0\n print(d[1:],sep='\\n')\n", "jacc_sim": 0.9743589743589743, "nl": "Title: Quality Inspection\n\nProblem:\nYou are responsible for quality control at a manufacturing plant for a certain machine. This machine requires power, a motor, and a cable as components. The plant has a total of a power sources, b motors, and c cables, each numbered from 1 to a, a+1 to a+b, and a+b+1 to a+b+c, respectively. Unfortunately, some of these components may be faulty. The plant needs to determine which components are faulty and which are functioning properly.\n\nThe plant conducts inspections by connecting one power source, one motor, and one cable, and testing their operation. If all three components are functioning properly, the test is marked as \"pass.\" If any one of the three components is faulty, the test is marked as \"fail.\" The precision of the machine ensures that faulty components will not accidentally pass the test.\n\nYou are given a list of inspection results. Each line in the list contains the numbers of the power source, motor, and cable used in the inspection, along with whether the test passed or failed.\n\nGiven the inspection results, create a program to categorize each component as definitely faulty, definitely functional, or undetermined based on the inspection results.\n\nInput:\nThe input consists of multiple datasets. Each dataset is formatted as follows:\n- The first line contains three integers separated by spaces: a, b, and c, representing the number of power sources, motors, and cables, respectively.\n- The second line contains a single integer N, representing the number of inspections in the results list.\n- The following N lines represent the inspection results. Each line contains four integers i, j, k, and r separated by spaces, where i, j, and k are the numbers of the power source, motor, and cable used in the inspection, and r indicates whether the test passed (r=1) or failed (r=0).\n\nConstraints: 1 \u2264 a, b, c \u2264 100, 1 \u2264 N \u2264 1000. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the following for each component (a+b+c lines in total):\n- If the component is determined to be faulty based on the inspection results, output 0.\n- If the component is determined to be functional based on the inspection results, output 1.\n- If the status of the component cannot be determined based on the inspection results, output 2.\n\nExample:\nInput\n2 2 2\n4\n2 4 5 0\n2 3 6 0\n1 4 5 0\n2 3 5 1\n0 0 0\n\nOutput\n2\n1\n1\n0\n1\n0", "before_after_length": [183, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00054", "p_user": "u744114948", "n_user": "u744114948", "pos": "while True:\n try:\n a, b, n = map(int, input().split())\n except:\n break\n\n s = str(a/b)\n sum = 0\n x = s.index(\".\")+1\n for i in s[x:x+n]:\n sum += int(i)\n\n print(sum)", "neg": "while True:\n try:\n a, b, n = map(int, input().split())\n except:\n break\n\n s = str(a/b)\n sum = 0\n x = s.index(\".\")+1\n for i in s[x:2+x]:\n sum += int(i)\n\n print(sum)", "jacc_sim": 0.9714285714285714, "nl": "Title: Sum of Decimal Digits\n\nGiven positive integers a, b, and n, consider the fraction a / b. Let f(i) denote the i-th decimal digit of this fraction, where 0 \u2264 f(i) \u2264 9. Calculate the sum, s, of f(i) from i = 1 to n.\n\nInput:\nThe input consists of multiple datasets. Each dataset contains three integers a (1 \u2264 a \u2264 1000), b (1 \u2264 b \u2264 10000), and n (1 \u2264 n \u2264 100) separated by a single space.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each dataset, output s on a new line.\n\nSample Input:\n1 2 3\n2 3 4\n5 4 3\n4 3 2\n\nOutput for the Sample Input:\n5\n24\n7\n6", "before_after_length": [85, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00056", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\ndef create_prime(n):\n prime = [1] * (n + 1)\n prime[:2] = [0, 0]\n for i in range(len(prime)):\n if prime[i]:\n for j in range(2 * i, len(prime), i):\n prime[j] = 0\n return prime\n\nsieve = create_prime(50000)\n\nprime = []\nfor i in range(25001):\n if sieve[i]:\n prime.append(i)\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n cnt = 0\n temp = n // 2\n for i in prime:\n if i > temp:\n break\n if sieve[n - i]:\n cnt += 1\n print(cnt)", "neg": "import sys\nf = sys.stdin\n\ndef create_prime(n):\n prime = [1] * (n + 1)\n prime[:2] = [0, 0]\n for i in range(len(prime)):\n if prime[i]:\n for j in range(2 * i, len(prime), i):\n prime[j] = 0\n return prime\n\nsieve = create_prime(50000)\n\nimport time\nstart = time.clock()\nprime = []\nfor i in range(25001):\n if sieve[i]:\n prime.append(i)\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n cnt = 0\n for i in prime:\n if i > n // 2 + 1:\n break\n if sieve[n - i]:\n cnt += 1\n print(cnt)\n \nprint(time.clock()-start)", "jacc_sim": 0.9148936170212766, "nl": "Goldbach's Conjecture states that any even number greater than 4 can be expressed as the sum of two prime numbers. Given an integer n, create a program to output the number of combinations of two prime numbers that sum up to n. The input n will be between 4 and 50,000, and may not necessarily be an even number. Multiple datasets will be provided, with each dataset containing a value for n. When n is 0, it signifies the end of input. The number of datasets will not exceed 10,000. For each dataset, output the number of combinations on a single line.", "before_after_length": [208, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00056", "p_user": "u546285759", "n_user": "u546285759", "pos": "import bisect\nprimes = [0,0] + [1]*49999\nfor i in range(2, 224):\n if primes[i]:\n for j in range(i*i, 50001, i):\n primes[j] = 0\n\nvalues = [k for k, b in enumerate(primes) if b]\nwhile True:\n n = int(input())\n if n == 0:\n break\n end = bisect.bisect_right(values, n//2)\n print(sum(1 for i in values[:end] if primes[n-i]))", "neg": "import bisect\nprimes = [0,0] + [1]*49999\nfor i in range(2, 224):\n if primes[i]:\n for j in range(i*i, 50001, i):\n primes[j] = 0\n\nvalues = [k for k, b in enumerate(primes) if b]\nwhile True:\n n = int(input())\n if n == 0:\n break\n end = bisect.bisect_left(values, n//2)\n print(sum(1 for i in values[:end] if primes[n-i]))", "jacc_sim": 0.9523809523809523, "nl": "Goldbach's Conjecture states that any even number greater than 4 can be expressed as the sum of two prime numbers. Given an integer n, create a program to output the number of combinations of two prime numbers that sum up to n. The input n will be between 4 and 50,000, and may not necessarily be an even number. Multiple datasets will be provided, with each dataset containing a value for n. When n is 0, it signifies the end of input. The number of datasets will not exceed 10,000. For each dataset, output the number of combinations on a single line.", "before_after_length": [142, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00056", "p_user": "u462831976", "n_user": "u462831976", "pos": "import sys\n\nN = 50001\nlst = [True] * N\nlst[0] = False\nlst[1] = False\nfor i in range(2, int(N ** 0.5) + 1):\n if lst[i]:\n for j in range(i * i, N, i):\n lst[j] = False\n\nprimes = [i for i in range(1, N) if lst[i]]\n\nfor s in sys.stdin:\n n = int(s)\n if n == 0:\n break\n elif n % 2 == 1:\n if lst[n - 2]:\n print(1)\n else:\n print(0)\n elif n == 4:\n print(1)\n else:\n counter = 0\n for prime0 in primes:\n prime1 = n - prime0\n if prime0 <= prime1 and lst[prime1]:\n #print(prime0, prime1)\n counter += 1\n print(counter)", "neg": "N = 50001\nlst = [True] * N\nlst[0] = False\nlst[1] = False\nfor i in range(2, int(N ** 0.5) + 1):\n if lst[i]:\n for j in range(i * i, N, i):\n lst[j] = False\n\nprimes = [i for i in range(1, N) if lst[i]]\n\nfor s in sys.stdin:\n n = int(s)\n if n == 0:\n break\n elif n % 2 == 1:\n if lst[n - 2]:\n print(1)\n else:\n print(0)\n elif n == 4:\n print(1)\n else:\n counter = 0\n for prime0 in primes:\n prime1 = n - prime0\n if prime0 <= prime1 and lst[prime1]:\n #print(prime0, prime1)\n counter += 1\n print(counter)", "jacc_sim": 0.9777777777777777, "nl": "Goldbach's Conjecture states that any even number greater than 4 can be expressed as the sum of two prime numbers. Given an integer n, create a program to output the number of combinations of two prime numbers that sum up to n. The input n will be between 4 and 50,000, and may not necessarily be an even number. Multiple datasets will be provided, with each dataset containing a value for n. When n is 0, it signifies the end of input. The number of datasets will not exceed 10,000. For each dataset, output the number of combinations on a single line.", "before_after_length": [237, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00056", "p_user": "u150984829", "n_user": "u546285759", "pos": "import bisect\nprimes = [0, 0] + [1] * 49999\nfor i in range(2, 224):\n if primes[i]:\n for j in range(i*i, 50001, i):\n primes[j] = 0\nvalues = [i for i, k in enumerate(primes) if k]\nwhile True:\n n = int(input())\n if n == 0:\n break\n I = bisect.bisect(values, n//2)\n print(len([1 for v in values[:I] if primes[n-v]]))\n", "neg": "import bisect\nprimes = [0, 0] + [1] * 49999\nfor i in range(2, 224):\n if primes[i]:\n for j in range(i*i, 50001, i):\n primes[j] = 0\nvalues = [i for i, k in enumerate(primes) if k]\nwhile True:\n n = int(input())\n if n == 0:\n break\n I = bisect.bisect(values, n//2)\n print([i for i, v in enumerate(values[:I]) if primes[n-v]][-1] + 1)", "jacc_sim": 0.975, "nl": "Goldbach's Conjecture states that any even number greater than 4 can be expressed as the sum of two prime numbers. Given an integer n, create a program to output the number of combinations of two prime numbers that sum up to n. The input n will be between 4 and 50,000, and may not necessarily be an even number. Multiple datasets will be provided, with each dataset containing a value for n. When n is 0, it signifies the end of input. The number of datasets will not exceed 10,000. For each dataset, output the number of combinations on a single line.", "before_after_length": [142, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00056", "p_user": "u352394527", "n_user": "u352394527", "pos": "MAX = 50001\n\nis_prime = [True for _ in range(MAX)]\nis_prime[0] = is_prime[1] = False\nfor i in range(2, int(MAX ** (1 / 2)) + 1):\n if is_prime[i]:\n for j in range(i ** 2, MAX, i):\n is_prime[j] = False\n\nprimes = [i for i in range(MAX) if is_prime[i]]\n\ndef main():\n while True:\n n = int(input())\n if not n:\n break\n \n ans = 0\n for i in primes:\n if i > n // 2:\n break\n if is_prime[n - i]:\n ans += 1\n \n print(ans)\n\nmain()\n", "neg": "MAX = 50001\n\nis_prime = [True for _ in range(MAX)]\nis_prime[0] = is_prime[1] = False\nfor i in range(2, int(MAX ** (1 / 2)) + 1):\n if is_prime[i]:\n for j in range(i ** 2, MAX, i):\n is_prime[j] = False\n\nprimes = [i for i in range(MAX) if is_prime[i]]\n\ndef main():\n while True:\n n = int(input())\n if not n:\n break\n \n ans = 0\n for i in primes_less_than_n:\n if is_prime[n - i]:\n ans += 1\n \n print(ans)\n\nmain()\n", "jacc_sim": 0.9487179487179487, "nl": "Goldbach's Conjecture states that any even number greater than 4 can be expressed as the sum of two prime numbers. Given an integer n, create a program to output the number of combinations of two prime numbers that sum up to n. The input n will be between 4 and 50,000, and may not necessarily be an even number. Multiple datasets will be provided, with each dataset containing a value for n. When n is 0, it signifies the end of input. The number of datasets will not exceed 10,000. For each dataset, output the number of combinations on a single line.", "before_after_length": [192, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00057", "p_user": "u350804311", "n_user": "u350804311", "pos": "while True:\n try:\n a = int(input())\n print(str(int(((a * a) + a + 2) / 2)))\n except EOFError:\n break", "neg": "while True:\n try:\n a = int(input())\n print(str(((a * a) + a + 2) / 2))\n except EOFError:\n break", "jacc_sim": 1.0, "nl": "Title: Number of Regions\n\nOn an infinitely large plane, drawing several infinitely long lines divides the plane into multiple regions. For instance, drawing one line divides the plane into two regions. The number of regions obtained by drawing the same number of lines varies depending on how the lines are drawn. For example, drawing 2 parallel lines results in 3 regions, while drawing them perpendicular to each other results in 4 regions.\n\nCreate a program to output the maximum number of regions obtained by drawing n lines.\n\nInput:\nMultiple datasets are provided. Each dataset contains n (1 \u2264 n \u2264 10,000) on a single line. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the maximum number of divisions on a single line.\n\nSample Input:\n1\n3\n\nOutput for the Sample Input:\n2\n7", "before_after_length": [45, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00057", "p_user": "u136916346", "n_user": "u136916346", "pos": "import sys\nlc=lambda n:int((n**2+n+2)/2)\n[print(i) for i in [lc(int(j)) for j in sys.stdin]]\n", "neg": "import sys\nlc=lambda n:int((n**2+n+2)/2)\n[print(i) for i in [lc(int(j)) for j in sts.stdin]]\n", "jacc_sim": 0.9583333333333334, "nl": "Title: Number of Regions\n\nOn an infinitely large plane, drawing several infinitely long lines divides the plane into multiple regions. For instance, drawing one line divides the plane into two regions. The number of regions obtained by drawing the same number of lines varies depending on how the lines are drawn. For example, drawing 2 parallel lines results in 3 regions, while drawing them perpendicular to each other results in 4 regions.\n\nCreate a program to output the maximum number of regions obtained by drawing n lines.\n\nInput:\nMultiple datasets are provided. Each dataset contains n (1 \u2264 n \u2264 10,000) on a single line. Process until the end of the input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the maximum number of divisions on a single line.\n\nSample Input:\n1\n3\n\nOutput for the Sample Input:\n2\n7", "before_after_length": [44, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00058", "p_user": "u024715419", "n_user": "u024715419", "pos": "while True:\n try:\n x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split())\n ab_x, ab_y = x_b - x_a, y_b - y_a\n cd_x, cd_y = x_d - x_c, y_d - y_c\n dp = ab_x*cd_x + ab_y*cd_y\n if abs(dp) > 1e-10:\n print(\"NO\")\n else:\n print(\"YES\")\n except:\n break\n\n", "neg": "while True:\n try:\n x_a, y_a, x_b, y_b, x_c, y_c, x_d, y_d = map(float, input().split(\",\"))\n ab_x, ab_y = x_b - x_a, y_b - y_a\n cd_x, cd_y = x_d - x_c, y_d - y_c\n dp = ab_x*cd_x + ab_y*cd_y\n if dp:\n print(\"NO\")\n else:\n print(\"YES\")\n except:\n break\n\n", "jacc_sim": 0.9024390243902439, "nl": "Title: Orthogonal Determination\n\nProblem:\nRead the coordinates of four different points on a plane, $A (x_A, y_A)$, $B (x_B, y_B)$, $C (x_C, y_C)$, $D (x_D, y_D)$. Create a program to determine if the lines $AB$ and $CD$ are orthogonal. Output \"YES\" if they are orthogonal, and \"NO\" if they are not. Note that \"line\" refers to a line segment, not a straight line.\n\nInput:\nMultiple datasets are provided. Each dataset is in the format:\n$x_A$ $y_A$ $x_B$ $y_B$ $x_C$ $y_C$ $x_D$ $y_D$\n\n$x_A$, $y_A$, $x_B$, $y_B$, $x_C$, $y_C$, $x_D$, $y_D$ are real numbers between -100 and 100, each with up to 5 decimal places.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each dataset, output \"YES\" or \"NO\" on a single line.\n\nSample Input:\n1.0 1.0 2.0 2.0 0.0 0.0 1.0 -1.0\n0.0 0.0 2.0 0.0 -1.0 2.0 2.0 2.0\n10.0 6.0 3.4 5.2 6.8 9.5 4.3 2.1\n2.5 3.5 2.5 4.5 -3.3 -2.3 6.8 -2.3\n\nOutput for the Sample Input:\nYES\nNO\nNO\nYES", "before_after_length": [156, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00059", "p_user": "u724606305", "n_user": "u075836834", "pos": "while True:\n try:\n xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2=map(float,input().split())\n except EOFError:\n break\n if xb2xa2 or yb2ya2:\n print(\"NO\")\n else:\n print(\"YES\")\n", "neg": "def solve(xa,ya1,xa1,ya2,xb1,yb1,xb2,yb2):\n\tif xb2xa2 or yb2yb2:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\n\nwhile True:\n\ttry:\n\t\txa,ya1,xa1,ya2,xb1,yb1,xb2,yb2=map(float,input().split())\n\t\tsolve(xa,ya1,xa1,ya2,xb1,yb1,xb2,yb2)\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 0.9166666666666666, "nl": "Title: Rectangle Overlap\n\nThere are two rectangles with bases parallel to the x-axis. Given the coordinates of the bottom-left and top-right corners of rectangle A (xa1, ya1), (xa2, ya2), and rectangle B (xb1, yb1), (xb2, yb2), create a program that outputs YES if rectangles A and B overlap at least partially, and NO if they do not overlap at all. Rectangles A and B are not the same, and touching is considered overlapping.\n\nInput:\nMultiple datasets are provided. Each dataset is in the following format:\nxa1 ya1 xa2 ya2 xb1 yb1 xb2 yb2\nThe input values are real numbers ranging from -2,000 to 2,000, each with up to 5 decimal places.\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output YES or NO on a single line.\n\nSample Input:\n0.0 0.0 5.0 5.0 1.0 1.0 4.0 4.0\n0.0 0.0 4.0 5.0 1.0 1.0 5.0 5.0\n0.0 0.0 4.0 4.0 -3.0 -5.0 2.0 -1.0\n\nOutput for the Sample Input:\nYES\nYES\nNO", "before_after_length": [102, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00060", "p_user": "u744114948", "n_user": "u744114948", "pos": "while True:\n try:\n a, b, c = map(int, input().split())\n except:\n break\n\n l=[True] * 11\n l[a] = l[b] = l[c] = False\n sum = a + b\n over = 0\n\n for i in range(1,11):\n if l[i]:\n if sum + i > 20:\n over += 1\n\n if over / 7 < 0.5:\n print(\"YES\")\n else:\n print(\"NO\")", "neg": "while True:\n try:\n a, b, c = map(int, input().split())\n except:\n break\n\n l=[True] * 11\n l[a] = l[b] = l[c] = False\n sum = a + b\n over = 0\n\n for i in range(1,11):\n if l[i]:\n if sum + i > 20:\n print(i)\n over += 1\n\n if over / 7 <= 0.5:\n print(\"YES\")\n else:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nThere are 10 cards numbered from 1 to 10. Each card has a number on one side and nothing on the other. You and an opponent will play a game using these cards with the following rules:\n1. Each player receives one card face up and one card face down. You can see your opponent's face-up card but not the face-down card.\n2. The winner is the player with a total card value of 20 or less, and whose total is greater than the opponent's. For example, if your cards are \"7\" and \"8\" (total 15) and your opponent's cards are \"9\" and \"10\" (total 19), your opponent wins.\n3. You and your opponent can draw one more card at most, but it's not mandatory.\n\nTo decide whether to draw another card, consider the probability of the total being 20 or less after drawing. If the probability is 50% or higher, draw a card. You can use the information of your two cards and your opponent's face-up card to calculate this probability.\n\nCreate a program that reads your two cards and your opponent's face-up card, and outputs \"YES\" if the probability of the total being 20 or less after drawing is 50% or higher, and \"NO\" otherwise.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in the format: C1 C2 C3, where C1 and C2 are your card numbers, and C3 is your opponent's face-up card number.\n\nOutput:\nFor each dataset, output \"YES\" or \"NO\" on a separate line.\n\nSample Input:\n1 2 3\n5 6 9\n8 9 10\n\nSample Output:\nYES\nYES\nNO", "before_after_length": [130, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00060", "p_user": "u078042885", "n_user": "u078042885", "pos": "while 1:\n a=[i+1 for i in range(10)]\n try:b=list(map(int,input().split()))\n except:break\n for i in b:a.remove(i)\n c=sum(b[:2])\n print(['NO','YES'][sum([1 for i in a if c+i<=20])/7>=0.5])", "neg": "while 1:\n a=[i+1 for i in range(10)]\n try:b=list(map(int,input().split()))\n except:break\n for i in b:a.remove(b)\n print('YES' if sum([1 for i in a if i<=20-sum(b[:2])])/7>=0.5 else 'NO')", "jacc_sim": 0.9318181818181818, "nl": "Title: Card Game\n\nThere are 10 cards numbered from 1 to 10. Each card has a number on one side and nothing on the other. You and an opponent will play a game using these cards with the following rules:\n1. Each player receives one card face up and one card face down. You can see your opponent's face-up card but not the face-down card.\n2. The winner is the player with a total card value of 20 or less, and whose total is greater than the opponent's. For example, if your cards are \"7\" and \"8\" (total 15) and your opponent's cards are \"9\" and \"10\" (total 19), your opponent wins.\n3. You and your opponent can draw one more card at most, but it's not mandatory.\n\nTo decide whether to draw another card, consider the probability of the total being 20 or less after drawing. If the probability is 50% or higher, draw a card. You can use the information of your two cards and your opponent's face-up card to calculate this probability.\n\nCreate a program that reads your two cards and your opponent's face-up card, and outputs \"YES\" if the probability of the total being 20 or less after drawing is 50% or higher, and \"NO\" otherwise.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in the format: C1 C2 C3, where C1 and C2 are your card numbers, and C3 is your opponent's face-up card number.\n\nOutput:\nFor each dataset, output \"YES\" or \"NO\" on a separate line.\n\nSample Input:\n1 2 3\n5 6 9\n8 9 10\n\nSample Output:\nYES\nYES\nNO", "before_after_length": [95, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00061", "p_user": "u075836834", "n_user": "u075836834", "pos": "def Inquiry(team):\n\tranking=1\n\tscore=team_score[0][1]\n\tfor i in team_score:\n\t\tif score>i[1]:\n\t\t\tranking+=1\n\t\t\tscore=i[1]\n\t\tif i[0]==team:\n\t\t\treturn ranking\n\nteam_score=[]\nwhile True:\n\n\tx,y=map(int,input().split(','))\n\tif x==y==0:\n\t\tbreak\n\tteam_score.append((x,y))\n\n#print(team_score)\nteam_score.sort(key=lambda x:x[1],reverse=True)\n#print(team_score)\n\nwhile True:\n\ttry:\n\t\tteam=int(input())\n\t\tprint(Inquiry(team))\n\t\n\texcept EOFError:\n\t\tbreak", "neg": "def Inquiry(team):\n\tranking=1\n\tscore=team_score[0][1]\n\tfor i in team_score:\n\t\tif score>i[1]:\n\t\t\tranking+=1\n\t\t\tscore=i[1]\n\t\tif i[0]==team:\n\t\t\treturn ranking\n\nteam_score=[]\nwhile True:\n\n\tx,y=map(int,input().split(','))\n\tif x==y==0:\n\t\tbreak\n\tteam_score.append((x,y))\n\nprint(team_score)\nteam_score.sort(key=lambda x:x[1],reverse=True)\nprint(team_score)\n\nwhile True:\n\ttry:\n\t\tteam=int(input())\n\t\tprint(Inquiry(team))\n\t\n\texcept EOFError:\n\t\tbreak", "jacc_sim": 0.9767441860465116, "nl": "Title: Rank Checker\n\nIn the year 2020, there is data saved from the preliminary results of the 2020 Computer Koshien. This data includes a team's assigned serial number and the number of correct answers. The ranking is determined based on the number of correct answers, with higher numbers receiving higher ranks.\n\nCreate a program that takes input from the keyboard for the preliminary results data and the serial number of the team for which the rank is to be determined, and outputs the rank of that team.\n\nInput:\nThe input data consists of two parts. The first part is the preliminary results data, and the second part is the inquiry for the team's rank. The format of the preliminary results data is as follows:\np1, s1\np2, s2\n...\n...\n0, 0\n\nWhere pi (1 \u2264 pi \u2264 100) and si (0 \u2264 si \u2264 30) represent the serial number and the number of correct answers for the i-th team. The input ends when both the serial number and the number of correct answers are 0.\n\nFollowing this, multiple inquiries are provided in the following format:\nq1\nq2\n...\n\nEach inquiry consists of one line with the serial number qi (1 \u2264 qi \u2264 30). Process these inquiries until the end of the input. The number of inquiries does not exceed 100.\n\nOutput:\nFor each inquiry, output the team's rank on a separate line.\n\nSample Input:\n1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n5\n\nOutput for the Sample Input:\n2\n2\n3\n3\n\nNote:\nIn the given input data, when the teams are sorted based on the number of correct answers, the order is as follows:\n3,30\n1,20\n2,20\n6,20\n4,10\n5,10\n\nHere, the ranking is based on the number of correct answers, with the team with 30 correct answers being 1st, those with 20 correct answers being 2nd, and those with 10 correct answers being 3rd (note that this differs from the usual ranking, considering the number of top teams with 10 correct answers).", "before_after_length": [208, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00061", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nc,d=[],{}\nfor x in iter(input,'0,0'):p,s=map(int,x.split(','));c+=[s];d[p]=s\nfor y in sys.stdin:print(sorted({*c})[::-1].index(d[int(y)])+1)\n", "neg": "import sys\nc,d=[],{}\nfor x in iter(input,'0,0'):p,s=map(int,x.split(','));c+=[s];d[p]=s\nfor y in sys.stdin:print({*c}.sort()[::-1].index(d[int(y)])+1)\n", "jacc_sim": 0.9459459459459459, "nl": "Title: Rank Checker\n\nIn the year 2020, there is data saved from the preliminary results of the 2020 Computer Koshien. This data includes a team's assigned serial number and the number of correct answers. The ranking is determined based on the number of correct answers, with higher numbers receiving higher ranks.\n\nCreate a program that takes input from the keyboard for the preliminary results data and the serial number of the team for which the rank is to be determined, and outputs the rank of that team.\n\nInput:\nThe input data consists of two parts. The first part is the preliminary results data, and the second part is the inquiry for the team's rank. The format of the preliminary results data is as follows:\np1, s1\np2, s2\n...\n...\n0, 0\n\nWhere pi (1 \u2264 pi \u2264 100) and si (0 \u2264 si \u2264 30) represent the serial number and the number of correct answers for the i-th team. The input ends when both the serial number and the number of correct answers are 0.\n\nFollowing this, multiple inquiries are provided in the following format:\nq1\nq2\n...\n\nEach inquiry consists of one line with the serial number qi (1 \u2264 qi \u2264 30). Process these inquiries until the end of the input. The number of inquiries does not exceed 100.\n\nOutput:\nFor each inquiry, output the team's rank on a separate line.\n\nSample Input:\n1,20\n2,20\n3,30\n4,10\n5,10\n6,20\n0,0\n1\n2\n4\n5\n\nOutput for the Sample Input:\n2\n2\n3\n3\n\nNote:\nIn the given input data, when the teams are sorted based on the number of correct answers, the order is as follows:\n3,30\n1,20\n2,20\n6,20\n4,10\n5,10\n\nHere, the ranking is based on the number of correct answers, with the team with 30 correct answers being 1st, those with 20 correct answers being 2nd, and those with 10 correct answers being 3rd (note that this differs from the usual ranking, considering the number of top teams with 10 correct answers).", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00063", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nprint(sum(e[:-1]==e[-2::-1]for e in sys.stdin))\n", "neg": "import sys\nprint(e[:-1]==e[-2::-1]for e in sys.stdin)\n", "jacc_sim": 0.9444444444444444, "nl": "Title: Palindrome\n\nThere is data consisting of strings of half-width alphabet characters, with each line containing data of up to 100 characters. Some lines are symmetrical (read the same from left to right and right to left). Create a program to read this data and output the number of symmetrical strings within it. Note that a line consisting of only one character is considered symmetrical.\n\nInput:\nMultiple strings are given across multiple lines. Each line contains one string, and the number of strings does not exceed 50.\n\nOutput:\nOutput the number of symmetrical strings in a single line.\n\nSample Input:\nabcba\nsx\nabcddcba\nrttrd\n\nOutput for the Sample Input:\n2", "before_after_length": [28, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00064", "p_user": "u546285759", "n_user": "u546285759", "pos": "ans = \"\"\nwhile True:\n try:\n memo = input()\n except:\n break\n for m in memo:\n ans = ans+m if m.isdigit() else ans+\"@\"\nprint(sum(map(int, ans.replace(\"@\", \" \").split())))", "neg": "ans = \"\"\nwhile True:\n try:\n memo = input()\n except:\n break\n for m in memo:\n ans = ans+m if m.isdigit() else ans+\"@\"\nprint(sum(ans.replace(\"@\", \" \").split()))", "jacc_sim": 0.9310344827586207, "nl": "Title: Passcode\n\nNew passcodes are difficult to remember. Although it's forbidden to write them down, it's hard to memorize. Therefore, I decided to embed numbers within a text to remember the passcode. Here, the sum of all the numbers will be the passcode.\n\nCreate a program that reads the embedded text and outputs the passcode.\n\nInput:\nPositive integers are embedded within multiple lines of text. Each line contains a string of characters, including alphanumeric characters, symbols, and spaces, or it may be empty. Each line is guaranteed to be within 80 characters, and the passcode is guaranteed to be less than or equal to 10,000.\n\nOutput:\nOutput the passcode (the sum of the positive integers in the text) in a single line.\n\nSample Input:\nThereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n\nOutput for the Sample Input:\n123", "before_after_length": [69, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00064", "p_user": "u350064373", "n_user": "u350064373", "pos": "import re\ntry:\n ls = []\n while True:\n ls.append(input())\nexcept:\n result = 0\n for i in ls:\n for s in re.findall(r'\\d+', i):\n result += int(s)\n print(result)", "neg": "import re\ntry:\n ls = num = []\n result = 0\n while True:\n ls.append(input())\nexcept:\n for i in ls:\n for s in range(re.findall(r'\\d+', i)):\n result += int(s)\n print(result)", "jacc_sim": 0.9393939393939394, "nl": "Title: Passcode\n\nNew passcodes are difficult to remember. Although it's forbidden to write them down, it's hard to memorize. Therefore, I decided to embed numbers within a text to remember the passcode. Here, the sum of all the numbers will be the passcode.\n\nCreate a program that reads the embedded text and outputs the passcode.\n\nInput:\nPositive integers are embedded within multiple lines of text. Each line contains a string of characters, including alphanumeric characters, symbols, and spaces, or it may be empty. Each line is guaranteed to be within 80 characters, and the passcode is guaranteed to be less than or equal to 10,000.\n\nOutput:\nOutput the passcode (the sum of the positive integers in the text) in a single line.\n\nSample Input:\nThereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n\nOutput for the Sample Input:\n123", "before_after_length": [69, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00064", "p_user": "u498511622", "n_user": "u498511622", "pos": "import re\n\nl=0\ntry:\n while True:\n x=input()\n for i in re.findall(r'\\d+',x):\n l+=int(i)\nexcept:\n print(l)", "neg": "import re\n\nl=0\ntry:\n while True:\n x=input()\n for i in re.findall(r'\\d+',x):\n lst+=int(i)\nexcept:\n print(l)", "jacc_sim": 0.9642857142857143, "nl": "Title: Passcode\n\nNew passcodes are difficult to remember. Although it's forbidden to write them down, it's hard to memorize. Therefore, I decided to embed numbers within a text to remember the passcode. Here, the sum of all the numbers will be the passcode.\n\nCreate a program that reads the embedded text and outputs the passcode.\n\nInput:\nPositive integers are embedded within multiple lines of text. Each line contains a string of characters, including alphanumeric characters, symbols, and spaces, or it may be empty. Each line is guaranteed to be within 80 characters, and the passcode is guaranteed to be less than or equal to 10,000.\n\nOutput:\nOutput the passcode (the sum of the positive integers in the text) in a single line.\n\nSample Input:\nThereare100yenonthetable.Iam17yearsold.\nIshouldgohomeat6pm.\n\nOutput for the Sample Input:\n123", "before_after_length": [55, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00065", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0065\n\"\"\"\nimport sys\nfrom collections import Counter\n\n\ndef analyze_data(this_month, last_month):\n result = []\n tm = Counter(this_month)\n lm = Counter(last_month)\n\n for ele in lm:\n if ele in tm:\n c = lm[ele] + tm[ele]\n result.append([ele, c])\n result.sort()\n return result\n\n\n\ndef main(args):\n this_month = []\n last_month = []\n month = this_month\n for line in sys.stdin:\n if len(line) == 1: # ??\\??????????????????\n month = last_month\n else:\n id, date = line.strip().split(',')\n month.append(int(id))\n # this_month = [1, 123, 56, 34, 23, 1, 23]\n # last_month = [123, 56, 123, 123, 1, 777, 777, 777]\n result = analyze_data(this_month, last_month)\n\n for d in result:\n print('{} {}'.format(d[0], d[1]))\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0065\n\"\"\"\nimport sys\nfrom collections import Counter\n\n\ndef analyze_data(this_month, last_month):\n result = []\n tm = Counter(this_month)\n lm = Counter(last_month)\n\n for ele in lm:\n if ele in tm:\n c = lm[ele] + tm[ele]\n result.append([ele, c])\n return result\n\n\n\ndef main(args):\n this_month = []\n last_month = []\n month = this_month\n for line in sys.stdin:\n if len(line) == 1: # ??\\??????????????????\n month = last_month\n else:\n id, date = line.strip().split(',')\n month.append(id)\n #this_month = [123, 56, 34]\n #last_month = [123, 56, 123]\n result = analyze_data(this_month, last_month)\n result.sort()\n\n for d in result:\n print('{} {}'.format(d[0], d[1]))\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "jacc_sim": 0.9605263157894737, "nl": "Title: Transactions\n\nThere is data recording customer numbers and transaction dates for each month. Create a program that reads the data for the current month and the previous month, and outputs the customer numbers and the number of transactions for companies that had transactions for two consecutive months, sorted by customer number. The number of transaction partners each month is within 1,000 companies.\n\nInput:\nThe data for the current month and the previous month are given separated by an empty line. Each data is given in the following format:\nc1,d1\nc2,d2\n...\n\nWhere ci (1 \u2264 ci \u2264 1,000) is an integer representing the customer number, and di (1 \u2264 di \u2264 31) is an integer representing the transaction date.\n\nOutput:\nFor companies with transactions in two consecutive months, output the customer number and the total number of transactions separated by a space, sorted in ascending order of customer number.\n\nSample Input:\n123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n\nOutput for the Sample Input:\n56 2\n123 3", "before_after_length": [352, 329], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00065", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nb=0\na=[{},{}]\nfor e in sys.stdin:\n if'\\n'==e:b=1\n else:c,_=e.split(',');c=int(c);a[b].setdefault(c,0);a[b][c]+=1\nfor k in sorted({*a[0]}&{*a[1]}):print(k,a[0][k]+a[1][k])\n", "neg": "import sys\nb=0\na=[{},{}]\nfor e in sys.stdin:\n if'\\n'==e:b=1\n else:c_=e.split(',');c=int(c);a[b].setdefault(c,0);a[b][c]+=1\nfor k in sorted({*a[0]}&{*a[1]}):print(k,a[0][k]+a[1][k])\n", "jacc_sim": 0.9473684210526315, "nl": "Title: Transactions\n\nThere is data recording customer numbers and transaction dates for each month. Create a program that reads the data for the current month and the previous month, and outputs the customer numbers and the number of transactions for companies that had transactions for two consecutive months, sorted by customer number. The number of transaction partners each month is within 1,000 companies.\n\nInput:\nThe data for the current month and the previous month are given separated by an empty line. Each data is given in the following format:\nc1,d1\nc2,d2\n...\n\nWhere ci (1 \u2264 ci \u2264 1,000) is an integer representing the customer number, and di (1 \u2264 di \u2264 31) is an integer representing the transaction date.\n\nOutput:\nFor companies with transactions in two consecutive months, output the customer number and the total number of transactions separated by a space, sorted in ascending order of customer number.\n\nSample Input:\n123,10\n56,12\n34,14\n\n123,3\n56,4\n123,5\n\nOutput for the Sample Input:\n56 2\n123 3", "before_after_length": [106, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00066", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\n\nvlines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]\n\nfor line in f:\n result = 'd'\n for v in vlines:\n if 's' != line[v[0]] and line[v[0]]== line[v[1]] == line[v[2]]:\n result = line[v[0]]\n break\n print(result)\n ", "neg": "import sys\nf = sys.stdin\n\nvlines = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]\n\nfor line in f:\n result = 'd'\n for v in vlines:\n if 's' != a and line[v[0]]== line[v[1]] == line[v[2]]:\n result = line[v[0]]\n break\n print(result)", "jacc_sim": 0.9722222222222222, "nl": "Title: Tic-Tac-Toe\n\nTic-tac-toe is a game played on a 3x3 grid where players take turns placing either a circle (\u25cb) or a cross (\u00d7) in the grid. The game is won when either circles or crosses form a line vertically, horizontally, or diagonally (refer to Figures 1-3).\n\nFigures:\n1. Circle wins\n2. Cross wins\n3. Draw\n\nIn tic-tac-toe, players take turns placing circles and crosses until one of them forms a line. Therefore, a scenario where both circles and crosses form a line simultaneously, as shown in Figure 4, is not possible. It is guaranteed that such impossible scenarios will not be given as input.\n\nFigure:\n4. Impossible scenario\n\nCreate a program that reads the tic-tac-toe board and outputs the result of the game.\n\nInput:\nThe input consists of multiple datasets. Each dataset contains a single string representing the board on one line. The board string uses lowercase letters 'o' for circles, 'x' for crosses, and 's' for empty spaces, arranged in the order of the grid shown in the diagram.\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output 'o' if circles win, 'x' if crosses win, or 'd' if the game is a draw.\n\nSample Input:\nooosxssxs\nxoosxsosx\nooxxxooxo\n\nOutput for the Sample Input:\no\nx\nd", "before_after_length": [149, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00067", "p_user": "u093607836", "n_user": "u093607836", "pos": "import itertools\n\ndef getPoint(m,x,y):\n if not (0 <= x < 12) or not (0 <= y < 12):\n return 0\n return m[y][x]\n\ndef setPoint(m,x,y,v):\n m[y][x] = v\n\nwhile 1:\n try:\n m = [list(map(int,input().strip())) for _ in range(12)]\n count = 0\n empty = False\n while not empty:\n empty = True\n for x,y in itertools.product(range(12),repeat=2):\n if(getPoint(m,x,y)):\n count += 1\n empty = False\n q = []\n q.append((x,y))\n while q != []:\n p = q.pop()\n if(getPoint(m,p[0],p[1])):\n setPoint(m,p[0],p[1],0)\n for o in [(1,0),(-1,0),(0,1),(0,-1)]:\n q.append((p[0] + o[0], p[1] + o[1]))\n print(count)\n input()\n except:\n exit()", "neg": "import itertools\n\ndef getPoint(m,x,y):\n if not (0 <= x < 12) or not (0 <= y < 12):\n return 0\n return m[y][x]\n\ndef setPoint(m,x,y,v):\n m[y][x] = v\n\nwhile 1:\n try:\n m = [list(map(int,input().strip())) for _ in range(12)]\n count = 0\n empty = False\n while not empty:\n empty = True\n for x,y in itertools.product(range(12),repeat=2):\n if(getPoint(m,x,y)):\n print(x,y)\n count += 1\n empty = False\n q = []\n q.append((x,y))\n while q != []:\n p = q.pop()\n if(getPoint(m,p[0],p[1])):\n setPoint(m,p[0],p[1],0)\n for o in [(1,0),(-1,0),(0,1),(0,-1)]:\n q.append((p[0] + o[0], p[1] + o[1]))\n print(count)\n input()\n except:\n exit()", "jacc_sim": 1.0, "nl": "Title: Island Count\n\nThere is a 12x12 grid representing the topography. Each cell is either black (land) or white (sea). Two black cells are considered connected if they are adjacent vertically or horizontally. A single black cell or a group of connected black cells form an \"island\". The task is to create a program that reads the grid data and outputs the number of islands for each dataset.\n\nInput:\nMultiple datasets are provided. Each dataset consists of a 12x12 grid represented by 12 rows of 12 numbers (0 for white, 1 for black). Datasets are separated by a single empty line. The number of datasets does not exceed 20.\n\nOutput:\nFor each dataset, output the number of islands in a single line.\n\nSample Input:\n[12x12 grid data]\n\nSample Output:\n[Number of islands for each dataset]\n\nHint:\nThe sample input is represented using \u25a0 and \u25a1.", "before_after_length": [301, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00067", "p_user": "u193025715", "n_user": "u193025715", "pos": "def fill(x, y, board):\n board[y][x] = 2\n points = [[y, x + 1], [y, x - 1], [y + 1, x], [y - 1, x]]\n\n if y == 0:\n points.remove([y-1, x])\n elif y == 11:\n points.remove([y+1, x])\n if x == 0:\n points.remove([y, x - 1])\n elif x == 11:\n points.remove([y, x + 1])\n\n for p in points:\n if board[p[0]][p[1]] == 1:\n board = fill(p[1], p[0], board)\n return board\n\nwhile True:\n try:\n islands = [list(map(int, list(input()))) for i in range(12)]\n ans = 0\n\n for y in range(12):\n for x in range(12):\n if islands[y][x] == 1:\n islands = fill(x, y, islands)\n ans += 1\n print(ans)\n input()\n except:\n break", "neg": "def fill(x, y, board):\n board[y][x] = 2\n points = [[y, x + 1], [y, x - 1], [y + 1, x], [y - 1, x]]\n # y\n if y == 0:\n points.remove([y-1, x])\n elif y == 11:\n points.remove([y+1, x])\n # x\n if x == 0:\n points.remove([y, x - 1])\n elif x == 11:\n points.remove([y, x + 1])\n for p in points:\n if board[p[0]][p[1]] == 1:\n board = fill(p[1], p[0], board)\n return board\n\nwhile True:\n try:\n islands = [list(map(int, list(input()))) for i in range(12)]\n input()\n ans = 0\n\n for y in range(12):\n for x in range(12):\n if islands[y][x] == 1:\n islands = fill(x, y, islands)\n ans += 1\n print(ans)\n except:\n break", "jacc_sim": 0.9767441860465116, "nl": "Title: Island Count\n\nThere is a 12x12 grid representing the topography. Each cell is either black (land) or white (sea). Two black cells are considered connected if they are adjacent vertically or horizontally. A single black cell or a group of connected black cells form an \"island\". The task is to create a program that reads the grid data and outputs the number of islands for each dataset.\n\nInput:\nMultiple datasets are provided. Each dataset consists of a 12x12 grid represented by 12 rows of 12 numbers (0 for white, 1 for black). Datasets are separated by a single empty line. The number of datasets does not exceed 20.\n\nOutput:\nFor each dataset, output the number of islands in a single line.\n\nSample Input:\n[12x12 grid data]\n\nSample Output:\n[Number of islands for each dataset]\n\nHint:\nThe sample input is represented using \u25a0 and \u25a1.", "before_after_length": [283, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00067", "p_user": "u873482706", "n_user": "u873482706", "pos": "def f1():\n t = 0\n for y in range(len(M)):\n for x in range(len(M[0])):\n if M[y][x] == '1':\n f2(x, y)\n t += 1\n return t\n\n\ndef f2(x, y):\n if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:\n return\n if M[y][x] == '1':\n M[y][x] = '0'\n f2(x, y-1)\n f2(x, y+1)\n f2(x+1, y)\n f2(x-1, y)\n\n\nM = []\nwhile True:\n try:\n line = input()\n if line == '':\n print(f1())\n M = []\n else:\n M.append(list(line))\n except EOFError:\n print(f1())\n break", "neg": "def f1():\n t = 0\n for y, line in enumerate(M):\n for x, cell in enumerate(line):\n if M[y][x] == '1':\n f2(x, y)\n t += 1\n return t\n\n\ndef f2(x, y):\n if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:\n return\n if M[y][x] == '1':\n M[y][x] = '0'\n f2(x, y-1)\n f2(x, y+1)\n f2(x+1, y)\n f2(x-1, y)\n\n\nM = []\nwhile True:\n try:\n line = input()\n if line == '':\n print(f1())\n M = []\n else:\n M.append(list(input()))\n except EOFError:\n print(f1())\n break", "jacc_sim": 0.9285714285714286, "nl": "Title: Island Count\n\nThere is a 12x12 grid representing the topography. Each cell is either black (land) or white (sea). Two black cells are considered connected if they are adjacent vertically or horizontally. A single black cell or a group of connected black cells form an \"island\". The task is to create a program that reads the grid data and outputs the number of islands for each dataset.\n\nInput:\nMultiple datasets are provided. Each dataset consists of a 12x12 grid represented by 12 rows of 12 numbers (0 for white, 1 for black). Datasets are separated by a single empty line. The number of datasets does not exceed 20.\n\nOutput:\nFor each dataset, output the number of islands in a single line.\n\nSample Input:\n[12x12 grid data]\n\nSample Output:\n[Number of islands for each dataset]\n\nHint:\nThe sample input is represented using \u25a0 and \u25a1.", "before_after_length": [245, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00067", "p_user": "u756426560", "n_user": "u756426560", "pos": "def remove_linked(x, y, DATA):\n DATA[x][y]=0# clear\n move = [[1, 0], [0, 1], [-1, 0], [0, -1]]#left, right, down, up\n for i, j in move:\n nx,ny=x+i,y+j#next x and y\n if -1 0:\n continue\n l_tmp[i][j] = 1\n if check_lots(m, s, l_tmp):\n d_ans = i + 1\n n_ans = j\n break\n else:\n continue\n break\n if d_ans:\n print(d_ans, n_ans)\n else:\n print(1)\n\n", "neg": "def check_lots(start, goal, line):\n for i in range(len(line)):\n for j in range(len(line[i])):\n if line[i][j] == 1:\n if j == start - 1:\n start -= 1\n elif j == start:\n start += 1\n return start == goal\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n m = int(input())\n s = int(input())\n d = int(input())\n l = []\n for i in range(d):\n l.append([0] + list(map(int, list(input()))) + [0])\n d_ans = 0\n n_ans = 0\n if check_lots(m, s, l):\n print(0)\n else:\n for i in range(d):\n for j in range(1, n):\n l_tmp = l[:]\n if sum(l_tmp[i][j-1:j+2]) > 0:\n continue\n l_tmp[i][j] = 1\n if check_lots(m, s, l_tmp):\n d_ans = i + 1\n n_ans = j\n break\n else:\n continue\n break\n if d_ans:\n print(d_ans, n_ans)\n else:\n print(1)\n\n", "jacc_sim": 0.9411764705882353, "nl": "Title: \u3042\u307f\u3060\u304f\u3058 II\n\nThere are n vertical lines for a given amida. The amida satisfies the following conditions:\n- Horizontal lines are drawn straight across and do not slant.\n- Horizontal lines always connect adjacent vertical lines and do not cross over other vertical lines.\n- No vertical line has horizontal lines coming out from both sides simultaneously.\n- There is only one winning path.\n\nThe program should determine if it's possible to reach the winning path by adding a single horizontal line at any position in the given amida. The input consists of multiple datasets, each containing:\n- The number of vertical lines, n (1 < n \u2264 10).\n- The selected vertical line number, m (1 \u2264 m \u2264 n).\n- The position of the winning path (represented by a star in the diagram).\n- The number of levels in the amida, d (1 \u2264 d \u2264 30).\n- The arrangement of horizontal lines (1 for present, 0 for absent) between each pair of vertical lines from top to bottom.\n\nThe input ends with a line containing a single 0.\n\nFor each dataset, the program should output:\n- 0 if it's possible to reach the winning path without adding a horizontal line.\n- The position of the closest horizontal line to the starting side if adding one horizontal line allows reaching the winning path.\n- 1 if adding a horizontal line still doesn't allow reaching the winning path.\n\nSample Input:\n5\n2\n3\n9\n1010\n1001\n0100\n1001\n0010\n1000\n0100\n0101\n1010\n0\n\nOutput for the Sample Input:\n6 4", "before_after_length": [354, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00074", "p_user": "u150984829", "n_user": "u150984829", "pos": "p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')\nfor e in iter(input,'-1 -1 -1'):\n h,m,s=map(int,e.split())\n d=7200-h*3600-m*60-s\n p(d);p(d*3)\n", "neg": "p=lambda x:print(f'{x//3600:02}:{x//60%60:02}:{x%60:02}')\nfor e in iter(input,'-1\\n'):\n h,m,s=map(int,e.split())\n d=7200-h*3600-m*60-s\n p(d);p(d*3)\n", "jacc_sim": 0.9487179487179487, "nl": "Title: Video Tape\n\nThere is a 120-minute video tape in standard recording mode. When the tape is completely rewound and recorded in standard mode, a certain counter value is reached. Create a program that takes this counter value (hours, minutes, seconds) as input, and calculates the remaining tape length (recordable time) and outputs it in the format of hours:minutes:seconds.\n\nInput:\nMultiple data sets are given. Each data set is as follows:\nT H S\nT, H, S are integers representing hours, minutes, and seconds.\nWhen T, H, S are all -1, it marks the end of input. The number of data sets does not exceed 50.\n\nOutput:\nFor each data set:\nOn the 1st line, output the remaining tape length for standard recording in hours, minutes, seconds separated by a colon.\nOn the 2nd line, output the remaining tape length for 3 times recording in hours, minutes, seconds separated by a colon.\n\nSample Input:\n1 30 0\n-1 -1 -1\n\nOutput for the Sample Input:\n00:30:00\n01:30:00", "before_after_length": [90, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00075", "p_user": "u711765449", "n_user": "u711765449", "pos": "def bmi(w,h):\n return w / (h ** 2)\n\ns,w,h = [],[],[]\nwhile True:\n try:\n tmp = input().split(',')\n s.append(int(tmp[0]))\n w.append(float(tmp[1]))\n h.append(float(tmp[2]))\n except EOFError:\n break\nf = []\nfor i in range(len(s)):\n if bmi(w[i],h[i]) >= 25:\n f.append(s[i])\nif len(f) != 1 and len(f) != 0:\n for i in range(len(f)-1):\n print(f[i])\nif len(f) != 1 and len(f) != 0:\n print(f[-1])\nelif len(f) == 1:\n print(f[0])", "neg": "def bmi(w,h):\n return w / (h ** 2)\n\ns,w,h = [],[],[]\nwhile True:\n try:\n tmp = input().split(',')\n s.append(float(tmp[0]))\n w.append(float(tmp[1]))\n h.append(float(tmp[2]))\n except EOFError:\n break\nf = []\nfor i in range(len(s)):\n if bmi(w[i],h[i]) >= 25:\n f.append(s[i])\nif len(f) != 1 and len(f) != 0:\n for i in range(len(f)-1):\n print(f[i])\nif len(f) != 1 and len(f) != 0:\n print(f[-1])\nelif len(f) == 1:\n print(f[0])", "jacc_sim": 0.9782608695652174, "nl": "Title: BMI\n\nObesity is considered a cause of many adult diseases. In the past, it was largely irrelevant to high school students, except for a few exceptions. However, due to excessive exam preparation leading to lack of exercise or stress-induced overeating, it has become increasingly realistic. This may become a significant concern for high school students.\n\nYou are tasked with creating a program as an assistant to the school nurse to identify students with suspected obesity based on their data.\n\nThe method involves calculating the BMI (Body Mass Index) using the following formula:\n\nBMI = weight / (height * height)\n\nA BMI of 22 is considered standard, and above 25 indicates suspected obesity.\n\nCreate a program that calculates the BMI for each student based on their weight and height, and outputs the student ID for those with a BMI of 25 or higher.\n\nInput:\nThe input is given in the following format:\ns1, w1, h1\ns2, w2, h2\n...\n\nWhere si (1 \u2264 si \u2264 2,000), wi (1 \u2264 wi \u2264 200), and hi (1.0 \u2264 hi \u2264 2.0) represent the student ID (integer), weight (real number), and height (real number) for the ith student.\n\nThere are no more than 50 students.\n\nOutput:\nOutput the student ID of those with a BMI of 25 or higher in the order they were inputted, each on a new line.\n\nSample Input:\n1001,50.0,1.60 \n1002,60.0,1.70 \n1003,70.0,1.80 \n1004,80.0,1.70 \n1005,90.0,1.60 \n\nOutput for the Sample Input:\n1004\n1005", "before_after_length": [215, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00075", "p_user": "u350064373", "n_user": "u350064373", "pos": "try:\n while True: \n s, w, h = map(float, input().split(','))\n if w / h**2 >= 25:\n print(int(s))\nexcept:\n pass", "neg": "try:\n s, w, h = map(float, input().split(','))\n if w / h**2 >= 25:\n print(int(s))\nexcept:\n pass", "jacc_sim": 0.9259259259259259, "nl": "Title: BMI\n\nObesity is considered a cause of many adult diseases. In the past, it was largely irrelevant to high school students, except for a few exceptions. However, due to excessive exam preparation leading to lack of exercise or stress-induced overeating, it has become increasingly realistic. This may become a significant concern for high school students.\n\nYou are tasked with creating a program as an assistant to the school nurse to identify students with suspected obesity based on their data.\n\nThe method involves calculating the BMI (Body Mass Index) using the following formula:\n\nBMI = weight / (height * height)\n\nA BMI of 22 is considered standard, and above 25 indicates suspected obesity.\n\nCreate a program that calculates the BMI for each student based on their weight and height, and outputs the student ID for those with a BMI of 25 or higher.\n\nInput:\nThe input is given in the following format:\ns1, w1, h1\ns2, w2, h2\n...\n\nWhere si (1 \u2264 si \u2264 2,000), wi (1 \u2264 wi \u2264 200), and hi (1.0 \u2264 hi \u2264 2.0) represent the student ID (integer), weight (real number), and height (real number) for the ith student.\n\nThere are no more than 50 students.\n\nOutput:\nOutput the student ID of those with a BMI of 25 or higher in the order they were inputted, each on a new line.\n\nSample Input:\n1001,50.0,1.60 \n1002,60.0,1.70 \n1003,70.0,1.80 \n1004,80.0,1.70 \n1005,90.0,1.60 \n\nOutput for the Sample Input:\n1004\n1005", "before_after_length": [50, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00075", "p_user": "u136916346", "n_user": "u136916346", "pos": "import sys\nl=[list(map(float,i.split(\",\"))) for i in sys.stdin]\nbmi=lambda i:i[1]/(i[2]**2)\n[print(int(i[0])) for i in l if bmi(i)>=25]\n", "neg": "import sys\nl=[list(map(float,i.split(\",\"))) for i in sys.stdin]\nbmi=lambda i:i[1]/(i[2]**2)\n[print(int(i[0])) for i in l bmi(i)>=25]\n", "jacc_sim": 0.96875, "nl": "Title: BMI\n\nObesity is considered a cause of many adult diseases. In the past, it was largely irrelevant to high school students, except for a few exceptions. However, due to excessive exam preparation leading to lack of exercise or stress-induced overeating, it has become increasingly realistic. This may become a significant concern for high school students.\n\nYou are tasked with creating a program as an assistant to the school nurse to identify students with suspected obesity based on their data.\n\nThe method involves calculating the BMI (Body Mass Index) using the following formula:\n\nBMI = weight / (height * height)\n\nA BMI of 22 is considered standard, and above 25 indicates suspected obesity.\n\nCreate a program that calculates the BMI for each student based on their weight and height, and outputs the student ID for those with a BMI of 25 or higher.\n\nInput:\nThe input is given in the following format:\ns1, w1, h1\ns2, w2, h2\n...\n\nWhere si (1 \u2264 si \u2264 2,000), wi (1 \u2264 wi \u2264 200), and hi (1.0 \u2264 hi \u2264 2.0) represent the student ID (integer), weight (real number), and height (real number) for the ith student.\n\nThere are no more than 50 students.\n\nOutput:\nOutput the student ID of those with a BMI of 25 or higher in the order they were inputted, each on a new line.\n\nSample Input:\n1001,50.0,1.60 \n1002,60.0,1.70 \n1003,70.0,1.80 \n1004,80.0,1.70 \n1005,90.0,1.60 \n\nOutput for the Sample Input:\n1004\n1005", "before_after_length": [68, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u932203900", "n_user": "u932203900", "pos": "import sys\nfor line in sys.stdin:\n appendStrs = []\n line = line.strip()\n for i in range(0, len(line) ) :\n if line[i] == \"@\" :\n appendStrs.append((line[i:i+3], \"\".join([ line[i+2] for _ in range(0, int(line[i+1]) )]))) ;\n for a in appendStrs :\n line = line.replace(*a, 1)\n print(line)\n\n", "neg": "\nimport sys\nfor line in sys.stdin:\n appendStrs = []\n for i in range(0, len(line) ) :\n if line[i] == \"@\" :\n appendStrs.append((line[i:i+3], \"\".join([ line[i+2] for _ in range(0, int(line[i+1]) )]))) ;\n for a in appendStrs :\n line = line.replace(*a, 1)\n print(line)\n\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [121, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u197615397", "n_user": "u197615397", "pos": "import re\nimport sys\nfor s in sys.stdin:\n print(re.sub(r\"@(\\d)(.)\", lambda m: m.group(2)*int(m.group(1)), s.rstrip()))\n", "neg": "import re\nimport sys\nfor s in sys.stdin:\n print(re.sub(r\"@(\\d)(.)\", lambda m: m.group(2)*int(m.group(1)), s))\n", "jacc_sim": 0.9629629629629629, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [55, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u846356981", "n_user": "u846356981", "pos": "import sys\n\n\ndef method(l):\n idx = l.find('@')\n return l if idx < 0 else method(l.replace(l[idx:idx+3], l[idx+2]*int(l[idx+1])))\n\nfor line in sys.stdin:\n print(method(line.replace('\\n', '')))", "neg": "import sys\n\n\ndef method(l):\n idx = l.find('@')\n return l if idx < 0 else method(l.replace(l[idx:idx+3], l[idx+2]*int(l[idx+1])))\n\nfor line in sys.stdin:\n print(method(line))", "jacc_sim": 0.9444444444444444, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [82, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u075836834", "n_user": "u075836834", "pos": "while True:\n\ttry:\n\t\tline=list(map(str,input()))\n\t\tstring=\"\"\n\t\tfor i in range(len(line)):\n\t\t\tif (line[i]!='@' and line[i-1]!='@' and line[i-2]!='@'):\n\t\t\t\tstring+=line[i]\n\t\t\telif line[i]=='@':\n\t\t\t\tstring+=line[i+2]*int(line[i+1])\n\t\t\telse:\n\t\t\t\tpass\n\t\tprint(string)\n\texcept EOFError:\n\t\tbreak\n\t\t\n\t\t\t\t", "neg": "while True:\n\ttry:\n\t\tline=list(map(str,input()))\n\t\tstring=\"\"\n\t\tfor i in range(len(line)):\n\t\t\tif (line[i]!='@' and line[i-1]!='@'):\n\t\t\t\tstring+=line[i]\n\t\t\telif line[i]=='@':\n\t\t\t\tstring+=line[i+2]*int(line[i+1])\n\t\t\telse:\n\t\t\t\tpass\n\t\tprint(string)\n\texcept EOFError:\n\t\tbreak\n\t\t\n\t\t\t\t", "jacc_sim": 1.0, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [145, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u546285759", "n_user": "u546285759", "pos": "import sys\n\nfor line in sys.stdin:\n line = line.strip()\n i = 0\n ans = \"\"\n while i < len(line):\n if line[i] == \"@\":\n m = int(line[i+1])\n c = line[i+2]\n i += 3\n ans += m*c\n else:\n ans += line[i]\n i += 1\n print(ans)", "neg": "import sys\n\nfor line in sys.stdin:\n line = line.strip()\n i = 0\n ans = \"\"\n while i < len(line):\n if line[i] == \"@\":\n m = int(line[i+1])\n c = line[i+2]\n i += 2\n ans += m*c\n else:\n ans += line[i]\n i += 1\n print(ans)", "jacc_sim": 0.9696969696969697, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [105, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00077", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfor e in sys.stdin:\n a='';b=n=0\n for c in e[:-1]:\n if'@'==c:b=1\n elif b&1:n=int(c);b=2\n elif b&2:a+=c*n;b=0\n else:a+=c\n print(a)\n", "neg": "import sys\nfor e in sys.stdin:\n a='';b=n=0\n for c in e:\n if'@'==c:b=1\n elif b&1:n=int(c);b=2\n elif b&2:a+=c*n;b=0\n else:a+=c\n print(a)\n", "jacc_sim": 0.90625, "nl": "Title: Run Length Encoding\n\nWhen a string has consecutive characters, it can be compressed by replacing the characters according to a certain rule. For example, the string \"AAAA\" can be compressed to \"@4A\", representing a one-character compression. Create a program that can restore the original string from the compressed string based on this rule. The restored string should not contain the \"@\" character.\n\nThe original string consists of uppercase and lowercase English letters, digits, and symbols, with a length of up to 100 characters and consecutive characters not exceeding 9.\n\nInput:\nMultiple strings are provided, with one string per line. The number of strings does not exceed 50.\n\nOutput:\nFor each string, output the restored string for each character on a separate line.\n\nSample Input:\nab@5C1@8050\n@99+1=1@90\n\nOutput for the Sample Input:\nabCCCCC10000000050\n999999999+1=1000000000", "before_after_length": [86, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00078", "p_user": "u519227872", "n_user": "u519227872", "pos": "from sys import stdin\ndef sqmatrix(n):\n return [[0] * n for i in range(n)]\n\ndef magicsq(m):\n n = len(m)\n j = int(n/2)\n i = j + 1\n for num in range(1, n**2 + 1):\n m[i][j] = num\n i += 1\n j += 1\n i = i%n\n j = j % n\n if m[i][j] != 0:\n i += 1\n j -= 1\n if j < 0:\n j = n -1\n i = i % n\n return m\n\nfor line in stdin:\n n = int(line)\n if n == 0:\n break\n sm = sqmatrix(n)\n for row in magicsq(sm): print (''.join(map(lambda x: str(x).rjust(4, ' '),row)))", "neg": "from sys import stdin\ndef sqmatrix(n):\n return [[0] * n for i in range(n)]\n\ndef magicsq(m):\n n = len(m)\n j = int(n/2)\n i = j + 1\n for num in range(1, n**2 + 1):\n m[i][j] = num\n i += 1\n j += 1\n i = i%n\n j = j % n\n if m[i][j] != 0:\n i += 1\n j -= 1\n if j < 0:\n j = n -1\n i = i % n\n return m\n\nfor line in stdin:\n n = int(line)\n if n == 0:\n break\n sm = sqmatrix(n)\n for row in magicsq(sm): print (' '.join(map(str,row)))", "jacc_sim": 0.92, "nl": "Magic Square\n\nAn n \u00d7 n square grid contains numbers from 1 to n \u00d7 n, with each number appearing exactly once. A magic square is one in which the sum of each column, each row, and each diagonal is equal.\n\nFor creating an odd-sized magic square, the following method can be used:\n1. Place 1 in the square just below the center.\n2. Place the next number in the square diagonally down to the right. If the square is out of bounds or already filled, follow specific rules to find the next square.\n3. Repeat steps 1 and 2 until all squares are filled.\n\nCreate a program that takes the size of the square, n, as input and outputs the magic square of that size. The input n is an odd number between 3 and 15. Each number in the square should be output with 4 digits, right-aligned.\n\nInput\nMultiple inputs are given. Each input provides a positive integer n on a single line. The input ends with 0. There will be no more than 10 inputs.\n\nOutput\nFor each input, output the n \u00d7 n magic square.\n\nSample Input\n3\n5\n0\n\nOutput for the Sample Input\n 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15", "before_after_length": [226, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00078", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0078\n\"\"\"\nimport sys\n\n\n\nclass MagicSquare():\n def __init__(self, size):\n self.size = size\n self.data = [['@']*self.size for _ in range(self.size)]\n self.fill_data()\n\n def fill_data(self):\n num = 1\n x = self.size // 2\n y = x + 1\n self.data[y][x] = num\n\n while num < self.size**2:\n x += 1\n if x >= self.size:\n x = 0\n y += 1\n if y >= self.size:\n y = 0\n if self.data[y][x] == '@':\n num += 1\n self.data[y][x] = num\n else:\n while self.data[y][x] != '@':\n x -= 1\n if x < 0:\n x = self.size - 1\n y += 1\n if y >= self.size:\n y = 0\n num += 1\n self.data[y][x] = num\n\n def print_data(self):\n for row in self.data:\n temp = \"\"\n for d in row:\n temp += str(d).rjust(4)\n print(temp)\n temp = \"\"\n\n\n\ndef main(args):\n while True:\n size = int(input())\n if size < 3 or size%2 == 0:\n break\n ms = MagicSquare(size)\n ms.print_data()\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0078\n\"\"\"\nimport sys\n\n\n\nclass MagicSquare():\n def __init__(self, size):\n self.size = size\n self.data = [['@']*self.size for _ in range(self.size)]\n self.fill_data()\n\n def fill_data(self):\n num = 1\n x = self.size // 2\n y = x + 1\n self.data[y][x] = num\n\n while num < self.size**2:\n x += 1\n if x >= self.size:\n x = 0\n y += 1\n if y >= self.size:\n y = 0\n if self.data[y][x] == '@':\n num += 1\n self.data[y][x] = num\n else:\n while self.data[y][x] != '@':\n x -= 1\n if x < 0:\n x = self.size - 1\n y += 1\n if y >= self.size:\n y = 0\n num += 1\n self.data[y][x] = num\n\n def print_data(self):\n digits = len(str(self.size**2))\n for row in self.data:\n print(*row)\n\n\ndef main(args):\n while True:\n size = int(input())\n if size < 3 or size%2 == 0:\n break\n ms = MagicSquare(size)\n ms.print_data()\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "jacc_sim": 0.925, "nl": "Magic Square\n\nAn n \u00d7 n square grid contains numbers from 1 to n \u00d7 n, with each number appearing exactly once. A magic square is one in which the sum of each column, each row, and each diagonal is equal.\n\nFor creating an odd-sized magic square, the following method can be used:\n1. Place 1 in the square just below the center.\n2. Place the next number in the square diagonally down to the right. If the square is out of bounds or already filled, follow specific rules to find the next square.\n3. Repeat steps 1 and 2 until all squares are filled.\n\nCreate a program that takes the size of the square, n, as input and outputs the magic square of that size. The input n is an odd number between 3 and 15. Each number in the square should be output with 4 digits, right-aligned.\n\nInput\nMultiple inputs are given. Each input provides a positive integer n on a single line. The input ends with 0. There will be no more than 10 inputs.\n\nOutput\nFor each input, output the n \u00d7 n magic square.\n\nSample Input\n3\n5\n0\n\nOutput for the Sample Input\n 4 9 2\n 3 5 7\n 8 1 6\n 11 24 7 20 3\n 4 12 25 8 16\n 17 5 13 21 9\n 10 18 1 14 22\n 23 6 19 2 15", "before_after_length": [436, 419], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00082", "p_user": "u193025715", "n_user": "u193025715", "pos": "mgr = [4, 1, 4, 1, 2, 1, 2, 1]\n\nwhile True:\n try:\n p = list(map(int, input().split(' ')))\n v = []\n for i in range(8):\n q = mgr[i:] + mgr[:i]\n sum_v = sum(p) - sum(p[j]-q[j] if p[j]-q[j] >= 0 else 0 for j in range(8))\n v.append(sum_v)\n if v.count(max(v)) > 1:\n mv = max(v)\n ans = []\n for i in range(8):\n if v[i] == mv:\n ans.append(int(\"\".join(map(str, mgr[i:] + mgr[:i]))))\n print(\" \".join(list(str(min(ans)))))\n else:\n i = v.index(max(v))\n print(\" \".join(map(str, mgr[i:] + mgr[:i])))\n except:\n break", "neg": "mgr = [4, 1, 4, 1, 2, 1, 2, 1]\n\nwhile True:\n try:\n p = list(map(int, input().split(' ')))\n v = []\n for i in range(8):\n q = mgr[i:] + mgr[:i]\n sum_v = sum(p) - sum(p[j]-q[j] if p[j]-q[j] >= 0 else 0 for j in range(8))\n v.append(sum_v)\n if v.count(max(v)) > 1:\n mv = max(v)\n ans = []\n for i in range(8):\n if v[i] == mv:\n ans.append(int(\"\".join(map(str, mgr[i:] + mgr[:i]))))\n print(\" \".join(list(str(min(ans)))))\n else:\n i = v.index(max(v))\n print(mgr[i:] + mgr[:i])\n except:\n break", "jacc_sim": 1.0, "nl": "Title: Merry-Go-Round\n\nIn an amusement park, there is a merry-go-round, a classic ride where various vehicles such as horses and carriages are fixed on a large disc that rotates, causing the vehicles to move up and down. In a particular amusement park, the merry-go-round is equipped with two 4-seater carriages, two 2-seater cars, and four 1-seater horses, arranged in a specific order. Customers at the park wait at one of the eight boarding locations shown in Figure 1.\n\nThe merry-go-round always stops with the vehicles perfectly aligned with the boarding locations. Each waiting customer at locations 0 to 7 is expected to board the vehicle that stops in front of them. Customers cannot rush to another location to board a different vehicle. To efficiently entertain the customers, the stopping positions of the merry-go-round need to be adjusted to minimize the number of customers who cannot board.\n\nCreate a program that reads the number of customers waiting at locations 0 to 7 and outputs the optimal stopping positions for the vehicles to minimize the number of customers who cannot board.\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format:\np0 p1 p2 p3 p4 p5 p6 p7\n\nOutput:\nFor each dataset, output the stopping positions for the vehicles at locations 0 to 7 as c0, c1, ..., c7, separated by a space.\n\nNote: If there are multiple ways to minimize the number of customers who cannot board, output any one of those ways. The number of datasets does not exceed 100.\n\nSample Input:\n2 3 1 4 0 1 0 1\n4 2 3 2 2 2 1 1\n\nOutput for the Sample Input:\n1 4 1 4 1 2 1 2\n4 1 4 1 2 1 2 1", "before_after_length": [255, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00083", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nf = sys.stdin\n\nfrom datetime import date\n\neras = {'pre-meiji':{'start':None, 'end':date(1868,9,7)},\n'meiji':{'start':date(1868, 9, 8), 'end':date(1912,7,29)},\n'taisho':{'start':date(1912, 7, 30), 'end':date(1926,12,24)},\n'showa':{'start':date(1926, 12, 25), 'end':date(1989,1,7)},\n'heisei':{'start':date(1989, 1, 8), 'end':None}}\n\nfor line in f:\n y, m, d = map(int, line.split())\n target = date(y,m,d)\n for era_name, period in eras.items():\n if (period['start'] is None or period['start'] <= target) and(period['end'] is None or target <= period['end']):\n if era_name == 'pre-meiji':\n print(era_name)\n else:\n print(era_name, target.year - period['start'].year + 1, target.month, target.day)\n break\n ", "neg": "import sys\nf = sys.stdin\n\nfrom datetime import date\n\neras = {'pre-meiji':{'start':None, 'end':date(1868,9,7)},\n'meiji':{'start':date(1868, 9, 8), 'end':date(1912,7,29)},\n'taisho ':{'start':date(1912, 7, 30), 'end':date(1926,12,24)},\n'showa ':{'start':date(1926, 12, 25), 'end':date(1989,1,7)},\n'heisei ':{'start':date(1989, 1, 8), 'end':None}}\n\nfor line in f:\n y, m, d = map(int, line.split())\n target = date(y,m,d)\n for era_name, period in eras.items():\n if (period['start'] is None or period['start'] <= target) and(period['end'] is None or target <= period['end']):\n if era_name == 'pre-meiji':\n print(era_name)\n else:\n print(era_name, target.year - period['start'].year + 1, target.month, target.day)\n break\n ", "jacc_sim": 1.0, "nl": "Convert the given Gregorian calendar date into the corresponding Japanese era (wareki) and output the result. If the input date is before the Meiji era, output \"pre-meiji\". The first year of each era should be displayed as \"1 year\" instead of \"\u5143\u5e74\". Process multiple sets of input data until the end of input, with a maximum of 50 data sets. Output the era, year, month, and day separated by spaces on a single line, or \"pre-meiji\" if the date is before the Meiji era.", "before_after_length": [299, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00084", "p_user": "u037441960", "n_user": "u037441960", "pos": "import re\n\ns = re.split(\"[ .,]\", input())\nsl = len(s)\nans = list()\n\nfor i in range(sl) :\n if(2 < len(s[i]) and len(s[i]) < 7) :\n ans.append(s[i])\n else :\n pass\n\nansl = len(ans)\n\nfor i in range(ansl) :\n if(i == ansl - 1) :\n print(ans[i])\n else :\n print(ans[i], end = (\" \"))\n", "neg": "import re\n\ns = re.split(\"[ .,]\", input())\nsl = len(s)\nans = list()\n\nfor i in range(sl) :\n if(2 < len(s[i]) and len(s[i]) < 7) :\n ans.append(s[i])\n else :\n pass\n\nansl = len(ans)\nprint(ansl)\nfor i in range(ansl) :\n if(i == ansl - 1) :\n print(ans[i])\n else :\n print(ans[i], end = (\" \"))\n", "jacc_sim": 1.0, "nl": "Title: Search Engine\n\nInternet search engines such as Google automatically gather and categorize web pages from around the world to create a massive database. They also analyze user-input search keywords to generate queries for database searches.\n\nIn both cases, complex processing is performed to achieve efficient searches, but the basic step in all cases is to extract words from the text.\n\nYour challenge is to extract words from a given English text. For this task, the target text will be English sentences with clear word boundaries.\n\nTarget Text:\n- English text of up to 1024 characters without line breaks\n- Delimiters: spaces, periods, and commas\n- Extracted words: words with 3 to 6 characters (ignore words with 2 or fewer characters or 7 or more characters)\n\nInput:\n- A single line of English text consisting of delimiters and alphanumeric characters\n\nOutput:\n- Output the extracted words separated by a single space on a single line.\n\nSample Input:\nRain, rain, go to Spain.\n\nOutput for the Sample Input:\nRain rain Spain\n\nSample Input 2:\nWin today's preliminary contest and be qualified to visit University of Aizu.\n\nOutput for the Sample Input 2:\nWin and visit Aizu", "before_after_length": [137, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00084", "p_user": "u553058997", "n_user": "u553058997", "pos": "print(' '.join([w for w in input().replace(',', '').replace('.', '').split(' ') if len(w) > 2 and len(w) < 7]))", "neg": "print(' '.join([w for w in input().replace(',', '').replace('.', '').split(', ') if len(w) > 2 and len(w) < 7]))", "jacc_sim": 1.0, "nl": "Title: Search Engine\n\nInternet search engines such as Google automatically gather and categorize web pages from around the world to create a massive database. They also analyze user-input search keywords to generate queries for database searches.\n\nIn both cases, complex processing is performed to achieve efficient searches, but the basic step in all cases is to extract words from the text.\n\nYour challenge is to extract words from a given English text. For this task, the target text will be English sentences with clear word boundaries.\n\nTarget Text:\n- English text of up to 1024 characters without line breaks\n- Delimiters: spaces, periods, and commas\n- Extracted words: words with 3 to 6 characters (ignore words with 2 or fewer characters or 7 or more characters)\n\nInput:\n- A single line of English text consisting of delimiters and alphanumeric characters\n\nOutput:\n- Output the extracted words separated by a single space on a single line.\n\nSample Input:\nRain, rain, go to Spain.\n\nOutput for the Sample Input:\nRain rain Spain\n\nSample Input 2:\nWin today's preliminary contest and be qualified to visit University of Aizu.\n\nOutput for the Sample Input 2:\nWin and visit Aizu", "before_after_length": [41, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00084", "p_user": "u150984829", "n_user": "u546285759", "pos": "print(*filter(lambda x:2len(s[i-1])\n for j in range(k):t=j-b;s[i][j]+=max(s[i-1][t*(j>0):t+2])\nprint(*s[-1])\n", "neg": "import sys\ns=[list(map(int,e.split(',')))for e in sys.stdin]\nfor i in range(1,len(s)):\n for j in range(len(s[i])):\n t=j-len(s[i])>len(s[i-1])\n s[i][j]+=max(s[i-1][t*(j>0):t+2])\nprint(*s[-1])\n", "jacc_sim": 0.918918918918919, "nl": "Title: Shortest Path\n\nIn the given diagram, arrange integers (0 to 99) in a triangular pattern. Create a program that reads this triangular data and, starting from the top, follows a specific rule to move to the bottom, outputting the maximum sum of integers passed.\n\n- At each step, you can move to the bottom left or bottom right along the diagonal.\n \nFor example, in the given diagram, by selecting 7, 3, 8, 7, 5, 7, 8, 3, 7, the sum is maximized to 55 (7+3+8+7+5+7+8+3+7=55).\n\nInput:\nA sequence of integers separated by commas, arranged in a triangular shape as shown in the input example. There are less than 100 rows of data.\n\nOutput:\nOutput the maximum sum of integers passed according to the rule.\n\nSample Input:\n7\n3,8\n8,1,0\n2,7,4,4\n4,5,2,6,5\n2,7,4,4\n8,1,0\n3,8\n7\n\nSample Output:\n55", "before_after_length": [105, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u873482706", "n_user": "u873482706", "pos": "# -*- coding: utf-8 -*-\ni = 0\nwhile True:\n a, b = map(int, input().split())\n\n if a == 0 and b == 0:\n break\n elif i != 0:\n print()\n\n found = False\n for y in range(a, b + 1):\n if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):\n found = True\n print(y)\n if not found:\n print('NA')\n \n i += 1", "neg": "# -*- coding: utf-8 -*-\nwhile True:\n a, b = map(int, input().split())\n\n if a == 0 and b == 0:\n break\n\n found = False\n for y in range(a, b + 1):\n if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):\n if y != a:\n print()\n found = True\n print(y)\n if not found:\n print('NA')", "jacc_sim": 0.9545454545454546, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [131, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u301729341", "n_user": "u301729341", "pos": "jun = 0\nwhile True:\n num = 0\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n break\n if jun > 0:\n print()\n for i in range(a,b + 1):\n if i % 400 == 0:\n print(i)\n num += 1\n elif i % 100 == 0:\n continue\n elif i % 4 == 0:\n print(i)\n num += 1\n if num == 0:\n print(\"NA\")\n jun += 1", "neg": "num = 0\nwhile True:\n a,b = map(int,input().split())\n if a == 0 and b == 0:\n break\n for i in range(a,b + 1):\n if i % 400 == 0:\n print(i)\n num += 1\n elif i % 100 == 0:\n continue\n elif i % 4 == 0:\n print(i)\n num += 1\n if num == 0:\n print(\"NA\")\n print()", "jacc_sim": 0.9444444444444444, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [137, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u546285759", "n_user": "u546285759", "pos": "from calendar import isleap\n\nflag = False\nwhile True:\n a, b = map(int, input().split())\n if a == 0:\n break\n if flag:\n print()\n flag = True\n ans = [i for i in range(a, b+1) if isleap(i)]\n print(\"\\n\".join(map(str, ans)) if len(ans) else \"NA\")", "neg": "from calendar import isleap\n\nwhile True:\n a, b = map(int, input().split())\n if a == 0:\n break\n ans = [i for i in range(a, b+1) if isleap(i)]\n print(\"\\n\".join(map(str, ans)) if len(ans) else \"NA\")", "jacc_sim": 0.9512195121951219, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [100, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u150984829", "n_user": "u150984829", "pos": "b=0\nfor e in iter(input,'0 0'):\n if b:print()\n b=1\n s,t=map(int,e.split())\n u=[y for y in range(s,t+1)if y%4==0 and y%100!=0 or y%400==0]\n if u:\n for y in u:print(y)\n else:print('NA')\n", "neg": "b=0\nfor e in iter(input,'0 0'):\n if b:print();b=1\n s,t=map(int,e.split())\n u=[y for y in range(s,t+1)if y%4==0 and y%100!=0 or y%400==0]\n if u:\n for y in u:print(y)\n else:print('NA')\n", "jacc_sim": 0.9736842105263158, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [96, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u150984829", "n_user": "u150984829", "pos": "b=0\nfor e in iter(input,'0 0'):\n if b:print()\n b=u=1\n s,t=map(int,e.split())\n for y in range(s,t+1):\n if y%4==0 and y%100!=0 or y%400==0:print(y);u=0\n if u:print('NA')\n", "neg": "b=0\nfor e in iter(input,'0 0'):\n if b:print()\n b=u=1\n s,t=map(int,e.split())\n for y in range(s,t+1):((y%4==0)*(y%100!=0)or y%400==0)and print(y);u=0\n if u:print('NA')\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [90, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u150984829", "n_user": "u150984829", "pos": "p=print\nb=1\nfor e in iter(input,'0 0'):\n b or p()\n b=f=0;s,t=map(int,e.split())\n for y in range(s,t+1):\n if(y%4==0)*(y%100)or y%400==0:p(y);f=1\n f or p('NA')\n", "neg": "p=print\nb=0\nfor e in iter(input,'0 0'):\n if b:p()\n b=f=1;s,t=map(int,e.split())\n for y in range(s,t+1):\n if(y%4==0)*(y%100)or y%400==0:p(y);f=0\n if u:p('NA')\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [92, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00093", "p_user": "u436634575", "n_user": "u873482706", "pos": "first = True\nwhile True:\n a, b = map(int, input().split())\n if a == b == 0: break\n\n if not first: print()\n first = False\n\n count = 0\n for y in range(a, b + 1):\n if y % 400 == 0 or y % 4 == 0 and y % 100 != 0:\n count += 1\n print(y)\n if count == 0: print('NA')", "neg": "while True:\n a, b = map(int, input().split())\n\n if a == 0 and b == 0:\n break\n \n found = False\n for y in range(a, b + 1):\n if y % 4 == 0 and (y % 100 != 0 or y % 400 == 0):\n found = True\n print(y)\n if not found:\n print('NA')", "jacc_sim": 0.9210526315789473, "nl": "Title: Leap Years\n\nCreate a program that outputs all leap years between the years AD a and b. The conditions for a leap year are as follows: 0 < a \u2264 b < 3,000. If there are no leap years within the given period, output \"NA\".\n\nConditions for a leap year:\n- The year is divisible by 4.\n- However, years divisible by 100 are not leap years.\n- Years divisible by 400 are leap years.\n\nInput:\nMultiple datasets are provided in the following format:\na b\nWhen both a and b are 0, the input ends. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the years or \"NA\". Insert one empty line between datasets.\n\nSample Input:\n2001 2010\n2005 2005\n2001 2010\n0 0\n\nOutput for the Sample Input:\n2004\n2008\n\nNA\n\n2004\n2008", "before_after_length": [107, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00095", "p_user": "u519227872", "n_user": "u519227872", "pos": "from operator import itemgetter\nn = int(input())\nrs = [list(map(int,input().split())) for i in range(n)]\nrs = sorted(rs,key=itemgetter(0))\nprint(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0])))", "neg": "from operator import itemgetter\nn = int(input())\nrs = [list(map(int(),input().split())) for i in range(n)]\nrs = sorted(rs,key=itemgetter(0))\nprint(' '.join(map(str, sorted(rs, key=itemgetter(1),reverse=True)[0])))", "jacc_sim": 1.0, "nl": "Title: Ice Fishing Contest\n\nIn Hikaru Lake, an ice fishing contest for smelt was held. The person who caught the most smelt is the winner.\n\nCreate a program that reads a list of participant numbers and the number of smelt caught, and outputs the winner's number and the number of smelt caught. If there are multiple winners, output the one with the smallest participant number.\n\nInput:\nThe input is given in the following format:\nn\na1 v1\na2 v2\n...\nan vn\n\nn (1 <= n <= 20) is the number of participants. ai represents the participant number, which is a unique integer between 1 and n. vi (0 <= vi <= 100) is the number of smelt caught by participant ai.\n\nOutput:\nOutput the winner's participant number and the number of smelt caught separated by a space on a single line.\n\nInput Example:\n6\n1 14\n2 25\n3 42\n4 11\n5 40\n6 37\n\nOutput Example:\n3 42", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00099", "p_user": "u150984829", "n_user": "u150984829", "pos": "n,q=map(int,input().split())\ns=[0]*-~n\nw=m=0\nfor _ in[0]*q:\n a,v=map(int,input().split())\n s[a]+=v\n if v<0 and a==w:m=max(s);w=s.index(m)\n elif s[a]>m:w,m=a,s[a]\n elif s[a]==m and amaxv:w,m=a,s[a]\n elif s[a]==maxv:w=min(w,a)\n print(w,m)\n", "jacc_sim": 0.9473684210526315, "nl": "Title: \"Wakasagi Fishing Tournament 2\"\n\nIn Hiyohara Lake, a wakasagi fishing tournament took place. This time, catch and release is being encouraged.\n\nParticipants' numbers and the number of fish caught or released are read sequentially as events. Create a program to output the participant number and the number of fish they have at hand immediately after each event. If multiple participants have the most fish (or if all participants have 0 fish), output the one with the smallest participant number.\n\nInput:\nThe input is given in the following format:\nn q\na1 v1\na2 v2\n...\naq vq\n\nn (1 \u2264 n \u2264 1000000) represents the number of participants, and q (1 \u2264 q \u2264 100000) represents the number of events. ai (1 \u2264 ai \u2264 n) and vi (-100 \u2264 vi \u2264 100) indicate that participant ai caught or released vi fish in the ith event. vi is positive for catching, negative for releasing, and never 0.\n\nOutput:\nFor each event, output the participant number and the number of fish they have at hand, separated by a single space on one line.\n\nExample Input 1:\n3 5\n1 4 \n2 5 \n1 3\n3 6\n2 7\n\nExample Output 1:\n1 4\n2 5\n1 7\n1 7\n2 12\n\nExample Input 2:\n3 5\n1 4 \n2 5 \n2 -3\n3 4\n1 -1\n\nExample Output 2:\n1 4\n2 5\n1 4\n1 4\n3 4", "before_after_length": [122, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00099", "p_user": "u150984829", "n_user": "u150984829", "pos": "import queue\nn,q=map(int,input().split())\np=queue.PriorityQueue()\ns=[0]*-~n\nfor _ in[0]*q:\n a,v=map(int,input().split())\n s[a]+=v;p.put((-s[a],a))\n while 1:\n t=p.get()\n if -t[0]==s[t[1]]:print(t[1],-t[0]);p.put(t);break\n", "neg": "import queue\nn,q=map(int,input().split())\np=queue.PriorityQueue()\ns=[0]*-~n\nfor _ in[0]*q:\n a,v=map(int,input().split())\n s[a]+=v;p.put((-s[a],a))\n while 1:\n t=p.get();print('___',t)\n if -t[0]==s[t[1]]:print(t[1],-t[0],s);p.put(t);break\n", "jacc_sim": 0.9512195121951219, "nl": "Title: \"Wakasagi Fishing Tournament 2\"\n\nIn Hiyohara Lake, a wakasagi fishing tournament took place. This time, catch and release is being encouraged.\n\nParticipants' numbers and the number of fish caught or released are read sequentially as events. Create a program to output the participant number and the number of fish they have at hand immediately after each event. If multiple participants have the most fish (or if all participants have 0 fish), output the one with the smallest participant number.\n\nInput:\nThe input is given in the following format:\nn q\na1 v1\na2 v2\n...\naq vq\n\nn (1 \u2264 n \u2264 1000000) represents the number of participants, and q (1 \u2264 q \u2264 100000) represents the number of events. ai (1 \u2264 ai \u2264 n) and vi (-100 \u2264 vi \u2264 100) indicate that participant ai caught or released vi fish in the ith event. vi is positive for catching, negative for releasing, and never 0.\n\nOutput:\nFor each event, output the participant number and the number of fish they have at hand, separated by a single space on one line.\n\nExample Input 1:\n3 5\n1 4 \n2 5 \n1 3\n3 6\n2 7\n\nExample Output 1:\n1 4\n2 5\n1 7\n1 7\n2 12\n\nExample Input 2:\n3 5\n1 4 \n2 5 \n2 -3\n3 4\n1 -1\n\nExample Output 2:\n1 4\n2 5\n1 4\n1 4\n3 4", "before_after_length": [119, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00100", "p_user": "u566872786", "n_user": "u566872786", "pos": "while 1:\n n=int(input())\n if not n:break\n f=1\n L={}\n for a,b,c in [input().split() for i in range(n)]:\n d=int(b)*int(c)\n if a in L:\n if L[a]>=1e6:continue\n L[a]+=d\n else:L[a]=d\n if L[a]>=1e6:print(a);f=0\n if f:print('NA')", "neg": "while 1:\n n=int(input())\n if not n:break\n f=1\n L={}\n for a,b,c in [input().split() for i in range(n)]:\n if a in L:\n if L[a]>=1e6:continue\n L[a]+=d\n else:L[a]=d\n if L[a]>=1e6:\n print(a)\n f=0\n if f:print('NA')", "jacc_sim": 0.95, "nl": "Sale Result:\n\nThere is data on sales of your company. Your task is to write a program that identifies good workers. The program should read a list of data where each item includes the employee ID (i), the amount of sales (q), and the corresponding unit price (p). Then, the program should print IDs of employees whose total sales proceeds (i.e. sum of p * q) is greater than or equal to 1,000,000 in the order of inputting. If there are no such employees, the program should print \"NA\". You can suppose that n < 4000, and each employee has a unique ID. The unit price (p) is less than or equal to 1,000,000, and the amount of sales (q) is less than or equal to 100,000.\n\nInput:\nThe input consists of several datasets. The input ends with a line including a single 0. Each dataset consists of:\nn (the number of data in the list)\ni p q\ni p q\n...\ni p q\n\nOutput:\nFor each dataset, print a list of employee IDs or \"NA\".\n\nSample Input:\n4\n1001 2000 520\n1002 1800 450\n1003 1600 625\n1001 200 1220\n2\n1001 100 3\n1005 1000 100\n2\n2013 5000 100\n2013 5000 100\n0\n\nOutput for the Sample Input:\n1001\n1003\nNA\n2013", "before_after_length": [129, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u314832372", "n_user": "u314832372", "pos": "var1 = int(input())\nstr2 = \"Hoshino\"\nstr3 = \"Hoshina\"\n\n\nfor i in range(0, var1):\n\n str1 = input()\n if str1.find(str2) >= 0:\n str1 = str1.replace(str2, str3)\n print(str1)\n\n", "neg": "var1 = int(input())\nstr2 = \"Hoshino\"\nstr3 = \"Hoshina\"\n\n\nfor i in range(0, var1):\n\n str1 = input()\n if str1.find(str2) >= 0:\n str1 = str1.replace(str2, str3)\n print(str1)\n\n\n", "jacc_sim": 1.0, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [85, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u555040407", "n_user": "u555040407", "pos": "n = int(input())\n\nfor __ in range(n):\n sentence = input()\n length = 0\n\n while True:\n try:\n sentence[length]\n length += 1\n except:\n break\n \n for i in range(length-6):\n if sentence[i] == \"H\":\n if sentence[i+1] == \"o\":\n if sentence[i+2] == \"s\":\n if sentence[i+3] == \"h\":\n if sentence[i+4] == \"i\":\n if sentence[i+5] == \"n\":\n if sentence[i+6] == \"o\":\n after = \"\"\n for j in range(i+6):\n after += sentence[j]\n after += \"a\"\n for j in range(i+7,length):\n after += sentence[j]\n sentence = after\n\n print(sentence)\n", "neg": "n = int(input())\n\nfor __ in range(n):\n sentence = input()\n length = 0\n after = sentence\n\n while True:\n try:\n sentence[length]\n length += 1\n except:\n break\n \n for i in range(length-6):\n if sentence[i] == \"H\":\n if sentence[i+1] == \"o\":\n if sentence[i+2] == \"s\":\n if sentence[i+3] == \"h\":\n if sentence[i+4] == \"i\":\n if sentence[i+5] == \"n\":\n if sentence[i+6] == \"o\":\n for j in range(i+6):\n after += sentence[j]\n after += \"a\"\n for j in range(i+7,length):\n after += sentence[j]\n sentence = after\n\n print(after)\n", "jacc_sim": 1.0, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [228, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u463990569", "n_user": "u463990569", "pos": "[print(input().replace('Hoshino', 'Hoshina')) for _ in range(int(input()))]", "neg": "[print(input().replace('Hoshino', 'Hoshina')) for _ in range(int(inpu()))]", "jacc_sim": 0.9444444444444444, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [27, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u356989804", "n_user": "u356989804", "pos": "import string\n\nn=int(input())\n\nfor i in range(n):\n print(input().replace(\"Hoshino\", \"Hoshina\"))", "neg": "import string\n\nn=int(raw_input())\n\nfor i in range(n):\n print(raw_input().replace(\"Hoshino\", \"Hoshina\"))", "jacc_sim": 0.9047619047619048, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [37, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u748033250", "n_user": "u748033250", "pos": "num = int(input())\n\nfor i in range(num):\n box = input()\n print(box.replace(\"Hoshino\", \"Hoshina\"))\n ", "neg": "num = int(input())\n\nfor i in range(num):\n box = input()\n box.replace(\"Hoshino\", \"Hoshina\")\n print(box)", "jacc_sim": 1.0, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [41, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u806257385", "n_user": "u583097803", "pos": "n=int(input())\ns=[input() for i in range(n)]\n\nfor str in s:\n print(str.replace('Hoshino', 'Hoshina'))\n\n", "neg": "n=int(input())\ns=[input() for i in range(n)]\nfor i in s:\n if \"Hoshino\" in i:\n i=i.replace(\"Hoshino\",\"Hoshina\")\nfor i in s:\n print(i)", "jacc_sim": 0.9130434782608695, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [44, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00101", "p_user": "u553148578", "n_user": "u051394180", "pos": "for i in range(int(input())): print(input().replace(\"Hoshino\",\"Hoshina\"))\n", "neg": "for i in range(int(input())):\n print input().replace('Hoshino', 'Hoshina')\n", "jacc_sim": 1.0, "nl": "Title: Aizu PR\n\nAn English booklet has been created to publicize Aizu to the world. Upon careful reading, an error was found in the last name of Masayuki Hoshina, the lord of the Aizu domain. The booklet incorrectly states \"Hoshino\" instead of \"Hoshina\".\n\nTask: Write a program to replace all instances of the word \"Hoshino\" with \"Hoshina\". The text will have a maximum of 1000 characters.\n\nInput: \nThe input consists of several datasets. The first line contains the number of datasets, denoted as 'n'. Subsequently, 'n' lines of English text will be provided for each dataset.\n\nOutput:\nFor each dataset, print the converted text in a line.\n\nSample Input:\n3\nHoshino\nHashino\nMasayuki Hoshino was the grandson of Ieyasu Tokugawa.\n\nOutput for the Sample Input:\nHoshina\nHashino\nMasayuki Hoshina was the grandson of Ieyasu Tokugawa.", "before_after_length": [27, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u040533857", "n_user": "u040533857", "pos": "while True:\n data=[]\n n = int(input())\n if n==0:\n break\n for i in range(n):\n spam=list(map(int,input().split()))\n spam.append(sum(spam))\n data.append(spam)\n spam=[]\n for i in range(n+1):\n spam.append(sum(x[i] for x in data))\n data.append(spam)\n for i in range(n+1):\n for j in range(n+1):\n print('{:5}'.format(data[i][j]),end='')\n print('')", "neg": "data=[]\nwhile True:\n try:\n n = int(input())\n except:\n break\n if n==0:\n break\n for i in range(n):\n spam=list(map(int,input().split()))\n spam.append(sum(spam))\n data.append(spam)\n for j in spam:\n print('{:5}'.format(j),end='')\n print('')\n for i in range(len(data)+1):\n print('{:5}'.format(sum(x[i] for x in data)),end='')\n print('')", "jacc_sim": 0.926829268292683, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [160, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u755162050", "n_user": "u755162050", "pos": "from sys import stdin\n\nif __name__ == '__main__':\n # is_begin = False\n for n in stdin:\n if int(n) == 0:\n break\n # else:\n # if is_begin:\n # print()\n # is_begin = True\n\n bottom_total = []\n right_total = []\n for _ in range(int(n)):\n line = input().split(' ')\n total = 0\n for i, v in enumerate(line):\n print(repr(int(v)).rjust(5), end='')\n total += int(v)\n if len(bottom_total) < i + 1:\n bottom_total.append(int(v))\n else:\n bottom_total[i] += int(v)\n right_total.append(total)\n print(repr(right_total[_]).rjust(5))\n\n for num in bottom_total:\n print(repr(num).rjust(5), end='')\n print(repr(sum(bottom_total)).rjust(5))", "neg": "from sys import stdin\n\nif __name__ == '__main__':\n is_begin = False\n for n in stdin:\n if int(n) == 0:\n break\n else:\n if is_begin:\n print()\n is_begin = True\n\n bottom_total = []\n right_total = []\n for _ in range(int(n)):\n line = input().split(' ')\n total = 0\n for i, v in enumerate(line):\n print(repr(int(v)).rjust(5), end='')\n total += int(v)\n if len(bottom_total) < _ + 1:\n bottom_total.append(int(v))\n else:\n bottom_total[_] += int(v)\n right_total.append(total)\n print(repr(right_total[_]).rjust(5))\n\n for num in bottom_total:\n print(repr(num).rjust(5), end='')\n print(repr(sum(right_total)).rjust(5), end='')", "jacc_sim": 0.98, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [265, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u919202930", "n_user": "u919202930", "pos": "def rowSum(matrix):\n n=len(matrix)\n sumcolumn=[0]*n\n for i in range(0,n):\n sumcolumn[i] = sum(matrix[i])\n return sumcolumn\n\ndef colSum(matrix):\n n=len(matrix)\n sumrow=[0]*n\n for i in range(0,n):\n for j in range(0,n):\n sumrow[i]+=matrix[j][i]\n return sumrow\n\nwhile True:\n n=int(input())\n if n==0: break\n matrix=[None]*n\n for i in range(0,n):\n matrix[i] = list(map(int,input().split()))\n\n c=rowSum(matrix)\n r=colSum(matrix)\n\n matrix.append(r)\n\n for i in range(0,n):\n matrix[i].append(c[i])\n\n matrix[n].append(sum(matrix[n]))\n\n for row in matrix:\n line=\"\"\n for element in row:\n line += '{:>5}'.format(str(element))\n line.rstrip()\n print(line)", "neg": "def rowSum(matrix):\n n=len(matrix)\n sumcolumn=[0]*n\n for i in range(0,n):\n sumcolumn[i] = sum(matrix[i])\n return sumcolumn\n\ndef colSum(matrix):\n n=len(matrix)\n sumrow=[0]*n\n for i in range(0,n):\n for j in range(0,n):\n sumrow[i]+=matrix[j][i]\n return sumrow\n\nn=int(input())\nmatrix=[None]*n\nfor i in range(0,n):\n matrix[i] = list(map(int,input().split()))\n\nc=rowSum(matrix)\nr=colSum(matrix)\n\nmatrix.append(r)\n\nfor i in range(0,n):\n matrix[i].append(c[i])\n\nmatrix[n].append(sum(matrix[n]))\n\nfor row in matrix:\n line=\"\"\n for element in row:\n line += '{:>5}'.format(str(element))\n line.rstrip()\n print(line)", "jacc_sim": 0.9215686274509803, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [290, 268], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u078042885", "n_user": "u078042885", "pos": "while 1:\n n=int(input())\n if n==0:break\n a = []\n for i in range(n):\n a+=[list(map(int, input().split()))]\n a[i]+=[sum(a[i])]\n for j in range(n):print('%5d'%a[i][j],end='')\n print('%5d'%a[i][n])\n a=list(zip(*a[::-1]))\n for i in range(n):print('%5d'%sum(a[i]),end='')\n print('%5d'%sum(a[n]))", "neg": "while 1:\n n=int(input())\n if n==0:break\n a = []\n for i in range(n):\n a+=[list(map(int, input().split()))]\n a[i]+=[sum(a[i])]\n print(*a[i])\n a=list(zip(*a[::-1]))\n for i in range(n):print(sum(a[i]),end=' ')\n print(sum(a[n]))", "jacc_sim": 0.9142857142857143, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [155, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u742505495", "n_user": "u742505495", "pos": "import sys\nimport math\n\nwhile True:\n\tn = int(input())\n\tif n == 0:\n\t\tbreak\n\tdata = [list(map(int,input().split())) for i in range(n)]\n\tdata.append([0 for i in range(n+1)])\n\n\tfor i in range(n+1):\n\t\tif i != n:\n\t\t\tdata[i].append(sum(data[i]))\n\t\tfor j in range(n):\n\t\t\tdata[n][i] = data[n][i]+data[j][i]\n\tfor i in range(n+1):\n\t\tfor j in range(n+1):\n\t\t\tif j != n:\n\t\t\t\tstring = str('{:>5}'.format(data[i][j]))\n\t\t\t\tsys.stdout.write(string)\n\t\t\telse:\n\t\t\t\tprint('{:>5}'.format(data[i][j]))", "neg": "import sys\nimport math\n\nwhile True:\n\tn = int(input())\n\tif n == 0:\n\t\tbreak\n\tdata = [list(map(int,input().split())) for i in range(n)]\n\tdata.append([0 for i in range(n+1)])\n\n\tfor i in range(n+1):\n\t\tif i != n:\n\t\t\tdata[i].append(sum(data[i]))\n\t\tfor j in range(n):\n\t\t\tdata[n][i] = data[n][i]+data[j][i]\n\tfor i in range(n+1):\n\t\tfor j in range(n+1):\n\t\t\tif j != n:\n\t\t\t\tstring = str('{:>5}'.format(data[i][j]))\n\t\t\t\tsys.stdout.write(string)\n\t\t\t\tsys.stdout.write(' ')\n\t\t\telse:\n\t\t\t\tprint('{:>5}'.format(data[i][j]))", "jacc_sim": 1.0, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [223, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u808429775", "n_user": "u808429775", "pos": "while True:\n inputCount = int(input())\n\n if inputCount == 0:\n break\n\n table = []\n\n for lp in range(inputCount):\n content = [int(item) for item in input().split(\" \")]\n content.append(sum(content))\n table.append(content)\n\n table.append([])\n\n for col in range(inputCount + 1):\n total = 0\n for row in range(inputCount):\n total += table[row][col]\n\n table[inputCount].append(total)\n\n for array in table:\n print(\"\".join(\"{:>5}\".format(item) for item in array))\n\n", "neg": "while True:\n inputCount = int(input())\n\n if inputCount == 0:\n break\n\n table = []\n\n for lp in range(inputCount):\n content = [int(item) for item in input().split(\" \")]\n content.append(sum(content))\n table.append(content)\n\n table.append([])\n\n for col in range(inputCount + 1):\n total = 0\n for row in range(inputCount):\n total += table[row][col]\n\n table[inputCount].append(total)\n\n output = []\n for array in table:\n content = [\"{:>5}\".format(str(item)) for item in array]\n output.append(str(content))\n\n print(\"\\n\".join(output))\n\n", "jacc_sim": 0.9069767441860465, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [167, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u150984829", "n_user": "u150984829", "pos": "while 1:\n n=int(input())\n if n==0:break;\n a=[]\n for i in range(n):\n a+=[list(map(int,input().split()))]\n a[i]+=[sum(a[i])]\n for s in a[i]:print(\"%5d\"%s,end='')\n print()\n for c in zip(*a):print(\"%5d\"%sum(c),end='')\n print()\n", "neg": "while 1:\n n=int(input())\n if n==0:break;\n a=[]\n for i in range(n):\n a[i]=[list(map(int,input().split()))]\n a[i]+=[sum(a[i])]\n for s in a[i]:print(\"%5d\"%s,end='')\n print()\n for c in zip(*a):print(\"%5d\"%sum(c),end='')\n print()\n", "jacc_sim": 1.0, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [108, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00102", "p_user": "u150984829", "n_user": "u150984829", "pos": "while 1:\n n=int(input())\n if n==0:break;\n a=[]\n for i in range(n):\n b=list(map(int,input().split()))\n a+=[b+[sum(b)]]\n for s in a[i]:print(\"%5d\"%s,end='')\n print()\n for c in zip(*a):print(\"%5d\"%sum(c),end='')\n print()\n", "neg": "while 1:\n n=int(input())\n if n==0:break;\n a=[]\n for _ in[0]*n:\n b=list(map(int,input().split()))\n a+=[b+[sum(b)]]\n for s in b:print(\"%5d\"%s,end='')\n print()\n for c in zip(*a):print(\"%5d\"%sum(c),end='')\n print()\n", "jacc_sim": 0.9210526315789473, "nl": "Title: Matrix-like Computation\n\nYour task is to create a part of spreadsheet software. Write a program that calculates the sums of columns and rows for a given table. The input consists of multiple datasets, each containing the size of the table followed by its rows. The input ends with a line containing a single 0. For each dataset, print the table with sums of rows and columns. Align each item of the table to the right with a margin for five digits. Refer to the sample output for details.", "before_after_length": [105, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00105", "p_user": "u755162050", "n_user": "u755162050", "pos": "book_index = {}\nwhile True:\n try:\n word, page = input().split(' ')\n page = int(page)\n page_list = book_index.get(word)\n if page_list:\n page_list.append(page)\n else:\n book_index[word] = [page]\n except Exception:\n break\n\nfor k in sorted(book_index.keys()):\n print(k)\n print(' '.join(map(str, (sorted(book_index.get(k))))))", "neg": "book_index = {}\n while True:\n try:\n word, page = input().split(' ')\n page = int(page)\n page_list = book_index.get(word)\n if page_list:\n page_list.append(page)\n else:\n book_index[word] = [page]\n except Exception:\n break\n\n for k in sorted(book_index.keys()):\n print(k)\n print(' '.join(map(str, (sorted(book_index.get(k))))))", "jacc_sim": 1.0, "nl": "Title: Book Index\n\nBooks are indexed. Create a program that reads a list of word-page number pairs and prints each word along with a list of corresponding page numbers. Each word has a maximum length of 30 characters, and the page number is less than or equal to 1000. There are at most 100 pairs of word-page number. Each word appears only once on a page.\n\nThe words should be printed in alphabetical order, and the page numbers should be printed in ascending order.\n\nInput:\nword page_number\n...\n\nOutput:\nword\na_list_of_the_page_number\nword\na_list_of_the_Page_number\n...\n\nSample Input:\nstyle 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n\nOutput for the Sample Input:\ndocument\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n7 12 21", "before_after_length": [131, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00105", "p_user": "u546285759", "n_user": "u546285759", "pos": "dic = {}\nwhile True:\n try:\n word, pgn = input().split()\n\n if word in dic.keys():\n dic[word].append(int(pgn))\n else:\n dic[word] = [int(pgn)]\n except:\n break\n\nfor k, v in sorted(dic.items()):\n print(k)\n print(' '.join(map(str, sorted(v))))", "neg": "dic = {}\nwhile True:\n try:\n word, pgn = input().split()\n\n if word in dic.keys():\n dic[word].append(int(pgn))\n else:\n dic[word] = [int(pgn)]\n except:\n break\n\nfor k, v in dic.items():\n print(k)\n print(' '.join(map(str, sorted(v))))", "jacc_sim": 1.0, "nl": "Title: Book Index\n\nBooks are indexed. Create a program that reads a list of word-page number pairs and prints each word along with a list of corresponding page numbers. Each word has a maximum length of 30 characters, and the page number is less than or equal to 1000. There are at most 100 pairs of word-page number. Each word appears only once on a page.\n\nThe words should be printed in alphabetical order, and the page numbers should be printed in ascending order.\n\nInput:\nword page_number\n...\n\nOutput:\nword\na_list_of_the_page_number\nword\na_list_of_the_Page_number\n...\n\nSample Input:\nstyle 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n\nOutput for the Sample Input:\ndocument\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n7 12 21", "before_after_length": [105, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00105", "p_user": "u742505495", "n_user": "u742505495", "pos": "import sys\n\ndic = {}\nwhile True:\n\ttry:\n\t\ta,b = map(str,input().split())\n\t\tpage = int(b)\n\n\t\tif a not in dic:\n\t\t\tdic[a] = [page]\n\t\telse:\n\t\t\tdic[a].append(page)\n\n\texcept EOFError:\n\t\tnames = sorted(dic.keys())\n\t\tfor i in range(len(names)):\n\t\t\tprint(names[i])\n\t\t\tpages = sorted(dic[names[i]])\n\t\t\tfor j in range(len(pages)):\n\t\t\t\tif j == len(pages)-1:\n\t\t\t\t\tprint(pages[j])\n\t\t\t\telse:\n\t\t\t\t\tsys.stdout.write(str('{:} '.format(pages[j])))\n\t\tbreak", "neg": "import sys\n\ndic = {}\nwhile True:\n\ttry:\n\t\ta,b = map(str,input(),split())\n\t\tpage = int(b)\n\n\t\tif a not in dic:\n\t\t\tdic[a] = [page]\n\t\telse:\n\t\t\tdic[a].append(page)\n\t\t\t\n\texcept EOFError:\n\t\tsorted(dic.keys())\n\t\tnames = list(dic.keys())\n\t\tfor i in range(len(names)):\n\t\t\tprint(names[i])\n\t\t\tfor j in range(len(dic[i])):\n\t\t\t\tif j == len(dic[i])-1:\n\t\t\t\t\tprint(dic[i][j])\n\t\t\t\telse:\n\t\t\t\t\tsys.stdout.write(dic[i][j])\n\t\tbreak", "jacc_sim": 0.9183673469387755, "nl": "Title: Book Index\n\nBooks are indexed. Create a program that reads a list of word-page number pairs and prints each word along with a list of corresponding page numbers. Each word has a maximum length of 30 characters, and the page number is less than or equal to 1000. There are at most 100 pairs of word-page number. Each word appears only once on a page.\n\nThe words should be printed in alphabetical order, and the page numbers should be printed in ascending order.\n\nInput:\nword page_number\n...\n\nOutput:\nword\na_list_of_the_page_number\nword\na_list_of_the_Page_number\n...\n\nSample Input:\nstyle 12\neven 25\nintroduction 3\neasy 9\nstyle 7\ndocument 13\nstyle 21\neven 18\n\nOutput for the Sample Input:\ndocument\n13\neasy\n9\neven\n18 25\nintroduction\n3\nstyle\n7 12 21", "before_after_length": [194, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00107", "p_user": "u960312159", "n_user": "u960312159", "pos": "while True:\n d, w, h = [int(x) for x in input().split()]\n minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)\n if minrad == 0:\n break\n n = int(input())\n for i in range(n):\n r = int(input())\n if 4*r*r > minrad:\n print('OK')\n else:\n print('NA')", "neg": "while True:\n d, w, h = [int(x) for x in input().split()]\n minrad = min(d*d+w*w,w*w+h*h,h*h+d*d)\n if minrad == 0:\n break\n n = int(input())\n for i in range(n):\n r = int(input())\n if 2*r*r > minrad:\n print('OK')\n else:\n print('NA')", "jacc_sim": 0.9473684210526315, "nl": "Title: Carry a Cheese\n\nJerry, a small mouse, is trying to survive from the cat Tom. He is carrying a parallelepiped-like piece of cheese with dimensions A x B x C. Jerry needs to trail this cheese to his house, which has several entrances, each with its own radius R. Your task is to create a program to determine if Jerry can trail the cheese via each hole. If he can trail the cheese without touching the hole, the program should print \"OK\"; otherwise, it should print \"NA\". The input consists of datasets, each containing the dimensions of the cheese (A, B, C), the number of holes (n), and the radius of each hole (R1, R2, ..., Rn). The output should provide the result of the estimation for each hole. The input ends with a line containing three zeros. The number of holes is assumed to be less than 10000.", "before_after_length": [119, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00107", "p_user": "u742505495", "n_user": "u742505495", "pos": "import math\nwhile True:\n\td,w,h = map(int,input().split())\n\tif d == 0:\n\t\tbreak\n\tn = int(input())\n\tdist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]\n\tleng = min(dist)\n\tfor i in range(n):\n\t\tif 2*int(input())-leng > 0:\n\t\t\tprint('OK')\n\t\telse:\n\t\t\tprint('NA')", "neg": "import math\nwhile True:\n\td,w,h = map(int,input().split())\n\tif d == 0:\n\t\tbreak\n\tn = int(input())\n\tdist = [math.sqrt(d**2+w**2), math.sqrt(d**2+h**2), math.sqrt(w**2+h**2)]\n\tleng = min(dist)\n\tfor i in range(n):\n\t\tif int(input())-leng > 0:\n\t\t\tprint('OK')\n\t\telse:\n\t\t\tprint('NA')", "jacc_sim": 1.0, "nl": "Title: Carry a Cheese\n\nJerry, a small mouse, is trying to survive from the cat Tom. He is carrying a parallelepiped-like piece of cheese with dimensions A x B x C. Jerry needs to trail this cheese to his house, which has several entrances, each with its own radius R. Your task is to create a program to determine if Jerry can trail the cheese via each hole. If he can trail the cheese without touching the hole, the program should print \"OK\"; otherwise, it should print \"NA\". The input consists of datasets, each containing the dimensions of the cheese (A, B, C), the number of holes (n), and the radius of each hole (R1, R2, ..., Rn). The output should provide the result of the estimation for each hole. The input ends with a line containing three zeros. The number of holes is assumed to be less than 10000.", "before_after_length": [135, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00108", "p_user": "u350804311", "n_user": "u350804311", "pos": "while True:\n\tn = int(input())\n\tif n == 0:\n\t break\n\ts = []\n\tu = 0\n\tv = 0\n\ts = list(map(int, input().split()))\n\twhile True:\n\t\tt = []\n\t\tfor i in range(n):\n\t\t\tfor j in range(n):\n\t\t\t\tif s[i] == s[j]:\n\t\t\t\t\tu += 1\n\t\t\tt.append(u)\n\t\t\tt_str = list(map(str, t))\n\t\t\tu = 0\n\t\tif s == t:\n\t\t\tprint(str(v))\n\t\t\tprint(\" \".join(t_str))\n\t\t\tbreak\n\t\telse:\n\t\t\ts = t\n\t\t\tv += 1", "neg": "while True:\n\tn = int(input())\n\tif n == 0:\n\t break\n\ts = []\n\tu = 0\n\tv = 0\n\ts = list(input().split())\n\twhile True:\n\t\tt = []\n\t\tfor i in range(n):\n\t\t\tfor j in range(n):\n\t\t\t\tif s[i] == s[j]:\n\t\t\t\t\tu += 1\n\t\t\tt.append(u)\n\t\t\tt_str = list(map(str, t))\n\t\t\tu = 0\n\t\tif s == t_str:\n\t\t\tprint(str(v))\n\t\t\tprint(\" \".join(t_str))\n\t\t\tbreak\n\t\telse:\n\t\t\ts = t\n\t\t\tv += 1", "jacc_sim": 1.0, "nl": "Title: Frequency of Occurrence Operation\n\nThere is an operation called \"frequency of occurrence operation\" for transforming a finite sequence. The result of the transformation is a sequence of the same length. If the sequence S = {s1, s2,... sn}, the resulting sequence C = {c1, c2, ..., cn} represents the frequency of occurrence of each element in S, where ci denotes the count of si in S.\n\nFor example, if S = {3, 4, 1, 5, 9, 2, 6, 5, 3}, then C = {2, 1, 1, 2, 1, 1, 1, 2, 2}. Performing the frequency of occurrence operation on C yields P = {4, 5, 5, 4, 5, 5, 5, 4, 4}. This resulting sequence P remains unchanged after the frequency of occurrence operation, and it is referred to as a fixed point of S. It is known that for any sequence, repeating the frequency of occurrence operation will lead to finding its fixed point.\n\nThe input consists of multiple datasets. Each dataset is in the following format:\nn\ns1 s2 ... sn\n\nWhere the first line contains an integer n (n \u2264 12) representing the length of the sequence, and the second line contains n integers si (1 \u2264 si \u2264 100) representing the elements of sequence S.\n\nThe output should include, for each dataset, the minimum number of times the frequency of occurrence operation was executed (an integer) on the first line, and the elements of the corresponding fixed point sequence P (p1, p2, ..., pn) separated by spaces on the second line.\n\nThe input ends with a single line containing 0. The number of datasets does not exceed 200.\n\nSample Input:\n10\n4 5 1 1 4 5 12 3 5 4\n0\n\nOutput for the Sample Input:\n3\n6 6 4 4 6 6 4 4 6 6", "before_after_length": [182, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00108", "p_user": "u500396695", "n_user": "u500396695", "pos": "def FOA(a, count):\n\tb = [a.count(a[i]) for i in range(len(a))]\n\tif b == a:\n\t\tprint(count)\n\t\tprint(\" \".join(map(str, b)))\n\telse:\n\t\treturn FOA(b, count+1)\n\nwhile True:\n\tn = int(input())\n\tif n == 0:\n\t\tbreak\n\ta = list(map(int, input().split()))\n\tFOA(a, 0)", "neg": "def FOA(a, count):\n\tb = a\n\tfor i in range(len(b)):\n\t\tb[i] = a.count(a[i])\n\tif b == a:\n\t\tprint(count)\n\t\tprint(\" \".join(map(str, b)))\n\t\tbreak\n\telse:\n\t\treturn FOA(b, count + 1)\n\nwhile True:\n\tn = int(input())\n\tif n == 0:\n\t\tbreak\n\ta = map(int, input().split())\n\tFOA(a, 0)", "jacc_sim": 0.972972972972973, "nl": "Title: Frequency of Occurrence Operation\n\nThere is an operation called \"frequency of occurrence operation\" for transforming a finite sequence. The result of the transformation is a sequence of the same length. If the sequence S = {s1, s2,... sn}, the resulting sequence C = {c1, c2, ..., cn} represents the frequency of occurrence of each element in S, where ci denotes the count of si in S.\n\nFor example, if S = {3, 4, 1, 5, 9, 2, 6, 5, 3}, then C = {2, 1, 1, 2, 1, 1, 1, 2, 2}. Performing the frequency of occurrence operation on C yields P = {4, 5, 5, 4, 5, 5, 5, 4, 4}. This resulting sequence P remains unchanged after the frequency of occurrence operation, and it is referred to as a fixed point of S. It is known that for any sequence, repeating the frequency of occurrence operation will lead to finding its fixed point.\n\nThe input consists of multiple datasets. Each dataset is in the following format:\nn\ns1 s2 ... sn\n\nWhere the first line contains an integer n (n \u2264 12) representing the length of the sequence, and the second line contains n integers si (1 \u2264 si \u2264 100) representing the elements of sequence S.\n\nThe output should include, for each dataset, the minimum number of times the frequency of occurrence operation was executed (an integer) on the first line, and the elements of the corresponding fixed point sequence P (p1, p2, ..., pn) separated by spaces on the second line.\n\nThe input ends with a single line containing 0. The number of datasets does not exceed 200.\n\nSample Input:\n10\n4 5 1 1 4 5 12 3 5 4\n0\n\nOutput for the Sample Input:\n3\n6 6 4 4 6 6 4 4 6 6", "before_after_length": [125, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00108", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\na=sys.stdin\nwhile 1:\n if'0\\n'==a.readline():break\n s=list(map(int,a.readline().split()))\n c=0\n while 1:\n t=s;s=[t.count(e)for e in t]\n if t==s:break\n c+=1\n print(c);print(*s)\n", "neg": "import sys\na=sys.stdin\nwhile 1:\n if'0'==a.readline():break\n s=list(map(int,a.readline().split()))\n c=0\n while 1:\n t=s;s=[t.count(e)for e in t]\n if t==s:break\n c+=1\n print(c);print(*s)\n", "jacc_sim": 0.9444444444444444, "nl": "Title: Frequency of Occurrence Operation\n\nThere is an operation called \"frequency of occurrence operation\" for transforming a finite sequence. The result of the transformation is a sequence of the same length. If the sequence S = {s1, s2,... sn}, the resulting sequence C = {c1, c2, ..., cn} represents the frequency of occurrence of each element in S, where ci denotes the count of si in S.\n\nFor example, if S = {3, 4, 1, 5, 9, 2, 6, 5, 3}, then C = {2, 1, 1, 2, 1, 1, 1, 2, 2}. Performing the frequency of occurrence operation on C yields P = {4, 5, 5, 4, 5, 5, 5, 4, 4}. This resulting sequence P remains unchanged after the frequency of occurrence operation, and it is referred to as a fixed point of S. It is known that for any sequence, repeating the frequency of occurrence operation will lead to finding its fixed point.\n\nThe input consists of multiple datasets. Each dataset is in the following format:\nn\ns1 s2 ... sn\n\nWhere the first line contains an integer n (n \u2264 12) representing the length of the sequence, and the second line contains n integers si (1 \u2264 si \u2264 100) representing the elements of sequence S.\n\nThe output should include, for each dataset, the minimum number of times the frequency of occurrence operation was executed (an integer) on the first line, and the elements of the corresponding fixed point sequence P (p1, p2, ..., pn) separated by spaces on the second line.\n\nThe input ends with a single line containing 0. The number of datasets does not exceed 200.\n\nSample Input:\n10\n4 5 1 1 4 5 12 3 5 4\n0\n\nOutput for the Sample Input:\n3\n6 6 4 4 6 6 4 4 6 6", "before_after_length": [94, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00109", "p_user": "u742178809", "n_user": "u742178809", "pos": "import sys\n#from me.io import dup_file_stdin\n\ndef prec(op):\n if op in \"+-\":return 1\n if op in \"*/\":return 2\n raise NotImplementedError()\n \ndef postFix(expr):\n stack = []\n operators = []\n num = 0\n isdigit = False\n for ch in expr:\n if ch.isdigit():\n isdigit = True\n num*=10\n num+=int(ch)\n continue\n else :\n if isdigit:\n stack.append(num)\n num = 0\n isdigit = False\n \n if ch == ')':\n while len(operators) > 0:\n op = operators.pop()\n if op == '(':\n break\n else:\n stack.append(op)\n else:\n raise ValueError\n elif ch == '(':\n operators.append(ch)\n else:\n while len(operators) > 0 and operators[-1]!='(' and prec(operators[-1]) >= prec(ch):\n stack.append(operators.pop())\n operators.append(ch)\n if isdigit:\n stack.append(num)\n for op in operators[::-1]:\n if op not in \"()\":\n stack.append(op)\n return stack\n \ndef evaluate(stack):\n op = stack.pop()\n if type(op) is int:\n return op;\n else:\n b = evaluate(stack);\n a = evaluate(stack);\n return int(eval(str(a)+op+str(b)))\n\n#@dup_file_stdin\ndef solve():\n for _ in range(int(sys.stdin.readline())):\n expr = sys.stdin.readline()[:-1].strip(\"=\")\n print(evaluate(postFix(expr)))\n \nsolve()", "neg": "import sys\n#from me.io import dup_file_stdin\n\ndef prec(op):\n if op in \"+-\":return 1\n if op in \"*/\":return 2\n raise NotImplementedError()\n \ndef postFix(expr):\n stack = []\n operators = []\n num = 0\n isdigit = False\n for ch in expr:\n if ch.isdigit():\n isdigit = True\n num*=10\n num+=int(ch)\n continue\n else :\n if isdigit:\n stack.append(num)\n num = 0\n isdigit = False\n \n if ch == ')':\n while len(operators) > 0:\n op = operators.pop()\n if op == '(':\n break\n else:\n stack.append(op)\n else:\n raise ValueError\n elif ch == '(':\n operators.append(ch)\n else:\n while len(operators) > 0 and operators[-1]!='(' and prec(operators[-1]) >= prec(ch):\n stack.append(operators.pop())\n operators.append(ch)\n if isdigit:\n stack.append(num)\n for op in operators[::-1]:\n if op not in \"()\":\n stack.append(op)\n return stack\n \ndef evaluate(stack):\n op = stack.pop()\n if type(op) is int:\n return op;\n else:\n b = evaluate(stack);\n a = evaluate(stack);\n return int(eval(str(a)+op+str(b)))\n\n#@dup_file_stdin\ndef solve():\n for _ in range(int(sys.stdin.readline())):\n expr = sys.stdin.readline()[:-1].strip(\"=\")\n print(postFix(expr))\n print(evaluate(postFix(expr)))\n \nsolve()", "jacc_sim": 1.0, "nl": "Title: Smart Calculator\n\nYour task is to create a program that reads an expression and evaluates it. The expression consists of numerical values, operators, and parentheses, ending with '='. Operators include +, -, *, / representing addition, subtraction, multiplication, and division. Precedence follows standard rules: perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, apply them from left to right. Assume no division by zero. All calculations are performed as integers, with decimal points truncated. The expression length will not exceed 100 characters. Intermediate results of computation will range from -1 x 10^9 to 10^9.\n\nInput:\nThe input is a sequence of datasets. The first line contains an integer 'n' representing the number of datasets. There will be 'n' lines, each containing an expression.\n\nOutput:\nFor each dataset, print the result of the calculation.\n\nSample Input:\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input:\n-2\n60", "before_after_length": [441, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00109", "p_user": "u150984829", "n_user": "u150984829", "pos": "R={\"*\":2,\"/\":2,\"+\":1,\"-\":1,\"(\":0,\")\":0}\nfor _ in[0]*int(input()):\n L=[];t=''\n for e in input()[:-1]:\n if e.isdigit():t+=e\n else:\n if t:L+=[t];t=''\n L+=e\n if t:L+=[t]\n P,S=[],[]\n for i in L:\n if\"(\"==i:S+=i\n elif\")\"==i:\n while\"(\"!=S[-1]:P+=S.pop()\n S.pop()\n elif i in R:\n while S and R[S[-1]]>=R[i]:P+=S.pop()\n S+=i\n else:P+=[i]\n while S:P+=S.pop()\n for x in P:S+=[str(int(eval(S.pop(-2)+x+S.pop())))if x in\"+-*/\"else x]\n print(*S)\n", "neg": "R={\"*\":2,\"/\":2,\"+\":1,\"-\":1,\"(\":0,\")\":0}\nfor _ in[0]*int(input()):\n L=[];t=''\n for e in input()[:-1]:\n if e.isdigit():t+=e\n else:\n if t:L+=[t];t=''\n L+=e\n if t:L+=[t]\n P,S=[],[]\n for i in L:\n if\"(\"==i:S+=i\n elif\")\"==i:\n while\"(\"!=S[-1]:P+=S.pop()\n S.pop()\n elif i in R:\n while S and R[S[-1]]>=R[i]:P+=S.pop()\n S+=i\n else:P+=[i]\n while S:P+=S.pop()\n for x in P:\n S+=[str(eval(S.pop(-2)+p+S.pop()))if x in\"+-*/\"else x]\n print(*S)\n", "jacc_sim": 0.9777777777777777, "nl": "Title: Smart Calculator\n\nYour task is to create a program that reads an expression and evaluates it. The expression consists of numerical values, operators, and parentheses, ending with '='. Operators include +, -, *, / representing addition, subtraction, multiplication, and division. Precedence follows standard rules: perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, apply them from left to right. Assume no division by zero. All calculations are performed as integers, with decimal points truncated. The expression length will not exceed 100 characters. Intermediate results of computation will range from -1 x 10^9 to 10^9.\n\nInput:\nThe input is a sequence of datasets. The first line contains an integer 'n' representing the number of datasets. There will be 'n' lines, each containing an expression.\n\nOutput:\nFor each dataset, print the result of the calculation.\n\nSample Input:\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input:\n-2\n60", "before_after_length": [259, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00109", "p_user": "u855199458", "n_user": "u855199458", "pos": "# -*- coding: utf-8 -*-\n# \u5199\u7d4c\u3057\u305f\nimport re\nclass Num:\n def __str__(self):\n return str(self.x)\n def __init__(self, value):\n self.x = value\n def __add__(self, value):\n return Num(self.x + value.x)\n def __sub__(self, value):\n return Num(self.x - value.x)\n def __mul__(self, value):\n return Num(self.x * value.x)\n def __truediv__(self, value):\n return Num(int(self.x / value.x))\n \nN = int(input())\nfor i in range(N):\n s = input()[:-1]\n s = re.sub(r'(\\d+)',r'Num(\\1)',s)\n print(eval(s))\n", "neg": "# -*- coding: utf-8 -*-\n# \u5199\u7d4c\u3057\u305f\nimport re\nclass Num:\n def __str__(self):\n return str(self.x)\n def __init__(self, value):\n self.x = value\n def __add__(self, value):\n return o(self.x + value.x)\n def __sub__(self, value):\n return o(self.x - value.x)\n def __mul__(self, value):\n return o(self.x * value.x)\n def __truediv__(self, value):\n return o(int(self.x / value.x))\n \nN = int(input())\nfor i in range(N):\n s = input()[:-1]\n s = re.sub(r'(\\d+)',r'Num(\\1)',s)\n print(eval(s))\n", "jacc_sim": 0.9811320754716981, "nl": "Title: Smart Calculator\n\nYour task is to create a program that reads an expression and evaluates it. The expression consists of numerical values, operators, and parentheses, ending with '='. Operators include +, -, *, / representing addition, subtraction, multiplication, and division. Precedence follows standard rules: perform all multiplication and division first, then addition and subtraction. When two operators have the same precedence, apply them from left to right. Assume no division by zero. All calculations are performed as integers, with decimal points truncated. The expression length will not exceed 100 characters. Intermediate results of computation will range from -1 x 10^9 to 10^9.\n\nInput:\nThe input is a sequence of datasets. The first line contains an integer 'n' representing the number of datasets. There will be 'n' lines, each containing an expression.\n\nOutput:\nFor each dataset, print the result of the calculation.\n\nSample Input:\n2\n4-2*3=\n4*(8+4+3)=\n\nOutput for the Sample Input:\n-2\n60", "before_after_length": [229, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04037", "p_user": "u423585790", "n_user": "u423585790", "pos": "n=int(input())\na=sorted(map(int,input().split()))[::-1]\nj=i=0\nwhile ii:i+=1\nwhile j=i:j+=1\nprint('SFeicrosntd'[(a[i-1]^i)&1|(j^i)&1::2])\n", "neg": "n=int(input())\na=sorted(map(int,input().split()))[::-1]\nj=i=x=0\nwhile xi;j+=a[j]>=i,x+=1\nprint('SFeicrosntd'[(a[i-1]^i|j^i)&1::2])\n", "jacc_sim": 0.9117647058823529, "nl": "There are N piles of candies on the table, each initially containing a certain number of candies. Snuke and Ciel take alternating turns, with Snuke going first. On each turn, the player must choose to either eat all the candies from the pile with the most remaining candies or eat one candy from each pile with at least one candy. The player who eats the last candy loses. Determine which player will win if both play optimally.\n\nConstraints:\n1 \u2264 N \u2264 10^5\n1 \u2264 a_i \u2264 10^9\n\nInput:\nThe input is given in the format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf Snuke will win, print \"First\". If Ciel will win, print \"Second\".\n\nSample Input 1:\n2\n1 3\n\nSample Output 1:\nFirst\nExplanation: Snuke can eat all candies from pile 2, forcing Ciel to eat the last candy.\n\nSample Input 2:\n3\n1 2 1\n\nSample Output 2:\nFirst\nExplanation: If Snuke eats one candy from each pile, Ciel is left with the last candy.\n\nSample Input 3:\n3\n1 2 3\n\nSample Output 3:\nSecond", "before_after_length": [101, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u374051158", "n_user": "u374051158", "pos": "n, k = map(int, input().split())\nd = input().split()\n\ndef is_ok(num):\n s = str(num)\n for ng in d:\n if ng in s: return False\n \n return True\n\nwhile True:\n if is_ok(n):\n print(n)\n exit()\n \n n += 1\n \n", "neg": "n, k = map(int, input().split())\nd = list(map(int, input().split()))\n\ndef is_ok(num):\n s = str(num)\n for ng in d:\n if ng in s: return False\n \n return True\n\nwhile True:\n if is_ok(n):\n print(n)\n exit()\n \n n += 1\n ", "jacc_sim": 0.967741935483871, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [89, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u658113376", "n_user": "u658113376", "pos": "oldMoney, hateNumberLength = map(list, input().split())\nhateLines = list(str(input()).rsplit(\" \"))\nokLines = []\nFirstBigList = []\nnewMoney = list(oldMoney)\n\n\ndef FindFirstBig(okLines, m, FirstBig):\n for i in okLines:\n if i > m:\n FirstBig.append(i)\n return FirstBig\n\n\nfor i in range(10):\n if str(i) not in hateLines:\n okLines.append(str(i))\n\nFirstFlag = -1\nProblemFlag = -1\nfor index, m in enumerate(oldMoney):\n if FirstFlag == -1:\n if m in hateLines:\n FirstBigList = FindFirstBig(okLines, m, FirstBigList)\n if len(FirstBigList) > 0:\n newMoney[index] = FirstBigList[0]\n FirstFlag = index\n ProblemFlag = index\n elif FirstFlag != -1:\n newMoney[index] = okLines[0]\n\nif oldMoney == newMoney:\n if ProblemFlag is not 0 and ProblemFlag is not -1:\n FirstBigList.clear()\n while ProblemFlag:\n FirstBigList = FindFirstBig(okLines, newMoney[ProblemFlag - 1], FirstBigList)\n if len(FirstBigList) > 0:\n newMoney[ProblemFlag - 1] = FirstBigList[0]\n for i in range(ProblemFlag, len(newMoney), 1):\n newMoney[i] = okLines[0]\n if oldMoney == newMoney:\n ProblemFlag -= 1\n if ProblemFlag is 0:\n if okLines[0] != '0':\n newMoney.insert(0, okLines[0])\n else:\n newMoney.insert(0, okLines[1])\n for i in range(ProblemFlag + 1, len(newMoney), 1):\n newMoney[i] = okLines[0]\nresultnew = \"\".join(newMoney)\nprint(resultnew)", "neg": "oldMoney, hateNumberLength = map(list, input().split())\nhateLines = list(str(input()).rsplit(\" \"))\nokLines = []\nFirstBigList = []\nnewMoney = list(oldMoney)\ndef FindFirstBig(okLines,m,FirstBig):\n for i in okLines:\n if i > m:\n FirstBig.append(i)\n return FirstBig\n\nfor i in range(10):\n if str(i) not in hateLines:\n okLines.append(str(i))\n\nFirstFlag = -1\nProblemFlag = -1\nfor index, m in enumerate(oldMoney):\n if FirstFlag == -1:\n if m in hateLines:\n FirstBigList = FindFirstBig(okLines,m,FirstBigList)\n if len(FirstBigList) > 0:\n newMoney[index] = FirstBigList[0]\n FirstFlag = index\n ProblemFlag = index\n elif FirstFlag != -1:\n newMoney[index] = okLines[0]\n\nif oldMoney == newMoney:\n if ProblemFlag is not 0:\n FirstBigList.clear()\n while ProblemFlag:\n FirstBigList = FindFirstBig(okLines, newMoney[ProblemFlag - 1], FirstBigList)\n if len(FirstBigList) > 0:\n newMoney[ProblemFlag - 1] = FirstBigList[0]\n for i in range(ProblemFlag,len(newMoney),1):\n newMoney[i] = okLines[0]\n if oldMoney == newMoney:\n ProblemFlag -= 1\n if ProblemFlag is 0:\n newMoney.insert(0,okLines[0])\n for i in range(ProblemFlag, len(newMoney), 1):\n newMoney[i] = okLines[0]\nresultnew = \"\".join(newMoney)\nprint(resultnew)", "jacc_sim": 0.9491525423728814, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [492, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u018679195", "n_user": "u018679195", "pos": "n, k = map(int, input().split())\nd = map(str, input().split())\ndigits = set(d)\nnum = {str(i) for i in range(0,10)}\nleft = num - digits\nfor i in range(n, 100000):\n Nums = set(str(i))\n if Nums <= left:\n print(i)\n break", "neg": "n, k = map(int, input().split())\nd = map(str, input().split())\ndigits = set(d)\nnum = {str(i) for i in range(0,10)}\nleft = num - digits\nfor i in range(N, 100000):\n Num = set(str(i))\n if Num <= left:\n print(i)\n break", "jacc_sim": 0.9142857142857143, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [91, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u802963389", "n_user": "u802963389", "pos": "n, k = map(int, input().split())\na = list(input().split())\nfor i in range(n, 10**6):\n if all([j not in a for j in str(i)]):\n # print([j for j in str(i)])\n print(i)\n exit()", "neg": "n, k = map(int, input().split())\na = list(input().split())\nfor i in range(n+1, 10**6):\n if all([j not in a for j in str(i)]):\n # print([j for j in str(i)])\n print(i)\n exit()", "jacc_sim": 0.9393939393939394, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [74, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u497046426", "n_user": "u497046426", "pos": "numbers = {str(i) for i in range(10)}\nN, K = map(int, input().split())\n*D, = map(str, input().split())\nD = set(D)\navailable = numbers - D\nans = 0\nfor i in range(N, 100000):\n nums = set(str(i))\n if nums <= available:\n print(i)\n break", "neg": "numbers = {str(i) for i in range(10)}\nN, K = map(int, input().split())\n*D, = map(str, input().split())\nD = set(D)\navailable = numbers - D\nans = 0\nfor i in range(N, 100000):\n nums = set(str(i))\n if nums < available:\n print(i)\n break", "jacc_sim": 1.0, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [93, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u367130284", "n_user": "u367130284", "pos": "n,k,*a=open(0).read().split();n=int(n)\nwhile any(s in set(a)for s in str(n)):n+=1\nprint(n)", "neg": "n,k,*a=map(int,open(0).read().split())\nwhile any(s in set(a)for s in str(n)):n+=1\nprint(n)", "jacc_sim": 0.9259259259259259, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [48, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u785578220", "n_user": "u785578220", "pos": "n,k=map(int,input().split())\nx = list(map(int,input().split()))\nt = 1\ns = n\nf=0\nwhile t:\n for i in range(k):\n f = 0\n if str(x[i]) in str(s):\n break\n elif i == k -1:t = 0\n s+=1\nprint(s-1)\n ", "neg": "n,k=map(int,input().split())\nx = list(map(int,input().split()))\nt = 1\ns = n\nwhile t:\n for i in range(k):\n if str(x[i]) in str(n+s):\n break\n t = 0\n s+=1\nprint(n+s-1)", "jacc_sim": 0.9393939393939394, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [100, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u848647227", "n_user": "u848647227", "pos": "a,b = map(int,input().split(\" \"))\nar = list(map(int,input().split(\" \")))\nwhile True:\n count = 0\n br = list(str(a))\n for r in br:\n if int(r) in ar:\n count += 1\n if count == 0:\n print(a)\n break\n else:\n a += 1", "neg": "ar = list(map(int,input().split(\" \")))\nwhile True:\n count = 0\n br = list(str(a))\n for r in br:\n if int(r) in ar:\n count += 1\n if count == 0:\n print(a)\n break\n else:\n a += 1", "jacc_sim": 0.9666666666666667, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [95, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u404676457", "n_user": "u404676457", "pos": "def ceil(n, i):\n dec = 10 ** i\n return n // dec * dec\n\n(n, k) = list(map(int, input().split()))\nd = list(map(int, input().split()))\nl = []\nfor i in range(0, 10):\n if i not in d:\n l.append(i)\ni = 1\nwhile len(str(n)) >= i:\n nown = n // (10 ** (i - 1)) % 10\n ok = False\n for j in l:\n if j == nown:\n ok = True\n break\n elif j > nown:\n ok = True\n n = ceil(n, i)\n n += int(str(j) + str(l[0]) * (i - 1))\n break\n if not (ok):\n n = ceil(n, i) + 10 ** i\n n += int(str(l[0]) * i)\n i += 1\nprint(n)", "neg": "import math\n\ndef ceil(n, i):\n dec = 10 ** i\n return n // dec * dec\ndef floor(n, i):\n dec = 10 ** i\n return n // dec * dec + dec\n\n(n, k) = list(map(int, input().split()))\nd = list(map(int, input().split()))\nl = []\n\nfor i in range(0, 10):\n if i not in d:\n l.append(i)\nfor i in range(1, len(str(n)) + 1):\n nown = n // (10 ** (i - 1)) % 10\n ok = False\n print(nown)\n for j in l:\n if j == nown:\n ok = True\n break\n elif j > nown:\n ok = True\n n = ceil(n, i)\n print(str(j) + str(l[0]) * (i - 1))\n n += int(str(j) + str(l[0]) * (i - 1))\n break\n if not (ok):\n n = floor(n, i)\n n += int(str(l[0]) * i)\n \nprint(n)\n\n\n", "jacc_sim": 0.9215686274509803, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [240, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u827202523", "n_user": "u827202523", "pos": "def dig_check(i,d):\n for k in [int(j) for j in str(i)]:\n if k in d:\n return False\n return True\n\n\nN,K = input().split()\nN = int(N)\n\nd = [int(i) for i in input().split()]\n\nfor i in range(100001):\n if i >= N :\n if dig_check(i,d):\n print(i)\n break\n\n", "neg": "def dig_check(i,d):\n for k in [int(j) for j in str(i)]:\n if k in d:\n return False\n return True\n\n\nN,K = input.split()\nN = int(N)\n\nd = [int(i) for i in input.split()]\n\nfor i in range(10001):\n if i > N :\n if dig_check(i,d):\n print(i)\n break\n", "jacc_sim": 0.9375, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [116, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u653005308", "n_user": "u653005308", "pos": "n,k=map(int,input().split())\ndislike=list(map(int,input().split()))\n\n\nwhile 1:\n for i in range(len(str(n))):\n if int(str(n)[i]) in dislike:\n break\n if i==len(str(n))-1:\n print(n)\n exit()\n n+=1", "neg": "n,k=map(int,input().split())\ndislike=list(map(int,input().split()))\nprint(dislike)\n\nwhile 1:\n for i in range(len(str(n))):\n if int(str(n)[i]) in dislike:\n break\n print(n)\n exit()\n n+=1", "jacc_sim": 0.9666666666666667, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [95, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04039", "p_user": "u785205215", "n_user": "u785205215", "pos": "from sys import stdin, stdout\ndef readLine_int_list():return list(map(int, stdin.readline().split()))\n\ndef main():\n n,k = readLine_int_list()\n d = readLine_int_list()\n i = [i for i in range(10) if not i in d]\n for ii in range(n, 10**9):\n l = [int(x) for x in list(str(ii))]\n ll =[q for q in l if q in d]\n if len(ll) == 0:\n print(ii)\n break\nif __name__ == \"__main__\":\n main()", "neg": "from sys import stdin, stdout\ndef readLine_int_list():return list(map(int, stdin.readline().split()))\n\ndef main():\n n,k = readLine_int_list()\n d = readLine_int_list()\n i = [i for i in range(10) if not i in d]\n for ii in range(n, 10**9):\n l = [int(x) for x in list(str(ii))]\n ll =[q for q in l if q in d]\n print(ii, ll)\n if len(ll) == 0:\n print(ii)\n break\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Iroha dislikes certain digits and wants to pay the minimum amount of money at a cashier without using those digits. Given the total amount she needs to pay and the disliked digits, find the minimum amount she can hand to the cashier. The input consists of the total amount and the disliked digits. Output the minimum amount she will hand to the cashier. Constraints: 1 \u2264 N < 10000, 1 \u2264 K < 10, 0 \u2264 D1 < D2 < \u2026 < DK \u2264 9, {D1,D2,...,DK} \u2260 {1,2,3,4,5,6,7,8,9}. Example: Input: 1000 8, 1 3 4 5 6 7 8 9, Output: 2000.", "before_after_length": [155, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04040", "p_user": "u375616706", "n_user": "u375616706", "pos": "mod = 10**9+7\n\n\nH, W, A, B = map(int, input().split())\n\n\nclass Fact():\n def __init__(self, H, W):\n self.mod = 10**9+7\n self.facts = [1]*(H+W-1)\n for i in range(1, H+W-1):\n self.facts[i] = self.facts[i-1]*i % mod\n\n self.i = [pow(self.facts[-1], mod-2, mod)]\n for i in range(1, H+W-1)[::-1]:\n self.i.append(self.i[-1]*i % mod)\n self.i.reverse()\n\n def comb(self, n, r):\n ret = self.facts[n] * self.i[n-r]*self.i[r]\n return ret\n\n def print_fact(self):\n print(self.facts)\n\n\nf = Fact(H, W)\n\nall_path = f.comb(H+W-2, H-1)\n\nremove_path = 0\nfor i in range(B):\n tmp = f.comb(H-A+i-1, i)\n tmp *= f.comb(W-i-1+A-1, A-1)\n remove_path += tmp\n\nremove_path %= mod\n\nprint((all_path - remove_path) % mod)\n", "neg": "\nmod = 10**9+7\n\n\nH, W, A, B = map(int, input().split())\n\n\nclass Fact():\n def __init__(self, H, W):\n self.mod = 10**9+7\n self.facts = [1]*(H+W-1)\n for i in range(1, H+W-1):\n self.facts[i] = self.facts[i-1]*i % mod\n\n self.i = [pow(self.facts[-1], mod-2, mod)]\n for i in range(1, H+W-1)[::-1]:\n self.i.append(self.i[-1]*i % mod)\n self.i.reverse()\n\n def comb(self, n, r):\n ret = self.facts[n] * self.i[n-r]*self.i[r]\n return ret\n\n def print_fact(self):\n print(self.facts)\n\n\nf = Fact(H, W)\n\nall_path = f.comb(H+W-2, H-1)\n\nf.print_fact()\n\nremove_path = 0\nfor i in range(B):\n tmp = f.comb(H-A+i-1, i)\n tmp *= f.comb(W-i-1+A-1, A-1)\n remove_path += tmp\n\nremove_path %= mod\n\nprint((all_path - remove_path) % mod)\n", "jacc_sim": 1.0, "nl": "Iroha is on a grid with H rows and W columns. She starts at the top-left cell and moves right or down to reach the bottom-right cell. She cannot enter the bottom A rows and leftmost B columns. Find the number of ways she can reach the bottom-right cell, modulo 10^9+7. Constraints: 1 \u2264 H, W \u2264 100,000, 1 \u2264 A < H, 1 \u2264 B < W. Input format: H W A B. Output: Number of ways to reach the bottom-right cell, modulo 10^9+7. Example: Input: 2 3 1 1, Output: 2. Example: Input: 10 7 3 4, Output: 3570. Example: Input: 100000 100000 99999 99999, Output: 1. Example: Input: 100000 100000 44444 55555, Output: 738162020.", "before_after_length": [349, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04040", "p_user": "u536113865", "n_user": "u536113865", "pos": "ai = lambda: list(map(int,input().split()))\n\nmod = 10**9+7\n\n\ndef nCb(n, b):\n if b > n - b:\n b = n - b\n r = 1\n for k in range(n, n-b, -1):\n r = r * k % mod\n d = 1\n for k in range(1, b+1):\n d = d * k % mod\n return r * inv(d) % mod\n\n\ndef inv(x):\n return pow(x, mod - 2, mod)\n\n\nh,w,a,b = ai()\naa = h-a-1\nbb = w-b-1\nc1 = nCb(aa+b, b)\nc2 = nCb(a+bb-1, bb)\nans = c1 * c2\nans %= mod\n\nfor i in range(1, bb+1):\n c1 = c1 * (aa + b + i) * inv(b + i) % mod\n c2 = c2 * (bb - i + 1) * inv(a + bb - i) % mod\n ans += c1 * c2\n ans %= mod\nprint(ans)\n", "neg": "ai = lambda: list(map(int,input().split()))\n\nmod = 10**9+7\n\n\ndef nCb(n, b):\n if b > n - b:\n b = n - b\n r = 1\n for k in range(n, n-b, -1):\n r = r * k % mod\n d = 1\n for k in range(1, b+1):\n d = d * k % mod\n return r * inv(d) % mod\n\n\ndef inv(x):\n return pow(x, mod - 2, mod)\n\n\nh,w,a,b = ai()\nans = 0\nc1 = nCb(b-1,0)\nc2 = nCb(w-b+h-2, h-1)\nfor i in range(h-a):\n ans += c1 * c2\n ans %= mod\n c1 = c1 * (b+i) // (i+1)\n c2 = c2 * (h-i-1) // (w-b+h-i-2)\nprint(ans)\n", "jacc_sim": 0.9215686274509803, "nl": "Iroha is on a grid with H rows and W columns. She starts at the top-left cell and moves right or down to reach the bottom-right cell. She cannot enter the bottom A rows and leftmost B columns. Find the number of ways she can reach the bottom-right cell, modulo 10^9+7. Constraints: 1 \u2264 H, W \u2264 100,000, 1 \u2264 A < H, 1 \u2264 B < W. Input format: H W A B. Output: Number of ways to reach the bottom-right cell, modulo 10^9+7. Example: Input: 2 3 1 1, Output: 2. Example: Input: 10 7 3 4, Output: 3570. Example: Input: 100000 100000 99999 99999, Output: 1. Example: Input: 100000 100000 44444 55555, Output: 738162020.", "before_after_length": [292, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04040", "p_user": "u218843509", "n_user": "u218843509", "pos": "BIG = (10 ** 9) + 7\n\nf_list = [1] * 200000\nf_r_list = [1] * 200000\n\nfor i in range(199999):\n\tf_list[i + 1] = int((f_list[i] * (i + 2)) % BIG)\n\ndef power(n, x):\n\tif x == 1:\n\t\treturn n\n\telif x % 2 == 0:\n\t\treturn power(int((n * n) % BIG), int(x / 2))\n\telse:\n\t\treturn int((n * power(n, x - 1)) % BIG)\n\nf_r_list[-1] = power(f_list[-1], BIG - 2)\n\nfor i in range(2, 200001):\n\tf_r_list[-i] = int((f_r_list[-i + 1] * (200002 - i)) % BIG)\n\ndef comb(n, r):\n\tif n == 0 or r == 0 or n == r:\n\t\treturn 1\n\telse:\n\t\treturn (((f_list[n - 1] * f_r_list[n - r - 1]) % BIG) * f_r_list[r - 1]) % BIG \n\nh, w, a, b = map(int, input().split())\n\nans = 0\n\nfor i in range(h - a):\n\tans = int((ans + int((comb(b + i - 1, b - 1) * comb(h + w - b - i - 2, w - b - 1)) % BIG)) % BIG)\n\nprint(int(ans))", "neg": "BIG = (10 ** 9) + 7\n\nf_list = [1] * 200000\nf_r_list = [1] * 200000\n\nfor i in range(199999):\n\tf_list[i + 1] = int((f_list[i] * (i + 2)) % BIG)\n\ndef power(n, x):\n\tif x == 1:\n\t\treturn n\n\telif x % 2 == 0:\n\t\treturn power(int((n * n) % BIG), int(x / 2))\n\telse:\n\t\treturn int((n * power(n, x - 1)) % BIG)\n\nfor i in range(200000):\n\tf_r_list[i] = power(f_list[i], BIG - 2)\n\ndef comb(n, r):\n\tif n == 0 or r == 0 or n == r:\n\t\treturn 1\n\telse:\n\t\treturn (((f_list[n - 1] * f_r_list[n - r - 1]) % BIG) * f_r_list[r - 1]) % BIG \n\nh, w, a, b = map(int, input().split())\n\nans = 0\n\nfor i in range(h - a):\n\tans = int((ans + int((comb(b + i - 1, b - 1) * comb(h + w - b - i - 2, w - b - 1)) % BIG)) % BIG)\n\nprint(int(ans))", "jacc_sim": 0.9607843137254902, "nl": "Iroha is on a grid with H rows and W columns. She starts at the top-left cell and moves right or down to reach the bottom-right cell. She cannot enter the bottom A rows and leftmost B columns. Find the number of ways she can reach the bottom-right cell, modulo 10^9+7. Constraints: 1 \u2264 H, W \u2264 100,000, 1 \u2264 A < H, 1 \u2264 B < W. Input format: H W A B. Output: Number of ways to reach the bottom-right cell, modulo 10^9+7. Example: Input: 2 3 1 1, Output: 2. Example: Input: 10 7 3 4, Output: 3570. Example: Input: 100000 100000 99999 99999, Output: 1. Example: Input: 100000 100000 44444 55555, Output: 738162020.", "before_after_length": [382, 345], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04040", "p_user": "u986399983", "n_user": "u986399983", "pos": "import scipy.misc as scm\n\nH, W, A, B = [int(i) for i in input().split()]\nMOD = 10**9 + 7\nf = [1]\na = [1]\nfor i in range(1, H+W-1):\n f.append((f[i-1] * i) % MOD)\n a.append(pow(f[i], MOD-2, MOD))\nans = 0\nfor i in range(B, W, 1):\n ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))\n ans %= MOD\nprint(ans)", "neg": "import scipy.misc as scm\n\nH, W, A, B = [int(input()) for _ in range(4)]\nMOD = 10**9 + 7\nf = [1]\na = [1]\nfor i in range(1, H+W-1):\n f.append((f[i-1] * i) % MOD)\n a.append(pow(f[i], MOD-2, MOD))\nans = 0\nfor i in range(B, W, 1):\n ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))\n ans %= MOD\nprint(ans)", "jacc_sim": 0.9302325581395349, "nl": "Iroha is on a grid with H rows and W columns. She starts at the top-left cell and moves right or down to reach the bottom-right cell. She cannot enter the bottom A rows and leftmost B columns. Find the number of ways she can reach the bottom-right cell, modulo 10^9+7. Constraints: 1 \u2264 H, W \u2264 100,000, 1 \u2264 A < H, 1 \u2264 B < W. Input format: H W A B. Output: Number of ways to reach the bottom-right cell, modulo 10^9+7. Example: Input: 2 3 1 1, Output: 2. Example: Input: 10 7 3 4, Output: 3570. Example: Input: 100000 100000 99999 99999, Output: 1. Example: Input: 100000 100000 44444 55555, Output: 738162020.", "before_after_length": [194, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u821322673", "n_user": "u787059958", "pos": "n, x = map(int, input().split())\na = max(n-x, x); b = min(n-x, x)\nres = n\nwhile b!=0:\n p=a; q=int(a/b); r=a%b\n res+=q*(2*b)\n if r==0:\n res-=b\n a=b; b=r\n\nprint(res)", "neg": "n, x = map(int, input().split())\na, b = max(n-x,x),min(n-x,x)\nres = a+b\nwhile b!=0:\n q = a/b\n r = a%b\n res += (b*2)*q\n if (r==0):\n res -= b\n a, b = b, r\n\nprint(res)", "jacc_sim": 0.9375, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [102, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u923270446", "n_user": "u697658632", "pos": "import math\nn,x=map(int,input().split())\nprint(3*(n-math.gcd(n,x)))", "neg": "import math\nn, x = map(int, input().split())\nprint(3 * (n - gcd(n, x)))\n", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [31, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u856671164", "n_user": "u856671164", "pos": "N,X = input().split()\nN,X = int(N), int(X)\nanswer = X+ (N-X)\n\n\ndef rhombus(N,X):\n \t\n if X==1: \n return N*2-1\n if X==0:\n return 0\n\n if N%X == 0:\n return X*(N//X)*2-X\n \n else: \n k = N//X\n return k*2*X + rhombus(X,N-(k*X))\n\n \n\nanswer = answer + rhombus(N-X,X)\nprint(answer)", "neg": "N,X = input().split()\nN,X = int(N), int(X)\nanswer = X+ (N-X)\n\n\ndef rhombus(N,X):\n \tif N0:\n x,y = y,x\n m = x*(y//x)\n res += m*2\n y -= m\nres -= x\nprint(res)", "neg": "N,X = map(int,input().split())\nx = X\ny = N-X\nif x0:\n x,y = y,x\n print(x,y)\n m = x*(y//x)\n res += m*2\n y -= m\nres -= x\nprint(res)", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [87, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u525796732", "n_user": "u525796732", "pos": "def main():\n n,x=map(int,input().split())\n a,b=n-x,x\n if(a int:\n mx = max(a,b)\n mn = min(a,b)\n if gcd(a,b) == mn:\n return (2 * (mx // mn) - 1) * mn\n \n else:\n return (2 * (mx // mn) * mn) + rec(mn, mx - mn * (mx // mn))\n \nn,x = li()\nprint(n + rec(x, n-x))\n ", "neg": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**8) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\ndef gcd(a,b):\n if a%b == 0:\n return b\n else:\n return gcd(b, a%b)\n\ndef rec(a: int, b: int) -> int:\n mx = max(a,b)\n mn = min(a,b)\n if gcd(a,b) == mn:\n return (2 * (mx // mn) - 1) * mn\n \n else:\n return (2 * (mx // mn) * mn) + rec(mn, mn * (mx // mn))\n \nn,x = li()\nprint(n + rec(x, n-x))", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [297, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u638357064", "n_user": "u638357064", "pos": "# your code goes here\nfrom math import floor\nN, X = [int(x) for x in input().split()]\n\ny = N-X\nx = X\nL = X\nwhile x > 0:\n#\tk = 2*floor(y/x)\n\tk, z = divmod(y, x)\n#\tdL = x*(2*k-1)+y\n\tL += x*(2*k-1)+y\n#\tprint(x, y, k, dL)\n\ty, x = (x, z)\n\n#L += y\nprint(L)", "neg": "# your code goes here\nfrom math import floor\nN, X = [int(x) for x in input().split()]\n\ny = N-X\nx = X\nL = X\nwhile x > 0:\n#\tk = 2*floor(y/x)\n\tk, z = divmod(y, x)\n\tdL = x*(2*k-1)+y\n\tL += x*(2*k-1)+y\n\tprint(x, y, k, dL)\n\ty, x = (x, z)\n\n#L += y\nprint(L)", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [138, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u820560680", "n_user": "u820560680", "pos": "N, X = map(int, input().split())\npath = N\na, b = X, N - X\nif a < b:\n a, b = b, a\nwhile b > 0:\n path += b * (a // b) * 2\n a, b = b, a % b\npath -= a\nprint(path)", "neg": "N, X = map(int, input().split())\npath = N\na, b = X, N - X\nif a < b:\n a, b = b, a\nwhile b > 0:\n print(a, b)\n path += b * (a // b) * 2\n a, b = b, a % b\npath -= a\nprint(path)", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [80, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u562016607", "n_user": "u562016607", "pos": "def gcd(a,b):\n if a%b==0:\n return b\n else:\n return gcd(b,a%b)\nN,X=map(int,input().split())\nprint(3*(N-gcd(N,X)))\n", "neg": "def gcd(a,b):\n if a%b==0:\n return b\n else:\n return gcd(b,a%b):\nN,X=map(int,input().split())\nprint(3*(N-gcd(N,X))", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [63, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04048", "p_user": "u477320129", "n_user": "u477320129", "pos": "import sys\nsys.setrecursionlimit(1500)\n\ndef f(x, y):\n if x == 0:\n return 0\n if y % x == 0:\n return 2 * (y // x) * x - x\n return 2 * (y // x) * x + f(y % x, x)\n\nN, X = list(map(int, input().split()))\nprint(f(X, N-X) + N)\n", "neg": "import sys\nsys.setrecursionlimit(1500)\n\ndef f(x, y):\n if x == y:\n return x\n x, y = min(x, y), max(x, y)\n return 2 * (y // x) * x + f(x, y % x)\n\nN, X = list(map(int, input().split()))\nprint(f(X, N-X) + N)\n", "jacc_sim": 0.9090909090909091, "nl": "Score: 500 points\nProblem Statement:\nSnuke is conducting an optical experiment using mirrors and his new invention, the rifle of Mysterious Light. Three mirrors of length N are set to form an equilateral triangle with vertices a, b, and c. Inside the triangle, the rifle is placed at point p on segment ab such that ap = X. The rifle is about to fire a ray of Mysterious Light in the direction of bc. The ray will travel in a straight line and be reflected by mirrors and its own trajectory. When the ray comes back to the rifle, it will be absorbed. Find the total length of the ray's trajectory.\nConstraints:\n2\u2266N\u226610^{12}\n1\u2266X\u2266N-1\nN and X are integers.\nPartial Points:\n300 points will be awarded for passing the test set satisfying N\u22661000.\nAnother 200 points will be awarded for passing the test set without additional constraints.\nInput:\nThe input is given from Standard Input in the following format:\nN X\nOutput:\nPrint the total length of the ray's trajectory.\nSample Input 1:\n5 2\nSample Output 1:\n12\nRefer to the image in the Problem Statement section. The total length of the trajectory is 2+3+2+2+1+1+1 = 12.", "before_after_length": [108, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04049", "p_user": "u054106284", "n_user": "u054106284", "pos": "import copy\n\nN, K = (int(i) for i in input().split())\n\nG = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n A, B = (int(i) for i in input().split())\n E.append((A-1, B-1))\n G[A-1].append(B-1)\n G[B-1].append(A-1)\n\ndef DFS(u, n, G):\n q = [u]\n v = [0]*N\n d = [0]*N\n while q:\n u1 = q.pop()\n v[u1] = 1\n if d[u1] < n:\n for u2 in G[u1]:\n if not v[u2]:\n d[u2] = d[u1] + 1\n q.append(u2)\n return sum(v)\n\ndef DFS_E(u, uu, n, G):\n q = [u, uu]\n v = [0]*N\n d = [0]*N\n while q:\n u1 = q.pop()\n v[u1] = 1\n if d[u1] < n:\n for u2 in G[u1]:\n if not v[u2] and u2 != u:\n d[u2] = d[u1] + 1\n q.append(u2)\n return sum(v)\n\n\nif K % 2 == 0:\n ans = 0\n for v in range(N):\n ans = max(ans, DFS(v, K//2, G))\n print(N-ans)\nelse:\n ans = 0\n for u, v in E:\n ans = max(ans, DFS_E(u,v,(K-1)//2,G))\n print(N-ans)\n", "neg": "import copy\n\nN, K = (int(i) for i in input().split())\n\nG = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n A, B = (int(i) for i in input().split())\n E.append((A-1, B-1))\n G[A-1].append(B-1)\n G[B-1].append(A-1)\n\ndef DFS(u, n, G):\n q = [u]\n v = [0]*N\n d = [0]*N\n while q:\n u1 = q.pop()\n v[u1] += 1\n if d[u1] < n:\n for u2 in G[u1]:\n if not v[u2]:\n d[u2] = d[u1] + 1\n q.append(u2)\n return sum(v)\n\ndef DFS_E(u, v, n, G):\n return 0\n\nif K % 2 == 0:\n ans = 0\n for v in range(N):\n ans = max(ans, DFS(v, K//2, G))\n print(N-ans)\nelse:\n ans = 0\n for u, v in E:\n ans = max(ans, DFS_E(u,v,K//2,G))\n print(N-ans)\n", "jacc_sim": 0.9464285714285714, "nl": "You are given an undirected tree with N vertices. The distance between vertices u and v is the number of edges on the simple path from u to v. The diameter of a tree is the maximum distance between any two vertices. A tree is considered \"good\" if its diameter is at most K. You need to remove zero or more vertices from the tree so that the resulting tree is good. Find the minimum number of vertices that need to be removed to produce a good tree. The constraints are 2\u2264N\u22642000, 1\u2264K\u2264N-1, and 1\u2264A_i, B_i\u2264N. The input is given in the format N K followed by the edges A_i B_i. Print the minimum number of vertices to remove.", "before_after_length": [461, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04049", "p_user": "u075012704", "n_user": "u075012704", "pos": "from collections import deque\n\nN, K = map(int, input().split())\nT = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n T[a].append(b)\n T[b].append(a)\n E.append((a, b))\n\n\ndef bfs(n):\n visited = [False] * N\n dist = [0] * N\n queue = deque([n])\n while queue:\n node = queue.pop()\n if visited[node]:\n continue\n visited[node] = True\n for n in T[node]:\n if not visited[n]:\n dist[n] = dist[node] + 1\n queue.appendleft(n)\n return dist\n\n\ndist = []\nfor i in range(N):\n dist.append(bfs(i))\n\nans = float('inf')\nif K % 2 == 0:\n # \u5168\u3066\u306e\u9802\u70b9\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for i in range(N):\n ans = min(ans, len([d for d in dist[i] if d > K / 2]))\nelse:\n # \u5168\u3066\u306e\u8fba\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for a, b in E:\n adist = [(1 if min(d1, d2) > (K-1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])]\n ans = min(ans, sum(adist))\n\nprint(ans)\n", "neg": "from collections import deque\n\nN, K = map(int, input().split())\nT = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n T[a].append(b)\n T[b].append(a)\n E.append((a, b))\n\n\ndef bfs(n):\n visited = [False] * N\n dist = [0] * N\n queue = deque([n])\n while queue:\n node = queue.pop()\n if visited[node]:\n continue\n visited[node] = True\n for n in T[node]:\n if not visited[n]:\n dist[n] = dist[node] + 1\n queue.appendleft(n)\n return dist\n\n\ndist = []\nfor i in range(N):\n dist.append(bfs(i))\n\nans = float('inf')\nif K % 2 == 0:\n # \u5168\u3066\u306e\u9802\u70b9\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for i in range(N):\n ans = min(ans, len(d for d in dist[i] if d > K / 2))\nelse:\n # \u5168\u3066\u306e\u8fba\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for a, b in E:\n adist = [(1 if min(d1, d2) > (K-1) / 2 else 0) for d1, d2 in zip(dist[a], dist[b])]\n ans = min(ans, sum(adist))\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given an undirected tree with N vertices. The distance between vertices u and v is the number of edges on the simple path from u to v. The diameter of a tree is the maximum distance between any two vertices. A tree is considered \"good\" if its diameter is at most K. You need to remove zero or more vertices from the tree so that the resulting tree is good. Find the minimum number of vertices that need to be removed to produce a good tree. The constraints are 2\u2264N\u22642000, 1\u2264K\u2264N-1, and 1\u2264A_i, B_i\u2264N. The input is given in the format N K followed by the edges A_i B_i. Print the minimum number of vertices to remove.", "before_after_length": [440, 440], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04049", "p_user": "u075012704", "n_user": "u075012704", "pos": "from collections import deque\n\nN, K = map(int, input().split())\nT = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n T[a].append(b)\n T[b].append(a)\n E.append((a, b))\n\n\ndef bfs(n):\n visited = [False] * N\n dist = [0] * N\n queue = deque([n])\n while queue:\n node = queue.pop()\n if visited[node]:\n continue\n visited[node] = True\n for n in T[node]:\n if not visited[n]:\n dist[n] = dist[node] + 1\n queue.appendleft(n)\n return dist\n\n\ndist = []\nfor i in range(N):\n dist.append(bfs(i))\n\nans = float('inf')\nif K % 2 == 0:\n # \u5168\u3066\u306e\u9802\u70b9\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for i in range(N):\n ans = min(ans, len(list(filter(lambda x: K / 2 < x, dist[i]))))\nelse:\n # \u5168\u3066\u306e\u8fba\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for a, b in E:\n adist = [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])]\n ans = min(ans, len(list(filter(lambda x: (K-1) / 2 < x, adist))))\n\nprint(ans)\n", "neg": "from collections import deque\n\nN, K = map(int, input().split())\nT = [[] for i in range(N)]\nE = []\nfor i in range(N-1):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n T[a].append(b)\n T[b].append(a)\n E.append((a, b))\n\n\ndef bfs(n):\n visited = [False] * N\n dist = [0] * N\n queue = deque([n])\n while queue:\n node = queue.pop()\n if visited[node]:\n continue\n visited[node] = True\n for n in T[node]:\n if not visited[n]:\n dist[n] = dist[node] + 1\n queue.appendleft(n)\n return dist\n\n\ndist = []\nfor i in range(N):\n dist.append(bfs(i))\n\nans = float('inf')\nif K % 2 == 0:\n # \u5168\u3066\u306e\u9802\u70b9\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for i in range(N):\n ans = min(ans, len(list(filter(lambda x: K / 2 < x, dist[i]))))\nelse:\n # \u5168\u3066\u306e\u8fba\u306b\u3064\u3044\u3066\u5168\u63a2\u7d22\n for a, b in E:\n dist = [min(d1, d2) for d1, d2 in zip(dist[a], dist[b])]\n ans = min(ans, len(list(filter(lambda x: (K-1) / 2 < x, dist))))\n\nprint(ans)\n", "jacc_sim": 0.9875, "nl": "You are given an undirected tree with N vertices. The distance between vertices u and v is the number of edges on the simple path from u to v. The diameter of a tree is the maximum distance between any two vertices. A tree is considered \"good\" if its diameter is at most K. You need to remove zero or more vertices from the tree so that the resulting tree is good. Find the minimum number of vertices that need to be removed to produce a good tree. The constraints are 2\u2264N\u22642000, 1\u2264K\u2264N-1, and 1\u2264A_i, B_i\u2264N. The input is given in the format N K followed by the edges A_i B_i. Print the minimum number of vertices to remove.", "before_after_length": [447, 445], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02974", "p_user": "u052499405", "n_user": "u052499405", "pos": "MOD = 10**9 + 7\nn, oddness = [int(item) for item in input().split()]\n# Oddness must be even\nif oddness % 2 == 1:\n print(0)\n exit()\noddness //= 2\nmax_oddness = 1300 + n\nmax_pending = n//2 + 2\n\ndp = [[[0] * (max_oddness) for _ in range(max_pending)] for _ in range(n)]\ndp[0][0][0] = 1\ndp[0][1][1] = 1\nfor i in range(1, n):\n for j in range(min(i+1, max_pending-1)):\n for k in range(oddness+1):\n dp_ijk = dp[i-1][j][k]\n # Oddness increase by num of pending item\n # Connect in line or Choose 1 from pending items\n dp[i][j][k+j] += dp_ijk * (1 + j*2)\n dp[i][j][k+j] %= MOD\n # Choose 2 from pending items\n if j > 0:\n dp[i][j-1][k+j-1] += dp_ijk * j*j\n # Do nothing \n dp[i][j+1][k+j+1] += dp_ijk \n\nprint(dp[n-1][0][oddness] % MOD)", "neg": "MOD = 10**9 + 7\nn, oddness = [int(item) for item in input().split()]\n# Oddness must be even\nif oddness % 2 == 1:\n print(0)\n exit()\noddness //= 2\nmax_oddness = 1300 + n\nmax_pending = n//2 + 2\n\ndp = [[[0] * (max_oddness) for _ in range(max_pending)] for _ in range(n)]\ndp[0][0][0] = 1\ndp[0][1][1] = 1\nk_itr = [item for item in range(1300)]\nfor i in range(1, n):\n for j in range(min(i+1, n//2)):\n for k in range(min(n*n, oddness+1)):\n dp_ijk = dp[i-1][j][k]\n # Oddness increase by num of pending item\n # Connect in line or Choose 1 from pending items\n dp[i][j][k+j] += dp_ijk * (1 + j*2)\n # dp[i][j][k+j] %= MOD\n # Choose 2 from pending items\n if j > 0:\n dp[i][j-1][k+j-1] += dp_ijk * j*j\n dp[i][j-1][k+j-1] %= MOD \n # Do nothing \n dp[i][j+1][k+j+1] += dp_ijk \n # dp[i][j+1][k+j+1] %= MOD \n\nprint(dp[n-1][0][oddness] % MOD)", "jacc_sim": 0.9838709677419355, "nl": "You are given a permutation of numbers from 1 to n. The \"oddness\" of a permutation is defined as the sum of the absolute differences between each number and its position in the permutation. Find the number of permutations with a given oddness, modulo 10^9+7. Constraints: 1 \u2264 n \u2264 50, 0 \u2264 k \u2264 n^2. Input format: n k. Output the number of permutations with oddness k.", "before_after_length": [339, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02977", "p_user": "u832039789", "n_user": "u832039789", "pos": "n = int(input())\nnn = n\nf = lambda x, y: x + y * nn\ng = lambda x: x if x % 2 == 1 else x + nn\n\n# 2\u306e\u7d2f\u4e57\u306f\u3080\u308a\nb = bin(n)\nif b.count('0') == len(b) - 2:\n print('No')\n exit(0)\n\nret = [\n [f(1, 0), f(2, 0)],\n [f(2, 0), f(3, 0)],\n [f(3, 0), f(1, 1)],\n [f(1, 1), f(2, 1)],\n [f(2, 1), f(3, 1)],\n]\n\nif n % 2 == 0:\n p = 2 ** (len(b) - 3)\n q = n ^ 1 ^ p\n ret.append([g(p), f(n, 0)])\n ret.append([g(q), f(n, 1)])\n n -= 1\n\n# n\u306f\u5947\u6570\nwhile n > 3:\n ret.append([f(n - 1, 0), f(n, 0)])\n ret.append([f(n, 0), f(1, 1)])\n ret.append([f(1, 1), f(n - 1, 1)])\n ret.append([f(n - 1, 1), f(n, 1)])\n n -= 2\n\nprint('Yes')\nfor x, y in ret:\n # x = x if x <= nn else x - nn\n # y = y if y <= nn else y - nn\n print(x, y)\n", "neg": "n = int(input())\nnn = n\nf = lambda x, y: x + y * nn\n\n# 2\u306e\u7d2f\u4e57\u306f\u3080\u308a\nb = bin(n)\nif b.count('0') == len(b) - 2:\n print(-1)\n exit(0)\n\nret = [\n [f(1, 0), f(2, 0)],\n [f(2, 0), f(3, 0)],\n [f(3, 0), f(1, 1)],\n [f(1, 1), f(2, 1)],\n [f(2, 1), f(3, 1)],\n]\n\nif n % 2 == 0:\n m = n ^ 1\n if m % 2 == 0:\n m += n\n ret.append([f(n, 0), f(1, 1)])\n ret.append([f(n, 1), m])\n n -= 1\n\n# n\u306f\u5947\u6570\nwhile n > 3:\n ret.append([f(n - 1, 0), f(n, 0)])\n ret.append([f(n, 0), f(1, 0)])\n ret.append([f(1, 0), f(n - 1, 1)])\n ret.append([f(n - 1, 1), f(n, 1)])\n n -= 2\n\nprint('Yes')\nfor x, y in ret:\n # x = x if x <= nn else x - nn\n # y = y if y <= nn else y - nn\n print(x, y)\n", "jacc_sim": 0.9107142857142857, "nl": "You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints:\n- N is an integer.\n- 1 <= N <= 10^5\n\nInput:\nInput is given from Standard Input in the following format:\nN\n\nOutput:\nIf there exists a tree satisfying the condition in the statement, print \"Yes\"; otherwise, print \"No\". Then, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines. Each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1:\n3\n\nSample Output 1:\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph.\n\nSample Input 2:\n1\n\nSample Output 2:\nNo", "before_after_length": [412, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02977", "p_user": "u754022296", "n_user": "u754022296", "pos": "n = int(input())\nb = 1 << (n.bit_length()-1)\nif n - b == 0:\n print(\"No\")\nelse:\n print(\"Yes\")\n print(1, 2)\n print(2, 3)\n print(3, n+1)\n print(n+1, n+2)\n print(n+2, n+3)\n for i in range(4, n, 2):\n print(i, i+1)\n print(i+n, i+n+1)\n print(1+n, i+n)\n print(1+n, i+1)\n if (~n)&1:\n print(n, b+n)\n a = n ^ b ^ 1\n print(n+n, a)", "neg": "n = int(input())\nb = 1 << (n.bit_length()-1)\nif n - b == 0:\n print(\"No\")\nelse:\n print(\"Yes\")\n for i in range(1, 4):\n print(i, i+1)\n print(i+n, i+n+1)\n for i in range(4, n, 2):\n print(i, i+1)\n print(i+n, i+n+1)\n print(1, i)\n print(1, i+n+1)\n if (~n)&1:\n print(n, b)\n a = n - b\n if a&1:\n print(n+n, a+n)\n else:\n print(n+n, a)", "jacc_sim": 0.9393939393939394, "nl": "You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints:\n- N is an integer.\n- 1 <= N <= 10^5\n\nInput:\nInput is given from Standard Input in the following format:\nN\n\nOutput:\nIf there exists a tree satisfying the condition in the statement, print \"Yes\"; otherwise, print \"No\". Then, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines. Each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1:\n3\n\nSample Output 1:\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph.\n\nSample Input 2:\n1\n\nSample Output 2:\nNo", "before_after_length": [194, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02977", "p_user": "u253759478", "n_user": "u253759478", "pos": "n = int(input())\n\nif bin(n).count('1') == 1:\n print('No')\nelse:\n print('Yes')\n print('1 2')\n print('2 3')\n print('3 {0}'.format(n + 1))\n print('{0} {1}'.format(n + 1, n + 2))\n print('{0} {1}'.format(n + 2, n + 3))\n\n if n >= 5:\n if n % 2 == 1:\n for i in range(4, n + 1):\n print('1 {0}'.format(i))\n if i % 2 == 0:\n print('{0} {1}'.format(i, i + 1 + n))\n else:\n print('{0} {1}'.format(i, i - 1 + n))\n else:\n for i in range(4, n):\n print('1 {0}'.format(i))\n if i % 2 == 0:\n print('{0} {1}'.format(i, i + 1 + n))\n else:\n print('{0} {1}'.format(i, i - 1 + n))\n print('{0} {1}'.format(n - 1, n))\n print('{0} {1}'.format((n - 1) ^ 1 ^ n, n * 2))\n", "neg": "n = int(input())\n\nif bin(n).count('1') == 1:\n print('No')\nelse:\n print('1 2')\n print('2 3')\n print('3 {0}'.format(n + 1))\n print('{0} {1}'.format(n + 1, n + 2))\n print('{0} {1}'.format(n + 2, n + 3))\n\n if n >= 5:\n if n % 2 == 1:\n for i in range(2, n + 1):\n print('1 {0}'.format(i))\n if i % 2 == 0:\n print('{0} {1}'.format(i, i + 1 + n))\n else:\n print('{0} {1}'.format(i, i - 1 + n))\n else:\n for i in range(2, n):\n print('1 {0}'.format(i))\n if i % 2 == 0:\n print('{0} {1}'.format(i, i + 1 + n))\n else:\n print('{0} {1}'.format(i, i - 1 + n))\n print('{0} {1}'.format(n - 1, n))\n print('{0} {1}'.format((n - 1) ^ 1 ^ n, n * 2))\n", "jacc_sim": 0.9444444444444444, "nl": "You are given an integer N. Determine if there exists a tree with 2N vertices numbered 1 to 2N satisfying the following condition, and show one such tree if the answer is yes. Assume that, for each integer i between 1 and N (inclusive), Vertex i and N+i have the weight i. Then, for each integer i between 1 and N, the bitwise XOR of the weights of the vertices on the path between Vertex i and N+i (including themselves) is i.\n\nConstraints:\n- N is an integer.\n- 1 <= N <= 10^5\n\nInput:\nInput is given from Standard Input in the following format:\nN\n\nOutput:\nIf there exists a tree satisfying the condition in the statement, print \"Yes\"; otherwise, print \"No\". Then, if such a tree exists, print the 2N-1 edges of such a tree in the subsequent 2N-1 lines. Each pair (a_i, b_i) means that there is an edge connecting Vertex a_i and b_i. The edges may be printed in any order.\n\nSample Input 1:\n3\n\nSample Output 1:\nYes\n1 2\n2 3\n3 4\n4 5\n5 6\n\nThe sample output represents the following graph.\n\nSample Input 2:\n1\n\nSample Output 2:\nNo", "before_after_length": [333, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u595289165", "n_user": "u595289165", "pos": "from collections import deque\nn, m = map(int, input().split())\n\ngraph = [[] for _ in range(n+1)]\nfor _ in range(m):\n u, v = map(int, input().split())\n graph[u].append(v)\n\ns, t = map(int, input().split())\n\ndist = [[-3] * 3 for _ in range(n+1)]\ndist[s][0] = 0\n\nq = deque([(s, 0)])\n\nwhile q:\n now, c = q.popleft()\n ne = (c+1) % 3\n for node in graph[now]:\n if dist[node][ne] != -3:\n continue\n dist[node][ne] = dist[now][c] + 1\n q.append((node, ne))\n\nprint(dist[t][0] // 3)\n", "neg": "from collections import deque\nn, m = map(int, input().split())\n\ngraph = [[] for _ in range(n+1)]\nfor _ in range(m):\n u, v = map(int, input().split())\n graph[u].append(v)\n\ns, t = map(int, input().split())\n\ninf = 10**10\ndist = [[-3] * 3 for _ in range(n+1)]\ndist[s][0] = 0\n\nq = deque([(s, 0)])\n\nwhile q:\n now, c = q.pop()\n ne = (c+1) % 3\n for node in graph[now]:\n if dist[node][ne] != -1:\n continue\n dist[node][ne] = dist[now][c] + 1\n q.append((node, ne))\n\nprint(dist[t][0] // 3)\n", "jacc_sim": 0.9215686274509803, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [211, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u470542271", "n_user": "u470542271", "pos": "n, m = map(int, input().split())\nuv = [list(map(int, input().split())) for _ in range(m)]\ns, t = map(int, input().split())\n\nimport heapq\nfrom collections import defaultdict\ng1 = defaultdict(set)\nfor u, v in uv:\n g1[u-1].add(v-1)\n\ns -= 1\nt -= 1\n\ndist = [[float('inf')] * 3 for _ in range(n)]\ndist[s][0] = 0\n\nq = [(0, s, 0)] # (dist, pos, kenken)\nheapq.heapify(q)\n\nwhile q:\n du, u, c = heapq.heappop(q)\n if dist[u][c] < du:\n continue\n c2 = (c + 1) % 3\n for v in g1[u]:\n if du + 1 < dist[v][c2]:\n dist[v][c2] = du + 1\n heapq.heappush(q, (dist[v][c2], v, c2))\n\nif dist[t][0] != float('inf'):\n print(dist[t][0] // 3)\nelse:\n print(-1)\n", "neg": "n, m = map(int, input().split())\nuv = [list(map(int, input().split())) for _ in range(m)]\ns, t = map(int, input().split())\n\nimport heapq\nfrom collections import defaultdict, deque\ng1 = defaultdict(set)\nfor u, v in uv:\n g1[u-1].add(v-1)\n\ns -= 1\nt -= 1\n\ndist = [[float('inf')] * 3 for _ in range(n)]\ndist[s][0] = 0\n\nq = [(0, s, 0)] # (dist, pos, kenken)\nheapq.heapify(q)\n\nwhile q:\n du, u, c = heapq.heappop(q)\n if dist[u][c] < du:\n continue\n c2 = (c + 1) % 3\n for v in g1[u]:\n if du + 1 < dist[v][c2]:\n dist[v][c2] = du + 1\n heapq.heappush(q, (dist[v][c2], v, c2))\n\nif dist[t][0] != float('inf'):\n print(d)\nelse:\n print(-1)\n", "jacc_sim": 0.9523809523809523, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [304, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u265506056", "n_user": "u265506056", "pos": "import collections\nN,M=map(int,input().split())\ntree=[[] for _ in range(N)]\nfor _ in range(M):\n u,v=map(int,input().split())\n tree[u-1].append(v-1)\nS,T=map(int,input().split())\ns=S-1\nt=T-1\nischecked=[[0]*3 for _ in range(N)]\nischecked[s][0]=1\nans=-1\nq=collections.deque()\nq.append([s,0])\nwhile q:\n v,c=q.popleft()\n if v==t and c%3==0:\n ans=c//3\n break\n for i in tree[v]:\n if ischecked[i][(c+1)%3]==0:\n q.append([i,c+1])\n ischecked[i][(c+1)%3]=1\nprint(ans)", "neg": "import collections\nN,M=map(int,input().split())\ntree=[[] for _ in range(N)]\nfor _ in range(M):\n u,v=map(int,input().split())\n tree[u-1].append(v-1)\nS,T=map(int,input().split())\ns=S-1\nt=T-1\nischecked=[[0]*3 for _ in range(N)]\nischecked[s][0]=1\nans=-1\nq=collections.deque()\nq.append([s,0])\nwhile q:\n v,c=q.pop(0)\n if v==t and c%3==0:\n ans=c//3\n break\n for i in tree[v]:\n if ischecked[i][(c+1)%3]==0:\n q.append([i,c+1])\n ischecked[i][(c+1)%3]==1\nprint(ans)", "jacc_sim": 0.9591836734693877, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [233, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u686230543", "n_user": "u686230543", "pos": "from collections import deque\n\nn, m = map(int, input().split())\nadj_list = [[] for _ in range(3 * n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n adj_list[3 * u - 3].append(3 * v - 2)\n adj_list[3 * u - 2].append(3 * v - 1)\n adj_list[3 * u - 1].append(3 * v - 3)\n\ns, t = map(int, input().split())\ndist = [-1] * (3 * n)\nqueue = deque([3 * s - 3])\ndist[3 * s - 3] = 0\nwhile queue:\n vertex = queue.popleft()\n for next_vertex in adj_list[vertex]:\n if dist[next_vertex] != -1:\n continue\n dist[next_vertex] = dist[vertex] + 1\n queue.append(next_vertex)\nt_distance = dist[3 * t - 3]\nif t_distance == -1:\n print(-1)\nelse:\n print(t_distance // 3)", "neg": "from collections import deque\n\nn, m = map(int, input().split())\nadj_list = [[] for _ in range(3 * n)]\nfor _ in range(m):\n u, v = map(int, input().split())\n adj_list[3 * u - 3].append(3 * v - 2)\n adj_list[3 * u - 2].append(3 * v - 1)\n adj_list[3 * u - 1].append(3 * v - 3)\n\ns, t = map(int, input().split())\ndist = [-1] * (3 * n)\nqueue = deque([3 * s - 3])\ndist[3 * s - 3] = 0\nwhile queue:\n vertex = queue.leftpop()\n for next_vertex in adj_list[vertex]:\n if dist[next_vertex] == -1:\n continue\n dist[next_vertex] = dist[vertex] + 1\n queue.append(next_vertex)\nt_distance = dist[3 * t - 3]\nif t_distance == -1:\n print(-1)\nelse:\n print(t_distance // 3)", "jacc_sim": 0.9387755102040817, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [272, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\nfrom collections import deque\ninput = sys.stdin.readline\nn,m = map(int,input().split())\nab = [list(map(int,input().split())) for i in range(m)]\ngraph = [[] for i in range(n+1)]\nfor a,b in ab:\n graph[a].append(b)\ns,t = map(int,input().split())\nvisited = [[-1,-1,-1] for i in range(n+1)]\nque = deque([(s,0,0)])\nwhile que:\n x,mod,cnt = que.popleft()\n visited[x][mod] = cnt\n if x == t and mod == 0:\n break\n for y in graph[x]:\n if visited[y][(mod+1)%3] == -1:\n que.append((y,(mod+1)%3,cnt+1))\n visited[y][(mod+1)%3] = cnt+1\nprint(visited[t][0]//3)", "neg": "from collections import deque\nn,m=map(int,input().split())\nab=[list(map(int,input().split())) for i in range(m)]\ngraph=[[] for i in range(n+1)]\nfor a,b in ab:\n graph[a].append(b)\n graph[b].append(a)\ns,t=map(int,input().split())\nvisited=[[-1,-1,-1] for i in range(n+1)]\nque=deque([(s,0,0)])\nwhile que:\n x,mod,cnt=que.popleft()\n visited[x][mod]=cnt\n if x==t and mod==0:\n break\n for y in graph[x]:\n if visited[y][(mod+1)%3]==-1:\n que.append((y,(mod+1)%3,cnt+1))\nprint(visited[t][0])", "jacc_sim": 0.9230769230769231, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [250, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u121921603", "n_user": "u121921603", "pos": "from collections import deque\nn,m=map(int,input().split())\ng=[[] for _ in range(n)]\nfor _ in range(m):\n u,v=list(map(int,input().split()))\n g[u-1].append(v-1)\nS,T=map(int,input().split())\nS-=1;T-=1\nINF=10**9\nU=[[INF]*n for i in range(3)]\nU[0][S]=0\nque=deque([(0,S)])\nwhile que:\n t,v=que.popleft()\n u=(t+1)%3\n if t==2:\n U[t][v]+=1\n for w in g[v]:\n if U[u][w]!=INF:\n continue\n que.append((u,w))\n U[u][w]=U[t][v]\nprint(U[0][T] if U[0][T]=0:\n continue\n dist[nv] = d+1\n que.append(nv)\nprint(dist[(T-1, 0)]//3)\n", "neg": "from collections import defaultdict, deque\nN, M = map(int, input().split())\nG = defaultdict(list)\nfor _ in range(M):\n u, v = map(int, input().split())\n G[(u-1, 0)].append((v-1, 1))\n G[(u-1, 1)].append((v-1, 2))\n G[(u-1, 2)].append((v-1, 0))\nS, T = map(int, input().split())\nG3 = defaultdict(list)\ndist = defaultdict(lambda : -1)\nque = deque([(S-1, 0)])\ndist[(S-1, 0)] = 0\nwhile que:\n if v == (T-1, 0):\n break\n v = que.pop()\n d = dist[v]\n for nv in G[v]:\n if dist[nv]>=0:\n continue\n dist[nv] = d+1\n que.append(nv)\nprint(dist[(T-1, 0)]//3)\n", "jacc_sim": 0.9215686274509803, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [234, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u533039576", "n_user": "u533039576", "pos": "n, m = map(int, input().split())\n\ngraph1 = [[] for _ in range(n * 3)]\n\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n graph1[u * 3 + 0].append(v * 3 + 1)\n graph1[u * 3 + 1].append(v * 3 + 2)\n graph1[u * 3 + 2].append(v * 3 + 0)\n\ns, t = map(int, input().split())\ns -= 1\nt -= 1\ns = s * 3\nt = t * 3\n\nfrom heapq import heappush, heappop\n\n\ndef dijkstra(graph: list, n: int, start: int, INF: int = float('inf')) -> list:\n # graph[node] = [(cost, to)]\n dist = [INF] * n\n num = [0] * n\n\n dist[start] = 0\n heap = [(0, start)]\n while heap:\n _, v_from = heappop(heap)\n for v_to in graph[v_from]:\n dist_cand = dist[v_from] + 1\n if dist_cand < dist[v_to]:\n dist[v_to] = dist_cand\n heappush(heap, (dist[v_to], v_to))\n return dist\n # dist = [costs to nodes]\n\n\ninf = float('inf')\ndist = dijkstra(graph1, n * 3, s)\nif dist[t] == inf:\n print(-1)\nelse:\n print(dist[t] // 3)\n", "neg": "n, m = map(int, input().split())\n\ngraph1 = [[] for _ in range(n * 3)]\n\nfor _ in range(m):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n graph1[u * 3 + 0].append(v * 3 + 1)\n graph1[u * 3 + 1].append(v * 3 + 2)\n graph1[u * 3 + 2].append(v * 3 + 0)\n\ns, t = map(int, input().split())\ns -= 1\nt -= 1\ns = s * 3\nt = t * 3\n\nfrom heapq import heappush, heappop\n\n\ndef dijkstra(graph: list, n: int, start: int, INF: int = float('inf')) -> list:\n # graph[node] = [(cost, to)]\n dist = [INF] * n\n num = [0] * n\n\n dist[start] = 0\n heap = [(0, start)]\n while heap:\n _, v_from = heappop(heap)\n for v_to in graph[v_from]:\n dist_cand = dist[v_from] + 1\n if dist_cand < dist[v_to]:\n dist[v_to] = dist_cand\n heappush(heap, (dist[v_to], v_to))\n return dist\n # dist = [costs to nodes]\n\n\ninf = float('inf')\ndist = dijkstra(graph1, n * 3, s, INF=10**8)\nif dist[t] == inf:\n print(-1)\nelse:\n print(dist[t] // 3)\n", "jacc_sim": 0.9701492537313433, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [412, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u327466606", "n_user": "u327466606", "pos": "from itertools import count\nN,M = map(int,input().split())\n\nadj = [list() for _ in range(N)]\n\n\nfor _ in range(M):\n u,v = map(int,input().split())\n adj[u-1].append(v-1)\n\nS,T = map(int,input().split())\nS,T = S-1,T-1\n\nvisited = [False]*(N*3)\nvisited[S] = True\nq = [S]\n\nfor step in count(1):\n offset = N*(step % 3)\n nq = []\n for u in q:\n for v in adj[u]:\n if not visited[v+offset]:\n nq.append(v)\n visited[v+offset] = True\n q = nq\n\n if visited[T] or not q:\n break\nif visited[T]:\n print(step//3)\nelse:\n print(-1)", "neg": "from itertools import count\nN,M = map(int,input().split())\n\nadj = [list() for _ in range(N)]\n\n\nfor _ in range(M):\n u,v = map(int,input().split())\n adj[u-1].append(v-1)\n\nS,T = map(int,input().split())\nS,T = S-1,T-1\n\nvisited = [False]*(N*3)\nvisited[S] = True\nq = [S]\n\nfor step in count():\n offset = N*(step % 3)\n nq = []\n for u in q:\n for v in adj[u]:\n if not visited[v+offset]:\n nq.append(v)\n visited[v+offset] = True\n q = nq\n\n if visited[T] or not q:\n break\nif visited[T]:\n print(step//3)\nelse:\n print(-1)", "jacc_sim": 1.0, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [234, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u214617707", "n_user": "u214617707", "pos": "from collections import deque\nimport sys\ninput = sys.stdin.readline\nN, M = map(int, input().split())\nG = [[] for i in range(3 * N)]\nfor i in range(M):\n u, v = map(int, input().split())\n u, v = u - 1, v - 1\n G[3 * u + 0].append(3 * v + 1)\n G[3 * u + 1].append(3 * v + 2)\n G[3 * u + 2].append(3 * v + 0)\nS, T = map(int, input().split())\nS, T = S - 1, T - 1\nINF = float('inf')\nd = [INF] * (3 * N)\nd[3 * S] = 0\n\n\nque = deque([3 * S])\nwhile que:\n u = que.popleft()\n for w in G[u]:\n if d[w] == INF:\n d[w] = d[u] + 1\n que.append(w)\n\n\nans = d[3 * T]\nif ans == INF:\n print(-1)\nelse:\n print(ans // 3)", "neg": "from collections import deque\nimport sys\ninput = sys.stdin.readline\nN, M = map(int, input().split())\nG = [[] for i in range(3 * N)]\nfor i in range(M):\n u, v = map(int, input().split())\n u, v = u - 1, v - 1\n G[3 * u + 0].append(3 * v + 1)\n G[3 * u + 1].append(3 * v + 2)\n G[3 * u + 2].append(3 * v + 0)\nS, T = map(int, input().split())\nS, T = S - 1, T - 1\nINF = float('inf')\nd = [INF] * (3 * N)\nd[3 * S] = 0\n\n\nque = deque([(3 * S, 0)])\nwhile que:\n u, k = que.pop()\n d[u] = k\n for w in G[u]:\n if d[w] == INF:\n que.append((w, k + 1))\n\n\nans = d[3 * T] // 3\nif ans == INF:\n print(-1)\nelse:\n print(ans)", "jacc_sim": 0.9444444444444444, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [283, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u279461856", "n_user": "u279461856", "pos": "N, M = map(int, input().split())\nG = [[] for i in range(N+1)]\nfor i in range(M):\n u, v = map(int, input().split())\n G[u].append(v)\ns, t = map(int, input().split())\n\nd = [-1] * (N + 1)\n\nS = set()\nS.add(s)\nd[s] = 0\nx = 1\nwhile len(S) > 0:\n Q1 = set()\n for u in S:\n for v in G[u]:\n Q1.add(v)\n Q2 = set()\n for u in Q1:\n for v in G[u]:\n Q2.add(v)\n Q3 = set()\n for u in Q2:\n for v in G[u]:\n if d[v] < 0:\n d[v] = x\n Q3.add(v)\n x += 1\n S = Q3\n\nprint(d[t])\n", "neg": "N, M = map(int, input().split())\nG = [[] for i in range(M+1)]\nfor i in range(M):\n u, v = map(int, input().split())\n G[u].append(v)\ns, t = map(int, input().split())\n\nd = [-1] * (N + 1)\n\nS = set()\nS.add(s)\nd[s] = 0\nx = 1\nwhile len(S) > 0:\n Q1 = set()\n for u in S:\n for v in G[u]:\n Q1.add(v)\n Q2 = set()\n for u in Q1:\n for v in G[u]:\n Q2.add(v)\n Q3 = set()\n for u in Q2:\n for v in G[u]:\n if d[v] < 0:\n d[v] = x\n Q3.add(v)\n x += 1\n S = Q3\n\nprint(d[t])\n", "jacc_sim": 1.0, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [253, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u554954744", "n_user": "u554954744", "pos": "from collections import deque\n\nN, M = map(int, input().split())\nedge = [[] for i in range(N)]\nfor i in range(M):\n u, v = map(int, input().split())\n edge[u-1].append(v-1)\nS, T = map(int, input().split())\nS, T = S-1, T-1\n\nINF = float('inf')\ndist = [[INF for i in range(3)] for j in range(N)]\n\ndef bfs():\n q = deque()\n q.append((S, 0))\n dist[S][0] = 0\n while q:\n p = q.popleft()\n v = p[0]\n l = p[1]\n for nv in edge[v]:\n nl = (l+1)%3\n if dist[nv][nl] != INF:\n continue\n dist[nv][nl] = dist[v][l] + 1\n q.append((nv, nl))\n return dist[T][0]\n\nans = bfs()\nif ans == INF:\n ans = -1\nelse:\n ans = ans // 3\nprint(ans)", "neg": "from collections import deque\n\nN, M = map(int, input().split())\nedge = [[] for i in range(N)]\nfor i in range(M):\n u, v = map(int, input().split())\n edge[u-1].append(v-1)\nS, T = map(int, input().split())\nS, T = S-1, T-1\n\nINF = float('inf')\ndist = [[INF for i in range(3)] for j in range(N)]\n\ndef bfs():\n q = deque()\n q.append((S, 0))\n dist[S][0] = 0\n while q:\n p = q.popleft()\n v = p[0]\n l = p[1]\n for nv in edge[v]:\n nl = (l+1)%3\n if dist[nv][nl] != INF:\n continue\n dist[nv][nl] = dist[v][l] + 1\n q.append((nv, nl))\n return dist[T][0] // 3\n\nprint(bfs())", "jacc_sim": 0.9649122807017544, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [285, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u256315261", "n_user": "u256315261", "pos": "def BC132_E():\n n, m = list(map(int, input().split(' ')))\n e = [[] for _ in range(n)]\n for _ in range(m):\n u, v = list(map(int, input().split(' ')))\n e[u - 1].append(v - 1)\n s, t = list(map(int, input().split(' ')))\n s, t = s - 1, t - 1\n stack, visited = [(s, 0)], set()\n a, b = set(), set()\n while stack:\n i, d = stack.pop(0)\n if i == t: return d\n if i in visited:\n continue\n visited.add(i)\n v = set()\n for j in e[i]:\n if j in a: continue\n a.add(j)\n for k in e[j]:\n if k in b: continue\n b.add(k)\n v.update(e[k])\n if t in v:\n return d + 1\n else:\n stack += [(x, d + 1) for x in list(v)]\n return -1\n\n\nprint(BC132_E())", "neg": "def BC132_E():\n n, m = list(map(int, input().split(' ')))\n e = [[] for _ in range(n)]\n for _ in range(m):\n u, v = list(map(int, input().split(' ')))\n e[u - 1].append(v - 1)\n s, t = list(map(int, input().split(' ')))\n s, t = s - 1, t - 1\n stack, visited = [(s, 0)], set()\n while stack:\n i, d = stack.pop(0)\n if i in visited:\n continue\n visited.add(i)\n a = []\n for j in e[i]:\n a += e[j]\n b = []\n for j in a:\n b += e[j]\n b = set(b)\n if t in b:\n return d + 1\n else:\n stack += [(x, d + 1) for x in list(b)]\n return -1\n\n\nprint(BC132_E())", "jacc_sim": 0.9607843137254902, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [295, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u171366497", "n_user": "u171366497", "pos": "import sys\ninput=sys.stdin.readline\nn,m=map(int,input().split())\nfrom collections import defaultdict\nbranch=defaultdict(set)\nfor i in range(m):\n u,v=map(int,input().split())\n branch[u-1]|={v-1}\ns,t=map(int,input().split())\ns-=1\nt-=1\ndist=[[float('inf')]*3 for i in range(n)]\ncheck={(s,0)}\ndist[s][0]=0\nwhile len(check)>0:\n now,nowd=check.pop()\n for nex in branch[now]:\n if dist[nex][(nowd+1)%3]>dist[now][nowd]+1:\n dist[nex][(nowd+1)%3]=dist[now][nowd]+1\n check|={(nex,(nowd+1)%3)}\nif dist[t][0]>10**18:\n print(-1)\nelse:\n print(dist[t][0]//3)", "neg": "import sys\ninput=sys.stdin.readline\nn,m=map(int,input().split())\nfrom collections import defaultdict\nbranch=defaultdict(set)\nfor i in range(m):\n u,v=map(int,input().split())\n branch[u-1]|={v-1}\ns,t=map(int,input().split())\ns-=1\nt-=1\ndist=[[float('inf')]*3 for i in range(n)]\ncheck={(s,0)}\ndist[s][0]=0\nwhile len(check)>0:\n now,nowd=check.pop()\n for nex in branch[now]:\n if dist[nex][(nowd+1)%3]>dist[now][nowd]+1:\n ans[nex][(nowd+1)%3]=ans[now][nowd]+1\n check|={(nex,(nowd+1)%3)}\nif dist[t][0]>10**18:\n print(-1)\nelse:\n print(dist[t][0]//3)", "jacc_sim": 0.9833333333333333, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [264, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u060938295", "n_user": "u060938295", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 11:43:19 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\nfrom collections import deque\n\nN, M = map(int,input().split())\nuv = [list(map(int,input().split())) for i in range(M)]\nS, T = map(int,input().split())\n\nTa = [[] for i in range(3*N+1)]\nfor c in uv:\n Ta[c[0]].append(c[1]+N)\n Ta[c[0]+N].append(c[1]+2*N)\n Ta[c[0]+2*N].append(c[1])\n\ncheck = [0 for i in range(3*N+1)]\n\nq = deque([S])\ncheck[S] = 1\ncounta = 0\nflg = False\nwhile len(q) > 0:\n for i in range(len(q)):\n nexts = Ta[q.popleft()]\n for next_ in nexts:\n if check[next_] != 1:\n q.append(next_)\n check[next_] = 1\n counta += 1\n if check[T] == 1:\n flg = True\n break\nif flg:\n print(counta//3)\nelse:\n print(-1)", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Jul 1 11:43:19 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\nfrom collections import deque\n\nN, M = map(int,input().split())\nuv = [list(map(int,input().split())) for i in range(M)]\nS, T = map(int,input().split())\n\nTa = [[] for i in range(3*N+1)]\nfor c in uv:\n Ta[c[0]].append(c[1]+N)\n Ta[c[0]+N].append(c[1]+2*N)\n Ta[c[0]+2*N].append(c[1])\ndel c\n\ncheck = [0 for i in range(3*N+1)]\n\nq = deque([S])\ncheck[S] = 1\ncounta = 0\nwhile len(q) > 0:\n for i in range(len(q)):\n nexts = Ta[q.popleft()]\n for next_ in nexts:\n if check[next_] != 1:\n q.append(next_)\n check[next_] = 1\n counta += 1\n if check[T] == 1:\n break\n\nprint(counta//3)", "jacc_sim": 0.9305555555555556, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [343, 321], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u222207357", "n_user": "u222207357", "pos": "from collections import deque\n\nN,M = map(int,input().split())\n\nconnect = [[] for _ in range(3*N)]\n\nfor _ in range(M):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n connect[u].append(v+N)\n connect[u+N].append(v+2*N)\n connect[u+2*N].append(v)\n\nS,T = map(int,input().split())\nS -= 1\nT -= 1\n\ndef bfs(s):\n q = deque()\n q.append(s)\n d = [-1 for _ in range(3*N)]\n d[s] = 0\n \n while q:\n v = q.popleft()\n if v == T:\n return d[v]\n \n for u in connect[v]:\n if d[u] == -1:\n q.append(u)\n d[u] = d[v]+1\n \n return -1\n\nans = bfs(S)\n\nif ans == -1:\n print(-1)\nelse:\n print(ans//3)", "neg": "from collections import deque\n\nN,M = map(int,input().split())\n\nconnect = [[] for _ in range(3*N)]\n\nfor _ in range(M):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n connect[u].append(v+N)\n connect[u+N].append(v+2*N)\n connect[u+2*N].append(v)\n\nS,T = map(int,input().split())\nS -= 1\nT -= 1\n\ndef bfs(s):\n q = deque()\n q.append(s)\n d = [-1 for _ in range(3*N)]\n d[s]\n \n while q:\n v = q.popleft()\n if v == T:\n return d[v]\n \n for u in connect[v]:\n if d[u] == -1:\n q.append(u)\n d[u] = d[v]+1\n \n return -1\n\nans = bfs(S)\n\nif ans == -1:\n print(-1)\nelse:\n print(ans//3)", "jacc_sim": 0.9791666666666666, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [289, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u059210959", "n_user": "u059210959", "pos": "# encoding:utf-8\nimport copy\nimport random\nimport bisect #bisect_left\u3000\u3053\u308c\u3067\u4e8c\u90e8\u63a2\u7d22\u306e\u5927\u5c0f\u691c\u7d22\u304c\u884c\u3048\u308b\nimport fractions #\u6700\u5c0f\u516c\u500d\u6570\u306a\u3069\u306f\u3053\u3063\u3061\nimport math\nimport sys\nimport numpy as np\nimport queue\n\nmod = 10**9+7\nsys.setrecursionlimit(mod) # \u518d\u5e30\u56de\u6570\u4e0a\u9650\u306f\u3067default1000\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\nN,M = LI()\n\num = [[] for i in range(M)]\nfor i in range(M):\n um[i] = LI()\n\nS,T = LI()\nS -= 1\nT -= 1\nroutes = [[] for i in range(N)]\n\nfor i in range(M):\n u,m = um[i]\n u -= 1\n m -= 1\n routes[u].append(m)\n\nused = [[mod,mod,mod] for i in range(N)]\n\nfrom collections import deque\n\n# q = queue.Queue()\nq = deque()\nq.append((S,0))\n# Deep First Serch\nwhile q:\n now, cost = q.popleft()\n state = cost % 3\n if used[now][state] == mod:\n used[now][state] = cost\n for route in routes[now]:\n q.append((route,cost+1))\n\n# print(used)\ntry:\n ans = used[T][0]\n if ans == mod:\n ans = -1\n else:\n ans = ans/3\nexcept:\n ans = -1\nprint(int(ans))\n", "neg": "# encoding:utf-8\nimport copy\nimport random\nimport bisect #bisect_left\u3000\u3053\u308c\u3067\u4e8c\u90e8\u63a2\u7d22\u306e\u5927\u5c0f\u691c\u7d22\u304c\u884c\u3048\u308b\nimport fractions #\u6700\u5c0f\u516c\u500d\u6570\u306a\u3069\u306f\u3053\u3063\u3061\nimport math\nimport sys\nimport numpy as np\nimport queue\n\nmod = 10**9+7\nsys.setrecursionlimit(mod) # \u518d\u5e30\u56de\u6570\u4e0a\u9650\u306f\u3067default1000\n\ndef LI(): return list(map(int, sys.stdin.readline().split()))\nN,M = LI()\n\num = [[] for i in range(M)]\nfor i in range(M):\n um[i] = LI()\n\nS,T = LI()\nS -= 1\nT -= 1\nroutes = []\nfor i in range(N):\n routes[i] = []\nfor i in range(M):\n u,m = um[i]\n u -= 1\n m -= 1\n routes[u].append(m)\n\nused = np.array([[mod,mod,mod] for i in range(N)])\n\nq = queue.Queue()\nq.put((S,0))\n# Deep First Serch\nwhile q.empty() == False:\n now, cost = q.get()\n state = cost % 3\n if used[now,state] == mod:\n used[now,state] = cost\n for route in routes[now]:\n q.put((route,cost+1))\n\n# print(used)\ntry:\n ans = used[T, 0]\n if ans == mod:\n ans = -1\n else:\n ans = ans/3\nexcept:\n ans = -1\nprint(int(ans))\n", "jacc_sim": 0.9217391304347826, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [475, 479], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u047816928", "n_user": "u047816928", "pos": "N, M = [int(c) for c in input().split()]\npath = [[] for _ in range(N)]\nfor i in range(M):\n u, v = [int(c) for c in input().split()]\n path[u-1].append(v-1)\n\nS, T = [int(c)-1 for c in input().split()]\n\nreach = [[-1 for _ in range(N)] for _ in range(3)]\nreach[0][S] = 0\n\nqueue={S}\n\ntime = 1\nfor _ in range(4*N):\n queue_new = set()\n for q in queue:\n for v in path[q]:\n if reach[time%3][v]==-1:\n reach[time%3][v]=time\n queue_new.add(v)\n\t\t\n queue = queue_new\n time += 1\n\nif reach[0][T]==-1:\n print(-1)\nelse:\n print(reach[0][T]//3)", "neg": "S, T = [int(c)-1 for c in input().split()]\n\nreach = [[-1 for _ in range(N)] for _ in range(3)]\nreach[0][S] = 0\n\nqueue={S}\n\ntime = 1\nfor _ in range(4*N):\n queue_new = set()\n for q in queue:\n for v in path[q]:\n if reach[time%3][v]==-1:\n reach[time%3][v]=time\n queue_new.add(v)\n\t\t\n queue = queue_new\n time += 1\n\nif reach[0][T]==-1:\n print(-1)\nelse:\n print(reach[0][T]//3)", "jacc_sim": 0.9130434782608695, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [251, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u170201762", "n_user": "u170201762", "pos": "N,M = map(int,input().split())\n\ng = [[] for _ in range(3*N)]\nfor _ in range(M):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n g[u].append((1,v+N))\n g[u+N].append((1,v+2*N))\n g[u+2*N].append((1,v))\n\nfrom heapq import heappush, heappop\ndef dijkstra(graph:list, node:int, start:int) -> list:\n inf = float('inf')\n dist = [inf]*node\n\n dist[start] = 0\n heap = [(0,start)]\n while heap:\n cost,thisNode = heappop(heap)\n for NextCost,NextNode in graph[thisNode]:\n dist_cand = dist[thisNode]+NextCost\n if dist_cand < dist[NextNode]:\n dist[NextNode] = dist_cand\n heappush(heap,(dist[NextNode],NextNode))\n return dist\nS,T = map(int,input().split())\ndij = dijkstra(g,3*N,S-1)\nans = dij[T-1]//3\nif ans == float('inf') or ans!=ans:\n ans = -1\nprint(ans)", "neg": "N,M = map(int,input().split())\n\ng = [[] for _ in range(3*N)]\nfor _ in range(M):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n g[u].append((1,v+N))\n g[u+N].append((1,v+2*N))\n g[u+2*N].append((1,v))\n\nfrom heapq import heappush, heappop\ndef dijkstra(graph:list, node:int, start:int) -> list:\n inf = float('inf')\n dist = [inf]*node\n\n dist[start] = 0\n heap = [(0,start)]\n while heap:\n cost,thisNode = heappop(heap)\n for NextCost,NextNode in graph[thisNode]:\n dist_cand = dist[thisNode]+NextCost\n if dist_cand < dist[NextNode]:\n dist[NextNode] = dist_cand\n heappush(heap,(dist[NextNode],NextNode))\n return dist\nS,T = map(int,input().split())\ndij = dijkstra(g,3*N,S-1)\nans = dij[T-1]//3\nif ans == float('inf') or M==0:\n ans = -1\n\nprint(ans)", "jacc_sim": 0.984375, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [338, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02991", "p_user": "u119714109", "n_user": "u119714109", "pos": "import sys\nfrom queue import Queue\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nn, m = na()\ng = []\nfor i in range(n):\n g.append([])\nfor i in range(m):\n u, v = na()\n g[u-1].append(v-1)\n\ns, t = na()\ns -= 1;\nt -= 1\n\nds = [[9999999999] * n for i in range(3)]\nds[0][s] = 0\n\nq = Queue()\nq.put((0, s))\nwhile not q.empty():\n r, cur = q.get_nowait()\n nr = (r+1) % 3\n for e in g[cur]:\n # print(nr, e)\n if ds[nr][e] > ds[r][cur] + 1:\n ds[nr][e] = ds[r][cur] + 1\n q.put((nr, e))\nif ds[0][t] < 99999999:\n print(ds[0][t]//3)\nelse:\n print(-1)\n", "neg": "import sys\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nn, m = na()\ng = []\nfor i in range(n):\n g.append([])\nfor i in range(m):\n u, v = na()\n g[u-1].append(v-1)\n\ns, t = na()\ns -= 1;\nt -= 1\n\nds = [[9999999999] * n for i in range(3)]\nds[0][s] = 0\n\nq = Queue()\nq.put((0, s))\nwhile not q.empty():\n r, cur = q.get_nowait()\n nr = (r+1) % 3\n for e in g[cur]:\n # print(nr, e)\n if ds[nr][e] > ds[r][cur] + 1:\n ds[nr][e] = ds[r][cur] + 1\n q.put((nr, e))\nif ds[0][t] >= 0:\n print(ds[0][t]//3)\nelse:\n print(-1)\n", "jacc_sim": 0.9402985074626866, "nl": "Ken loves playing \"ken-ken-pa\" (Japanese hopscotch) on a directed graph G. The graph G has N vertices numbered from 1 to N and M edges. Ken starts at vertex S and aims to reach vertex T by repeating ken-ken-pa. In one ken-ken-pa, he follows an edge from his current vertex three times. The task is to determine if Ken can reach vertex T by repeating ken-ken-pa and find the minimum number of ken-ken-pa needed if possible. Constraints include N (2 \u2264 N \u2264 10^5), M (0 \u2264 M \u2264 min(10^5, N(N-1))), and edge conditions. The input format is N, M, followed by edge pairs and S, T. The output should be the minimum number of ken-ken-pa needed or -1 if Ken cannot reach vertex T from vertex S. Sample inputs and outputs are provided for illustration.", "before_after_length": [306, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u202560873", "n_user": "u202560873", "pos": "import sys\nsys.setrecursionlimit(100000)\n\nN = int(input())\nvertex = set()\nconn = [[] for _ in range(2*10**5 + 1)]\ncheck = [False]*(2*10**5 + 1)\nfor i in range(N):\n x, y = [int(x) for x in input().split()]\n vertex.add(x)\n vertex.add(y + 10**5)\n conn[x].append(y + 10**5)\n conn[y + 10**5].append(x)\n\ncount = [0] * 2\ndef dfs(z):\n if check[z] == True:\n return\n check[z] = True\n if z <= 10**5:\n count[0] += 1\n else:\n count[1] += 1\n for w in conn[z]:\n dfs(w)\n\nans = 0\nfor z in vertex:\n if check[z] == False:\n count = [0]*2\n dfs(z)\n X, Y = count[0], count[1]\n ans += X * Y\nans -= N\n\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(100000)\n\nN = int(input())\nvertex = set()\nconn = [[] for _ in range(2*10**5 + 1)]\ncheck = [False]*(2*10**5 + 1)\nfor i in range(N):\n x, y = [int(x) for x in input().split()]\n vertex.add(x)\n vertex.add(y + 10**5)\n conn[x].append(y + 10**5)\n conn[y + 10**5].append(x)\n\ncount = [0] * 2\ndef dfs(z):\n if check[z] == True:\n return\n check[z] = True\n if z <= 10**5:\n count[0] += 1\n else:\n count[1] += 1\n for w in conn[z]:\n dfs(w)\n\nans = 0\nfor z in vertex:\n if check[z] == False:\n count = [0]*2\n dfs(z)\n X, Y = count[0], count[1]\n ans += X * Y\nans -= N", "jacc_sim": 0.9807692307692307, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [279, 273], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u682672120", "n_user": "u682672120", "pos": "n = int(input())\n\npos_max = 100000\n\ndic = dict()\n\nfor _ in range(n):\n x, y = map(int, input().split())\n y += pos_max\n if not x in dic:\n dic[x] = set()\n if not y in dic:\n dic[y] = set()\n dic[x].add(y)\n dic[y].add(x)\nchecked = set()\n\ncount = 0\nfor x in dic:\n if x in checked:\n continue\n checked.add(x)\n\n member = {x}\n next_items = {x}\n while next_items:\n v = next_items.pop()\n member |= dic[v]\n next_items |= dic[v] - checked\n checked |= dic[v]\n x_n = sum(w <= pos_max for w in member)\n y_n = sum(w > pos_max for w in member)\n count += x_n * y_n\nprint(count - n)", "neg": "n = int(input())\n\npos_max = 100000\n\ndic = dict()\n\nfor _ in range(n):\n x, y = map(int, input().split())\n y += pos_max\n if not x in dic:\n dic[x] = set()\n if not y in dic:\n dic[y] = set()\n dic[x].add(y)\n dic[y].add(x)\nchecked = set()\n\ncount = 0\nfor x in dic:\n if x in checked:\n continue\n checked.add(x)\n\n member = {x}\n next_items = {x}\n while next_items:\n v = next_items.pop()\n temp = dic[v] - checked\n next_items |= dic[v] - checked\n checked |= dic[v]\n x_n = sum(w <= pos_max for w in member)\n y_n = sum(w > pos_max for w in member)\n count += x_n * y_n\nprint(count - n)", "jacc_sim": 0.98, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [254, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u690536347", "n_user": "u690536347", "pos": "from collections import defaultdict\n\nN = int(input())\nd = defaultdict(list)\ncd = set()\nD = 100000\nused = [0]*(2*D+1)\nans = 0\n\nfor _ in range(N):\n x, y = map(int, input().split())\n y += D\n cd.add(x)\n d[x].append(y)\n d[y].append(x)\n\nfor x in cd:\n if used[x]:continue\n q = [x]\n used[x] = 1\n cx, sx = 0, 0\n\n while q:\n a = q.pop()\n if a<=D:\n cx += 1\n sx += 1\n for b in d[a]:\n if used[b]:continue\n used[b] = 1\n q.append(b)\n ans += cx*(sx-cx)\n\nprint(ans-N)\n", "neg": "from collections import defaultdict\n\nN = int(input())\nd = defaultdict(list)\ncd = set()\nD = 100000\n\nfor _ in range(N):\n x, y = map(int, input().split())\n y += D\n cd.add(x)\n d[x].append(y)\n d[y].append(x)\n\nused = [0]*(D+1)\nans = 0\n\nfor x in cd:\n if used[x]:continue\n q = [x]\n used[x] = 1\n cx, sx = 0, 0\n\n while q:\n a = q.pop()\n if a<=D:\n cx += 1\n sx += 1\n for b in d[a]:\n if used[b]:continue\n used[b] = 1\n q.append(b)\n ans += cx*(sx-cx)\n\nprint(ans-N)\n", "jacc_sim": 0.98, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [225, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u997641430", "n_user": "u997641430", "pos": "class UnionFind:\n def __init__(self, n):\n self.n = n\n self.parent = [None]*n\n\n def root(self, x):\n if self.parent[x] == None:\n return x\n else:\n return self.root(self.parent[x])\n\n def union(self, x, y):\n x0 = self.root(x)\n y0 = self.root(y)\n if x0 == y0:\n return\n if x0 > y0:\n x0, y0 = y0, x0\n self.parent[y0] = x0\n\n\nn = int(input())\nm = 10**5\nuf = UnionFind(2*m)\nX, Y = [], []\nfor i in range(n):\n x, y = map(int, input().split())\n X.append(x-1)\n Y.append(y-1+m)\n uf.union(x-1, y-1+m)\nR = {}\nfor x, y in zip(X, Y):\n r = uf.root(x)\n try:\n R[r][0].add(x)\n R[r][1].add(y)\n except:\n R[r] = [{x}, {y}]\nans = 0\nfor r in R.keys():\n ans += len(R[r][0])*len(R[r][1])\nprint(ans-n)\n", "neg": "class UnionFind:\n def __init__(self, n):\n self.n = n\n self.parent = [None]*n\n\n def root(self, x):\n if self.parent[x] == None:\n return x\n else:\n return self.root(self.parent[x])\n\n def union(self, x, y):\n x0 = self.root(x)\n y0 = self.root(y)\n if x0 == y0:\n return\n if x0 > y0:\n x0, y0 = y0, x0\n self.parent[y0] = x0\n\n\nn = int(input())\nm = 10**5\nuf = UnionFind(2*m)\nX, Y = [], []\nfor i in range(n):\n x, y = map(int, input().split())\n X.append(x-1)\n Y.append(y-1+m)\n uf.union(x-1, y-1+m)\nR = {}\nfor x, y in zip(X, Y):\n r = uf.root(x)\n try:\n R[r][0].add(x)\n R[r][1].add(y)\n except:\n R[r] = [{x}, {y}]\nans = 0\nfor r in R.keys():\n ans += len(R[r][0])*len(R[r][1])\nprint(R)\nprint(ans-n)\n", "jacc_sim": 1.0, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [362, 367], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u858742833", "n_user": "u858742833", "pos": "def main():\n N = int(input())\n X, Y = {}, {}\n for _ in range(N):\n x, y = map(int, input().split())\n if x not in X:\n X[x] = set()\n X[x].add(y)\n if y not in Y:\n Y[y] = set()\n Y[y].add(x)\n r = 0\n while X:\n x, ys = X.popitem()\n tx = set([x])\n ty = set(ys)\n mx, my = set(), set(ys)\n while mx or my:\n while my:\n y = my.pop()\n mx |= Y.pop(y, set())\n tx |= mx\n while mx:\n x = mx.pop()\n my |= X.pop(x, set())\n ty |= my\n r += len(tx) * len(ty)\n return r - N\n\nprint(main())\n", "neg": "def main():\n N = int(input())\n X, Y = {}, {}\n for _ in range(N):\n x, y = map(int, input().split())\n if x not in X:\n X[x] = set()\n X[x].add(y)\n if y not in Y:\n Y[y] = set()\n Y[y].add(x)\n processed = set()\n r = 0\n while X:\n x, ys = X.popitem()\n tx = set([x])\n ty = set()\n mx, my = set(), set(ys)\n while mx or my:\n while my:\n y = my.pop()\n mx |= Y.pop(y, set())\n tx |= mx\n while mx:\n x = mx.pop()\n my |= X.pop(x, set())\n ty |= my\n r += len(tx) * len(ty)\n return r - N\n\nprint(main())\n", "jacc_sim": 0.9791666666666666, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [238, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u407311141", "n_user": "u407311141", "pos": "import sys\nsys.setrecursionlimit(10**5)\nv = 100005\nvisited = [False]*(2*v)\ncount = [0, 0]\n\ndef dfs(a):\n visited[a] = True\n count[a//v] += 1\n for i in vertex[a]:\n if not visited[i]:\n dfs(i)\n\ninput = sys.stdin.readline\nN = int(input())\nvertex = [[] for _ in range(v*2)]\nfor _ in range(N):\n x, y=map(int, input().split())\n y += v\n vertex[x].append(y)\n vertex[y].append(x)\n\nans = 0\nfor i in range(v):\n if not visited[i]:\n count = [0, 0]\n dfs(i)\n ans += count[0]*count[1]\n\nprint(ans-N)", "neg": "import sys\nsys.setrecursionlimit(10**5)\nv = 100005\nvisited = [False]*(2*v)\ncount = [0, 0]\n\ndef dfs(a):\n visited[a] = True\n count[a//v] += 1\n for i in vertex[a]:\n if not visited[i]:\n dfs(i)\n\ninput = sys.stdin.readline\nN = int(input())\nvertex = [[] for _ in range(v*2)]\nfor _ in range(N):\n x, y=map(int, input().split())\n y += v\n vertex[x].append(y)\n vertex[y].append(x)\n\nans = 0\nfor i in range(v):\n if not visited[i]:\n count = [0, 0]\n dfs(i)\n ans += count[0]*count[1]\n\nprint(ans-N)\n\n\nprint(vertex[1])", "jacc_sim": 1.0, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [219, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u117980998", "n_user": "u117980998", "pos": "import sys\nsys.setrecursionlimit(10**5)\nm = 100005\nvisited = [False]*(m*2)\ncnt = [0,0]\ndef dfs(i):\n visited[i] = True\n cnt[i//m] = cnt[i//m]+1\n for j in to[i]:\n if not visited[j]:\n dfs(j)\n \ninput = sys.stdin.readline\nn = int(input())\nto = [[] for _ in range(m*2)]\nfor _ in range(n):\n x,y = map(int,input().split())\n y = y+m\n to[x].append(y)\n to[y].append(x)\n \nans = 0\nfor i in range(m):\n if not visited[i]:\n cnt = [0,0]\n dfs(i)\n ans = ans + cnt[0]*cnt[1]\n \nprint(ans-n)", "neg": "import sys\nsys.setrecursionlimit(10**5)\nm = 100005\nvisited = [False]*(m*2)\ncnt = [0,0]\ndef dfs(i):\n visited[i] = True\n cnt[i//m] +\uff1d 1\n for j in to[i]:\n if not visited[j]:\n dfs(j)\n \ninput = sys.stdin.readline\nn = int(input())\nto = [[] for _ in range(m*2)]\nfor _ in range(n):\n x,y = map(int,input().split())\n y = y+m\n to[x].append(y)\n to[y].append(x)\n \nans = 0\nfor i in range(m):\n if not visited[i]:\n cnt = [0,0]\n dfs(i)\n ans = ans + cnt[0]*cnt[1]\n \nprint(ans-n)", "jacc_sim": 0.98, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [231, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u988402778", "n_user": "u988402778", "pos": "def main():\n from collections import defaultdict\n import sys\n # functions used\n r = lambda: sys.stdin.readline().strip()\n R = lambda: list(map(int, r().split()))\n\n N = int(r())\n Dic = defaultdict(list)\n V = 10**5 + 5\n Arrived = [False] * (2 * V)\n for _ in range(N):\n x, y = R()\n y += V\n Dic[x].append(y)\n Dic[y].append(x)\n\n ans = 0\n task = []\n for k, v in Dic.items():\n if Arrived[k]:\n continue\n Arrived[k] = True\n if k < V:\n cntx = 1\n cnty = 0\n else:\n cntx = 0\n cnty = 1\n cntdot = 0\n task.extend(v)\n cntdot += len(v)\n while task:\n s = task.pop()\n if Arrived[s]:\n continue\n if s < V:\n cntx += 1\n else:\n cnty += 1\n Arrived[s] = True\n task.extend(Dic[s])\n cntdot += len(Dic[s])\n ans += cntx * cnty - cntdot // 2\n print(ans)\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n # functions used\n r = lambda: sys.stdin.readline().strip()\n R = lambda: list(map(int, r().split()))\n\n N = int(r())\n Dic = defaultdict(list)\n V = 10**5 + 5\n Arrived = [False] * (2 * V)\n for _ in range(N):\n x, y = R()\n y += V\n Dic[x].append(y)\n Dic[y].append(x)\n\n ans = 0\n task = []\n for k, v in Dic.items():\n if Arrived[k]:\n continue\n Arrived[k] = True\n if k < V:\n cntx = 1\n cnty = 0\n else:\n cntx = 0\n cnty = 1\n cntdot = 0\n task.extend(v)\n cntdot += len(v)\n while task:\n s = task.pop()\n if Arrived[s]:\n continue\n if s < V:\n cntx += 1\n else:\n cnty += 1\n Arrived[s] = True\n task.extend(Dic[s])\n cntdot += len(Dic[s])\n ans += cntx * cnty - cntdot // 2\n print(ans)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9577464788732394, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [350, 340], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u533039576", "n_user": "u533039576", "pos": "from collections import defaultdict\n\nclass UnionFind():\n def __init__(self, n):\n self.par = [i for i in range(n)]\n\n def find(self, x):\n if self.par[x] != x:\n self.par[x] = self.find(self.par[x]) # contruction\n return self.par[x]\n\n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n self.par[x] = y\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n\nn = int(input())\n\nuf = UnionFind(n)\nxs = []\nys = []\nx_dict = {}\ny_dict = {}\nfor i in range(n):\n x, y = map(int, input().split())\n xs.append(x)\n ys.append(y)\n\n if x in x_dict:\n uf.unite(i, x_dict[x])\n\n if y in y_dict:\n uf.unite(i, y_dict[y])\n\n x_dict[x] = uf.find(i)\n y_dict[y] = uf.find(i)\n\n# print(uf.par)\nxi = defaultdict(list)\nyi = defaultdict(list)\nfor i in range(n):\n xi[uf.find(x_dict[xs[i]])].append(xs[i])\n yi[uf.find(y_dict[ys[i]])].append(ys[i])\n\nans = 0\nfor k in xi.keys():\n ans += len(set(xi[k])) * len(set(yi[k])) - len(xi[k])\n\nprint(ans)\n", "neg": "from collections import defaultdict\n\nclass UnionFind():\n def __init__(self, n):\n self.par = [i for i in range(n)]\n\n def find(self, x):\n if self.par[x] != x:\n self.par[x] = self.find(self.par[x]) # contruction\n return self.par[x]\n\n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n self.par[x] = y\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n\nn = int(input())\n\nuf = UnionFind(n)\nxs = []\nys = []\nx_dict = {}\ny_dict = {}\nfor i in range(n):\n x, y = map(int, input().split())\n xs.append(x)\n ys.append(y)\n\n if x in x_dict:\n uf.unite(i, x_dict[x])\n\n if y in y_dict:\n uf.unite(i, y_dict[y])\n\n x_dict[x] = uf.find(i)\n y_dict[y] = uf.find(i)\n\nprint(uf.par)\nxi = defaultdict(list)\nyi = defaultdict(list)\nfor i in range(n):\n xi[uf.find(x_dict[xs[i]])].append(xs[i])\n yi[uf.find(y_dict[ys[i]])].append(ys[i])\n\nans = 0\nfor k in xi.keys():\n ans += len(set(xi[k])) * len(set(yi[k])) - len(xi[k])\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [451, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef YesNo(x): return 'Yes' if x else 'No'\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom collections import defaultdict\n\ndef main():\n N = II()\n xy2g = defaultdict(int)\n g2xy = defaultdict(set)\n for _ in range(N):\n x, y = LI()\n y = -y\n gx = xy2g[x]\n gy = xy2g[y]\n if gx != 0 and gy != 0: # merge\n if gx == gy:\n continue\n if len(g2xy[gx]) < len(g2xy[gy]):\n gx, gy = gy, gx\n for xy in g2xy[gy]:\n xy2g[xy] = gx\n g2xy[gx] |= g2xy[gy]\n g2xy[gy].clear()\n else:\n g = gx or gy or x\n xy2g[x] = xy2g[y] = g\n g2xy[g] |= {x, y}\n ans = -N\n for xys in g2xy.values():\n nx = sum(xy > 0 for xy in xys)\n ny = len(xys) - nx\n ans += nx * ny\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef YesNo(x): return 'Yes' if x else 'No'\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom collections import defaultdict\n\ndef main():\n N = II()\n xy = []\n for _ in range(N):\n xy.append(LI())\n xy2g = defaultdict(int)\n g2xy = defaultdict(set)\n for x, y in xy:\n y = -y\n gx = xy2g[x]\n gy = xy2g[y]\n if gx == 0 or gy == 0:\n g = gx or gy or x\n xy2g[x] = xy2g[y] = g\n g2xy[g] |= {x, y}\n elif gx != gy: # merge\n if len(g2xy[gx]) < len(g2xy[gy]):\n gx, gy = gy, gx\n for xy in g2xy[gy]:\n xy2g[xy] = gx\n g2xy[gx] |= g2xy[gy]\n g2xy[gy].clear()\n ans = -N\n for xys in g2xy.values():\n if len(xys) < 4:\n continue\n nx = 0\n for xy in xys:\n if xy > 0:\n nx += 1\n ny = len(xys) - nx\n ans += nx * ny\n return ans\n\nprint(main())", "jacc_sim": 0.9390243902439024, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [444, 475], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef YesNo(x): return 'Yes' if x else 'No'\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom collections import defaultdict\n\ndef main():\n N = II()\n xy = []\n for _ in range(N):\n xy.append(LI())\n xy2g = defaultdict(int)\n g2xy = defaultdict(set)\n for x, y in xy:\n y = -y\n gx = xy2g[x]\n gy = xy2g[y]\n if gx != 0 and gy != 0: # merge\n if gx == gy:\n continue\n if len(g2xy[gx]) < len(g2xy[gy]):\n gx, gy = gy, gx\n for xy in g2xy[gy]:\n xy2g[xy] = gx\n g2xy[gx] |= g2xy[gy]\n g2xy[gy].clear()\n else:\n g = gx or gy or x\n xy2g[x] = xy2g[y] = g\n g2xy[g] |= {x, y}\n ans = -N\n for xys in g2xy.values():\n m, p = 0, 0\n for xy in xys:\n if xy < 0:\n m += 1\n else:\n p += 1\n ans += m * p\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef YesNo(x): return 'Yes' if x else 'No'\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\nfrom collections import defaultdict\n\ndef main():\n N = II()\n xy = []\n for _ in range(N):\n xy.append(LI())\n xy2g = defaultdict(int)\n g2xy = defaultdict(set)\n for x, y in xy:\n gx = xy2g[x]\n gy = xy2g[-y]\n if gx != 0 and gy != 0: # merge\n if len(g2xy[gx]) < len(g2xy[gy]):\n gx, gy = gy, gx\n for xy in g2xy[gy]:\n xy2g[xy] = gx\n g2xy[gx] |= g2xy[gy]\n g2xy[gy].clear()\n else:\n g = gx or gy or x\n xy2g[x] = xy2g[-y] = g\n g2xy[g] |= {x, -y}\n ans = -N\n for xys in g2xy.values():\n m, p = 0, 0\n for xy in xys:\n if xy < 0:\n m += 1\n else:\n p += 1\n if m == 0 and p != 0:\n 1 = 1\n elif m != 0 and p == 0:\n 1 = 1\n ans += m * p\n return ans\n\nprint(main())", "jacc_sim": 0.9746835443037974, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [470, 486], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02998", "p_user": "u864197622", "n_user": "u864197622", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nN = int(input())\nK = 10**5+1\nP = [i for i in range(K)]\n\ndef par(a):\n if P[a] == a:\n return a\n t = par(P[a])\n P[a] = t\n return t\ndef cb(a, b):\n pa = par(a)\n pb = par(b)\n if pa != pb:\n P[pa] = pb\n\nX = [[] for _ in range(K)]\nY = [[] for _ in range(K)]\nfor _ in range(N):\n x, y = map(int, input().split())\n X[x-1].append(y-1)\n Y[y-1].append(x-1)\nfor i in range(K):\n for j in range(len(Y[i])-1):\n cb(Y[i][j], Y[i][j+1])\n\nM = [[] for _ in range(K)]\nfor i in range(K):\n M[par(i)].append(i)\nans = -N\nfor i in range(K):\n S = []\n for j in M[i]:\n for k in X[j]:\n S.append(k)\n S = list(set(S))\n ans += len(S)*len(M[i])\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nN = int(input())\nK = 10**5+1\nP = [i for i in range(K)]\n\ndef par(a):\n if P[a] == a:\n return a\n t = par(P[a])\n P[a] = t\n return t\ndef cb(a, b):\n P[pa] = pb\n\nX = [[] for _ in range(K)]\nY = [[] for _ in range(K)]\nfor _ in range(N):\n x, y = map(int, input().split())\n X[x-1].append(y-1)\n Y[y-1].append(x-1)\nfor i in range(K):\n for j in range(len(Y[i])-1):\n cb(Y[i][j], Y[i][j+1])\n\nM = [[] for _ in range(K)]\nfor i in range(K):\n M[par(i)].append(i)\nans = -N\nfor i in range(K):\n S = []\n for j in M[i]:\n for k in X[j]:\n S.append(k)\n S = list(set(S))\n ans += len(S)*len(M[i])\nprint(ans)\n", "jacc_sim": 0.9824561403508771, "nl": "You are given N dots in a two-dimensional plane with coordinates (x_i, y_i). The task is to repeat an operation as long as possible: choose four integers a, b, c, d (a \u2260 c, b \u2260 d) such that there are dots at exactly three of the positions (a, b), (a, d), (c, b), and (c, d), and add a dot at the remaining position. Find the maximum number of times this operation can be done. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 x_i, y_i \u2264 10^5, x_i \u2260 x_j or y_i \u2260 y_j if i \u2260 j. Input is given in the format: N, x_1 y_1, ..., x_N y_N. Output the maximum number of times the operation can be done.", "before_after_length": [354, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u682672120", "n_user": "u398846051", "pos": "mod = 1000000007\n\nn, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\n\ndp = [[0] * (m+1) for _ in range(n+1)]\ndp[0][0] = 0\nfor i in range(1, n+1):\n for j in range(1, m+1):\n dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1]) % mod\n if s[i-1] == t[j-1]: \n dp[i][j] = (dp[i][j] + dp[i-1][j-1] + 1) % mod\nprint((dp[n][m]+1) % mod)", "neg": "n, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\ndp = [[0] * (m+2) for _ in range(n+2)]\nmod = 1000000007\ndp[0][0] = 1\nfor i in range(1, n+1):\n for j in range(1, m+1):\n dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod\n if s[i-1] == t[j-1]:\n dp[i][j] += 1 + dp[i-1][j-1]\n dp[i][j] %= mod\nprint(dp[n][m])\n", "jacc_sim": 0.9714285714285714, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [205, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u368796742", "n_user": "u798129018", "pos": "N,M = map(int,input().split())\nS = list(map(int,input().split()))\nT = list(map(int,input().split()))\nmod = 10**9+7\n\ndp = [[0]*(M+1) for i in range(N+1)]\nfor n in range(N):\n for m in range(M):\n if S[n] == T[m]:\n dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]+1\n else:\n dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]\n dp[n+1][m+1] %= mod\n\nprint(dp[-1][-1]+1)\n", "neg": "N,M = map(int,input().split())\nS = list(map(int,input().split()))\nT = list(map(int,input().split()))\ndp = [[0]*(M+1) for i in range(N+1)]\n\nfor n in range(N):\n for m in range(M):\n if S[n] == T[m]:\n dp[n+1][m+1] = (dp[n+1][m]+dp[n][m+1]+1)%mod\n else:\n dp[n+1][m+1] = dp[n+1][m]+dp[n][m+1]-dp[n][m]\n\nprint((dp[N][M]+1)%mod)", "jacc_sim": 0.918918918918919, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [196, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u989345508", "n_user": "u989345508", "pos": "from numpy import*\nN,M,*U= map(int,open(0).read().split())\nT=array(U[N:])\np=ones(M+1,dtype=\"i8\")\nfor s in U[:N]:p[1:]=((p[:-1]*(s==T)).cumsum()+p[1:])%(10**9+7)\nprint(p[-1])", "neg": "from numpy import*\nN,M,*U= map(int,open(0).read().split())\nT=array(U[N:])\np=ones(M+1)\nfor s in U[:N]:p[1:]=((p[:-1]*(s==T)).cumsum()+p[1:])%(10**9+7)\nprint(p[-1])", "jacc_sim": 0.925, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [96, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u186838327", "n_user": "u186838327", "pos": "n, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\n\nM = 10**9+7\n\ndp = [[1]*(m+1) for _ in range(n+1)]\n\nfor i in range(n):\n for j in range(m):\n if s[i] == t[j]:\n dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1]\n else:\n dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j]\n dp[i+1][j+1] %= M\n\n#print(dp)\nprint(dp[-1][-1]%M)", "neg": "n, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\n \nM = 10**9+7\n \ndp = [[0]*(m+1) for _ in range(n+1)]\ndp[0][0] = 1\n \nfor i in range(n):\n for j in range(m):\n if s[i] == t[j]:\n dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1]\n else:\n dp[i+1][j+1] = dp[i+1][j] + dp[i][j+1] - dp[i][j]\n dp[i+1][j+1] %= M\n \n#print(dp)\nprint(dp[-1][-1]%M)", "jacc_sim": 0.9736842105263158, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [205, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u263830634", "n_user": "u263830634", "pos": "def main():\n N, M = map(int, input().split())\n S = list(map(int, input().split()))\n T = list(map(int, input().split()))\n\n MOD = 10 ** 9 + 7\n\n dp0 = [[0] * 2005 for _ in range(2005)]\n dp1 = [[0] * 2005 for _ in range(2005)]\n\n dp0[0][0] = 1\n for i in range(N + 1):\n for j in range(M + 1):\n dp0[i + 1][j] += dp0[i][j]\n dp1[i][j] += dp0[i][j]\n dp1[i][j] %= MOD\n dp1[i][j + 1] += dp1[i][j]\n if i < N and j < M and S[i] == T[j]:\n dp0[i + 1][j + 1] += dp1[i][j]\n dp1[i][j] %= MOD\n dp0[i + 1][j] %= MOD\n dp1[i][j + 1] %= MOD\n dp0[i + 1][j + 1] %= MOD\n\n ans = dp1[N][M] % MOD\n print (ans)\n return \n\nif __name__ == '__main__':\n main()", "neg": "def main():\n\n N, M = map(int, input().split())\n S = list(map(int, input().split()))\n T = list(map(int, input().split()))\n\n MOD = 10 ** 9 + 7\n\n dp0 = [[0] * 2005 for _ in range(2005)]\n dp1 = [[0] * 2005 for _ in range(2005)]\n\n dp0[0][0] = 1\n for i in range(N + 1):\n for j in range(M + 1):\n dp0[i + 1][j] += dp0[i][j]\n dp1[i][j] += dp0[i][j]\n dp1[i][j + 1] += dp1[i][j]\n if i < N and j < M and S[i] == T[j]:\n dp0[i + 1][j + 1] += dp1[i][j]\n dp0[i][j] %= MOD\n dp1[i][j] %= MOD\n\n ans = dp1[N][M]\n print (ans)\n return \n\nif __name__ == '__main()__':\n main()", "jacc_sim": 0.9375, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [327, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u543954314", "n_user": "u227082700", "pos": "n,m = map(int,input().split())\ns = list(map(int,input().split()))\nt = list(map(int,input().split()))\nmod = 10**9 + 7\ndp = [[1]*(m+1) for _ in range(n+1)]\nfor i in range(n):\n for j in range(m):\n dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j]*(s[i] != t[j])) % mod\nprint(dp[n][m])", "neg": "n,m=map(int,input().split())\ns=list(map(int,input().split()))\nt=list(map(int,input().split()))\ndp=[(m+1)*[1]for _ in range(n+1)]\nfor i in range(n):\n for j in range(m):\n dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]\n if s[i]!=t[j]:dp[i+1][j+1]-=dp[i][j]\n dp[i+1][j+1]%(10**9+7)\nprint(dp[-1][-1])", "jacc_sim": 0.9444444444444444, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [144, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u089230684", "n_user": "u089230684", "pos": "import sys\nfrom math import ceil\n\ndef input():\n return sys.stdin.readline().strip()\n\ndef iinput():\n return int(input())\n\ndef finput():\n return float(input())\n\ndef tinput():\n return input().split()\n\ndef rinput():\n return map(int, tinput())\n\ndef rlinput():\n return list(rinput())\n\ndef nok(a, b):\n m = a * b\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n return m // (a + b) \n\n\ndef main():\n mod = 1e9 + 7\n n, m = rinput()\n s = rlinput()\n t = rlinput()\n a = [1] * (m + 1)\n for j in s:\n d = a[:]\n k = 0\n for i, v in enumerate(t):\n d[i] = (k + d[i]) % mod\n if j == v:\n k = (k + a[i]) % mod\n d[-1] = (k + d[-1]) % mod\n a = d[:]\n print(int(a[-1]))\n \n \n \nmain()", "neg": "import sys\nfrom math import ceil\n\ndef input():\n return sys.stdin.readline().strip()\n\ndef iinput():\n return int(input())\n\ndef finput():\n return float(input())\n\ndef tinput():\n return input().split()\n\ndef rinput():\n return map(int, tinput())\n\ndef rlinput():\n return list(rinput())\n\ndef nok(a, b):\n m = a * b\n while a != 0 and b != 0:\n if a > b:\n a %= b\n else:\n b %= a\n return m // (a + b) \n\n\ndef main():\n mod = 1e9 + 7\n n, m = rinput()\n s = rlinput()\n t = rlinput()\n a = [1] * (m + 1)\n for j in s:\n d = a[:]\n k = 0\n for i, v in enumerate(t):\n d[i] = (k + d[i]) % mod\n if j == v:\n k = (k + a[i]) % mod\n d[-1] = (k + d[-1]) % mod\n a = d[:]\n print(a[-1])\n \n \n \nmain()", "jacc_sim": 1.0, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [312, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u067729694", "n_user": "u067729694", "pos": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\n\nMOD = 10**9+7\n\ndp = [[0 for i in range(M+1)] for j in range(N+1)] # dp[i][j] : S[i]\u3068T[j]\u304c\u672b\u5c3e\u306b\u6765\u308b\u90e8\u5206\u96c6\u5408\u306e\u6570\ndp_sum = [[0 for i in range(M+1)] for j in range(N+1)] # dp[i][j]\u306e\u7dcf\u548c\n\n# \u4e00\u65e6\u7a7a\u96c6\u5408\uff0b\u7a7a\u96c6\u5408\u306f\u8003\u3048\u306a\u3044\nret = 0\nfor i, s in enumerate(S):\n for j, t in enumerate(T):\n if s == t:\n dp[i+1][j+1] = dp_sum[i][j] + 1 # S[i]\u3068T[j]\u3092\u4f7f\u3063\u3066\u306a\u3044\u3082\u306e\u306e\u7dcf\u548c\u306bS[i]\u3068T[j]\u3060\u3051\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u8db3\u3059\n dp_sum[i+1][j+1] = (dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]) % MOD\n \nprint(dp_sum[N][M]+1)#\u6700\u5f8c\u306b\u7a7a\u96c6\u5408\uff0b\u7a7a\u96c6\u5408\u3092\u52a0\u3048\u308b\n\n", "neg": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\n\ndp = [[0 for i in range(M+1)] for j in range(N+1)] # dp[i][j] : S[i]\u3068T[j]\u304c\u672b\u5c3e\u306b\u6765\u308b\u90e8\u5206\u96c6\u5408\u306e\u6570\ndp_sum = [[0 for i in range(M+1)] for j in range(N+1)] # dp[i][j]\u306e\u7dcf\u548c\n\n# \u4e00\u65e6\u7a7a\u96c6\u5408\uff0b\u7a7a\u96c6\u5408\u306f\u8003\u3048\u306a\u3044\nfor i, s in enumerate(S):\n for j, t in enumerate(T):\n if s == t:\n dp[i+1][j+1] = dp_sum[i][j] + 1 # S[i]\u3068T[j]\u3092\u4f7f\u3063\u3066\u306a\u3044\u3082\u306e\u306e\u7dcf\u548c\u306bS[i]\u3068T[j]\u3060\u3051\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u8db3\u3059\n else:\n dp[i+1][j+1] = 0\n dp_sum[i+1][j+1] = dp[i+1][j+1] + dp_sum[i][j+1] + dp_sum[i+1][j] - dp_sum[i][j]\n \nprint(dp_sum[N][M]+1)#\u6700\u5f8c\u306b\u7a7a\u96c6\u5408\uff0b\u7a7a\u96c6\u5408\u3092\u52a0\u3048\u308b\n\n", "jacc_sim": 0.9024390243902439, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [481, 483], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u704216644", "n_user": "u704216644", "pos": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\ndp = [1] * (M+1)\ndpleft = [0] * (M)\nMOD = 10 ** 9 + 7\nndp = [1] * (M+1)\nfor n in range(N):\n for m in range(M):\n if S[n] == T[m]:\n ndp[m+1] = ndp[m] + dp[m+1]\n dpleft[m] = dp[m+1]\n else:\n ndp[m+1] = ndp[m] + dpleft[m]\n dp = ndp[:]\nprint(dp[-1] % MOD)", "neg": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\ndp = [1] * (M+1)\ndpleft = [0] * (M)\nMOD = 10 ** 9 + 7\nndp = [1] * (M+1)\nfor n in range(N):\n for m in range(M):\n if S[n] == T[m]:\n ndp[m+1] = ndp[m] + dp[m+1])\n dpleft[m] = dp[m+1]\n else:\n ndp[m+1] = ndp[m] + dpleft[m]\n dp = ndp\nprint(dp[-1] % MOD)", "jacc_sim": 1.0, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [195, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u607865971", "n_user": "u607865971", "pos": "import sys\nfrom collections import Counter, deque, defaultdict\nfrom itertools import accumulate, permutations, combinations, takewhile, compress, cycle\n\n# from functools import reduce\n# from math import ceil, floor, log10, log2, factorial\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\n\n# N = int(input())\n# A = [int(x) for x in input().split()]\n# V = [[0] * 100 for _ in range(100)]\n# A = [int(input()) for _ in range(N)]\n\ndef main():\n \"\"\"\"\u3053\u3053\u306b\u4eca\u307e\u3067\u306e\u30b3\u30fc\u30c9\"\"\"\n N, M = [int(x) for x in input().split()]\n S = [int(x) for x in input().split()]\n T = [int(x) for x in input().split()]\n\n DP = [[0] * (M + 1) for _ in range(N + 1)]\n DP[0] = [1] * (M + 1)\n for n in range(1, N + 1):\n DP[n][0] = DP[n - 1][0]\n for m in range(1, M + 1):\n DP[n][m] = DP[n][m - 1] + DP[n - 1][m] - DP[n - 1][m - 1]\n DP[n][m] %= MOD\n if S[n - 1] == T[m - 1]:\n DP[n][m] += DP[n - 1][m - 1]\n DP[n][m] %= MOD\n print(DP[n][m])\n\n\nif __name__ == '__main__':\n main()\n\n", "neg": "import sys\nfrom collections import Counter, deque, defaultdict\nfrom itertools import accumulate, permutations, combinations, takewhile, compress, cycle\n\n# from functools import reduce\n# from math import ceil, floor, log10, log2, factorial\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\n\n# N = int(input())\n# A = [int(x) for x in input().split()]\n# V = [[0] * 100 for _ in range(100)]\n# A = [int(input()) for _ in range(N)]\n\ndef main():\n \"\"\"\"\u3053\u3053\u306b\u4eca\u307e\u3067\u306e\u30b3\u30fc\u30c9\"\"\"\n N, M = [int(x) for x in input().split()]\n S = [int(x) for x in input().split()]\n T = [int(x) for x in input().split()]\n\n if S[0] == S[1] and S[1] == 1 and T[0] == T[1] and T[1] == 1:\n hogehoge\n pass\n\n DP = [[0] * (M + 1) for _ in range(N + 1)]\n DP[0] = [1] * (M + 1)\n for n in range(1, N + 1):\n DP[n][0] = DP[n - 1][0]\n for m in range(1, M + 1):\n DP[n][m] = DP[n][m - 1] + DP[n - 1][m] - DP[n - 1][m - 1]\n DP[n][m] %= MOD\n if S[n - 1] == T[m - 1]:\n DP[n][m] += DP[n - 1][m - 1]\n DP[n][m] %= MOD\n print(DP[n][m])\n\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 0.9625, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [438, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u375616706", "n_user": "u375616706", "pos": "# -*- coding: utf-8 -*-\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nMOD = 10**9+7\nN, M = map(int, input().split())\nS = list(input().split())\nT = list(input().split())\n\n# S\u306ei\u6587\u5b57\u76ee\u307e\u3067\u3068\u3001T\u306ej\u6587\u5b57\u76ee\u307e\u3067\u3067\u3001dp[i][j]\u3053\ndp = [[0]*(M+1) for _ in range(N+1)]\n\nfor r in range(1, N+1):\n for k in range(1, M+1):\n if S[r-1] == T[k-1]:\n dp[r][k] = 1+dp[r-1][k]+dp[r][k-1]\n dp[r][k] %= MOD\n else:\n dp[r][k] = dp[r-1][k]+dp[r][k-1]-dp[r-1][k-1]\n dp[r][k] %= MOD\nprint((dp[-1][-1]+1) % MOD)\n", "neg": "# -*- coding: utf-8 -*-\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nMOD = 10**9+7\nN, M = map(int, input().split())\nS = list(input().split())\nT = list(input().split())\n\n# S\u306ei\u6587\u5b57\u76ee\u307e\u3067\u3068\u3001T\u306ej\u6587\u5b57\u76ee\u307e\u3067\u3067\u3001dp[i][j]\u3053\ndp = [[0]*(N+1) for _ in range(M+1)]\n\nfor i in range(1, N+1):\n for j in range(1, M+1):\n if S[i-1] == T[j-1]:\n dp[i][j] = 1+dp[i-1][j]+dp[i][j-1]\n dp[i][j] %= MOD\n else:\n dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]\n dp[i][j] %= MOD\nprint((dp[-1][-1]+1) % MOD)\n", "jacc_sim": 0.9666666666666667, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [312, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u619819312", "n_user": "u704216644", "pos": "n,m=map(int,input().split())\ns=list(map(int,input().split()))\nt=list(map(int,input().split()))\na=[1]*(m+1)\nfor i in range(n):\n b=a[:]\n k=0\n for j in range(m):\n b[j]=(k+b[j])%(10**9+7)\n if s[i]==t[j]:\n k=(k+a[j])%(10**9+7)\n b[-1]=(k+b[-1])%(10**9+7)\n a=b[:]\nprint(a[-1]%(10**9+7))\n", "neg": " n,m=map(int,input().split())\n s=list(map(int,input().split()))\n t=list(map(int,input().split()))\n a=[1]*(m+1)\n for i in range(n):\n b=a[:]\n k=0\n for j in range(m):\n b[j]=(k+b[j])%(10**9+7)\n if s[i]==t[j]:\n k=(k+a[j])%(10**9+7)\n b[-1]=(k+b[-1])%(10**9+7)\n a=b[:]\n print(a[-1]%(10**9+7))", "jacc_sim": 1.0, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [170, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u545368057", "n_user": "u545368057", "pos": "N,M = map(int, input().split())\nSs = list(map(int, input().split()))\nTs = list(map(int, input().split()))\nmod = 10**9 + 7\n\nx = 2160\ndp = [[0]*x for i in range(x)]\nfor i in range(N):\n for j in range(M):\n if Ss[i] == Ts[j]:\n dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] + 1) % mod\n else:\n dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j])%mod\n\nprint((dp[N][M]+1)%mod)", "neg": "N,M = map(int, input().split())\nSs = list(map(int, input().split()))\nTs = list(map(int, input().split()))\nmod = 10**9 + 7\n\nx = 2160\ndp = [[0]*x for i in range(x)]\nsum2d = [[0]*x for i in range(x)]\nsum2d[0][0] = 1\nfor i in range(N):\n for j in range(M):\n if Ss[i] == Ts[j]:\n dp[i+1][j+1] = sum2d[i][j] + 1\n sum2d[i+1][j+1] = (dp[i+1][j+1]+sum2d[i][j+1]+sum2d[i+1][j]-sum2d[i][j])%mod\nprint((sum2d[N][M]+1)%mod)", "jacc_sim": 0.9487179487179487, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [194, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u398846051", "n_user": "u398846051", "pos": "n, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\ndp = [[0] * (m+2) for _ in range(n+2)]\nmod = 1000000007\n\nfor i in range(n+1):\n dp[i][0] = 1\nfor i in range(m+1):\n dp[0][i] = 1\n\nfor i in range(1, n+1):\n for j in range(1, m+1):\n dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod\n if s[i-1] == t[j-1]:\n dp[i][j] += dp[i-1][j-1]\n dp[i][j] %= mod\nprint(dp[n][m])\n", "neg": "n, m = map(int, input().split())\ns = list(map(int, input().split()))\nt = list(map(int, input().split()))\ndp = [[0] * (m+2) for _ in range(n+2)]\ndp[0][0] = 0\nfor i in range(1, n+1):\n for j in range(1, m+1):\n dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]\n if s[i-1] == t[j-1]:\n dp[i][j] += 1 + dp[i-1][j-1]\nprint(dp[n][m] + 1)\n", "jacc_sim": 0.9142857142857143, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [229, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u667469290", "n_user": "u667469290", "pos": "# -*- coding: utf-8 -*-\ndef solve():\n N, M = map(int, input().split())\n S = map(int, input().split())\n *T, = map(int, input().split())\n dp = [1]*(M+1)\n for s in S:\n is_s = s.__eq__\n dp_ = dp[:]\n acc = 0\n for i, t in enumerate(T):\n if is_s(t):\n acc += dp_[i]\n dp[i+1] = dp_[i+1] + acc\n res = (dp[-1])%(10**9+7)\n return str(res)\n\nif __name__ == '__main__':\n print(solve())\n", "neg": "# -*- coding: utf-8 -*-\n\ndef solve():\n N, M = map(int, input().split())\n S = map(int, input().split())\n *T, = map(int, input().split())\n dp = [0]*(M+1)\n for s in S:\n dp_ = dp\n for i, t in enumerate(T):\n dp[i+1] = dp_[i+1] + dp[i] - dp_[i] + (dp_[i]+1 if t==s else 0)\n res = (dp_[-1]+1)%(10**9+7)\n\n return str(res)\n\nif __name__ == '__main__':\n print(solve())\n", "jacc_sim": 0.9215686274509803, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [186, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u016128476", "n_user": "u296518383", "pos": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\ndp = [[0 for _ in range(N+1)] for _ in range(M+1)]\ndp[0] = [0 for _ in range(N+1)]\n\nfor i in range(1,M+1):\n for j in range(N+1):\n if j == 0:\n dp[i][j] = 0\n continue\n dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]\n if S[j-1] == T[i-1]:\n dp[i][j] += dp[i-1][j-1] + 1\n dp[i][j] %= MOD\n \n\nprint((dp[-1][-1] + 1) % MOD)\n", "neg": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\ndp = [[0 for _ in range(M)] for _ in range(N)]\ndp[0][0] = 1\n\nfor i in range(N):\n for j in range(M):\n if i == j == 0:\n continue\n if S[i] == T[j]:\n dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] + 1) % MOD\n else:\n dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])\n \nprint(dp[-1][-1] + 1)", "jacc_sim": 0.9487179487179487, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [237, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u843135954", "n_user": "u843135954", "pos": "import sys\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m = na()\ns = na()\nt = na()\nmod = 10**9+7\n\ndp = [[0 for i in range(m + 1)] for j in range(n + 1)]\n\nfor i in range(1, n+1):\n for j in range(1, m+1):\n if (s[i-1] == t[j-1]):\n dp[i][j] = (1 + dp[i][j-1] + dp[i-1][j])%mod\n else:\n dp[i][j] = (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1])%mod\n \nprint((dp[n][m]+1)%mod)", "neg": "import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,m = na()\ns = na()\nt = na()\nmod = 10**9+7\n\ndp = [[0 for i in range(n + 1)] for i in range(m + 1)]\nfor i in range(1, n+1):\n for j in range(1, m+1):\n if (s[i-1] == t[j-1]):\n dp[i][j] = (1 + dp[i][j-1] + dp[i-1][j])%mod \n else: \n dp[i][j] = (dp[i][j-1] + dp[i-1][j] -dp[i-1][j-1])%mod\n \nprint((dp[n][m]+1)%mod)\n", "jacc_sim": 0.9574468085106383, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [250, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u627417051", "n_user": "u627417051", "pos": "def getlist():\n\treturn list(map(int, input().split()))\n\nN, M = getlist()\nS = getlist()\nT = getlist()\n\nL = [[1 for i in range(N + 1)] for j in range(M + 1)]\nfor i in range(1, N + 1):\n\tfor j in range(1, M + 1):\n\t\tif S[i - 1] == T[j - 1]:\n\t\t\tL[j][i] = (L[j - 1][i] + L[j][i - 1]) % 1000000007\n\t\telse:\n\t\t\tL[j][i] = (L[j - 1][i] + L[j][i - 1] - L[j - 1][i - 1]) % 1000000007\n\nprint(L[M][N] % 1000000007)", "neg": "def getlist():\n\treturn list(map(int, input().split()))\n\nN, M = getlist()\nS = getlist()\nT = getlist()\n\nL = [[1 for i in range(N + 1)] for j in range(M + 1)]\nfor i in range(1, N + 1):\n\tfor j in range(1, M + 1):\n\t\tif S[i - 1] == T[j - 1]:\n\t\t\tL[j][i] = max(L[j - 1][i - 1] * 2, L[j - 1][i] + L[j][i - 1]) % 1000000007\n\t\telse:\n\t\t\tL[j][i] = (L[j - 1][i] + L[j][i - 1] - L[j - 1][i - 1]) % 1000000007\n\nprint(L[M][N])", "jacc_sim": 0.918918918918919, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [200, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u785989355", "n_user": "u685263709", "pos": "N,M = list(map(int,input().split()))\n\nS = list(map(int,input().split()))\nT = list(map(int,input().split()))\n\nDP = [[0]*(N+1) for i in range(M+1)]\n\nfor i in range(N+1):\n DP[0][i]=1\n\n\nfor i in range(M+1):\n DP[i][0]=1\n\nmod=10**9 + 7\nfor i in range(M):\n for j in range(N):\n if T[i]==S[j]:\n DP[i+1][j+1]=(DP[i+1][j]+DP[i][j+1])%mod\n else:\n DP[i+1][j+1]=(DP[i+1][j]+DP[i][j+1]-DP[i][j])%mod\n\nprint(DP[M][N])", "neg": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\n\ndp = [[0 for i in range(M+1)] for i in range(N+1)]\ndp[0][0] = 1\nfor i in range(1, N+1):\n for j in range(1, M+1):\n if S[i-1] == T[j-1]:\n dp[i][j] = (1 + dp[i-1][j] + dp[i][j-1]) % mod\n else:\n dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % mod\n\nprint((dp[-1][-1] + 1) % mod)\n", "jacc_sim": 0.9459459459459459, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [233, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u741397536", "n_user": "u332906195", "pos": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\nMOD = 10**9 + 7\n\ndp = [[0 for j in range(M+1)]for i in range(N+1)]\nfor j in range(M+1):\n dp[0][j] = 1\nfor i in range(N+1):\n dp[i][0] = 1\n\nfor i in range(N):\n for j in range(M):\n if S[i] == T[j]:\n dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j])%MOD\n else:\n dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j] - dp[i][j])%MOD\n\nprint(dp[N][M])\n", "neg": "MOD = 10 ** 9 + 7\n\nN, M = map(int, input().split())\nS, T = list(input().split()), list(input().split())\n\ndp_sum = [0] * (M + 1)\n\nfor i in range(N):\n for j in range(M):\n if S[i] == T[j]:\n dp_sum[j + 1] += dp_sum[j] + 1\n else:\n dp_sum[j + 1] = dp_sum[j]\n\nprint((dp_sum[M] + 1) % MOD)\n", "jacc_sim": 0.918918918918919, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [230, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u064408584", "n_user": "u623687794", "pos": "n,m=map(int, input().split())\ns=list(map(int, input().split()))\nt=list(map(int, input().split()))\ndp=[[0]*(n+1) for _ in range(m+1)]\nfor i in range(m+1):\n dp[i][0]=1\nfor i in range(n+1):\n dp[0][i]=1\nfor i in range(m):\n for j in range(n):\n if s[j]==t[i]:\n dp[i+1][j+1]=(dp[i][j+1]+dp[i+1][j])%(10**9+7)\n else:\n dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]-dp[i][j]\nprint(dp[-1][-1]%(10**9+7))", "neg": "n,m=map(int,input().split())\nmod=10**9+7\ns=list(map(int,input().split()))\nt=list(map(int,input().split()))\ndp=[[0 for i in range(n+1)] for i in range(m+1)]\nsum=[[0 for i in range(n+1)] for i in range(m+1)]\nfor i in range(1,n+1):\n for j in range(1,m+1):\n if s[i-1]==t[j-1]:\n dp[i][j]=(sum[i-1][j-1]+1)%mod\n else:dp[i][j]=0\n sum[i][j]=(sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+dp[i][j])%mod\nprint(sum[-1][-1]%mod)", "jacc_sim": 0.9210526315789473, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [222, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03003", "p_user": "u564902833", "n_user": "u211160392", "pos": "N, M = map(int, input().split())\nS = list(map(int, input().split()))\nT = list(map(int, input().split()))\n\nMOD = 10**9 + 7\n\ndp = [[1 for _ in range(M + 1)] for _ in range(N + 1)]\nfor i in range(1, N + 1):\n for j in range(1, M + 1):\n if S[i - 1] == T[j - 1]:\n dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD\n else:\n dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]) % MOD\n\nans = dp[N][M]\nprint(ans)\n\n", "neg": "N,M = map(int,input().split())\nS = list(map(int,input().split()))\nT = list(map(int,input().split()))\ndp = [[1]*(M+1) for i in range(N+1)]\n\nfor i in range(N):\n for j in range(M+1):\n if S[i]==T[j-1]:\n dp[i+1][j]=(dp[i+1][j-1] + dp[i][j])%(10**9+7)\n else:\n dp[i+1][j]=(dp[i+1][j-1] +dp[i][j]-dp[i][j-1])%(10**9+7)\nprint(dp[-1][-1])", "jacc_sim": 0.918918918918919, "nl": "You are given two integer sequences S and T of length N and M, respectively, both consisting of integers between 1 and 10^5 (inclusive). Determine the number of pairs of subsequences of S and T that are the same in content. A subsequence of A is a sequence obtained by removing zero or more elements from A and concatenating the remaining elements without changing the order. The answer should be printed modulo 10^9+7. The input is given in the format N M followed by the sequences S and T. Output the number of pairs of subsequences of S and T such that the subsequences are the same in content, modulo 10^9+7.", "before_after_length": [204, 187], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u799443198", "n_user": "u777923818", "pos": "from collections import defaultdict, deque\nimport sys\n#input = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\nN = int(input())\nA = sorted(inpl())\n\nprint(A[-1] + sum(map(abs, A[1:-1])) - A[0])\nfor i in range(N-2, 0, -1):\n a = A[i]\n if a > 0:\n print(A[0], a)\n A[0] -= a\n else:\n print(A[-1], a)\n A[-1] -= a\nprint(A[-1], A[0])\n", "neg": "from collections import defaultdict, deque\nimport sys\n#input = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\nN = int(input())\nA = sorted(inpl())\n\nprint(sum(map(abs, A[1:])) - A[0])\nfor i in range(N-2, 0, -1):\n a = A[i]\n if a > 0:\n print(A[0], a)\n A[0] -= a\n else:\n print(A[-1], a)\n A[-1] -= a\n print(A[-1], A[0])", "jacc_sim": 0.9772727272727273, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [160, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u777923818", "n_user": "u777923818", "pos": "from collections import defaultdict, deque\nimport sys\n#input = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\nN = int(input())\nA = sorted(inpl())\nif A[-1] < 0:\n print(A[-1] - sum(A[:-1]))\n for i in range(N-2, -1, -1):\n print(A[-1], A[i])\n A[-1] -= A[i]\nelse:\n print(sum(map(abs, A[1:])) - A[0])\n for i in range(N-2, 0, -1):\n a = A[i]\n if a > 0:\n print(A[0], a)\n A[0] -= a\n else:\n print(A[-1], a)\n A[-1] -= a\n print(A[-1], A[0])", "neg": "# -*- coding: utf-8 -*-\nfrom collections import defaultdict, deque\nimport sys\n#input = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\nN = int(input())\nA = sorted(inpl())\nif A[-1] < 0:\n print(A[-1] - sum(A[:-1]))\n for i in range(N-2, -1, -1):\n print(A[-1], A[i])\n A[-1] -= A[i]\nelse:\n print(sum(map(abs, A)))\n for i in range(N-2, 0, -1):\n a = A[i]\n if a > 0:\n print(A[0], a)\n A[0] -= a\n else:\n print(A[-1], a)\n A[-1] -= a\n print(A[-1], A[0])", "jacc_sim": 0.9166666666666666, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [222, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u941438707", "n_user": "u941438707", "pos": "n,*a=map(int,open(0).read().split())\na.sort()\nprint(sum(abs(i)for i in a)-2*min(abs(a[-1]),abs(a[0]))*(a[0]*a[-1]>0))\nfor i in a[1:-1]:\n if i<0:\n print(a[-1],i)\n a[-1]-=i\n else:\n print(a[0],i)\n a[0]-=i\nprint(a[-1],a[0])", "neg": "n,*a=map(int,open(0).read().split())\na.sort()\nprint(sum(abs(i)for i in a)-2*abs(a[0]))\nif n==2:\n print(a[1]-1[0])\n print(a[1],a[0])\nelse:\n print(a[0],a[-1])\n a[0]-=a[-1]\n for i in a[1:-2]:\n print(a[0],i)\n a[0]-=i\n print(a[-2],a[0])", "jacc_sim": 0.90625, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [136, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u139112865", "n_user": "u672475305", "pos": "n = int(input())\na = list(map(int, input().split()))\na.sort()\n\nans = []\nfor i in range(1, n-1):\n if a[i] <= 0:\n ans.append([a[n-1], a[i]])\n a[n-1] += abs(a[i])\n\n else:\n ans.append([a[0], a[i]])\n a[0] -= a[i]\n \nans.append([a[n-1], a[0]])\n\nprint(a[n-1] - a[0])\nfor i in range(n-1):\n print(*ans[i])\n", "neg": "n = int(input())\nA = list(map(int,input().split()))\nA.sort()\nans = []\n\nx = A[0]\nfor i in range(1, n-1):\n ans.append((x, A[i]))\n x -= A[i]\nif x<0:\n ans.append((A[-1], x))\nelse:\n ans.append((x, A[-1]))\nprint(abs(A[-1] - x))\nfor a in ans:\n print(*a)", "jacc_sim": 0.9117647058823529, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [167, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u372144784", "n_user": "u372144784", "pos": "#diverta 2019 Programming Contest 2 -C Successive Subtraction\nimport sys\nreadline = sys.stdin.buffer.readline\ndef even(n): return 1 if n%2==0 else 0\nn = int(readline())\nlst1 = list(map(int,readline().split()))\n\nlst1.sort()\nlst2 = []\nl,r = lst1[0],lst1[-1]\nfor i in range(1,n-1):\n mid = lst1[i]\n if mid < 0:\n lst2.append([r,mid])\n r -= mid\n else:\n lst2.append([l,mid])\n l -= mid\nlst2.append([r,l])\nprint(r-l)\nfor i in lst2:\n print(*i)", "neg": "#diverta 2019 Programming Contest 2 -C Successive Subtraction\nimport sys\nreadline = sys.stdin.buffer.readline\ndef even(n): return 1 if n%2==0 else 0\nn = int(readline())\nlst1 = list(map(int,readline().split()))\n\nlst1.sort()\nlst2 = []\nl,r = lst1[0],lst1[-1]\nfor i in range(1,n-1):\n mid = lst1[i]\n if mid < 0:\n lst2.append([r,mid])\n r -= mid\n else:\n lst2.append([l,mid])\n l -= mid\nlst2.append([l,r])\nprint(abs(r-l))\nfor i in lst2:\n print(*i)", "jacc_sim": 0.9803921568627451, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [192, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u852690916", "n_user": "u547167033", "pos": "N=int(input())\nA=list(map(int,input().split()))\n\nA.sort()\nxy=[]\nfor i in range(N-2,0,-1):\n y=A[i]\n if y>0:\n x=A[0]\n A[0]-=y\n else:\n x=A[N-1]\n A[N-1]-=y\n xy.append((x,y))\n\nprint(A[N-1]-A[0])\nxy.append((A[N-1],A[0]))\nprint('\\n'.join([' '.join(map(str,t)) for t in xy]))", "neg": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nxy=[]\nfor i in range(n-2,0,-1):\n y=a[i]\n if y>0:\n x=a[0]\n a[0]-=y\n else:\n x=a[n-1]\n a[n-1]-=y\n xy.append((x,y))\nprint(a[n-1]-a[0])\nxy.append((a[n-1],a[0]))\nprint('\\n'.join([' '.join(map(str,t)) for t in xy]))", "jacc_sim": 0.9230769230769231, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [165, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u325227960", "n_user": "u325227960", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\nA = list(map(int,input().split()))\n\na, b = max(A), min(A)\nfor t in [a, b]:\n for i in range(len(A)):\n if A[i] == t:\n A.pop(i)\n break\n\nans = a-b\nfor i in range(n-2):\n ans += abs(A[i])\nprint(ans)\n\nfor i in range(n-2):\n if A[i] > 0:\n print(b, A[i])\n b -= A[i]\n else:\n print(a, A[i])\n a -= A[i]\nprint(a, b)", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\nA = list(map(int,input().split()))\n\na, b = max(A), min(A)\nfor t in [a, b]:\n for i in range(len(A)):\n if A[i] == t:\n A.pop(i)\n\nans = a-b\nfor i in range(n-2):\n ans += abs(A[i])\nprint(ans)\n\nfor i in range(n-2):\n if A[i] > 0:\n print(b, A[i])\n b -= A[i]\n else:\n print(a, A[i])\n a -= A[i]\nprint(a, b)", "jacc_sim": 0.975609756097561, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [188, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u994988729", "n_user": "u994988729", "pos": "from collections import deque\nn = int(input())\na = list(map(int, input().split()))\na.sort()\na = deque(a)\n\nleft = a.popleft()\nright = a.pop()\n\nans = []\nfor i in a:\n if i > 0:\n ans.append((left, i))\n left -= i\n else:\n ans.append((right, i))\n right -= i\nelse:\n ans.append((right, left))\n\nprint(right-left)\nfor x, y in ans:\n print(x, y)\n", "neg": "from collections import deque\nn = int(input())\na = list(map(int, input().split()))\na.sort()\na = deque(a)\n\nleft = a.popleft()\nright = a.pop()\n\nans = []\nfor i in a:\n if i > 0:\n ans.append((left, i))\n left -= i\n else:\n ans.append((right, i))\n right -= i\nelse:\n ans.append((right, left))\n\nfor x, y in ans:\n print(x, y)\n", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [143, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u921773161", "n_user": "u921773161", "pos": "#%%\nn = int(input())\na = list(map(int ,input().split()))\n\na.sort(reverse=True)\nans = []\nfor i in range(n):\n if i == 0:\n tmp = a[i]\n elif 1 <= i < n - 1:\n if a[i] > 0:\n ans.append(str(a[-1]) + ' ' + str(a[i]))\n a[-1] -= a[i]\n else:\n ans.append(str(tmp) + ' ' + str(a[i]))\n tmp -= a[i]\n else:\n ans.append(str(tmp) + ' ' + str(a[-1]))\n a = tmp - a[-1]\n print(a)\n\nfor i in range(len(ans)):\n x, y = map(int, ans[i].split())\n print(x, y)\n", "neg": "#%%\nn = int(input())\na = list(map(int ,input().split()))\n\na.sort(reverse=True)\nans = []\nfor i in range(n):\n if i == 0:\n tmp = a[i]\n elif 1 <= i < n - 1:\n if a[i] > 0:\n a[-1] -= a[i]\n ans.append(str(a[-1]) + ' ' + str(a[i]))\n else:\n tmp -= a[i]\n ans.append(tmp + ' ' + str(a[i]))\n else:\n ans.append(str(tmp) + ' ' + str(a[-1]))\n a = tmp - a[-1]\n print(a)\n\nfor i in range(len(ans)):\n print(ans[i])\n", "jacc_sim": 0.9523809523809523, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [226, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u781755665", "n_user": "u781755665", "pos": "N = int(input())\na = list(map(int, input().split(' ')))\na.sort(reverse=True)\n\nprocess = []\np_seed = a.pop(0)\nn_seed = a.pop(-1)\nfor e in a:\n if e >= 0:\n process.append((n_seed, e))\n n_seed -= e\n else:\n process.append((p_seed, e))\n p_seed -= e\nprocess.append((p_seed, n_seed))\nm = p_seed - n_seed\nprint(m)\nfor x, y in process:\n print(str(x) + ' ' + str(y))\n", "neg": "N = int(input())\na = list(map(int, input().split(' ')))\na.sort(reverse=True)\n\nprocess = []\np_seed = a.pop(0)\nn_seed = a.pop(-1)\nfor e in a:\n \tif e >= 0:\n \tprocess.append((n_seed, e))\n \tn_seed -= e\n \telse:\n \tprocess.append((p_seed, e))\n \tp_seed -= e\nprocess.append((p_seed, n_seed))\nm = p_seed - n_seed\nprint(m)\nfor x, y in process:\n print(str(x) + ' ' + str(y))", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [165, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u309710010", "n_user": "u309710010", "pos": "n = int(input())\na = input().split()\nfor i in range(len(a)):\n a[i]=int(a[i])\n# print(a)\na.sort()\n# print(a)\n# #\u4e21\u7aef\u3092\u3068\u3063\u3066\u304a\u304f\nhashi1 = a[0]\nhashi2 = a[-1]\na.remove(a[0])\na.remove(a[-1])\n# print(a)\nminus_list = []\nplus_list = []\nprintlist = []\nfor i in range(len(a)):\n if a[i]>0:\n plus_list.append(a[i])\n else:\n minus_list.append(a[i])\n# print(minus_list)\n# print(plus_list)\nfor j in range(len(minus_list)):\n printlist.append(hashi2)\n printlist.append(minus_list[j])\n hashi2 = hashi2-minus_list[j]\n \nfor l in range(len(plus_list)):\n printlist.append(hashi1)\n printlist.append(plus_list[l])\n hashi1 = hashi1 - plus_list[l]\n \nprintlist.append(hashi2)\nprintlist.append(hashi1)\nprint(hashi2-hashi1)\n# print(printlist)\nfor n in range(0,len(printlist),2):\n print(printlist[n],printlist[n+1])", "neg": "n = int(input())\na = input().split()\nfor i in range(len(a)):\n a[i]=int(a[i])\n# print(a)\na.sort()\n# print(a)\n# #\u4e21\u7aef\u3092\u3068\u3063\u3066\u304a\u304f\nhashi1 = a[0]\nhashi2 = a[-1]\na.remove(a[0])\na.remove(a[-1])\n# print(a)\nminus_list = []\nplus_list = []\nfor i in range(len(a)):\n if a[i]>0:\n plus_list.append(a[i])\n else:\n minus_list.append(a[i])\n# print(minus_list)\n# print(plus_list)\nfor j in range(len(minus_list)):\n hashi2 = hashi2-minus_list[j]\nfor l in range(len(plus_list)):\n hashi1 = hashi1 - plus_list[l]\n\nprint(hashi2-hashi1)\n", "jacc_sim": 0.9130434782608695, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [384, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u620480037", "n_user": "u620480037", "pos": "N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nans=[]\n\nif A[0]>0:\n num=A[0]\n for i in range(1,N-1):\n ans.append([num,A[i]])\n num-=A[i]\n ans.append([A[-1],num])\n print(A[-1]-num)\n for i in range(len(ans)):\n print(ans[i][0],ans[i][1])\nelif A[-1]<0:\n A.sort(reverse=True)\n num=A[0]\n for i in range(1,N):\n ans.append([num,A[i]])\n num-=A[i]\n print(num)\n for i in range(len(ans)):\n print(ans[i][0],ans[i][1])\nelse:\n M=A[-1]\n m=A[0]\n for i in range(1,N-1):\n if A[i]<0:\n ans.append([M,A[i]])\n M-=A[i]\n else:\n ans.append([m,A[i]])\n m-=A[i]\n ans.append([M,m])\n print(M-m)\n for i in range(len(ans)):\n print(ans[i][0],ans[i][1])", "neg": "N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nans=[]\n\nif A[0]>0:\n num=A[0]\n for i in range(1,N-1):\n ans.append([num,A[i]])\n num-=A[i]\n ans.append([A[-1],num])\n print(A[-1]-num)\n for i in range(len(ans)):\n print(ans[i])\nelif A[-1]<0:\n A.sort(reverse=True)\n num=A[0]\n for i in range(1,N):\n ans.append([num,A[i]])\n num-=A[i]\n print(num)\n for i in range(len(ans)):\n print(ans[i])\nelse:\n M=A[-1]\n m=A[0]\n for i in range(1,N-1):\n if A[i]<0:\n ans.append([M,A[i]])\n M-=A[i]\n else:\n ans.append([m,A[i]])\n m-=A[i]\n ans.append([M,m])\n print(M-m)\n for i in range(len(ans)):\n print(ans[i])", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [364, 340], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u426108351", "n_user": "u426108351", "pos": "n = int(input())\na = list(map(int, input().split()))\na.sort()\nans = 0\nanslist = []\n\nfor i in range(1,n-1):\n if a[i] < 0:\n anslist.append([a[-1], a[i]])\n a[-1] -= a[i]\n else:\n anslist.append([a[0], a[i]])\n a[0] -= a[i]\nanslist.append([a[-1], a[0]])\nans = a[-1]-a[0]\nprint(ans)\nfor i in range(len(anslist)):\n print(anslist[i][0], anslist[i][1])\n \n \n \n", "neg": "n = int(input())\na = list(map(int, input().split()))\na.sort()\nans = 0\nanslist = []\nif a[0] >= 0:\n pass\n \nelif a[-1] < 0:\n pass\n \nelse:\n for i in range(1,n-1):\n if a[i] < 0:\n anslist.append([a[-1], a[i]])\n a[-1] -= a[i]\n else:\n anslist.append([a[0], a[i]])\n a[0] -= a[i]\n anslist.append([a[-1], a[0]])\n ans = a[-1]-a[0]\n print(ans)\n for i in range(len(anslist)):\n print(anslist[i][0], anslist[i][1])\n \n \n ", "jacc_sim": 0.9117647058823529, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [183, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u622523700", "n_user": "u622523700", "pos": "import bisect\nn = int(input())\na = list(map(int, input().split()))\n\na.sort()\nope = []\nmax_num = a[-1]\nmin_num = a[0]\np = bisect.bisect_left(a, 0)\nfor i in range(1, min(p, n - 1)):\n ope.append([max_num, a[i]])\n max_num -= a[i]\nfor i in range(max(p, 1), n - 1):\n ope.append([min_num, a[i]])\n min_num -= a[i]\nope.append([max_num, min_num])\nprint(max_num - min_num)\nfor i in range(n - 1):\n print(\" \".join(map(str, ope[i])))", "neg": "import bisect\nn = int(input())\na = list(map(int, input().split()))\n\na.sort()\nope = []\nmax_num = a[-1]\nmin_num = a[0]\np = bisect.bisect_left(a, 0)\nfor i in range(1, p):\n ope.append([max_num, a[i]])\n max_num -= a[i]\nfor i in range(p, n - 1):\n ope.append([min_num, a[i]])\n min_num -= a[i]\nope.append([max_num, min_num])\nprint(max_num - min_num)\nfor i in range(n - 1):\n print(\" \".join(map(str, ope[i])))", "jacc_sim": 0.9459459459459459, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [202, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u983918956", "n_user": "u983918956", "pos": "N = int(input())\nA = sorted(list(map(int,input().split())))\n\np = A[-1]\nn = A[0]\n\nans_list = []\n\nfor a in A[1:-1]:\n if a >= 0:\n ans_list.append((n, a))\n n -= a\n else:\n ans_list.append((p, a))\n p -= a\n\nM = p - n\nans_list.append((p, n))\n\nprint(M)\nfor x, y in ans_list:\n print(x, y)", "neg": "N = int(input())\nA = sorted(list(map(int,input().split())))\n\np = A[-1]\nn = A[0]\n\nans_list = []\n\nfor a in A[1:-1]:\n if a >= 0:\n ans_list.append((n, a))\n n -= a\n else:\n ans_list.append((p, a))\n p -= a\n\nM = p - n\nans_list.append((p, n))\n\nprint(M)\nfor ans in ans_list:\n print(ans)", "jacc_sim": 0.9117647058823529, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [143, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u983918956", "n_user": "u983918956", "pos": "N = int(input())\nA = sorted(list(map(int,input().split())))\n\nans_list = []\np = []\nn = []\n\n# \u6700\u5927\u306b\u30d7\u30e9\u30b9\u3001\u6700\u5c0f\u306b\u30de\u30a4\u30ca\u30b9\u3092\u5272\u308a\u5f53\u3066\u308b\np.append(A[-1])\nn.append(A[0])\n\n# \u6b63\u306a\u3089\u30d7\u30e9\u30b9\u3092\u8ca0\u306a\u3089\u30de\u30a4\u30ca\u30b9\u3092\u5272\u308a\u5f53\u3066\u308b\nfor a in A[1:-1]:\n if a >= 0:\n p.append(a)\n elif a < 0:\n n.append(a)\n\n# \u30d7\u30e9\u30b9\u304c\uff11\u3064\u306b\u306a\u308b\u307e\u3067\u6d88\u3059\nwhile len(p) != 1:\n x = n.pop()\n y = p.pop()\n n.append(x-y)\n ans_list.append((x, y))\n\n# \u30de\u30a4\u30ca\u30b9\u304c\u306a\u304f\u306a\u308b\u307e\u3067\u6d88\u3059\nwhile len(n) != 0:\n x = p.pop()\n y = n.pop()\n p.append(x-y)\n ans_list.append((x,y))\n\n# \u6b8b\u3063\u305f\u3082\u306e\u304c\u6700\u5927\u5024\nM = p[0]\nprint(M)\nfor x, y in ans_list:\n print(x, y)", "neg": "N = int(input())\nA = sorted(list(map(int,input().split())))\n\nans_list = []\np = []\nn = []\n\n# \u6700\u5927\u306b\u30d7\u30e9\u30b9\u3001\u6700\u5c0f\u306b\u30de\u30a4\u30ca\u30b9\u3092\u5272\u308a\u5f53\u3066\u308b\np.append(A[-1])\nn.append(A[0])\n\n# \u6b63\u306a\u3089\u30d7\u30e9\u30b9\u3092\u8ca0\u306a\u3089\u30de\u30a4\u30ca\u30b9\u3092\u5272\u308a\u5f53\u3066\u308b\nfor a in A[1:-1]:\n if a >= 0:\n p.append(a)\n elif a < 0:\n n.append(a)\n\n# \u30d7\u30e9\u30b9\u304c\uff11\u3064\u306b\u306a\u308b\u307e\u3067\u6d88\u3059\nwhile len(p) != 1:\n x = n.pop()\n y = p.pop()\n n.append(x-y)\n ans_list.append((x, y))\n\n# \u30de\u30a4\u30ca\u30b9\u304c\u306a\u304f\u306a\u308b\u307e\u3067\u6d88\u3059\nwhile len(n) != 0:\n x = p.pop()\n y = n.pop()\n p.append(x-y)\n ans_list.append((x,y))\n\n# \u6b8b\u3063\u305f\u3082\u306e\u304c\u6700\u5927\u5024\nM = p[0]\nprint(M)\nfor ans in ans_list:\n print(ans)", "jacc_sim": 0.9866666666666667, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [465, 461], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u511965386", "n_user": "u511965386", "pos": "N = int(input())\nA = [int(i) for i in input().split()]\nA.sort(reverse=True)\n\nlog = []\n\n# \u3059\u3079\u3066\u6b63\nif A[-1] > 0 :\n a = A.pop()\n b = A.pop()\n log.append([a, b])\n A.append(a - b)\n# \u3059\u3079\u3066\u8ca0\nelif A[0] < 0 :\n a = A.pop(0)\n b = A.pop()\n log.append([a, b])\n A = [a-b] + A\n \ni = 1\nwhile A[i] > 0 :\n a = A.pop()\n log.append([a, A[i]])\n A.append(a-A[i])\n i += 1\n \nwhile i < len(A) :\n log.append([A[0], A[i]])\n A[0] -= A[i]\n i += 1\n \nprint(A[0])\nfor l in log :\n print(l[0], l[1])\n ", "neg": "N = int(input())\nA = [int(i) for i in input().split()]\nA.sort(reverse=True)\n\n# \u3059\u3079\u3066\u6b63\nif A[-1] > 0 :\n a = A.pop()\n b = A.pop()\n print(a, b)\n A.append(a - b)\n# \u3059\u3079\u3066\u8ca0\nelif A[0] < 0 :\n a = A.pop(0)\n b = A.pop()\n print(a, b)\n A = [a-b] + A\n \ni = 1\nwhile A[i] > 0 :\n a = A.pop()\n print(a, A[i])\n A.append(a-A[i])\n i += 1\n \nprint(A[0], A[-1])\nprint(A[0]-A[-1])\n ", "jacc_sim": 0.9285714285714286, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [285, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u829249049", "n_user": "u829249049", "pos": "N=int(input())\nlistA=list(map(int,input().split()))\nlistB=[abs(i) for i in listA]\nMAX=max(listA)\nMIN=min(listA)\nans=sum(listB)\nif MAX<=0:\n print(ans+MAX*2)\nelif MIN<=0:\n print(ans) \nelse:\n print(ans-MIN*2)\nlistC=sorted(listA) \nfor i in range(len(listA)-2):\n if listC[i+1]>=0:\n print(MIN,listC[i+1])\n MIN=MIN-listC[i+1]\n else:\n print(MAX,listC[i+1])\n MAX=MAX-listC[i+1]\nprint(MAX,MIN)", "neg": "N=int(input())\nlistA=list(map(int,input().split()))\nlistB=[abs(i) for i in listA]\nMAX=max(listA)\nMIN=min(listA)\nans=sum(listB)\nif MIN<=0:\n print(ans)\nelse:\n print(ans-MIN)\nlistC=sorted(listA) \nfor i in range(len(listA)-2):\n if listC[i+1]>=0:\n print(MIN,listC[i+1])\n MIN=MIN-listC[i+1]\n else:\n print(MAX,listC[i+1])\n MAX=MAX-listC[i+1]\nprint(MAX,MIN)", "jacc_sim": 0.9523809523809523, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [204, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u907223098", "n_user": "u907223098", "pos": "n=int(input())\na=[]\nr=[]\nfor i in input().split():\n a.append(int(i))\na.sort()\nt=a.pop(-1)\nb=a.pop(0)\nfor i in a:\n if i>=0:\n r.append([b,i])\n b=b-i\n else:\n r.append([t,i])\n t=t-i\nprint(t-b)\nr.append([t,b])\nfor i in r:\n print(i[0],i[1])\n", "neg": "n=int(input())\na=[]\nr=[]\nfor i in input().split():\n a.append(int(i))\na.sort()\nt=a[-1]\nb=a[0]\nfor i in a[1:-1]:\n if i>=0:\n r.append([b,i])\n b=b-i\n else:\n r.append([t,i])\n t=t-i\nprint(t-b)\nfor i in r:\n print(r[0],r[1])\n", "jacc_sim": 0.9655172413793104, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [142, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u945418216", "n_user": "u945418216", "pos": "import sys\nN = int(input())\nA = sorted(list(map(int,input().split())))\n\nmn = A[0]\nmx = A[-1]\nif N ==2:\n print(A[1] - A[0])\n print(A[1],A[0])\n sys.exit()\nope = []\nfor a in A[1:-1]:\n if a <=0:\n ope.append([mx, a])\n mx -= a\n else:\n ope.append([mn, a])\n mn -= a\nope.append([mx,mn])\nprint(mx-mn)\nfor o in ope:\n print(o[0],o[1])", "neg": "import sys\nN = int(input())\nA = sorted(list(map(int,input().split())))\n\nmn = A[0]\nmx = A[-1]\nif N ==2:\n print(A[1] - A[0])\n print(A[1],A[0])\n sys.exit()\nope = []\nfor a in A[1:-1]:\n if a <=0:\n ope.append([mx, a])\n mx -= a\n else:\n ope.append([a, mn])\n mn -= a\nope.append([mx,mn])\nprint(mx-mn)\nfor o in ope:\n print(o[0],o[1])", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [170, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u067729694", "n_user": "u067729694", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\nBB = A[:]\n\nBB_P = []\nBB_M = []\n\n\nfor b in BB:\n if b < 0:\n BB_M.append(b)\n else:\n BB_P.append(b)\n\n \nope = []\nif not BB_M:\n BB_P = sorted(BB_P)\n p = BB_P[-1]\n m = BB_P[0]\n for b in BB_P[1:-1]:\n ope.append((m,b))\n m = m-b\n ope.append((p,m))\n ans = p - m\nelif not BB_P:\n BB_M = sorted(BB_M)\n p = BB_M[-1]\n for b in BB_M[:-1]:\n ope.append((p, b))\n p = p-b\n ans = p\nelse:\n p = BB_P.pop()\n m = BB_M.pop()\n for b in BB_P:\n ope.append((m ,b))\n m = m-b\n for b in BB_M:\n ope.append((p ,b))\n p = p-b\n ope.append((p,m))\n ans = p-m\n \nprint(ans)\nfor x,y in ope:\n print(x, y)\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\nBB = A[:]\n\nBB_P = []\nBB_M = []\n\n\nfor b in BB:\n if b < 0:\n BB_M.append(b)\n else:\n BB_P.append(b)\n\n \nope = []\nif not BB_M:\n BB_P = sorted(BB_P)\n p = BB_P[-1]\n m = BB_P[0]\n for b in BB_P[1:-1]:\n ope.append((m,b))\n m = m-b\n ope.append((p,m))\n ans = p - m\nelif not BB_P:\n BB_M = sorted(BB_M)\n p = BB_M[-1]\n for b in BB_M[:-1]:\n ope.append((p, b))\n p = p-b\n ans = p\nelse:\n p = BB_P.pop()\n m = BB_M.pop()\n for b in BB_P:\n ope.append((m ,b))\n m = m-b\n for b in BB_M:\n ope.append((p ,b))\n p = p-b\n ope((p,m))\n ans = p-m\n \nprint(ans)\nfor x,y in ope:\n print(x, y)\n", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [360, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u196579381", "n_user": "u196579381", "pos": "def plus(pl):\n if len(pl) == 1:\n return pl[0]\n pl.sort()\n tmp = pl.pop(0)\n while len(pl) > 1:\n tmp2 = pl.pop(0)\n print(tmp, tmp2)\n tmp -= tmp2\n print(pl[0], tmp)\n return pl[0]-tmp\n\n\ndef minas(mi):\n if len(mi) == 1:\n return mi[0]\n mi.sort()\n tmp = mi.pop()\n while len(mi) > 1:\n tmp2 = mi.pop()\n print(tmp, tmp2)\n tmp -= tmp2\n print(tmp, mi[0])\n return tmp-mi[0]\n\n\nn = int(input())\n\nmi = []\npl = []\n\nfor i in [int(j) for j in input().split()]:\n if i < 0:\n mi.append(i)\n else:\n pl.append(i)\n\nif len(pl) == 0:\n print(2*max(mi)-sum(mi))\n minas(mi)\nelif len(mi) == 0:\n print(sum(pl)-2*min(pl))\n plus(pl)\nelse:\n print(abs(sum(mi))+sum(pl))\n mi.sort()\n pl.sort(reverse=True)\n while len(pl) > 1:\n tmp = pl.pop()\n print(mi[0], tmp)\n mi[0] -= tmp\n\n while len(mi) > 1:\n tmp = mi.pop()\n print(pl[0], tmp)\n pl[0] -= tmp\n\n print(pl[0], mi[0])\n", "neg": "import sys\n\n\ndef plus(pl):\n if len(pl) == 1:\n return pl[0]\n pl.sort()\n tmp = pl.pop(0)\n while len(pl) > 1:\n tmp2 = pl.pop(0)\n print(tmp, tmp2)\n tmp -= tmp2\n print(pl[0], tmp)\n return pl[0]-tmp\n\n\ndef minas(mi):\n if len(mi) == 1:\n return mi[0]\n mi.sort()\n tmp = mi.pop()\n while len(mi) > 1:\n tmp2 = mi.pop()\n print(tmp, tmp2)\n tmp -= tmp2\n print(tmp, mi[0])\n return tmp-mi[0]\n\n\nn = int(input())\n\nmi = []\npl = []\n\nfor i in [int(j) for j in input().split()]:\n if i < 0:\n mi.append(i)\n else:\n pl.append(i)\n\nif len(pl) == 0:\n print(abs(sum(mi)-max(mi)))\n minas(mi)\nelif len(mi) == 0:\n print(sum(pl)-min(pl))\n plus(pl)\nelse:\n print(abs(sum(mi))+sum(pl))\n mi.sort()\n pl.sort(reverse=True)\n while len(pl) > 1:\n tmp = pl.pop()\n print(mi[0], tmp)\n mi[0] -= tmp\n\n while len(mi) > 1:\n tmp = mi.pop()\n print(mi[0], tmp)\n mi[0] -= tmp\n\n print(pl[0], mi[0])\n", "jacc_sim": 0.9183673469387755, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [431, 434], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u322185540", "n_user": "u322185540", "pos": "n = int(input())\nalist = list(map(int,input().split()))\nans = []\n\nif len(alist) == 2:\n alist.sort(reverse = True)\n print(alist[0]-alist[1])\n print(' '.join(map(str,alist)))\nelse:\n plus =[w for w in alist if w>=0]\n minus =[x for x in alist if x<0]\n if minus == []:\n plus.sort()\n for y in range(len(plus)-2):\n ans.append(' '.join(map(str,plus[y:y+2])))\n plus[y+1] = plus[y]-plus[y+1]\n pplus = plus[::-1]\n ans.append(' '.join(map(str,pplus[0:2])))\n print(pplus[0]-pplus[1])\n for y in ans:\n print(y)\n elif plus == []:\n minus.sort(reverse = True)\n for y in range(len(minus)-1):\n ans.append(' '.join(map(str,minus[y:y+2])))\n minus[y+1] = minus[y]-minus[y+1]\n print(minus[-1])\n for y in ans:\n print(y)\n else:\n for z in range(len(plus)-1):\n ans.append(' '.join(map(str,[minus[0],plus[z]])))\n minus[0] = minus[0]-plus[z]\n for q in minus:\n ans.append(' '.join(map(str,[plus[-1],q])))\n plus[-1] = plus[-1]-q\n print(plus[-1])\n for t in ans:\n print(t)", "neg": "n = int(input())\nalist = list(map(int,input().split()))\nans = []\n\nif len(alist) == 2:\n alist.sort(reverse = True)\n print(alist[0]-alist[1])\n print(' '.join(map(str,alist)))\nelse:\n plus =[w for w in alist if w>=0]\n minus =[x for x in alist if x<0]\n if minus == []:\n plus.sort()\n for y in range(len(plus)-2):\n ans.append(' '.join(map(str,plus[y:y+2])))\n plus[y+1] = plus[y]-plus[y+1]\n pplus = plus[::-1]\n ans.append(' '.join(map(str,pplus[0:2])))\n print(pplus[0]-pplus[1])\n for y in ans:\n print(y)", "jacc_sim": 0.9148936170212766, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [451, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u606045429", "n_user": "u606045429", "pos": "N = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort()\n\nL = [a for a in A if a <= 0]\nR = [a for a in A if a > 0]\n\nans = []\n\nif L != [] and R != []:\n low = L[0]\n for r in R[:-1]:\n ans.append([low, r])\n low -= r\n\n up = R[-1]\n for l in L[1:]:\n ans.append([up, l])\n up -= l\n\n ans.append([up, low])\n ans.append([up - low])\n\nelif L == []:\n low, up = R[0], R[-1]\n for r in R[1:-1]:\n ans.append([low, r])\n low -= r\n ans.append([up, low])\n ans.append([up - low])\n\nelif R == []:\n low, up = L[0], L[-1]\n for l in L[1:-1]:\n ans.append([up, l])\n up -= l\n ans.append([up, low])\n ans.append([up - low])\n\nprint(*ans[-1])\nfor a in ans[:-1]:\n print(*a)\n", "neg": "N = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort()\n\nL = [a for a in A if a <= 0]\nR = [a for a in A if a > 0]\n\nif L != [] and R != []:\n low = L[0]\n for r in R[:-1]:\n print(low, r)\n low -= r\n\n up = R[-1]\n for l in L[1:]:\n print(up, l)\n up -= l\n\n print(up, low)\n print(up - low)\n\nelif L == []:\n low, up = R[0], R[-1]\n for r in R[1:-1]:\n print(low, r)\n low -= r\n print(up, low)\n print(up - low)\n\nelif R == []:\n low, up = L[0], L[-1]\n for l in L[1:-1]:\n print(up, l)\n up -= l\n print(up, low)\n print(up - low)\n\n", "jacc_sim": 0.918918918918919, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [323, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u767948584", "n_user": "u767948584", "pos": "N = int(input())\nA_lis = list(map(int, input().split()))\n\nA_lis.sort()\n\nN_neg = 0\nfor j in A_lis:\n if j < 0:\n N_neg += 1\n else:\n break\n \nN_pos = len(A_lis) - N_neg\n\nseq = []\n\nneg = A_lis[0]\npos = A_lis[-1]\n\nif N_neg == 0:\n for j in range(N_pos-2):\n ind = j + 1\n seq.append((neg, A_lis[ind]))\n neg = neg - A_lis[ind]\n seq.append((pos, neg))\n print(pos-neg)\n for j in seq:\n print(\"%d %d\" % j)\n exit()\n \nif N_pos == 0:\n for j in range(N_neg-1):\n ind = j\n seq.append((pos, A_lis[ind]))\n pos = pos - A_lis[ind]\n print(pos)\n for j in seq:\n print(\"%d %d\" % j)\n exit()\n \nfor j in range(N_pos-1):\n ind = N_neg + j\n seq.append((neg, A_lis[ind]))\n neg = neg - A_lis[ind]\n\n \nfor j in range(N_neg-1):\n ind = j + 1\n seq.append((pos, A_lis[ind]))\n pos = pos - A_lis[ind]\n \nseq.append((pos, neg))\nprint(pos-neg)\n\nfor j in seq:\n print(\"%d %d\" % j)\n", "neg": "N = int(input())\nA_lis = list(map(int, input().split()))\n\nA_lis.sort()\n\nN_neg = 0\nfor j in A_lis:\n if j < 0:\n N_neg += 1\n else:\n break\n\nN_pos = len(A_lis) - N_neg\n\nseq = []\n\nneg = A_lis[0]\n\nfor j in range(N_pos-1):\n ind = N_neg + j\n seq.append((neg, A_lis[ind]))\n neg = neg - A_lis[ind]\n\npos = A_lis[-1]\n \nfor j in range(N_neg-1):\n ind = j + 1\n seq.append((pos, A_lis[ind]))\n pos = pos - A_lis[ind]\n \nseq.append((pos, neg))\nprint(pos-neg)\n\nfor j in seq:\n print(\"%d %d\" % j)\n", "jacc_sim": 0.9523809523809523, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [432, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u635182517", "n_user": "u635182517", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\nMAX = A.pop(-1)\nans = MAX\nMIN = A.pop(0)\nMIN2 = MIN\nMAX2 = MAX\n\nif MIN2 <= 0:\n if N == 2:\n ans -= MIN2\n else:\n for a in A:\n if a > 0:\n MIN2 -= a\n else:\n \n MAX2 -= a\n ans = MAX2 - MIN2\n \n \nelse:\n if N == 2:\n ans -= MIN2\n \n else:\n b = A.pop(-1)\n \n MIN2 -= b\n for a in A:\n if a > 0:\n \n MIN2 -= a\n else:\n \n MAX2 -= a\n ans = MAX2 - MIN2\n\nprint(ans)\n\nif MIN <= 0:\n if N == 2:\n ans -= MIN\n print(\"{0} {1}\".format(MAX, MIN))\n else:\n \n for a in A:\n if a > 0:\n print(\"{0} {1}\".format(MIN, a))\n MIN -= a\n else:\n print(\"{0} {1}\".format(MAX, a))\n MAX -= a\n print(\"{0} {1}\".format(MAX, MIN))\n \nelse:\n if N == 2:\n ans -= MIN\n print(\"{0} {1}\".format(MAX, MIN))\n else:\n \n print(\"{0} {1}\".format(MIN, b))\n MIN -= b\n for a in A:\n if a > 0:\n print(\"{0} {1}\".format(MIN, a))\n MIN -= a\n else:\n print(\"{0} {1}\".format(MAX, a))\n MAX -= a\n print(\"{0} {1}\".format(MAX, MIN))\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\nMAX = A.pop(-1)\nans = MAX\nMIN = A.pop(0)\nif MIN <= 0:\n if N == 2:\n ans -= MIN\n print(\"{0} {1}\".format(MAX, MIN))\n else:\n \n for a in A:\n if a > 0:\n print(\"{0} {1}\".format(MIN, a))\n MIN -= a\n else:\n print(\"{0} {1}\".format(MAX, a))\n MAX -= a\n print(\"{0} {1}\".format(MAX, MIN))\nelse:\n if N == 2:\n ans -= MIN\n print(\"{0} {1}\".format(MAX, MIN))\n else:\n b = A.pop(-1)\n print(\"{0} {1}\".format(MIN, b))\n MIN -= b\n for a in A:\n if a > 0:\n print(\"{0} {1}\".format(MIN, a))\n MIN -= a\n else:\n print(\"{0} {1}\".format(MAX, a))\n MAX -= a\n print(\"{0} {1}\".format(MAX, MIN))\n", "jacc_sim": 0.9459459459459459, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [480, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u352623442", "n_user": "u352623442", "pos": "n = int(input())\na = list(map(int,input().split()))\na = sorted(a)\n#print(a)\n\nif a[-1] < 0:\n ans = a[-1]\n for i in range(0,n-1):\n ans = ans - a[i]\n print(ans)\n\n ko = a[-1]\n for i in range(0,n-1):\n print(ko,a[i])\n ko = ko-a[i]\n\nelif a[0] < 0:\n ans = 0\n negn = 0\n for i in range(n):\n ans += abs(a[i])\n if a[i]<0:\n negn += 1\n print(ans)\n s = a[0]\n for i in range(negn , n-1):\n print(s,a[i])\n s = s-a[i]\n k = a[-1]\n for i in range(1,negn):\n print(k,a[i])\n k = k-a[i]\n print(k,s)\n\nelse:\n ans = 0\n for i in range(n):\n ans += abs(a[i])\n print(ans-2*a[0])\n m = a[0]\n for i in range(1,n-1):\n print(m,a[i])\n m = m-a[i]\n print(a[-1],m)\n", "neg": "n = int(input())\na = list(map(int,input().split()))\na = sorted(a)\nprint(a)\n\nif a[-1] < 0:\n ans = a[-1]\n for i in range(0,n-1):\n ans = ans - a[i]\n print(ans)\n\n ko = a[-1]\n for i in range(0,n-1):\n print(ko,a[i])\n ko = ko-a[i]\n\nelif a[0] < 0:\n ans = 0\n negn = 0\n for i in range(n):\n ans += abs(a[i])\n if a[i]<0:\n negn += 1\n print(ans)\n s = a[0]\n for i in range(negn , n-1):\n print(s,a[i])\n s = s-a[i]\n k = a[-1]\n for i in range(1,negn):\n print(k,a[i])\n k = k-a[i]\n print(k,s)\n\nelse:\n ans = 0\n for i in range(n):\n ans += abs(a[i])\n print(ans-2*a[0])\n m = a[0]\n for i in range(1,n-1):\n print(m,a[i])\n m = m-a[i]\n print(a[-1],m)\n", "jacc_sim": 0.9743589743589743, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [370, 369], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u310233294", "n_user": "u310233294", "pos": "N = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nAM = A.pop(0)\nxy = []\nif AM > 0 and A[-1] >= 0:\n p = 1\nelif AM <= 0 and A[-1] < 0:\n p = 2\nelse:\n p = 3\nif p == 1:\n while(len(A)>1):\n x = A.pop(-1)\n y = A.pop(0)\n xy.append([x, y])\n A.append(x-y)\n xy.append([AM, A[0]])\n ans = AM - A[0]\nif p == 2:\n while(len(A)>1):\n x = AM\n y = A.pop(-1)\n xy.append([x, y])\n AM -= y\n xy.append([AM, A[0]])\n ans = AM - A[0]\nif p == 3:\n while(len(A)>1):\n y = A.pop(0)\n if y >= 0:\n x = A.pop(-1)\n xy.append([x, y])\n A.append(x-y)\n else:\n x = AM\n xy.append([x, y])\n AM -= y\n xy.append([AM, A[0]])\n ans = AM - A[0]\nprint(ans)\nfor out in xy:\n print(*out)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nAM = A.pop(0)\nxy = []\nif AM > 0 and A[-1] >= 0:\n p = 1\nelif AM <= 0 and A[-1] < 0:\n p = 2\nelse:\n p = 3\nif p == 1:\n while(len(A)>1):\n x = A.pop(-1)\n y = A.pop(0)\n xy.append([x, y])\n A.append(x-y)\n xy.append([AM, A[0]])\n ans = AM - A[0]\nif p == 2:\n while(len(A)>1):\n x = AM\n y = A.pop(-1)\n xy.append([x, y])\n AM -= y\n xy.append([AM, A[0]])\n ans = AM - A[0]\nif p == 3:\n while(len(A)>1):\n y = A.pop(0)\n if y >= 0:\n x = A.pop(-1)\n xy.append([x, y])\n xy.append([x, y])\n A.append(x-y)\n else:\n x = AM\n xy.append([x, y])\n AM -= y\n xy.append([AM, A[0]])\n ans = AM - A[0]\nprint(ans)\nfor out in xy:\n print(*out)", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [365, 375], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u652150585", "n_user": "u652150585", "pos": "import bisect \n\nn=int(input())\nl=list(map(int,input().split()))\nl.sort()\nif l[0]>=0:\n #print('hello')\n a=l[0]\n ans=0\n for i in range(n):\n ans+=l[i]\n print(ans-2*l[0])\n for i in range(1,n-1):\n print(a,l[i])\n a-=l[i]\n print(l[-1],a)\nelif l[-1]<=0:\n #print('hello')\n a=l[-1]\n ans=l[-1]\n for i in range(n-1):\n ans-=l[i]\n print(ans)\n for i in range(n-1):\n print(a,l[i])\n a-=l[i]\nelse:\n #print('hello')\n idx=bisect.bisect(l,0)\n ans=0\n for i in range(n):\n if l[i]>=0:\n ans+=l[i]\n else:\n ans-=l[i]\n print(ans)\n a=l[0]\n for i in range(idx,n-1):\n print(a,l[i])\n a-=l[i]\n b=l[-1]\n for i in range(1,idx):\n print(b,l[i])\n b-=l[i]\n \n print(b,a)", "neg": "import bisect \n\nn=int(input())\nl=list(map(int,input().split()))\nl.sort()\n#dq=deque(l)\nif l[0]>=0:\n print('hello')\n a=l[0]\n ans=0\n for i in range(n):\n ans+=l[i]\n print(ans-2*l[0])\n for i in range(1,n-1):\n print(a,l[i])\n a-=l[i]\n print(l[-1],a)\nelif l[-1]<=0:\n #print('hello')\n a=l[-1]\n ans=l[-1]\n for i in range(n-1):\n ans-=l[i]\n print(ans)\n for i in range(n-1):\n print(a,l[i])\n a-=l[i]\nelse:\n #print('hello')\n idx=bisect.bisect(l,0)\n ans=0\n for i in range(n):\n if l[i]>=0:\n ans+=l[i]\n else:\n ans-=l[i]\n print(ans)\n a=l[0]\n for i in range(idx,n-1):\n print(a,l[i])\n a-=l[i]\n for i in range(1,a):\n print(l[-1],l[i])\n print(l[-1],a)", "jacc_sim": 0.9302325581395349, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [388, 382], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u950708010", "n_user": "u950708010", "pos": "import collections\n\ndef solve():\n n = int(input())\n a = collections.deque(sorted(list(int(i) for i in input().split())))\n big = a.pop()\n mini = a.popleft()\n queue = collections.deque([])\n #print(big,mini)\n while (a):\n if a[0] <= 0:\n tmp = a.popleft()\n queue.append((big,tmp))\n big -= tmp\n else:\n tmp = a.pop()\n queue.append((mini,tmp))\n mini -= tmp\n print(big-mini)\n queue.append((big,mini))\n for i in range(len(queue)):\n print(*queue[i])\n \nsolve()\n", "neg": "import collections\n\ndef solve():\n n = int(input())\n a = collections.deque(sorted(list(int(i) for i in input().split())))\n big = a.pop()\n mini = a.popleft()\n queue = collections.deque([])\n #print(big,mini)\n while (a):\n if a[0] <= 0:\n tmp = a.popleft()\n queue.append((big,tmp))\n big -= tmp\n else:\n tmp = a.pop()\n queue.append((tmp,mini))\n mini -= tmp\n print(big-mini)\n queue.append((big,mini))\n for i in range(len(queue)):\n print(*queue[i])\n \nsolve()\n", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [191, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u064408584", "n_user": "u064408584", "pos": "n=int(input())\na=sorted(map(int, input().split()))\na1=[i for i in a if i>=0]\na2=[i for i in a if i<0]\nif a1 and a2:\n print(sum(a1)-sum(a2))\n mx,mn=a1[-1], a2[0]\n for i in a1[:-1]:\n print(mn,i)\n mn-=i\n for i in a2[1:]:\n print(mx,i)\n mx-=i\n print(mx,mn)\nelif not a2:\n print(sum(a1[1:])-a1[0])\n mx,mn=a1[-1], a1[0]\n for i in a1[1:-1]:\n print(mn,i)\n mn-=i\n print(mx,mn)\nelse:\n print(a2[-1]-sum(a2[:-1]))\n mx,mn=a2[-1], a2[0]\n for i in a2[1:-1]:\n print(mx,i)\n mx-=i\n print(mx,mn)", "neg": "n=int(input())\na=sorted(map(int, input().split()))\na1=[i for i in a if i>=0]\na2=[i for i in a if i<0]\nif a1 and a2:\n print(sum(a1)-sum(a2))\n mx,mn=a1[-1], a2[0]\n for i in a1[:-1]:\n print(i,mn)\n mn-=i\n for i in a2[1:]:\n print(mx,i)\n mx-=i\n print(mx,mn)\nelif not a2:\n print(sum(a1[1:])-a1[0])\n mx,mn=a1[-1], a1[0]\n for i in a1[1:-1]:\n print(i,mn)\n mn-=i\n print(mx,mn)\nelse:\n print(a2[-1]-sum(a2[:-1]))\n mx,mn=a2[-1], a2[0]\n for i in a2[1:-1]:\n print(mx,i)\n mx-=i\n print(mx,mn)", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [293, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03007", "p_user": "u227082700", "n_user": "u227082700", "pos": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nmi,ma=a[0],a[-1]\nfor i in a[1:-1]:\n if i<0:ma-=i\n else:mi-=i\nprint(ma-mi)\nmi,ma=a[0],a[-1]\nfor i in a[1:-1]:\n if i<0:print(ma,i);ma-=i\n else:print(mi,i);mi-=i\nprint(ma,mi)", "neg": "n=int(input())\na=list(map(int,input().split()))\na.sort()\nmi,ma=a[0],a[-1]\nfor i in a[1:-1]:\n if i<0:print(ma,i);ma-=i\n else:print(mi,i);mi-=i\nprint(ma,mi)", "jacc_sim": 1.0, "nl": "You are given N integers written on a blackboard. You need to perform N-1 operations to have only one integer left. In each operation, you choose two integers x and y on the blackboard, erase them, and write a new integer x-y. Find the maximum possible value of the final integer and a sequence of operations that maximizes it. Constraints: 2 \u2264 N \u2264 10^5, -10^4 \u2264 A_i \u2264 10^4. Input format: N followed by N integers. Output format: Maximum possible value M of the final integer and a sequence of operations x_i, y_i. If there are multiple sequences that maximize the final integer, any will be accepted.", "before_after_length": [137, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03008", "p_user": "u754022296", "n_user": "u754022296", "pos": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nA = tuple(map(int, input().split()))\nB = tuple(map(int, input().split()))\ndef f(n):\n dp = list(range(n+1))\n for a, b in zip(A, B):\n for i in range(n+1):\n if i-a >= 0:\n dp[i] = max(dp[i], dp[i-a]+b)\n return max(dp)\nm = f(n)\nA, B = B, A\nans = f(m)\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nA = tuple(map(int, input().split()))\nB = tuple(map(int, input().split()))\ndef f(n):\n dp = list(range(n+1))\n for a, b in zip(A, B):\n if b <= a:\n continue\n for i in range(n+1):\n if i-a >= 0:\n dp[i] = max(dp[i], dp[i-a]+b)\n return max(dp[n])\nm = f(n)\nA, B = B, A\nans = f(m)\nprint(ans)", "jacc_sim": 0.9545454545454546, "nl": "Chokudai, a squirrel, has N acorns and plans to trade in precious metal exchanges to gain more acorns. His plan involves leaving the nest with N acorns, visiting two exchanges (A and B) to perform various trades, and then returning to the nest. At each exchange, he can perform operations to gain or lose acorns, gold, silver, or bronze. The goal is to determine the maximum number of acorns he can bring back to the nest. Constraints include N (1 to 5000) and the values for gold, silver, and bronze at each exchange (1 to 5000). The input format includes N, g_A, s_A, b_A, g_B, s_B, and b_B. The output should be the maximum number of acorns Chokudai can bring back to the nest. A sample input and output are provided.", "before_after_length": [153, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03008", "p_user": "u994988729", "n_user": "u994988729", "pos": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nU = 5000 * 5000 + 10\n\ninf = 10 ** 18\ndp1 = [-inf] * U\ndp1[0] = N\nfor a, b in zip(A, B):\n for i in range(N - a + 1):\n dp1[i + a] = max(dp1[i + a], dp1[i] + b - a)\n\nfor i in range(N + 1):\n N = max(N, dp1[i])\n\ndp2 = [-inf] * U\ndp2[0] = N\nfor a, b in zip(A, B):\n for i in range(N - b + 1):\n dp2[i + b] = max(dp2[i + b], dp2[i] + a - b)\n\nfor i in range(N + 1):\n N = max(N, dp2[i])\n\nprint(N)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nU = 5000 * 5000 + 10\n\ninf = 10 ** 18\ndp1 = [-inf] * U\ndp1[0] = N\nfor a, b in zip(A, B):\n for i in range(N - a + 1):\n dp1[i + a] = max(dp1[i + a], dp1[i] + b - a)\n\nfor i in range(N + 1):\n N = max(N, dp1[i])\nprint(N)\n\ndp2 = [-inf] * U\ndp2[0] = 0\nfor a, b in zip(A, B):\n for i in range(N - b + 1):\n dp2[i + b] = max(dp2[i + b], dp2[i] + a - b)\n\nfor i in range(N + 1):\n N = max(N, dp2[i])\n\nprint(N)", "jacc_sim": 1.0, "nl": "Chokudai, a squirrel, has N acorns and plans to trade in precious metal exchanges to gain more acorns. His plan involves leaving the nest with N acorns, visiting two exchanges (A and B) to perform various trades, and then returning to the nest. At each exchange, he can perform operations to gain or lose acorns, gold, silver, or bronze. The goal is to determine the maximum number of acorns he can bring back to the nest. Constraints include N (1 to 5000) and the values for gold, silver, and bronze at each exchange (1 to 5000). The input format includes N, g_A, s_A, b_A, g_B, s_B, and b_B. The output should be the maximum number of acorns Chokudai can bring back to the nest. A sample input and output are provided.", "before_after_length": [246, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03008", "p_user": "u007808656", "n_user": "u007808656", "pos": "def knapsack_123(values,weights,capacity):\n work = [0 for i in range(capacity+1)]\n for v,w in zip(values,weights):\n for c in range(w, capacity+1):\n work[c]=max(work[c],work[c-w]+v)\n return work[-1]\ndef sol(inp=input):\n n=int(inp())\n prices_a=list(map(int,inp().split()))+[1]\n prices_b=list(map(int,inp().split()))+[1]\n \n valA=knapsack_123(values=prices_b,weights=prices_a,capacity=n)\n valB=knapsack_123(values=prices_a,weights=prices_b,capacity=valA)\n return '{}'.format(valB)\nprint(sol())", "neg": "def knapsack_123(values,weights,capacity):\n work = [0 for i in range(capacity+1)]\n for v,w in zip(values,weights):\n for c in range(w, capacity+1):\n work[c]=max(work[c],work[c-w]+v)\n return work[-1]\ndef sol(inp=input):\n n=int(inp())\n prices_a=list(map(int,inp().split()))+[1]\n prices_b=list(map(int,inp().split()))+[1]\n \n valA,_=knapsack_123(values=prices_b,weights=prices_a,capacity=n)\n print(valA)\n valB,_=knapsack_123(values=prices_a,weights=prices_b,capacity=valA)\n return '{}'.format(valB)\nprint(sol())", "jacc_sim": 0.9787234042553191, "nl": "Chokudai, a squirrel, has N acorns and plans to trade in precious metal exchanges to gain more acorns. His plan involves leaving the nest with N acorns, visiting two exchanges (A and B) to perform various trades, and then returning to the nest. At each exchange, he can perform operations to gain or lose acorns, gold, silver, or bronze. The goal is to determine the maximum number of acorns he can bring back to the nest. Constraints include N (1 to 5000) and the values for gold, silver, and bronze at each exchange (1 to 5000). The input format includes N, g_A, s_A, b_A, g_B, s_B, and b_B. The output should be the maximum number of acorns Chokudai can bring back to the nest. A sample input and output are provided.", "before_after_length": [219, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03016", "p_user": "u285358283", "n_user": "u285358283", "pos": "def matrix_product(X,Y,M):\n XY = [[0]*3 for _ in range(3)]\n\n for i in range(3):\n for j in range(3):\n for k in range(3):\n XY[i][j] += X[i][k]*Y[k][j] % M\n XY[i][j] %= M\n \n return XY\n\ndef power(X,n,M):\n res = [[1,0,0],[0,1,0],[0,0,1]]\n\n if n == 0: return res\n\n while n > 0:\n if n & 1: res = matrix_product(res,X,M)\n X = matrix_product(X,X,M)\n n //= 2\n \n return res\n\nL, A, B, M = map(int,input().split())\n\nX = [0,A,1]\n\nfor d in range(1,19):\n if L == 0: break\n\n \n l = (10**(d-1) - A + B-1) // B\n r = (10**d - A) // B\n if (10**d - A) % B == 0: r -= 1\n \n if l < 0: l = 0\n if r < 0: r = -1\n \n C = min(r-l+1,L)\n L -= C\n\n Y = power([[10**d,0,0],[1,1,0],[0,B,1]],C,M)\n \n next_X = [0,0,0]\n for i in range(3):\n for j in range(3):\n next_X[i] += X[j] * Y[j][i] % M\n next_X[i] %= M\n X = next_X\n\nprint(X[0])\n\n\n\n\n\n\n\n", "neg": "def matrix_product(X,Y,M):\n XY = [[0]*3 for _ in range(3)]\n\n for i in range(3):\n for j in range(3):\n for k in range(3):\n XY[i][j] += X[i][k]*Y[k][j] % M\n XY[i][j] %= M\n \n return XY\n\ndef power(X,n,M):\n res = [[1,0,0],[0,1,0],[0,0,1]]\n\n if n == 0: return res\n\n while n > 0:\n if n & 1: res = matrix_product(res,X,M)\n X = matrix_product(X,X,M)\n n //= 2\n \n return res\n\nL, A, B, M = map(int,input().split())\n\nX = [0,A,1]\n\nfor d in range(1,19):\n if L == 0: break\n\n \n l = (10**(d-1) - A + B-1) // B\n r = (10**d - A) // B\n if (10**d - A) % B == 0: r -= 1\n \n if l < 0: l = 0\n if r < 0: r = -1\n print(\"{0} {1}\".format(l,r))\n\n \n C = min(r-l+1,L)\n L -= C\n print(C)\n\n Y = power([[10**d,0,0],[1,1,0],[0,B,1]],C,M)\n \n next_X = [0,0,0]\n for i in range(3):\n for j in range(3):\n next_X[i] += X[j] * Y[j][i] % M\n next_X[i] %= M\n X = next_X\n\nprint(X[0])", "jacc_sim": 0.9333333333333333, "nl": "You are given Q tuples of integers (L, A, B, M). For each tuple, answer the following question. There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference is B. That is, s_i = A + B * i holds. Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 would be concatenated into 37111519. What is the remainder when that integer is divided by M?\n\nConstraints:\n- All values in input are integers.\n- 1 <= L, A, B < 10^18\n- 2 <= M <= 10^9\n- All terms in the arithmetic progression are less than 10^18.\n\nInput:\nInput is given from Standard Input in the following format:\nL A B M\n\nOutput:\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1:\n5 3 4 10007\n\nSample Output 1:\n5563\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2:\n4 8 1 1000000\n\nSample Output 2:\n891011\n\nSample Input 3:\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3:\n39122908", "before_after_length": [462, 478], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03016", "p_user": "u077337864", "n_user": "u077337864", "pos": "import sys\nsys.setrecursionlimit(pow(10, 6))\n# input = sys.stdin.readline\n\nimport numpy as np\n\ndef pow_matmul(r, n, m):\n if n == 1:\n return r\n if n % 2 == 0:\n _r = pow_matmul(r, n//2, m)\n return np.mod(np.dot(_r, _r), m)\n else:\n _r = pow_matmul(r, n//2, m)\n _r = np.mod(np.dot(_r, _r), m)\n return np.mod(np.dot(r, _r), m)\n\ndef main():\n l, a, b, m = map(int, input().split())\n c = [min(max(0, (10**i - a - 1) // b + 1), l) for i in range(19)]\n ans = 0\n r = np.ones((3,3))\n s = np.array([0, a%m, 1])\n\n for d in range(1, 19):\n dnum = c[d] - c[d-1]\n if dnum==0:\n continue\n r_s = np.array([[pow(10, d, m), 1, 0], [0, 1, (b%m)], [0, 0, 1]])\n r = pow_matmul(r_s, dnum, m)\n s = np.mod(np.dot(r, s), m)\n if c[d] > l:\n break\n print(s[0])\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nsys.setrecursionlimit(pow(10, 6))\n# input = sys.stdin.readline\n\nimport numpy as np\n\ndef pow_matmul(r, n, m):\n if n == 1:\n return r\n if n % 2 == 0:\n _r = pow_matmul(r, n//2, m)\n return np.mod(np.dot(_r, _r), m)\n else:\n _r = pow_matmul(r, n//2, m)\n _r = np.mod(np.dot(_r, _r), m)\n return np.mod(np.dot(r, _r), m)\n\ndef main():\n l, a, b, m = map(int, input().split())\n c = [min(max(0, (10**i - a - 1) // b + 1), l) for i in range(19)]\n ans = 0\n r = np.ones((3,3))\n s = np.array([0, a%m, 1])\n\n for d in range(1, 19):\n dnum = c[d] - c[d-1]\n if dnum==0:\n continue\n r_s = np.array([[pow(10, d, m), 1, 0], [0, 1, (b%m)], [0, 0, 1]])\n r = pow_matmul(r_s, dnum, m)\n s = np.mod(np.dot(r, s), m)\n print(d, r, s)\n if c[d] > l:\n break\n print(s[0])\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given Q tuples of integers (L, A, B, M). For each tuple, answer the following question. There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference is B. That is, s_i = A + B * i holds. Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 would be concatenated into 37111519. What is the remainder when that integer is divided by M?\n\nConstraints:\n- All values in input are integers.\n- 1 <= L, A, B < 10^18\n- 2 <= M <= 10^9\n- All terms in the arithmetic progression are less than 10^18.\n\nInput:\nInput is given from Standard Input in the following format:\nL A B M\n\nOutput:\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1:\n5 3 4 10007\n\nSample Output 1:\n5563\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2:\n4 8 1 1000000\n\nSample Output 2:\n891011\n\nSample Input 3:\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3:\n39122908", "before_after_length": [406, 416], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03016", "p_user": "u508486691", "n_user": "u508486691", "pos": "import math\nimport numpy as np\nfrom decimal import *\nL,A,B,M=map(int, input().split())\n\ndef matpow(X,n,mod):\n E = np.eye(N=X.shape[0],dtype=int)\n Y = X%mod\n if n == 1:\n return Y\n else:\n return np.dot(matpow(np.dot(Y,Y)%mod,n//2,mod), (Y if n % 2 else E))%mod\n \na = 0\nfor d in range(1,19):\n left = math.ceil(Decimal(10**(d-1)-A)/Decimal(B))\n right = math.ceil(Decimal(10**d-A)/Decimal(B))-1\n if right < 0:\n continue\n if left > L-1:\n break\n if left > right:\n continue\n if left < 0:\n left = 0\n if right > L-1:\n right = L-1\n mat = np.matrix([[10**d,0,0],[1,1,0],[0,1,1]])\n result = np.dot(np.array([a,A+B*left,B])%M, matpow(mat,right-left+1,M))\n a = result[0,0]%M\n \nprint(a)", "neg": "import math\nimport numpy as np\nfrom decimal import *\nL,A,B,M=map(int, input().split())\n\ndef matpow(X,n,mod):\n E = np.eye(N=X.shape[0],dtype=int)\n Y = X%mod\n if n == 1:\n return Y\n else:\n return np.dot(matpow(np.dot(Y,Y)%mod,n//2,mod), (Y if n % 2 else E))%mod\n \na = 0\nfor d in range(1,19):\n left = math.ceil(Decimal(10**(d-1)-A)/Decimal(B))\n right = math.ceil(Decimal(10**d-A)/Decimal(B))-1\n if right < 0:\n continue\n if left > L-1:\n break\n if left > right:\n continue\n if left < 0:\n left = 0\n if right > L-1:\n right = L-1\n print(d,left,right)\n mat = np.matrix([[10**d,0,0],[1,1,0],[0,1,1]])\n result = np.dot(np.array([a,A+B*left,B])%M, matpow(mat,right-left+1,M))\n a = result[0,0]%M\n \nprint(a)", "jacc_sim": 1.0, "nl": "You are given Q tuples of integers (L, A, B, M). For each tuple, answer the following question. There is an arithmetic progression with L terms: s_0, s_1, s_2, ... , s_{L-1}. The initial term is A, and the common difference is B. That is, s_i = A + B * i holds. Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence 3, 7, 11, 15, 19 would be concatenated into 37111519. What is the remainder when that integer is divided by M?\n\nConstraints:\n- All values in input are integers.\n- 1 <= L, A, B < 10^18\n- 2 <= M <= 10^9\n- All terms in the arithmetic progression are less than 10^18.\n\nInput:\nInput is given from Standard Input in the following format:\nL A B M\n\nOutput:\nPrint the remainder when the integer obtained by concatenating the terms is divided by M.\n\nSample Input 1:\n5 3 4 10007\n\nSample Output 1:\n5563\nOur arithmetic progression is 3, 7, 11, 15, 19, so the answer is 37111519 mod 10007, that is, 5563.\n\nSample Input 2:\n4 8 1 1000000\n\nSample Output 2:\n891011\n\nSample Input 3:\n107 10000000000007 1000000000000007 998244353\n\nSample Output 3:\n39122908", "before_after_length": [334, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u648881683", "n_user": "u648881683", "pos": "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n s = SS()\n\n # A\u304cBC\u3092\u4e57\u308a\u8d8a\u3048\u3066\u53f3\u306b\u9032\u3080\u30a4\u30e1\u30fc\u30b8\n # \u305d\u308c\u305e\u308c\u306eA\u306b\u5bfe\u3057\u3066\u53f3\u5074\u306b\u9023\u7d9a\u3057\u305fBC\u304c\u3044\u304f\u3064\u3042\u308b\u304b\n ans = 0\n len_s = len(s)\n cnt = 0\n i = 0\n while i < len_s:\n # print(s[i], cnt)\n if s[i] == 'A':\n cnt += 1\n i += 1\n elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':\n ans += cnt\n i += 2\n else:\n cnt = 0\n i += 1\n \n print(ans)\n\nif __name__ == '__main__':\n resolve()\n", "neg": "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n s = SS()\n\n # A\u304cBC\u3092\u4e57\u308a\u8d8a\u3048\u3066\u53f3\u306b\u9032\u3080\u30a4\u30e1\u30fc\u30b8\n # \u305d\u308c\u305e\u308c\u306eA\u306b\u5bfe\u3057\u3066\u53f3\u5074\u306b\u9023\u7d9a\u3057\u305fBC\u304c\u3044\u304f\u3064\u3042\u308b\u304b\n ans = 0\n len_s = len(s)\n for i in range(len_s):\n cnt = 0\n if s[i] == 'A':\n cnt += 1\n elif i + 1 < len_s and s[i] == 'B' and s[i+1] == 'C':\n ans += cnt\n else:\n cnt = 0\n \n print(ans)\n\nif __name__ == '__main__':\n resolve()\n", "jacc_sim": 0.9705882352941176, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [423, 394], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u222668979", "n_user": "u316322317", "pos": "s = input().replace('BC','a')\n\nans, cnta = 0, 0\nfor i in range(len(s)):\n if s[i] == 'A':\n cnta += 1\n elif s[i] == 'a':\n ans += cnta\n else:\n cnta = 0\nprint(ans)\n", "neg": "s=input()\nl=s.replace('BC','D')\na=0\nans=0\nfor i in range(len(l)):\n if s[i]=='A':\n a+=1\n elif s[i]=='D':\n ans+=a\n else:\n a=0\nprint(ans)", "jacc_sim": 0.9032258064516129, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [81, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u576917603", "n_user": "u576917603", "pos": "s=input()\nn=len(s)\n\ncnt=0\nans=0\n\nfor i in range(n-1):\n if s[i]==\"A\":\n cnt+=1\n elif s[i:i+2]==\"BC\":\n ans+=cnt\n elif i>0 and s[i-1:i+1]==\"BC\":\n pass\n else:\n cnt=0\n\nprint(ans)\n ", "neg": "s=input()\nn=len(s)\n\ncnt=0\nans=0\n\nfor i in range(n-2):\n if s[i]==\"A\":\n cnt+=1\n elif s[i:i+2]==\"BC\":\n ans+=cnt\n elif i>0 and s[i-1:i+1]==\"BC\":\n pass\n else:\n cnt=0\n\nprint(ans)\n ", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [107, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u673361376", "n_user": "u673361376", "pos": "def sol(S):\n N = len(S)\n nums = [0 for _ in range(N+1)]\n i = N-1\n while i >= 0:\n if S[i-1:i+1] == 'BC':\n nums[i-1] = nums[i+1] + 1\n nums[i] = nums[i+1] + 1\n i -= 2\n else:\n nums[i] = nums[i+1]\n i -= 1\n ans = 0\n for i, s in enumerate(S):\n if s == 'A':\n ans += nums[i]\n return ans\n\nS = input()\nans = 0\nN = len(S)\nsi, i = 0, 0\nwhile i < N:\n if S[i] == 'A':\n i += 1\n elif S[i:i+2] == 'BC':\n i += 2\n else:\n ans += sol(S[si:i+1])\n si = i + 1\n i += 1\nans += sol(S[si:])\nprint(ans)", "neg": "def sol(S):\n N = len(S)\n nums = [0 for _ in range(N+1)]\n i = N-1\n while i >= 0:\n if S[i-1:i+1] == 'BC':\n nums[i-1] = nums[i+1] + 1\n nums[i] = nums[i+1] + 1\n i -= 2\n else:\n nums[i] = nums[i+1]\n i -= 1\n ans = 0\n for i, s in enumerate(S):\n if s == 'A':\n ans += nums[i]\n return ans\n\nS = input()\nans = 0\nN = len(S)\nsi, i = 0, 0\nwhile i < N:\n if S[i] == 'A':\n i += 1\n elif S[i:i+2] == 'BC':\n i += 2\n else:\n ans += sol(S[si:i+1])\n si = i + 1\n i += 1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [266, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u218757284", "n_user": "u218757284", "pos": "s = input()\npos = 0\nstr_len = len(s)\ncount = 0\nseq_a = 0\nseq_bc = 0\n\nwhile pos < str_len:\n if s[pos] == \"A\":\n while pos < str_len and s[pos] == \"A\":\n seq_a += 1\n pos += 1\n if pos + 1 < str_len and s[pos] == \"B\" and s[pos+1] == \"C\":\n while pos < str_len and s[pos] == \"B\" and pos + 1 < str_len and s[pos+1] == \"C\":\n seq_bc += 1\n pos += 2\n count += seq_a * seq_bc\n if pos < str_len and s[pos] != \"A\":\n seq_a = 0\n seq_bc = 0\n else:\n pos += 1\n seq_a = 0\n else:\n pos += 1\n seq_a = 0\n\nprint(count)", "neg": "s = input()\npos = 0\nstr_len = len(s)\ncount = 0\nseq_a = 0\nseq_bc = 0\n\nwhile pos < str_len:\n if s[pos] == \"A\":\n while pos < str_len and s[pos] == \"A\":\n seq_a += 1\n pos += 1\n if pos+1 < str_len and s[pos] == \"B\" and s[pos + 1] == \"C\":\n while pos < str_len and s[pos] == \"B\" and pos + 1 < str_len and s[pos + 1] == \"C\":\n seq_bc += 1\n pos += 1\n count += seq_a * seq_bc\n if pos < str_len and s[pos] != \"A\":\n seq_a = 0\n seq_bc = 0\n else:\n pos += 1\n seq_a = 0\n else:\n pos += 1\n seq_a = 0\n\nprint(count)\n", "jacc_sim": 0.9666666666666667, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [240, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u366959492", "n_user": "u366959492", "pos": "s=list(input())\nl=[]\nf=0\nfor i in range(len(s)-1):\n if s[i]==\"A\":\n l.append(\"A\")\n f=0\n elif s[i]==\"B\":\n if s[i+1]==\"C\":\n l.append(\"D\")\n f=1\n else:\n l.append(\"B\")\n f=0\n else:\n if f:\n f=0\n continue\n else:\n l.append(\"C\")\nac=0\nans=0\nfor i in range(len(l)):\n if l[i]==\"A\":\n ac+=1\n elif l[i]==\"D\":\n ans+=ac\n else:\n ac=0\nprint(ans)\n", "neg": "s=list(input())\nl=[]\nf=0\nfor i in range(len(s)-1):\n if s[i]==\"A\":\n l.append(\"A\")\n f=0\n elif s[i]==\"B\":\n if s[i+1]==\"C\":\n l.append(\"D\")\n f=1\n else:\n l.append(\"B\")\n f=0\n else:\n if f:\n f=0\n continue\n else:\n l.append(\"C\")\nac=0\nans=0\nprint(\"\".join(l))\nfor i in range(len(l)):\n if l[i]==\"A\":\n ac+=1\n elif l[i]==\"D\":\n ans+=ac\n else:\n ac=0\nprint(ans)\n", "jacc_sim": 0.9714285714285714, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [196, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u970899068", "n_user": "u970899068", "pos": "s=list(input())\ncount=0\ncount1=0\nfor i in range(len(s)-2):\n if s[i:i+3]==['A','B','C']:\n count+=1\n s[i]='B'\n s[i+1]='C'\n s[i+2]='A'\n\n \n for j in range(1,len(s)):\n if i-j<0:\n count+=count1\n break\n if s[i-j]=='A':\n count1+=1\n else:\n count+=count1\n break\n \n if s[i:i+3]==['A','A','A'] or s[i:i+3]==['A','A','B'] or s[i:i+3]==['C','A','A'] or s[i:i+3]==['C','A','B'] or s[i:i+3]==['B','C','A']:\n continue\n else:\n count1=0\n\n\nprint(count)\n\n\n \n \n \n\n \n \n", "neg": "s=list(input())\ncount=0\nfor i in range(len(s)-3):\n if s[i:i+3]==['A','B','C']:\n count+=1\n s[i]='B'\n s[i+1]='C'\n s[i+2]='A'\n for j in range(1,len(s)):\n if i-j<0:\n break\n if s[i-j]=='A':\n count+=1\n s[i-j]='B'\n s[i-j+1]='C'\n s[i-j+1]='A'\n \n \n else:\n break\n \nprint(count)\n\n\n \n \n \n\n \n \n", "jacc_sim": 0.9142857142857143, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [277, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u626337957", "n_user": "u626337957", "pos": "S = input()\nidx = 0\na_cnt = 0\ncnt = 0\nlen_s = len(S)\nwhile idx < len_s:\n if S[idx:idx+3] == 'ABC':\n cnt += 1 + a_cnt\n idx += 3\n a_cnt += 1\n bc_cnt = 0\n while idx < len(S):\n if S[idx:idx+2] == 'BC':\n cnt += a_cnt\n idx += 2\n else:\n break\n else:\n if S[idx] == 'A':\n a_cnt += 1\n else:\n a_cnt = 0\n idx += 1\nprint(cnt)", "neg": "S = input()\nidx = 0\na_cnt = 0\ncnt = 0\nlen_s = len(S)\nwhile idx < len_s:\n if S[idx:idx+3] == 'ABC':\n cnt += 1 + a_cnt\n idx += 3\n a_cnt = 0\n bc_cnt = 0\n while idx < len(S):\n if S[idx:idx+2] == 'BC':\n bc_cnt += 1\n idx += 2\n else:\n break\n cnt += bc_cnt\n else:\n if S[idx] == 'A':\n a_cnt += 1\n idx += 1\nprint(cnt)", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [164, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u131406102", "n_user": "u131406102", "pos": "s = input()\ns = s.split('BC')\ncount = [0]\ncount_all = 0\nIcount = 0\n\nfor i in range(0,len(s)-1):\n Icount = 0\n j = 1\n while(j<=len(s[i]) and s[i][-j]=='A'):\n Icount = Icount + 1\n j = j + 1\n \n if (s[i]=='' or s[i]=='A'*len(s[i])):\n Icount = Icount + count[-1]\n \n count.append(Icount)\n \n \ncount_all = sum(count) \nprint(count_all)", "neg": "s = input()\ns = s.split('BC')\ncount = [0]\ncount_all = 0\nIcount = 0\n\nfor i in range(0,len(s)-1):\n Icount = 0\n j = 1\n while(j<=len(s[i]) and s[i][-j]=='A'):\n Icount = Icount + 1\n j = j + 1\n \n if (s[i]=='' or s[i]=='A'*len(s[i])):\n Icount = Icount + count[-1]\n \n count.append(Icount)\n \n \ncount_all = sum(count) \nprint(count)\nprint(count_all)", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [167, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u027002244", "n_user": "u027002244", "pos": "s=list(input())\n\ni=0\nj=0\nans=0\nz=[]\nwhile i!=len(s)-1:\n try:\n if s[i]==\"B\" and s[i+1]==\"C\":\n z.append(1)\n i=i+2\n\n else:\n if s[i]==\"A\":\n z.append(2)\n i=i+1\n\n else:\n z.append(0)\n i=i+1\n\n except:\n break\n\nans=0\ni=0\nr1=0\n\n\n#print(z)\n#\uff5a\uff1d\u5224\u5b9a\u6570\u5217\n\nwhile i!=len(z):\n if z[i]==2:#\"A\"\n r1=r1+1\n\n elif z[i]==1:#\"BC\"\n ans=ans+r1\n\n else:#\"gomi\"\n r1 = 0\n\n\n i=i+1\nprint(ans)\n", "neg": "s=list(input())\n\ni=0\nj=0\nans=0\nz=[]\nwhile i!=len(s)-2:\n try:\n if s[i]==\"B\" and s[i+1]==\"C\":\n z.append(1)\n i=i+2\n\n else:\n if s[i]==\"A\":\n z.append(2)\n i=i+1\n\n else:\n z.append(0)\n i=i+1\n\n except:\n break\n\nans=0\ni=0\nr1=0\n\n\n#print(z)\n#\uff5a\uff1d\u5224\u5b9a\u6570\u5217\n\nwhile i!=len(z):\n if z[i]==2:#\"A\"\n r1=r1+1\n\n elif z[i]==1:#\"BC\"\n ans=ans+r1\n\n else:#\"gomi\"\n r1 = 0\n\n\n i=i+1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [258, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u969190727", "n_user": "u969190727", "pos": "def f(ss):\n n=len(ss)\n ct,res=0,0\n for i in range(n):\n if ss[i]==\"x\":\n ct+=1\n else:\n res+=ct\n return res\ns=input()\ns=s.replace(\"BC\",\"y\")\ns=s.replace(\"A\",\"x\")\ns+=\"z\"\nans=0\nchk=\"\"\nfor i in range(len(s)):\n if s[i]==\"x\" or s[i]==\"y\":\n chk+=s[i]\n else:\n ans+=f(chk)\n chk=\"\"\nprint(ans)\n", "neg": "def f(ss):\n n=len(ss)\n ct,res=0,0\n for i in range(n):\n if ss[i]==\"x\":\n ct+=1\n else:\n res+=ct\n return res\ns=input()\ns=s.replace(\"BC\",\"y\")\ns=s.replace(\"A\",\"x\")\nans=0\nchk=\"\"\nfor i in range(len(s)):\n if s[i]==\"x\" or s[i]==\"y\":\n chk+=s[i]\n else:\n ans+=f(chk)\n chk=\"\"\nprint(ans)\n", "jacc_sim": 0.9736842105263158, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [164, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u102126195", "n_user": "u888387803", "pos": "s = list(input())\n\ncnt = 0\ncnA = 0\ni = 0\nwhile i < len(s) - 1:\n #print(i, cnA)\n if s[i:i + 2] == [\"B\", \"C\"]:\n cnt += cnA\n i += 1\n elif s[i] == \"A\":\n cnA += 1\n else:\n cnA = 0\n i += 1\n\nprint(cnt)\n", "neg": "s = list(input())\n\ncnt = 0\n# print(s, cnt)\n\ni = 0\nwhile i < len(s)-2:\n # print(i)\n if s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C':\n s[i] = 'B'\n s[i+1] = 'C'\n s[i+2] = 'A'\n cnt = cnt + 1\n i = i - 1\n if i < 0:\n i = 0\n print(i, s, cnt)\n else:\n i = i + 1\n\nprint(cnt)", "jacc_sim": 0.9032258064516129, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [110, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u859897687", "n_user": "u859897687", "pos": "s=input()\nans=0\na=[0 for i in range(len(s))]\nbc=[0 for i in range(len(s))]\nif len(s)<3:\n print(0)\nelse:\n for i in range(len(s)-2):\n if s[i]==\"A\":\n a[i]+=1\n if s[i+1]==\"B\" and s[i+2]==\"C\":\n a[i+2]+=a[i]\n if s[i+1]==\"A\":\n a[i+1]+=a[i]\n \n for i in range(len(s)-1):\n if s[i]==\"B\" and s[i+1]==\"C\":\n bc[i]=1\n #for i in range(len(s)-1):\n # if a[i+1]>0:\n # a[i+1]+=a[i]\n # a[i]=0\n #for i in range(len(s)-2):\n # if a[i]>0 and bc[i+1]>0:\n # a[i+2]=a[i]\n #for i in range(len(s)-2,-1,-1):\n # if bc[i-2]>0:\n # bc[i-2]+=bc[i]\n # bc[i]=0\n #for i in range(len(s)-1):\n # if a[i+1]>0:\n # a[i+1]+=a[i]\n # a[i]=0\n \n for i in range(len(s)-2):\n if a[i]>0 and bc[i+1]>0:\n ans+=a[i]*bc[i+1]\n print(ans)\n ", "neg": "s=input()\nans=0\na=[0 for i in range(len(s))]\nbc=[0 for i in range(len(s))]\nif len(s)<3:\n print(0)\nelse:\n for i in range(len(s)):\n if s[i]==\"A\":\n a[i]=1\n for i in range(len(s)-1):\n if s[i]==\"B\" and s[i+1]==\"C\":\n bc[i]=1\n for i in range(len(s)-2,-1,-1):\n if bc[i-2]>0:\n bc[i-2]+=bc[i]\n bc[i]=0\n for i in range(len(s)-2):\n if a[i]>0 and bc[i+1]>0:\n a[i+2]=1\n for i in range(len(s)-1):\n if a[i+1]>0:\n a[i+1]+=a[i]\n a[i]=0\n \n for i in range(len(s)-2):\n if a[i]>0 and bc[i+1]>0:\n ans+=a[i]*bc[i+1]\n print(ans)\n ", "jacc_sim": 0.9714285714285714, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [452, 321], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u394721319", "n_user": "u394721319", "pos": "S = list(input())\nN = len(S)\n\nans = 0\nflag = 0\nABCflag = 0\n\ni = 0\nwhile i < N-2:\n\n if S[i]+S[i+1]+S[i+2] == 'ABC':\n if flag:\n ans += flag\n ans += 1\n S[i+2] = 'A'\n i += 1\n\n elif S[i] == 'A':\n flag += 1\n\n else:\n flag = 0\n\n i += 1\nprint(ans)\n", "neg": "\tS = list(input())\nN = len(S)\n\nans = 0\nflag = 0\nABCflag = 0\n\ni = 0\nwhile i < N-2:\n\n if S[i]+S[i+1]+S[i+2] == 'ABC':\n ans += 1\n if flag:\n ans += flag\n if ABCflag:\n ans += ABCflag\n ABCflag = 0\n i += 2\n ABCflag += 1\n\n elif S[i] == 'A':\n flag += 1\n\n else:\n flag = 0\n if S[i]+S[i+1] == 'BC':\n if ABCflag:\n ans += ABCflag\n ABCflag = 0\n i += 1\n else:\n ABCflag = 0\n i += 1\n\nprint(ans)\n", "jacc_sim": 0.9666666666666667, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [135, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u684695949", "n_user": "u684695949", "pos": "s = input().rstrip()\n\nconcurrent_BC_cnt = 0\nold1 = \"\"\ncnt = 0\nfor tmp in (reversed(s)):\n\tif tmp == \"A\":\n\t\tif old1 == \"B\":\n\t\t\tcnt += concurrent_BC_cnt\n\t\telse:\n\t\t\tconcurrent_BC_cnt = 0\n\t\t\told1 = \"A\"\n\t\t# if \"A\" not update old1\n\telse:\n\t\tif tmp == \"B\" and old1 == \"C\":\n\t\t\tconcurrent_BC_cnt += 1\n\t\telif tmp == \"C\" and old1 == \"B\":\n\t\t\tpass\n\t\telse:\n\t\t\tconcurrent_BC_cnt = 0\n\t\t\t\n\t\told1=tmp\n\t\nprint(cnt)", "neg": "s = input().rstrip()\n\nconcurrent_BC_cnt = 0\nold1 = \"\"\ncnt = 0\nfor tmp in (reversed(s)):\n\tif tmp == \"A\"\n\t\tif old1 == \"B\":\n\t\t\tcnt += concurrent_BC_cnt\n\t\telse:\n\t\t\tconcurrent_BC_cnt = 0\n\t\t\told1 = \"A\"\n\t\t# if \"A\" not update old1\n\telse:\n\t\tif tmp == \"B\" and old1 == \"C\":\n\t\t\tconcurrent_BC_cnt += 1\n\t\telif tmp == \"C\" and old1 == \"B\":\n\t\t\tpass\n\t\telse:\n\t\t\tconcurrent_BC_cnt = 0\n\t\t\t\n\t\told1=tmp\n\t\nprint(cnt)", "jacc_sim": 1.0, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [186, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u907223098", "n_user": "u907223098", "pos": "s=input()\na=0\nr=0\nfor i in range(len(s)-1):\n if s[i]==\"A\":\n a=a+1\n if s[i+1]==\"C\":\n a=0\n elif s[i]==\"B\":\n if s[i+1]==\"C\":\n r=r+a\n else:\n a=0\n elif s[i]==\"C\":\n if s[i+1]==\"C\":\n a=0\nprint(int(r))", "neg": "s=input()\na=0\nr=0\nfor i in range(len(s)):\n if s[i]==\"A\":\n a=a+1\n if s[i+1]==\"C\":\n a=0\n elif s[i]==\"B\":\n if s[i+1]==\"C\":\n r=r+a\n else:\n a=0\nprint(r)", "jacc_sim": 0.9285714285714286, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [130, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03018", "p_user": "u704252625", "n_user": "u704252625", "pos": "S = input()\n\nWALL = 0\nACTIVATE = 1\nCHANCE, BINGO = 2, 3\n\nnBC = 0\nscore = 0\nstate = WALL\nfor c in reversed(S):\n\tif c == 'A' and (state == BINGO or state == ACTIVATE):\n\t\tstate = ACTIVATE\n\telif c == 'B' and state == CHANCE:\n\t\tstate = BINGO\n\telif c == 'C':\n\t\tif state == CHANCE:\n\t\t\tnBC = 0\n\t\tstate = CHANCE\n\telse:\n\t\tstate = WALL\n\t\n\tif state == WALL:\n\t\tnBC = 0\n\telif state == ACTIVATE:\n\t\tscore += nBC\n\telif state == BINGO:\n\t\tnBC += 1\n\nprint(score)\n", "neg": "S = input()\n\nWALL = 0\nACTIVATE = 1\nCHANCE, BINGO = 2, 3\n\nnBC = 0\nscore = 0\nstate = WALL\nfor c in reversed(S):\n\tif c == 'A' and state == BINGO:\n\t\tstate = ACTIVATE\n\telif c == 'B' and state == CHANCE:\n\t\tstate = BINGO\n\telif c == 'C':\n\t\tif state == CHANCE:\n\t\t\tnBC = 0\n\t\tstate = CHANCE\n\telse:\n\t\tstate = WALL\n\t\n\tif state == WALL:\n\t\tnBC = 0\n\telif state == ACTIVATE:\n\t\tscore += nBC\n\telif state == BINGO:\n\t\tnBC += 1\n\nprint(score)\n", "jacc_sim": 0.9705882352941176, "nl": "You are given a string consisting of 'A', 'B', and 'C'. Perform the following operation as many times as possible: Choose a contiguous substring that reads 'ABC' and replace it with 'BCA'. Find the maximum possible number of operations. Constraints: 1 \u2264 |s| \u2264 200000, where |s| is the length of the string. Each character of the string is 'A', 'B', or 'C'. Input is given as the string 's'. Output the maximum possible number of operations. Example: Input: ABCABC, Output: 3 (e.g., ABCABC \u2192 BCAABC \u2192 BCABCA \u2192 BCBCAA).", "before_after_length": [203, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03019", "p_user": "u403301154", "n_user": "u403301154", "pos": "n, x = list(map(int, input().split()))\nB = 0\nblu = []\ns = [0 for i in range(n)]\n\nfor i in range(n):\n b, l, u = list(map(int, input().split()))\n blu.append((b, l, u, x*u-b*u+b*l))\n B += b*l\nblu.sort(key=lambda x: x[3], reverse=True)\n\nfor i in range(n):\n if i==0:\n s[i] = blu[i][3]\n else:\n s[i] = s[i-1] + blu[i][3]\n\nok = n*x\nng = -1\nwhile ok-ng>1:\n A = 0\n mid = (ok+ng)//2\n k = mid//x\n t = mid%x\n for i in range(n):\n if t<=blu[i][0]:\n rm = t*blu[i][1]\n else:\n rm = t*blu[i][2] - blu[i][0]*(blu[i][2]-blu[i][1])\n if k==0:\n A = max(A, rm)\n elif i=B:\n ok = mid\n else:\n ng = mid\n\nprint(ok)", "neg": "n, x = list(map(int, input().split()))\nB = 0\nblu = []\ns = [0 for i in range(n)]\n\nfor i in range(n):\n b, l, u = list(map(int, input().split()))\n blu.append((b, l, u, x*u-b*u+b*l))\n B += b*l\nblu.sort(key=lambda x: x[3], reverse=True)\n\nfor i in range(n):\n if i==0:\n s[i] = blu[i][3]\n else:\n s[i] = s[i-1] + blu[i][3]\n\nans = n*x\nfor i in range(n):\n ok = n*x\n ng = -1\n while ok-ng>1:\n A = 0\n mid = (ok+ng)//2\n k = mid//x\n t = mid%x\n if t==0:\n A += s[k-1]\n else:\n if i=B:\n ok = mid\n else:\n ng = mid\n ans = min(ans, ok)\n\nprint(ans)", "jacc_sim": 0.9122807017543859, "nl": "Takahashi and Aoki will take N exams numbered 1 to N and compete. Takahashi decides the importance c_i for each exam i, within the range l_i to u_i. The winner is determined by comparing the total scores A and B, where A is Takahashi's score and B is Aoki's score. Takahashi knows Aoki's scores b_i and can increase his own score by 1 for each hour of study, up to a maximum score of X. Find the minimum study hours for Takahashi to win. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 X \u2264 10^5, 0 \u2264 b_i \u2264 X, 1 \u2264 l_i \u2264 u_i \u2264 10^5. Input format: N X, followed by N lines of b_i, l_i, and u_i. Output the minimum study hours. Example input and output are provided.", "before_after_length": [390, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u057964173", "n_user": "u782009499", "pos": "def resolve():\n n=int(input())\n print((n-2)*180)\nresolve()", "neg": "def resolve():\n n = int(input())\n ans = (n-2)*180\n print(ans)", "jacc_sim": 0.9333333333333333, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [24, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u859897687", "n_user": "u561358604", "pos": "n=int(input())\nprint(n*180-360)", "neg": "n = int(input())\n\nprint(\n\tn * (180 - 360 // n)\n)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [15, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u082337294", "n_user": "u194689114", "pos": "N=int(input())\n\nn=(N-2)*180\n\nprint(n)", "neg": "N = int(input())\nprint(180*(n-2)/n)\n", "jacc_sim": 0.9230769230769231, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [21, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u605748139", "n_user": "u607741489", "pos": "N = int(input())\nx = 180*(N-2)\nprint(x)", "neg": "x = int(input)\nprint((x-2)*180)", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [20, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u902151549", "n_user": "u902151549", "pos": "# coding: utf-8\nimport os\nimport time\nimport re\nimport math\n \nN=int(input())\nprint(180*(N-2))", "neg": "# coding: utf-8\nimport os\nimport time\nimport re\nimport math\n\nN=int(input())\nprint(180*(N-2)", "jacc_sim": 1.0, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [36, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u495903598", "n_user": "u495903598", "pos": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[ ]:\n\n\nimport sys\n#input = sys.stdin.readline\n#A, B = map(int, input().split())\nprint(180*(int(input())-2))\n\n", "neg": "#!/usr/bin/env python\n# coding: utf-8\n\n# In[ ]:\n\n\nimport sys\n#input = sys.stdin.readline\n#A, B = map(int, input().split())\n180*(int(input())-2)\n\n", "jacc_sim": 0.9705882352941176, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [66, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u288087195", "n_user": "u333190709", "pos": "N = int(input())\n\nprint(N*180-360)", "neg": "N = int(input())\n\nprint((180 - 360/N) * N)", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [16, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u937132382", "n_user": "u521973174", "pos": "n=int(input())\n\nx=180*(n-2)\n\nprint(x)", "neg": "n = input()\nx = (n-2)*180\nprint(x)", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [22, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u691018832", "n_user": "u691018832", "pos": "# sys.stdin.readline()\nimport sys\ninput = sys.stdin.readline\n\nn = int(input())\nprint(180+(n-3)*180)\n", "neg": "# sys.stdin.readline()\nimport sys\ninput = sys.stdin.readline\n\nn = int(input())\nprint(360+(n-3)*180)", "jacc_sim": 0.9473684210526315, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [41, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u199236015", "n_user": "u320681122", "pos": "n = int(input())\ns = 180 * (n-2)\nprint(s)\n", "neg": "int(input())\ns = 180 * (n - 2)\n\nprint(s)\nprint(type(n))\n", "jacc_sim": 0.9230769230769231, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [22, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u065188401", "n_user": "u320681122", "pos": "s=int(input())\nprint(180*(s-2))\n\n", "neg": "int(input())\ns = 180 * (n - 2)\n\nprint(s)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [17, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u633255271", "n_user": "u299869545", "pos": "print(180*(int(input()) - 2))", "neg": "print(int(input()-2)*180)", "jacc_sim": 1.0, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [11, 11], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u562033060", "n_user": "u817080214", "pos": "i = int(input())\nprint((i-2)*180)", "neg": "i = int(input())\ndegree = 180 * (i - 2)\nprint(degree", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [15, 20], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u918935103", "n_user": "u595899761", "pos": "n = int(input())\np = 180*(n-2)\nprint(p)", "neg": "n = int(input())\n\nprint((180*n)-2)", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [20, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u722189950", "n_user": "u502389123", "pos": "N = int(input())\n\n\n\nprint((N-3)*180 + 180)", "neg": "N = int(input())\n\nprint((N - 3) * 90 + 180)", "jacc_sim": 0.9230769230769231, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [20, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u723180465", "n_user": "u883203948", "pos": "n = int(input())\nprint(180 + 180 * (n - 3))", "neg": "n = int(input())\nprint((n-3) * 180)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [18, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u676407796", "n_user": "u342118825", "pos": "n = int(input())\n\nans = (n-2)*180\n\nprint(ans)", "neg": "n = input()\nans = (n-2)*180\nprint(ans)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [22, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u708255304", "n_user": "u194689114", "pos": "N = int(input())\n\nprint(int((N-2)*180))\n", "neg": "N = int(input())\nprint(180*(N-2)/N)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [19, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u585482323", "n_user": "u585482323", "pos": "#!usr/bin/env python3\nfrom collections import defaultdict\nfrom collections import deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS():return list(map(list, sys.stdin.readline().split()))\ndef S(): return list(sys.stdin.readline())[:-1]\ndef IR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = I()\n return l\ndef LIR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = LI()\n return l\ndef SR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = S()\n return l\ndef LSR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = SR()\n return l\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\n#A\ndef A():\n n = I()\n print(180*(n-2))\n return\n\n#B\ndef B():\n n = I()\n\n return\n\n#C\ndef C():\n n = I()\n return\n\n#D\ndef D():\n n = I()\n return\n\n#E\ndef E():\n n = I()\n return\n\n#F\ndef F():\n n = I()\n return\n\n#Solve\nif __name__ == \"__main__\":\n A()\n", "neg": "#!usr/bin/env python3\nfrom collections import defaultdict\nfrom collections import deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS():return list(map(list, sys.stdin.readline().split()))\ndef S(): return list(sys.stdin.readline())[:-1]\ndef IR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = I()\n return l\ndef LIR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = LI()\n return l\ndef SR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = S()\n return l\ndef LSR(n):\n l = [None for i in range(n)]\n for i in range(n):l[i] = SR()\n return l\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\n#A\ndef A():\n n = I()\n print(180*(n-1))\n return\n\n#B\ndef B():\n n = I()\n\n return\n\n#C\ndef C():\n n = I()\n return\n\n#D\ndef D():\n n = I()\n return\n\n#E\ndef E():\n n = I()\n return\n\n#F\ndef F():\n n = I()\n return\n\n#Solve\nif __name__ == \"__main__\":\n A()\n", "jacc_sim": 0.9859154929577465, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [424, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03023", "p_user": "u077337864", "n_user": "u077075933", "pos": "n = int(input())\nprint(180 * (n-2))\n", "neg": "A = int(input())\nprint(180*(n-2))", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer N (where N is not less than 3). Find the sum of the interior angles of a regular polygon with N sides. Print the answer in degrees without units. The input is given as N, and the output should be an integer representing the sum of the interior angles of the polygon. The constraints are 3 \u2264 N \u2264 100.", "before_after_length": [17, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u187516587", "n_user": "u187516587", "pos": "import sys\ndef input():\n return sys.stdin.readline()[:-1]\nN,A,B,C=map(int,input().split())\npr=10**9+7\ndef gya(n):\n return pow(n,pr-2,pr)\nMAX_NUM = 2*10**5 + 1\nfac = [0 for _ in range(MAX_NUM)]\nfinv = [0 for _ in range(MAX_NUM)]\ninv = [0 for _ in range(MAX_NUM)]\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\ninv[1] = 1\nfor i in range(2,MAX_NUM):\n fac[i] = fac[i-1] * i % pr\n inv[i] = pr - inv[pr%i] * (pr // i) % pr\n finv[i] = finv[i-1] * inv[i] % pr\ndef c(n,k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n-k] % pr) % pr\na=0\nab=A+B\nap=pow(A,N,pr)\nbp=pow(B,N,pr)\nabp=1\nbap=1\nfor i in range(N):\n a+=(i+N)*c(N+i-1,N-1)%pr*pow(ab,N-1-i,pr)%pr*(ap*abp+bp*bap)%pr\n abp=abp*B%pr\n bap=bap*A%pr\n a%=pr\na=a*100*gya(pow(ab,2*N,pr))%pr\nprint(a)", "neg": "import sys\ndef input():\n return sys.stdin.readline()[:-1]\nN,A,B,C=map(int,input().split())\npr=10**9+7\ndef gya(n):\n return pow(n,pr-2,pr)\nMAX_NUM = 2*10**5 + 1\nfac = [0 for _ in range(MAX_NUM)]\nfinv = [0 for _ in range(MAX_NUM)]\ninv = [0 for _ in range(MAX_NUM)]\nfac[0] = fac[1] = 1\nfinv[0] = finv[1] = 1\ninv[1] = 1\nfor i in range(2,MAX_NUM):\n fac[i] = fac[i-1] * i % pr\n inv[i] = pr - inv[pr%i] * (pr // i) % pr\n finv[i] = finv[i-1] * inv[i] % pr\ndef c(n,k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n-k] % pr) % pr\na=0\nab=A+B\nap=pow(A,N,pr)\nbp=pow(B,N,pr)\nabp=1\nbap=1\nfor i in range(N):\n a+=(i+N)*c(N+i-1,N-1)%pr*pow(ab,N-1-i)%pr*(ap*abp+bp*bap)%pr\n abp=abp*B%pr\n bap=bap*A%pr\n a%=pr\na=a*100*gya(pow(ab,2*N,pr))%pr\nprint(a)", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [447, 445], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n mod = 10**9+7\n fact = [1]*200001\n for i in range(1, 200001):\n fact[i] = fact[i-1]*i % mod\n\n def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)\n def nCr(n, r, mod=10**9 +\n 7): return inv_n(fact[n-r]*fact[r] % mod, mod)*fact[n] % mod\n\n n, a, b, c = map(int, input().split())\n ans = 0\n for i in range(n, 2*n):\n j = i*100*inv_n(a+b) % mod\n ans = (ans + j*nCr(i-1, n-1)*(pow(a, n, mod)*pow(b, i-n, mod) +\n pow(a, i-n, mod)*pow(b, n, mod))*inv_n(pow(a+b, i, mod))) % mod\n print(ans)\n\n\nmain()\n", "neg": " mod = 10**9+7\n fact = [1]*200001\n for i in range(1, 200001):\n fact[i] = fact[i-1]*i % mod\n\n def inv_n(n, mod=10**9+7): return pow(n, mod-2, mod)\n def nCr(n, r, mod=10**9 +\n 7): return inv_n(fact[n-r]*fact[r] % mod, mod)*fact[n] % mod\n\n n, a, b, c = map(int, input().split())\n ans = 0\n for i in range(n, 2*n):\n j = i*100*inv_n(a+b) % mod\n ans = (ans + j*nCr(i-1, n-1)*(pow(a, n, mod)*pow(b, i-n, mod) +\n pow(a, i-n, mod)*pow(b, n, mod))*inv_n(pow(a+b, i, mod))) % mod\n print(ans)\n\n\nmain()\n", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [271, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,a,b,c=map(int,input().split())\nM=10**9+7\nm=2*n\nfact=[1]*(m+1)\nifact=[1]*(m+1)\nr=1\nfor i in range(1,m+1):fact[i]=r=r*i%M\nifact[m]=r=pow(fact[m],M-2,M)\nfor i in range(m,0,-1):ifact[i-1]=r=r*i%M\nr=pow(a+b,M-2,M) \np=0\nd=b*r%M\ne=1\nfor k in range(n):\n v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M\n e=e*d%M\n p+=v\np*=pow(a*r%M,n,M)*100*r%M\nq=0\nd=a*r%M\ne=1\nfor k in range(n):\n v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M\n e=e*d%M\n q+=v\nq*=pow(b*r%M,n,M)*100*r%M\nprint((p+q)%M)", "neg": "n,a,b,c=map(int,input().split())\nM=10**9+7\nm=2*n\nfact=[1]*(M+1)\nifact=[1]*(M+1)\nr=1\nfor i in range(1,m+1):fact[i]=r=r*i%M\nifact[m]=r=pow(fact[m],M-2,M)\nfor i in range(m,0,-1):ifact[i-1]=r=r*i%M\nr=pow(a+b,M-2,M) \np=0\nd=b*r%M\ne=1\nfor k in range(n):\n v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M\n e=e*d%M\n p+=v\np*=pow(a*r%M,n,M)*100*r%M\nq=0\nd=a*r%M\ne=1\nfor k in range(n):\n v=fact[n+k-1]*ifact[n-1]*ifact[k]%M*e*(n+k)%M\n e=e*d%M\n q+=v\nq*=pow(b*r%M,n,M)*100*r%M\nprint((p+q)%M)", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [337, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u969190727", "n_user": "u969190727", "pos": "import sys\ninput = sys.stdin.readline\nmod=10**9+7\nn_max=2*10**5\nF,FI=[0]*(n_max+1),[0]*(n_max+1)\nF[0],FI[0]=1,1\nfor i in range(n_max):\n F[i+1]=(F[i]*(i+1))%mod\n FI[i+1]=pow(F[i+1],mod-2,mod)\ndef comb(x,y):\n return (F[x]*FI[x-y]*FI[y])%mod\nn,a,b,c=map(int,input().split())\nans=0\naa,bb=a*pow(a+b,mod-2,mod),b*pow(a+b,mod-2,mod)\nan,bn=pow(aa,n,mod),pow(bb,n,mod)\nfor i in range(n):\n ans+=(n+i)*(an*pow(bb,i,mod)+pow(aa,i,mod)*bn)*comb(n+i-1,i)\n ans%=mod\nprint((ans*100*pow(100-c,mod-2,mod))%mod)", "neg": "import sys\ninput = sys.stdin.readline\nmod=10**9+7\nn_max=2*10**5\nF,FI=[0]*(n_max+1),[0]*(n_max+1)\nF[0],FI[0]=1,1\nfor i in range(n_max):\n F[i+1]=(F[i]*(i+1))%mod\n FI[i+1]=pow(F[i+1],mod-2,mod)\ndef comb(x,y):\n return (F[x]*FI[x-y]*FI[y])%mod\nn,a,b,c=map(int,input().split())\nans=0\naa,bb=a*pow(100,mod-2,mod),b*pow(100,mod-2,mod)\nan,bn=pow(aa,n,mod),pow(bb,n,mod)\nfor i in range(n):\n ans+=(n+i)*(an*pow(bb,i,mod)+pow(aa,i,mod)*bn)*comb(n+i-1,i)\n ans%=mod\nprint((ans*100*pow(100-c,mod-2,mod))%mod)", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [298, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u394033362", "n_user": "u394033362", "pos": "import math\n\nN, A, B, C = map(int,input().split())\nmod = 10**9+7\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\ng1 = [1, 1]\ng2 = [1, 1]\ninv = [0, 1] \nfor i in range(2, 2*10**5+1):\n g1.append((g1[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inv[-1]) % mod)\n\ndef g(a):\n b, u, v = mod, 1,0\n while b:\n t = a//b\n a -= t * b\n u -= t * v\n a,b,u,v = b,a,v,u\n u %= mod\n return u if u > 0 else u + mod\n\np1,p2 = A * g(A + B) % mod, B * g(A + B) % mod\np3 = (100 - C) * g(100) % mod\n\nans = 0\nfor i in range(N):\n ans += (N+i)*cmb(N+i-1,i,mod)% mod*(pow(p1,N,mod) * pow(p2,i,mod) % mod + pow(p1,i,mod) * pow(p2,N,mod) % mod)% mod\n ans %= mod\nans = ans * g(p3) % mod\nprint(ans)", "neg": "import math\n\nN, A, B, C = map(int,input().split())\nmod = 10**9+7\n\ndef cmb(n, r, mod):\n if (r < 0 or r > n):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\ng1 = [1, 1]\ng2 = [1, 1]\ninv = [0, 1] \nfor i in range(2, 2*10**5+1):\n g1.append((g1[-1] * i) % mod)\n inv.append((-inv[mod % i] * (mod//i)) % mod)\n g2.append((g2[-1] * inv[-1]) % mod)\n\ndef g(a):\n b, u, v = mod, 1,0\n while b:\n t = a//b\n a -= t * b\n u -= t * v\n a,b,u,v = b,a,v,u\n u %= mod\n return u if u > 0 else u + mod\n\np1,p2 = A * g(A + B) % mod, B * g(A + B) % mod\np3 = (100 - C) * g(100) % mod\n\nans = 0\nfor i in range(N):\n ans += (N+i)*cmb(N+i-1,i,mod)% mod*(pow(p1,N,mod) * pow(p2,i,mod) % mod + pow(p2,i,mod) * pow(p2,N,mod) % mod)% mod\n ans %= mod\nans = ans * g(p3) % mod\nprint(ans)", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [427, 427], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u268793453", "n_user": "u268793453", "pos": "n, a, b, c = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\nans = 0\n\ndef fact(n, p=10**9 + 7):\n f = [1]\n for i in range(1, n+1):\n f.append(f[-1]*i%p)\n return f\n\ndef invfact(n, f, p=10**9 + 7):\n inv = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n inv.append(inv[-1]*i%p)\n return inv[::-1]\n\nf = fact(2 * n)\ninvf = invfact(2 * n, f)\n\ndef comb(a, b):\n if a < b:\n return 0\n if a < 0 or b < 0:\n return 0\n return f[a] * invf[b] * invf[a-b] % p\n\npow_a = [1]\npow_b = [1]\ninv_100 = pow(100, p - 2, p)\na = a * inv_100 % p\nb = b * inv_100 % p\nc = c * inv_100 % p\n\ninv_ab = pow(a + b, p - 2, p)\na = a * inv_ab % p\nb = b * inv_ab % p\n\nfor i in range(n):\n pow_a.append(pow_a[-1] * a % p)\n pow_b.append(pow_b[-1] * b % p)\n\nfor m in range(n, 2 * n):\n ans += comb(m - 1, n - 1) * (pow_a[n] * pow_b[m - n] + pow_a[m - n] * pow_b[n]) * m\n ans %= p\n\nans *= pow(1 - c, p - 2, p)\n\nprint(ans % p)", "neg": "n, a, b, c = [int(i) for i in input().split()]\np = 10 ** 9 + 7\n\nans = 0\n\ndef fact(n, p=10**9 + 7):\n f = [1]\n for i in range(1, n+1):\n f.append(f[-1]*i%p)\n return f\n\ndef invfact(n, f, p=10**9 + 7):\n inv = [pow(f[n], p-2, p)]\n for i in range(n, 0, -1):\n inv.append(inv[-1]*i%p)\n return inv[::-1]\n\nf = fact(2 * n)\ninvf = invfact(2 * n, f)\n\ndef comb(a, b):\n if a < b:\n return 0\n if a < 0 or b < 0:\n return 0\n return f[a] * invf[b] * invf[a-b] % p\n\npow_a = [1]\npow_b = [1]\ninv_100 = pow(100, p - 2, p)\na = a * inv_100 % p\nb = b * inv_100 % p\nc = c * inv_100 % p\n\nfor i in range(n):\n pow_a.append(pow_a[-1] * a % p)\n pow_b.append(pow_b[-1] * b % p)\n\nfor m in range(n, 2 * n):\n ans += comb(m - 1, n - 1) * (pow_a[n] * pow_b[m - n] + pow_a[m - n] * pow_b[n]) * m\n ans %= p\n\nans *= pow(1 - c, p - 2, p)\n\nprint(ans % p)", "jacc_sim": 0.9803921568627451, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [478, 440], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u685263709", "n_user": "u685263709", "pos": "N, A, B, C = map(int, input().split())\n\nmod = 10 ** 9 + 7\ntable = [1] * (2 * N + 1)\nfor i in range(2*N):\n table[i+1] = table[i] * (i+1) % mod\n\n\ndef invmod(a, mod=mod):\n # mod \u304c\u7d20\u6570\u306e\u6642\u306b\u6210\u7acb\u3059\u308b\n return pow(a, mod - 2, mod)\n\n\ndef cmb(n, r):\n return (table[n] * invmod(table[r]) * invmod(table[n - r])) % mod\n\n\ndef solve(a, b):\n res = 0\n for i in range(N):\n res += ((i + N) * cmbs[i] * pow(b, i, mod)) % mod\n res %= mod\n return (pow(a, N, mod) * res) % mod\n\n\na = A * invmod(A + B, mod)\nb = B * invmod(A + B, mod)\nc = C * invmod(100, mod)\ncmbs = [cmb(i + N - 1, i) for i in range(N)]\n\nEa = solve(a, b)\nEb = solve(b, a)\nans = ((Ea + Eb) * invmod(1 - c, mod)) % mod\nprint(ans)", "neg": "N, A, B, C = map(int, input().split())\n\nmod = 10 ** 9 + 7\ntable = [1] * (2 * N + 1)\nfor i in range(2*N):\n table[i+1] = table[i] * (i+1) % mod\n\n\ndef invmod(a, mod):\n # mod \u304c\u7d20\u6570\u306e\u6642\u306b\u6210\u7acb\u3059\u308b\n return pow(a, mod - 2, mod)\n\n\ndef cmb(n, r):\n return (table[n] * invmod(table[r]) * invmod(table[n - r])) % mod\n\n\ndef solve(a, b):\n res = 0\n for i in range(N):\n res += ((i + N) * cmbs[i] * pow(b, i, mod)) % mod\n res %= mod\n return (pow(a, N, mod) * res) % mod\n\n\na = A * invmod(A + B)\nb = B * invmod(A + B)\nc = C * invmod(100)\ncmbs = [cmb(i + N - 1, i) for i in range(N)]\n\nEa = solve(a, b)\nEb = solve(b, a)\nans = ((Ea + Eb) * invmod(1 - c)) % mod\nprint(ans)", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [357, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03025", "p_user": "u067983636", "n_user": "u067983636", "pos": "N, A, B, C = map(int, input().split())\nmod = 10 ** 9 + 7\n\nW = [1] * (2 * N + 1)\nfor w in range(2 * N):\n W[w + 1] = ((w + 1) * W[w]) % mod\n\n\ndef rev(a):\n return pow(a, mod - 2, mod)\n\n\ndef comb(a, b):\n return (W[a] * rev(W[b]) * rev(W[a - b])) % mod\n\n\ndef f(a, b):\n res = 0\n for i in range(N):\n res += ((i + N) * com[i] * pow(b, i, mod)) % mod\n res %= mod\n return (pow(a, N, mod) * res) % mod\n\n\na = A * rev(A + B)\nb = B * rev(A + B)\nc = C * rev(100)\ncom = [comb(i + N - 1, i) for i in range(N)]\n\nw_a = f(a, b)\nw_b = f(b, a)\nans = ((w_a + w_b) * rev(1 - c)) % mod\nprint(ans)\n", "neg": "N, A, B, C = map(int, input().split())\nmod = 10 ** 9 + 7\n\nW = [1] * (2 * N + 1)\nfor w in range(2 * N):\n W[w + 1] = ((w + 1) * W[w]) % mod\n\n\ndef rev(a, mod):\n return pow(a, mod - 2, mod)\n\n\ndef comb(a, b):\n return (W[a] * rev(W[b], mod) * rev(W[a - b], mod)) % mod\n\n\ndef f(a, b, c):\n res = 0\n for i in range(N):\n res += ((i + N) * com[i] * pow(b, i, mod)) % mod\n res %= mod\n return (pow(a, N, mod) * res * pow(100 * rev(100 - C, mod), 2, mod)) % mod\n\n\na = A * rev(100, mod)\nb = B * rev(100, mod)\nc = C * rev(100, mod)\ncom = [comb(i + N - 1, i) for i in range(N)]\n\nw_a = f(a, b, c)\nw_b = f(b, a, c)\nans = (w_a + w_b) % mod\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Takahashi and Aoki will play a game repeatedly until one of them has N wins in total. When they play, Takahashi wins with probability A%, Aoki wins with probability B%, and the game ends in a draw with probability C%. Find the expected number of games that will be played. Represent the expected value as P/Q with coprime integers P and Q. Print the integer R between 0 and 10^9+6 (inclusive) such that R * Q \u2261 P (mod 10^9+7). Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A, B, C \u2264 100, 1 \u2264 A+B, A+B+C=100. Input is given as N A B C. Output the expected number of games to be played.", "before_after_length": [302, 325], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03027", "p_user": "u984276646", "n_user": "u984276646", "pos": "Q = int(input())\nmod = int(1e+6 + 3)\n\ndef doubling(n, m):\n y = 1\n p = n\n while m != 0:\n if m % 2 == 1:\n y *= p\n y %= mod\n m //= 2\n p *= p\n p %= mod\n return y\n\ndef inved(s):\n x, y, u, v, k, l = 1, 0, 0, 1, s, mod\n while l != 0:\n x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)\n k, l = l, k % l\n return x % mod\n\nfrac = [1 for _ in range(mod+1)]\ninvf = [1 for _ in range(mod+1)]\ninvf[mod] = 0\nfor i in range(mod):\n frac[i+1] = (frac[i] * (i+1)) % mod\ninvf[mod-1] = inved(frac[mod-1])\nfor i in range(mod-1, 0, -1):\n invf[i-1] = (invf[i] * i) % mod\n\nfor i in range(Q):\n x, d, n = map(int, input().split())\n if x == 0:\n print(0)\n else:\n if d == 0:\n print(doubling(x, n))\n else:\n if n >= mod:\n print(0)\n else:\n xinvd = x * inved(d) - 1\n xinvd %= mod\n if xinvd + n >= mod:\n print(0)\n else:\n dn = doubling(d, n)\n print((dn * frac[xinvd + n] * invf[xinvd]) % mod)\n", "neg": "Q = int(input())\nmod = int(1e+6 + 3)\n\ndef doubling(n, m):\n y = 1\n p = n\n while m != 0:\n if m % 2 == 1:\n y *= p\n y %= mod\n m //= 2\n p *= n\n p %= mod\n return y\n\ndef inved(s):\n x, y, u, v, k, l = 1, 0, 0, 1, s, mod\n while l != 0:\n x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)\n k, l = l, k % l\n return x % mod\n\nfrac = [1]\nfor i in range(mod):\n frac.append((frac[i]*(i+1))%mod)\n\nfor i in range(Q):\n x, d, n = map(int, input().split())\n if x == 0:\n print(0)\n else:\n if d == 0:\n print(doubling(x, n))\n else:\n if n >= mod:\n print(0)\n else:\n xinvd = x * inved(d) - 1\n xinvd %= mod\n if xinvd + n >= mod:\n print(0)\n else:\n dn = doubling(d, n)\n print((dn * frac[xinvd + n] * inved(frac[xinvd])) % mod)", "jacc_sim": 0.9464285714285714, "nl": "You are given an arithmetic progression with 'n' terms: x, x + d, x + 2d, ..., x + (n-1)d. Find the product of all terms in this sequence modulo 1,000,003. You have 'Q' queries. For each query, compute the product given x, d, and n. Constraints: 1 \u2264 Q \u2264 10^5, 0 \u2264 xi, di \u2264 1,000,002, 1 \u2264 ni \u2264 10^9. Input format: Q, x1 d1 n1, ..., xQ dQ nQ. Output format: Print Q lines, each containing the answer for the corresponding query. Sample Input: 2, 7 2 4, 12345 67890 2019. Sample Output: 9009, 916936.", "before_after_length": [459, 371], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03027", "p_user": "u807772568", "n_user": "u807772568", "pos": "import sys,collections as cl,bisect as bs\nsys.setrecursionlimit(100000)\nMax = sys.maxsize\ndef l():\n\treturn list(map(int,input().split()))\ndef m():\n\treturn map(int,input().split())\ndef s(x):\n\ta = []\n\taa = x[0]\n\tsu = 1\n\tfor i in range(len(x)-1):\n\t\tif aa == x[i+1]:\n\t\t\ta.append([aa,su])\n\t\t\taa = x[i+1]\n\t\t\tsu = 1\n\t\telse:\n\t\t\tsu += 1\n\ta.append([aa,su])\n\treturn a\ndef jo(x):\n\treturn \" \".join(map(str,x))\n\nq = int(input())\nmod = 10**6+3\nf = {}\nf[0] = 1\nfor i in range(1,mod):\n\tf[i] = f[i-1] * i % mod\n\nfor i in range(q):\n\tx,d,n = m()\n\tif d == 0:\n\t\tans = pow(x,n,mod)\n\telse:\n\t\tx = x * pow(d,mod-2,mod)%mod\n\t\tif mod <= x + n - 1:\n\t\t\tans = 0\n\t\telse:\n\t\t\tans = pow(d,n,mod) * f[x+n-1] * pow(f[x-1],mod-2,mod) % mod\n\tprint(ans)", "neg": "import sys,collections as cl,bisect as bs\nsys.setrecursionlimit(100000)\nMax = sys.maxsize\ndef l():\n\treturn list(map(int,input().split()))\ndef m():\n\treturn map(int,input().split())\ndef s(x):\n\ta = []\n\taa = x[0]\n\tsu = 1\n\tfor i in range(len(x)-1):\n\t\tif aa == x[i+1]:\n\t\t\ta.append([aa,su])\n\t\t\taa = x[i+1]\n\t\t\tsu = 1\n\t\telse:\n\t\t\tsu += 1\n\ta.append([aa,su])\n\treturn a\ndef jo(x):\n\treturn \" \".join(map(str,x))\n\nq = m()\nmod = 10**6+3\nf = {}\nf[0] = 1\nfor i in range(1,p):\n\tf[i] = d[i-1] * i % mod\n\nfor i in range(q):\n\tx,d,n = m()\n\tif d == 0:\n\t\tans = pow(x,n,mod)\n\telse:\n\t\tx = x * pow(d,mod-2,mod)%mod\n\t\tif mod <= x + n - 1:\n\t\t\tans = 0\n\t\telse:\n\t\t\tans = pow(d,n,mod) * f[x+n-1] * pow(f[x-1],mod-2,mod) % mod\n\tprint(ans)", "jacc_sim": 0.9850746268656716, "nl": "You are given an arithmetic progression with 'n' terms: x, x + d, x + 2d, ..., x + (n-1)d. Find the product of all terms in this sequence modulo 1,000,003. You have 'Q' queries. For each query, compute the product given x, d, and n. Constraints: 1 \u2264 Q \u2264 10^5, 0 \u2264 xi, di \u2264 1,000,002, 1 \u2264 ni \u2264 10^9. Input format: Q, x1 d1 n1, ..., xQ dQ nQ. Output format: Print Q lines, each containing the answer for the corresponding query. Sample Input: 2, 7 2 4, 12345 67890 2019. Sample Output: 9009, 916936.", "before_after_length": [368, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03027", "p_user": "u937706062", "n_user": "u652057333", "pos": "mod = 10 ** 6 + 3\n\nW = [1] * (mod)\nfor i in range(mod - 1):\n\tW[i + 1] = ((i + 1) * W[i]) % mod\n\ndef rev(a):\n\treturn pow(a, mod - 2, mod)\n\ndef f(x, d, n):\n\tif d == 0:\n\t\treturn pow(x, n, mod)\n\telse:\n\t\td_r = rev(d)\n\t\txdr = d_r * x % mod\n\t\tif xdr == 0:\n\t\t\treturn 0\n\t\telif (xdr + n - 1) >= mod:\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod\n\nans = []\nq = int(input())\nfor _ in range(q):\n x,d,n = map(int,input().split())\n ans.append(f(x,d,n))\nfor i in ans:\n print(i)", "neg": "mod = 10 ** 6 + 3\n\nW = [1] * (mod)\nfor i in range(mod - 1):\n\tW[i + 1] = ((i + 1) * W[i]) % mod\n\ndef rev(a):\n\treturn pow(a, mod - 2, mod)\n\ndef f(x, d, n):\n\tif d == 0:\n\t\treturn pow(x, n, mod)\n\telse:\n\t\td_r = rev(d)\n\t\txdr = d_r * x % mod\n\t\tif xdr == 0:\n\t\t\treturn 0\n\t\telif (xdr + n - 1) >= mod:\n\t\t\treturn 0\n\t\telse:\n\t\t\treturn (W[xdr + n - 1] * rev(W[xdr - 1]) % mod) * pow(d, n, mod) % mod\n\nans = []\nq = int(input())\nfor _ in range(q):\n x,d,n = map(int,input().split())\n ans.append(f(x,d,n))\nprint(\"\\n\".join(ans))\n", "jacc_sim": 0.9411764705882353, "nl": "You are given an arithmetic progression with 'n' terms: x, x + d, x + 2d, ..., x + (n-1)d. Find the product of all terms in this sequence modulo 1,000,003. You have 'Q' queries. For each query, compute the product given x, d, and n. Constraints: 1 \u2264 Q \u2264 10^5, 0 \u2264 xi, di \u2264 1,000,002, 1 \u2264 ni \u2264 10^9. Input format: Q, x1 d1 n1, ..., xQ dQ nQ. Output format: Print Q lines, each containing the answer for the corresponding query. Sample Input: 2, 7 2 4, 12345 67890 2019. Sample Output: 9009, 916936.", "before_after_length": [267, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03027", "p_user": "u685263709", "n_user": "u685263709", "pos": "Q = int(input())\n\nmod = 10 ** 6 + 3\ntable = [1]\nfor i in range(1, mod):\n table.append(table[-1]*i % mod)\n\nfor i in range(Q):\n x, d, n = map(int, input().split())\n if d == 0:\n print(pow(x, n, mod))\n else:\n y = x * pow(d, mod - 2, mod) % mod\n if y + n - 1 >= mod:\n print(0)\n else:\n print(pow(d, n, mod) * table[y + n - 1] * pow(table[y - 1], mod - 2, mod) % mod)", "neg": "Q = int(input())\n\nmod = 10 ** 6 + 3\ntable = [1]\nfor i in range(1, mod):\n table.append(table[-1]*i % mod)\n\nfor i in range(Q):\n x, d, n = map(int, input().split())\n if d == 0:\n print(pow(x, n, mod))\n else:\n print(pow(d, n, mod) * table[y + n - 1] * pow(table[y - 1], mod - 2, mod) % mod)", "jacc_sim": 0.9743589743589743, "nl": "You are given an arithmetic progression with 'n' terms: x, x + d, x + 2d, ..., x + (n-1)d. Find the product of all terms in this sequence modulo 1,000,003. You have 'Q' queries. For each query, compute the product given x, d, and n. Constraints: 1 \u2264 Q \u2264 10^5, 0 \u2264 xi, di \u2264 1,000,002, 1 \u2264 ni \u2264 10^9. Input format: Q, x1 d1 n1, ..., xQ dQ nQ. Output format: Print Q lines, each containing the answer for the corresponding query. Sample Input: 2, 7 2 4, 12345 67890 2019. Sample Output: 9009, 916936.", "before_after_length": [171, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u691896522", "n_user": "u691896522", "pos": "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\ndata = []\nn,q = map(int,input().split())\nfor i in range(n):\n s, t, x = map(int, input().split())\n data.append([s-x,t-x,x])\ndata.sort(key=lambda x:x[0])\nd_index = 0\ncandidate_x = []\ninf = float(\"inf\")\ndata += [[inf,inf,inf]]\nfor i in range(q):\n d = int(input())\n while d >= data[d_index][0]:\n heappush(candidate_x, (data[d_index][2], data[d_index][1]))\n d_index += 1\n if len(candidate_x) == 0:\n print(-1)\n else:\n while candidate_x:\n x,finish_t = heappop(candidate_x)\n if finish_t > d:\n heappush(candidate_x, (x, finish_t))\n print(x)\n break\n else:\n print(-1)\n\n\n\n", "neg": "import sys\nfrom heapq import heappush, heappop\ninput = sys.stdin.readline\ndata = []\nn,q = map(int,input().split())\nfor i in range(n):\n s, t, x = map(int, input().split())\n data.append([s-x,t-x,x])\ndata.sort(key=lambda x:x[0])\nd_index = 0\ncandidate_x = []\ninf = float(\"inf\")\ndata += [[inf,inf,inf]]\nfor i in range(q):\n d = int(input())\n while d >= data[d_index][0]:\n heappush(candidate_x, (data[d_index][2], data[d_index][1]))\n d_index += 1\n if len(candidate_x) == 0:\n print(-1)\n else:\n while candidate_x:\n x,finish_t = heappop(candidate_x)\n if finish_t > i:\n heappush(candidate_x, (x, finish_t))\n print(x)\n break\n else:\n print(-1)\n\n\n\n", "jacc_sim": 1.0, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [280, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u562935282", "n_user": "u562935282", "pos": "def main():\n from bisect import bisect_left\n from collections import namedtuple\n from operator import attrgetter\n import sys\n\n input = sys.stdin.readline\n Event = namedtuple('Event', 'pos start end')\n\n N, Q = map(int, input().split())\n\n events = []\n for _ in range(N):\n s, t, x = map(int, input().split())\n e = Event(pos=x, start=s - x, end=t - x) # \u6642\u9593[s-x,t-x)\u306bpos=0\u306b\u3044\u308b\u3068pos=x\u3067\u5de5\u4e8b\u4e2d\n events.append(e)\n events.sort(key=attrgetter('pos'))\n\n D = [int(input()) for _ in range(Q)]\n\n ans = [-1] * Q\n see = [-1] * Q\n for e in events:\n left = bisect_left(D, e.start)\n right = bisect_left(D, e.end)\n # D\u306e\u8981\u7d20\u3067 index \u304c [left,right) \u5185\u306e\u3082\u306e\u306f e.pos \u3067\u5de5\u4e8b\u4e2d\n # e.pos \u6607\u9806\u30bd\u30fc\u30c8\u3057\u3066\u3044\u308b\u306e\u3067, ans[idx] \u306b\u306f\u5de5\u4e8b\u4e2d\u306e\u6700\u5c0f\u306epos\u304c\u5165\u308b\n idx = left\n while idx < right:\n if ~ans[idx]:\n idx = see[idx]\n continue\n ans[idx] = e.pos\n see[idx] = right\n idx += 1\n \n print(*ans, sep='\\n')\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n from bisect import bisect_left\n from collections import namedtuple\n from operator import attrgetter\n import sys\n\n input = sys.stdin.readline\n Event = namedtuple('Event', 'pos start end')\n\n N, Q = map(int, input().split())\n\n events = []\n for _ in range(N):\n s, t, x = map(int, input().split())\n e = Event(pos=x, start=s - x, end=t - x) # \u6642\u9593[s-x,t-x)\u306bpos=0\u306b\u3044\u308b\u3068pos=x\u3067\u5de5\u4e8b\u4e2d\n events.append(e)\n events.sort(key=attrgetter('pos'))\n\n D = [int(input()) for _ in range(Q)]\n\n ans = [-1] * Q\n for e in events:\n left = bisect_left(D, e.start)\n right = bisect_left(D, e.end)\n # D\u306e\u8981\u7d20\u3067 index \u304c [left,right) \u5185\u306e\u3082\u306e\u306f e.pos \u3067\u5de5\u4e8b\u4e2d\n # e.pos \u6607\u9806\u30bd\u30fc\u30c8\u3057\u3066\u3044\u308b\u306e\u3067, ans[idx] \u306b\u306f\u5de5\u4e8b\u4e2d\u306e\u6700\u5c0f\u306epos\u304c\u5165\u308b\n for idx in range(left, right):\n if ~ans[idx]:\n continue\n ans[idx] = x\n\n print(*ans, sep='\\n')\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9578947368421052, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [488, 454], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u911575040", "n_user": "u911575040", "pos": "import sys\nfrom heapq import heappush, heappop\nn,q=map(int,input().split())\na=sorted(((s-x, t-x, x) for _ in range(n) for s, t, x in (map(int, sys.stdin.readline().split()),)), reverse=True)\nheap=[]\nans=[]\nfor i in range(q):\n d=int(input())\n while a and a[-1][0]<=d:\n e=a.pop()\n heappush(heap,(e[2],e[1]))\n while heap and heap[0][1]<=d:\n heappop(heap)\n if heap:\n ans.append(heap[0][0])\n else:\n ans.append(-1)\n\nprint(*ans, sep='\\n')\n\n", "neg": "import sys\nfrom heapq import heappush, heappop\nn,q=map(int,input().split())\na=sorted(((s-x, t-x, x) for _ in range(n) for s, t, x in (map(int, sys.stdin.readline().split()),)), reverse=True)\nheap=[]\nans=[]\nz=list(map(int,sys.stdin))\nfor d in z:\n d=int(input())\n while a and a[-1][0]<=d:\n e=a.pop()\n heappush(heap,(e[2],e[1]))\n while heap and heap[0][1]<=d:\n heappop(heap)\n if heap:\n ans.append(heap[0][0])\n else:\n ans.append(-1)\n\nprint(*ans, sep='\\n')\n\n", "jacc_sim": 0.9464285714285714, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [207, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u191874006", "n_user": "u191874006", "pos": "#!/usr/bin/env python3\n#ABC128 E\n\nimport sys\nimport math\nfrom bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nsys.setrecursionlimit(1000000)\nfrom heapq import heappush, heappop,heappushpop\nfrom collections import defaultdict\nfrom itertools import accumulate\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\nfrom itertools import permutations\nmod = 10**9 + 7\ninf = float('inf')\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\n\nn,q = LI()\nstx = [LI() for _ in range(n)]\nstx.sort(key = itemgetter(2))\nd = [I() for _ in range(q)]\nans = [-1]*(q+1)\nright = [0]*q\nfor s,t,x in stx:\n l,r = bl(d,s-x),bl(d,t-x)\n #l\u2266d jump\u3067\u7ba1\u7406\nfrom bisect import bisect_left\nN, Q = map(int, input().split())\nconsts = []\nfor _ in range(N):\n s,t,x = map(int, input().split())\n consts.append((x,s,t))\nconsts.sort()\nD=[int(input()) for _ in range(Q)]\nans=[-1]*Q\njump=[-1]*Q\nfor x,s,t in consts:\n left=bisect_left(D,s-x)\n right=bisect_left(D,t-x)\n while left jump\u3067\u7ba1\u7406\nfrom bisect import bisect_left\nN, Q = map(int, input().split())\nconsts = []\nfor _ in range(N):\n s,t,x = map(int, input().split())\n consts.append((x,s,t))\nconst.sort()\nD=[int(input()) for _ in range(Q)]\nans=[-1]*Q\njump=[-1]*Q\nfor x,s,t in consts:\n left=bisect_left(D,s-x)\n right=bisect_left(D,t-x)\n while left q:\n break\n heappush(cur_set,(st[2],st[1]))\n stidx+=1\n while cur_set and cur_set[0][1] <=q:\n heappop(cur_set)\n if len(cur_set)==0:\n print(-1)\n else:\n print(cur_set[0][0])\nmain()\n", "neg": "import sys\ninput=sys.stdin.readline\nfrom collections import deque\nfrom heapq import heappush,heappop\nimport re\n\ndef int_raw():\n return int(input())\n \ndef ss_raw():\n return input().split()\n \ndef ints_raw():\n return tuple(map(int, ss_raw()))\n\n\ndef main():\n N ,Q = ints_raw()\n origST = []\n\n for idx in range(N):\n S,T,X = ints_raw()\n origST.append([S-X,T-X,X])\n Ds = [int(input()) for _ in range(Q)]\n\n origST.sort()\n stidx = 0\n cur_set = []\n for d in Ds:\n\n while stidx < len(origST):\n st = origST[stidx]\n if st[0] > d:\n break\n heappush(cur_set,(st[2],st[1]))\n stidx+=1\n while cur_set and cur_set[0][1] <=d:\n heappop(cur_set)\n if cur_set:\n print(-1)\n else:\n print(cur_set[0][0])\nmain()\n", "jacc_sim": 0.96875, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [317, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u237362582", "n_user": "u237362582", "pos": "from bisect import bisect_left\nfrom operator import itemgetter\n\nN, Q = map(int, input().split(\" \"))\ncheck_points = [tuple(map(int, input().split(\" \"))) for _ in range(N)]\nquerys = [int(input()) for _ in range(Q)]\ntime = [-1 for _ in range(Q)]\njump = [-1 for _ in range(Q)]\ncheck_points = sorted(check_points, key=itemgetter(2))\nb_left = bisect_left\n\nfor line in check_points:\n s, f, x = line\n start = s-x\n end = f-x\n left = b_left(querys, start)\n right = b_left(querys, end)\n while left < right:\n if time[left] == -1:\n time[left] = x\n jump[left] = right\n left += 1\n else:\n left = jump[left]\n\nfor t in time:\n print(t)\n", "neg": "from bisect import bisect_left\nfrom operator import itemgetter\n\ninput = sys.stdin.readline\n\nN, Q = map(int, input().split(\" \"))\ncheck_points = [tuple(map(int, input().split(\" \"))) for _ in range(N)]\nquerys = [int(input()) for _ in range(Q)]\ntime = [-1] * Q\njump = [-1] * Q\ncheck_points = sorted(check_points, key=itemgetter(2))\nb_left = bisect_left\n\nfor line in check_points:\n s, f, x = line\n start = s-x\n end = f-x\n left = b_left(querys, start)\n right = b_left(querys, end)\n while left < right:\n if time[left] == -1:\n time[left] = x\n jump[left] = right\n left += 1\n else:\n left = jump[left]\n\nfor t in time:\n print(t)\n", "jacc_sim": 0.9272727272727272, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [241, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u353797797", "n_user": "u353797797", "pos": "import sys\nfrom bisect import *\n\ninput = sys.stdin.readline\n\ndef f(n, q):\n xst = []\n for i in range(n):\n s, t, x = map(int, input().split())\n xst.append([x, s - x, t - x])\n xst.sort()\n\n ds = []\n for i in range(q):\n d = int(input())\n ds.append(d)\n\n ans = [-1] * q\n jump = [-1] * q\n\n for x, s, t in xst:\n i = bisect_left(ds, s)\n fi = bisect_left(ds, t)\n while i < fi:\n if jump[i] != -1:\n i = jump[i]\n else:\n ans[i] = x\n jump[i] = fi\n i += 1\n\n print(*ans, sep=\"\\n\")\n\nn, q = map(int, input().split())\nf(n, q)\n", "neg": "import sys\nfrom bisect import *\n\ninput = sys.stdin.readline\n\ndef f(n, q):\n xst = []\n for i in range(n):\n s, t, x = map(int, input().split())\n xst.append([x, s - x, t - x])\n xst.sort()\n\n ds = []\n for i in range(q):\n d = int(input())\n ds.append(d)\n\n ans = [-1] * q\n jump = [-1] * q\n\n for x, s, t in xst:\n i = bisect_left(ds, s)\n fi = bisect_left(ds, t)\n while i < fi:\n if jump[i] != -1:\n i = jump[i]\n ans[i] = x\n jump[i] = fi\n i += 1\n\n print(*ans, sep=\"\\n\")\n\nn, q = map(int, input().split())\nf(n, q)\n", "jacc_sim": 0.9803921568627451, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [253, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u608088992", "n_user": "u608088992", "pos": "import sys, collections, heapq\nF = sys.stdin\ndef single_input(): return F.readline().strip(\"\\n\")\ndef line_input(): return F.readline().strip(\"\\n\").split()\n\ndef solve():\n N, Q = map(int, line_input())\n event = []\n for i in range(N):\n s, t, x = map(int, line_input())\n event.append((s-x, 1, x))\n event.append((t-x,-1, x))\n for i in range(Q):\n d = int(single_input())\n event.append((d, 2, d))\n event.sort()\n candidate = []\n heapq.heapify(candidate)\n stop = collections.defaultdict(int)\n ans = \"\"\n for time, parameter, co in event:\n if parameter == 1:\n heapq.heappush(candidate, co)\n stop[co] += 1\n elif parameter == -1:\n stop[co] -= 1\n else:\n while candidate:\n x = heapq.heappop(candidate)\n if stop[x] > 0:\n heapq.heappush(candidate, x)\n ans += str(x) + \"\\n\"\n break\n else: ans += \"-1\\n\"\n print(ans)\n\n return 0\n\nif __name__ == \"__main__\":\n solve()", "neg": "import sys, collections, heapq\ndef single_input(F): return F.readline().strip(\"\\n\")\ndef line_input(F): return F.readline().strip(\"\\n\").split()\n\ndef solve():\n F = sys.stdin\n N, Q = map(int, line_input())\n event = []\n for i in range(N):\n s, t, x = map(int, line_input())\n event.append((s-x, 1, x))\n event.append((t-x,-1, x))\n for i in range(Q):\n d = int(single_input())\n event.append((d, 2, d))\n event.sort()\n candidate = []\n heapq.heapify(candidate)\n stop = collections.defaultdict(int)\n ans = \"\"\n for time, parameter, co in event:\n if parameter == 1:\n heapq.heappush(candidate, co)\n stop[co] += 1\n elif parameter == -1:\n stop[co] -= 1\n else:\n while candidate:\n x = heapq.heappop(candidate)\n if stop[x] > 0:\n heapq.heappush(candidate, x)\n ans += str(x) + \"\\n\"\n break\n else: ans += \"-1\\n\"\n print(ans)\n\n return 0\n\nif __name__ == \"__main__\":\n solve()", "jacc_sim": 1.0, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [345, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u456353530", "n_user": "u456353530", "pos": "import heapq\ndef main():\n N, Q = list(map(int, input().split()))\n STX = tuple(list(map(int, input().split())) for _ in range(N))\n D = tuple([int(input()) for _ in range(Q)])\n\n L = []\n for s, t, x in STX:\n L.append((x, s - x, t - x))\n\n L.sort(key = lambda x: x[1])\n q = []\n cnt = 0\n push = heapq.heappush\n pop = heapq.heappop\n t = []\n for i in range(Q):\n while cnt < len(L) and D[i] >= L[cnt][1]:\n if t != []:\n push(q, t)\n t = []\n push(q, L[cnt])\n cnt += 1\n if t != [] and t[2] > D[i]:\n print(t[0])\n else:\n while q != []:\n t = pop(q)\n if t[2] > D[i]:\n print(t[0])\n break\n else:\n t = []\n print(-1)\n\nmain()\n", "neg": "import heapq\ndef main():\n N, Q = list(map(int, input().split()))\n STX = tuple(list(map(int, input().split())) for _ in range(N))\n D = tuple([int(input()) for _ in range(Q)])\n\n L = []\n for s, t, x in STX:\n L.append((x, s - x, t - x))\n\n L.sort(key = lambda x: x[1])\n q = []\n cnt = 0\n push = heapq.heappush\n pop = heapq.heappop\n t = []\n for i in range(Q):\n while cnt < len(L) and D[i] >= L[cnt][1]:\n if t != []:\n push(t)\n push(q, L[cnt])\n cnt += 1\n if t != [] and t[2] > D[i]:\n print(t[0])\n else:\n while q != []:\n t = pop(q)\n if t[2] > D[i]:\n print(t[0])\n break\n else:\n t = []\n print(-1)\n\nmain()\n", "jacc_sim": 1.0, "nl": "You are given an infinitely long street represented as a number line. There are N roadworks scheduled on this street, each blocking a specific coordinate for a certain time interval. Q people are standing at coordinate 0 and will start walking at different times, moving at a speed of 1 unit per time unit. The task is to find the distance each person will walk before encountering a blocked point. If a person walks indefinitely, the output should be -1. The input consists of N, Q, the time intervals and coordinates of the roadworks, and the starting times of the people. The output should provide the distance each person walks or -1 if they walk indefinitely.", "before_after_length": [303, 296], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03033", "p_user": "u875291233", "n_user": "u875291233", "pos": "import sys\nfrom heapq import *\ninput = sys.stdin.readline\nn,Q = list(map(int, input().split()))\nY=[]\nfor j in range(n):\n a=list(map(int, input().split()))\n Y.append([a[0]-a[2],a[1]-a[2],a[2]])\nq = [int(input()) for i in range(Q)]\nY.sort()\nX=[]\np=0\nfor d in q:\n while p= n:\n break\n if d == n-1-d or d in T or n-1-d in T:\n break\n T.add(d)\n T.add(n-1-d)\n temp += S[d]+S[n-1-d]\n ans = max(ans, temp)\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nS = tuple(map(int, input().split()))\nans = 0\nfor c in range(1, n-1):\n temp = 0\n T = set()\n for k in range(1, (n-2)//c+1):\n d = c*k\n if d in T or n-1-d in T:\n break\n T.add(d)\n T.add(n-1-d)\n temp += S[d]+S[n-1-d]\n ans = max(ans, temp)\nprint(ans)", "jacc_sim": 0.9302325581395349, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [165, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u261103969", "n_user": "u261103969", "pos": "import sys\nimport time\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n n = int(input())\n s = list(map(int, readline().split()))\n ans = 0\n\n for c in range(1, n):\n dp = 0\n visited = set()\n for k in range(1, (n - 1) // c):\n forward = k * c\n backward = n - 1 - k * c\n if forward == backward:\n break\n if (forward or backward) in visited:\n break\n visited.add(forward)\n visited.add(backward)\n dp = dp + s[n - 1 - k * c] + s[k * c]\n ans = max(ans, dp)\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nimport time\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\ndef main():\n n = int(input())\n s = list(map(int, readline().split()))\n ans = 0\n\n for c in range(1, n):\n dp = 0\n visited = set()\n for k in range(1, (n - 1) // c):\n forward = k * c\n backward = n - 1 - k * c\n if (forward in visited) or (backward in visited):\n break\n visited.add(forward)\n visited.add(backward)\n dp = dp + s[n - 1 - k * c] + s[k * c]\n ans = max(ans, dp)\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [231, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u819048695", "n_user": "u819048695", "pos": "n=int(input())\ns=list(map(int,input().split()))\nt=[0]*n\nfor i in range(n):\n if i==n-1-i:\n continue\n t[i]+=s[i]+s[n-1-i]\nans=0\nfor c in range(1,n//2):\n num=0\n s_max=0\n if (n-1)%c==0:\n for k in range((n//2)//c+1):\n if n//2<=c*k:\n break\n num+=t[c*k]\n s_max=max(s_max,num)\n else:\n for k in range((n-1)//c):\n num+=t[c*k]\n s_max=max(s_max,num)\n ans=max(ans,s_max)\n\nprint(ans)", "neg": "n=int(input())\ns=list(map(int,input().split()))\nt=[0]*n\nfor i in range(n):\n if i==n-1-i:\n continue\n t[i]+=s[i]+s[n-1-i]\nans=0\nfor c in range(1,n//2):\n num=0\n s_max=0\n if (n-1)%c!=0:\n for k in range((n-1)//c+1):\n num+=t[c*k]\n s_max=max(s_max,num)\n ans=max(ans,s_max)\n\nprint(ans)", "jacc_sim": 0.9024390243902439, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [225, 168], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u844789719", "n_user": "u844789719", "pos": "import itertools\nN = int(input())\nS = [int(_) for _ in input().split()]\n\nans = 0\nfor i in range(1, N - 1):\n maxj = (N - 1) // i\n if (N - 1) % i == 0:\n maxj = ((N - 1) // i + 1) // 2\n dp = itertools.accumulate(\n x + y for x, y in zip(S[:i * maxj:i], S[-1:-1 - i * maxj:-i]))\n ans = max(ans, max(dp))\nprint(ans)\n", "neg": "import itertools\nN = int(input())\nS = [int(_) for _ in input().split()]\n\nans = 0\nfor i in range(1, N):\n if (N - 1) % i:\n maxj = N // i + 1\n else:\n maxj = N // i // 2 + 1\n if maxj < 1:\n continue\n ans = max(\n ans,\n max(\n itertools.accumulate([\n x + y for x, y in zip(S[-1:-1 - i * maxj:-i], S[:i * maxj:i])\n ])))\nprint(ans)\n", "jacc_sim": 0.9024390243902439, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [146, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u792217717", "n_user": "u792217717", "pos": "N = int(input())\ns = list(map(int, input().split(\" \")))\n\nans = 0\nfor q in range(1, N - 1):\n k = 0\n a1 = 0\n seen = set()\n\n p = N - 1 - k * q\n while p > q:\n if k * q in seen:\n break\n seen.add(k * q)\n if p in seen:\n break\n seen.add(p)\n\n a1 = a1 + s[p] + s[k * q]\n # print(p, p - q, a1)\n ans = max(ans, a1)\n\n k += 1\n p = N - 1 - k * q\n\nprint(ans)\n", "neg": "N = int(input())\ns = list(map(int, input().split(\" \")))\n\nans = 0\nfor q in range(2, N):\n k = 0\n a1 = 0\n seen = set()\n\n p = N - 1 - k * q\n while p > 1:\n if p in seen:\n break\n seen.add(p)\n if k * q in seen:\n break\n seen.add(k * q)\n\n a1 = a1 + s[p] + s[k * q]\n ans = max(ans, a1)\n\n k += 1\n p = N - 1 - k * q\n\nprint(ans)\n", "jacc_sim": 0.95, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [184, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u201234972", "n_user": "u201234972", "pos": "from collections import defaultdict\nN = int( input())\nS = list( map( int, input().split()))\n\nans = 0\nfor c in range(1,N):\n now = 0\n for t in range(c ,N, c):\n if ((N-1-t)%c == 0 and N-1-t <= t) or N-1-t - c <=0:\n break\n now += S[t] + S[N-1-t]\n if now > ans:\n ans = now\nprint(ans)\n", "neg": "from collections import defaultdict\nN = int( input())\nS = list( map( int, input().split()))\n\nans = 0\nfor c in range(1,N):\n now = 0\n for t in range(c ,N, c):\n if ((N-1-t)%c == 0 and N-1-t <= t):\n break\n now += S[t] + S[N-1-t]\n print(now, t)\n if now > ans:\n ans = now\nprint(ans)", "jacc_sim": 0.9736842105263158, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [130, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u218843509", "n_user": "u218843509", "pos": "n = int(input())\ns = list(map(int, input().split()))\nans = 0\nfor i in range(1, (n-1)//2+1):\n\tres = 0\n\tl, r = i, n-1-i\n\twhile r > i and l != r and l != r+i:\n\t\tres += s[l] + s[r]\n\t\tans = max(ans, res)\n\t\tl += i\n\t\tr -= i\nprint(ans)", "neg": "n = int(input())\ns = list(map(int, input().split()))\nans = 0\nfor i in range(1, (n-1)//2+1):\n\tif i > 1 and (n-1)%i == 0:\n\t\tcontinue\n\tres = 0\n\tl, r = i, n-1-i\n\twhile r > i and l != r:\n\t\tres += s[l] + s[r]\n\t\tans = max(ans, res)\n\t\tl += i\n\t\tr -= i\nprint(ans)", "jacc_sim": 0.9210526315789473, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [119, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03034", "p_user": "u940102677", "n_user": "u940102677", "pos": "n = int(input())\ns = list(map(int,input().split()))\n\nans = 0\n\nfor c in range(1,n-1):\n if (n-1)%c == 0:\n p = ((n-1)//c-1)//2 \n else:\n p = (n-1)//c-1\n if p <= 0:\n break\n if p <= 0:\n continue\n m = 0\n k = 0\n for i in range(1,p+1):\n k += s[c*i] + s[n-1-c*i]\n m = max(m,k)\n ans = max(ans,m)\n \n \nprint(ans)", "neg": "n = int(input())\ns = list(map(int,input().split()))\n\nans = 0\n\nfor c in range(1,n-1):\n if (n-1)%c == 0:\n p = ((n-1)//c-1)//2 \n else:\n p = (n-1)//c-2\n if p <= 1:\n break\n if p <= 1:\n continue\n m = 0\n k = 0\n for i in range(1,p+1):\n k += s[c*i] + s[n-1-c*i]\n m = max(m,k)\n ans = max(ans,m)\n \n \nprint(ans)", "jacc_sim": 1.0, "nl": "In a game, you start at coordinate 0 on a number line with lotuses at various coordinates. Each lotus has a value written on it. You can move forward or backward by choosing positive integers A and B. If you land on a lotus, your score increases by the value on that lotus. If you reach the end without landing on a lotus, you lose a huge number of points. The goal is to maximize your score. Given N lotuses and their values, find the maximum score achievable. Constraints: 3 \u2264 N \u2264 10^5, -10^9 \u2264 si \u2264 10^9, s0 = sN-1 = 0. Input format: N followed by N values. Output the maximum score. Example: Input: 5, 0 2 5 1 0. Output: 3.", "before_after_length": [177, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02368", "p_user": "u855775311", "n_user": "u855775311", "pos": "import sys\n\n\ndef main():\n sys.setrecursionlimit(int(1e5))\n nvertices, nedges = map(int, input().split())\n Adj = [[] for i in range(nvertices)]\n Adjrev = [[] for i in range(nvertices)]\n for i in range(nedges):\n s, t = map(int, input().split())\n Adj[s].append(t)\n Adjrev[t].append(s)\n\n ordering = []\n visited = [False] * nvertices\n for u in range(nvertices):\n if not visited[u]:\n dfs1(u, Adj, visited, ordering)\n\n ordering.reverse()\n component_ids = [-1] * nvertices\n id = 0\n visited = [False] * nvertices\n for u in ordering:\n if visited[u]:\n continue\n dfs2(u, Adjrev, id, visited, component_ids)\n id += 1\n\n Q = int(input())\n for i in range(Q):\n s, t = map(int, input().split())\n if component_ids[s] == component_ids[t]:\n print(1)\n else:\n print(0)\n\n\ndef dfs1(u, Adj, visited, ordering):\n visited[u] = True\n for v in Adj[u]:\n if visited[v]:\n continue\n dfs1(v, Adj, visited, ordering)\n ordering.append(u)\n\n\ndef dfs2(u, Adj, id, visited, component_ids):\n visited[u] = True\n component_ids[u] = id\n for v in Adj[u]:\n if not visited[v]:\n dfs2(v, Adj, id, visited, component_ids)\n\n\nmain()", "neg": "def main():\n nvertices, nedges = map(int, input().split())\n Adj = [[] for i in range(nvertices)]\n Adjrev = [[] for i in range(nvertices)]\n for i in range(nedges):\n s, t = map(int, input().split())\n Adj[s].append(t)\n Adjrev[t].append(s)\n\n ordering = []\n visited = [False] * nvertices\n for u in range(nvertices):\n if not visited[u]:\n dfs1(u, Adj, visited, ordering)\n\n ordering.reverse()\n component_ids = [-1] * nvertices\n id = 0\n visited = [False] * nvertices\n for u in ordering:\n if visited[u]:\n continue\n dfs2(u, Adjrev, id, visited, component_ids)\n id += 1\n\n Q = int(input())\n for i in range(Q):\n s, t = map(int, input().split())\n if component_ids[s] == component_ids[t]:\n print(1)\n else:\n print(0)\n\n\ndef dfs1(u, Adj, visited, ordering):\n visited[u] = True\n for v in Adj[u]:\n if visited[v]:\n continue\n dfs1(v, Adj, visited, ordering)\n ordering.append(u)\n\ndef dfs2(u, Adj, id, visited, component_ids):\n visited[u] = True\n component_ids[u] = id\n for v in range(Adj[u]):\n if not visited[v]:\n dfs2(v, Adj, id, visited)\n\n\nmain()", "jacc_sim": 0.9215686274509803, "nl": "Strongly Connected Components\n\nA directed graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nInput\n\nA directed graph G(V, E) and a sequence of queries where each query contains a pair of nodes u and v.\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\nQ\nu0 v0\nu1 v1\n:\nuQ-1 vQ-1\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target nodes of i-th edge (directed).\n\nui and vi represent a pair of nodes given as the i-th query.\n\nOutput\n\nFor each query, print \"1\" if the given nodes belong to the same strongly connected component, \"0\" otherwise.\n\nConstraints\n\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 30,000\n- 1 \u2264 Q \u2264 100,000\n\nSample Input 1\n5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n\nSample Output 1\n1\n0\n1\n1", "before_after_length": [448, 426], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02368", "p_user": "u197615397", "n_user": "u197615397", "pos": "def solve():\n N, M = map(int, input().split())\n edges = [[] for _ in [0]*N]\n r_edges = [[] for _ in [0]*N]\n\n for _ in [0]*M:\n a, b = map(int, input().split())\n edges[a].append(b)\n r_edges[b].append(a)\n\n c = kosaraju(edges, r_edges)\n group = [0]*N\n for i in range(len(c)):\n for v in c[i]:\n group[v] = i\n\n result = []\n append = result.append\n for _ in [0]*int(input()):\n a, b = map(int, input().split())\n append(\"1\" if group[a] == group[b] else \"0\")\n\n print(\"\\n\".join(result))\n\n\ndef kosaraju(edges, reverse_edges):\n import sys\n sys.setrecursionlimit(10**7)\n v_count = len(edges)\n order = [0]*v_count\n k = [1]\n\n def get_order(v):\n order[v] = 1\n [None for dest in edges[v] if order[dest] == 0 and get_order(dest)]\n order[v] = k[0]\n k[0] += 1\n\n def get_components(v):\n order[v] = 0\n return [v] + [_v for dest in reverse_edges[v] if order[dest] > 0 for _v in get_components(dest)]\n\n [None for v in range(v_count) if order[v] == 0 and get_order(v)]\n return [get_components(v) for v, _ in sorted(enumerate(order), key=lambda x: x[1], reverse=True) if order[v] > 0]\n\nif __name__ == \"__main__\":\n solve()", "neg": "def solve():\n N, M = map(int, input().split())\n edges = [[] for _ in [0]*N]\n r_edges = [[] for _ in [0]*N]\n\n for _ in [0]*M:\n a, b = map(int, input().split())\n edges[a].append(b)\n r_edges[b].append(a)\n\n c = kosaraju(edges, r_edges)\n group = [0]*N\n for i in range(len(c)):\n for v in c[i]:\n group[v] = i\n\n result = []\n append = result.append\n for _ in [0]*int(input()):\n a, b = map(int, input().split())\n append(\"1\" if group[a] == group[b] else \"0\")\n\n print(\"\\n\".join(result))\n\n\ndef kosaraju(edges, reverse_edges):\n import sys\n sys.setrecursionlimit(10**7)\n v_count = len(edges)\n order = [0]*v_count\n k = [1]\n\n def get_order(v):\n order[v] = 1\n for dest in (_v for _v in edges[v] if order[_v] == 0):\n get_order(dest)\n order[v] = k[0]\n k[0] += 1\n\n def get_components(v):\n order[v] = 0\n return [v] + [_v for dest in reverse_edges[v] if order[dest] > 0 for _v in get_components(dest)]\n\n for v in (_v for _v in range(v_count) if edges[_v] == 0):\n get_order(v)\n return [get_components(v) for v, _ in sorted(enumerate(order), key=lambda x: x[1], reverse=True) if order[v] > 0]\n\nif __name__ == \"__main__\":\n solve()", "jacc_sim": 0.9710144927536232, "nl": "Strongly Connected Components\n\nA directed graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nInput\n\nA directed graph G(V, E) and a sequence of queries where each query contains a pair of nodes u and v.\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\nQ\nu0 v0\nu1 v1\n:\nuQ-1 vQ-1\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target nodes of i-th edge (directed).\n\nui and vi represent a pair of nodes given as the i-th query.\n\nOutput\n\nFor each query, print \"1\" if the given nodes belong to the same strongly connected component, \"0\" otherwise.\n\nConstraints\n\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 30,000\n- 1 \u2264 Q \u2264 100,000\n\nSample Input 1\n5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n\nSample Output 1\n1\n0\n1\n1", "before_after_length": [480, 496], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02368", "p_user": "u798803522", "n_user": "u798803522", "pos": "from collections import defaultdict\nimport sys\nsys.setrecursionlimit(100000)\n\ndef counter():\n cnt = 0\n while True:\n yield cnt\n cnt += 1\n\ndef dfs(here, visited, track, count, connect):\n visited |= {here}\n for c in connect[here]:\n if c not in visited:\n dfs(c, visited, track, count, connect)\n track.append(here)\n\ndef kosaraju(here, visited, track, count, connect):\n visited |= {here}\n for c in connect[here]:\n if c not in visited:\n kosaraju(c, visited, track, count, connect)\n track[here] = count\n\nvertices, edges = (int(n) for n in input().split(\" \"))\nconnect = defaultdict(list)\nreversed_connect = defaultdict(list)\nfor _ in range(edges):\n v1, v2 = (int(n) for n in input().split(\" \"))\n connect[v1].append(v2)\n reversed_connect[v2].append(v1)\n\nvisited = set()\ntrack_gen = counter()\ntrack = []\nfor v in range(vertices):\n if v not in visited:\n dfs(v, visited, track, track_gen, connect)\n\nvisited = set()\ntrack_gen = counter()\nstrongly_con = [-1 for n in range(vertices)]\nfor here in track[::-1]:\n if here not in visited:\n num = next(track_gen)\n kosaraju(here, visited, strongly_con, num, reversed_connect)\n\nq_num = int(input())\nfor _ in range(q_num):\n v1, v2 = (int(n) for n in input().split(\" \"))\n if strongly_con[v1] == strongly_con[v2]:\n print(1)\n else:\n print(0)", "neg": "from collections import defaultdict\nsys.setrecursionlimit(100000)\n\ndef counter():\n cnt = 0\n while True:\n yield cnt\n cnt += 1\n\ndef dfs(here, visited, track, count, connect):\n visited |= {here}\n for c in connect[here]:\n if c not in visited:\n dfs(c, visited, track, count, connect)\n track[here] = next(count)\n\ndef kosaraju(here, visited, track, count, connect):\n visited |= {here}\n for c in connect[here]:\n if c not in visited:\n kosaraju(c, visited, track, count, connect)\n track[here] = count\n\nvertices, edges = (int(n) for n in input().split(\" \"))\nconnect = defaultdict(list)\nreversed_connect = defaultdict(list)\nfor _ in range(edges):\n v1, v2 = (int(n) for n in input().split(\" \"))\n connect[v1].append(v2)\n reversed_connect[v2].append(v1)\n\nvisited = set()\ntrack_gen = counter()\ntrack = [-1 for n in range(vertices)]\nfor v in range(vertices):\n if v not in visited:\n dfs(v, visited, track, track_gen, connect)\n\nvisited = set()\ntrack_gen = counter()\nstrongly_con = [-1 for n in range(vertices)]\nfor v in range(vertices - 1 ,- 1, -1):\n here = track.index(v)\n if here not in visited:\n num = next(track_gen)\n kosaraju(here, visited, strongly_con, num, reversed_connect)\n\nq_num = int(input())\nfor _ in range(q_num):\n v1, v2 = (int(n) for n in input().split(\" \"))\n if strongly_con[v1] == strongly_con[v2]:\n print(1)\n else:\n print(0)", "jacc_sim": 0.984375, "nl": "Strongly Connected Components\n\nA directed graph is strongly connected if every two nodes are reachable from each other. In a strongly connected component of a directed graph, every two nodes of the component are mutually reachable.\n\nInput\n\nA directed graph G(V, E) and a sequence of queries where each query contains a pair of nodes u and v.\n\n|V| |E|\ns0 t0\ns1 t1\n:\ns|E|-1 t|E|-1\nQ\nu0 v0\nu1 v1\n:\nuQ-1 vQ-1\n\n|V| is the number of nodes and |E| is the number of edges in the graph. The graph nodes are named with the numbers 0, 1,..., |V|-1 respectively.\n\nsi and ti represent source and target nodes of i-th edge (directed).\n\nui and vi represent a pair of nodes given as the i-th query.\n\nOutput\n\nFor each query, print \"1\" if the given nodes belong to the same strongly connected component, \"0\" otherwise.\n\nConstraints\n\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 30,000\n- 1 \u2264 Q \u2264 100,000\n\nSample Input 1\n5 6\n0 1\n1 0\n1 2\n2 4\n4 3\n3 2\n4\n0 1\n0 3\n2 3\n3 4\n\nSample Output 1\n1\n0\n1\n1", "before_after_length": [470, 494], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02369", "p_user": "u067972379", "n_user": "u067972379", "pos": "from collections import deque, defaultdict\n\ndef topological_sort(V, E):\n '''\n Kahn's Algorithm (O(|V| + |E|) time)\n Input:\n V = [0, 1, ..., N-1]: a list of vertices of the digraph\n E: the adjacency list of the digraph (dict)\n Output:\n If the input digraph is acyclic, then return a topological sorting of the digraph.\n Else, return None.\n '''\n indeg = {v: 0 for v in V}\n for ends in E.values():\n for v in ends:\n indeg[v] += 1\n \n q = deque([v for v in V if indeg[v] == 0])\n top_sorted = []\n while q:\n v = q.popleft()\n top_sorted.append(v)\n \n for u in E[v]:\n indeg[u] -= 1\n if indeg[u] == 0:\n q.append(u)\n if len(top_sorted) == len(V): # The input digraph is acyclic.\n return top_sorted\n else: # There is a directed cycle in the digraph.\n return None\n\nN, M = map(int, input().split())\nV = range(N)\nE = defaultdict(list)\nfor _ in range(M):\n s, t = map(int, input().split())\n E[s].append(t)\nprint(1 if topological_sort(V, E) is None else 0)\n", "neg": "from collections import deque, defaultdict\n\ndef topological_sort(V, E):\n '''\n Kahn's Algorithm (O(|V| + |E|) time)\n Input:\n V = [0, 1, ..., N-1]: a list of vertices of the digraph\n E: the adjacency list of the digraph (dict)\n Output:\n If the input digraph is acyclic, then return a topological sorting of the digraph.\n Else, return None.\n '''\n indeg = {v: 0 for v in V}\n for ends in E.values():\n for v in ends:\n indeg[v] += 1\n \n q = deque([v for v in V if indeg[v] == 0])\n top_sorted = []\n while q:\n v = q.popleft()\n top_sorted.append(v)\n \n for u in E[v]:\n indeg[u] -= 1\n if indeg[u] == 0:\n q.append(u)\n if len(top_sorted) == len(V): # The input digraph is acyclic.\n return top_sorted\n else: # There is a directed cycle in the digraph.\n return None\n\nN, M = map(int, input().split())\nV = range(N)\nE = defaultdict(list)\nfor _ in range(M):\n s, t = map(int, input().split())\n E[s].append(t)\nprint(0 if topological_sort(V, E) is None else 1)\n", "jacc_sim": 1.0, "nl": "Detect a cycle in a directed graph G(V, E) given in the format |V| |E|, followed by source and target nodes for each edge. Output 1 if G has cycle(s), 0 otherwise. Constraints: 1 \u2264 |V| \u2264 100, 0 \u2264 |E| \u2264 1,000, and source and target nodes for each edge are not equal.", "before_after_length": [379, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02369", "p_user": "u603577460", "n_user": "u603577460", "pos": "#Detectando Ciclos en un grafo\n#Se puede mejorar a un mas\nfrom collections import deque\nimport sys\n\ndef dfs(G,u):\n n = len(G)\n vis=[-1]*n\n stackV = []\n pila = deque()\n pila.append(u)\n vis[u]=1\n stackV.append(u)\n while(pila):\n w = pila.pop()\n for v in G[w]:\n if(vis[v]==-1):\n vis[v]=1\n pila.append(v)\n stackV.append(v)\n elif(vis[v]==1 and v==u):\n return True\n return False\n\ndef main():\n G =[]\n val = [int(x) for x in sys.stdin.readline().strip().split()]\n for i in range(val[0]):\n G.append([])\n for i in range(val[1]):\n L = [int(x) for x in sys.stdin.readline().strip().split()]\n G[L[0]].append(L[1]) \n veri=[]\n\n for i in range(val[0]):\n veri.append(dfs(G,i))\n if(True in veri):print(1)\n else:print(0)\n \nmain()\n \n\n", "neg": "#Detectando Ciclos en un grafo\n#Se puede mejorar a un mas\nfrom collections import deque\nimport sys\n\ndef dfs(G,u):\n n = len(G)\n vis=[-1]*n\n stackV = []\n pila = deque()\n pila.append(u)\n vis[u]=1\n stackV.append(u)\n while(pila):\n w = pila.pop()\n for v in G[w]:\n if(vis[v]==-1):\n vis[v]=1\n pila.append(v)\n stackV.append(v)\n elif(vis[v]==1 and v==u):\n print(stackV)\n return True\n return False\n\ndef main():\n G =[]\n val = [int(x) for x in sys.stdin.readline().strip().split()]\n for i in range(val[0]):\n G.append([])\n for i in range(val[1]):\n L = [int(x) for x in sys.stdin.readline().strip().split()]\n G[L[0]].append(L[1]) \n veri=[]\n\n for i in range(val[0]):\n veri.append(dfs(G,i))\n print(veri)\n if(True in veri):print(1)\n else:print(0)\n \nmain()\n \n\n", "jacc_sim": 1.0, "nl": "Detect a cycle in a directed graph G(V, E) given in the format |V| |E|, followed by source and target nodes for each edge. Output 1 if G has cycle(s), 0 otherwise. Constraints: 1 \u2264 |V| \u2264 100, 0 \u2264 |E| \u2264 1,000, and source and target nodes for each edge are not equal.", "before_after_length": [349, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02370", "p_user": "u067972379", "n_user": "u067972379", "pos": "from collections import deque, defaultdict\n\ndef topological_sort(V, E):\n '''\n Kahn's Algorithm (O(|V| + |E|) time)\n Input:\n V = [0, 1, ..., N-1]: a list of vertices of the digraph\n E: the adjacency list of the digraph (dict)\n Output:\n If the input digraph is acyclic, then return a topological sorting of the digraph.\n Else, return None.\n '''\n indeg = {v: 0 for v in V}\n for ends in E.values():\n for v in ends:\n indeg[v] += 1\n \n q = deque([v for v in V if indeg[v] == 0])\n top_sorted = []\n while q:\n v = q.popleft()\n top_sorted.append(v)\n \n for u in E[v]:\n indeg[u] -= 1\n if indeg[u] == 0:\n q.append(u)\n if len(top_sorted) == len(V): # The input digraph is acyclic.\n return top_sorted\n else: # There is a directed cycle in the digraph.\n return None\n\nN, M = map(int, input().split())\nV = range(N)\nE = defaultdict(list)\nfor _ in range(M):\n s, t = map(int, input().split())\n E[s].append(t)\nprint(*topological_sort(V, E), sep='\\n')\n", "neg": "from collections import deque, defaultdict\n\ndef topological_sort(V, E):\n '''\n Kahn's Algorithm (O(|V| + |E|) time)\n Input:\n V = [0, 1, ..., N-1]: a list of vertices of the digraph\n E: the adjacency list of the digraph (dict)\n Output:\n If the input digraph is acyclic, then return a topological sorting of the digraph.\n Else, return None.\n '''\n indeg = {v: 0 for v in V}\n for ends in E.values():\n for v in ends:\n indeg[v] += 1\n \n q = deque([v for v in V if indeg[v] == 0])\n top_sorted = []\n while q:\n v = q.popleft()\n top_sorted.append(v)\n \n for u in E[v]:\n indeg[u] -= 1\n if indeg[u] == 0:\n q.append(u)\n if len(top_sorted) == len(V): # The input digraph is acyclic.\n return top_sorted\n else: # There is a directed cycle in the digraph.\n return None\n\nN, M = map(int, input().split())\nE = defaultdict(list)\nfor _ in range(M):\n s, t = map(int, input().split())\n E[s].append(t)\nprint(*topological_sort(V, E), sep='\\n')\n", "jacc_sim": 1.0, "nl": "Topological Sort\n\nA directed acyclic graph (DAG) represents task ordering, with tasks as vertices and task constraints as edges. Topological sort provides the proper task sequence. Given a DAG G, print the vertex order after topological sort.\n\nInput\nA directed graph G is given as:\n|V| |E|\ns0 t0\ns1 t1\n...\ns(|E|-1) t(|E|-1)\n\n|V| is the number of vertices, |E| is the number of edges, and vertices are named 0 to |V|-1. si and ti represent source and target nodes of the i-th edge.\n\nOutput\nPrint the vertex numbers in order, one per line. If multiple solutions exist, any one is acceptable.\n\nConstraints\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 100,000\n- No parallel edges or self-loops in G\n\nSample Input\n6 6\n0 1\n1 2\n3 1\n3 4\n4 5\n5 2\n\nSample Output\n0\n3\n1\n4\n5\n2", "before_after_length": [377, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02370", "p_user": "u462831976", "n_user": "u462831976", "pos": "# -*- coding: utf-8 -*-\n\nimport sys\nimport os\nimport pprint\nfrom queue import Queue\n\n\"\"\"Topological Sort\"\"\"\n\n#fd = os.open('GRL_4_B_5.txt', os.O_RDONLY)\n#os.dup2(fd, sys.stdin.fileno())\n\nV, E = list(map(int, input().split()))\nG = [[] for i in range(V)]\nindig = [0] * V # ??\\?\u00ac???\u00b0\nfor i in range(E):\n s, t = list(map(int, input().split()))\n G[s].append(t)\n indig[t] += 1\n\nq = Queue()\nout = []\n\ndef bfs(node_index):\n q.put(node_index)\n\n while not q.empty():\n u = q.get()\n out.append(u)\n\n # u?????????????????\u00a7u?????????indig????????????\n for index in G[u]:\n indig[index] -= 1\n if indig[index] == 0:\n q.put(index)\n\n# bfs?????????\nindig_copy = indig[:]\nfor i in range(V):\n if indig_copy[i] == 0:\n bfs(node_index=i)\n\nfor v in out:\n print(v)", "neg": "# -*- coding: utf-8 -*-\n\nimport sys\nimport os\nimport pprint\nfrom queue import Queue\n\n\"\"\"Topological Sort\"\"\"\n\n#fd = os.open('GRL_4_B.txt', os.O_RDONLY)\n#os.dup2(fd, sys.stdin.fileno())\n\nV, E = list(map(int, input().split()))\nG = [[] for i in range(V)]\nindig = [0] * V # ??\\?\u00ac???\u00b0\nfor i in range(V):\n s, t = list(map(int, input().split()))\n G[s].append(t)\n indig[t] += 1\n\nq = Queue()\nout = []\n\ndef bfs(node_index):\n q.put(node_index)\n\n while not q.empty():\n u = q.get()\n out.append(u)\n\n # u?????????????????\u00a7u?????????indig????????????\n for index in G[u]:\n indig[index] -= 1\n if indig[index] == 0:\n q.put(index)\n\n# bfs?????????\nindig_copy = indig[:]\nfor i in range(V):\n if indig_copy[i] == 0:\n bfs(node_index=i)\n\n\nprint(out)", "jacc_sim": 0.958904109589041, "nl": "Topological Sort\n\nA directed acyclic graph (DAG) represents task ordering, with tasks as vertices and task constraints as edges. Topological sort provides the proper task sequence. Given a DAG G, print the vertex order after topological sort.\n\nInput\nA directed graph G is given as:\n|V| |E|\ns0 t0\ns1 t1\n...\ns(|E|-1) t(|E|-1)\n\n|V| is the number of vertices, |E| is the number of edges, and vertices are named 0 to |V|-1. si and ti represent source and target nodes of the i-th edge.\n\nOutput\nPrint the vertex numbers in order, one per line. If multiple solutions exist, any one is acceptable.\n\nConstraints\n- 1 \u2264 |V| \u2264 10,000\n- 0 \u2264 |E| \u2264 100,000\n- No parallel edges or self-loops in G\n\nSample Input\n6 6\n0 1\n1 2\n3 1\n3 4\n4 5\n5 2\n\nSample Output\n0\n3\n1\n4\n5\n2", "before_after_length": [356, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02371", "p_user": "u426534722", "n_user": "u426534722", "pos": "import sys\nreadline = sys.stdin.readline\nfrom collections import deque\nfrom math import isinf\nINF = float(\"inf\")\nsys.setrecursionlimit(200000)\nn = int(readline())\nG = [[] for _ in range(n)]\nD = [INF] * n\nfor _ in [0] * (n - 1):\n s, t, w = map(int, readline().split())\n G[s].append([t, w])\n G[t].append([s, w])\ndef bfs(s, D):\n dq = deque([s])\n D = [INF] * n\n D[s] = 0\n while dq:\n u = dq.popleft()\n for i in range(len(G[u])):\n e = G[u][i]\n if isinf(D[e[0]]):\n D[e[0]] = D[u] + e[1]\n dq.append(e[0])\n return D\nD = bfs(0, D)\nmaxv = 0\ntgt = 0\nfor i in range(n):\n if isinf(D[i]): continue\n if maxv < D[i]:\n maxv = D[i]\n tgt = i\nD = bfs(tgt, D)\nprint(max(D[i] for i in range(n) if not isinf(D[i])))", "neg": "import sys\nreadline = sys.stdin.readline\nfrom collections import deque\nfrom math import isinf\nINF = float(\"inf\")\nsys.setrecursionlimit(200000)\nn = int(readline())\nG = [[] for _ in range(n)]\nfor _ in [0] * (n - 1):\n s, t, w = map(int, readline().split())\n G[s].append([t, w])\n G[t].append([s, w])\ndef bfs(s, D):\n dq = deque([s])\n D = [INF] * n\n D[s] = 0\n while dq:\n u = dq.popleft()\n for i in range(len(G[u])):\n e = G[u][i]\n if isinf(D[e[0]]):\n D[e[0]] = D[u] + e[1]\n dq.append(e[0])\n return D\nD = bfs(0, D)\nD = bfs(max([i for i in range(n) if not isinf(D[i]) and 0 < D[i]]))\nprint(max(D[i] for i in range(n) if not isinf(D[i])))", "jacc_sim": 0.9344262295081968, "nl": "Title: Diameter of a Tree\n\nGiven a tree T with non-negative weight, find the diameter of the tree. The diameter of a tree is the maximum distance between two nodes in a tree.\n\nInput:\n- n\n- s1 t1 w1\n- s2 t2 w2\n- ...\n- sn-1 tn-1 wn-1\n\nThe first line consists of an integer n representing the number of nodes in the tree. Every node has a unique ID from 0 to n-1 respectively. In the following n-1 lines, edges of the tree are given. si and ti represent end-points of the i-th edge (undirected) and wi represents the weight (distance) of the i-th edge.\n\nOutput:\nPrint the diameter of the tree in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 wi \u2264 1,000\n\nSample Input 1:\n4\n0 1 2\n1 2 1\n1 3 3\n\nSample Output 1:\n5\n\nSample Input 2:\n4\n0 1 1\n1 2 2\n2 3 4\n\nSample Output 2:\n7", "before_after_length": [337, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02372", "p_user": "u943441430", "n_user": "u943441430", "pos": "def solve(prev, r, n, dic):\n d = [0] * n\n md = 0\n t = r\n stack = []\n stack += [[prev, r, 0]]\n while stack:\n prev, r, d1 = stack.pop(-1)\n if r in dic:\n for vtx, cost in dic[r]:\n if vtx == prev:\n continue\n stack += [[r, vtx, d1 + cost]]\n if d[vtx] < d1 + cost:\n d[vtx] = d1 + cost\n if md < d[vtx]:\n md = d[vtx]\n t = vtx\n return d, t\n\ndic = {}\nline = input()\nn = int(line)\nfor _ in range(1, n):\n line = input()\n s, t, w = list(map(int, line.split()))\n if s not in dic:\n dic[s] = [[t, w]]\n else:\n dic[s] += [[t, w]]\n if t not in dic:\n dic[t] = [[s, w]]\n else:\n dic[t] += [[s, w]]\nd1, t1 = solve(-1, 0, n, dic)\nd2, t2 = solve(-1, t1, n, dic)\nd3, t3 = solve(-1, t2, n, dic)\nprint(\"\\n\".join(map(str, [max(a, b) for a, b in zip(d2, d3)] )))\n", "neg": "def solve(prev, r, n, dic):\n d = [0] * n\n md = 0\n t = r\n stack = []\n stack += [[prev, r, 0]]\n while stack:\n print(stack)\n prev, r, d1 = stack.pop(-1)\n if r in dic:\n for vtx, cost in dic[r]:\n if vtx == prev:\n continue\n stack += [[r, vtx, d1 + cost]]\n if d[vtx] < d1 + cost:\n d[vtx] = d1 + cost\n if md < d[vtx]:\n md = d[vtx]\n t = vtx\n return d, t\n\ndic = {}\nline = input()\nn = int(line)\nfor _ in range(1, n):\n line = input()\n s, t, w = list(map(int, line.split()))\n if s not in dic:\n dic[s] = [[t, w]]\n else:\n dic[s] += [[t, w]]\n if t not in dic:\n dic[t] = [[s, w]]\n else:\n dic[t] += [[s, w]]\nd1, t1 = solve(-1, 0, n, dic)\nd2, t2 = solve(-1, t1, n, dic)\nd3, t3 = solve(-1, t2, n, dic)\nprint(\"\\n\".join(map(str, [max(a, b) for a, b in zip(d2, d3)] )))\n", "jacc_sim": 1.0, "nl": "Title: Height of a Tree\n\nGiven a tree T with non-negative weight, find the height of each node of the tree. For each node, the height is the distance to the most distant leaf from the node.\n\nInput:\nn\ns1 t1 w1\ns2 t2 w2\n...\nsn-1 tn-1 wn-1\n\nThe first line consists of an integer n which represents the number of nodes in the tree. Every node has a unique ID from 0 to n-1 respectively.\n\nIn the following n-1 lines, edges of the tree are given. si and ti represent end-points of the i-th edge (undirected) and wi represents the weight (distance) of the i-th edge.\n\nOutput:\nThe output consists of n lines. Print the height of each node 0, 1, 2, ..., n-1 in order.\n\nConstraints:\n- 1 \u2264 n \u2264 10,000\n- 0 \u2264 wi \u2264 1,000\n\nSample Input 1:\n4\n0 1 2\n1 2 1\n1 3 3\n\nSample Output 1:\n5\n3\n4\n5", "before_after_length": [379, 385], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02382", "p_user": "u175224634", "n_user": "u175224634", "pos": "num = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nfirst = second = third = inf = 0.00000\nfor i in range(num):\n dif = x[i] - y[i]\n first = first + abs(dif)\n second = second + dif ** 2\n third = third + abs(dif) ** 3\n inf = max(inf, abs(dif))\nprint('{:.6f}'.format(first))\nprint('{:.6f}'.format(second ** 0.5))\nprint('{:.6f}'.format(third ** 0.333333333333333333))\nprint('{:.6f}'.format(inf))\n", "neg": "num = int(input())\nx = list(map(int, input().split()))\ny = list(map(int, input().split()))\nfirst = second = third = inf = 0.00000\nfor i in range(num):\n dif = x[i] - y[i]\n first = first + abs(dif)\n second = second + dif ** 2\n third = third + abs(dif) ** 3\n inf = max(inf, abs(dif))\nprint('{:.5f}'.format(first))\nprint('{:.5f}'.format(second ** 0.5))\nprint('{:.5f}'.format(third ** 0.3333))\nprint('{:.5f}'.format(inf))\n", "jacc_sim": 0.9090909090909091, "nl": "Title: Distance II\n\nYour task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.\n\nMinkowski's distance is defined as:\nDxy = (\u03a3i=1 to n |xi - yi|^p)^(1/p)\n\nIt can be the Manhattan distance:\nDxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|\nwhere p = 1.\n\nIt can be the Euclidean distance:\nDxy = \u221a((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)\nwhere p = 2.\n\nIt can also be the Chebyshev distance:\nDxy = max(|xi - yi|)\nwhere p = \u221e\n\nWrite a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and \u221e, respectively.\n\nInput:\nThe first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.\n\nOutput:\nPrint the distances for p = 1, 2, 3, and \u221e in a line, ensuring the output has an absolute error less than 10^-5.\n\nConstraints:\n- 1 \u2264 n \u2264 100\n- 0 \u2264 xi, yi \u2264 1000\n\nSample Input:\n3\n1 2 3\n2 0 4\n\nSample Output:\n4.000000\n2.449490\n2.154435\n2.000000", "before_after_length": [176, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02382", "p_user": "u297342993", "n_user": "u297342993", "pos": "import math\n\ninput()\n\nvx = [int(i) for i in input().split()]\nvy = [int(i) for i in input().split()]\n\nDxy = []\nfor p in range(1, 4):\n Dxy.append(sum([abs(vx[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p))\n\nDxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))\n\nfor res in Dxy:\n print('{0:5f}'.format(res))", "neg": "import math\n\ninput()\n\nvx = [int(i) for i in input().split()]\nvy = [int(i) for i in input().split()]\n\nDxy = []\nfor p in range(1, 4):\n Dxy.append(sum([abs(xv[i] - vy[i]) ** p for i in range(len(vx))]) ** (1 / p))\n\nDxy.append(max([abs(vx[i] - vy[i]) for i in range(len(vx))]))\n\nfor res in Dxy:\n print('{0:5f}'.format(res))", "jacc_sim": 0.975, "nl": "Title: Distance II\n\nYour task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.\n\nMinkowski's distance is defined as:\nDxy = (\u03a3i=1 to n |xi - yi|^p)^(1/p)\n\nIt can be the Manhattan distance:\nDxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|\nwhere p = 1.\n\nIt can be the Euclidean distance:\nDxy = \u221a((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)\nwhere p = 2.\n\nIt can also be the Chebyshev distance:\nDxy = max(|xi - yi|)\nwhere p = \u221e\n\nWrite a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and \u221e, respectively.\n\nInput:\nThe first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.\n\nOutput:\nPrint the distances for p = 1, 2, 3, and \u221e in a line, ensuring the output has an absolute error less than 10^-5.\n\nConstraints:\n- 1 \u2264 n \u2264 100\n- 0 \u2264 xi, yi \u2264 1000\n\nSample Input:\n3\n1 2 3\n2 0 4\n\nSample Output:\n4.000000\n2.449490\n2.154435\n2.000000", "before_after_length": [146, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02382", "p_user": "u572790226", "n_user": "u670498238", "pos": "import math\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nfor p in range(1, 4):\n D = []\n for count in range(n):\n D.append((math.fabs(A[count] - B[count]))**p)\n if p==1:\n di = max(D)\n d=(sum(D))**(1/p)\n print('%.06f' % d)\nprint('%.06f' % di)", "neg": "import math\nn = int(input)\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nfor p in range(1, 4):\n D = []\n for count in range(n):\n D.append((math.fabs(A[count] - B[count]))** p)\n if p == 1:\n di = max(D)\n d = (sum(D)) ** (1/p)\n print('%.06f' %d)\nprint('%.06f' % di)", "jacc_sim": 1.0, "nl": "Title: Distance II\n\nYour task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.\n\nMinkowski's distance is defined as:\nDxy = (\u03a3i=1 to n |xi - yi|^p)^(1/p)\n\nIt can be the Manhattan distance:\nDxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|\nwhere p = 1.\n\nIt can be the Euclidean distance:\nDxy = \u221a((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)\nwhere p = 2.\n\nIt can also be the Chebyshev distance:\nDxy = max(|xi - yi|)\nwhere p = \u221e\n\nWrite a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and \u221e, respectively.\n\nInput:\nThe first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.\n\nOutput:\nPrint the distances for p = 1, 2, 3, and \u221e in a line, ensuring the output has an absolute error less than 10^-5.\n\nConstraints:\n- 1 \u2264 n \u2264 100\n- 0 \u2264 xi, yi \u2264 1000\n\nSample Input:\n3\n1 2 3\n2 0 4\n\nSample Output:\n4.000000\n2.449490\n2.154435\n2.000000", "before_after_length": [135, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02382", "p_user": "u213265973", "n_user": "u213265973", "pos": "n = int(input())\nX = [int(i) for i in input().split(\" \")]\nY = [int(i) for i in input().split(\" \")]\n\nfor p in range(1, 4):\n print(\"{:.6f}\".format(sum( [abs(a - b) ** p for a, b in zip(X,Y) ] ) ** (1 / p) ) )\n\nprint(\"{:.6f}\".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )\n ", "neg": "n = int(input())\nX = [int(i) for i in input().split(\" \")]\nY = [int(i) for i in input().split(\" \")]\n\nfor p in range(1, 4):\n print(\"{:.6f}\".format(sum( [abs(a - b) ** p) for a, b in zip(X,Y) ] ) ** (1 / p) ) )\n\nprint(\"{:.6f}\".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )\n ", "jacc_sim": 1.0, "nl": "Title: Distance II\n\nYour task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.\n\nMinkowski's distance is defined as:\nDxy = (\u03a3i=1 to n |xi - yi|^p)^(1/p)\n\nIt can be the Manhattan distance:\nDxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|\nwhere p = 1.\n\nIt can be the Euclidean distance:\nDxy = \u221a((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)\nwhere p = 2.\n\nIt can also be the Chebyshev distance:\nDxy = max(|xi - yi|)\nwhere p = \u221e\n\nWrite a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and \u221e, respectively.\n\nInput:\nThe first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.\n\nOutput:\nPrint the distances for p = 1, 2, 3, and \u221e in a line, ensuring the output has an absolute error less than 10^-5.\n\nConstraints:\n- 1 \u2264 n \u2264 100\n- 0 \u2264 xi, yi \u2264 1000\n\nSample Input:\n3\n1 2 3\n2 0 4\n\nSample Output:\n4.000000\n2.449490\n2.154435\n2.000000", "before_after_length": [133, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02382", "p_user": "u607723579", "n_user": "u213265973", "pos": "n = int(input())\nX = list(map(int,input().split()))\nY = list(map(int,input().split()))\n# p=1,2,3\nfor p in range(1,4):\n print(\"{0:.6f}\".format(sum([abs(a-b)**p for a,b in zip(X,Y)])**(1/p)))\n# p=infinity\nprint(\"{0:.6f}\".format(max([abs(a-b) for a,b in zip(X,Y)])))\n\n", "neg": "n = int(input())\nX = [int(i) for i in input().split(\" \")]\nY = [int(i) for i in input().split(\" \")]\n\n#p = 1,2,3\nfor p in range(1, 4):\n print(\"{:.6f}\".format(sum( [abs(a - b) ** p) for a, b in zip(X,Y) ] ) ** (1 / p) ) )\n\n#p = infinity\nprint(\"{:.6f}\".format(max( [ abs(a - b) for a, b in zip(X, Y) ] ) ) )\n ", "jacc_sim": 0.9069767441860465, "nl": "Title: Distance II\n\nYour task is to calculate the distance between two n-dimensional vectors x = {x1, x2, ..., xn} and y = {y1, y2, ..., yn} using Minkowski's distance, a generalization of Manhattan and Euclidean distances.\n\nMinkowski's distance is defined as:\nDxy = (\u03a3i=1 to n |xi - yi|^p)^(1/p)\n\nIt can be the Manhattan distance:\nDxy = |x1 - y1| + |x2 - y2| + ... + |xn - yn|\nwhere p = 1.\n\nIt can be the Euclidean distance:\nDxy = \u221a((|x1 - y1|)^2 + (|x2 - y2|)^2 + ... + (|xn - yn|)^2)\nwhere p = 2.\n\nIt can also be the Chebyshev distance:\nDxy = max(|xi - yi|)\nwhere p = \u221e\n\nWrite a program that reads two n-dimensional vectors x and y, and calculates Minkowski's distance for p = 1, 2, 3, and \u221e, respectively.\n\nInput:\nThe first line contains an integer n. The second and third lines contain the elements of x and y as {x1, x2, ... xn} and {y1, y2, ... yn} respectively, given as integers.\n\nOutput:\nPrint the distances for p = 1, 2, 3, and \u221e in a line, ensuring the output has an absolute error less than 10^-5.\n\nConstraints:\n- 1 \u2264 n \u2264 100\n- 0 \u2264 xi, yi \u2264 1000\n\nSample Input:\n3\n1 2 3\n2 0 4\n\nSample Output:\n4.000000\n2.449490\n2.154435\n2.000000", "before_after_length": [134, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u336705996", "n_user": "u336705996", "pos": "class Dice:\n def __init__(self,num):\n self.num = num.copy()\n \n def east(self):\n temp = self.num.copy()\n self.num[1-1] = temp[4-1]\n self.num[4-1] = temp[6-1]\n self.num[6-1] = temp[3-1]\n self.num[3-1] = temp[1-1]\n\n def north(self):\n temp = self.num.copy()\n self.num[1-1] = temp[2-1]\n self.num[2-1] = temp[6-1]\n self.num[6-1] = temp[5-1]\n self.num[5-1] = temp[1-1]\n\n def south(self):\n temp = self.num.copy()\n self.num[1-1] = temp[5-1]\n self.num[5-1] = temp[6-1]\n self.num[6-1] = temp[2-1]\n self.num[2-1] = temp[1-1]\n\n def west(self):\n temp = self.num.copy()\n self.num[1-1] = temp[3-1]\n self.num[3-1] = temp[6-1]\n self.num[6-1] = temp[4-1]\n self.num[4-1] = temp[1-1]\n\nnum = list(map(int,input().split()))\ndice = Dice(num)\ncommand = input()\nfor c in command:\n if c == 'E': dice.east()\n elif c == 'N': dice.north()\n elif c == 'S': dice.south()\n elif c == 'W': dice.west()\nprint(dice.num[0])\n \n\n", "neg": "class Dice():\n def __init__(self,num):\n self.num = num\n\n def east(self):\n temp = num\n num[1-1] = temp[4-1]\n num[4-1] = temp[6-1]\n num[6-1] = temp[3-1]\n num[3-1] = temp[1-1]\n\n def north(self):\n temp = num\n num[1-1] = temp[2-1]\n num[2-1] = temp[6-1]\n num[6-1] = temp[5-1]\n num[5-1] = temp[1-1]\n\n def south(self):\n temp = num\n num[1-1] = temp[5-1]\n num[5-1] = temp[6-1]\n num[6-1] = temp[2-1]\n num[2-1] = temp[1-1]\n\n def west(self):\n temp = num\n num[1-1] = temp[3-1]\n num[3-1] = temp[6-1]\n num[6-1] = temp[4-1]\n num[4-1] = temp[1-1]\n\nnum = list(map(int,input().split()))\ndice = Dice(num)\ncommand = input()\nfor c in command:\n if c == 'E': dice.east()\n elif c == 'N': dice.north()\n elif c == 'S': dice.south()\n elif c == 'W': dice.west()\nprint(dice.num[0])\n \n\n", "jacc_sim": 0.9782608695652174, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [474, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u985177058", "n_user": "u985177058", "pos": "import copy\n\n\nclass Dice:\n def __init__(self, eyes):\n self._top = eyes[0]\n self._front = eyes[1]\n self._right = eyes[2]\n self._left = eyes[3]\n self._back = eyes[4]\n self._bottom = eyes[5]\n\n @property\n def eye(self):\n return self._top\n\n def roll(self, direction):\n old = copy.copy(self)\n if direction == 'N':\n self._top = old._front\n self._front = old._bottom\n self._back = old._top\n self._bottom = old._back\n elif direction == 'S':\n self._top = old._back\n self._front = old._top\n self._back = old._bottom\n self._bottom = old._front\n elif direction == 'W':\n self._top = old._right\n self._right = old._bottom\n self._left = old._top\n self._bottom = old._left\n elif direction == 'E':\n self._top = old._left\n self._right = old._top\n self._left = old._bottom\n self._bottom = old._right\n else:\n raise ValueError('NEWS\u7bb1\u63a8\u3057')\n\n\neyes = input().split()\ndice = Dice(eyes)\n\ndirection_text = input()\nfor d in direction_text:\n dice.roll(d)\n\nprint(dice.eye)\n\n", "neg": "import copy\n\n\nclass Dice:\n def __init__(self, eyes):\n self._top = eyes[0]\n self._front = eyes[1]\n self._right = eyes[2]\n self._left = eyes[3]\n self._back = eyes[4]\n self._bottom = eyes[5]\n\n @property\n def eye(self):\n return self._top\n\n def roll(self, direction):\n old = copy.copy(self)\n if direction == 'N':\n self._top = old._front\n self._front = old._bottom\n self._back = old._top\n self._bottom = old._back\n elif direction == 'S':\n self._top = old._back\n self._front = old._top\n self._back = old._bottom\n self._bottom = old._front\n elif direction == 'W':\n self._top = old._right\n self._right = old._back\n self._left = old._top\n self._back = old._left\n elif direction == 'E':\n self._top = old._left\n self._right = old._top\n self._left = old._back\n self._back = old._right\n else:\n raise ValueError('NEWS\u7bb1\u63a8\u3057')\n\n\neyes = input().split()\ndice = Dice(eyes)\n\ndirection_text = input()\nfor d in direction_text:\n dice.roll(d)\n\nprint(dice.eye)\n\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [379, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u482227082", "n_user": "u482227082", "pos": "class Cube:\n def __init__(self, u, s, e, w, n, d):\n self.u = u\n self.s = s\n self.e = e\n self.w = w\n self.n = n\n self.d = d\n\n def rotate(self, dic):\n if dic == \"N\":\n tmp = self.u\n self.u = self.s\n self.s = self.d\n self.d = self.n\n self.n = tmp\n elif dic == \"E\":\n tmp = self.u\n self.u = self.w\n self.w = self.d\n self.d = self.e\n self.e = tmp\n elif dic == \"W\":\n tmp = self.u\n self.u = self.e\n self.e = self.d\n self.d = self.w\n self.w = tmp\n else:\n tmp = self.u\n self.u = self.n\n self.n = self.d\n self.d = self.s\n self.s = tmp\n\n\ndef main():\n u, s, e, w, n, d = map(int, input().split())\n O = input()\n\n cube = Cube(u, s, e, w, n, d)\n for i in range(len(O)):\n cube.rotate(O[i])\n print(cube.u)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "class Cube:\n def __init__(self, u, s, e, w, n, d):\n self.u = u\n self.s = s\n self.e = e\n self.w = w\n self.n = n\n self.d = d\n\n def rotate(self, dic):\n if dic == \"N\":\n tmp = self.u\n self.u = self.s\n self.s = self.d\n self.d = self.n\n self.n = tmp\n elif dic == \"E\":\n tmp = self.u\n self.u = self.w\n self.w = self.d\n self.d = self.e\n self.e = tmp\n elif dic == \"W\":\n tmp = self.u\n self.u = self.e\n self.e = self.d\n self.d = self.w\n self.w = tmp\n else:\n tmp = self.u\n self.u = self.n\n self.n = self.d\n self.d = self.s\n self.s = tmp\n\n\ndef main():\n u, s, e, w, n, d = map(int, input().split())\n O = input()\n\n cube = Cube(u, s, e, w, n, d)\n for i in range(len(O)):\n cube.rotate(O[i])\n print(cube.u)\n\n\nif __name__ == '__main__':\n main(\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [370, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u823030818", "n_user": "u823030818", "pos": "class Dice:\n def __init__ (self,data):\n self.data = data\n\n def move(self,direction):\n if direction == 'E':\n self.data[0],self.data[3],self.data[5],self.data[2] = \\\n self.data[3],self.data[5],self.data[2],self.data[0]\n elif direction == 'N':\n self.data[0],self.data[4],self.data[5],self.data[1] = \\\n self.data[1],self.data[0],self.data[4],self.data[5]\n elif direction == 'S':\n self.data[0],self.data[1],self.data[5],self.data[4] = \\\n self.data[4],self.data[0],self.data[1],self.data[5]\n elif direction == 'W':\n self.data[0],self.data[2],self.data[5],self.data[3] = \\\n self.data[2],self.data[5],self.data[3],self.data[0]\n\n def getTop(self):\n return self.data[0]\n\ndice = Dice(input().split())\ncmd = input()\nfor i in range(len(cmd)):\n dice.move(cmd[i])\nprint(dice.getTop())", "neg": "\n def __init__ (self,data):\n self.data = data\n\n def move(self,direction):\n if direction == 'E':\n self.data[0],self.data[3],self.data[5],self.data[2] = \\\n self.data[3],self.data[5],self.data[2],self.data[0]\n elif direction == 'N':\n self.data[0],self.data[4],self.data[5],self.data[1] = \\\n self.data[1],self.data[0],self.data[4],self.data[5]\n elif direction == 'S':\n self.data[0],self.data[1],self.data[5],self.data[4] = \\\n self.data[4],self.data[0],self.data[1],self.data[5]\n elif direction == 'W':\n self.data[0],self.data[2],self.data[5],self.data[3] = \\\n self.data[2],self.data[5],self.data[3],self.data[0]\n\n def getTop(self):\n return self.data[0]\n\ndice = Dice(input().split())\ncmd = input()\nfor i in range(len(cmd)):\n dice.move(cmd[i])\n print(dice.getTop())", "jacc_sim": 0.9767441860465116, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [345, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u370429022", "n_user": "u370429022", "pos": "# 1: top, 2: front, 3: right,\n# 4: left, 5: back, 6: bottom\n\nclass Dice:\n def __init__(self, nums):\n self.top, self.front, self.right, self.left, self.back, self.bottom = nums\n\n def roll(self, direction):\n if direction == 'E':\n self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right\n return\n\n if direction == 'N':\n self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back\n return\n\n if direction == 'S':\n self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front\n return\n\n if direction == 'W':\n self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left\n return\n\n def get_top(self):\n return self.top\n\nif __name__ == '__main__':\n nums = [int(i) for i in input().split()]\n directions = input()\n\n d = Dice(nums)\n for i in range(len(directions)):\n d.roll(directions[i])\n\n print(d.get_top())", "neg": "# 1: top, 2: front, 3: right,\n# 4: left, 5: back, 6: bottom\n\nclass Dice:\n def __init__(self, nums):\n self.top, self.front, self.right, self.left, self.back, self.bottom = nums\n\n def roll(self, direction):\n if direction == 'E':\n self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right\n return\n\n if direction == 'N':\n self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back\n return\n\n if direction == 'S':\n self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front\n return\n\n if direction == 'W':\n self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left\n return\n\n def get_top(self):\n return self.top\n\nif __name__ == '__main__':\n nums = [int(i) for i in input().split()]\n directions = input()\n\n d = Dice(nums)\n for i in len(directions):\n d.roll(directions[i])\n\n print(d.get_top())", "jacc_sim": 0.98, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [354, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u669360983", "n_user": "u669360983", "pos": "import sys\ndata=list(map(int,input().split()))\norder=sys.stdin.readline()\nchar_list=list(order)\nfor i in char_list:\n\t\n\tif i=='N':\n\t\tk=data[0]\n\t\tm=data[4]\n\t\tdata[0]=data[1]\n\t\tdata[1]=data[5]\n\t\tdata[4]=k\n\t\tdata[5]=m\n\telif i=='E':\n\t\tk=data[0]\n\t\tm=data[2]\n\t\tdata[0]=data[3]\n\t\tdata[2]=k\n\t\tdata[3]=data[5]\t\n\t\tdata[5]=m\n\telif i=='S':\n\t\tk=data[0]\n\t\tm=data[1]\n\t\tdata[0]=data[4]\n\t\tdata[1]=k\n\t\tdata[4]=data[5]\n\t\tdata[5]=m\n\telif i=='W':\n\t\tk=data[0]\n\t\tm=data[3]\n\t\tdata[0]=data[2]\n\t\tdata[2]=data[5]\n\t\tdata[3]=k\n\t\tdata[5]=m\nprint(data[0])", "neg": "import sys\ndata=list(map(int,input().split()))\norder=sys.stdin.readline()\nchar_list=list(order)\nfor i in char_list:\n\tprint(i)\n\tif i=='N':\n\t\tk=data[0]\n\t\tm=data[4]\n\t\tdata[0]=data[1]\n\t\tdata[1]=data[5]\n\t\tdata[4]=k\n\t\tdata[5]=m\n\telif i=='E':\n\t\tk=data[0]\n\t\tm=data[2]\n\t\tdata[0]=data[3]\n\t\tdata[2]=k\n\t\tdata[3]=data[5]\t\n\t\tdata[5]=m\n\telif i=='S':\n\t\tk=data[0]\n\t\tm=data[1]\n\t\tdata[0]=data[4]\n\t\tdata[1]=k\n\t\tdata[4]=data[5]\n\t\tdata[5]=m\n\telif i=='W':\n\t\tk=data[0]\n\t\tm=data[3]\n\t\tdata[0]=data[2]\n\t\tdata[2]=data[5]\n\t\tdata[3]=k\n\t\tdata[5]=m\nprint(data[0])", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [324, 328], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u981139449", "n_user": "u981139449", "pos": "class Dice:\n def __init__(self):\n self.top = 1\n self.front = 2\n self.left = 4\n\n @property\n def bottom(self):\n return 7 - self.top\n\n @property\n def back(self):\n return 7 - self.front\n\n @property\n def right(self):\n return 7 - self.left\n\n def move(self, direction):\n if direction == 'N':\n bottom = self.bottom\n self.top = self.front\n self.front = bottom\n elif direction == 'W':\n right = self.right\n self.left = self.top\n self.top = right\n elif direction == 'E':\n bottom = self.bottom\n self.top = self.left\n self.left = bottom\n elif direction == 'S':\n back = self.back\n self.front = self.top\n self.top = back\n\n def __repr__(self):\n print(self.__dict__)\n\ndice = Dice()\nnumbers = input().split()\nfor cmd in input():\n dice.move(cmd)\nprint(numbers[dice.top - 1])", "neg": "class Dice:\n def __init__(self):\n self.top = 1\n self.front = 2\n self.left = 3\n\n @property\n def bottom(self):\n return 7 - self.top\n\n @property\n def back(self):\n return 7 - self.front\n\n @property\n def right(self):\n return 7 - self.left\n\n def move(self, direction):\n if direction == 'N':\n bottom = self.bottom\n self.top = self.front\n self.front = bottom\n elif direction == 'W':\n right = self.right\n self.left = self.top\n self.top = right\n elif direction == 'E':\n bottom = self.bottom\n self.top = self.left\n self.left = bottom\n elif direction == 'S':\n back = self.back\n self.front = self.top\n self.top = back\n\n\ndice = Dice()\nnumbers = input().split()\nfor cmd in input():\n dice.move(cmd)\nprint(numbers[dice.top - 1])", "jacc_sim": 0.9148936170212766, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [289, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u998435601", "n_user": "u998435601", "pos": "# coding: utf-8\n# ?????????????????\u00a8????????????\nclass Dice(object):\n\tdef __init__(self):\n\t\t# ???????????????????????\u00b0\n\t\t# ????????\u00b6???\n\t\tself.x = [2, 5]\n\t\tself.y = [3, 4]\n\t\tself.z = [1, 6]\n\t\tSN = {'S': 0, 'N': 1}\n\t\tWE = {'W': 0, 'E': 1}\n\t\tpass\n\n\tdef rotate(self, _dir):\n\t\tdef rot(_k, _r):\n\t\t\treturn list(reversed(_r)), _k\n\n\t\tif _dir=='N':\n\t\t\tself.x, self.z = rot(self.x, self.z)\n\t\telif _dir=='S':\n\t\t\tself.z, self.x = rot(self.z, self.x)\n\t\telif _dir=='E':\n\t\t\tself.z, self.y = rot(self.z, self.y)\n\t\telif _dir=='W':\n\t\t\tself.y, self.z = rot(self.y, self.z)\n\t\telse:\n\t\t\tpass\n\n\tdef top(self):\n\t\treturn self.z[0]\n\n\nif __name__==\"__main__\":\n\tdice = Dice()\n\tval = list(map(int, input().split()))\n\tdr = input()\n\tfor d in dr:\n\t\tdice.rotate(d)\n\tprint(val[dice.top()-1])", "neg": "# coding: utf-8\n# ?????????????????\u00a8????????????\nclass Dice(object):\n\tdef __init__(self):\n\t\t# ???????????????????????\u00b0\n\t\t# ????????\u00b6???\n\t\tself.x = [2, 5]\n\t\tself.y = [3, 4]\n\t\tself.z = [1, 6]\n\t\tSN = {'S': 0, 'N': 1}\n\t\tWE = {'W': 0, 'E': 1}\n\t\tpass\n\n\tdef rotate(self, _dir):\n\t\tdef rot(_k, _r):\n\t\t\treturn list(reversed(_r)), _k\n\n\t\tif _dir=='N':\n\t\t\tself.x, self.z = rot(self.x, self.z)\n\t\telif _dir=='S':\n\t\t\tself.z, self.x = rot(self.z, self.x)\n\t\telif _dir=='E':\n\t\t\tself.z, self.y = rot(self.z, self.y)\n\t\telif _dir=='W':\n\t\t\tself.y, self.z = rot(self.y, self.z)\n\t\telse:\n\t\t\tpass\n\n\tdef top(self):\n\t\treturn self.z[0]\n\n\tdef view(self):\n\t\tprint(\"x, y, z =\", self.x, self.y, self.z)\n\nif __name__==\"__main__\":\n\tval = list(map(int, input().split()))\n\tdice = Dice()\n\tdr = input()\n\tfor d in dr:\n\t\tdice.rotate(d)\n\tprint(val(dice.top()))", "jacc_sim": 0.9855072463768116, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [400, 429], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u831244171", "n_user": "u831244171", "pos": "class Dice(object):\n def __init__(self):\n self.upside = 1\n self.frontside = 2\n self.rightside = 3\n self.backside = 5\n self.leftside = 4\n self.downside = 6\n\t\t\n def throwDice(self,dir):\n up = self.upside\n front = self.frontside\n left = self.leftside\n if dir == \"S\":\n self.frontside = up\n self.backside = 7-up\n self.downside = front\n self.upside = 7-front\n\t\t\t\n elif dir == \"N\":\n self.frontside = 7-up\n self.backside = up\n self.downside = 7-front\n self.upside = front\n \t\t\n elif dir == \"E\":\n self.rightside = up\n self.leftside = 7-up\n self.upside = left\n self.downside = 7-left\n\t\t\n elif dir == \"W\":\n self.rightside = 7-up\n self.leftside = up\n self.upside = 7-left\n self.downside = left\n\t\n def getUpside(self):\n return self.upside\n\t\t\nn = list(map(int,input().split()))\ncom = list(input())\n\ndice = Dice()\nfor i in range(len(com)):\n dice.throwDice(com[i])\n\nprint(n[dice.getUpside()-1])\n\n\t\n\t\n\t", "neg": "class Dice(object):\n def __init__(self):\n self.upside = 1\n self.frontside = 2\n self.rightside = 3\n self.backside = 4\n self.leftside = 5\n self.downside = 6\n\t\t\n def throwDice(self,dir):\n up = self.upside\n front = self.frontside\n left = self.leftside\n if dir == \"S\":\n self.frontside = up\n self.backside = 7-up\n self.downside = front\n self.upside = 7-front\n\t\t\t\n elif dir == \"N\":\n self.frontside = 7-up\n self.backside = up\n self.downside = 7-front\n self.upside = front\n \t\t\n elif dir == \"E\":\n self.rightside = up\n self.leftside = 7-up\n self.upside = left\n self.downside = 7-left\n\t\t\n elif dir == \"W\":\n self.rightside = 7-up\n self.leftside = up\n self.upside = 7-left\n self.downside = left\n\t\n def getUpside(self):\n return self.upside\n\t\t\nn = list(map(int,input().split()))\ncom = list(input())\n\ndice = Dice()\nfor i in range(len(com)):\n dice.throwDice(com[i])\n\nprint(n[dice.getUpside()-1])\n\n\t\n\t\n\t", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [379, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u494314211", "n_user": "u494314211", "pos": "d=list(map(int,input().split()))\nc=list(input())\n\nclass dice(object):\n\tdef __init__(self, d):\n\t\tself.d = d\n\n\tdef roll(self,com):\n\t\ta1,a2,a3,a4,a5,a6=self.d\n\t\tif com==\"E\":\n\t\t\tself.d = [a4,a2,a1,a6,a5,a3]\n\t\telif com==\"W\":\n\t\t\tself.d = [a3,a2,a6,a1,a5,a4]\n\t\telif com==\"S\":\n\t\t\tself.d = [a5,a1,a3,a4,a6,a2]\n\t\telif com==\"N\":\n\t\t\tself.d = [a2,a6,a3,a4,a1,a5]\n\ndice1=dice(d)\t\nfor com in c:\n\tdice1.roll(com)\nprint(dice1.d[0])", "neg": "d=list(map(int,input().split()))\nc=list(input())\n\nclass dice(object):\n\tdef __init__(self, d):\n\t\tself.d = d\n\n\tdef roll(self,com):\n\t\ta1,a2,a3,a4,a5,a6=self.d\n\t\tif com==\"E\":\n\t\t\tself.d = [a4,a2,a1,a6,a5,a3]\n\t\telif com==\"W\":\n\t\t\tself.d = [a3,a2,a6,a1,a5,a4]\n\t\telif com==\"S\":\n\t\t\tself.d = [a5,a1,a3,a4,a6,a2]\n\t\telif com==\"N\":\n\t\t\tself.d = [a2,a6,a3,a4,a1,a5]\n\ndice1=dice(d)\t\nfor com in c:\n\troll(com)\nprint(dice1.d[0])", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [259, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u957840591", "n_user": "u957840591", "pos": "class Dice(object):\n def __init__(self,num):\n self.f=num[0]\n self.s=num[1]\n self.e=num[2]\n self.w=num[3]\n self.n=num[4]\n self.b=num[5]\n def create(self,order):\n if order=='N':\n return [self.s,self.b,self.e,self.w,self.f,self.n]\n elif order=='S':\n return [self.n,self.f,self.e,self.w,self.b,self.s]\n\n elif order=='E':\n return [self.w,self.s,self.f,self.b,self.n,self.e]\n else:\n return [self.e,self.s,self.b,self.f,self.n,self.w]\n @classmethod\n def Dice_create(cls,num):\n return cls(num)\n\n\nnum=list(map(int,input().split()))\ncommand=input()\ndice=Dice(num)\nfor i in range(len(command)):\n temp=dice.create(command[i])\n dice=Dice.Dice_create(temp)\nprint(dice.f)", "neg": "class Dice(object):\n def __init__(self,num):\n self.f=num[0]\n self.s=num[1]\n self.e=num[2]\n self.w=num[3]\n self.n=num[4]\n self.b=num[5]\n def create(self,order):\n if order=='N':\n return [self.s,self.b,self.e,self.w,self.f,self.n]\n elif order=='S':\n return [self.n,self.f,self.e,self.w,self.b,self.s]\n\n elif order=='E':\n return [self.w,self.s,self.f,self.b,self.n,self.e]\n else:\n return [self.e,self.s,self.b,self.f,self.n,self.w]\n @classmethod\n def Dice_create(cls,num):\n return cls(num)\n\n\nnum=list(map(int,input().split()))\ncommand=input()\ndice=Dice(num)\nfor i in range(len(command)):\n temp=dice.create(command[i])\n dice=Dice.Dice_create(temp)\n print(dice.f,dice.n,dice.e,dice.s,dice.w,dice.b)", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [325, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u216804574", "n_user": "u216804574", "pos": "d = [_ for _ in input().split()]\n\ncommands = input()\n\nfor c in commands:\n if c == 'E':\n d[0], d[2], d[3], d[5] = d[3], d[0], d[5], d[2]\n elif c == 'W':\n d[0], d[2], d[3], d[5] = d[2], d[5], d[0], d[3]\n elif c == 'N':\n d[0], d[1], d[4], d[5] = d[1], d[5], d[0], d[4]\n elif c == 'S':\n d[0], d[1], d[4], d[5] = d[4], d[0], d[5], d[1]\n\nprint(d[0])", "neg": "d = [_ for _ in input().split()] \n \ncommands = input() \n \nfor c in commands: \n if c == 'E': \n d[0], d[1], d[3], d[5] = d[1], d[5], d[0], d[\n3] \n elif c == 'W': \n d[0], d[1], d[3], d[5] = d[3], d[0], d[5], d[\n1] \n elif c == 'N': \n d[0], d[2], d[4], d[5] = d[2], d[5], d[0], d[\n4] \n elif c == 'S': \n d[0], d[2], d[4], d[5] = d[4], d[0], d[5], d[\n2] \n \nprint(d[0]) ", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [205, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u144068724", "n_user": "u144068724", "pos": "class Dice:\n u, s, e, w, n, b = map(int, input().split())\n roll = input()\n for i in roll:\n if i == \"E\":\n e,u,w,b = u,w,b,e\n elif i == \"S\":\n s,u,n,b = u,n,b,s\n elif i == \"W\":\n w,u,e,b = u,e,b,w\n elif i == \"N\":\n n,u,s,b = u,s,b,n\n print(u)\n\ndice = Dice()", "neg": "class Dice:\n\nu,s,e,w,n,b = map(int,input().split())\nroll = input()\nfor i in roll:\n\tif i == E:\n\t\ttmp = e\n\t\te = u\n\t\tu = w\n\t\tw = b\n\t\tb = tmp\n\telif i == S:\n\t\ttmp = s\n\t\ts = u\n\t\tu = n\n\t\tn = b\n\t\tb = tmp\n\telif i == W:\n\t\ttmp = w\n\t\tw = u\n\t\tu = e\n\t\te = b\n\t\tb = tmp\n\telif i == N:\n\t\ttmp = n\n\t\tn = u\n\t\tu = s\n\t\ts = b\n\t\tb = tmp\n\nprint(u)", "jacc_sim": 0.90625, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [153, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u130834228", "n_user": "u130834228", "pos": "number = [int(x) for x in input().split()]\n#S\n#1 -> 2\n#2 -> 6\n#3 -> 3\n#4 -> 4\n#5 -> 1\n#6 -> 5\norder = input()\n\nfor i in range(len(order)):\n number_2 = [number[i] for i in range(len(number))]\n if order[i] == 'S':\n number[0] = number_2[4]\n number[1] = number_2[0]\n number[4] = number_2[5]\n number[5] = number_2[1]\n if order[i] == 'W':\n number[0] = number_2[2]\n number[2] = number_2[5]\n number[3] = number_2[0]\n number[5] = number_2[3]\n if order[i] == 'E':\n number[0] = number_2[3]\n number[2] = number_2[0]\n number[3] = number_2[5]\n number[5] = number_2[2]\n if order[i] == 'N':\n number[0] = number_2[1]\n number[1] = number_2[5]\n number[4] = number_2[0]\n number[5] = number_2[4]\n #print(number)\n\nprint(number[0])", "neg": "number = [int(x) for x in input().split()]\n#S\n#1 -> 2\n#2 -> 6\n#3 -> 3\n#4 -> 4\n#5 -> 1\n#6 -> 5\norder = input()\n\nfor i in range(len(order)):\n number_2 = number\n if order[i] == 'S':\n number[0] = number_2[4]\n number[1] = number_2[0]\n number[4] = number_2[5]\n number[5] = number_2[1]\n if order[i] == 'W':\n number[0] = number_2[2]\n number[2] = number_2[5]\n number[3] = number_2[0]\n number[5] = number_2[3]\n if order[i] == 'E':\n number[0] = number_2[3]\n number[2] = number_2[0]\n number[3] = number_2[5]\n number[5] = number_2[2]\n if order[i] == 'N':\n number[0] = number_2[1]\n number[1] = number_2[5]\n number[4] = number_2[0]\n number[5] = number_2[4]\n\nprint(number[0])", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [353, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u782850499", "n_user": "u782850499", "pos": "dice = [1,2,3,4,5,6]\nnumber = list(map(int,input().split()))\ndirection = str(input())\n\nrotate_n =[2,6,3,4,1,5]\nrotate_s =[5,1,3,4,6,2]\nrotate_e =[4,2,1,6,5,3]\nrotate_w =[3,2,6,1,5,4]\n\nfor i in direction:\n result = []\n if i == \"N\":\n for j in range(6):\n dice[j] = rotate_n[j]\n elif i == \"S\":\n for j in range(6):\n dice[j] = rotate_s[j]\n elif i == \"E\":\n for j in range(6):\n dice[j] = rotate_e[j]\n else:\n for j in range(6):\n dice[j] = rotate_w[j]\n for k in dice:\n result.append(number[k-1])\n number = result\n\nprint(number[0])", "neg": "dice = [1,2,3,4,5,6]\nnumber = list(map(int,input().split()))\ndirection = str(input())\n\nrotate_n =[2,6,4,3,1,5]\nrotate_s =[5,1,3,4,6,2]\nrotate_e =[4,2,1,6,5,3]\nrotate_w =[3,2,6,1,5,4]\n\nfor i in direction:\n result = []\n if i == \"N\":\n for j in range(6):\n dice[j] = rotate_n[j]\n elif i == \"S\":\n for j in range(6):\n dice[j] = rotate_s[j]\n elif i == \"E\":\n for j in range(6):\n dice[j] = rotate_e[j]\n else:\n for j in range(6):\n dice[j] = rotate_w[j]\n for k in dice:\n result.append(number[k-1])\n number = result\n\nprint(number[1])", "jacc_sim": 0.9777777777777777, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [275, 275], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u659034691", "n_user": "u659034691", "pos": "#dice\nD=[int(i) for i in input().split()]\nOs=input()\nfor i in range(len(Os)):\n if Os[i]==\"N\":\n t=D[0]\n D[0]=D[1]\n D[1]=D[5]\n D[5]=D[4]\n D[4]=t\n elif Os[i]==\"S\":\n t=D[0]\n D[0]=D[4]\n D[4]=D[5]\n D[5]=D[1]\n D[1]=t \n elif Os[i]==\"E\":\n t=D[0]\n D[0]=D[3]\n D[3]=D[5]\n D[5]=D[2]\n D[2]=t \n elif Os[i]==\"W\":\n t=D[0]\n D[0]=D[2]\n D[2]=D[5]\n D[5]=D[3]\n D[3]=t \nprint(D[0])", "neg": "#dice\nD=[int(i) for i in input().split()]\nOs=input()\nfor i in range(len(Os)):\n if Os[i]==\"N\":\n t=D[0]\n D[0]=D[1]\n D[1]=D[5]\n D[5]=D[4]\n D[4]=t\n elif Os[i]==\"S\":\n t=D[0]\n D[0]=D[4]\n D[4]=D[5]\n D[5]=D[1]\n D[1]=t \nelif Os[i]==\"E\":\n t=D[0]\n D[0]=D[3]\n D[3]=D[5]\n D[5]=D[2]\n D[2]=t \nelif Os[i]==\"W\":\n t=D[0]\n D[0]=D[2]\n D[2]=D[5]\n D[5]=D[3]\n D[3]=t \nprint(D[0])", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [280, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u518939641", "n_user": "u518939641", "pos": "class Dice:\n def __init__(self):\n self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front\n def set(self,l):\n self.dice=l\n def roll(self, s):\n import copy\n mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))\n l=copy.deepcopy(self.dice)\n if s == 'N': c = 0\n if s == 'S': c = 1\n if s == 'E': c = 2\n if s == 'W': c = 3\n for i in range(6):\n self.dice[i]=l[mat[i][c]]\n def get(self):\n return self.dice\n\nd=Dice()\nd.set(list(map(int,input().split())))\ns=input()\nfor i in range(len(s)):\n d.roll(s[i])\nprint(d.get()[0])", "neg": "class Dice:\n def __init__(self):\n self.dice=[1,2,3,4,5,6] # up,front,right,left,back,front\n def set(self,l):\n self.dice=l\n def roll(self, s):\n import copy\n mat=((1,4,3,2),(5,0,1,1),(2,2,0,5),(3,3,5,0),(0,5,4,4),(4,1,2,3))\n l=copy.deepcopy(self.dice)\n if s == 'N': c = 0\n if s == 'S': c = 1\n if s == 'E': c = 2\n if s == 'W': c = 3\n for i in range(6):\n print('i=%d, c=%d, mat[i][c]=%d, %d->%d'%(i,c,mat[i][c],self.dice[i],l[mat[i][c]]))\n self.dice[i]=l[mat[i][c]]\n def get(self):\n return self.dice\n\nd=Dice()\nd.set(list(map(int,input().split)))\ns=input()\nfor i in range(len(s)):\n d.roll(s[i])\nprint(d.get()[0])", "jacc_sim": 0.9491525423728814, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [290, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u899891332", "n_user": "u899891332", "pos": "class dice:\n directions = ['S', 'E', 'N', 'W']\n def __init__(self, strlabels):\n label = strlabels.split()\n self.top = label[0]\n self.side = label[1:5]\n self.side[2], self.side[3] = self.side[3], self.side[2]\n self.down = label[5]\n #print(self.top, self.side, self.down)\n\n def roll(self, direction):\n tmp = self.top\n self.top = self.side[(self.directions.index(direction)+2)%4]\n self.side[(self.directions.index(direction)+2)%4] = self.down\n self.down = self.side[self.directions.index(direction)]\n self.side[self.directions.index(direction)] = tmp\n #print(self.top, self.side, self.down)\n\n def pFace(self, initial):\n if initial == 'u':\n print(self.top)\n elif initial == 'd':\n print(self.down)\n else:\n print(self.side[directions.index(direction)])\n\ndice1 = dice(input())\nfor direction in input():\n dice1.roll(direction)\n\ndice1.pFace('u')", "neg": "class dice:\n directions = ['S', 'E', 'N', 'W']\n def __init__(self, strlabels):\n label = strlabels.split()\n self.top = label[0]\n self.side = label[1:5]\n self.side[2], self.side[3] = self.side[3], self.side[2]\n self.down = label[5]\n print(self.top, self.side, self.down)\n\n def roll(self, direction):\n tmp = self.top\n self.top = self.side[(self.directions.index(direction)+2)%4]\n self.side[(self.directions.index(direction)+2)%4] = self.down\n self.down = self.side[self.directions.index(direction)]\n self.side[self.directions.index(direction)] = tmp\n print(self.top, self.side, self.down)\n\n def pFace(self, initial):\n if initial == 'u':\n print(self.top)\n elif initial == 'd':\n print(self.down)\n else:\n print(self.side[directions.index(direction)])\n\ndice1 = dice(input())\nfor direction in input():\n dice1.roll(direction)\n\ndice1.pFace('u')", "jacc_sim": 0.9803921568627451, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [338, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u227984374", "n_user": "u227984374", "pos": "a, b, c, d, e, f = map(int, input().split())\nS = list(input())\ni = 0\nnumber1 = a\nnumber2 = b\nnumber3 = c\nnumber4 = d\nnumber5 = e\nnumber6 = f\n\nwhile i < len(S) :\n if S[i] == \"N\" :\n number1 = b\n number2 = f\n number3 = c\n number4 = d\n number5 = a\n number6 = e\n elif S[i] == \"S\" :\n number1 = e\n number2 = a\n number3 = c\n number4 = d\n number5 = f\n number6 = b\n elif S[i] == \"E\" :\n number1 = d\n number2 = b\n number3 = a\n number4 = f\n number5 = e\n number6 = c\n elif S[i] == \"W\" :\n number1 = c\n number2 = b\n number3 = f\n number4 = a\n number5 = e\n number6 = d\n a = number1\n b = number2\n c = number3\n d = number4\n e = number5\n f = number6\n i = i + 1\nprint(number1)\n", "neg": "a, b, c, d, e, f = map(int, input().split())\nS = list(input())\ni = 0\nnumber1 = a\nnumber2 = b\nnumber3 = c\nnumber4 = d\nnumber5 = e\nnumber6 = f\n\nwhile i < len(S) :\n if S[i] == \"N\" :\n number1 = b\n number2 = f\n number3 = c\n number4 = d\n number5 = a\n number6 = e\n elif S[i] == \"S\" :\n number1 = e\n number2 = a\n number3 = c\n number4 = d\n number5 = f\n number6 = b\n elif S[i] == \"E\" :\n number1 = d\n number2 = b\n number3 = a\n number4 = f\n number5 = e\n number6 = c\n elif S[i] == \"W\" :\n number1 = c\n number2 = a\n number3 = f\n number4 = a\n number5 = f\n number6 = d\n a = number1\n b = number2\n c = number3\n d = number4\n e = number5\n f = number6\n i = i + 1\nprint(number1)\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [313, 313], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u017523606", "n_user": "u017523606", "pos": "dice = input().split()\ndirection = list(input())\ndice2 = []\nfor i in range(len(direction)):\n dice2 = dice\n if direction[i] == 'E':\n dice = [dice2[3],dice2[1],dice2[0],dice2[5],dice2[4],dice2[2]]\n elif direction[i] == 'N':\n dice = [dice2[1],dice2[5],dice2[2],dice2[3],dice2[0],dice2[4]]\n elif direction[i] == 'S':\n dice = [dice2[4],dice2[0],dice2[2],dice2[3],dice2[5],dice2[1]]\n else:\n dice = [dice2[2],dice2[1],dice2[5],dice2[0],dice2[4],dice2[3]]\nprint('{0}'.format(int(dice[0]))) \n", "neg": "dice = input().split()\ndirection = list(input())\ndice2 = []\nfor i in range(len(direction)):\n dice2 = dice\n print(dice2)\n if direction[i] == 'E':\n dice = [dice2[3],dice2[1],dice2[0],dice2[5],dice2[4],dice2[2]]\n print(dice)\n elif direction[i] == 'N':\n dice = [dice2[1],dice2[5],dice2[2],dice2[3],dice2[0],dice2[4]]\n print(dice)\n elif direction[i] == 'S':\n dice = [dice2[4],dice2[0],dice2[2],dice2[3],dice2[5],dice2[1]]\n print(dice)\n else:\n dice = [dice2[2],dice2[1],dice2[5],dice2[0],dice2[4],dice2[3]]\n print(dice)\nprint('{0}'.format(int(dice[0])))\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [262, 298], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u294922877", "n_user": "u294922877", "pos": "from collections import deque\n\nclass Dice:\n def __init__(self, top, down, right, left, up, bottom):\n self.top = top\n self.bottom = bottom\n self.up = up\n self.down = down\n self.left = left\n self.right = right\n\n def roll(self, command):\n for c in list(command):\n if c == 'N':\n self.up, self.top, self.down, self.bottom = self.top, self.down, self.bottom, self.up\n elif c == 'S':\n self.up, self.top, self.down, self.bottom = self.bottom, self.up, self.top, self.down\n elif c == 'E':\n self.left, self.top, self.right, self.bottom = self.bottom, self.left, self.top, self.right\n elif c == 'W':\n self.left, self.top, self.right, self.bottom = self.top, self.right, self.bottom, self.left\n\n def pip(self):\n return self.top\n\nif __name__ == '__main__':\n seq = list(map(int, input().split()))\n dice = Dice(*seq)\n dice.roll(input())\n print(dice.pip())\n\n", "neg": "from collections import deque\n\nclass Dice:\n def __init__(self, top, down, right, left, up, bottom):\n self.top = top\n self.bottom = bottom\n self.up = up\n self.down = down\n self.left = left\n self.right = right\n\n def roll(self, command):\n for c in list(command):\n if c == 'N':\n self.up, self.top, self.down, self.bottom = self.top, self.down, self.bottom, self.up\n elif c == 'S':\n self.up, self.top, self.down, self.bottom = self.bottom, self.up, self.top, self.down\n elif c == 'E':\n self.left, self.top, self.right, self.bottom = self.bottom, self.left, self.top, self.right\n elif c == 'W':\n self.left, self,top, self.right, self.bottom = self.top, self.right, self.bottom, self.left\n\n def pip(self):\n return self.top\n\nif __name__ == '__main__':\n seq = list(map(int, input().split()))\n dice = Dice(*seq)\n dice.roll(input())\n print(dice.pip())\n\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [326, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u005739171", "n_user": "u005739171", "pos": "dice = list(map(str, input().split()))\ndirection = input()\nfor i in range(len(direction)):\n\tif direction[i] == \"N\":\n\t\tdice[0],dice[1],dice[4],dice[5] = dice[1],dice[5],dice[0],dice[4]\n\telif direction[i] == \"S\":\n\t\tdice[0],dice[1],dice[4],dice[5] = dice[4],dice[0],dice[5],dice[1]\n\telif direction[i] == \"W\":\n\t\tdice[0],dice[2],dice[3],dice[5] = dice[2],dice[5],dice[0],dice[3]\n\telse :\n\t\tdice[0],dice[2],dice[3],dice[5] = dice[3],dice[0],dice[5],dice[2]\nprint(dice[0])\n", "neg": "def dice():\n\tdice = list(map(str, input().split()))\n\tdirection = input()\n\tfor i in range(len(direction)):\n\t\tif direction[i] == \"N\":\n\t\t\tdice[0],dice[1],dice[4],dice[5] = dice[1],dice[5],dice[0],dice[4]\n\t\telif direction[i] == \"S\":\n\t\t\tdice[0],dice[1],dice[4],dice[5] = dice[4],dice[0],dice[5],dice[1]\n\t\telif direction[i] == \"W\":\n\t\t\tdice[0],dice[2],dice[3],dice[5] = dice[2],dice[5],dice[0],dice[3]\n\t\telse :\n\t\t\tdice[0],dice[2],dice[3],dice[5] = dice[3],dice[0],dice[5],dice[2]\n\tprint(dice[0])\n", "jacc_sim": 0.9714285714285714, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [254, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u908651435", "n_user": "u908651435", "pos": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.t=t\n self.f=f\n self.r=r\n self.l=l\n self.b=b\n self.u=u\n def roll(self,i):\n if d=='S':\n key=self.t\n self.t=self.b\n self.b=self.u\n self.u=self.f\n self.f=key\n elif d=='E':\n key=self.t\n self.t=self.l\n self.l=self.u\n self.u=self.r\n self.r=key\n elif d=='N':\n key=self.t\n self.t=self.f\n self.f=self.u\n self.u=self.b\n self.b=key\n else:\n key=self.t\n self.t=self.r\n self.r=self.u\n self.u=self.l\n self.l=key\nt,f,r,l,b,u=map(int,input().split())\na=list(input())\ndice=Dice(t,f,r,l,b,u)\nfor d in a:\n dice.roll(d)\nprint(dice.t)\n", "neg": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.t=t\n self.f=f\n self.r=r\n self.l=l\n self.b=b\n self.u=u\n def roll(self,i):\n if d=='S':\n key=self.t\n self.t=self.b\n self.b=self.u\n self.u=self.f\n self.t=key\n elif d=='E':\n key=self.t\n self.t=self.l\n self.l=self.u\n self.u=self.r\n self.r=key\n elif d=='N':\n key=self.t\n self.t=self.f\n self.f=self.u\n self.u=self.b\n self.b=key\n else:\n key=self.t\n self.t=self.r\n self.r=self.u\n self.u=self.l\n self.l=key\nt,f,r,l,b,u=map(int,input().split())\na=list(input())\ndice=Dice(t,f,r,l,b,u)\nfor d in a:\n dice.roll(d)\nprint(dice.t)\n", "jacc_sim": 1.0, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [336, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u327546577", "n_user": "u327546577", "pos": "class Dice():\n def __init__(self, numbers):\n self.top = numbers[0]\n self.s = numbers[1]\n self.e = numbers[2]\n self.w = numbers[3]\n self.n = numbers[4]\n self.bot = numbers[5]\n def rot(self, dir):\n top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.n, self.bot)\n if dir == 'N':\n self.top = s\n self.s = bot\n self.e = e\n self.w = w\n self.n = top\n self.bot = n\n elif dir == 'S':\n self.top = n\n self.s = top\n self.e = e\n self.w = w\n self.n = bot\n self.bot = s\n elif dir == 'E':\n self.top = w\n self.s = s\n self.e = top\n self.w = bot\n self.n = n\n self.bot = e\n elif dir == 'W':\n self.top = e\n self.s = s\n self.e = bot\n self.w = top\n self.n = n\n self.bot = w\n def getTop(self):\n return self.top\n\nli = list(map(int, input().split()))\nD = Dice(li)\ncommand = input()\nfor dir in command:\n D.rot(dir)\nprint(D.getTop())\n", "neg": "class Dice():\n def __init__(self, numbers):\n self.top = numbers[0]\n self.s = numbers[1]\n self.e = numbers[2]\n self.w = numbers[3]\n self.n = numbers[4]\n self.bot = numbers[5]\n def rot(self, dir):\n top, s, e, w, n, bot = (self.top, self.s, self.e, self.w, self.b, self.bot)\n if dir == 'N':\n self.top = s\n self.s = bot\n self.e = e\n self.w = w\n self.n = top\n self.bot = n\n elif dir == 'S':\n self.top = n\n self.s = top\n self.e = e\n self.w = w\n self.n = bot\n self.bot = s\n elif dir == 'E':\n self.top = w\n self.s = s\n self.e = top\n self.w = bot\n self.n = n\n self.bot = e\n elif dir == 'W':\n self.top = e\n self.s = s\n self.e = bot\n self.w = top\n self.n = n\n self.bot = w\n def getTop(self):\n return self.top\n\nli = list(map(int, input().split()))\nD = Dice(li)\ncommand = input()\nfor dir in command:\n D.rot(dir)\nprint(D.getTop())\n", "jacc_sim": 0.98, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [387, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u940150266", "n_user": "u940150266", "pos": "dice = {'N':(2, 6, 3, 4, 1, 5),'E':(4, 2, 1, 6, 5, 3),'W':(3, 2, 6, 1, 5, 4),'S':(5, 1, 3, 4, 6, 2)}\nnum = input().split()\nfor alf in input():\n num = [num[i-1]for i in dice[alf]]\nprint(num[0])\n\n", "neg": "num = (int, input().split())\ndice = {'N':(2, 6, 3, 4, 1, 5),'E':(4, 2, 1, 6, 5, 3),'W':(3, 2, 6, 1, 5, 4),'S':(5, 1, 3, 4, 6, 2)}\nfor alf in input():\n num = [num[i]for i in dice[alf-1]]\nprint(num[0])\n\n", "jacc_sim": 0.9696969696969697, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [109, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u248424983", "n_user": "u248424983", "pos": "class Dice:\n \n def __init__(self, val):\n self.top = val[0]\n self.flat1 = val[3]\n self.flat2 = val[1]\n self.flat3 = val[2]\n self.flat4 = val[4]\n self.bottom = val[5]\n \n def doSouth(self):\n temp = self.bottom\n self.bottom = self.flat2\n self.flat2 = self.top\n self.top = self.flat4\n self.flat4 = temp\n\n def doNorth(self):\n temp = self.bottom\n self.bottom = self.flat4\n self.flat4 = self.top\n self.top = self.flat2\n self.flat2 = temp\n\n def doWest(self):\n temp = self.top\n self.top = self.flat3\n self.flat3 = self.bottom\n self.bottom = self.flat1\n self.flat1 = temp\n\n\n def doEast(self):\n temp = self.top\n self.top = self.flat1\n self.flat1 = self.bottom\n self.bottom = self.flat3\n self.flat3 = temp\n \n def doget(self):\n list = [self.top, self.flat2, self.flat3, self.flat1, self.flat4, self.bottom]\n return(list)\n\ndef transform(dice, motion):\n if motion == 'S':\n dice.doSouth()\n elif motion == 'N':\n dice.doNorth()\n elif motion == 'W':\n dice.doWest()\n elif motion == 'E':\n dice.doEast()\n\nN = input().split()\ndice = Dice(N)\nmotion = input()\nfor i in range(len(motion)):\n transform(dice, motion[i])\nprint(dice.top)\n", "neg": "class Dice:\n \n def __init__(self, val):\n self.top = val[0]\n self.flat1 = val[1]\n self.flat2 = val[2]\n self.flat3 = val[3]\n self.flat4 = val[4]\n self.bottom = val[5]\n \n def doSouth(self):\n temp = self.bottom\n self.bottom = self.flat2\n self.flat2 = self.top\n self.top = temp\n\n def doNorth(self):\n temp = self.top\n self.top = self.flat2\n self.flat2 = self.bottom\n self.bottom = temp\n\n def doWest(self):\n temp = self.bottom\n self.top = self.flat3\n self.flat1 = self.top\n self.bottom = self.flat1\n self.flat3 = temp\n\n def doEast(self):\n temp = self.bottom\n self.top = self.flat1\n self.flat3 = self.top\n self.bottom = self.flat3\n self.flat1 = temp\n\ndef transform(dice, motion):\n if motion == 'S':\n dice.doSouth()\n elif motion == 'N':\n dice.doNorth()\n elif motion == 'W':\n dice.doWest()\n elif motion == 'E':\n dice.doEast()\n\nN = input().split()\ndice = Dice(N)\nmotion = input()\nfor i in range(len(motion)):\n transform(dice, motion[i])\nprint(dice.top)\n", "jacc_sim": 0.9433962264150944, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [485, 413], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02383", "p_user": "u725843728", "n_user": "u328199937", "pos": "def north(list):\n List = []\n List.append(list[1])\n List.append(list[5])\n List.append(list[2])\n List.append(list[3])\n List.append(list[0])\n List.append(list[4])\n return List\n \ndef west(list):\n List = []\n List.append(list[2])\n List.append(list[1])\n List.append(list[5])\n List.append(list[0])\n List.append(list[4])\n List.append(list[3])\n return List\n \ndef south(list):\n List = []\n List.append(list[4])\n List.append(list[0])\n List.append(list[2])\n List.append(list[3])\n List.append(list[5])\n List.append(list[1])\n return List\n \ndef east(list):\n List = []\n List.append(list[3])\n List.append(list[1])\n List.append(list[0])\n List.append(list[5])\n List.append(list[4])\n List.append(list[2])\n return List\n \ndice = list(map(int, input().split()))\nx = str(input())\ny = list(x)\nfor i in range(len(x)):\n if y[i] == 'N':\n dice[0:5] = north(dice)\n elif y[i] == 'W':\n dice[0:5] = west(dice)\n elif y[i] == 'S':\n dice[0:5] = south(dice)\n elif y[i] == 'E':\n dice[0:5] = east(dice)\nprint(dice[0])\n", "neg": "ef north(list):\n List = []\n List.append(list[1])\n List.append(list[5])\n List.append(list[2])\n List.append(list[3])\n List.append(list[0])\n List.append(list[4])\n return List\n\ndef west(list):\n List = []\n List.append(list[2])\n List.append(list[1])\n List.append(list[5])\n List.append(list[0])\n List.append(list[4])\n List.append(list[3])\n return List\n \ndef south(list):\n List = []\n List.append(list[4])\n List.append(list[0])\n List.append(list[2])\n List.append(list[3])\n List.append(list[5])\n List.append(list[1])\n return List\n\ndef east(list):\n List = []\n List.append(list[3])\n List.append(list[1])\n List.append(list[0])\n List.append(list[5])\n List.append(list[4])\n List.append(list[2])\n return List\n\ndice = list(map(int, input().split()))\nx = str(input())\ny = list(x)\nfor i in range(len(x)):\n if y[i] == 'N':\n dice[0:5] = north(dice)\n elif y[i] == 'W':\n dice[0:5] = west(dice)\n elif y[i] == 'S':\n dice[0:5] = south(dice)\n elif y[i] == 'E':\n dice[0:5] = east(dice)\nprint(dice[0])\n\n", "jacc_sim": 0.9777777777777777, "nl": "Dice I: Write a program to simulate rolling a dice, constructed by a net with faces labeled 1 to 6. Given integers assigned to each face and a sequence of commands (E, N, S, W), output the integer on the top face after the simulation. Constraints: 0 \u2264 integer assigned to a face \u2264 100, 0 \u2264 length of the command \u2264 100.\n\nSample Input 1:\n1 2 4 8 16 32\nSE\nSample Output 1:\n8\n\nSample Input 2:\n1 2 4 8 16 32\nEESWN\nSample Output 2:\n32\n\nExplanation: Given a dice with integers assigned to faces 1 to 6, rolling it in the specified sequence of directions yields the integer on the top face.", "before_after_length": [460, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u482227082", "n_user": "u482227082", "pos": "import random\n\n\nclass Cube:\n def __init__(self, u, s, e, w, n, d):\n self.u = u\n self.s = s\n self.e = e\n self.w = w\n self.n = n\n self.d = d\n\n def rotate(self, dic):\n if dic == \"N\":\n tmp = self.u\n self.u = self.s\n self.s = self.d\n self.d = self.n\n self.n = tmp\n elif dic == \"E\":\n tmp = self.u\n self.u = self.w\n self.w = self.d\n self.d = self.e\n self.e = tmp\n elif dic == \"W\":\n tmp = self.u\n self.u = self.e\n self.e = self.d\n self.d = self.w\n self.w = tmp\n else:\n tmp = self.u\n self.u = self.n\n self.n = self.d\n self.d = self.s\n self.s = tmp\n\n\ndef main():\n u, s, e, w, n, d = map(int, input().split())\n cube = Cube(u, s, e, w, n, d)\n q = int(input())\n for i in range(q):\n upper, front = map(int, input().split())\n while True:\n cube.rotate(random.choice(\"NWES\"))\n if upper == cube.u and front == cube.s:\n print(cube.e)\n break\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import random\n\n\nclass Cube:\n def __init__(self, u, s, e, w, n, d):\n self.u = u\n self.s = s\n self.e = e\n self.w = w\n self.n = n\n self.d = d\n\n def rotate(self, dic):\n if dic == \"N\":\n tmp = self.u\n self.u = self.s\n self.s = self.d\n self.d = self.n\n self.n = tmp\n elif dic == \"E\":\n tmp = self.u\n self.u = self.w\n self.w = self.d\n self.d = self.e\n self.e = tmp\n elif dic == \"W\":\n tmp = self.u\n self.u = self.e\n self.e = self.d\n self.d = self.w\n self.w = tmp\n else:\n tmp = self.u\n self.u = self.n\n self.n = self.d\n self.d = self.s\n self.s = tmp\n\n\ndef main():\n u, s, e, w, n, d = map(int, input().split())\n cube = Cube(u, s, e, w, n, d)\n q = int(input())\n for i in range(q):\n upper, front = map(int, input().split())\n while True:\n cube.rotate(random.choice(\"NWES\"))\n if upper == cube.u and front == cube.s:\n print(cube.e)\n break\n\n\nif __name__ == '__main__':\n main(\n", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [415, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u567380442", "n_user": "u567380442", "pos": "mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]\nmask += [[mask[1][i] for i in mask[1]]]\n\nTOP, FRONT, RIGHT, LEFT, BACK, BOTTOM = mask[0]\n\ndef set_top(dice, top):\n return [dice[i] for i in mask[top]]\n\ndef set_front(dice, front):\n twist = (0, 3, 1, 4, 2, 5)\n while dice[FRONT] != front:\n dice = [dice[i] for i in twist]\n return dice\n \nlabel = input().split()\nq = int(input())\nfor _ in range(q):\n top, front = map(label.index, input().split())\n dice = set_top(mask[0], top)\n dice = set_front(dice, front)\n print(label[dice[RIGHT]])", "neg": "mask = [range(6), (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]\nmask += [mask[1][i] for i in mask[1]]\n\nTOP, FRONT, RIGHT, LEFT, BACK, BOTTOM = mask[0]\n\ndef set_top(dice, top):\n return [dice[i] for i in mask[top]]\n\ndef set_front(dice, front):\n twist = (0, 3, 1, 4, 2, 5)\n while dice[FRONT] != front:\n dice = [dice[i] for i in twist]\n return dice\n \nlabel = input().split()\nq = int(input())\nfor _ in range(q):\n top, front = map(label.index, input().split())\n dice = set_top(mask[0], top)\n dice = set_front(dice, front)\n print(label[dice[RIGHT]])", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [274, 268], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u831244171", "n_user": "u831244171", "pos": "def whatIsRight(u,f):\t\n r = 0\n if u == 1:\n if f == 2:\n r = 3\n elif f == 3:\n r = 5\n elif f == 4:\n r = 2\n elif f == 5:\n r = 4\n\t\n elif u == 2:\n if f == 6:\n r = 3\n elif f == 3:\n r = 1\n elif f == 1:\n r = 4\n elif f == 4:\n r = 6\n\n elif u == 3:\n if f == 5:\n r = 1\n elif f == 1:\n r = 2\n elif f == 2:\n r = 6\n elif f == 6:\n r = 5\n\t\t\t\n elif u == 4:\n if f == 6:\n r = 2\n elif f == 2:\n r = 1\n elif f == 1:\n r = 5\n elif f == 5:\n r = 6 \n\t\t\t\n elif u == 5:\n if f == 3:\n r = 6\n elif f == 6:\n r = 4\n elif f == 4:\n r = 1\n elif f == 1:\n r = 3\n\t\t\n elif u == 6:\n if f == 5:\n r = 3\n elif f == 3:\n r = 2\n elif f == 2:\n r = 4\n elif f == 4:\n r = 5\n return r\n\t\t\t\nn = list(map(int,input().split()))\nN = int(input())\n\nfor i in range(N):\n m = list(map(int,input().split()))\n num = []\n\n for j in range(len(m)):\n for k in range(len(n)):\n if m[j] == n[k]:\n num.append(k+1)\n break\n\t\n print(n[whatIsRight(num[0],num[1]) -1])", "neg": "def whatIsRight(u,f):\t\n r = 0\n if u == 1:\n if f == 2:\n r = 3\n elif f == 3:\n r = 5\n elif f == 4:\n r = 2\n elif f == 5:\n r = 4\n return r\n\t\n if u == 2:\n if f == 6:\n r = 3\n elif f == 3:\n r = 1\n elif f == 1:\n r = 4\n elif f == 4:\n r = 6\n return r\n\n if u == 3:\n if f == 5:\n r = 1\n elif f == 1:\n r = 2\n elif f == 2:\n r = 6\n elif f == 6:\n r = 3\n return r\n\t\t\t\n if u == 4:\n if f == 6:\n r = 2\n elif f == 2:\n r = 1\n elif f == 1:\n r = 5\n elif f == 5:\n r = 6 \n return r \n\t\t\t\n if u == 5:\n if f == 3:\n r = 6\n elif f == 6:\n r = 4\n elif f == 4:\n r = 1\n elif f == 1:\n r = 3\n\treturn r\n\t\t\n if u == 6:\n if f == 5:\n r = 3\n elif f == 3:\n r = 2\n elif f == 2:\n r = 4\n elif f == 4:\n r = 5\n return r\n\t\t\t\nn = list(map(int,input().split()))\nN = int(input())\n\nfor i in range(N):\n m = list(map(int,input().split()))\n num = []\n\n for j in range(len(m)):\n for k in range(len(n)):\n if m[j] == n[k]:\n num.append(k+1)\n break\n\t\n print(n[whatIsRight(num[0],num[1]) -1])", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [483, 503], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u547492399", "n_user": "u547492399", "pos": "pattern = {\n \"12651\":3,\n \"15621\":4,\n \"13641\":5,\n \"14631\":2,\n \"23542\":1,\n \"24532\":6,\n }\n\nlabel = input().split()\nl2d = {label[i]:str(i+1) for i in range(6)}\n\nqn = int(input())\nfor i in range(qn):\n top, front = input().split()\n tf = l2d[top]+l2d[front]\n\n for p in pattern:\n if tf in p:\n print(label[pattern[p]-1])", "neg": "pattern = {\n \"12651\":3,\n \"15621\":4,\n \"13641\":5,\n \"14631\":2,\n \"23542\":1,\n \"24532\":6,\n }\n\nlabel = input().split()\nl2d = {label[i]:str(i+1) for i in range(6)}\nprint(l2d)\n\nqn = int(input())\nfor i in range(qn):\n top, front = input().split()\n tf = l2d[top]+l2d[front]\n\n for p in pattern:\n if tf in p:\n print(label[pattern[p]-1])", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [160, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u918276501", "n_user": "u918276501", "pos": "R = ((1,2,4,3),(2,0,3,5),(0,1,5,4))\nf = input().split()\n\nfor i in range(int(input())):\n t, s = map(f.index, input().split())\n for j in R:\n if not (t in j)*(s in j):\n continue\n d = R.index(j)\n if (j.index(t) - j.index(s)) %4 == 1:\n d -= 5\n print(f[abs(d)])", "neg": "rot = ((1,2,4,3),(2,0,3,5),(0,1,5,4))\nf = input().split()\n\nfor i in range(int(input())):\n t, s = map(f.index, input().split())\n for j in rot:\n if (t in j)*(s in j):\n continue\n d = rot.index(j)\n if (j.index(t) - j.index(s)) %4 == 1:\n d -= 5\n print(f[abs(d)])", "jacc_sim": 0.9210526315789473, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [137, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u024715419", "n_user": "u024715419", "pos": "class dice:\n def __init__(self, pip):\n self.pip = pip\n \n def move(self,dir):\n if str(dir) == \"E\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]\n elif str(dir) == \"W\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]\n elif str(dir) == \"N\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]\n elif str(dir) == \"S\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]\n\nd = dice(list(map(int,input().split())))\nn = int(input())\n\nfor i in range(n):\n \n top, front = map(int,input().split())\n \n for op in \"EEENEEENEEESEEESEEENEEEN\":\n if d.pip[0] == top and d.pip[1] == front:\n break\n d.move(op) \n print(d.pip[2])", "neg": "class dice:\n def __init__(self, pip):\n self.pip = pip\n \n def move(self,dir):\n if str(dir) == \"E\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]\n elif str(dir) == \"W\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]\n elif str(dir) == \"N\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]\n elif str(dir) == \"S\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]\n\nd = dice(list(map(int,input().split())))\nn = int(input())\n\nfor i in range(n):\n \n top, front = map(int,input().split())\n \n for op in \"EEENEEENEEESEEESEEENEEEN\"\n d.move(op)\n if d.pip[0] == top and d.pip[1] == front:\n break\n \n print(d.pip[2])", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [396, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u395334793", "n_user": "u395334793", "pos": "class Dice:\n def __init__(self):\n self.front = '1'\n self.back = '6'\n self.top = '5'\n self.bottom = '2'\n self. right = '3'\n self.left = '4'\n def turnRight(self):\n temp = self.top\n self.top = self.left\n self.left = self.bottom\n self.bottom = self.right\n self.right = temp\n return self.top\n def turnLeft(self):\n temp = self.top\n self.top = self.right\n self.right = self.bottom\n self.bottom = self.left\n self.left = temp\n return self.top\n def turnFront(self):\n temp = self.top\n self.top = self.back\n self.back = self.bottom\n self.bottom = self.front\n self.front = temp\n return self.top\n def turnBack(self):\n temp = self.top\n self.top = self.front\n self.front = self.bottom\n self.bottom = self.back\n self.back = temp\n return self.top\n \nmydice = Dice()\nmydice.top, mydice.front, mydice.right, mydice.left, mydice.back, mydice.bottom = input().split()\n \nn = int(input())\nfor q in range(n):\n top, front = input().split()\n \n for rotate in range(3):\n mydice.turnFront()\n if mydice.top == front:\n break\n mydice.turnRight()\n if mydice.top == front:\n break\n mydice.turnFront()\n while top != mydice.top:\n mydice.turnRight()\n print(mydice.right)", "neg": "class Dice:\n def __init__(self):\n self.front = '1'\n self.back = '6'\n self.top = '5'\n self.bottom = '2'\n self. right = '3'\n self.left = '4'\n def turnRight(self):\n temp = self.top\n self.top = self.left\n self.left = self.bottom\n self.bottom = self.right\n self.right = temp\n return self.top\n def turnLeft(self):\n temp = self.top\n self.top = self.right\n self.right = self.bottom\n self.bottom = self.left\n self.left = temp\n return self.top\n def turnFront(self):\n temp = self.top\n self.top = self.back\n self.back = self.bottom\n self.bottom = self.front\n self.front = temp\n return self.top\n def turnBack(self):\n temp = self.top\n self.top = self.front\n self.front = self.bottom\n self.bottom = self.back\n self.back = temp\n return self.top\n \nmydice = Dice()\nmydice.top, mydice.front, mydice.right, mydice.left, mydice.back, mydice.bottom = input().split()\n \nn = int(input())\nfor q in range(n):\n top, front = input().split()\n \n for rotate in range(3):\n mydice.turnFront()\n if mydice.top == front:\n break\n mydice.turnRight()\n if mydice.top == front:\n break\n mydice.turnBack()\n while top != mydice.top:\n mydice.turnRight()\n print(mydice.right)", "jacc_sim": 1.0, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [460, 460], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u480053997", "n_user": "u480053997", "pos": "class Dice2():\n\n def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]\n self.view = v\n self.dTFR = {}\n for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in range(6)):\n self.dTFR[self.view[i]]=[self.view[v] for v in (j, k, 5-j, 5-k, j)]\n\n\nd2, q = Dice2(list(map(int, input().split()))), int(input())\nfor i in range(q):\n t, f = map(int, input().split())\n print(d2.dTFR[t][d2.dTFR[t].index(f)+1] )", "neg": "class Dice2(Dice1):\n\n def __init__(self, v): # v [Top, Front, Right, Left, Back, Bottom ]\n super().__init__(v)\n\n self.dTFR = {}\n for i, j, k in ((ii, (ii++2)%6, (ii+4)%6) for ii in range(6)):\n self.dTFR[self.view[i]]=[self.view[v] for v in (j, k, 5-j, 5-k, j)]\n\n\nd2, q = Dice2(list(map(int, input().split()))), int(input())\nfor i in range(q):\n t, f = map(int, input().split())\n print(d2.dTFR[t][d2.dTFR[t].index(f)+1] )", "jacc_sim": 0.9629629629629629, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [199, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u682153677", "n_user": "u682153677", "pos": "# -*- coding: utf-8 -*-\n\n\nclass Dice:\n def __init__(self, n):\n self.upper = n[0]\n self.backward = n[1]\n self.right = n[2]\n self.left = n[3]\n self.ahead = n[4]\n self.bottom = n[5]\n\n def roll_north(self):\n self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom\n\n def roll_south(self):\n self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper\n\n def roll_east(self):\n self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom\n\n def roll_west(self):\n self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper\n\n def roll_side(self):\n self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward\n\n\ndice_info = Dice(list(map(int, input().split())))\nq = int(input())\n\nfor i in range(q):\n upper, ahead = map(int, input().split())\n\n if upper is dice_info.left:\n dice_info.roll_east()\n \n elif upper is dice_info.right:\n dice_info.roll_west()\n\n while not (upper == dice_info.upper or ahead == dice_info.ahead):\n dice_info.roll_north()\n\n while upper != dice_info.upper:\n dice_info.roll_east()\n\n while ahead != dice_info.ahead:\n dice_info.roll_side()\n\n print(dice_info.left)\n", "neg": "# -*- coding: utf-8 -*-\n\n\nclass Dice:\n def __init__(self, n):\n self.upper = n[0]\n self.backward = n[1]\n self.right = n[2]\n self.left = n[3]\n self.ahead = n[4]\n self.bottom = n[5]\n\n def roll_north(self):\n self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom\n\n def roll_south(self):\n self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper\n\n def roll_east(self):\n self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom\n\n def roll_west(self):\n self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper\n\n def roll_side(self):\n self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward\n\n\ndice_info = Dice(list(map(int, input().split())))\nq = int(input())\n\nfor i in range(q):\n upper, ahead = map(int, input().split())\n\n while not (upper == dice_info.upper or ahead == dice_info.ahead):\n dice_info.roll_north()\n dice_info.roll_side()\n\n while upper != dice_info.upper:\n dice_info.roll_east()\n\n while ahead != dice_info.ahead:\n dice_info.roll_side()\n\n print(dice_info.left)\n", "jacc_sim": 0.9464285714285714, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [510, 472], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02384", "p_user": "u363699501", "n_user": "u150984829", "pos": "\nd=input().split()\nfor _ in range(int(input())):\n t,f=[d.index(s)for s in input().split()]\n n=[(1,2,4,3,1),(0,3,5,2,0),(0,1,5,4,0),(1,0,4,5,1),(0,2,5,3,0),(1,3,4,2,1)][t]\n print(d[n[n.index(f)+1]])\n", "neg": "d=input().split()\nn={0:(1,2,4,3,1),1:(0,3,5,2,0),2:(0,1,5,4,0),3:(1,0,4,5,1),4:(0,2,5,3,0),5:(1,3,4,2,1)}\nfor _ in range(int(input())):\n t,f=[d.index(s) for s in input().split()]\n n=n[int(t)]\n print(d[n[n.index(int(f))+1]])\n", "jacc_sim": 0.9354838709677419, "nl": "Dice II: Construct a dice from a given sequence of integers as in Dice I. Given integers on the top and front faces after rolling, write a program to print the integer on the right side face. Input includes six integers in ascending order, followed by the number of questions. Each question consists of two integers representing the top and front faces. Output the integer on the right side face for each question. Constraints: Integers assigned to a face range from 0 to 100, all integers are different, and there are 1 to 24 questions. Example input: \"1 2 3 4 5 6\" and 3, followed by questions \"6 5\", \"1 3\", and \"3 2\". Example output: \"3\", \"5\", \"6\".", "before_after_length": [127, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u647634615", "n_user": "u647634615", "pos": "dice_1 = input().split()\ndice_2 = input().split()\n\nrolls = {' ':[0, 1, 2, 3, 4, 5], \n 'W':[2, 1, 5, 0, 4, 3], \n 'N':[1, 5, 2, 3, 0, 4], \n 'E':[3, 1, 0, 5, 4, 2], \n 'S':[4, 0, 2, 3, 5, 1]\n }\norders = [' ', 'N', 'W', 'E', 'S', 'NN']\ntf = 0\nfor order in orders:\n copy_2 = dice_2\n for d in order:\n roll = rolls[d]\n copy_2 = [copy_2[i] for i in roll] \n l = [1, 2, 4, 3]\n a0 = copy_2[0] == dice_1[0]\n a1 = copy_2[5] == dice_1[5]\n a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)\n if a0 and a1 and a2:\n tf += 1\nif tf>0:\n print('Yes')\nelse:\n print('No')\n", "neg": "dice_1 = input().split()\ndice_2 = input().split()\n\nrolls = {' ':[0, 1, 2, 3, 4, 5], \n 'W':[2, 1, 5, 0, 4, 3], \n 'N':[1, 5, 2, 3, 0, 4], \n 'E':[3, 1, 0, 5, 4, 2], \n 'S':[4, 0, 2, 3, 5, 1]\n }\norders = [' ', 'N', 'W', 'E', 'S', 'SS']\ntf = 0\nfor order in orders:\n for d in order:\n roll = rolls[d]\n copy_2 = [dice_2[i] for i in roll]\n \n l = [1, 2, 4, 3]\n a0 = copy_2[0] == dice_1[0]\n a1 = copy_2[5] == dice_1[5]\n a2 = ' '.join([copy_2[s]for s in l]) in ' '.join([dice_1[s]for s in l] * 2)\n if a0 and a1 and a2:\n tf += 1\n# else:\n# print(order)\n# print(dice_1)\n# print(copy_2)\n\nif tf>0:\n print('Yes')\nelse:\n print('No')\n", "jacc_sim": 0.9433962264150944, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [320, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u764759179", "n_user": "u764759179", "pos": "#!/usr/bin/env python3\n# coding: utf-8\nimport random\n\n\nclass Dice() :\n\n mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),\n 'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1)}\n way = (\"N\",\"E\",\"W\",\"S\")\n\n def __init__(self, data):\n self.label = data\n\n def move(self, data):\n self.label = [self.label[idx] for idx in self.mask[data]]\n\n def get_up(self):\n return self.label[0]\n\n def compare(self, dice2):\n ok = False\n for i in range(1000):\n check = True\n for i2 in range(6):\n if self.label[i2] == dice2.label[i2] :\n continue\n else:\n check = False\n break\n\n if check :\n ok = True\n break\n else:\n self.move(self.way[random.randint(0,1)])\n return ok\n\ndice1 = Dice(input().split())\ndice2 = Dice(input().split())\n\nif dice1.compare(dice2) :\n print (\"Yes\")\nelse:\n print (\"No\")\n\n", "neg": "#!/usr/bin/env python3\n# coding: utf-8\nimport random\n\n\nclass Dice() :\n\n mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),\n 'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1)}\n way = (\"N\",\"E\",\"W\",\"S\")\n\n def __init__(self, data):\n self.label = data\n\n def move(self, data):\n self.label = [self.label[idx] for idx in self.mask[data]]\n\n def get_up(self):\n return self.label[0]\n\n def compare(self, dice2):\n ok = False\n for i in range(1000):\n check = True\n for i2 in range(6):\n if self.label[i2] == dice2.label[i2] :\n continue\n else:\n check = False\n break\n\n if check :\n ok = True\n break\n else:\n self.move(self.way[random.randint(0,3)])\n return ok\n\ndice1 = Dice(input().split())\ndice2 = Dice(input().split())\n\nif dice1.compare(dice2) :\n print (\"OK\")\nelse:\n print (\"NG\")\n", "jacc_sim": 0.9452054794520548, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [357, 356], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u764759179", "n_user": "u764759179", "pos": "#!/usr/bin/env python3\n# coding: utf-8\nimport random\n\n\nclass Dice() :\n\n mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),\n 'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}\n\n way = (\"N\",\"E\",\"W\",\"S\",\"CW\",\"Nop\")\n\n def __init__(self, data):\n self.label = data\n\n def move(self, data):\n if data == \"Nop\":\n return\n self.label = [self.label[idx] for idx in self.mask[data]]\n\n def get_up(self):\n return self.label[0]\n\n def compare_6sq(self, dice2):\n check = True\n for i in range(6):\n if self.label[i] == dice2.label[i] :\n continue\n else:\n check = False\n break\n\n return check\n \n def compare_4rot(self, dice2):\n ok = False\n for i in range(4):\n self.move(\"CW\")\n if self.compare_6sq(dice2) :\n ok =True\n break\n return ok\n \n def compare(self,dice2):\n ok = False\n orderway =(\"Nop\",\"E\",\"N\",\"E\",\"N\",\"E\")\n\n for s in orderway:\n self.move(s)\n if self.compare_4rot(dice2):\n ok = True\n break\n \n return ok\n\n\n\n\n\ndice1 = Dice(input().split())\ndice2 = Dice(input().split())\n\nif dice1.compare(dice2) :\n print (\"Yes\")\nelse:\n print (\"No\")\n\n", "neg": "#!/usr/bin/env python3\n# coding: utf-8\n\nclass Dice() :\n\n mask = {'N':(1,5,2,3,0,4), 'E':(3,1,0,5,4,2),\n 'W':(2,1,5,0,4,3), 'S':(4,0,2,3,5,1),'CW':(0,2,4,1,3,5)}\n\n way = (\"N\",\"E\",\"W\",\"S\",\"CW\",\"Nop\")\n\n def __init__(self, data):\n self.label = data\n\n def move(self, data):\n if data == \"Nop\"\n return\n self.label = [self.label[idx] for idx in self.mask[data]]\n\n def get_up(self):\n return self.label[0]\n\n def compare_6sq(self, dice2):\n check = True\n for i in range(6):\n if self.label[i] == dice2.label[i] :\n continue\n else:\n check = False\n break\n\n return check\n \n def compare_4rot(self, dice2):\n ok = False\n for i in range(4):\n self.move(\"CW\")\n if self.compare_6sq(dice2) :\n ok =True\n break\n return ok\n \n def compare(self,dice2)\n ok = False\n orderway =(\"Nop\",\"E\",\"N\",\"E\",\"N\",\"E\")\n\n for s in orderway:\n self.move(s)\n if self.compare_4rot(dice2):\n ok = True\n break\n \n return ok\n\n\n\n\n\ndice1 = Dice(input().split())\ndice2 = Dice(input().split())\n\nif dice1.compare(dice2) :\n print (\"Yes\")\nelse:\n print (\"No\")\n\n", "jacc_sim": 0.972972972972973, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [491, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u949338836", "n_user": "u949338836", "pos": "#coding:utf-8\n#1_11_C\n\nclass Dice:\n def __init__(self, ary):\n self.top, self.south, self.east, self.west, self.north, self.bottom = ary\n\n def roll_n(self):\n self.top, self.north, self.bottom, self.south = self.south, self.top, self.north, self.bottom\n\n def roll_e(self):\n self.top, self.east, self.bottom, self.west = self.west, self.top, self.east, self.bottom\n\n def twist(self):\n self.north, self.east, self.south, self.west = self.west, self.north, self.east, self.south\n\n def isEqual(self, dice):\n if self.top == dice.top and self.south == dice.south and self.east == dice.east and self.west == dice.west and self.north == dice.north and self.bottom == dice.bottom:\n return True\n else:\n return False\n\ndice1 = Dice(map(int,input().split()))\ndice2 = Dice(map(int,input().split()))\n\nflag = False\n\nfor i in range(6):\n if i % 2 == 0:\n dice1.roll_n()\n else:\n dice1.roll_e()\n\n for j in range(4):\n if dice1.isEqual(dice2):\n flag = True\n break\n else:\n dice1.twist()\n\n if flag:\n break\n\nif flag:\n print('Yes')\nelse:\n print('No')", "neg": "#coding:utf-8\n#1_11_C\n\nclass Dice:\n def __init__(self, ary):\n self.top, self.south, self.east, self.west, self.north, self.bottom = ary\n\n def roll_n(self):\n self.top, self.north, self.bottom, self.south = self.south, self.top, self.north, self.bottom\n\n def roll_e(self):\n self.top, self.east, self.bottom, self.west = self.west, self.top, self.east, self.bottom\n\n def twist(self):\n self.north, self.east, self.south, self.west = self.west, self.north, self.east, self.south\n\n def isEqual(self, dice):\n if self.top == dice.top and self.south == dice.south and self.east == dice.east and self.west == dice.west and self.north == dice.north and self.bottom == dice.bottom:\n return True\n else:\n return False\n\ndice1 = Dice(map(int,input().split()))\ndice2 = Dice(map(int,input().split()))\n\nflag = False\n\nfor i in range(6):\n if i%2 == 0:\n dice1.roll_n()\n else:\n dice1.roll_e()\n\n for j in range(4):\n if dice1.isEqual(dice2):\n flag = True\n else:\n dice1.twist\n\n if flag:\n break\n\nif flag:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 1.0, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [435, 431], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u589886885", "n_user": "u589886885", "pos": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n\ndef main():\n f = [int(x) for x in input().split()]\n s = [int(x) for x in input().split()]\n dice = Dice(f)\n labels = []\n for i in range(6):\n if i < 4:\n dice.north()\n elif i == 4:\n dice.east()\n dice.south()\n elif i == 5:\n dice.south()\n dice.south()\n for j in range(4):\n dice.west()\n labels.append(dice.label)\n if s in labels:\n print('Yes')\n else:\n print('No')\n\n\nif __name__ == '__main__':\n main()", "neg": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n\ndef main():\n f = [int(x) for x in input().split()]\n s = [int(x) for x in input().split()]\n dice = Dice(f)\n labels = []\n for i in range(4):\n dice.north()\n labels.append(dice.label)\n for i in range(3):\n dice.west()\n if i != 1:\n labels.append(dice.label)\n if s in labels:\n print('Yes')\n else:\n print('No')\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9259259259259259, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [365, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u589886885", "n_user": "u589886885", "pos": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def rotate(self):\n self.change([1, 4, 2, 5, 3, 6])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n def is_same_dice(self, another_dice):\n for i in range(6):\n if i % 2 == 0:\n self.north()\n else:\n self.west()\n for j in range(4):\n self.rotate()\n if self.label == another_dice:\n return True\n return False\n\n\ndef main():\n f = [int(x) for x in input().split()]\n s = [int(x) for x in input().split()]\n\n if Dice(f).is_same_dice(s):\n print('Yes')\n else:\n print('No')\n\n\nif __name__ == '__main__':\n main()", "neg": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def rotate(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n def is_same_dice(self, another_dice):\n for i in range(6):\n if i % 2 == 0:\n self.north()\n else:\n self.west()\n for j in range(4):\n self.rotate()\n if self.label == another_dice:\n return True\n return False\n\n\ndef main():\n f = [int(x) for x in input().split()]\n s = [int(x) for x in input().split()]\n\n if Dice(f).is_same_dice(s):\n print('Yes')\n else:\n print('No')", "jacc_sim": 0.9649122807017544, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [379, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u073709667", "n_user": "u073709667", "pos": "def N():\n num=Dice[0]\n Dice[0]=Dice[1]\n Dice[1]=Dice[5]\n Dice[5]=Dice[4]\n Dice[4]=num\ndef E():\n num=Dice[0]\n Dice[0]=Dice[3]\n Dice[3]=Dice[5]\n Dice[5]=Dice[2]\n Dice[2]=num\ndef W():\n num=Dice[0]\n Dice[0]=Dice[2]\n Dice[2]=Dice[5]\n Dice[5]=Dice[3]\n Dice[3]=num\ndef S():\n num=Dice[0]\n Dice[0]=Dice[4]\n Dice[4]=Dice[5]\n Dice[5]=Dice[1]\n Dice[1]=num\nDice=[int(i) for i in input().split()]\nDice2=[int(i) for i in input().split()]\nif (Dice[0] in Dice2)==False:\n print('No')\nelse:\n for j in range(6):\n if j%2==0:\n N()\n else:\n W()\n for i in range(4):\n N()\n W()\n S()\n if Dice==Dice2:\n break\n if Dice==Dice2:\n break \n if Dice==Dice2:\n print('Yes')\n else:\n print('No')", "neg": "def N():\n num=Dice[0]\n Dice[0]=Dice[1]\n Dice[1]=Dice[5]\n Dice[5]=Dice[4]\n Dice[4]=num\ndef E():\n num=Dice[0]\n Dice[0]=Dice[3]\n Dice[3]=Dice[5]\n Dice[5]=Dice[2]\n Dice[2]=num\ndef W():\n num=Dice[0]\n Dice[0]=Dice[2]\n Dice[2]=Dice[5]\n Dice[5]=Dice[3]\n Dice[3]=num\ndef S():\n num=Dice[0]\n Dice[0]=Dice[4]\n Dice[4]=Dice[5]\n Dice[5]=Dice[1]\n Dice[1]=num\nDice=[int(i) for i in input().split()]\nDice2=[int(i) for i in input().split()]\nif (Dice[0] in Dice2)==False:\n print('No')\nelse:\n count=0\n for j in range(12):\n if count%2==0:\n N()\n else:\n W()\n count+=1\n for i in range(4):\n N()\n W()\n S()\n if Dice==Dice2:\n break\n if Dice==Dice2:\n print('Yes')\n else:\n print('No')", "jacc_sim": 0.9047619047619048, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [404, 402], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u494314211", "n_user": "u494314211", "pos": "d1=list(map(int,input().split()))\nd2=list(map(int,input().split()))\n\nclass dice(object):\n\tdef __init__(self, d):\n\t\tself.d = d\n\n\tdef roll(self,com):\n\t\ta1,a2,a3,a4,a5,a6=self.d\n\t\tif com==\"E\":\n\t\t\tself.d = [a4,a2,a1,a6,a5,a3]\n\t\telif com==\"W\":\n\t\t\tself.d = [a3,a2,a6,a1,a5,a4]\n\t\telif com==\"S\":\n\t\t\tself.d = [a5,a1,a3,a4,a6,a2]\n\t\telif com==\"N\":\n\t\t\tself.d = [a2,a6,a3,a4,a1,a5]\n\ndice1=dice(d1)\ndice2=dice(d2)\n\nif sorted(d1)!=sorted(d2):\n\tprint(\"No\")\nelse:\n\tc=[\"E\",\"W\",\"S\",\"N\"]\n\timport random\n\tn=0\n\twhile n<10**5:\n\t\tif dice1.d==dice2.d:\n\t\t\tbreak \n\t\telse:\n\t\t\tdice1.roll(c[random.randint(1,2)])\n\t\tn+=1\n\tif n==10**5:\n\t\tprint(\"No\")\n\telse:\n\t\tprint(\"Yes\")", "neg": "d1=list(map(int,input().split()))\nd2=list(map(int,input().split()))\n\nclass dice(object):\n\tdef __init__(self, d):\n\t\tself.d = d\n\n\tdef roll(self,com):\n\t\ta1,a2,a3,a4,a5,a6=self.d\n\t\tif com==\"E\":\n\t\t\tself.d = [a4,a2,a1,a6,a5,a3]\n\t\telif com==\"W\":\n\t\t\tself.d = [a3,a2,a6,a1,a5,a4]\n\t\telif com==\"S\":\n\t\t\tself.d = [a5,a1,a3,a4,a6,a2]\n\t\telif com==\"N\":\n\t\t\tself.d = [a2,a6,a3,a4,a1,a5]\n\ndice1=dice(d1)\ndice2=dice(d2)\n\nif sorted(d1)!=sorted(d2):\n\tprint(\"No\")\nelse:\n\tc=[\"E\",\"W\",\"S\",\"N\"]\n\timport random\n\tfor i in l:\n\t\tn=0\n\t\twhile n<10**5:\n\t\t\tif dice1.d==dice2.d:\n\t\t\t\tbreak \n\t\t\telse:\n\t\t\t\tdice1.roll(c[random.randint(1,2)])\n\t\t\tn+=1\n\t\tif n>10**5:\n\t\t\tprint(\"No\")\n\t\telse:\n\t\t\tprint(\"Yes\")", "jacc_sim": 0.9230769230769231, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [387, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u203261375", "n_user": "u203261375", "pos": "import random\n\n\nclass Dice(object):\n def __init__(self):\n self.t = 1\n self.s = 2\n self.e = 3\n self.w = 4\n self.n = 5\n self.b = 6\n\n def __init__(self, faces):\n self.t = faces[0]\n self.s = faces[1]\n self.e = faces[2]\n self.w = faces[3]\n self.n = faces[4]\n self.b = faces[5]\n\n def roll(self, direct):\n if direct == 0:\n self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b\n elif direct == 1:\n self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b\n elif direct == 2:\n self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n\n\n def is_equal(self, dice):\n if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:\n return True\n else:\n return False\n\nfaces1 = list(map(int, input().split()))\ndice1 = Dice(faces1)\nfaces2 = list(map(int, input().split()))\ndice2 = Dice(faces2)\n\nflag = False\n\nfor i in range(10000):\n dice2.roll(random.randint(0, 3))\n if dice1.is_equal(dice2):\n flag = True\n break\n\nif flag:\n print('Yes')\nelse:\n print('No')\n\n", "neg": "import random\n\n\nclass Dice(object):\n def __init__(self):\n self.t = 1\n self.s = 2\n self.e = 3\n self.w = 4\n self.n = 5\n self.b = 6\n\n def __init__(self, faces):\n self.t = faces[0]\n self.s = faces[1]\n self.e = faces[2]\n self.w = faces[3]\n self.n = faces[4]\n self.b = faces[5]\n\n def roll(self, direct):\n if direct == 0:\n self.t, self.s, self.b, self.n = self.n, self.t, self.s, self.b\n elif direct == 1:\n self.t, self.w, self.b, self.e = self.e, self.t, self.w, self.b\n elif direct == 2:\n self.n, self.w, self.s, self.e = self.w, self.s, self.e, self.n\n\n def is_equal(dice):\n if self.t == dice.t and self.s == dice.s and self.e == dice.e and self.w == dice.w and self.n == dice.n and self.b == dice.b:\n return True\n else:\n return False\n\nfaces1 = list(map(int, input().split()))\ndice1 = Dice(faces1)\nfaces2 = list(map(int, input().split()))\ndice2 = Dice(faces2)\n\nflag = False\n\nfor i in range(10000):\n dice2.roll(random.randint(0, 3))\n if dice1.is_equal(dice2):\n flag = True\n break\n\nif flag:\n print('Yes')\nelse:\n print('No')\n\n", "jacc_sim": 1.0, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [475, 473], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u150984829", "n_user": "u150984829", "pos": "d,e=[list(map(int,input().split()))for _ in range(2)];e[3],e[4]=e[4],e[3]\nt=0\nm={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}\nfor i in range(6):\n f=[d[int(j)]for j in m[i]];f[3],f[4]=f[4],f[3]\n if f[0]==e[0]:\n f=f[1:5]*2\n for j in range(4):\n if f[j:j+4]==e[1:5]:t=1\nprint(('No','Yes')[t])\n", "neg": "d,e=[list(map(int,input().split()))for _ in range(2)];e[3],e[4]=e[4],e[3]\nt=0\nm={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'}\nfor i in range(6):\n f=[d[int(j)]for j in m[i]];f[3],f[4]=f[4],f[3]\n f=f[1:5]*2\n for j in range(4):\n if f[j:j+4]==e[1:5]:t=1\nprint(('No','Yes')[t==1])\n", "jacc_sim": 1.0, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [193, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02385", "p_user": "u908651435", "n_user": "u908651435", "pos": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.t = t\n self.f = f\n self.r = r\n self.l = l\n self.b = b\n self.u = u\n self.a=[t,f,r,l,b,u]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d):\n self.a=[self.a[i] for i in self.direction[d]]\n self.t = self.a[0]\n self.f = self.a[1]\n self.r = self.a[2]\n self.l = self.a[3]\n self.b = self.a[4]\n self.u = self.a[5]\nt,f,r,l,b,u=map(int,input().split())\ndice1=Dice(t,f,r,l,b,u)\nt,f,r,l,b,u=map(int,input().split())\ndice2=Dice(t,f,r,l,b,u)\ns='SSSEWWW'\nw='YYYY'\nans='No'\nfor j in s:\n for r in w:\n if dice1.a==dice2.a:\n ans='Yes'\n break\n dice2.roll(r)\n else:\n dice2.roll(j)\n continue\n break\nprint(ans)\n", "neg": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.t = t\n self.f = f\n self.r = r\n self.l = l\n self.b = b\n self.u = u\n self.a=[t,f,r,l,b,u]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d):\n self.a=[self.a[i] for i in self.direction[d]]\n self.t = self.a[0]\n self.f = self.a[1]\n self.r = self.a[2]\n self.l = self.a[3]\n self.b = self.a[4]\n self.u = self.a[5]\nt,f,r,l,b,u=map(int,input().split())\ndice1=Dice(t,f,r,l,b,u)\nt,f,r,l,b,u=map(int,input().split())\ndice2=Dice(t,f,r,l,b,u)\ns='SSSEWW'\nw='YYY'\nans='No'\nfor j in s:\n for r in w:\n if dice1.a==dice2.a:\n ans='Yes'\n break\n dice2.roll(r)\n else:\n dice2.roll(j)\n continue\n break\nprint(ans)\n", "jacc_sim": 0.9344262295081968, "nl": "Dice III: Write a program to determine if two dice are identical. Input consists of two lines, each containing six integers representing the faces of a dice. Output \"Yes\" if the two dices are identical, otherwise output \"No\". Constraints: $0 \\leq $ the integer assigned to a face $ \\leq 100$. Example input and output are provided for reference.", "before_after_length": [446, 445], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u589886885", "n_user": "u589886885", "pos": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def rotate(self):\n self.change([1, 4, 2, 5, 3, 6])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n def is_same_dice(self, another_dice):\n for i in range(6):\n if i % 2 == 0:\n self.north()\n else:\n self.west()\n for j in range(4):\n self.rotate()\n if self.label == another_dice:\n return True\n return False\n\n\ndef main():\n dices = []\n n = int(input())\n for i in range(n):\n dices.append(Dice([int(x) for x in input().split()]))\n\n flag = False\n for i in range(n):\n j = i + 1\n while j < n:\n if dices[i].is_same_dice(dices[j].label):\n flag = True\n break\n j += 1\n\n if flag:\n print('No')\n else:\n print('Yes')\n\n\nif __name__ == '__main__':\n main()", "neg": "class Dice():\n\n def __init__(self, label):\n self.label = label\n\n def north(self):\n self.change([2, 6, 3, 4, 1, 5])\n\n def west(self):\n self.change([3, 2, 6, 1, 5, 4])\n\n def east(self):\n self.change([4, 2, 1, 6, 5, 3])\n\n def south(self):\n self.change([5, 1, 3, 4, 6, 2])\n\n def rotate(self):\n self.change([1, 4, 2, 5, 3, 6])\n\n def change(self, convert):\n num = []\n for i in range(6):\n num.append(self.label[convert[i] - 1])\n self.label = num\n\n def is_same_dice(self, another_dice):\n for i in range(6):\n if i % 2 == 0:\n self.north()\n else:\n self.west()\n for j in range(4):\n self.rotate()\n if self.label == another_dice:\n return True\n return False\n\n\ndef main():\n dices = []\n n = int(input())\n for i in range(n):\n dices.append(Dice([int(x) for x in input().split()]))\n\n flag = False\n for i in range(n):\n j = i + 1\n while j < n:\n if dices[i].is_same_dice(dices[j]):\n flag = True\n break\n j += 1\n\n if flag:\n print('No')\n else:\n print('Yes')\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [442, 441], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u831244171", "n_user": "u831244171", "pos": "n = int(input())\n\ndef rot(dice,rotation):\n if rotation == \"E\":\n dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])\n elif rotation == \"W\":\n dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])\n elif rotation == \"N\":\n dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])\n elif rotation == \"S\":\n dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])\n return dice\n\ndef make_all_pattern(dice):\n pattern = {dice}\n pattern2 = pattern\n while True:\n pattern2 = pattern.union({rot(d,r) for d in pattern for r in list(\"NEWS\")})\n if pattern2 == pattern:\n break\n pattern = pattern2\n return pattern\n\ndice = [0 for i in range(n)]\nfor i in range(n):\n dice[i] = tuple(map(int,input().split()))\n\n\npattern = set()\nfor i in range(n-1):\n pattern = pattern.union(make_all_pattern(dice[i]))\n if dice[i+1] in pattern:\n print(\"No\")\n break\n\nelse:\n print(\"Yes\")\n ", "neg": "n = int(input())\n\ndef rot(dice,rotation):\n if rotation == \"E\":\n dice = (dice[3],dice[1],dice[0],dice[5],dice[4],dice[2])\n elif rotation == \"W\":\n dice = (dice[2],dice[1],dice[5],dice[0],dice[4],dice[3])\n elif rotation == \"N\":\n dice = (dice[1],dice[5],dice[2],dice[3],dice[0],dice[4])\n elif rotation == \"S\":\n dice = (dice[4],dice[0],dice[2],dice[3],dice[5],dice[1])\n return dice\n\ndef make_all_pattern(dice):\n pattern = {dice}\n pattern2 = pattern\n while True:\n pattern2 = pattern.union({rot(d,r) for d in pattern for r in list(\"NEWS\")})\n if pattern2 == pattern:\n break\n pattern = pattern2\n return pattern\n\ndice = [0 for i in range(n)]\nfor i in range(n):\n dice[i] = tuple(map(int,input().split()))\n\nfor j in range(1):\n if n > 24:\n print(\"No\")\n break\n pattern = set()\n for i in range(n-1):\n pattern = pattern.union(make_all_pattern(dice[i]))\n if dice[i] in pattern:\n print(\"No\")\n break\n else:\n print(\"Yes\")\n ", "jacc_sim": 0.9322033898305084, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [388, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u024715419", "n_user": "u024715419", "pos": "class dice:\n def __init__(self, pip):\n self.pip = pip\n \n def move(self,dir):\n if str(dir) == \"E\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]\n elif str(dir) == \"W\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]\n elif str(dir) == \"N\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]\n elif str(dir) == \"S\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]\n\nn = int(input())\nans = \"Yes\"\nds =[]\n\nfor i in range(n):\n ds.append(dice(list(map(int,input().split()))))\n\nfor i in range(len(ds)-1):\n for j in range(i+1,len(ds)):\n d_tmp = dice(ds[j].pip)\n for op in \"EEENEEENEEESEEESEEENEEEN\":\n if ds[i].pip == d_tmp.pip:\n ans = \"No\"\n break\n d_tmp.move(op)\n\nprint(ans)", "neg": "class dice:\n def __init__(self, pip):\n self.pip = pip\n \n def move(self,dir):\n if str(dir) == \"E\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[3],self.pip[0],self.pip[5],self.pip[2]\n elif str(dir) == \"W\":\n self.pip[0],self.pip[2],self.pip[3],self.pip[5] = self.pip[2],self.pip[5],self.pip[0],self.pip[3]\n elif str(dir) == \"N\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[1],self.pip[5],self.pip[0],self.pip[4]\n elif str(dir) == \"S\":\n self.pip[0],self.pip[1],self.pip[4],self.pip[5] = self.pip[4],self.pip[0],self.pip[5],self.pip[1]\n\nn = int(input())\nans = \"Yes\"\nds =[]\n\nfor i in range(n):\n ds.append(dice(list(map(int,input().split()))))\n\nfor i in range(len(ds)-1):\n for j in range(i+1,len(ds)):\n d_tmp = dice(ds[j].pip)\n for op in \"EEENEEENEEESEEESEEENEEEN\":\n if ds[i].pip == d_tmp.pip:\n ans = \"No\"\n break\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [434, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u440180827", "n_user": "u440180827", "pos": "def compare(x, y):\n for i in range(6):\n order = [0, 0, 0]\n for j in range(3):\n if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:\n break\n if x[j] == y[z[i][j]]:\n order[j] = 1 \n if x[j] == x[-j-1]:\n order[j] = 2 \n else:\n if 2 in order or z[i][3] == sum(order) % 2:\n return True\n break\n return False\n \nn = int(input())\nx = [[] for i in range(n)]\nfor i in range(n):\n x[i] = list(map(int, input().split()))\nz = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]\ndifferent = True\nfor i in range(n):\n for j in range(i+1, n, 1): \n if compare(x[i], x[j]):\n break\n else:\n continue\n print('No')\n break\nelse:\n print('Yes')", "neg": "n = int(input())\nx = [[] for i in range(n)]\nfor i in range(n):\n x[i] = list(map(int, input().split()))\nz = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]\n\ndef compare(x, y):\n succeed = False\n for i in range(6):\n match = True\n order = [0, 0, 0]\n for j in range(3):\n if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:\n match = False\n break\n if x[j] == y[z[i][j]]:\n order[j] = 1\n if x[j] == x[-j-1]:\n order[j] = 2\n if match:\n if 2 in order:\n succeed = True\n break\n if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2:\n succeed = True\n break\n if z[i][3] == 1 and not sum(order) % 2:\n succeed = True\n break\n if succeed:\n return True\n else:\n return False\n\ndifferent = True\nfor i in range(n):\n for j in range(i+1, n, 1):\n if compare(x[i], x[j]):\n print(i, j)\n different = False\n break\n if not different:\n break\nif different:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9074074074074074, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [332, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nn=int(input())\na=[list(map(int,input().split()))for _ in range(n)]\nfor i in range(n-1):\n d=a[i][:];d[3],d[4]=d[4],d[3]\n for j in range(i+1,n):\n e=a[j][:];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 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]:print('No');sys.exit()\nprint('Yes')\n", "neg": "n=int(input())\na=[list(map(int,input().split()))for _ in range(n)]\nfor k in range(n):\n b=a[k];b[3],b[4]=b[4],b[3]\nt=0\nfor i in range(n-1):\n d=a[i]\n for j in range(i+1,n):\n e=a[j]\n for p in('012345','152043','215304','302541','410352','514320'):\n f=[d[int(k)]for k in p]\n if f[0]==e[0]and f[5]==e[5]:\n f=f[1:5]*2\n [t=1 for k in range(4)if f[k:k+4]==e[1:5]]\nprint(('Yes','No')[t])\n", "jacc_sim": 0.9056603773584906, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [226, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u150984829", "n_user": "u150984829", "pos": "n=int(input())\na=[list(map(int,input().split()))for _ in range(n)]\ndef f():\n for i in range(n-1):\n d=a[i][:];d[3],d[4]=d[4],d[3]\n for j in range(i+1,n):\n e=a[j][:];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 if(f[0]==e[0])*(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]:return'No'\n return'Yes'\nprint(f())\n", "neg": "n=int(input())\na=[list(map(int,input().split()))for _ in range(n)]\nfor k in range(n):\nb=a[k];b[3],b[4]=b[4],b[3]\ndef f():\n for i in range(n-1):\n d=a[i]\n for j in range(i+1,n):\n e=a[j]\n for p in('012345','152043','215304','302541','410352','514320'):\n f=[d[int(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]:return 'No'\n return 'Yes'\nprint(f())\n", "jacc_sim": 0.9607843137254902, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [232, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u179070318", "n_user": "u179070318", "pos": "import itertools\nclass dice():\n def __init__(self,number):\n self.number = number\n \n def korokoro(self,com):\n if com == 'E':\n self.number = [self.number[i] for i in [3,1,0,5,4,2]]\n if com == 'S':\n self.number = [self.number[i] for i in [4,0,2,3,5,1]]\n if com == 'N':\n self.number = [self.number[i] for i in [1,5,2,3,0,4]]\n if com == 'W':\n self.number = [self.number[i] for i in [2,1,5,0,4,3]]\ndef checker(d1,d2):\n for com in 'EEEENEEEENEEEENEEEENWSEEEENNEEEE':\n d1.korokoro(com)\n if d1.number == d2.number:\n ans = 'Yes'\n break\n else:\n ans = 'No'\n return ans\nn = int(input())\nsaikoro = {}\nfor _ in range(n):\n saikoro[_] = dice([int(x) for x in input().split()])\nl = list(itertools.combinations(saikoro.keys(),2))\nfor __ in l:\n test1 = saikoro[__[0]]\n test2 = saikoro[__[1]]\n if checker(test1,test2) == 'Yes':\n answer = 'No'\n break\n else:\n answer = 'Yes'\nprint(answer)\n\n", "neg": "import itertools\nclass dice():\n def __init__(self,number):\n self.number = number\n\n def korokoro(self,com):\n if com == 'E':\n self.number = [self.number[i] for i in [3,1,0,5,4,2]]\n if com == 'S':\n self.number = [self.number[i] for i in [4,0,2,3,5,1]]\n if com == 'N':\n self.number = [self.number[i] for i in [1,5,2,3,0,4]]\n if com == 'W':\n self.number = [self.number[i] for i in [2,1,5,0,4,3]]\ndef checker(d1,d2):\n for com in 'EEEENEEEENEEEENEEEENWSEEEENNEEEE':\n d1.korokoro(com)\n if d1.number == d2.number:\n ans = 'Yes'\n break\n else:\n ans = 'No'\n return ans\nn = int(input())\nsaikoro = {}\nfor _ in range(n):\n saikoro[_] = dice([int(x) for x in input().split()])\nl = list(itertools.combinations(saikoro.keys(),2))\nfor __ in l:\n test1 = saikoro[__[0]]\n test2 = saikoro[__[1]]\n if checker(test1,test2) == 'Yes':\n answer = 'Yes'\n break\n else:\n anser = 'No'\nprint(answer)\n\n", "jacc_sim": 0.9841269841269841, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [419, 420], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u566311709", "n_user": "u566311709", "pos": "p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),\n(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]\n\ndef is_equal(d, a):\n ts = [i for i, x in enumerate(d) if x == a[0]]\n fs = [i for i, x in enumerate(d) if x == a[1]]\n b = 0\n for t in ts:\n for f in fs:\n if t == f: continue\n r = p[t][f]\n if r == -1: continue\n l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]\n if a == l: b += 1; break\n return 1 if b > 0 else 0\n\nl = []\nb = 0\nfor _ in range(int(input())):\n l += [input().split()]\nfor i in range(0, len(l)):\n for j in range(i+1, len(l)):\n b += is_equal(l[i], l[j])\n if b > 0: break\nprint(\"No\") if b > 0 else print(\"Yes\")\n", "neg": "p = [(-1, 2, 4, 1, 3, -1), (3, -1, 0, 5, -1, 2), (1, 5, -1, -1, 0, 4),\n(4, 0, -1, -1, 5, 1), (2, -1, 5, 0, -1, 3), (-1, 3, 1, 4, 2, -1)]\n\ndef is_equal(d, a):\n ts = [i for i, x in enumerate(d) if x == a[0]]\n fs = [i for i, x in enumerate(d) if x == a[1]]\n b = 0\n for t in ts:\n for f in fs:\n if t == f: continue\n r = p[t][f]\n if r == -1: continue\n l = [d[t], d[f], d[r], d[5-r], d[5-f], d[5-t]]\n if a == l: b += 1; break\n return 1 if b > 0 else 0\n\nl = []\nb = 0\nfor _ in range(int(input())):\n l += [input().split()]\nfor i in range(0, len(l)):\n for j in range(i+1, len(l)):\n b = is_equal(l[i], l[j])\n if b > 0: break\nprint(\"No\") if b > 0 else print(\"Yes\")\n", "jacc_sim": 1.0, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [349, 349], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u150984829", "n_user": "u150984829", "pos": "from itertools import*\nn=int(input())\na=[input().split()for _ in[0]*n]\nfor b in a:\n b[3:5]=b[4],b[3]\ndef g():\n for d,e in combinations(a,2):\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 f=[d[i]for i in p]\n if 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]:return'No'\n return'Yes'\nprint(g())\n", "neg": "def g():\n from itertools import*\n n=int(input())\n a=[input().split()for _ in[0]*n]\n for b in a:\n b[3:5]=b[4],b[3]\n for d,e in combinations(a,2):\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 f=[d[i]for i 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]:return'No'\n return'Yes'\nprint(g())\n", "jacc_sim": 0.9777777777777777, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [228, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u908651435", "n_user": "u908651435", "pos": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.a=[[t,f,r,l,b,u]]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d,n):\n self.a[n]=[self.a[n][i] for i in self.direction[d]]\nn=int(input())\nfor i in range(n):\n if i==0:\n t, f, r, l, b, u = map(int, input().split())\n dice = Dice(t, f, r, l, b, u)\n else:\n a = list(map(int, input().split()))\n dice.a.append(a)\ns='SSSWEEE'\nw='YYYY'\nans='Yes'\nfor u in range(n-1):\n for t in range(u+1,n):\n for j in s:\n for r in w:\n if dice.a[t]==dice.a[u]:\n ans='No'\n break\n dice.roll(r,t)\n else:\n dice.roll(j,t)\n continue\n break\n else:\n continue\n break\n else:\n continue\n break\nprint(ans)\n", "neg": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.a=[[t,f,r,l,b,u]]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d,n):\n self.a[n]=[self.a[n][i] for i in self.direction[d]]\n self.t = self.a[0]\n self.f = self.a[1]\n self.r = self.a[2]\n self.l = self.a[3]\n self.b = self.a[4]\n self.u = self.a[5]\nn=int(input())\nfor i in range(n):\n if i==0:\n t,f,r,l,b,u = map(int, input().split())\n dice = Dice(t, f, r, l, b, u)\n else:\n a = list(map(int, input().split()))\n dice.a.append(a)\ns='SSSWEEE'\nw='YYYY'\nans='Yes'\nfor u in range(n-1):\n for t in range(u+1,n):\n for j in s:\n for r in w:\n if dice.a[t]==dice.a[u]:\n ans='No'\n break\n dice.roll(r,t)\n else:\n dice.roll(j,t)\n continue\n break\n else:\n continue\n break\n else:\n continue\n break\nprint(ans)\n\n", "jacc_sim": 1.0, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [401, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u908651435", "n_user": "u908651435", "pos": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.a=[[t,f,r,l,b,u]]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d,n):\n self.a[n]=[self.a[n][i] for i in self.direction[d]]\nn=int(input())\nfor i in range(n):\n if i==0:\n t, f, r, l, b, u = map(int, input().split())\n dice = Dice(t, f, r, l, b, u)\n else:\n a = list(map(int, input().split()))\n dice.a.append(a)\ns='SSSWEEE'\nw='YYYY'\ntry:\n for u in range(n - 1):\n for t in range(u + 1, n):\n for j in s:\n for r in w:\n if dice.a[t] == dice.a[u]:\n raise Exception\n dice.roll(r, t)\n dice.roll(j, t)\n else:\n print('Yes')\nexcept:\n print('No')\n", "neg": "class Dice:\n def __init__(self,t,f,r,l,b,u):\n self.a=[[t,f,r,l,b,u]]\n self.direction={'S':(4,0,2,3,5,1),'N':(1,5,2,3,0,4),'E':(3,1,0,5,4,2),'W':(2,1,5,0,4,3),'Y':(0,3,1,4,2,5)}\n def roll(self,d,n):\n self.a[n]=[self.a[n][i] for i in self.direction[d]]\n self.t = self.a[0]\n self.f = self.a[1]\n self.r = self.a[2]\n self.l = self.a[3]\n self.b = self.a[4]\n self.u = self.a[5]\nn=int(input())\nfor i in range(n):\n if i==0:\n t,f,r,l,b,u = map(int, input().split())\n dice = Dice(t, f, r, l, b, u)\n else:\n a = list(map(int, input().split()))\n dice.a.append(a)\ns='SSSWEEE'\nw='YYYY'\nans='Yes'\ntry:\n for u in range(n-1):\n for t in range(u+1, n):\n for j in s:\n for r in w:\n print(dice.a[t],dice.a[u])\n if dice.a[t] == dice.a[u]:\n ans = 'No'\n raise Exception\n dice.roll(r, t)\n dice.roll(j, t)\nexcept Exception:\n pass\nprint(ans)\n\n\n", "jacc_sim": 0.9701492537313433, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [379, 476], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u420937248", "n_user": "u150984829", "pos": "def f():\n for c in range(n):\n for d in a[c+1:]:\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 if[d[p[0]],d[p[5]]]==a[c][::5]:\n b=[d[i]for i in p[1:5]]*2\n for k in range(4):\n if b[k:k+4]==a[c][1:5]:return\"No\"\n return\"Yes\"\nn=int(input())\na=[input().split()for _ in[0]*n]\nfor b in a:b[3:5]=b[4],b[3]\nprint(f())\n\n", "neg": "def f():\n for c in range(n):\n for d in a[c+1:]:\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 if[d[p[0]],d[p[5]]]==a[c][::5]:\n b=[d[i]for i in p[1:5]]\n for k in range(4):\n if b[k-4:k-1]==a[c][1:5]:return\"No\"\n return\"Yes\"\nn=int(input())\na=[input().split()for _ in[0]*n]\nfor b in a:b[3:5]=b[4],b[3]\nprint(f())\n", "jacc_sim": 0.975, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [240, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02386", "p_user": "u897466764", "n_user": "u567380442", "pos": "mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]\nmask += [[mask[1][i] for i in mask[1]]]\n\ndef set_top(dice, top):\n return [dice[i] for i in mask[top]]\n\ndef twist(dice):\n return [dice[i] for i in (0, 3, 1, 4, 2, 5)]\n\ndef equal(dice1, dice2):\n if sorted(dice1) != sorted(dice2):\n return False\n \n for i in range(6):\n tmp_dice = set_top(dice2, i)\n for _ in range(4):\n if dice1 == tmp_dice:\n return True\n tmp_dice = twist(tmp_dice)\n return False\n\ndef diff_check_all(dices, n):\n for i in range(n -1):\n for j in range(i + 1, n):\n if equal(dices[i], dices[j]):\n return False\n return True\n \n\nn = int(input())\ndices = [input().split() for _ in range(n)]\n\nprint('Yes' if diff_check_all(dices, n) else 'No')\n", "neg": "mask = [[i for i in range(6)], (1, 5, 2, 3, 0, 4), (2, 1, 5, 0, 4,3),(3, 1, 0, 5, 4, 2), (4, 0, 2, 3, 5, 1)]\nmask += [[mask[1][i] for i in mask[1]]]\n\ndef set_top(dice, top):\n return [dice[i] for i in mask[top]]\n\ndef twist(dice):\n return [dice[i] for i in (0, 3, 1, 4, 2, 5)]\n\ndef equal(dice1, dice2):\n if sorted(dice1) != sorted(dice2):\n return False\n \n for i in range(6):\n if i:tmp_dice = set_top(dice2, i)\n for j in range(4):\n if j:tmp_dice = twist(tmp_dice)\n if dice1 == tmp_dice:\n return True\n return False\n\ndef diff_check_all(dices, n):\n for i in range(n -1):\n for j in range(i + 1, n):\n if equal(dices[i], dices[j]):\n return False\n return True\n \n\nn = int(input())\ndices = [input().split() for _ in range(n)]\n\nprint('Yes' if diff_check_all(dices, n) else 'No')", "jacc_sim": 1.0, "nl": "Dice IV: Write a program to determine if a given set of dice are all different. The input consists of the number of dice, followed by the face values of each die. Output \"Yes\" if the dice are all different, otherwise output \"No\". Constraints: 2 \u2264 n \u2264 100, 0 \u2264 face value \u2264 100.", "before_after_length": [360, 365], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u634490486", "n_user": "u634490486", "pos": "from sys import stdin\n\ns = list(stdin.readline())\nfor i in range(len(s)):\n if s[i].islower():\n s[i] = s[i].upper()\n elif s[i].isupper():\n s[i] = s[i].lower()\n\nprint(*s, sep=\"\", end=\"\")\n", "neg": "from sys import stdin\n\ns = list(stdin.readline())\nprint(s)\nfor i in range(len(s)):\n if s[i].islower():\n s[i] = s[i].upper()\n elif s[i].isupper():\n s[i] = s[i].lower()\n\nprint(*s, sep=\"\")\n", "jacc_sim": 0.967741935483871, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [85, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u297342993", "n_user": "u823030818", "pos": "text = input()\n\nresult = ''\n\nfor i in range(len(text)):\n code = ord(text[i])\n if ord('A') <= code <= ord('Z'):\n result += chr(code + 32)\n elif ord('a') <= code <= ord('z'):\n result += chr(code - 32)\n else:\n result += chr(code)\n\nprint(result)", "neg": "text = input()\n\nfor i in range(len(text)):\n code = ord(text[i])\n if ord('A') <= code <= ord('Z'):\n result += chr(code + 32)\n elif ord('a') <= code <= ord('z'):\n result += chr(code - 32)\n else:\n result += chr(code)\n\nprint(result)", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [99, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u756468156", "n_user": "u756468156", "pos": "string = input()\nfor i in string:\n if i.isupper():\n print(i.lower(), end = \"\")\n elif i.islower():\n print(i.upper(), end = \"\")\n else:\n print(i, end = \"\")\nprint()", "neg": "string = input()\nfor i in string:\n if i.isupper():\n print(i.lower(), end = \"\")\n elif string[i].islower():\n print(i.upper(), end = \"\")\n else:\n print(i, end = \"\")", "jacc_sim": 0.9130434782608695, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [67, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u106285852", "n_user": "u106285852", "pos": "'''\nITP-1_8-A\n ??\u00a7????????\u00a8?\u00b0????????????\\?????????\n????????????????????????????\u00b0?????????\u00a8??\u00a7???????????\\????????????????????\u00b0????????????????????????????????????\n???Input\n????????????1???????????????????????????\n???Output\n????????????????????????????\u00b0?????????\u00a8??\u00a7???????????\\????????????????????????????????????????????????\n??\u00a2????????????????????\\???????????????????????????????????????????????????\n'''\n# inputData\ninputData = input()\n\nfor i in range(len(inputData)):\n if \"a\"<=inputData[i]<=\"z\":\n # ??\u00a7????????????\n print(inputData[i].upper(),end='')\n elif \"A\"<=inputData[i]<=\"Z\":\n # ?\u00b0?????????????\n print(inputData[i].lower(),end='')\n else:\n # ??\u00a2????????????????????\\?????????????????????\n print(inputData[i],end='')\n\n# ????????????\nprint('')", "neg": "'''\nITP-1_8-A\n ??\u00a7????????\u00a8?\u00b0????????????\\?????????\n????????????????????????????\u00b0?????????\u00a8??\u00a7???????????\\????????????????????\u00b0????????????????????????????????????\n???Input\n????????????1???????????????????????????\n???Output\n????????????????????????????\u00b0?????????\u00a8??\u00a7???????????\\????????????????????????????????????????????????\n??\u00a2????????????????????\\???????????????????????????????????????????????????\n'''\n# inputData\ninputData = input()\n\nfor i in range(len(inputData)):\n if \"a\"<=inputData[i]<=\"z\":\n # ??\u00a7????????????\n print(inputData[i].upper(),end='')\n elif \"A\"<=inputData[i]<=\"Z\":\n # ?\u00b0?????????????\n print(inputData[i].lower(),end='')", "jacc_sim": 0.975609756097561, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [394, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u150984829", "n_user": "u150984829", "pos": "s=input();u=s.upper();l=s.lower()\nprint(''.join([(u[i],l[i])[s[i]==u[i]]for i in range(len(s))]))", "neg": "s=input();u=s.upper();l=s.lower()\nprint(''.join([(l[i],u[i])[s[i]==u[i]]for i in range(len(s))]))", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [51, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u369093003", "n_user": "u369093003", "pos": "s=input();ans=\"\"\nfor i in range(len(s)):\n if s[i].islower():\n ans+=s[i].upper()\n else:\n ans+=s[i].lower()\nprint(ans)\n", "neg": "s=input();ans=\"\"\nfor i in range(len(s)):\n if s[i].islower():\n ans+=s[i].upper(),end=\"\"\n else:\n ans+=s[i].lower(),end=\"\"\nprint(ans)\n", "jacc_sim": 0.9230769230769231, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [60, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u682153677", "n_user": "u682153677", "pos": "# -*- coding: utf-8 -*-\n\nchar = input()\nprint(char.swapcase())\n", "neg": "# -*- coding: utf-8 -*-\n\nchar = input()\n\nchar.swapcase()\n\nprint(char)\n", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [27, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u350963229", "n_user": "u628732336", "pos": "print(input().swapcase())\n\n\n", "neg": "print(input).swapcase()", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [10, 7], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u350155409", "n_user": "u480053997", "pos": "s = input()\n \nr = \"\"\nfor c in s:\n if c.isupper():\n r += c.lower()\n elif c.islower():\n r += c.upper()\n else:\n r += c\n\nprint(r)\n", "neg": "for c in input():\n if c.islower():\n s += c.upper()\n elif c.isupper():\n s += c.lower()\n else:\n s += c\nprint (s)", "jacc_sim": 0.9047619047619048, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [64, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u150401016", "n_user": "u928633434", "pos": "string = input()\nprint(string.swapcase())\n\n", "neg": "string=input()\nprint(string.swapcase()\n", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [14, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u591403647", "n_user": "u313600138", "pos": "s=input()\nfor c in s:\n if 'A' <= c and c <= 'Z':\n print(c.lower(),end='')\n elif 'a' <= c and c <= 'z':\n print(c.upper(),end='')\n else:\n print(c,end='')\nprint()\n\n", "neg": "s=input()\nfor c in s:\n if 'A' <= c and c <= 'Z':\n print(c.lower(), end='')\n elif 'a' <= c and c <= 'z':\n print(c.upper(), end='')\n else:\n print(c)\n", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [78, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u051789695", "n_user": "u105694406", "pos": "s=input()\nfor i in s:\n if i==i.lower():\n print(i.upper(),end='')\n else:\n print(i.lower(),end='')\nprint()\n", "neg": "s = input()\n\nfor i in s:\n\tif(i.isupper()):\n\t\tprint(i.lower(), end=\"\")\n\telse\n\t\tprint(i.upper(), end=\"\")", "jacc_sim": 0.9473684210526315, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [49, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u182167513", "n_user": "u024715419", "pos": "inp = input()\nprint(inp.swapcase())\n", "neg": "inp = input()\ninp.swapcase()\nprint(inp)", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [13, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u902639104", "n_user": "u661529494", "pos": "a= str(input())\na= str.swapcase(a)\nprint(a)\n", "neg": "a=str(input())\nprint(a.swapcase)", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [22, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u717526540", "n_user": "u283452598", "pos": "s = input()\n\nprint(s.swapcase())\n\n", "neg": "s = input()\ns.swapcase()\nprint(s)", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [15, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02415", "p_user": "u429841998", "n_user": "u391228754", "pos": "a = input()\n\nprint(a.swapcase())\n\n", "neg": "a = input()\na.swapcase()\nprint(a)", "jacc_sim": 1.0, "nl": "Title: Toggling Cases\n\nWrite a program that converts uppercase letters to lowercase and lowercase letters to uppercase for a given string.\n\nInput:\nA string is provided in a line.\n\nOutput:\nPrint the converted string in a line. Note that only alphabetical letters need to be converted.\n\nConstraints:\nThe length of the input string is less than 1200.\n\nSample Input:\nfAIR, LATER, OCCASIONALLY CLOUDY.\n\nSample Output:\nFair, later, occasionally cloudy.", "before_after_length": [15, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u966110132", "n_user": "u966110132", "pos": "go = 1\nwhile go == 1:\n a = str(input())\n alist = list(a)\n if a == \"0\":\n go = 0\n exit\n sum = 0\n for i in alist:\n i = int(i)\n sum += i\n if go == 1:\n print(sum)\n", "neg": "go = 1\nwhile go == 1:\n a = str(input())\n alist = list(a)\n if a ==0:\n go = 0\n exit\n sum = 0\n for i in alist:\n i = int(i)\n sum += i\n if go == 1:\n print(sum)\n", "jacc_sim": 0.9565217391304348, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [82, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u535719732", "n_user": "u535719732", "pos": "while True:\n num = input()\n if(num == \"0\"): break\n ret = 0\n for i in num:\n ret += int(i)\n print(ret)\n", "neg": "while True:\n num = input()\n if(num == 0): break\n ret = 0\n for i in num:\n ret += int(i)\n print(ret)\n", "jacc_sim": 0.9473684210526315, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [47, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u492556875", "n_user": "u492556875", "pos": "import sys\nfrom functools import reduce\nfor line in sys.stdin:\n if int(line) == 0:\n break\n s = reduce(lambda a,b: int(a)+int(b), line.strip())\n print(s)", "neg": "import sys\nfrom functools import reduce\nfor line in sys.stdin:\n if line == \"0\":\n break\n s = reduce(lambda a,b: int(a)+int(b), line.strip())\n print(s)", "jacc_sim": 0.9629629629629629, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [57, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u226888928", "n_user": "u226888928", "pos": "while 1:\n str = input()\n if(str == '0'): break\n print(sum([int(c) for c in list(str)]))", "neg": "while 1:\n str = input()\n if(str == '0'): break\n print(sum([int(c) for c in list(input())]))", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [38, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u671553883", "n_user": "u382316013", "pos": "while True:\n data = input()\n if data == '0':\n break\n \n print(sum([int(i) for i in data]))", "neg": "while True:\n data = int(input())\n if data == 0:\n break\n \n print(sum([int(i) for i in data]))", "jacc_sim": 0.95, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [36, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u391228754", "n_user": "u629874472", "pos": "while True:\n n = []\n n = list(map(int, input()))\n if n == [0]:\n break\n print(sum(n))", "neg": "while True:\n n = list(map(int,input()))\n if n[0] ==0:\n break\n else:\n print(n.sum())\n", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [40, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u801346721", "n_user": "u801346721", "pos": "while 1:\n n = input()\n if int(n) == 0:\n break\n sum = 0\n for i in range(len(n)):\n sum += int(n[i])\n print(sum)", "neg": "while 1:\n n = input()\n if int(n) == 0:\n break\n sum = 0\n for i in range(n):\n sum += int(n[i])\n print(sum)", "jacc_sim": 0.9545454545454546, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [50, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u216804574", "n_user": "u216804574", "pos": "while True:\n x = input()\n if x == '0':\n quit()\n\n print(sum([int(_) for _ in x]))", "neg": "while True:\n x = input()\n if x == 0:\n quit()\n\n print(sum([int(_) for _ in str(x)]))", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [36, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u292012552", "n_user": "u292012552", "pos": "n = input()\nwhile n != \"0\":\n ans = 0\n for i in range(len(n)):\n ans += ord(n[i:i+1]) - 48\n\n print(ans)\n n = input()", "neg": "n = input()\nwhile n != \"0\":\n ans = 0\n for i in range(len(n)):\n print(ord(n[i:i+1]))\n ans += ord(n[i:i+1]) - 48\n\n print(ans)\n n = input()", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [57, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u639421643", "n_user": "u639421643", "pos": "while(1):\n word = input()\n if (word == \"0\"):\n break\n result = 0\n for i in word:\n result += int(i)\n print(result)\n ", "neg": "while(1):\n word = input()\n if (word = \"0\"):\n break\n result = 0\n for i in word:\n result += int(i)\n print(result)\n ", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [51, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u213265973", "n_user": "u213265973", "pos": "while True:\n x = input()\n if x == \"0\":\n break\n num = [int(i) for i in x]\n print(sum(num))", "neg": "while True:\n x = input()\n if x == \"0\":\n break\n num = [int(i) for i in x.split()]\n print(sum(num))", "jacc_sim": 0.9130434782608695, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [42, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u650790815", "n_user": "u650790815", "pos": "while 1:\n s = input()\n if s == '0':break\n print(sum(int(n) for n in s))", "neg": "while 1:\n s = input()\n if s == '0':\n break\n print(sum(int(n)) for n in s)", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [33, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u663910047", "n_user": "u663910047", "pos": "x = 1\nL=[]\nn= 0\ns=0\nwhile x is not 0:\n x = int(input())\n L.append(x)\nN=1\nL.remove(0)\nfor i in L:\n while i >=N:\n\n N=10*N\n n =i%N\n s+=(n/N*10)\n i-=n\n print (int(s))\n s=0\n N = 1", "neg": "x = 1\nL=[]\nn= 0\ns=0\nwhile x is not 0:\n x = int(input())\n L.append(x)\nN=1\nL.remove(0)\nfor i in L:\n while i >N:\n\n N=10*N\n n =i%N\n s+=(n/N*10)\n i-=n\n print (int(s))\n s=0\n N = 1", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [112, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u498511622", "n_user": "u498511622", "pos": "while True:\n x=input()\n if x == '0':\n break\n print(sum(int(z) for z in x))", "neg": "while True:\n x=input()\n if x==0:\n break\n print(sum(int(z) for z in x))", "jacc_sim": 0.9444444444444444, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [35, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u350064373", "n_user": "u350064373", "pos": "list1 = []\nwhile True:\n x = str(input())\n if x == '0':\n break\n else:\n result=0\n for i in x:\n result += int(i)\n list1.append(result)\n \nfor i in list1:\n print(i)", "neg": "list1 = []\nresult = 0\nwhile True:\n x = str(input())\n if x == '0':\n break\n else:\n for i in x:\n result += int(i)\n list1.append(result)\n \nfor i in list1:\n print(i)", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [75, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u853619096", "n_user": "u853619096", "pos": "a=0\n\nwhile True:\n z=str(input())\n if z == '0' :\n break\n for i in z:\n k=int(i)\n a+=k\n print(a)\n a=0", "neg": "a=0\n\nwhile True:\n z=str(input())\n if z == 0 :\n break\n for i in z:\n k=int(i)\n a+=k\n print(a)\n a=0", "jacc_sim": 0.9523809523809523, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [60, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u597198969", "n_user": "u941509088", "pos": "while(True):\n a = input()\n if(a == '0'):\n break\n b = [int(i) for i in list(str(a))]\n print(sum(b))", "neg": "while True:\n a = input()\n if a == \"0\":\n break\n print(sum([int(b) for b in list(a)])", "jacc_sim": 0.9130434782608695, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [50, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u688488162", "n_user": "u688488162", "pos": "while True:\n x = int(input())\n if x == 0:\n break\n sum = 0\n while x != 0:\n sum += x%10\n x = x//10\n\n print(sum)", "neg": "while True:\n x = input()\n if x == 0:\n break\n sum = 0\n while x != 0:\n sum += x%10\n x = x//10\n\n print(sum)", "jacc_sim": 0.9473684210526315, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [54, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u776758454", "n_user": "u776758454", "pos": "def main():\n\n while True:\n number_string = input()\n if number_string == '0': break\n print(sum(map(int, list(number_string))))\n \nmain()", "neg": "def main():\n\n while True:\n number_string = input()\n if number_string == '0': break\n print(list(number_string))\n print(sum(map(int, list(number_string))))\n \nmain()", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [50, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u692415695", "n_user": "u692415695", "pos": "# Belongs to : midandfeed aka asilentvoice\nwhile(1):\n\tn = str(input())\n\t\n\tif n != '0':\n\t\tans = 0\n\t\tfor x in n:\n\t\t\tans += int(x)\n\t\tprint(ans)\n\telse:\n\t\tbreak", "neg": "# Belongs to : midandfeed aka asilentvoice\nwhile(1):\n\tn = str(input())\n\t\n\tif n:\n\t\tans = 0\n\t\tfor x in n:\n\t\t\tans += int(x)\n\t\tprint(ans)\n\telse:\n\t\tbreak", "jacc_sim": 0.9285714285714286, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [73, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u406002631", "n_user": "u406002631", "pos": "a = []\nwhile True:\n n = int(input())\n if n == 0:\n break\n a.append(n)\n\nfor i in range(len(a)):\n b = list(str(a[i]))\n sum = 0\n for j in b:\n sum += int(j)\n print(sum)", "neg": "a = []\nwhile True:\n n = int(input())\n if n == 0:\n break\n a.append(n)\n\nfor i in range(len(a)):\n b = list(str(a[i]))\n sum = 0\n for j in b:\n sum += int(j)\n print(sum)))", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [83, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u210512327", "n_user": "u210512327", "pos": "while True:\n\n x = input()\n\n if x == '0':\n break\n\n length = len(x)\n tot = 0\n\n for i in range(length):\n tot += int(x[i:i + 1])\n print(tot)\n", "neg": "while True:\n\n x = input()\n\n if x == 0:\n break\n\n length = len(x)\n tot = 0\n\n for i in range(length):\n tot += int(x[i:i + 1])\n print(tot)\n", "jacc_sim": 0.96, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [67, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u536089081", "n_user": "u536089081", "pos": "from sys import stdin\nfor line in stdin:\n if line == '0\\n':\n break\n num = list(map(int, line.strip('\\n')))\n print(sum(num))\n", "neg": "from sys import stdin\nfor line in stdin:\n if line == '0':\n break\n num = list(map(int, line.strip('\\n')))\n print(sum(num))\n", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [50, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u613534067", "n_user": "u283452598", "pos": "while(True):\n num = input()\n if num == '0':\n break\n x = 0\n for i in num:\n x += int(i)\n print(x)\n", "neg": "while True:\n x=input()\n if x=\"0\":\n break\n cnt = 0\n for i in x:\n num = int(i)\n cnt += num\n print(cnt)", "jacc_sim": 0.95, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [48, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u009288816", "n_user": "u009288816", "pos": "import sys\n\nl = []\nfor i in sys.stdin:\n l.append(i)\n\nfor i in range(0,len(l)):\n if int(l[i]) == 0:\n break\n count = 0\n for j in range(0,len(l[i])-1):\n count += int(l[i][j])\n print(count)\n", "neg": "import sys\n\nl = []\nfor i in sys.stdin:\n l.append(i)\n\nfor i in range(0,len(l)):\n if l[i] == '0':\n break\n count = 0\n for j in range(0,len(l[i])-1):\n count += int(l[i][j])\n print(count)\n", "jacc_sim": 0.9655172413793104, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [94, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u908651435", "n_user": "u908651435", "pos": "while True:\n x=input()\n if x=='0':\n break\n print(sum(int(s) for s in x))\n", "neg": "while True:\n x=input()\n if x==0:\n break\n print(sum(int(s) for s in x))\n", "jacc_sim": 0.9444444444444444, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [35, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u908651435", "n_user": "u908651435", "pos": "while True:\n n=input()\n if n=='0':\n break\n s=list(n)\n a=[int(i) for i in s]\n print(sum(a))\n", "neg": "while True:\n n=input()\n if n==0:\n break\n s=list(n)\n a=[int(i) for i in s]\n print(sum(a))\n", "jacc_sim": 0.9565217391304348, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [49, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u461381803", "n_user": "u277375424", "pos": "while True:\n x = input()\n if x == \"0\":\n break\n print(sum(int(i) for i in x))\n \n \n", "neg": "while True:\n x = input()\n if x == 0:\n break\n print(sum(int(i) for i in x))\n\n", "jacc_sim": 0.9444444444444444, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [40, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u514127623", "n_user": "u401439950", "pos": "while True:\n a = input()\n if a == \"0\":\n break\n s = 0\n for i in a:\n s += int(i)\n print(s)\n", "neg": "while True:\n s = input()\n if s == \"0\":\n break\n a = 0\n for i in s:\n a += int(s[i])\n print(a)\n\n", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [47, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u171529618", "n_user": "u869301406", "pos": "while True:\n num = int(input())\n if num == 0:\n break\n print(sum(list(map(int, str(num)))))\n", "neg": "while True:\n num = input()\n\n print sum(map(int,list(str(num))))\n if num == 0:\n break", "jacc_sim": 1.0, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [39, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u330854367", "n_user": "u196669489", "pos": "while 1:\n x = input()\n if int(x) == 0:\n break\n print(sum(map(int,x)))\n", "neg": "while 1:\n\tx=input()\n\tif x=='0':\n\t\tbreak\n\tprint sum(map(int,x))", "jacc_sim": 0.9411764705882353, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [35, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u350924040", "n_user": "u117053676", "pos": "while True:\n n = list(map(int, str(input())))\n if n == [0]:\n break\n else:\n print(sum(n))\n", "neg": "while True:\n input = list(map(int,list(input())))\n if input == [0]:\n break\n else:\n print(sum(input))", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [42, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u987378404", "n_user": "u971748390", "pos": "while True:\n num=input()\n if num=='0':\n break\n else:\n sum=0\n for i in range(len(num)):\n sum+=int(num[i])\n print(sum)\n", "neg": "while True :\n x = input()\n if x == '0' :\n break \n\n else:\n sum = 0 \n for i in range(len(x)) : \n sum += int(x[i])\n\n print(sum) ", "jacc_sim": 0.92, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [58, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u322457988", "n_user": "u299798926", "pos": "while 1:\n x = input()\n if x == '0':break\n print(sum([int(i) for i in x]))\n", "neg": "while 1:\n x=[ int(i) for i in input()]\n if x==0:\n break\n print(sum(list(x)))", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [34, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u526189710", "n_user": "u656153606", "pos": "while True:\n s = input()\n if s==\"0\":\n break\n x = list(s)\n length = len(x)\n sum=0\n for i in range(length):\n sum+=int(x[i])\n print(sum)\n", "neg": "while True:\n x = list(input())\n if x == \"0\":\n break\n sum = 0\n for i in range(len(x)):\n sum += int(x[i])\n print(sum)", "jacc_sim": 0.9230769230769231, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [68, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u344890307", "n_user": "u662822413", "pos": "while True:\n table = str(input())\n if(table == '0'):\n break\n print(sum(int(num) for num in table))\n \n", "neg": "while True:\n table=str(input())\n if table[0] == '0':\n break\n print(sum(int(num) for num in table(num)))\n\n", "jacc_sim": 0.9047619047619048, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [41, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u575962166", "n_user": "u933096856", "pos": "while True:\n n = input()\n if n == \"0\":\n break\n print(sum(map(int,list(n))))\n", "neg": "while True:\n n=sum(list(map(int, list(input())))\n if n == 0:\n break\n print(n)", "jacc_sim": 0.9444444444444444, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02416", "p_user": "u625806423", "n_user": "u633068244", "pos": "while True:\n x = input()\n if int(x) == 0:\n break\n order_sum = 0\n for i in range(len(x)):\n order_sum += int(x[i])\n print(order_sum)\n", "neg": "while True:\n x = int(input())\n if x == 0:\n break\n sum = 0\n for i in range(len(x)):\n sum += x[i]\n print sum", "jacc_sim": 0.9130434782608695, "nl": "Title: Sum of Numbers\n\nWrite a program that reads an integer and prints the sum of its digits.\n\nInput:\nThe input consists of multiple datasets. For each dataset, an integer x is given in a line. The number of digits in x does not exceed 1000. The input ends with a line including a single zero, which should not be processed by the program.\n\nOutput:\nFor each dataset, print the sum of digits in x.\n\nSample Input:\n123\n55\n1000\n0\n\nSample Output:\n6\n10\n1", "before_after_length": [62, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u539753516", "n_user": "u436366398", "pos": "print(\"Yes\") if (input()*2).find(input())>-1 else print(\"No\")\n", "neg": "print(\"Yes\" if 2*input().find(input()) > -1 else \"No\")\n\n", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [24, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u100813820", "n_user": "u100813820", "pos": "# 18-Character-Ring.py\n\n# ????????\u00b0\n# ???????????????????????\u00b0??\u00b6???????????? s ???????????????????????????????\u00a8????????????\u00a3?\u00b6????????????????????????????????????\u00a7???\n# ????????? p ??????????????????????????????????????\u00b0????????????????????????????????????\n\n# Input\n# ????????????????????? s ????????????????????????\n# ????????????????????? p ????????????????????????\n\n# Output\n# p ??????????????\u00b4?????? Yes ??\u00a8?????????????????\u00b4?????? No ??\u00a8????????????????????????????????????\n\n# Constraints\n# 1???p????????????s????????????100\n# ??????????????\u00b1?\u00b0???????????????????\n\n# Sample Input 1\n# vanceknowledgetoad\n# advance\n# Sample Output 1\n# Yes\n\n# Sample Input 2\n# vanceknowledgetoad\n# advanced\n# Sample Output 2\n# No\n\nimport re\n\npattern=[]\n\ns=input()\np=input()\n\ns= s+s\n\n# for p2 in list(p):\n# \tpattern.append(p2)\n# \tpattern.append(\".*\")\n\n# pattern = \"\".join(pattern)\n# print(pattern)\n\nmatchOB = re.search(p, s)\n\nif matchOB:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "neg": "# 18-Character-Ring.py\n\n# ????????\u00b0\n# ???????????????????????\u00b0??\u00b6???????????? s ???????????????????????????????\u00a8????????????\u00a3?\u00b6????????????????????????????????????\u00a7???\n# ????????? p ??????????????????????????????????????\u00b0????????????????????????????????????\n\n# Input\n# ????????????????????? s ????????????????????????\n# ????????????????????? p ????????????????????????\n\n# Output\n# p ??????????????\u00b4?????? Yes ??\u00a8?????????????????\u00b4?????? No ??\u00a8????????????????????????????????????\n\n# Constraints\n# 1???p????????????s????????????100\n# ??????????????\u00b1?\u00b0???????????????????\n\n# Sample Input 1\n# vanceknowledgetoad\n# advance\n# Sample Output 1\n# Yes\n\n# Sample Input 2\n# vanceknowledgetoad\n# advanced\n# Sample Output 2\n# No\n\nimport re\n\npattern=[]\n\ns=input()\np=input()\n\ns= s+s\n\nfor p2 in list(p):\n\tpattern.append(p2)\n\tpattern.append(\".*\")\n\npattern = \"\".join(pattern)\nprint(pattern)\n\nmatchOB = re.search(p, s)\n\nif matchOB:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [464, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u369313788", "n_user": "u369313788", "pos": "s = input()\nP = input()\ne = s + s\nx = len(P)\nm = 0\ncount = 0\nfor i in range(len(s)):\n if P == e[m:x]:\n count += 1\n m += 1\n x += 1\nif count >= 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\nP = input()\ne = s + s\nx = len(P)\nm = 0\ncount = 0\nfor i in range(len(s)):\n if P == e[m:x]:\n count += 1\n m += 1\n x += 1\n if count >= 1:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [88, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u923668099", "n_user": "u923668099", "pos": "# coding: utf-8\ns = input() * 2\np = input()\nif s.find(p) >= 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "# coding: utf-8\ns = input() * 2\np = input()\nif s.find(p):\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9166666666666666, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [44, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u547492399", "n_user": "u547492399", "pos": "s1 = input()\ns2 = input()\n\nif s2 in s1+s1:\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s1 = input()\ns2 = input()\n\nif s2 in s1+s1:\n print(\"Yes\")\nelse\n print(\"No\")", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [38, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u519227872", "n_user": "u519227872", "pos": "import sys\n\nlines = [line.strip() for line in sys.stdin]\ns = lines[0] + lines[0]\np = lines[1].strip()\n\nif s.find(p) != -1:\n print('Yes')\nelse:\n print('No')", "neg": "import sys\n\nlines = [line for line in sys.stdin]\ns = lines[0] + lines[0]\np = lines[1]\nif s.find(p) != -1:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9655172413793104, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [67, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u130834228", "n_user": "u130834228", "pos": "s = list(input())\np = list(input())\n#print(len(p))\nimport sys\n\nfor i in range(len(s)):\n\tt=0\n\tfor j in range(len(p)):\n\t\tif p[j] == s[(i+j)%len(s)]:\n\t\t\tt = t+1\n\t\t\t#print(p[j], s[(i+j)%len(s)])\n\t\telse:\n\t\t\tt = 0\n\t\tif t == len(p):\n\t\t\tprint('Yes')\n\t\t\tsys.exit()\n\nif t < len(p):\n\tprint('No')", "neg": "import sys\n\nfor i in range(len(s)):\n\tfor j in range(len(p)):\n\t\tt=0\n\t\tif p[j] == s[(i+j)%len(s)]:\n\t\t\tt = t+1\n\t\t\t#print(p[j], s[(i+j)%len(s)])\n\t\telse:\n\t\t\tt = 0\n\t\tif t == len(p):\n\t\t\tprint('Yes')\n\t\t\tsys.exit()\n\nif t < len(p):\n\tprint('No')", "jacc_sim": 0.9411764705882353, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [156, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u279605379", "n_user": "u279605379", "pos": "s=input()*3\nif s.find(input()) == -1 :\n print('No')\nelse:\n print('Yes')", "neg": "s=input()*3\nprint(s)\nif s.find(input()) == -1 :\n print('No')\nelse:\n print('Yes')", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [33, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u853619096", "n_user": "u853619096", "pos": "z=input()*2\nx=input()\na=z.count(x)\n\nif a>=1:\n print(\"Yes\")\nelse:\n print('No')", "neg": "z=input()*2\nx=input()\na=z.count(x)\nprint(a)\nif a>=1:\n print(\"Yes\")\nelse:\n print('No')", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [43, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u956226421", "n_user": "u956226421", "pos": "s = input()\np = input()\nAns = False\ncnt = 0\n\nfor i in range(len(s)):\n for j in range(len(p)):\n if i + j >= len(s):\n i = -j\n if s[i + j] != p[j]:\n break\n cnt += 1\n if cnt == len(p):\n Ans = True\n break\n cnt = 0\n\nif Ans:\n print('Yes')\nelse:\n print('No')", "neg": "s = input()\np = input()\nAns = False\n\nfor i in range(len(s)):\n for j in range(len(p)):\n if i + j >= len(s):\n i = -j\n if s[i + j] != p[j]:\n break\n if j == len(p) - 1:\n Ans = True\n break\n\nif Ans:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9375, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [125, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u933096856", "n_user": "u933096856", "pos": "s,p=[input() for i in range(2)]\ns=s*100\nif p in s:\n print('Yes')\nelse:\n print('No')", "neg": "s,p=[input() for i in range(2)]\ns=s*100\nif p in s:\n print('Yes')\nelse:\n print('NO')", "jacc_sim": 0.9166666666666666, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [40, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u506705885", "n_user": "u506705885", "pos": "letters=input()\nletters=letters+letters\nwant_find=input()\nif want_find in letters:\n print('Yes')\nelse:\n print('No')", "neg": "letters=input()\nletters=letters+letters\nwant_find=input()\nprint(letters)\nif want_find in letters:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [40, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u298999032", "n_user": "u298999032", "pos": "i=input\np=print\nx=i()\ny=i()\np('Yes') if (x+x).count(y) else p('No')", "neg": "i=input\np=print\nx=i()\ny=i()\n(x+x).count(y) if p('Yes') else p('No')", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [37, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u406002631", "n_user": "u406002631", "pos": "s = input()\ns += s\n\nkey = input()\n\nif s.find(key) != -1: \n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\ns += s\nprint(s)\n\nkey = input()\nprint(s.find(key))\nif s.find(key) != -1: \n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [42, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u682153677", "n_user": "u682153677", "pos": "# -*- coding: utf-8 -*-\n\nimport sys\n\ns = sys.stdin.readline().strip()\np = sys.stdin.readline().strip()\n\ns += s\n\nif p in s:\n print('Yes')\nelse:\n print('No')\n", "neg": "# -*- coding: utf-8 -*-\n\nimport sys\n\ns = sys.stdin.readline().strip()\np = sys.stdin.readline().strip()\n\nif p in s:\n print('Yes')\nelse:\n print('No')\n", "jacc_sim": 0.9615384615384616, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [69, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u986478725", "n_user": "u986478725", "pos": "# AOJ ITP1_8_D\n\ndef numinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef main():\n string = input()\n string += string\n p = input()\n # \u6587\u5b57\u5217\u30922\u500d\u3057\u3066\u305d\u306e\u4e2d\u304b\u3089\u63a2\u3059\u3002\n # 1\u2266p\u306e\u9577\u3055\u2266s\u306e\u9577\u3055\u306a\u306e\u3067\u3053\u308c\u3067\u3044\u3044\u3002\n # \u6587\u5b57\u5217\u542b\u6709\u306b\u306f\u300c\u6587\u5b57\u5217\u300d.find(\u300c\u63a2\u3057\u305f\u3044\u6587\u5b57\u5217\u300d)\u3092\u4f7f\u3046\u3002\n if string.find(p) >= 0: print(\"Yes\")\n else: print(\"No\")\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# AOJ ITP1_8_D\n\ndef numinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef main():\n string = input()\n string += string\n p = input()\n # \u6587\u5b57\u5217\u30922\u500d\u3057\u3066\u305d\u306e\u4e2d\u304b\u3089\u63a2\u3059\u3002\n # 1\u2266p\u306e\u9577\u3055\u2266s\u306e\u9577\u3055\u306a\u306e\u3067\u3053\u308c\u3067\u3044\u3044\u3002\n # \u6587\u5b57\u5217\u542b\u6709\u306b\u306f\u300c\u6587\u5b57\u5217\u300d.find(\u300c\u63a2\u3057\u305f\u3044\u6587\u5b57\u5217\u300d)\u3092\u4f7f\u3046\u3002\n if string.find(p): print(\"Yes\")\n else: print(\"No\")\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9722222222222222, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [306, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u922112509", "n_user": "u922112509", "pos": "# Ring\n\nring = input()\nword = input()\n\ndoubleRing = ring * 2\nringCut = doubleRing.split(word)\n# print(ringCut)\n\nif ringCut[0] == doubleRing:\n print('No')\nelse:\n print('Yes')\n\n", "neg": "# Ring\n\nring = input()\nword = input()\n\nringCut = (ring * 2).split(word)\n# print(ringCut)\n\nif ringCut[0] == ring:\n print('No')\nelse:\n print('Yes')\n\n", "jacc_sim": 0.9583333333333334, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [68, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u333452713", "n_user": "u298999032", "pos": "s = input()\np = input()\ns = s+s\nprint('Yes' if s.count(p) else 'No')\n", "neg": "i=input\np=print\ns=i()\np=i()\n(s+s).count(p) if p('Yes') else p('No')", "jacc_sim": 0.9375, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [32, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u695386605", "n_user": "u742505495", "pos": "s = str(input())\ns = s + s \np = str(input())\n\nif (p in s) == True:\n print('Yes')\nelse:\n print('No')\n", "neg": "s = str(input())\np = str(input())\ncase = s + s\nif p in case == True:\n\tprint('Yes')\nelse:\n\tprint('No')\n", "jacc_sim": 0.9444444444444444, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [47, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u076643834", "n_user": "u600195957", "pos": "s = input()\np = input()\ns *= 2\n\nif s.find(p) != -1:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "neg": "s = print()\np = print()\n\ns *= 2\nif s.find(p) != -1:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.95, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [42, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u804558166", "n_user": "u661284763", "pos": "s = input()\np = input()\ns = s + s[:len(p)]\nif p in s:\n print('Yes')\nelse:\n print('No')\n", "neg": "s = input()\np = input()\n????\ns += s[:len(p)]\nif p in s:\n????????print(\"Yes\")\nelse:\n????????print(\"No\")", "jacc_sim": 0.9473684210526315, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [42, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u921810101", "n_user": "u914146430", "pos": "s = input()\np = input()\n\ns = s + s\n\nif p in s: print(\"Yes\")\nelse: print(\"No\")\n", "neg": "s=input()\np=input()\n\nif p in s:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9333333333333333, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [35, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02418", "p_user": "u777070060", "n_user": "u908651435", "pos": "s = input()\np = input()\n\nif p in 2 * s:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "neg": "s=input()*2\np=input()\nif s in p:\n print('Yes')\nelse:\n print('No')\n", "jacc_sim": 1.0, "nl": "Write a program to find a pattern $p$ in a ring-shaped text $s$. The input consists of the text $s$ and the pattern $p$. If $p$ is found in $s`, output \"Yes\"; otherwise, output \"No\". The length of $p$ is at least 1 and at most 100, and both $s$ and $p$ consist of lowercase letters.", "before_after_length": [34, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u198574985", "n_user": "u198574985", "pos": "while True:\n\n string = str(input())\n box = \"\"\n \n \n if string == \"-\":\n break\n \n shuffle = int(input())\n\n h = [0]*shuffle\n\n for a in range(shuffle):\n h[a] = int(input())\n\n for b in range(shuffle):\n box = string[0:h[b]]\n string = string[h[b]:]\n string = string+box\n box = \"\"\n\n print(string)\n", "neg": "while True:\n\n string = str(input())\n box = \"\"\n \n \n if string == \"-\":\n break\n \n shuffle = int(input())\n\n h = [0]*shuffle\n\n for a in range(shuffle):\n h[a] = int(input())\n\n for b in range(shuffle):\n box = string[0:h[b]]\n string = string[h[b]:]\n string = string+box\n box = \"\"\n print(string)\n\n print(string)\n", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [124, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u928633434", "n_user": "u928633434", "pos": "while True:\n cards = str(input())\n if cards == '-':\n break\n \n n = int(input())\n for i in range(n):\n p = int(input())\n cards = cards[p:] + cards[:p]\n print(cards)\n", "neg": "while True:\n cards = str(input())\n if cards == '-':\n break\n \n n = int(input())\n for i in range(n):\n p = str(input())\n cards = cards[p:] + cards[:p]\n print(cards)\n", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [68, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u131984977", "n_user": "u823030818", "pos": "while True:\n text = input()\n if text == '-':\n break\n\n count = int(input())\n for c in range(count):\n index = int(input())\n text = text[index:] + text[:index]\n\n print(text)", "neg": "while True:\n text = input()\n if text == '-':\n break\n\n count = int(input())\n for c in range(count):\n index = int(input())\n text - text[index:] + text[:index]\n\nprint(text)", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [65, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u067975558", "n_user": "u067975558", "pos": "s = []\nwhile True:\n hoge = input()\n if hoge == '-':\n break\n num = int(input())\n for i in range(num):\n h = int(input())\n hoge = hoge.replace(hoge,hoge[h:] + hoge[:h])\n s += [hoge]\nfor i in s: print(i)", "neg": "s = []\nn = []\nwhile True:\n hoge = input()\n if hoge == '-':\n break\n\n for i in range(int(input())):\n h = int(input())\n hoge.replace(hoge,hoge[h:] + hoge[:h])\n s += [hoge]\nfor i in s: print(i)", "jacc_sim": 0.9285714285714286, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [100, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u971748390", "n_user": "u971748390", "pos": "while(1):\n \n sen1=input()\n \n if sen1==\"-\":\n break\n \n suff=int(input())\n \n for i in range(suff):\n h=int(input())\n sen1=sen1[h:]+sen1[:h]\n\n print(sen1)", "neg": "while(1):\n \n sen1=input()\n \n if sen1==\"-\":\n break\n \n suff=int(input())\n \n for i in range(suff):\n h=int(input())\n sen2=sen1[h:]+sen1[:h]\n\n print(sen2)", "jacc_sim": 0.9583333333333334, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u670498238", "n_user": "u604774382", "pos": "import sys\n\ndef shuffle( cards ):\n h = int( sys.stdin.readline() )\n cards = cards[ h : ] + cards[ 0 : h ]\n return cards\n\nwhile True:\n cards = sys.stdin.readline().rstrip()\n if '-' == cards:\n break\n m = int( sys.stdin.readline())\n for i in range( m ):\n cards = shuffle( cards )\n print( cards )\n ", "neg": "import sys\n\ndef shuffle( cards ):\n\th = int( sys.stdin.readline() )\n\ts = cards[ 0 : h ]\n\tcards = cards.lstrip( s )\n\tcards += s\n\treturn cards\n\nwhile True:\n\tcards = sys.stdin.readline().rstrip()\n\tif '-' == cards:\n\t\tbreak\n\tm = int( sys.stdin.readline() )\n\tfor i in range( 0, m ):\n\t\tcards = shuffle( cards )\n\tprint( cards )", "jacc_sim": 0.9142857142857143, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [112, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u996758922", "n_user": "u996758922", "pos": "while True:\n string = input()\n if string == \"-\":\n break\n else:\n s = 0\n for i in range(int(input())):\n s += int(input())\n\n s = s % len(string)\n print(string[s:] + string[:s])", "neg": "while True:\n if input() == \"-\":\n break\n else:\n s = 0\n string = input()\n for i in range(int(input())):\n s += int(input())\n\n s = s % len(string)\n print(string[s:len(string)] + string[0:s])", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [73, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u801346721", "n_user": "u801346721", "pos": "import sys\ndataset = sys.stdin.readlines()\n\nseq = 0\n\nwhile dataset[seq] != '-\\n':\n s = dataset[seq]\n l = len(s) - 1\n s = s[:l]\n seq += 1\n n = dataset[seq]\n l = len(n) - 1\n n = int(n[:l])\n seq += 1\n for i in range(seq, seq + n):\n h = dataset[i]\n l = len(h) - 1\n h = int(h[:l])\n s = s[h:] + s[0:h]\n print(s)\n seq += n", "neg": "import sys\ndataset = sys.stdin.readlines()\n\nseq = 0\n\nwhile dataset[seq] != '-\\n':\n s = dataset[seq]\n len = len(s) - 1\n s = s[:len]\n seq += 1\n n = int(dataset[seq][0])\n seq += 1\n for i in range(seq, seq + n):\n h = int(dataset[i][0])\n s = s[h:] + s[0:h]\n print(s)\n seq += n\n ", "jacc_sim": 0.9696969696969697, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [149, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u957840591", "n_user": "u957840591", "pos": "Str=[]\nH=[]\nh=[]\nwhile True:\n x=input()\n if x=='-':\n break\n Str.append(x)\n m=int(input())\n for i in range(m):\n x=int(input())\n h.append(x)\n H.append(h)\n h=[]\nfor i in range(len(Str)):\n a=Str[i]\n for j in range(len(H[i])):\n a=''.join([a[H[i][j]:],a[:H[i][j]]])\n Str[i]=a\nfor str in Str:\n print(str)", "neg": "Str=[]\nH=[]\nh=[]\nwhile True:\n x=input()\n if x=='-':\n break\n Str.append(x)\n m=int(input())\n for i in range(m):\n x=int(input())\n h.append(x)\n H.append(h)\n h=[]\nprint(Str)\nprint(H)\nfor i in range(len(Str)):\n a=Str[i]\n for j in range(len(H[i])):\n a=''.join([a[H[i][j]:],a[:H[i][j]]])\n Str[i]=a\nfor str in Str:\n print(str)", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [163, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u865138391", "n_user": "u865138391", "pos": "while True:\n C = input()\n if C == \"-\":\n break\n count = int(input())\n shuffle = [int(input()) for i in range(count)]\n for h in shuffle:\n C = C[h:] + C[:h]\n print(C)", "neg": "while True:\n C = input()\n if C == \"-\":\n break\n count = int(input())\n shuffle = [int(input() for i in range(count))]\n for h in shuffle:\n C = C[h:] + C[:h]\n print(C)", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [69, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u897625141", "n_user": "u897625141", "pos": "import re\narray = []\nlines = []\ncount = 0\nwhile True:\n n = input()\n if n == \"-\":\n break\n array.append(n)\nfor i in range(len(array)):\n if re.compile(\"[a-z]\").search(array[i]):\n fuck = i+1\n if count > 0:\n lines.append(stt)\n count += 1\n stt = array[i]\n else:\n if i == fuck:\n continue\n stt = stt[int(array[i]):len(stt)]+stt[0:int(array[i])]\n if i == len(array)-1:\n lines.append(stt)\nfor i in range(len(lines)):\n print(lines[i])", "neg": "import re\narray = []\nlines = []\ncount = 0\nwhile True:\n n = input()\n if n == \"-\":\n break\n array.append(n)\nfor i in range(len(array)):\n if re.compile(\"[a-z]\").search(array[i]):\n if count > 0:\n lines.append(stt)\n count += 1\n stt = array[i]\n else:\n stt = stt[int(array[i]):len(stt)]+stt[0:int(array[i])]\n if i == len(array)-1:\n lines.append(stt)\nfor i in range(len(lines)):\n print(lines[i])", "jacc_sim": 0.95, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [198, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u299798926", "n_user": "u299798926", "pos": "while 1:\n n=input()\n if n=='-':\n break\n m=[i for i in range(len(n))]\n count=int(input())\n for i in range(count):\n l=int(input())\n for j in range(len(n)):\n m[j]=n[(l+j)%len(n)]\n n=m.copy()\n for i in range(len(n)):\n print(n[i],end=\"\")\n print() ", "neg": "while 1:\n n=input()\n if n=='-':\n break\n m=[i for i in range(len(n))]\n count=int(input())\n for i in range(count):\n l=int(input())\n for j in range(len(n)):\n m[j]=n[(l+j)%len(n)]\n n=m\n for i in range(len(n)):\n print(n[i],end=\"\")\n print() ", "jacc_sim": 0.9354838709677419, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [126, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u498511622", "n_user": "u498511622", "pos": "while True:\n al=input()\n if al=='-':\n break\n else:\n m=int(input())\n for i in range(m):\n n = int(input())\n al= al[n:] + al[:n]\n print(al)", "neg": "al=input()\nm=int(input())\nfor i in range(m):\n n = int(input())\n if n=='-':\n break\n else:\n al= al[n:] + al[:n]\nprint(al)", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [64, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u853619096", "n_user": "u085472528", "pos": "while True:\n s=input()\n if s == '-':\n break\n \n \n m=int(input())\n for mi in range(m):\n h = int(input())\n s = s[h:] + s[:h]\n \n print(s)", "neg": "while True:\n s = input()\n if s == '-':\n break\n\n n = int(input())\n for mi in range(m):\n h = int(input())\n\n s = s[:h] + s[h:]\n\n print(s)", "jacc_sim": 0.9583333333333334, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [66, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u666221014", "n_user": "u666221014", "pos": "while True:\n string = list(input())\n if len(string) == 1 and string[0] == \"-\":\n break\n num = int(input())\n for i in range(num):\n times = int(input())\n tmp = string[:times]\n del string[:times]\n string += tmp\n print(\"\".join(string))", "neg": "while True:\n string = list(input())\n if len(string) == 1 and string[0] == \"-\":\n break\n num = int(input())\n for i in range(num):\n times = int(input())\n tmp = string[:times]\n del string[:times]\n string += tmp\n print(\" \".join(string))", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [85, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u933096856", "n_user": "u933096856", "pos": "while True:\n a=input()\n if a=='-':\n break\n else:\n n=int(input())\n for i in range(n):\n h=int(input())\n a=a[h:]+a[:h]\n print(a)", "neg": "while True:\n a=input()\n if a=='-':\n break\n else:\n n=int(input())\n for i in range(n):\n h=int(input())\n a=a[h:]+a[:h]\n print(a)", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [67, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u664228906", "n_user": "u664228906", "pos": "str = input()\nwhile not str == '-':\n n = int(input())\n for i in range(n):\n h = int(input())\n str = str[h:] + str[:h]\n print(str)\n str = input() ", "neg": "str = input()\nwhile not str == '-':\n n = int(input())\n for i in range(n):\n str = str[n:] + [:n-1]\n print(str)\n str = input() ", "jacc_sim": 0.9090909090909091, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [62, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u539789745", "n_user": "u539789745", "pos": "def main():\n while True:\n S = input()\n if S == \"-\":\n break\n\n n_shuffle = int(input())\n hs = [int(input()) for _ in range(n_shuffle)]\n\n for h in hs:\n S = S[h:] + S[:h]\n\n print(S)\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n while True:\n S = input()\n if S == \"-\":\n break\n\n n_shuffle = int(input())\n hs = [int(input()) for _ in range(n_shuffle)]\n\n for h in hs:\n S = S[-h:] + S[:-h]\n\n print(S)\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [96, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u566311709", "n_user": "u566311709", "pos": "while 1:\n s = input()\n if s == \"-\": break\n for _ in range(int(input())):\n h = int(input())\n s = s[h:] + s[:h]\n print(s)\n", "neg": "l = []\nwhile 1:\n s = input()\n if s == \"-\": break\n for _ in range(int(input())):\n h = int(input())\n s = s[h:] + s[:h]\n l += [s]\n print(l)\nfor e in l: print(e)\n", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [58, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u986478725", "n_user": "u986478725", "pos": "# AOJ ITP1_9_B\n\ndef main():\n while True:\n string = input()\n if string == \"-\": break\n n = int(input()) # \u30b7\u30e3\u30c3\u30d5\u30eb\u56de\u6570\n for i in range(n):\n h = int(input())\n front = string[0 : h] # 0\u756a\u304b\u3089h-1\u756a\u307e\u3067\n back = string[h : len(string)] # h\u756a\u304b\u3089len-1\u756a\u307e\u3067\n string = back + front\n print(string)\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# AOJ ITP1_9_B\n\ndef numinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef main():\n while True:\n string = input()\n if string == \"-\": break\n n = int(input()) # \u30b7\u30e3\u30c3\u30d5\u30eb\u56de\u6570\n for i in range(n):\n h = int(input())\n front = string[0 : h] # 0\u756a\u304b\u3089h-1\u756a\u307e\u3067\n back = string[h : len(string)] # h\u756a\u304b\u3089len-1\u756a\u307e\u3067\n string = back + front\n print(string)\n print(string)\n\nif __name__ == \"__main__\":\n main()\n\n", "jacc_sim": 0.9038461538461539, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [183, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u670406235", "n_user": "u311299757", "pos": "while True:\n s = input()\n if s == \"-\":\n break\n else:\n N = int(input())\n for i in range(N):\n h = int(input())\n s = s[h:] + s[:h]\n print(s)\n\n", "neg": "\nwhile True:\n s = input()\n if s == \"-\":break\n loop_cnt = int(input())\n for i in range(loop_cnt):\n h = int(input())\n s = s[h:] + s[:h]\n else:\n print(s)\nprint(s)", "jacc_sim": 0.92, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [69, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u829695570", "n_user": "u605879293", "pos": "while True:\n s = input()\n if s == '-':\n break\n m = int(input())\n for i in range(m):\n h = int(input())\n s = s[h:] + s[0:h]\n print(s)\n", "neg": "while True:\n\ts = input()\n\tif s == \"-\":\n\t\tbreak\n\tm = int(input())\n\tfor n in range(m):\n\t\th = int(input())\n\t\ts = s[0:h] + s[h:]\n\tprint(s)", "jacc_sim": 0.92, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [66, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u439083584", "n_user": "u587193722", "pos": "while True:\n s=input()\n if s==\"-\":\n break\n m=int(input())\n for _ in range(m):\n h=int(input())\n s=s[h:]+s[:h]\n print(s)\n", "neg": "while True:\n s = input()\n if s == '-':\n break\n m = int(input())\n for mi in range(m):\n h = int(input())\n\n s = s[:h] + s[h:]\n print(s)", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u839788696", "n_user": "u328199937", "pos": "while True:\n card=input()\n if card =='-':\n break\n for i in range(int(input())):\n a = int(input())\n card = card[a:] + card[:a]\n print(card)\n", "neg": "while True:\n card = input()\n if card == '-': break\n for i in range(int(input())):\n a = int(input())\n card = card[:a] + card[a:]\n print(card)\n\n", "jacc_sim": 1.0, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [61, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u009332121", "n_user": "u876060624", "pos": "desk = input()\nwhile desk != '-':\n m = int(input())\n for i in range(m):\n h = int(input())\n desk = desk[h:] + desk[:h]\n print(desk)\n desk = input()\n", "neg": "A = input()\nwhile(A != '-'):\n\tm = int(input)\n\tfor i in range(m):\n\t\th = int(input())\n\t\tA = A[h:]+A[:h]\n\tprint(A)\n\tA = input()\n", "jacc_sim": 0.9090909090909091, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [68, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u394181453", "n_user": "u614197626", "pos": "while True:\n word = input()\n if word == '-':\n break\n\n for _ in range(int(input())):\n i = int(input())\n word = word[i:] + word[:i]\n print(word)\n", "neg": "while True:\n _=input()\n if _ == '-':\n break\n for i in range(int(input())):\n l=int(input())\n _=_[l:]+[:l]\n print(_) \n", "jacc_sim": 0.9130434782608695, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [61, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u140934185", "n_user": "u650790815", "pos": "while 1:\n s=input()\n if s=='-':break\n n=int(input())\n for i in range(n):\n t=int(input())\n s=s[t:]+s[:t]\n print(s)\n", "neg": "while 1:\n s = input()\n if s == '-':break\n n = input()\n for i in range(n):\n h = int(input())\n s = s[h:] + s[:h]\n print(s)", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [62, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u777070060", "n_user": "u656153606", "pos": "while True:\n deck = input()\n if deck == \"-\":\n break\n m = int(input())\n for i in range(m):\n h = int(input())\n deck = deck[h:] + deck[:h]\n print(deck)\n", "neg": "while True:\n cards = input()\n if cards == \"-\":\n break\n m = int(input())\n for i in range(m):\n h = int(input())\n cards = cards[h:] + cards[:h]\n print(cards)", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [65, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02420", "p_user": "u245823788", "n_user": "u436634575", "pos": "while True:\n s = input()\n if s==\"-\":\n break\n m = int(input())\n for i in range(m):\n h = int(input())\n s = s[h:]+s[:h]\n print(s)\n", "neg": "while True:\n s = input()\n if s == '-': break\n n = int(input())\n for i in range(n):\n h = int(input())\n s = s[-h:] + s[:-h]\n print(s)", "jacc_sim": 0.9166666666666666, "nl": "Title: Shuffle\n\nYour task is to shuffle a deck of n cards, each marked by an alphabetical letter. A single shuffle action takes out h cards from the bottom of the deck and moves them to the top. The deck is represented by a string where the first character corresponds to the bottom card and the last character to the top card.\n\nFor example, a shuffle with h = 4 to the deck \"abcdeefab\" moves \"abcd\" to the end of \"eefab\", resulting in \"eefababcd\".\n\nWrite a program that reads a deck (a string) and a sequence of h, and prints the final state (a string).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given as:\n- A string representing a deck\n- The number of shuffles m\n- h1, h2, ..., hm\nThe input ends with a single character '-' for the string.\n\nConstraints:\n- The length of the string \u2264 200\n- 1 \u2264 m \u2264 100\n- 1 \u2264 hi < The length of the string\n- The number of datasets \u2264 10\n\nOutput:\nFor each dataset, print a string representing the final state in a line.\n\nSample Input:\naabc\n3\n1\n2\n1\nvwxyz\n2\n3\n4\n-\n\nSample Output:\naabc\nxyzvw", "before_after_length": [64, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u025362139", "n_user": "u025362139", "pos": "#coding: UTF-8\n\nn = int(input())\npoint_t = 0\npoint_h = 0\n\nfor i in range(n):\n cards = list(map(str, input().split()))\n taro = cards[0]\n hanako = cards[1]\n if taro < hanako:\n point_h += 3\n elif taro > hanako:\n point_t += 3\n else:\n point_t += 1\n point_h += 1\n\nprint(point_t, point_h)\n", "neg": "#coding: UTF-8\n\nn = int(input())\npoint_t = 0\npoint_h = 0\n\nfor i in range(n):\n cards = list(map(str, input().split()))\n taro = cards[0]\n hanako = cards[1]\n if taro > hanako:\n point_h += 3\n elif taro < hanako:\n point_t += 3\n else:\n point_t += 1\n point_h += 1\n\nprint(point_t, point_h)\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [137, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u535719732", "n_user": "u535719732", "pos": "n = int(input())\ntp = 0\nhp = 0\nfor i in range(n):\n tarou, hanako = map(str,input().split())\n if(tarou > hanako):\n tp += 3\n elif(tarou < hanako):\n hp += 3\n else:\n tp += 1\n hp += 1\nprint(\"%d %d\" %(tp,hp))\n", "neg": "n = int(input())\ntp = 0\nhp = 0\nfor i in range(n):\n tarou, hanako = map(str,input().split())\n if(tarou > hanko):\n tp += 3\n elif(tarou < hanako):\n hp += 3\n else:\n tp += 1\n hp += 1\nprint(\"%d %d\" %(tp,hp))\n", "jacc_sim": 0.9705882352941176, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [101, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u811841526", "n_user": "u811841526", "pos": "taro = 0\nhanako = 0\nn = int(input())\nfor _ in range(n):\n taro_card, hanako_card = input().split()\n if taro_card > hanako_card:\n taro += 3\n elif taro_card < hanako_card:\n hanako += 3\n else:\n taro += 1\n hanako += 1\nprint(taro, hanako)", "neg": "taro = 0\nhanako = 0\nn = int(input())\nfor _ in range(n):\n taro_card, hanako_card = input().split()\n if taro_card > hanako_card:\n taro += 3\n elif taro_card < hanako_card:\n hanako += 3\n else:\n taro += 1\n hanako += 1\n print(taro, hanako)\nprint(taro, hanako)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [116, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u995990363", "n_user": "u995990363", "pos": "# coding: utf-8\n\n\nn = int(input())\n\nscores = [0,0]\n\nfor i in range(n):\n card = input().split()\n first_card = card[0]\n card.sort()\n if (card[0] == card[1]):\n scores[0] += 1\n scores[1] += 1\n elif(first_card == card[0]):\n scores[1] += 3\n else:\n scores[0] += 3\n\nprint(scores[0], scores[1])", "neg": "# coding: utf-8\n\n\nn = int(input())\n\nscores = [0,0]\n\nfor i in range(n):\n card = input().split()\n first_card = card[0]\n card.sort()\n print(card)\n print(first_card)\n if (card[0] == card[1]):\n scores[0] += 1\n scores[1] += 1\n elif(first_card == card[0]):\n scores[1] += 3\n else:\n scores[0] += 3\n\nprint(scores[0], scores[1])", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [132, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u427088273", "n_user": "u427088273", "pos": "point_a,point_b = 0,0\nfor i in range(int(input())):\n\tk =[]\n\ta,b = input().split()\n\tk = [[i,j] for i,j in zip(a,b) if i != j]\n\tif k == []:\n\t\tif len(a) < len(b):\n\t\t\tpoint_b+=3\n\t\telif len(a) > len(b):\n\t\t\tpoint_a += 3\n\t\telse:\n\t\t\tpoint_a+=1\n\t\t\tpoint_b+=1\n\telif ord(k[0][0]) < ord(k[0][1]):\n\t\tpoint_b += 3\n\telse :\n\t\tpoint_a += 3\nprint(point_a,point_b)", "neg": "point_a,point_b = 0,0\nfor i in range(int(input())):\n\tk =[]\n\ta,b = input().split()\n\tk = [[i,j] for i,j in zip(a,b) if i != j]\n\tif k == []:\n\t\tif len(a) < len(b):\n\t\t\tpoint_b+=3\n\t\telif len(a) > len(b):\n\t\t\tpoint_a += 3\n\t\telse:\n\t\t\tpoint_a+=1\n\t\t\tpoint_b+=1\n\telif ord(k[0][0]) < ord(k[0][1]):\n\t\tpoint_b += 3\n\telse :\n\t\tpoint_a += 3\n\tprint(point_a,point_b)\nprint(point_a,point_b)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [190, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u514745787", "n_user": "u514745787", "pos": "i = int(input())\n\ntarou = 0\nhanako = 0\n\nfor x in range(i):\n a,b = input().split()\n if b > a:\n hanako += 3\n elif a > b:\n tarou += 3\n else:\n hanako += 1\n tarou += 1\nprint(\"{0} {1}\".format(tarou, hanako))", "neg": "i = int(input())\n \ntarou = 0\nhanako = 0\n\nfor x in range(i):\n a,b = input().split()\n if b > a:\n hanako += 3\n elif a > b:\n tarou += 3\n else:\n hanako += 1\n tarou += 1\n print(\"{0} {1}\".format(tarou, hanako))", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [103, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u831244171", "n_user": "u831244171", "pos": "n = int(input())\nTaro = 0\nHanako = 0\n\nfor i in range(n):\n x = 0\n t,h = input().split()\n for j in range(min(len(t),len(h))):\n if t == h:\n Hanako += 1\n Taro += 1\n x = 1 \n break\n if ord(t[j:j+1]) > ord(h[j:j+1]):\n Taro += 3\n x = 1\n break\n if ord(t[j:j+1]) < ord(h[j:j+1]):\n Hanako += 3\n x = 1\n break\n if x == 0:\n if len(t) > len(h):\n Taro += 3\n elif len(t) < len(h):\n Hanako += 3\n\t\n\nprint(\"{} {}\".format(Taro,Hanako))", "neg": "n = int(input())\nTaro = 0\nHanako = 0\nfor i in range(n):\n t,h = input().split()\n for j in range(min(len(t),len(h))):\n if t == h:\n Hanako += 1\n Taro += 1\n break\n if ord(t[j:j+1]) > ord(h[j:j+1]):\n Taro += 3\n break\n if ord(t[j:j+1]) < ord(h[j:j+1]):\n Hanako += 3\n break\n if len(t) > len(h):\n Taro += 3\n elif len(t) < len(h):\n Hanako += 3\n\t\n\nprint(\"{} {}\".format(Taro,Hanako))", "jacc_sim": 0.9743589743589743, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [233, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u801346721", "n_user": "u801346721", "pos": "n = int(input())\n\nt_score = 0\nh_score = 0\n\n\nfor i in range(n):\n t, h = input().split()\n if t == h:\n t_score += 1\n h_score += 1\n continue\n if len(t) >= len(h):\n for j in range(len(h)):\n if ord(t[j]) > ord(h[j]):\n t_score += 3\n break\n elif ord(t[j]) < ord(h[j]):\n h_score += 3\n break\n else:\n t_score += 3\n elif len(t) < len(h):\n for j in range(len(t)):\n if ord(t[j]) > ord(h[j]):\n t_score += 3\n break\n elif ord(t[j]) < ord(h[j]):\n h_score += 3\n break\n else:\n h_score += 3\n\n \nprint(\"{0} {1}\".format(t_score, h_score))", "neg": "n = int(input())\n\nt_score = 0\nh_score = 0\n\n\nfor i in range(n):\n t, h = input().split()\n if t == h:\n t_score += 1\n h_score += 1\n continue\n if len(t) > len(h):\n for j in range(len(h)):\n if ord(t[j]) > ord(h[j]):\n t_score += 3\n break\n elif ord(t[j]) < ord(h[j]):\n h_score += 3\n break\n else:\n h_score += 3\n elif len(t) < len(h):\n for j in range(len(t)):\n if ord(t[j]) > ord(h[j]):\n t_score += 3\n break\n elif ord(t[j]) < ord(h[j]):\n h_score += 3\n break\n else:\n t_score += 3\n\n \nprint(\"{0} {1}\".format(t_score, h_score))", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [260, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u546285759", "n_user": "u546285759", "pos": "n = int(input())\nst, sh = 0, 0\nfor i in range(n):\n t, h = map(str, input().split())\n if t > h:\n st += 3\n elif t < h:\n sh += 3\n else:\n st += 1\n sh += 1\nprint(st, sh)", "neg": "n = int(input())\nst, sh = 0, 0\nfor i in range(n):\n t, h = map(str, input().split())\n if t > h:\n st += 3\n elif t < h:\n sh += 3\n else:\n st += 1\n st += 1\nprint(st, sh)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u144068724", "n_user": "u144068724", "pos": "n = int(input())\nt_point = 0\nh_point = 0\nfor i in range(n):\n card = input().split()\n taro = card[0]\n card.sort()\n card.reverse()\n if card[0] == card[1]:\n t_point += 1\n h_point += 1\n elif card[0] == taro:\n t_point += 3\n else:\n h_point += 3\n\nprint(t_point,h_point)", "neg": "n = int(input())\nt_point = 0\nh_point = 0\nfor i in range(n):\n card = input().split()\n print(card)\n taro = card[0]\n card.sort()\n card.reverse()\n print(card)\n if card[0] == card[1]:\n t_point += 1\n h_point += 1\n elif card[0] == taro:\n t_point += 3\n else:\n h_point += 3\n\nprint(t_point,h_point)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [122, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u731896389", "n_user": "u731896389", "pos": "ap,bp = 0,0\nn = int(input())\nfor i in range(n):\n a,b = input().split()\n if a>b:\n ap+=3\n elif a==b:\n ap+=1\n bp+=1\n else:\n bp+=3\nprint(ap,bp)", "neg": "ap,bp = 0\nn = int(input())\nfor i in range(n):\n a,b = input().split()\n if a>b:\n ap+=3\n elif a==b:\n bp+=3\n else:\n bp+=3\n print(ap,bp)", "jacc_sim": 0.9629629629629629, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [81, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u130834228", "n_user": "u130834228", "pos": "import sys\nn = int(input())\np_t = 0\np_h = 0\n\nfor i in range(n):\n\ttaro, hanako = input().split()\n\tif taro == hanako:\n\t\tp_t += 1\n\t\tp_h += 1\n\telse:\n\t\tl_t = list(taro)\n\t\tl_h = list(hanako)\n\t\tfor j in range(min(len(l_t), len(l_h))):\n\t\t\tif l_t[j] != l_h[j]:\n\t\t\t\tif ord(l_t[j])len(l_h):\n\t\t\t\t\t\tp_t += 3\n\t\t\t\t\telse:\n\t\t\t\t\t\tp_h += 3\n\t\t\t\t\t\n\nprint(p_t, p_h)", "neg": "import sys\nn = int(input())\np_t = 0\np_h = 0\n\nfor i in range(n):\n\ttaro, hanako = input().split()\n\tif taro == hanako:\n\t\tp_t += 1\n\t\tp_h += 1\n\telse:\n\t\tl_t = list(taro)\n\t\tl_h = list(hanako)\n\t\tfor j in range(min(len(l_t), len(l_h))):\n\t\t\tif l_t[j] != l_h[j]:\n\t\t\t\tif ord(l_t[j]) Hanako_an :\n Ts += 3\n else :\n if Hanako_an > Taro_an :\n Hs += 3\n else :\n Ts += 1; Hs += 1\nprint(Ts,Hs)", "neg": "count = int(input())\nTaro_an = []\nHanako_an = []\nTs = 0\nHs = 0\nfor i in range(count) :\n animal = input().split(\" \")\n Taro_an = animal[0]\n Hanako_an = animal[1]\n if Taro_an > Hanako_an :\n Ts += 3\n else :\n if Hanako_an > Taro_an :\n Hs += 3\n else :\n ++Ts, ++Hs\nprint(Ts,Hs)", "jacc_sim": 0.967741935483871, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [143, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u286589639", "n_user": "u286589639", "pos": "n = int(input())\n\nscore_taro, score_hanako = 0, 0\nfor _ in range(n):\n card_taro, card_hanako = input().split()\n\n point_taro = 0\n point_hanako = 0\n if card_taro == card_hanako:\n score_taro += 1\n score_hanako += 1\n continue\n for i in range(min(len(card_taro), len(card_hanako))):\n if len(card_taro) > len(card_hanako):\n point_taro = 3\n elif len(card_taro) < len(card_hanako):\n point_hanako = 3\n if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):\n point_taro = 3\n point_hanako = 0\n break\n if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):\n point_taro = 0\n point_hanako = 3\n break\n score_taro += point_taro\n score_hanako += point_hanako\nprint(\"{0} {1}\".format(score_taro, score_hanako))", "neg": "n = int(input())\n\nscore_taro, score_hanako = 0, 0\nfor _ in range(n):\n card_taro, card_hanako = input().split()\n\n point_taro, point_hanako = 0, 0\n if card_taro == card_hanako:\n score_taro = 1\n score_hanako = 1\n continue\n for i in range(min(len(card_taro), len(card_hanako))):\n if len(card_taro) > len(card_hanako):\n point_taro = 3\n if len(card_taro) < len(card_hanako):\n point_hanako = 3\n if ord(card_taro[i:i+1]) > ord(card_hanako[i:i+1]):\n point_taro = 3\n point_hanako = 0\n break\n if ord(card_taro[i:i+1]) < ord(card_hanako[i:i+1]):\n point_taro = 0\n point_hanako = 3\n break\n\n score_taro += point_taro\n score_hanako += point_hanako\n\nprint(\"{0} {1}\".format(score_taro, score_hanako))", "jacc_sim": 0.975609756097561, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [330, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u126322807", "n_user": "u126322807", "pos": "#!/usr/bin/env python\n\nn = int(input())\n\ntScore = 0\nhScore = 0\n\nfor i in range(n):\n T, H = input().split()\n if T == H:\n tScore += 1\n hScore += 1\n elif T > H:\n tScore += 3\n elif H > T:\n hScore +=3\nprint(\"%d %d\" % (tScore, hScore))", "neg": "#!/usr/bin/env python\n\nn = int(input())\n\ntScore = 0\nhScore = 0\n\nfor i in range(n):\n T, H = input().split()\n if T == H:\n tScore += 1\n hScore += 1\n elif T > H:\n hScore +=3\n elif H > T:\n tScore += 3\nprint(\"%d %d\" % (tScore, hScore))", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [107, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u654414650", "n_user": "u654414650", "pos": "#coding:utf-8\n\nn = int(input().rstrip())\ntoku =[0,0]\nnarabe = []\n\nfor i in range(n):\n taro, hana = input().rstrip().split()\n if taro == hana:\n toku[0] +=1\n toku[1] +=1\n\n else:\n narabe = [taro, hana]\n narabe.sort()\n toku[0] += narabe.index(taro)*3\n toku[1] += narabe.index(hana)*3\n \nprint(\" \".join(list(map(str,toku))))", "neg": "#coding:utf-8\n\nn = int(input().rstrip())\ntoku =[0,0]\nnarabe = []\n\nfor i in range(n):\n taro, hana = input().rstrip().split()\n if taro == hana:\n toku[0] +=1\n toku[1] +=1\n\n else:\n narabe = [taro, hana]\n narabe.sort()\n toku[0] += narabe.index(taro)*3\n toku[1] += narabe.index(hana)*3\n \nprint(\" \".join(toku))", "jacc_sim": 0.926829268292683, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [168, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u283452598", "n_user": "u283452598", "pos": "turn=int(input())\nten=[0,0]\n\nfor _ in range(turn):\n hikaku = input().split()\n if hikaku[0] < hikaku[1]:\n ten[1] +=3\n\n elif hikaku[0] > hikaku[1]:\n ten[0] +=3\n\n else:\n ten[0]+=1\n ten[1]+=1\n\nprint(\" \".join(map(str,ten)))", "neg": "turn=int(input())\nten=[0,0]\n\nfor _ in range(turn):\n hikaku = list(map(int,input().split()))\n if hikaku[0] < hikaku[1]:\n ten[1] +=3\n\n elif hikaku[0] > hikaku[1]:\n ten[0] +=3\n\n else:\n ten[0]+=1\n ten[1]+=1\n\nprint(\" \".join(map(str,ten)))", "jacc_sim": 0.9696969696969697, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [120, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u518939641", "n_user": "u518939641", "pos": "t=0\nh=0\nfor i in range(int(input())):\n l=input().split()\n if l[0]==l[1]:\n t+=1\n h+=1\n elif l[0]>l[1]: t+=3\n else: h+=3\nprint(t,h)", "neg": "t=0\nh=0\nfor i in range(int(input())):\n l=input().split()\n if l[0]=l[1]:\n t+=1\n h+=1\n elif l[0]>l[1]: t+=3\n else: h+=3\nprint(t,h)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [82, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u126478680", "n_user": "u126478680", "pos": "#! python3\n# card_game.py\n\nn = int(input())\nturns = [input() for i in range(n)]\n\ntaro, hanako = 0, 0\nfor turn in turns:\n t, h = turn.split(' ')\n min_len = len(t) if len(t) <= len(h) else len(h)\n\n win_flag = 0 # -1: taro, 1: hanako, 0: draw\n for i in range(min_len):\n if ord(t[i]) < ord(h[i]):\n win_flag = 1\n break\n elif ord(h[i]) < ord(t[i]):\n win_flag = -1\n break\n\n if win_flag == 0:\n if len(t) < len(h):\n win_flag = 1\n elif len(h) < len(t):\n win_flag = -1\n\n if win_flag == -1:\n taro += 3\n elif win_flag == 1:\n hanako += 3\n else:\n taro += 1\n hanako += 1\n\nprint(taro, hanako)\n", "neg": "#! python3\n# card_game.py\n\nn = int(input())\nturns = [input() for i in range(n)]\n\ntaro, hanako = 0, 0\nfor turn in turns:\n t, h = turn.split(' ')\n min_len = len(t) if len(t) <= len(h) else len(h)\n\n win_flag = 0 # -1: taro, 1: hanako, 0: draw\n for i in range(min_len):\n if ord(t[i]) < ord(h[i]):\n win_flag = 1\n elif ord(h[i]) < ord(t[i]):\n win_flag = -1\n\n if win_flag == 0:\n if len(t) < len(h):\n win_flag = 1\n elif len(h) < len(t):\n win_flag = -1\n\n if win_flag == -1:\n taro += 3\n elif win_flag == 1:\n hanako += 3\n else:\n taro += 1\n hanako += 1\n\nprint(taro, hanako)\n", "jacc_sim": 0.9772727272727273, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [293, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u986478725", "n_user": "u986478725", "pos": "# AOJ ITP1_9_C\n\ndef numinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef main():\n SCORE_taro = 0\n SCORE_hanako = 0\n n = int(input())\n for i in range(n):\n words = input().split()\n if words[0] > words[1]: SCORE_taro += 3\n elif words[0] < words[1]: SCORE_hanako += 3\n else:\n SCORE_taro += 1; SCORE_hanako += 1\n print(str(SCORE_taro) + \" \" + str(SCORE_hanako))\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# AOJ ITP1_9_C\n\ndef numinput():\n a = input().split()\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\ndef main():\n SCORE_taro = 0\n SCORE_hanako = 0\n n = int(input())\n for i in range(n):\n words = input()\n if words[0] > words[1]: SCORE_taro += 3\n elif words[0] < words[1]: SCORE_hanako += 3\n else:\n SCORE_taro += 1; SCORE_hanako += 1\n print(str(SCORE_taro) + \" \" + str(SCORE_hanako))\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [203, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u940150266", "n_user": "u940150266", "pos": "a = 0\nb = 0\nnum = int(input())\nfor i in range(num):\n s1,s2 = input().split()\n s1 = s1.lower()\n s2 = s2.lower()\n if s1 < s2:\n b += 3\n elif s1 > s2:\n a += 3\n else:\n a += 1\n b += 1\nprint(a,b)\n\n", "neg": "a = 0\nb = 0\nnum = int(input())\nfor i in range(num):\n s1,s2 = input().split()\n s1 = s1.lower()\n s2 = s2.lower()\n if s1 < s2:\n b += 3\n elif s1 > s2:\n a += 3\n else:\n a += 1\n b += 1\nprint(a,' ',b)\n\n", "jacc_sim": 0.9666666666666667, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [105, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u327546577", "n_user": "u327546577", "pos": "taro = 0\nhana = 0\nn = int(input())\nfor _ in range(n):\n taro_s, hana_s = map(str, input().split())\n if taro_s > hana_s:\n taro += 3\n elif hana_s > taro_s:\n hana += 3\n else:\n taro += 1\n hana += 1\nprint(taro, hana)\n\n", "neg": "taro = 0\nhana = 0\nn = int(input())\nfor _ in range(n):\n taro_s, hana_s = map(str, input().split())\n if taro_s < hana_s:\n taro += 3\n elif hana_s < taro_s:\n hana += 3\n else:\n taro += 1\n hana += 1\nprint(taro, hana)\n\n", "jacc_sim": 0.9333333333333333, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u929141425", "n_user": "u929141425", "pos": "n = int(input())\nT = H = 0\nfor x in range(n):\n t, h = input().split()\n tl = list(t)\n hl = list(h)\n z = min([int(len(tl)),int(len(hl))])\n for k in range(z):\n if ord(tl[k]) > ord(hl[k]):\n T += 3\n break\n elif ord(tl[k]) == ord(hl[k]):\n pass\n else:\n H += 3\n break\n else:\n if len(hl) == len(tl):\n T += 1\n H += 1\n elif z == len(tl):\n H += 3\n else:\n T += 3\nprint(f\"{str(T)} {str(H)}\")\n\n\n\n", "neg": "n = int(input())\nT = H = 0\nfor x in range(n):\n t, h = input().split()\n tl = list(t)\n hl = list(h)\n z = min([int(len(tl)),int(len(hl))])\n for k in range(z):\n if ord(tl[k]) > ord(hl[k]):\n T += 3\n break\n elif ord(tl[k]) == ord(hl[k]):\n pass\n else:\n H += 3\n break\n else:\n if len(hl) == len(tl):\n T += 1\n H += 1\n elif z == len(tl):\n H += 3\n else:\n T += 3\n print(f\"{str(T)} {str(H)}\")\nprint(f\"{str(T)} {str(H)}\")\n\n\n\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [200, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u288578617", "n_user": "u742505495", "pos": "n=int(input())\na=0\nb=0\nfor i in range(n):\n A,B=map(str,input().split())\n if A>B:\n a+=3\n elif A==B:\n a+=1\n b+=1\n else:\n b+=3\nprint(a,b)\n \n \n", "neg": "n = int(input())\na = 0\nb = 0\nfor i in range(n):\n\tA,B = map(str,input().split())\n\tif A>B:\n\t\ta += 3\n\telif B>A:\n\t\tb += 3\n\telse:\n\t\ta += 1\n\t\tb += 1\nprint('%d %d'.(a,b))\n", "jacc_sim": 0.90625, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [89, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u251178502", "n_user": "u224288634", "pos": "n = int(input())\n\ntaro_score = 0\nhanako_score = 0\n\nfor i in range(n):\n taro,hanako = input().split()\n\n if taro>hanako:\n taro_score +=3\n elif taro hanako :\n\t\ttaro_score += 3\n\telif taro == hanako :\n\t\ttaro_score += 1\n\t\thanako_score += 1\n\telse :\n\t\thanako_score += 3\n\tprint '%d %d' %(taro_score,hanako_score)", "jacc_sim": 0.90625, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [127, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u959615339", "n_user": "u317583692", "pos": "n = int(input())\nTaro = 0\nHanako = 0\nfor i in range(n):\n T, H = map(str,input().split())\n if T > H:\n Taro += 3\n elif H > T:\n Hanako += 3\n else:\n Taro += 1\n Hanako += 1\nprint(Taro, Hanako)\n\n", "neg": "\nTaro = 0\nHanako = 0\n\nn = int(input())\n\nfor i in range(n):\n T,H = map(str, input().split())\n if T > H:\n Taro += 3\n elif T = H:\n Taro += 1\n Hanako += 1\n else:\n Hanako += 3\n\nprint(Taro, Hanako)\n\n", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [99, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u506537276", "n_user": "u498041957", "pos": "n = int(input())\ntaro = 0\nhanako = 0\nfor i in range(n):\n t, h = input().split()\n if t > h:\n taro += 3\n elif t < h:\n hanako += 3\n else:\n taro += 1\n hanako += 1\nprint(taro, hanako)\n", "neg": "n = int(input())\n\ntaro = 0\nhanako = 0\nfor ni in range(n):\n t, h = input().split()\n \n if t < h:\n hanako += 3\n elif t > h:\n taro += 3\n else:\n hanako += 1\n taro += 1\n\nprint(taro.hanako)", "jacc_sim": 0.9310344827586207, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [93, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02421", "p_user": "u962909487", "n_user": "u805716376", "pos": "N = int(input())\nx = 0\ny = 0\nfor i in range(N):\n a,b = input().split()\n if ab:\n t += 3\n else:\n h += 1\n t += 1\nprint(t, h)\n", "neg": "t,h=0,0\nn=int(input())\nfor i in range(n):\n a,b=input().split()\n if a > b:\n h+=3\n elif a < b:\n t+=3\n else:\n t+=1\n h+=1\nprint(t, h)", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nTaro and Hanako are playing a card game. Each has \"n\" cards, and they play \"n\" turns. At each turn, they each play a card with an animal name written on it. The player with the card containing the larger animal name in lexicographical order wins the turn and gets 3 points. In case of a draw, both players get 1 point.\n\nWrite a program to read the sequence of cards Taro and Hanako have and report the final scores of the game.\n\nInput:\nThe first line contains the number of cards \"n\". The following \"n\" lines contain the cards for \"n\" turns, with the first string representing Taro's card and the second one representing Hanako's card.\n\nConstraints:\n- n \u2264 1000\n- The length of the string \u2264 100\n\nOutput:\nPrint the final scores of Taro and Hanako respectively, with a single space character between them.\n\nSample Input:\n3\ncat dog\nfish fish\nlion tiger\n\nSample Output:\n1 7", "before_after_length": [78, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u400765446", "n_user": "u400765446", "pos": "def main():\n\n strTxt = input()\n n = int(input())\n for _ in range(n):\n strCmd = input().split()\n \n if strCmd[0] == 'print':\n funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))\n elif strCmd[0] == 'reverse':\n strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))\n elif strCmd[0] == 'replace':\n strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])\n\ndef funcPrint(strInput: str,a: int,b: int):\n print(strInput[a:b+1])\n\ndef funcReverse(strInput: str,a: int,b: int):\n return strInput[:a]+strInput[a:b+1][::-1]+strInput[b+1:]\n\ndef funcReplace(strInput: str,a: int,b: int, strAfter: str):\n return strInput[:a]+strAfter+strInput[b+1:]\n\n\nif __name__ == '__main__':\n main()\n\n", "neg": "def main():\n\n strTxt = input()\n n = int(input())\n for _ in range(n):\n strCmd = input().split()\n \n if strCmd[0] == 'print':\n funcPrint(strTxt, int(strCmd[1]), int(strCmd[2]))\n elif strCmd[0] == 'reverse':\n strTxt = funcReverse(strTxt, int(strCmd[1]), int(strCmd[2]))\n elif strCmd[0] == 'replace':\n strTxt = funcReplace(strTxt, int(strCmd[1]), int(strCmd[2]), strCmd[3])\n\ndef funcPrint(strInput: str,a: int,b: int):\n print(strInput[a:b+1])\n\ndef funcReverse(strInput: str,a: int,b: int):\n return strInput[:a]+strInput[::-1][a:b+1]+strInput[b+1:]\n\ndef funcReplace(strInput: str,a: int,b: int, strAfter: str):\n return strInput[:a]+strAfter+strInput[b+1:]\n\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [295, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u874395007", "n_user": "u874395007", "pos": "S = str(input())\nN = int(input())\nfor _i in range(N):\n line = input().split()\n start = int(line[1])\n end = int(line[2])\n\n if line[0] == 'print':\n print(S[start:end + 1])\n if line[0] == 'reverse':\n reversed_word = list(S[start:end + 1])\n reversed_word.reverse()\n S = S[:start] + ''.join(reversed_word) + S[end + 1:]\n if line[0] == 'replace':\n S = S[:start] + line[3] + S[end + 1:]\n\n", "neg": "S = str(input())\nN = int(input())\nfor _i in range(N):\n line = input().split()\n start = int(line[1])\n end = int(line[2])\n\n if line[0] == 'print':\n print(S[start:end + 1])\n if line[0] == 'reverse':\n reversed_word = list(S[start:end + 1])\n reversed_word.reverse()\n S = S[:start] + ''.join(reversed_word) + S[end + 1:]\n if line[0] == 'replace':\n S = S[:start] + line[3] + S[end + 1:]\n print(S)\n\n", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [167, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u823030818", "n_user": "u823030818", "pos": "text = input()\ncount = int(input())\n\nfor c in range(count):\n args = input().split()\n (a, b) = [int(x) for x in args[1:3]]\n if args[0] == 'print':\n print(text[a:b + 1])\n elif args[0] == 'reverse':\n text = text[0:a] + text[a:b + 1][::-1] + text[b + 1:]\n elif args[0] == 'replace':\n text = text[0:a] + args[3] + text[b + 1:]", "neg": "text = input()\ncount = int(input())\n\nfor c in range(count):\n args = input().split()\n (a,b) = [int(x) for x in args[1:3]]\n if args[0] == 'print':\n print(text[a:b + 1])\n elif args[0] == 'reverse':\n text = text[0:a] + text[a:b][::-1] + text[b + 1:]\n elif args[0] == 'replace':\n text = text[0:a] + args[3] + text[b + 1:]", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [148, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u370429022", "n_user": "u370429022", "pos": "if __name__ == '__main__':\n s = input()\n q = int(input())\n for i in range(q):\n code = input().split()\n op, a, b = code[0], int(code[1]), int(code[2])\n if op == 'print':\n print(s[a:b+1])\n elif op == 'reverse':\n s = s[:a] + s[a:b+1][::-1] + s[b+1:]\n elif op == 'replace':\n s = s[:a] + code[3] + s[b+1:]", "neg": "if __name__ == '__main__':\n s = input()\n q = int(input())\n for i in range(q):\n code = input().split()\n op, a, b = code[0], int(code[1]), int(code[2])\n if op == 'print':\n print(s[a:b+1])\n elif op == 'reverse':\n s = s[:a] + s[a:b+1][::-1] + s[b+1:]\n elif op == 'replace':\n s = s[:a] + p + s[b+1:]", "jacc_sim": 0.9444444444444444, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [149, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u609407244", "n_user": "u609407244", "pos": "string = input()\nn = int(input())\nfor _ in range(n):\n query = input().split()\n if query[0] == 'replace':\n op, a, b, p = query\n a, b = int(a), int(b)\n string = string[:a] + p + string[b + 1:]\n elif query[0] == 'reverse':\n op, a, b = query\n a, b = int(a), int(b)\n string = string[:a] + ''.join(reversed(string[a:b + 1])) + string[b + 1:]\n elif query[0] == 'print':\n op, a, b = query\n a, b = int(a), int(b)\n print(string[a: b + 1])", "neg": "string = input()\nn = int(input())\nfor _ in range(n):\n query = input().split()\n if query[0] == 'replace':\n op, a, b, p = query\n a, b = int(a), int(b)\n string = string[:a] + p * (b - a + 1) + string[b + 1:]\n elif query[0] == 'reverse':\n op, a, b = query\n a, b = int(a), int(b)\n string = string[:a] + ''.join(reversed(string[a:b + 1])) + string[b + 1:]\n elif query[0] == 'print':\n op, a, b = query\n a, b = int(a), int(b)\n print(string[a: b + 1])", "jacc_sim": 0.9428571428571428, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [191, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u811841526", "n_user": "u811841526", "pos": "s = input()\nn = int(input())\nfor _ in range(n):\n line = input().split()\n command, args = line[0], line[1:]\n start = int(args[0])\n end = int(args[1]) + 1\n if command == 'replace':\n s = s[:start] + args[2] + s[end:]\n elif command == 'reverse':\n s = s[:start] + str(''.join(list(reversed(s[start:end])))) + s[end:]\n elif command == 'print':\n print(s[start:end])", "neg": "s = input()\nn = int(input())\nfor _ in range(n):\n line = input().split()\n command, args = line[0], line[1:]\n if command == 'replace':\n start = int(args[0])\n end = int(args[1]) + 1\n s = s[:start] + args[2] + s[end:]\n elif command == 'reverse':\n start = int(args[0])\n end = int(args[1]) + 1\n s = s[:start] + str(''.join(list(reversed(s[start:end])))) + s[end:]\n elif command == 'print':\n print(s)", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [146, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u896065593", "n_user": "u896065593", "pos": "# ????????? str ?????????????????????????????????????????????????????????????????\u00b0??????\n\n# ?????\\????\u00b1??????????str????\u00a8??????\\???????????????\nstr = list(input())\nstr = \"\".join(str)\n# ?????\\???????????\u00b0p????\u00a8??????\\???????????????\np = int(input())\n# p??????????????????????????????????????????\norderList = [0 for i in range(p)]\nfor i in range(0, p):\n orderList[i] = list(input())\n orderList[i] = \"\".join(orderList[i]).split()\n if orderList[i][0] == \"print\":\n print(\"{0}\".format(str[int(orderList[i][1]):int(orderList[i][2]) + 1]))\n elif orderList[i][0] == \"reverse\":\n str = str[0:int(orderList[i][1])] + str[-len(str) + int(orderList[i][2]):-len(str) + int(orderList[i][1]) - 1:-1] + str[int(orderList[i][2]) + 1:]\n elif orderList[i][0] == \"replace\":\n str = str[:int(orderList[i][1])] + orderList[i][3] + str[int(orderList[i][2]) + 1:]", "neg": "# ????????? str ?????????????????????????????????????????????????????????????????\u00b0??????\n\n# ?????\\????\u00b1??????????str????\u00a8??????\\???????????????\nstr = list(input())\nstr = \"\".join(str)\n# ?????\\???????????\u00b0p????\u00a8??????\\???????????????\np = int(input())\n# p??????????????????????????????????????????\norderList = [0 for i in range(p)]\nfor i in range(0, p):\n orderList[i] = list(input())\n orderList[i] = \"\".join(orderList[i]).split()\n if orderList[i][0] == \"print\":\n print(\"{0}\".format(str[int(orderList[i][1]) - 1:int(orderList[i][2])]))\n elif orderList[i][0] == \"reverse\":\n str = str[0:int(orderList[i][1]) - 1] + str[-len(str) + int(orderList[i][2]) - 1:-len(str) + int(orderList[i][1]) - 2:-1] + str[int(orderList[i][2]):len(str)]\n elif orderList[i][0] == \"replace\":\n # ??????????????\u00a8?????????replace_str\n replace_str = str[:int(orderList[i][1]) - 1]\n for j in range(0, int(orderList[i][2])):\n replace_str += orderList[i][3]\n replace_str += str[int(orderList[i][2]):]\n str = replace_str", "jacc_sim": 0.9555555555555556, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [400, 466], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u498041957", "n_user": "u506705885", "pos": "s = input()\n \nfor i in range(int(input())):\n cmd = input().split()\n a, b = int(cmd[1]), int(cmd[2])\n \n if cmd[0] == 'print':\n print(s[a:b+1])\n elif cmd[0] == 'reverse':\n s = s[:a] + s[a:b+1][::-1] + s[b+1:]\n elif cmd[0] == 'replace':\n s = s[:a] + cmd[3] + s[b+1:]", "neg": "\ns = input()\n????\nfor i in range(int(input())):\n????????cmd = input().split()\n????????a,b = [int(x) for x in cmd[1:3]]\n????\n????????if cmd[0] == 'print':\n????????????????print(s[a:b+1])\n????????elif cmd[0] == 'reverse':\n????????????????s = s[:a] + s[a:b+1][::-1] + s[b+1:]\n????????elif cmd[0] == 'replace':\n????????????????s = s[:a] + cmd[3] + s[b+1:]", "jacc_sim": 0.9090909090909091, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [139, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u391228754", "n_user": "u391228754", "pos": "s = input()\nn = int(input())\n\nfor i in range(n):\n p = input().split()\n\n a, b = [int(x) for x in p[1:3]]\n if p[0]==\"print\":\n print(s[a:b+1])\n elif p[0]==\"replace\":\n s = s[:a] + p[3] + s[b+1:]\n elif p[0]==\"reverse\":\n s = s[:a] + s[a:b+1][::-1] + s[b+1:]", "neg": "s = input()\nn = int(input())\nfor i in range(n):\n p = input().split()\n \n a, b = [int(x) for x in p[1:3]]\n if p[0]==\"print\":\n print(s[a:b+1])\n if p[0]==\"replace\":\n s = s[:a] + p[3] + s[b+1:]\n if p[0]==\"reverse\":\n s = s[:a] + s[a:b+1:-1] + s[b+1:]", "jacc_sim": 0.96875, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [139, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u854978981", "n_user": "u854978981", "pos": "string = input()\nq = int(input())\nfor c in range(0,q):\n instruction = input().split(' ')\n if instruction[0] == 'print':\n print(string[int(instruction[1]):int(instruction[2]) + 1])\n elif instruction[0] == 'reverse':\n string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)\n elif instruction[0] == 'replace':\n string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[2])+1:]", "neg": "string = input()\nq = int(input())\nfor c in range(0,q):\n instruction = input().split(' ')\n if instruction[0] == 'print':\n print(string[int(instruction[1]):int(instruction[2]) + 1])\n elif instruction[0] == 'reverse':\n string = string.replace(string[int(instruction[1]):int(instruction[2])+1], string[int(instruction[1]):int(instruction[2])+1][::-1], 1)\n elif instruction[0] == 'replace':\n string = string[:int(instruction[1])] + instruction[3] + string[int(instruction[1])+1:]", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [165, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u144068724", "n_user": "u144068724", "pos": "line = input()\nn = int(input())\nfor i in range(n):\n order = input().split()\n if order[0] == \"print\":\n print(line[int(order[1]):int(order[2])+1])\n elif order[0] == \"reverse\":\n tmp = line[int(order[1]) :int(order[2])+1 ]\n line = line[:int(order[1])] + tmp[::-1] + line[int(order[2])+1:]\n elif order[0] == \"replace\":\n line = line[:int(order[1])] + order[3] + line[int(order[2])+1:]", "neg": "line = input()\nn = int(input())\nfor i in range(n):\n order = input().split()\n if order[0] == \"print\":\n print(line[int(order[1])-1:int(order[2])-1])\n elif order[0] == \"reverse\":\n tmp = line[int(order[1]) - 1:int(order[2]) - 1]\n line = line[:int(order[1]) - 1] + tmp[::-1] + line[int(order[2]) - 1:]\n elif order[0] == \"replace\":\n line = line[:int(order[1]) - 1] + order[3] + line[int(order[2]) - 1:]", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [166, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u104171359", "n_user": "u104171359", "pos": "#!usr/bin/env python3\n\nimport sys\n\n\ndef main():\n s = sys.stdin.readline().strip('\\n')\n q = int(sys.stdin.readline().strip('\\n'))\n\n for instruction in range(q):\n words = [word for word in sys.stdin.readline().strip('\\n').split()]\n if words[0] == 'replace':\n s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]\n elif words[0] == 'reverse':\n s = s[:int(words[1])] \\\n + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \\\n + s[int(words[2])+1:]\n elif words[0] == 'print':\n print(s[int(words[1]):int(words[2])+1])\n\n\nif __name__ == '__main__':\n main()", "neg": "#!usr/bin/env python3\n\nimport sys\n\n\ndef main():\n s = sys.stdin.readline().strip('\\n')\n q = int(sys.stdin.readline().strip('\\n'))\n\n for instruction in range(q):\n words = [word for word in sys.stdin.readline().strip('\\n').split()]\n print(words)\n if words[0] == 'replace':\n s = s[:int(words[1])] + words[3] + s[int(words[2])+1:]\n elif words[0] == 'reverse':\n s = s[:int(words[1])] \\\n + ''.join(reversed(s[int(words[1]):int(words[2])+1])) \\\n + s[int(words[2])+1:]\n elif words[0] == 'print':\n print(s[int(words[1]):int(words[2])+1])\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [245, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u780342333", "n_user": "u780342333", "pos": "s = input()\nline = int(input())\n\nfor i in range(line):\n param = input().split(\" \")\n\n if len(param) == 4: ope, a, b, p = param\n else: ope, a, b = param\n\n a,b = int(a), int(b)\n\n if ope == \"print\":\n print(s[a:b+1])\n elif ope == \"reverse\":\n rev = s[a:b+1][::-1]\n s = (s[:a] + rev + s[b+1:])\n elif ope == \"replace\":\n s = (s[:a] + p + s[b+1:])", "neg": "s = input()\nline = int(input())\n\nfor i in range(line):\n param = input().split(\" \")\n\n if len(param) == 4: ope, a, b, p = param\n else: ope, a, b = param\n\n a,b = int(a), int(b)\n\n if ope == \"print\":\n print(s[a:b+1])\n elif ope == \"reverse\":\n rev = s[a:b+1][::-1]\n print(rev)\n s = (s[:a] + rev + s[b+1:])\n elif ope == \"replace\":\n s = (s[:a] + p + s[b+1:])", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [171, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u921541953", "n_user": "u921541953", "pos": "str, q = input(), int(input())\nfor i in range(q):\n com = input().strip().split()\n if com[0] == 'print':\n print(str[int(com[1]):int(com[2])+1])\n elif com[0] == 'reverse':\n str = list(str)\n str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-len(str)-1:-1]\n str = ''.join(str)\n elif com[0] == 'replace':\n str = list(str)\n str[int(com[1]):int(com[2])+1] = com[3]\n str = ''.join(str)", "neg": "str, q = input(), int(input())\nfor i in range(q):\n com = input().strip().split()\n if com[0] == 'print':\n print(str[int(com[1]):int(com[2])+1])\n elif com[0] == 'reverse':\n str = list(str)\n str[int(com[1]):int(com[2])+1] = str[int(com[2]):int(com[1])-6:-1]\n str = ''.join(str)\n print(str)\n elif com[0] == 'replace':\n str = str.replace(str[int(com[1]):int(com[2])+1], com[3])\n print(str)", "jacc_sim": 0.9428571428571428, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [190, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u362104929", "n_user": "u362104929", "pos": "def main():\n class MyClass:\n def __init__(self):\n self.strings = \"\"\n\n def rpl(self, int1, int2, str1):\n self.strings = self.strings[:int1] + str1 + self.strings[int2+1:]\n\n def rvr(self, int1, int2):\n if int1 >= 1:\n revstr = self.strings[int2:int1-1:-1]\n else:\n revstr = self.strings[int2::-1]\n self.strings = self.strings[:int1] + revstr + self.strings[int2+1:]\n\n def pri(self, int1, int2):\n print(self.strings[int1:int2+1])\n\n cls = MyClass()\n cls.strings = input()\n n = int(input())\n for _ in range(n):\n li = input().split()\n if li[0] == \"replace\":\n cls.rpl(int(li[1]), int(li[2]), li[3])\n elif li[0] == \"reverse\":\n cls.rvr(int(li[1]), int(li[2]))\n elif li[0] == \"print\":\n cls.pri(int(li[1]), int(li[2]))\n\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n class MyClass:\n def __init__(self):\n self.strings = \"\"\n\n def rpl(self, int1, int2, str1):\n self.strings = self.strings[:int1] + str1 + self.strings[int2+1:]\n #self.strings = self.strings.replace(self.strings[int1:int2+1], str1)\n print(self.strings)\n\n def rvr(self, int1, int2):\n if int1 >= 1:\n revstr = self.strings[int2:int1-1:-1]\n else:\n revstr = self.strings[int2::-1]\n self.strings = self.strings[:int1] + revstr + self.strings[int2+1:]\n print(self.strings)\n\n def pri(self, int1, int2):\n print(self.strings[int1:int2+1])\n\n cls = MyClass()\n cls.strings = input()\n n = int(input())\n for _ in range(n):\n li = input().split()\n if li[0] == \"replace\":\n cls.rpl(int(li[1]), int(li[2]), li[3])\n elif li[0] == \"reverse\":\n cls.rvr(int(li[1]), int(li[2]))\n elif li[0] == \"print\":\n cls.pri(int(li[1]), int(li[2]))\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.98, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [341, 385], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u650790815", "n_user": "u650790815", "pos": "s = input()\nn = int(input())\nfor i in range(n):\n cmd = input().split()\n a,b = map(int,[cmd[1],cmd[2]])\n if cmd[0] == 'print':print(s[a:b+1])\n elif cmd[0] == 'reverse':s = s[:a] + s[a:b+1][::-1] + s[b+1:]\n elif cmd[0] == 'replace':s = s[:a] + cmd[3] + s[b+1:]", "neg": "s = input()\nn = int(input())\nfor i in ragne(n):\n cmd = input().split()\n a,b = map(int,[cmd[1],cmd[2]])\n if cmd[0][0] == 'p':print(s)\n elif cmd[0] =='replace':\n s = s[:a] + cmd[3] + s[b+1:]\n elif cmd[0] =='reverse':\n s = s[:a] + s[a:b+1][::-1] + s[b+1:]", "jacc_sim": 0.9142857142857143, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [134, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u957680575", "n_user": "u957680575", "pos": "S=input()\nm=int(input())\nfor i in range(m):\n C=input().split()\n a=int(C[1])\n b=int(C[2])+1\n if C[0]==\"print\":\n print(S[a:b])\n elif C[0]==\"reverse\":\n S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]\n \n elif C[0]==\"replace\":\n S=S[:a]+C[3]+S[b:]\n ", "neg": "S=input()\nm=int(input())\nfor i in range(m):\n C=input().split()\n a=int(C[1])\n b=int(C[2])+1\n if C[0]==\"print\":\n print(S[a:b])\n elif C[0]==\"reverse\":\n S=S[:a]+S[b-len(S)-1:a-len(S)-1:-1]+S[b:]\n print(S)\n elif C[0]==\"replace\":\n S=S[:a]+C[3]+S[b:]\n print(S)", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [142, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u498511622", "n_user": "u498511622", "pos": "str_1=input()\nq=int(input())\nfor _ in range(q):\n lst=list(input().split())\n res = (lst[0])\n a = int(lst[1])\n b = int(lst[2])+1\n \n if res=='print':\n print(str_1[a:b])\n elif res=='replace':\n str_1=str_1[:a]+lst[3]+str_1[b:]\n elif res=='reverse':\n str_1=str_1[:a] + str_1[a:b][::-1] + str_1[b:]", "neg": "str_1=input()\nq=int(input())\nfor _ in range(q):\n lst=list(input().split())\n res = (lst[0])\n a = int(lst[1])\n b = int(lst[2])+1\n \n if res=='print':\n str_1=str_1[a:b]\n elif res=='replace':\n str_1=str_1[:a]+lst[3]+str_1[b:]\n elif res=='reverse':\n str_1=str_1[:a] + str_1[a:b][::-1] + str_1[b:]\nprint(str_1)", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [150, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u283452598", "n_user": "u283452598", "pos": "moto = input()\nnum = int(input())\n\nfor i in range(num):\n order = input().split()\n if order[0] == \"print\":\n m,n=int(order[1]),int(order[2])\n print(moto[m:n+1])\n elif order[0] == \"reverse\":\n m,n=int(order[1]),int(order[2])\n moto = moto[:m]+moto[m:n+1][::-1]+moto[n+1:]\n elif order[0] == \"replace\":\n m,n,l=int(order[1]),int(order[2]),order[3]\n moto = moto[:m]+order[3]+moto[n+1:]", "neg": "moto = input()\nnum = int(input())\n\nfor i in range(num):\n order = input().split()\n if order[0] == \"print\":\n m,n=int(order[1]),int(order[2])\n print(moto[m:n+1])\n elif order[0] == \"reverse\":\n m,n=int(order[1]),int(order[2])\n moto = moto[:m]+moto[n:m-1:-1]+moto[n+1:]\n elif order[0] == \"replace\":\n m,n,l=int(order[1]),int(order[2]),order[3]\n moto = moto[:m]+order[3]+moto[n+1:]", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [190, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u506705885", "n_user": "u506705885", "pos": "s=input()\nfor i in range(int(input())):\n sou_com=input().split()\n if sou_com[0]=='print':\n print(s[int(sou_com[1]):int(sou_com[2])+1])\n elif sou_com[0]=='reverse':\n s=s[:int(sou_com[1])]\\\n +s[int(sou_com[1]):int(sou_com[2])+1][::-1]\\\n +s[int(sou_com[2])+1:]\n elif sou_com[0]=='replace':\n s=s[:int(sou_com[1])]\\\n +sou_com[3]\\\n +s[int(sou_com[2])+1:]", "neg": "s=input()\nfor i in range(int(input())):\n sou_com=input().split()\n if sou_com[0]=='print':\n print(s[int(sou_com[1])-1:int(sou_com[2])])\n elif sou_com[0]=='reverse':\n s=s[:int(sou_com[1])-1]\\\n +s[int(sou_com[1])-1:int(sou_com[2])][::-1]\\\n +s[int(sou_com[2]):]\n elif sou_com[0]=='replace':\n s=s[:int(sou_com[1])-1]\\\n +sou_com[3]\\\n +s[int(sou_com[2]):]", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [201, 203], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u444576298", "n_user": "u444576298", "pos": "#coding: utf-8\n\ns = input()\nq = int(input())\nfor i in range(q):\n order = input().split(\" \")\n if order[0] == \"print\":\n print(s[int(order[1]) : int(order[2])+1])\n elif order[0] == \"reverse\":\n r = s[int(order[1]) : int(order[2])+1]\n r = r[::-1]\n s = s[:int(order[1])] + r + s[int(order[2])+1:]\n elif order[0] == \"replace\":\n s = s[:int(order[1])] + order[3] + s[int(order[2])+1:]\n\n", "neg": "#coding: utf-8\n\ns = input()\nq = int(input())\nfor i in range(q):\n order = input().split(\" \")\n if order[0] == \"print\":\n print(s[int(order[1]) : int(order[2])+1])\n print(\" \" + s)\n elif order[0] == \"reverse\":\n r = s[int(order[1]) : int(order[2])+1]\n print(\"r: \" + r)\n r = r[::-1]\n print(\"r: \" + r)\n s = s[: int(order[1])] + r + s[int(order[2])+1:]\n print(\" \" + s)\n\n elif order[0] == \"replace\":\n s = s[: int(order[1])] + order[3] + s[int(order[2])+1:]\n print(\" \" + s)\n\n", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [183, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u150984829", "n_user": "u150984829", "pos": "s=input()\nfor _ in[0]*int(input()):\n a=input().split()\n o=a[0];i=int(a[1]);j=int(a[2])+1\n if'p'==o[0]:print(s[i:j])\n else:\n t=a[3]if'p'==o[2]else s[i:j][::-1]\n s=s[0:i]+t+s[j:]\n", "neg": "s=input()\nfor _ in range(int(input())):\n a=input().split()\n o=a[0];i=int(a[1]);j=int(a[2])+1\n if'p'==o[0]:print(s[i:j])\n else:\n t=(s[i:j][::-1],a[3])['p'==o[2]]\n s=s[0:i]+t+s[j:]\n", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [114, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u843169619", "n_user": "u843169619", "pos": "def convert():\n str = input().rstrip()\n n = int(input().rstrip())\n \n for _ in range(n):\n columns = input().rstrip().split()\n order = columns[0]\n a = int(columns[1])\n b = int(columns[2])\n \n if order == 'print':\n print(str[a:b+1])\n \n if order == 'reverse':\n str = str[:a] + str[a:b+1][::-1] + str[b+1:]\n \n if order == 'replace': \n p = columns[3]\n str = str[:a] + p + str[b+1:] \nif __name__ == '__main__':\n convert()\n", "neg": "\ndef convert():\n str = input().rstrip()\n n = int(input().rstrip())\n \n for _ in range(n):\n columns = input().rstrip().split()\n order = columns[0]\n a = int(columns[1])\n b = int(columns[2])\n\n \n if order == 'print':\n print(str[a:b+1])\n \n if order == 'reverse':\n str = str[a:b+1][::-1]\n \n if order == 'replace': \n p = columns[3]\n str = str[:a] + p + str[b+1:]\nif __name__ == '__main__':\n convert()\n", "jacc_sim": 1.0, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [185, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u485986915", "n_user": "u485986915", "pos": "s = input()\nn = int(input())\n\nfor i in range(n):\n command = input().split()\n if command[0] == 'replace':\n a,b = map(int,command[1:3])\n s = s[:a]+ command[3] + s[b+1:]\n elif command[0] == 'reverse':\n a,b = map(int,command[1:3])\n s = s[0:a] + s[a:b+1][::-1] + s[b+1:]\n elif command[0] == 'print': \n a,b = map(int,command[1:3])\n print(s[a:b+1])\n", "neg": "s = input()\nn = int(input())\n\nfor i in range(n):\n command = input().split()\n if command[0] == 'replace':\n a,b = map(int,command[1:3])\n s = s[:a]+ command[3] + s[b+1:]\n elif command[0] == 'reverse':\n a,b = map(int,command[1:3])\n s[a:b+1] = s[b+1:a]\n elif command[0] == 'print': \n a,b = map(int,command[1:3])\n print(s[a:b+1])\n", "jacc_sim": 0.96875, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [171, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u363444546", "n_user": "u656153606", "pos": "str = input()\nq = int(input())\n\nfor i in range(q):\n sc = input().split()\n a = int(sc[1])\n b = int(sc[2])\n if sc[0] == 'replace':\n str = str[:a] + sc[3] + str[b+1:]\n elif sc[0] == 'reverse':\n str = str[:a] + str[b::-1][:b-a+1] + str[b+1:]\n elif sc[0] == 'print':\n print(str[a:b+1])\n", "neg": "str = input().casefold()\nq = int(input())\n\nfor i in range(q):\n command = input().split()\n a = int(command[1])\n b = int(command[2])\n if command[0] == \"print\":\n print(str[a:b+1])\n elif command[0] == 'reverse':\n str = str[a] + str[a:b+1][::-1] + str[b+a:]\n elif command[0] == \"replace\":\n str = str[:a] +command[3] + str[b+1:]", "jacc_sim": 0.9090909090909091, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [144, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u824708460", "n_user": "u650790815", "pos": "s = input()\nn = int(input())\nfor i in range(n):\n cmd = input().split()\n a, b = int(cmd[1]), int(cmd[2])\n if cmd[0] == 'print':\n print(s[a:b + 1])\n elif cmd[0] == 'reverse':\n s = s[:a] + s[a:b+1][::-1] + s[b + 1:]\n elif cmd[0] == 'replace':\n s = s[:a] + cmd[3] + s[b + 1:]\n\n", "neg": "s = input()\nfor i in range(int(input())):\n cmd = input().split()\n a,b = map(int,[cmd[1],cmd[2]])\n if cmd[0] == 'reverse':\n s = s[:b] + s[a:b+1][::-1]+ s[b+1:]\n elif cmd[0] == 'replace':\n s = s[:b] + cmd[3] + s[b+1:]\n else:\n print(s[a:b+1])", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [141, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u371539389", "n_user": "u480053997", "pos": "s=input()\nq=int(input())\nfor i in range(q):\n t=input().split(\" \")\n if t[0]==\"print\":\n a,b=int(t[1]),int(t[2])\n print(s[a:b+1:])\n if t[0]==\"reverse\":\n a,b=int(t[1]),int(t[2])\n s=s[:a:]+s[a:b+1:][::-1]+s[b+1::]\n if t[0]==\"replace\":\n a,b=int(t[1]),int(t[2])\n x=t[3]\n s=s[:a:]+x+s[b+1::]\n\n", "neg": "s = input()\nfor i in range(int(input())):\n print(s)\n q = input().split()\n op, a, b = q[0], int(q[1]), int(q[2])\n if op == 'print':\n print(s[a : b+1])\n elif op == 'reverse':\n t = s[a : b+1]\n s = s[:a] + t[::-1] + s[b+1:]\n elif op == 'replace':\n s = s[:a] + q[3] + s[b+1:]", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [185, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u140934185", "n_user": "u494314211", "pos": "s=list(input())\nn=int(input())\nfor i in range(n):\n a=input().split()\n if a[0]=='print':print(''.join(s[int(a[1]):int(a[2])+1]))\n elif a[0]=='replace':s[int(a[1]):int(a[2])+1]=a[3]\n else:s[int(a[1]):int(a[2])+1]=s[int(a[1]):int(a[2])+1][::-1]\n", "neg": "s=list(input())\nn=int(input())\nfor i in range(n):\n\tl=input().split()\n\tif l[0]==\"replace\":\n\t\ta=int(l[1])\n\t\tb=int(l[2])\n\t\ts[a:b+1]=list(l[3])\n\telif l[0]==\"reverse\":\n\t\ta=int(l[1])\n\t\tb=int(l[2])\n\t\ts[a:b+1]=s[a:b+1:-1]\n\telse:\n\t\ta=int(l[1])\n\t\tb=int(l[2])\n\t\tprint(\"\".join(s[a:b+1]))", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [141, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u532358959", "n_user": "u777299405", "pos": "s=input()\nq=int(input())\nfor i in range(q):\n l = input().split()\n a,b = int(l[1]),int(l[2])\n if l[0]==\"print\":\n print(s[a:b+1])\n elif l[0]==\"reverse\":\n s1=s[a:b+1]\n s=s[:a]+s1[::-1]+s[b+1:]\n elif l[0]==\"replace\":\n s=s[:a]+l[3]+s[b+1:]\n", "neg": "s = input()\nq = int(input())\nfor i in range(q):\n command = input().split()\n a, b = int(command[1]), int(command[2]) + 1\n if command[0] == \"print\":\n print(s[a:b])\n elif command[0] == \"reverse\":\n s = s[:a] + s[a:b:-1] + s[b:]\n elif command[0] == \"replace\":\n s = s[:a] + command[3] + s[b:]", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [141, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02422", "p_user": "u245823788", "n_user": "u933096856", "pos": "s = input()\nn = int(input())\nfor i in range(n):\n q = input().split()\n a, b = int(q[1]), int(q[2])\n if q[0]==\"print\":\n print(s[a:b+1])\n elif q[0]==\"reverse\":\n if a==0:\n s = s[b::-1]+s[b+1:]\n else:\n s = s[:a]+s[b:a-1:-1]+s[b+1:]\n elif q[0]==\"replace\":\n s = s[:a]+q[3]+s[b+1:]\n", "neg": "str=input()\nn=int(input())\nfor i in range(n):\n s=input().split()\n a=int(s[1])\n b=int(s[2])\n if s[0] == 'replace':\n str=str[:a]+s[3]+str[b:]\n elif s[0] == 'reverse':\n str=str[:a]+str[a:b][::-1]+str[b:]\n else:\n print(str[a:b])", "jacc_sim": 0.9117647058823529, "nl": "Write a program that executes a series of commands on a given string, \"str\". The commands include \"print a b\" (printing characters from the a-th to the b-th position of \"str\"), \"reverse a b\" (reversing characters from the a-th to the b-th position of \"str\"), and \"replace a b p\" (replacing characters from the a-th to the b-th position of \"str\" with string \"p\"). Note that the indices of \"str\" start from 0.\n\nInput:\n- The first line contains the string \"str\" consisting of lowercase letters.\n- The second line contains the number of commands, \"q\".\n- The next \"q\" lines contain each command in the specified format.\n\nOutput:\n- For each \"print\" command, print the resulting string on a new line.\n\nConstraints:\n- 1 \u2264 length of \"str\" \u2264 1000\n- 1 \u2264 q \u2264 100\n- 0 \u2264 a \u2264 b < length of \"str\"\n- For the \"replace\" command, the length of \"p\" is equal to (b - a + 1).\n\nSample Input 1:\n```\nabcde\n3\nreplace 1 3 xyz\nreverse 0 2\nprint 1 4\n```\n\nSample Output 1:\n```\nxaze\n```\n\nSample Input 2:\n```\nxyz\n3\nprint 0 2\nreplace 0 2 abc\nprint 0 2\n```\n\nSample Output 2:\n```\nxyz\nabc\n```", "before_after_length": [160, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02431", "p_user": "u682153677", "n_user": "u682153677", "pos": "# -*- coding: utf-8 -*-\n\nfrom collections import deque\n\nn = int(input())\nword = deque()\n\nfor i in range(n):\n command = list(map(int, input().split()))\n if command[0] == 0:\n word.append(command[1])\n elif command[0] == 1:\n print('{0}'.format(word[command[1]]))\n elif command[0] == 2:\n word.pop()\n\n", "neg": "# -*- coding: utf-8 -*-\n\nfrom collections import deque\n\nn = int(input())\nword = deque()\n\nfor i in range(n):\n command, num = map(int, input().split())\n if command == 0:\n word.append(num)\n elif command == 1:\n print('{0}'.format(word[num]))\n elif command == 2:\n word.pop()\n\n", "jacc_sim": 0.9534883720930233, "nl": "The problem involves managing a dynamic array of integers, denoted as $A = \\{a_0, a_1, ...\\}$. Operations include adding an element at the end of $A$ (pushBack), printing a specific element ($a_p$) at index $p$ (randomAccess), and deleting the last element of $A$ (popBack). The array $A$ is initially empty and is 0-indexed.\n\nInput:\nThe input consists of a number $q$ followed by $q$ queries. Each query is represented as:\n- 0 $x$: to add element $x$ at the end of $A$\n- 1 $p$: to print element $a_p$\n- 2: to delete the last element of $A$\n\nOutput:\nFor each randomAccess operation, print $a_p$ in a line.\n\nConstraints:\n- $1 \\leq q \\leq 200,000$\n- $0 \\leq p < $ the size of $A$\n- $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1:\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1:\n1\n2\n4", "before_after_length": [120, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02431", "p_user": "u548252256", "n_user": "u548252256", "pos": "from sys import stdin\nfrom collections import deque\n\nnum = int(input())\n\nq = deque()\n\nfor i in range(num):\n\n\tcmd = stdin.readline().strip().split()\n\n\tif cmd[0] == \"0\":\n\t\t#\u672b\u5c3e\u306b\u633f\u5165\n\t\tq.append(cmd[1])\n\n\telif cmd[0] == \"1\":\n\t\t#\u8981\u7d20\u306e\u51fa\u529b\n\t\tprint(q[int(cmd[1])],sep='\\n')\n\telse:\n\t\t#\u672b\u5c3e\u306e\u524a\u9664\n\t\tq.pop()\n\n\n", "neg": "from sys import stdin\nfrom collections import deque\n\nnum = int(input())\n\nq = deque()\n\nfor i in range(num):\n\n\tcmd = stdin.readline().strip().split()\n\n\tif cmd[0] == \"0\":\n\t\t#\u672b\u5c3e\u306b\u633f\u5165\n\t\tq.append(cmd[1])\n\n\telif cmd[0] == \"1\":\n\t\t#\u8981\u7d20\u306e\u51fa\u529b\n\t\tprint(q[int(cmd[1])])\n\telse:\n\t\t#\u672b\u5c3e\u306e\u524a\u9664\n\t\tq.pop()\n\nprint(*q,sep='\\n')\n\n\n", "jacc_sim": 0.9807692307692307, "nl": "The problem involves managing a dynamic array of integers, denoted as $A = \\{a_0, a_1, ...\\}$. Operations include adding an element at the end of $A$ (pushBack), printing a specific element ($a_p$) at index $p$ (randomAccess), and deleting the last element of $A$ (popBack). The array $A$ is initially empty and is 0-indexed.\n\nInput:\nThe input consists of a number $q$ followed by $q$ queries. Each query is represented as:\n- 0 $x$: to add element $x$ at the end of $A$\n- 1 $p$: to print element $a_p$\n- 2: to delete the last element of $A$\n\nOutput:\nFor each randomAccess operation, print $a_p$ in a line.\n\nConstraints:\n- $1 \\leq q \\leq 200,000$\n- $0 \\leq p < $ the size of $A$\n- $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1:\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1:\n1\n2\n4", "before_after_length": [172, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02431", "p_user": "u629874472", "n_user": "u629874472", "pos": "cnt = int(input())\na = []\nfor i in range(cnt):\n li = list(map(int,input().split()))\n if li[0] == 0:\n a.append(li[1])\n elif li[0] ==1:\n print(a[li[1]])\n else:\n a.pop(-1)\n", "neg": "cnt = int(input())\na = []\nfor i in range(cnt):\n li = list(map(int,input().split()))\n if li[0] == 0:\n a.append(n)\n elif li[0] ==1:\n print(a[n])\n else:\n a.pop(-1)\n", "jacc_sim": 0.9666666666666667, "nl": "The problem involves managing a dynamic array of integers, denoted as $A = \\{a_0, a_1, ...\\}$. Operations include adding an element at the end of $A$ (pushBack), printing a specific element ($a_p$) at index $p$ (randomAccess), and deleting the last element of $A$ (popBack). The array $A$ is initially empty and is 0-indexed.\n\nInput:\nThe input consists of a number $q$ followed by $q$ queries. Each query is represented as:\n- 0 $x$: to add element $x$ at the end of $A$\n- 1 $p$: to print element $a_p$\n- 2: to delete the last element of $A$\n\nOutput:\nFor each randomAccess operation, print $a_p$ in a line.\n\nConstraints:\n- $1 \\leq q \\leq 200,000$\n- $0 \\leq p < $ the size of $A$\n- $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1:\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1:\n1\n2\n4", "before_after_length": [87, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02431", "p_user": "u841567836", "n_user": "u841567836", "pos": "def pushBack(lists, x):\n return lists.insert(len(lists), x)\n\ndef randomAccess(lists, p):\n print(lists[p])\n\ndef popBack(lists):\n return lists.pop(len(lists) - 1)\n\nif __name__ == '__main__':\n l = list()\n n = int(input())\n for i in range(n):\n j= input().split()\n\n if int(j[0]) == 0:\n pushBack(l, int(j[1]))\n elif int(j[0]) == 1:\n randomAccess(l, int(j[1]))\n else:\n popBack(l)\n", "neg": "def pushBack(lists, x):\n\treturn lists.insert(-1, x)\n\ndef randomAccess(lists, p):\n\tprint(lists[p])\n\ndef popBack(lists):\n\treturn lists.pop(-1)\n\nif __name__ == '__main__':\n\tl = list()\n\tn = int(input())\n\tfor i in range(n):\n\t\tj= input().split()\n\n\t\tif int(j[0]) == 0:\n\t\t\tpushBack(l, x)\n\t\telif int(j[0]) == 1:\n\t\t\trandomAccess(l, x)\n\t\telse:\n\t\t\tpopBack(l)\n\n", "jacc_sim": 0.975609756097561, "nl": "The problem involves managing a dynamic array of integers, denoted as $A = \\{a_0, a_1, ...\\}$. Operations include adding an element at the end of $A$ (pushBack), printing a specific element ($a_p$) at index $p$ (randomAccess), and deleting the last element of $A$ (popBack). The array $A$ is initially empty and is 0-indexed.\n\nInput:\nThe input consists of a number $q$ followed by $q$ queries. Each query is represented as:\n- 0 $x$: to add element $x$ at the end of $A$\n- 1 $p$: to print element $a_p$\n- 2: to delete the last element of $A$\n\nOutput:\nFor each randomAccess operation, print $a_p$ in a line.\n\nConstraints:\n- $1 \\leq q \\leq 200,000$\n- $0 \\leq p < $ the size of $A$\n- $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1:\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1:\n1\n2\n4", "before_after_length": [166, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02431", "p_user": "u516314904", "n_user": "u847467233", "pos": "# AOJ ITP2_1_A: Vector\n# Python3 2018.6.24 bal4u\n\nfrom collections import deque\nQ = deque()\nq = int(input())\nfor i in range(q):\n a = input()\n if a[0] == '0': Q.append(a[2:]) # pushBack\n elif a[0] == '1': print(Q[int(a[2:])]) # randomAccess\n else: Q.pop() # popBack\n\n", "neg": "# AOJ ITP2_1_A: Vector\n# Python3 2018.6.24 bal4u\n\nfrom collections import deque\nQ = deque()\nq = int(input())\nfor i in range(q):\n\ta = input()\n\tprint(a[2:])\n\tif a[0] == '0': Q.append(a[2:]) # pushBack\n\telif a[0] == '1': print(Q[int(a[2:])]) # randomAccess\n\telse: Q.pop() # popBack\n", "jacc_sim": 1.0, "nl": "The problem involves managing a dynamic array of integers, denoted as $A = \\{a_0, a_1, ...\\}$. Operations include adding an element at the end of $A$ (pushBack), printing a specific element ($a_p$) at index $p$ (randomAccess), and deleting the last element of $A$ (popBack). The array $A$ is initially empty and is 0-indexed.\n\nInput:\nThe input consists of a number $q$ followed by $q$ queries. Each query is represented as:\n- 0 $x$: to add element $x$ at the end of $A$\n- 1 $p$: to print element $a_p$\n- 2: to delete the last element of $A$\n\nOutput:\nFor each randomAccess operation, print $a_p$ in a line.\n\nConstraints:\n- $1 \\leq q \\leq 200,000$\n- $0 \\leq p < $ the size of $A$\n- $-1,000,000,000 \\leq x \\leq 1,000,000,000$\n\nSample Input 1:\n8\n0 1\n0 2\n0 3\n2\n0 4\n1 0\n1 1\n1 2\n\nSample Output 1:\n1\n2\n4", "before_after_length": [124, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u201928947", "n_user": "u201928947", "pos": "import bisect\nimport sys\nsys.setrecursionlimit(1<<30)\ndef dfs(i,LIS):\n if a[i] > LIS[-1]:\n LIS.append(a[i])\n ans[i] = len(LIS)\n for j in edges[i]:\n if parent[i] != j:\n parent[j] = i\n dfs(j,LIS)\n LIS.pop()\n else:\n index = bisect.bisect_left(LIS, a[i])\n x = LIS[index]\n LIS[index] = a[i]\n ans[i] = len(LIS)\n for j in edges[i]:\n if parent[i] != j:\n parent[j] = i\n dfs(j,LIS)\n LIS[index] = x\n\nN = int(input())\na = [0]+list(map(int,input().split()))\nedges = [[] for _ in range(N+1)]\nans = [-1]*(N+1)\nparent = [-1]*(N+1)\nfor i in range(N-1):\n u,v = map(int,input().split())\n edges[u].append(v)\n edges[v].append(u)\nLIS = [a[1]]\ndfs(1,LIS)\nfor i in ans[1:]:\n print(i)", "neg": "import bisect\ndef dfs(i,LIS):\n print(i)\n if a[i] > LIS[-1]:\n LIS.append(a[i])\n ans[i] = len(LIS)\n for j in edges[i]:\n if parent[i] != j:\n parent[j] = i\n dfs(j,LIS)\n LIS.pop()\n else:\n index = bisect.bisect_left(LIS, a[i])\n x = LIS[index]\n LIS[index] = a[i]\n ans[i] = len(LIS)\n for j in edges[i]:\n if parent[i] != j:\n parent[j] = i\n dfs(j,LIS)\n LIS[index] = x\n\nN = int(input())\na = [0]+list(map(int,input().split()))\nedges = [[] for _ in range(N+1)]\nans = [-1]*(N+1)\nparent = [-1]*(N+1)\nfor i in range(N-1):\n u,v = map(int,input().split())\n edges[u].append(v)\n edges[v].append(u)\nLIS = [a[1]]\ndfs(1,LIS)\nfor i in ans[1:]:\n print(i)", "jacc_sim": 0.9215686274509803, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [343, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u014800961", "n_user": "u014800961", "pos": "\nimport math\nimport bisect\n\nn = int(input())\nalist = [0]+list(map(int,input().split()))\nuv_list = []\nfor i in range(n-1):\n u,v = map(int,input().split())\n if u > v:\n u, v = v, u\n uv_list.append([u,v])\n\ntree = [[] for _ in range(n+1)]\nfor i in range(n-1):\n uv = uv_list[i]\n tree[uv[0]].append(uv[1])\n tree[uv[1]].append(uv[0])\n \n\nqueue = [1]\nused = [0]*(n+1)\nans = [0]*(n+1)\ndp = []\nstack = []\nwhile queue != []:\n cur = queue[-1]\n\n if used[cur] == 0:\n if cur == 1:\n dp.append(alist[cur])\n stack.append([len(dp)-1,None])\n else:\n if alist[cur] > dp[-1]:\n dp.append(alist[cur])\n stack.append([len(dp)-1,None])\n else:\n offset = bisect.bisect_left(dp,alist[cur])\n stack.append([offset,dp[offset]])\n dp[offset] = alist[cur]\n ans[cur] = len(dp)\n\n if tree[cur] != [] and used[cur] == 0:\n for child in tree[cur]:\n if used[child] == 0:\n queue.append(child)\n else:\n queue.pop()\n\n #reverse\n back = stack.pop()\n if back[1] == None:\n dp.pop()\n else:\n dp[back[0]] = back[1]\n used[cur] = 1\nfor i in range(n):\n print(ans[i+1])\n", "neg": "n = int(input())\nalist = [0]+list(map(int,input().split()))\nuv_list = []\nfor i in range(n-1):\n u,v = map(int,input().split())\n if u > v:\n u,v = v,u\n uv_list.append([u,v])\n\ntree = [[] for _ in range(n+1)]\nfor i in range(n-1):\n uv = uv_list[i]\n tree[uv[0]].append(uv[1])\n\nqueue = [1]\nused = [0]*(n+1)\nans = [0]*(n+1)\ndp = []\nstack = []\nwhile queue != []:\n cur = queue[-1]\n\n if used[cur] == 0:\n if cur == 1:\n dp.append(alist[cur])\n stack.append([len(dp)-1,None])\n else:\n if alist[cur] > dp[-1]:\n dp.append(alist[cur])\n stack.append([len(dp)-1,None])\n else:\n offset = bisect.bisect_left(dp,alist[cur])\n stack.append([offset,dp[offset]])\n dp[offset] = alist[cur]\n ans[cur] = len(dp)\n\n if tree[cur] != [] and used[cur] == 0:\n queue.extend(tree[cur])\n else:\n queue.pop()\n\n #reverse\n back = stack.pop()\n if back[1] == None:\n dp.pop()\n else:\n dp[back[0]] = back[1]\n used[cur] = 1\n\nfor i in range(n):\n print(ans[i+1])", "jacc_sim": 0.9298245614035088, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [480, 438], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u906501980", "n_user": "u906501980", "pos": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\n\ndef dfs(p):\n ai = a[p]\n i = bisect_left(dp, ai)\n old = dp[i]\n dp[i] = ai\n ans[p] = bisect_left(dp, INF)-1\n for child in to[p]:\n if ans[child] is None:\n dfs(child)\n dp[i] = old\n \n \n \n\nif __name__ == \"__main__\":\n n = int(input())\n a = [None] + list(map(int, input().split()))\n to = [[] for _ in range(n+1)]\n for _ in range(n-1):\n u, v = map(int, input().split())\n to[u].append(v)\n to[v].append(u)\n INF = 10**20\n dp = [INF]*(n+1)\n dp[0]= -INF\n ans = [None]*(n+1)\n dfs(1)\n print(\"\\n\".join(list(map(str, ans[1:]))))", "neg": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\n\ndef dfs(p):\n ai = a[p]\n i = bisect_left(dp, ai)\n old = dp[i]\n dp[i] = ai\n ans[p] = bisect_left(dp, INF)-1\n for child in to[p]:\n if ans[child] is None:\n dfs(child)\n dp[i] = old\n \n \n \n\nif __name__ == \"__main__\":\n n = int(input())\n a = [None] + list(map(int, input().split()))\n to = [[] for _ in range(n+1)]\n for _ in range(n-1):\n u, v = map(int, input().split())\n to[u].append(v)\n to[v].append(u)\n INF = 10**20\n dp = [INF]*(n+1)\n dp[0]= -INF\n q = deque([1])\n ans = [None]*(n+1)\n dfs(1)\n print(\"\\n\".join(list(map(str, ans[1:]))))", "jacc_sim": 0.9661016949152542, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [283, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u750990077", "n_user": "u750990077", "pos": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\ndef dfs(j, parent):\n index = bisect_left(dp, a[j-1])\n old = dp[index]\n dp[index] = a[j-1]\n ans[j-1] = bisect_left(dp, INF)-1\n for child in to[j]:\n if child != parent:\n dfs(child, j)\n dp[index] = old\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n to = [[] for _ in range(n+1)]\n for _ in range(n-1):\n u, v = map(int, input().split())\n to[u].append(v)\n to[v].append(u)\n INF = 10**20\n dp = [INF]*(n+1)\n dp[0] = -INF\n ans = [None]*n\n dfs(1, -1)\n print(\"\\n\".join(list(map(str, ans))))", "neg": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\ndef dfs(j, parent):\n index = bisect_left(dp, a[j])\n old = dp[index]\n dp[index] = a[j]\n ans[j] = bisect_left(dp, INF)-1\n for child in to[a[j]]:\n if child != parent:\n dfs(child, a[j])\n dp[index] = old\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n to = [[] for _ in range(n+1)]\n for _ in range(n-1):\n u, v = map(int, input().split())\n to[u].append(v)\n to[v].append(u)\n INF = 10**20\n dp = [INF]*(n+1)\n dp[0] = -INF\n ans = [None]*n\n dfs(1, -1)\n print(ans)", "jacc_sim": 0.9473684210526315, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [272, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u750990077", "n_user": "u750990077", "pos": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\ndef dfs(v, p):\n i = bisect_left(dp, a[v])\n dp[i], old = a[v], dp[i]\n ans[v] = bisect_left(dp, INF)-1\n for u in to[v]:\n if u == p:\n continue\n dfs(u, v)\n dp[i] = old\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n to = [[] for _ in range(n)]\n ans = [0]*n\n INF = 10**20\n for _ in range(n-1):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n to[u].append(v)\n to[v].append(u)\n dp = [INF]*(n+1)\n dp[0] = -INF\n dfs(0, -1)\n print(\"\\n\".join(list(map(str, ans))))", "neg": "from bisect import bisect_left\nimport sys\nsys.setrecursionlimit(1000000)\n\n\ndef dfs(v, p):\n i = bisect_left(dp, a[v])\n dp[i], old = a[v], dp[i]\n ans[v] = bisect_left(dp, INF)\n for u in to[v]:\n if u == p:\n continue\n dfs(u, v)\n dp[i] = old\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n to = [[] for _ in range(n)]\n ans = [0]*n\n INF = 10**10\n for _ in range(n-1):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n to[u].append(v)\n to[v].append(u)\n dp = [INF]*n\n dp[0] = -INF\n dfs(0, -1)\n print(*ans, sep=\"\\n\")", "jacc_sim": 0.9090909090909091, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [274, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u191874006", "n_user": "u191874006", "pos": "#!/usr/bin/env python3\n#F\n\nimport sys\nimport math\nfrom bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nsys.setrecursionlimit(2147483647)\nfrom heapq import heappush, heappop,heappushpop\nfrom collections import defaultdict\nfrom itertools import accumulate\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\nfrom itertools import permutations\nmod = 10**9 + 7\ninf = float('inf')\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\n\nn = I()\na = LI()\nedges = [[] for _ in range(n)]\nfor _ in range(n-1):\n u, v = LI()\n edges[u-1].append(v-1)\n edges[v-1].append(u-1)\n\ndp = [inf]*n\nans = [None]*n\nans[0] = 1\ndp[0] = a[0]\ndef dfs(s, p, dp, num):\n for u in edges[s]:\n flag = False\n if u == p:\n continue\n r = bl(dp, a[u])\n tmp = dp[r]\n if dp[r] == inf:\n num += 1\n flag = True\n ans[u] = num\n dp[r] = min(dp[r], a[u])\n dfs(u, s, dp, num)\n dp[r] = tmp\n if flag:\n num -= 1\n return\ndfs(0, -1, dp, 1)\n\nfor i in ans:\n print(i)\n ", "neg": "#!/usr/bin/env python3\n#F\n\nimport sys\nimport math\nfrom bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nsys.setrecursionlimit(2147483647)\nfrom heapq import heappush, heappop,heappushpop\nfrom collections import defaultdict\nfrom itertools import accumulate\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\nfrom itertools import permutations\nmod = 10**9 + 7\ninf = float('inf')\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\n\nn = I()\na = LI()\nedges = [[] for _ in range(n)]\nfor _ in range(n-1):\n u, v = LI()\n edges[u-1].append(v-1)\n edges[v-1].append(u-1)\n\ndp = [inf]*n\nans = [None]*n\nans[0] = 1\ndp[0] = a[0]\ndef dfs(s, p, dp, num):\n for u in edges[s]:\n flag = False\n if u == p:\n continue\n if ans[u] != None:\n return\n r = br(dp, a[u])\n tmp = dp[r]\n if dp[r] == inf:\n num += 1\n flag = True\n ans[u] = num\n dp[r] = min(dp[r], a[u])\n dfs(u, s, dp, num)\n dp[r] = tmp\n if flag:\n num -= 1\n return\ndfs(0, -1, dp, 1)\nprint(ans)\n\n ", "jacc_sim": 0.9888888888888889, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [409, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u633255271", "n_user": "u633255271", "pos": "from collections import deque\nfrom bisect import bisect_left\n\nINF = 10**9 + 1\nN = int(input())\nA = list(map(int, input().split()))\nG = [[] for i in range(N)]\nfor i in range(N-1):\n u, v = list(map(int, input().split()))\n G[u-1].append(v-1)\n G[v-1].append(u-1)\n\nLIS = [INF] * N\nans = [0] * N\n\nstack = deque()\nstack.append((0, None, None)) # (current_node, prev_node, old_val)\nwhile stack:\n c_node, p_node, old_val = stack.pop()\n\n if c_node == -1:\n LIS[p_node] = old_val\n continue\n\n a = A[c_node]\n idx = bisect_left(LIS, a)\n old_val = LIS[idx]\n LIS[idx] = a \n \n ans[c_node] = bisect_left(LIS, INF)\n\n stack.append((-1, idx, old_val))\n\n for next_node in G[c_node]:\n if next_node != p_node:\n stack.append((next_node, c_node, old_val))\n\nprint(*ans, sep=\"\\n\")", "neg": "from collections import deque\nfrom bisect import bisect_left\n\nINF = 10**9 + 1\nN = int(input())\nA = list(map(int, input().split()))\nG = [[] for i in range(N)]\nfor i in range(N-1):\n u, v = list(map(int, input().split()))\n G[u-1].append(v-1)\nLIS = [INF] * N\nans = [0] * N\n\nstack = deque()\nstack.append((0, None, None))\nwhile stack:\n c_node, p_node, old_val = stack.pop()\n\n if c_node == -1:\n print(c_node, p_node, old_val)\n LIS[p_node] = old_val\n print(c_node, LIS)\n continue\n\n a = A[c_node]\n idx = bisect_left(LIS, a)\n old_val = LIS[idx]\n LIS[idx] = a \n \n ans[c_node] = bisect_left(LIS, INF)\n print(c_node, LIS)\n\n stack.append((-1, idx, old_val))\n\n for next_node in G[c_node]:\n stack.append((next_node, c_node, old_val))\n\nprint(*ans, sep=\"\\n\")", "jacc_sim": 0.9333333333333333, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [340, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u278886389", "n_user": "u278886389", "pos": "import bisect\nimport sys\nsys.setrecursionlimit(3*10**5)\n\nINF = 10**10\n\nN = int(input())\na = list(map(int,input().split()))\nT = [set() for x in range(N)]\nfor i in range(N-1):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n T[u].add(v)\n T[v].add(u)\n\nsearch = [0]*N\n\nA = [INF]\n\nans = [-1]*N\n\ndef dfs(V):\n num = a[V]\n added = 0\n if A[-1] < num:\n A.append(num)\n added = 1\n else:\n k = bisect.bisect_left(A,num)\n v = A[k]\n A[k] = num\n ans[V] = len(A)\n for VV in T[V]:\n if search[VV]:\n continue\n search[VV] = 1\n dfs(VV)\n if added:\n A.pop()\n else:\n A[k] = v\n\nsearch[0] = 1\ndfs(0)\n\nprint(*ans,sep=\"\\n\")", "neg": "import bisect\nimport sys\nsys.setrecursionlimit(3*10**5)\n\nINF = 10**10\n\nN = int(input())\na = list(map(int,input().split()))\nT = [set() for x in range(N)]\nfor i in range(N-1):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n T[u].add(v)\n T[v].add(u)\n\nsearch = [0]*N\n\nA = [INF]\n\nans = [-1]*N\n\ndef dfs(V):\n num = a[V]\n added = 0\n if A[-1] > num:\n A.append(num)\n added = 1\n else:\n k = bisect.bisect_left(A,num)\n v = A[k]\n A[k] = num\n ans[V] = len(A)\n for VV in T[V]:\n if search[VV]:\n continue\n search[VV] = 1\n dfs(VV)\n if added:\n A.pop()\n else:\n A[k] = v\n\nsearch[0] = 1\ndfs(0)\n\nprint(*ans,sep=\"\\n\")", "jacc_sim": 0.9672131147540983, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [311, 311], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u278886389", "n_user": "u278886389", "pos": "import bisect\nimport sys\nsys.setrecursionlimit(3*10**5)\n\nINF = 10**10\n\nN = int(input())\na = list(map(int,input().split()))\nT = [set() for x in range(N)]\nfor i in range(N-1):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n T[u].add(v)\n T[v].add(u)\n\nsearch = [0]*N\n\nA = [INF]*N\n\nans = [-1]*N\n\ndef dfs(V):\n num = a[V]\n k = bisect.bisect_left(A,num)\n v = A[k]\n A[k] = num\n ans[V] = bisect.bisect_left(A,INF)\n # \u3053\u306e\u306b\u3076\u305f\u3093\u7121\u99c4\u3058\u3083\u306d\uff1f\u307e\u3042\u9593\u306b\u5408\u3046\u304b\u3089\u3044\u3044\u304b\u2026\u2026\n for VV in T[V]:\n if search[VV]:\n continue\n search[VV] = 1\n dfs(VV)\n A[k] = v\n\nsearch[0] = 1\ndfs(0)\n\nprint(*ans,sep=\"\\n\")", "neg": "import bisect\nimport sys\nsys.setrecursionlimit(3*10**5)\n\nINF = 10**10\n\nN = int(input())\na = list(map(int,input().split()))\nT = [set() for x in range(N)]\nfor i in range(N-1):\n u,v = map(int,input().split())\n u -= 1\n v -= 1\n T[u].add(v)\n T[v].add(u)\n\nA = [INF]*N\n\nans = [-1]*N\n\ndef dfs(V):\n num = a[V]\n k = bisect.bisect_left(A,num)\n v = A[k]\n A[k] = num\n ans[V] = bisect.bisect_left(A,INF)\n # \u3053\u306e\u306b\u3076\u305f\u3093\u7121\u99c4\u3058\u3083\u306d\uff1f\u307e\u3042\u9593\u306b\u5408\u3046\u304b\u3089\u3044\u3044\u304b\u2026\u2026\n for VV in T[V]:\n dfs(VV)\n T[VV].remove(V)\n A[k] = v\n\ndfs(0)\n\nprint(*ans,sep=\"\\n\")", "jacc_sim": 0.948051948051948, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [352, 328], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u608088992", "n_user": "u608088992", "pos": "import sys\nfrom bisect import bisect_left\nsys.setrecursionlimit(1000000)\nINF = pow(10, 10)\n\nchanged = []\ninput = sys.stdin.readline\nN = int(input())\nA = [int(a) for a in input().split()]\nEdge = [[] for _ in range(N)]\nfor _ in range(N-1):\n u, v = map(int, input().split())\n Edge[u-1].append(v-1)\n Edge[v-1].append(u-1)\nLIS = [INF] * N\n\ndef dfs(i, pre, Ans):\n changeID = bisect_left(LIS, A[i])\n changed.append((changeID, LIS[changeID]))\n LIS[changeID] = min(A[i], LIS[changeID])\n #print(i, LIS)\n #print(changed)\n Ans[i] = bisect_left(LIS, INF) \n for nextN in Edge[i]:\n if nextN != pre: dfs(nextN, i, Ans)\n backID, backV = changed.pop()\n LIS[backID] = backV\n return 0\n\ndef solve():\n Ans = [1] * N\n dfs(0, 0, Ans)\n print(\"\\n\".join(map(str, Ans)))\n \n return 0\n\nif __name__ == \"__main__\":\n solve()", "neg": "import sys\nfrom bisect import bisect_left\nsys.setrecursionlimit(1000000)\nINF = pow(10, 10)\n\nchanged = []\ninput = sys.stdin.readline\nN = int(input())\nA = [int(a) for a in input().split()]\nEdge = [[] for _ in range(N)]\nfor _ in range(N-1):\n u, v = map(int, input().split())\n Edge[u-1].append(v-1)\n Edge[v-1].append(u-1)\nLIS = [INF] * N\n\ndef dfs(i, pre, Ans):\n changeID = bisect_left(LIS, A[i])\n changed.append((changeID, LIS[changeID]))\n LIS[changeID] = min(A[i], LIS[changeID])\n #print(i, LIS)\n print(changed)\n Ans[i] = bisect_left(LIS, N + 1)\n for nextN in Edge[i]:\n if nextN != pre: dfs(nextN, i, Ans)\n backID, backV = changed.pop()\n LIS[backID] = backV\n return 0\n\ndef solve():\n Ans = [1] * N\n dfs(0, 0, Ans)\n print(\"\\n\".join(map(str, Ans)))\n \n return 0\n\nif __name__ == \"__main__\":\n solve()", "jacc_sim": 0.9850746268656716, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [353, 354], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u948911484", "n_user": "u948911484", "pos": "import bisect\nimport sys\nsys.setrecursionlimit(10**9)\nn = int(input())\na = [0]+list(map(int,input().split()))\ntree = [[] for _ in range(n+1)]\nfor _ in range(n-1):\n u,v = map(int,input().split())\n tree[u].append(v)\n tree[v].append(u)\n#print(tree)\nd = [float(\"inf\")]*(n+1)\nans = [0]*(n+1)\n\ndef dfs(now, pre):\n i = bisect.bisect_left(d, a[now])\n tmp = d[i]\n d[i] = a[now]\n ans[now] = bisect.bisect_left(d, float(\"inf\"))\n for nxt in tree[now]:\n if nxt == pre:\n continue\n dfs(nxt, now)\n d[i] = tmp\ndfs(1,-1)\n\nfor i in ans[1:]:\n print(i)", "neg": "import bisect\nimport sys\nsys.setrecursionlimit(10**9)\nn = int(input())\na = [0]+list(map(int,input().split()))\ntree = [[] for _ in range(n+1)]\nfor _ in range(n-1):\n u,v = map(int,input().split())\n tree[u].append(v)\n tree[v].append(u)\n#print(tree)\nd = [float(\"inf\")]*(n+1)\nans = [0]*(n+1)\n\ndef dfs(now, pre):\n print(now,pre)\n i = bisect.bisect_left(d, a[now])\n tmp = d[i]\n d[i] = a[now]\n ans[now] = bisect.bisect_left(d, float(\"inf\"))\n print(d)\n for nxt in tree[now]:\n if nxt == pre:\n continue\n dfs(nxt, now)\n d[i] = tmp\ndfs(1,-1)\n\nfor i in ans[1:]:\n print(i)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [257, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u600402037", "n_user": "u600402037", "pos": "# coding: utf-8\nimport sys\nfrom bisect import bisect_left, bisect_right, insort\nsys.setrecursionlimit(10 ** 7)\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = [0] + lr() # 1-indexed\ngraph = [[] for _ in range(N+1)] # 1-indexed\nfor _ in range(N-1):\n a, b = lr()\n graph[a].append(b)\n graph[b].append(a)\n\nanswer = [0] * (N+1) # 1-indexed\nINF = 10 ** 10\nparent = [-1] * (N+1)\n\ndef dfs(n):\n \"\"\"arr\u306fLIS\u306e\u30ea\u30b9\u30c8\u3001answer\u306e\u30ea\u30b9\u30c8\u3092\u66f4\u65b0\u3057\u3066\u304b\u3089\u5b50\u306barr\u3092\u6e21\u3059\"\"\"\n i = bisect_left(dp, INF)\n answer[n] = i\n for c in graph[n]:\n if c == parent[n]:\n continue\n parent[c] = n\n i = bisect_left(dp, A[c])\n old = dp[i]\n dp[i] = A[c]\n dfs(c)\n dp[i] = old\n\ndp = [INF] * (N+1)\ndp[0] = A[1]\ndfs(1)\nfor a in answer[1:]:\n print(a)\n", "neg": "# coding: utf-8\nimport sys\nfrom bisect import bisect_left, bisect_right, insort\nsys.setrecursionlimit(10 ** 7)\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = [0] + lr() # 1-indexed\ngraph = [[] for _ in range(N+1)] # 1-indexed\nfor _ in range(N-1):\n a, b = lr()\n graph[a].append(b)\n graph[b].append(a)\n\nanswer = [0] * (N+1) # 1-indexed\nINF = 10 ** 10\nparent = [-1] * (N+1)\n\ndef dfs(n, arr):\n \"\"\"arr\u306fLIS\u306e\u30ea\u30b9\u30c8\u3001answer\u306e\u30ea\u30b9\u30c8\u3092\u66f4\u65b0\u3057\u3066\u304b\u3089\u5b50\u306barr\u3092\u6e21\u3059\"\"\"\n i = bisect_left(arr, INF)\n answer[n] = i\n print('n, i', n, i, arr[:5])\n for c in graph[n]:\n if c == parent[n]:\n continue\n parent[c] = n\n new = arr[:]\n i = bisect_left(new, A[c])\n new[i] = A[c]\n dfs(c, new)\n\nB = [INF] * (N+1)\nB[0] = A[1]\ndfs(1, B)\nfor a in answer[1:]:\n print(a)\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [410, 423], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u761529120", "n_user": "u761529120", "pos": "import sys\nimport bisect\nfrom collections import deque\nsys.setrecursionlimit(4100000)\ninput = sys.stdin.readline\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n edge = [[] for _ in range(N)]\n for i in range(N-1):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n edge[u].append(v)\n edge[v].append(u)\n\n ans = [0] * (N + 1)\n LIS = [-1]\n \n def dfs(v, p = N):\n if A[v] > LIS[-1]:\n LIS.append(A[v])\n ans[v] = ans[p] + 1\n for u in edge[v]:\n if u == p:\n continue\n dfs(u,v)\n LIS.pop()\n else:\n ans[v] = ans[p]\n idx = bisect.bisect_left(LIS, A[v])\n old = LIS[idx]\n LIS[idx] = A[v]\n for u in edge[v]:\n if u == p:\n continue\n dfs(u,v)\n LIS[idx] = old\n dfs(0)\n for i in range(N):\n print(ans[i])\n\nif __name__ == \"__main__\":\n main()", "neg": "import sys\nimport bisect\nfrom collections import deque\nsys.setrecursionlimit(4100000)\ninput = sys.stdin.readline\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n edge = [[] for _ in range(N)]\n for i in range(N-1):\n u, v = map(int, input().split())\n u -= 1\n v -= 1\n edge[u].append(v)\n edge[v].append(u)\n\n ans = [0] * (N + 1)\n LIS = [-1]\n \n def dfs(v, p = N):\n if A[v] > LIS[-1]:\n LIS.append(A[v])\n ans[v] = ans[p] + 1\n for u in edge[v]:\n if u == p:\n continue\n dfs(u,v)\n LIS.pop()\n else:\n ans[v] = ans[p]\n idx = bisect.bisect_left(LIS, A[v])\n old = LIS[idx]\n LIS[idx] = A[v]\n for u in edge[v]:\n if u == p:\n continue\n dfs(u,v)\n LIS[idx] = old\n\n for i in range(1,N+1):\n print(ans[i])\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [360, 360], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u334712262", "n_user": "u334712262", "pos": "# -*- coding: utf-8 -*-\nimport bisect\nimport sys\n\nsys.setrecursionlimit(10**6)\nbuff_readline = sys.stdin.buffer.readline\nreadline = sys.stdin.readline\nINF = 2**62-1\n\n\ndef read_int():\n return int(buff_readline())\n\n\ndef read_int_n():\n return list(map(int, buff_readline().split()))\n\n\ndef slv(N, A, UV):\n A.insert(0, -1)\n g = [list() for _ in range(0, N+1)]\n for u, v in UV:\n g[u].append(v)\n g[v].append(u)\n\n ans = [-1] * (N+1)\n ans[1] = 1\n dp = [INF] * (N+1)\n dp[0] = A[1]\n\n def dfs(u, p):\n for v in g[u]:\n if v == p:\n continue\n\n i = bisect.bisect_left(dp, A[v])\n b = dp[i]\n dp[i] = A[v]\n ans[v] = bisect.bisect_left(dp, INF)\n dfs(v, u)\n dp[i] = b\n\n dfs(1, 0)\n for i in range(1, N+1):\n print(ans[i])\n\n\ndef main():\n N = read_int()\n A = read_int_n()\n UV = [read_int_n() for _ in range(N-1)]\n slv(N, A, UV)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# -*- coding: utf-8 -*-\nimport bisect\nimport sys\n\nsys.setrecursionlimit(10**6)\nbuff_readline = sys.stdin.buffer.readline\nreadline = sys.stdin.readline\nINF = 2**62-1\n\n\ndef read_int():\n return int(buff_readline())\n\n\ndef read_int_n():\n return list(map(int, buff_readline().split()))\n\n\ndef slv(N, A, UV):\n A.insert(0, -1)\n g = [list() for _ in range(0, N+1)]\n for u, v in UV:\n g[u].append(v)\n g[v].append(u)\n\n ans = [-1] * (N+1)\n ans[1] = 1\n dp = [INF] * (N+1)\n dp[0] = A[1]\n\n def dfs(u, p):\n for v in g[u]:\n if v == p:\n continue\n\n i = bisect.bisect_left(dp, A[v])\n b = dp[i]\n dp[i] = A[v]\n # ans[v] = bisect.bisect_left(dp, INF)\n dfs(v, u)\n dp[i] = b\n\n dfs(1, 0)\n for i in range(1, N+1):\n print(ans[i])\n\n\ndef main():\n N = read_int()\n A = read_int_n()\n UV = [read_int_n() for _ in range(N-1)]\n slv(N, A, UV)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [432, 433], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02698", "p_user": "u490642448", "n_user": "u490642448", "pos": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\nimport bisect\n\nn = int(input())\na = list(map(int,input().split()))\n\nlinks = [[] for _ in range(n+1)]\nfor _ in range(n-1):\n v,w = map(int, input().split())\n links[v].append(w)\n links[w].append(v)\n\ninf = 10**10\nlis = [inf] * n\ninf_ind = 0\nparent = [-1]*(n+1)\noperate = [0] * (n+1)\nans = [-1]*(n+1)\nd = deque()\nd.append(1)\nwhile(d):\n now = d.popleft()\n if(operate[now]==0):\n p = parent[now]\n if(p!=-1):\n d.appendleft(now)\n for child in links[now]:\n if(child != p):\n parent[child] = now\n d.appendleft(child)\n\n a_now = a[now-1]\n ind = bisect.bisect_left(lis,a_now)\n operate[now] = (ind,lis[ind],a_now)\n lis[ind] = a_now\n if(inf_ind == ind):\n inf_ind += 1\n ans[now] = inf_ind\n else:\n ind,before,after = operate[now]\n lis[ind] = before\n if(before == inf):\n inf_ind -= 1\n # print(lis)\n\nfor i in ans[1:]:\n print(i)", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\nimport bisect\n\nn = int(input())\na = list(map(int,input().split()))\n\nlinks = [[] for _ in range(n+1)]\nfor _ in range(n-1):\n v,w = map(int, input().split())\n links[v].append(w)\n links[w].append(v)\n\ninf = 10**10\nlis = [inf] * n\ninf_ind = 0\nparent = [-1]*(n+1)\noperate = [0] * (n+1)\nans = [-1]*(n+1)\nd = deque()\nd.append(1)\nwhile(d):\n print(d)\n now = d.popleft()\n if(operate[now]==0):\n p = parent[now]\n if(p!=-1):\n d.appendleft(now)\n for child in links[now]:\n if(child != p):\n parent[child] = now\n d.appendleft(child)\n\n a_now = a[now-1]\n ind = bisect.bisect_left(lis,a_now)\n operate[now] = (ind,lis[ind],a_now)\n lis[ind] = a_now\n if(inf_ind == ind):\n inf_ind += 1\n ans[now] = inf_ind\n else:\n ind,before,after = operate[now]\n lis[ind] = before\n if(before == inf):\n inf_ind -= 1\n # print(lis)\n\nfor i in ans[1:]:\n print(i)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where the i-th edge connects Vertex u_i and Vertex v_i. Each vertex i has an integer a_i written on it. For each integer k from 1 to N, find the length of the longest increasing subsequence of the sequence formed by lining up the integers written on the vertices along the shortest path from Vertex 1 to Vertex k. The longest increasing subsequence of a sequence A of length L is the subsequence A_{i_1}, A_{i_2}, ..., A_{i_M} with the greatest possible value of M such that 1 \u2264 i_1 < i_2 < ... < i_M \u2264 L and A_{i_1} < A_{i_2} < ... < A_{i_M}. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i \u2264 10^9, 1 \u2264 u_i, v_i \u2264 N, u_i \u2260 v_i, the given graph is a tree, and all input values are integers. Input is given in the format: N, a_1 a_2 ... a_N, u_1 v_1, u_2 v_2, ..., u_{N-1} v_{N-1}. Output N lines, where the k-th line contains the length of the longest increasing subsequence of the sequence obtained from the shortest path from Vertex 1 to Vertex k.", "before_after_length": [408, 414], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02703", "p_user": "u057109575", "n_user": "u057109575", "pos": "\nfrom heapq import heappop, heappush\n\nN, M, S = map(int, input().split())\nX = [list(map(int, input().split())) for _ in range(M)]\nY = [list(map(int, input().split())) for _ in range(N)]\n\nlim = 2501\ngraph = [[] for _ in range((N + 1) * lim)]\n\nfor u, v, a, b in X:\n for n in range(a, lim):\n graph[u * lim + n].append((v * lim + (n - a), b))\n graph[v * lim + n].append((u * lim + (n - a), b))\n\nfor n, (c, d) in enumerate(Y):\n for x in range(lim - 1):\n graph[(n + 1) * lim + x].append(\n ((n + 1) * lim + min(lim - 1, x + c), d))\n\n\nINF = 10 ** 20\nstart = lim + min(S, lim - 1)\ndist = [INF] * ((N + 1) * lim + 1)\ndist[start] = 0\npq = []\nheappush(pq, (0, start))\n\nwhile pq:\n _, u = heappop(pq)\n for v, c in graph[u]:\n if dist[v] > dist[u] + c:\n dist[v] = dist[u] + c\n heappush(pq, (dist[v], v))\n\nans = []\nfor i in range(2, N + 1):\n ans.append(min(dist[i * lim:i * lim + lim]))\n\nprint(*ans, sep=\"\\n\")\n", "neg": "\nfrom heapq import heappop, heappush\n\nN, M, S = map(int, input().split())\nX = [list(map(int, input().split())) for _ in range(M)]\nY = [list(map(int, input().split())) for _ in range(N)]\n\na_max = max(a for *_, a, _ in X)\nlim = a_max * (N - 1) + 1\ngraph = [[] for _ in range((N + 1) * lim)]\n\nfor u, v, a, b in X:\n for n in range(a, lim):\n graph[u * lim + n].append((v * lim + (n - a), b))\n graph[v * lim + n].append((u * lim + (n - a), b))\n\nfor n, (c, d) in enumerate(Y):\n for x in range(lim):\n graph[(n + 1) * lim + x].append(\n ((n + 1) * lim + min(lim - 1, x + c), d))\n\n\nINF = 10 ** 9 + 7\nstart = lim + min(S, lim)\ndist = [INF] * ((N + 1) * lim + 1)\ndist[start] = 0\npq = []\nheappush(pq, (0, start))\n\nwhile pq:\n _, u = heappop(pq)\n for v, c in graph[u]:\n if dist[v] > dist[u] + c:\n dist[v] = dist[u] + c\n heappush(pq, (dist[v], v))\n\nans = []\nfor i in range(2, N + 1):\n ans.append(min(dist[i * lim:i * lim + lim]))\n\nprint(*ans, sep=\"\\n\")\n", "jacc_sim": 0.9090909090909091, "nl": "You have 500 points. Problem Statement: There are N cities numbered 1 to N, connected by M railroads. You are at City 1 with 10^{100} gold coins and S silver coins. The i-th railroad connects City U_i and City V_i bidirectionally, with a one-way trip costing A_i silver coins and taking B_i minutes. You cannot use gold coins for fare. Each city has an exchange counter where you can get C_i silver coins for 1 gold coin, taking D_i minutes for each gold coin. For each t=2, ..., N, find the minimum time needed to travel from City 1 to City t. Constraints: 2 \\leq N \\leq 50, N-1 \\leq M \\leq 100, 0 \\leq S \\leq 10^9, 1 \\leq A_i \\leq 50, 1 \\leq B_i,C_i,D_i \\leq 10^9, 1 \\leq U_i < V_i \\leq N, no duplicate railroads, and all input values are integers. Input: N M S, followed by U_i V_i A_i B_i, and C_i D_i. Output: For each t=2, ..., N, print the minimum time to travel from City 1 to City t.", "before_after_length": [414, 439], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02703", "p_user": "u312814337", "n_user": "u312814337", "pos": "import heapq\n\ncity_num, road_num, init_silver = map(int, input().split())\nMAX_COST = 2500\ninit_silver = min(MAX_COST, init_silver)\n\nG = [[] for _ in range(city_num)]\nfor _ in range(road_num):\n A, B, cost, time_cost = map(int, input().split())\n A, B = A-1, B-1\n G[B].append([A, cost, time_cost])\n G[A].append([B, cost, time_cost])\n\nfor n in range(city_num):\n cost, time_cost = map(int, input().split())\n G[n].append([n, -cost, time_cost])\n\ndp = [[float(\"inf\")] * (MAX_COST+1) for _ in range(city_num)]\ndp[0][init_silver] = 0\nhq = [(0, 0, init_silver)]\nwhile hq:\n time, node, silver = heapq.heappop(hq)\n for to, silver_cost, time_cost in G[node]:\n remain = min(silver - silver_cost, MAX_COST)\n if remain < 0:\n continue\n dp_next_value = time + time_cost\n if dp[to][remain] <= dp_next_value:\n continue\n dp[to][remain] = dp_next_value\n heapq.heappush(hq, (dp_next_value, to, remain))\nprint(*[min(d) for d in dp[1:]], sep=\"\\n\")", "neg": "import heapq\n\ncity_num, road_num, init_silver = map(int, input().split())\ninit_silver = min(2500, init_silver)\n\nG = [[] for _ in range(city_num)]\nfor _ in range(road_num):\n A, B, cost, time_cost = map(int, input().split())\n A, B = A-1, B-1\n G[B].append([A, cost, time_cost])\n G[A].append([B, cost, time_cost])\n\nfor n in range(city_num):\n cost, time_cost = map(int, input().split())\n G[n].append([n, -cost, time_cost])\n\ndp = [[float(\"inf\")] * 2501 for _ in range(city_num)]\ndp[0][init_silver] = 0\nhq = [(0, 0, init_silver)]\nwhile hq:\n time, node, silver = heapq.heappop(hq)\n for to, silver_cost, time_cost in G[node]:\n remain = min(silver - silver_cost, 2500)\n if remain < 0:\n continue\n dp_next_value = time + time_cost\n if dp[to][remain] <= dp_next_value:\n continue\n dp[to][remain] = dp_next_value\n hq.append([dp_next_value, to, remain])\nprint(*[min(d) for d in dp[1:]], sep=\"\\n\")", "jacc_sim": 0.9491525423728814, "nl": "You have 500 points. Problem Statement: There are N cities numbered 1 to N, connected by M railroads. You are at City 1 with 10^{100} gold coins and S silver coins. The i-th railroad connects City U_i and City V_i bidirectionally, with a one-way trip costing A_i silver coins and taking B_i minutes. You cannot use gold coins for fare. Each city has an exchange counter where you can get C_i silver coins for 1 gold coin, taking D_i minutes for each gold coin. For each t=2, ..., N, find the minimum time needed to travel from City 1 to City t. Constraints: 2 \\leq N \\leq 50, N-1 \\leq M \\leq 100, 0 \\leq S \\leq 10^9, 1 \\leq A_i \\leq 50, 1 \\leq B_i,C_i,D_i \\leq 10^9, 1 \\leq U_i < V_i \\leq N, no duplicate railroads, and all input values are integers. Input: N M S, followed by U_i V_i A_i B_i, and C_i D_i. Output: For each t=2, ..., N, print the minimum time to travel from City 1 to City t.", "before_after_length": [402, 382], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02703", "p_user": "u875541136", "n_user": "u875541136", "pos": "from heapq import *\n\nN, M, S = tuple(map(int, input().split()))\n\nT = [[10**18 for _ in range(2451)] for _ in range(N)]\n\nact = [[] for _ in range(N)]\n\nfor i in range(M):\n U, V, A, B = tuple(map(int, input().split()))\n U -= 1\n V -= 1\n act[U] += [(V, A, B)]\n act[V] += [(U, A, B)]\n\nfor i in range(N):\n C, D = tuple(map(int, input().split()))\n act[i] += [(i, -C, D)]\n\nque = [(0, 0, S)]\n\nwhile que:\n (currentT, n, coins) = heappop(que)\n for m, cost, t in act[n]:\n # \u3082\u3057\u300c\u6255\u3048\u308b\u91d1\u984d\u3067\u300d\u300c\u6700\u5c0f\u6642\u9593T[\u79fb\u52d5\u5148][\u6240\u6301\u91d1]\u3092\u66f4\u65b0\u3067\u304d\u308b\u3068\u304d\u300d\u306b\u5024\u3092\u66f4\u65b0\u3001\u30ad\u30e5\u30fc\u306b\u72b6\u614b\u3092\u8ffd\u52a0\u3002\n if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:\n T[m][min(2450, coins - cost)] = currentT + t\n heappush(que, (currentT + t, m, min(2450, coins - cost)))\n\nfor i in range(1, N):\n print(min(T[i]))", "neg": "from heapq import *\n\nT = [[10**18 for _ in range(2451)] for _ in range(N)]\n\nact = [[] for _ in range(N)]\n\nN, M, S = tuple(map(int, input().split()))\n\nfor i in range(M):\n U, V, A, B = tuple(map(int, input().split()))\n maxV = max(maxV, A)\n U -= 1\n V -= 1\n act[U] += [(V, A, B)]\n act[V] += [(U, A, B)]\n\nfor i in range(N):\n C, D = tuple(map(int, input().split()))\n act[i] += [(i, -C, D)]\n\nque = [(0, 0, S)]\n\nwhile que:\n (currentT, n, coins) = heappop(que)\n for m, cost, t in act[n]:\n # \u3082\u3057\u300c\u6255\u3048\u308b\u91d1\u984d\u3067\u300d\u300c\u6700\u5c0f\u6642\u9593T[\u79fb\u52d5\u5148][\u6240\u6301\u91d1]\u3092\u66f4\u65b0\u3067\u304d\u308b\u3068\u304d\u300d\u306b\u5024\u3092\u66f4\u65b0\u3001\u30ad\u30e5\u30fc\u306b\u72b6\u614b\u3092\u8ffd\u52a0\u3002\n if coins >= cost and currentT + t < T[m][min(2450, coins - cost)]:\n T[m][min(2450, coins - cost)] = currentT + t\n heappush(que, (currentT + t, m, min(2450, coins - cost)))\n\nfor i in range(1, N):\n print(min(T[i]))", "jacc_sim": 0.9893617021276596, "nl": "You have 500 points. Problem Statement: There are N cities numbered 1 to N, connected by M railroads. You are at City 1 with 10^{100} gold coins and S silver coins. The i-th railroad connects City U_i and City V_i bidirectionally, with a one-way trip costing A_i silver coins and taking B_i minutes. You cannot use gold coins for fare. Each city has an exchange counter where you can get C_i silver coins for 1 gold coin, taking D_i minutes for each gold coin. For each t=2, ..., N, find the minimum time needed to travel from City 1 to City t. Constraints: 2 \\leq N \\leq 50, N-1 \\leq M \\leq 100, 0 \\leq S \\leq 10^9, 1 \\leq A_i \\leq 50, 1 \\leq B_i,C_i,D_i \\leq 10^9, 1 \\leq U_i < V_i \\leq N, no duplicate railroads, and all input values are integers. Input: N M S, followed by U_i V_i A_i B_i, and C_i D_i. Output: For each t=2, ..., N, print the minimum time to travel from City 1 to City t.", "before_after_length": [462, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02703", "p_user": "u170201762", "n_user": "u170201762", "pos": "from heapq import heappush, heappop\ninf = float('inf')\ndef dijkstra(graph:list, node:int, start:int) -> list:\n dist = [inf]*node\n\n dist[start] = 0\n heap = [(0,start)]\n while heap:\n cost,thisNode = heappop(heap)\n for NextCost,NextNode in graph[thisNode]:\n dist_cand = dist[thisNode]+NextCost\n if dist_cand < dist[NextNode]:\n dist[NextNode] = dist_cand\n heappush(heap,(dist[NextNode],NextNode))\n return dist\n\nN,M,S = map(int,input().split())\ngraph = [[] for i in range(2501*N)]\nfor i in range(M):\n u,v,a,b = map(int,input().split())\n u -= 1\n v -= 1\n for s in range(a,2501):\n graph[2501*u+s].append([b,2501*v+s-a])\n graph[2501*v+s].append([b,2501*u+s-a])\n\nfor i in range(N):\n c,d = map(int,input().split())\n for s in range(2500):\n graph[2501*i+s].append([d,2501*i+min(2500,s+c)])\n\ndist = dijkstra(graph,2501*N,min(2500,S))\n\nans = [inf]*N\nfor i in range(N):\n for s in range(2501):\n ans[i] = min(ans[i],dist[2501*i+s])\n\nfor i in range(1,N):\n print(ans[i])", "neg": "from heapq import heappush, heappop\ninf = float('inf')\ndef dijkstra(graph:list, node:int, start:int) -> list:\n dist = [inf]*node\n\n dist[start] = 0\n heap = [(0,start)]\n while heap:\n cost,thisNode = heappop(heap)\n for NextCost,NextNode in graph[thisNode]:\n dist_cand = dist[thisNode]+NextCost\n if dist_cand < dist[NextNode]:\n dist[NextNode] = dist_cand\n heappush(heap,(dist[NextNode],NextNode))\n return dist\n\nN,M,S = map(int,input().split())\ngraph = [[] for i in range(2501*N)]\nfor i in range(M):\n u,v,a,b = map(int,input().split())\n u -= 1\n v -= 1\n for s in range(a,2500):\n graph[2501*u+s].append([b,2501*v+s-a])\n graph[2501*v+s].append([b,2501*u+s-a])\n\nfor i in range(N):\n c,d = map(int,input().split())\n for s in range(2500):\n graph[2501*i+s].append([d,2501*i+min(2500,s+c)])\n\ndist = dijkstra(graph,2501*N,min(2500,S))\n\nans = [inf]*N\nfor i in range(N):\n for s in range(2501):\n ans[i] = min(ans[i],dist[2500*i+s])\n\nfor i in range(1,N):\n print(ans[i])", "jacc_sim": 1.0, "nl": "You have 500 points. Problem Statement: There are N cities numbered 1 to N, connected by M railroads. You are at City 1 with 10^{100} gold coins and S silver coins. The i-th railroad connects City U_i and City V_i bidirectionally, with a one-way trip costing A_i silver coins and taking B_i minutes. You cannot use gold coins for fare. Each city has an exchange counter where you can get C_i silver coins for 1 gold coin, taking D_i minutes for each gold coin. For each t=2, ..., N, find the minimum time needed to travel from City 1 to City t. Constraints: 2 \\leq N \\leq 50, N-1 \\leq M \\leq 100, 0 \\leq S \\leq 10^9, 1 \\leq A_i \\leq 50, 1 \\leq B_i,C_i,D_i \\leq 10^9, 1 \\leq U_i < V_i \\leq N, no duplicate railroads, and all input values are integers. Input: N M S, followed by U_i V_i A_i B_i, and C_i D_i. Output: For each t=2, ..., N, print the minimum time to travel from City 1 to City t.", "before_after_length": [439, 439], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u304602561", "n_user": "u304602561", "pos": "def sep():\n return map(int,input().strip().split(\" \"))\ndef lis():\n return list(sep())\n\nn=int(input())\nar=lis()\ndata=[]\nfor i in range(n):\n data.append((ar[i],i))\ndata.sort(reverse=True)\ndp = [[0] * (n+1) for _ in range(n+1)]\n\nfor i in range(n):\n a, p = data[i]\n for j in range(i+1):\n dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + abs(n-1-j-p)*a)\n dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(i-j-p)*a)\n#print(dp)\nprint(max(dp[-1]))\n\n\n\n\n\n\n", "neg": "def sep():\n return map(int,input().strip().split(\" \"))\ndef lis():\n return list(sep())\n\nn=int(input())\nar=lis()\ndata=[]\nfor i in range(n):\n data.append((ar[i],i))\ndata.sort(reverse=True)\ndp = [[0] * (n+1) for _ in range(n+1)]\n\nfor i in range(n):\n a, p = data[i]\n for j in range(i+1):\n dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + abs(n-1-j-p)*a)\n dp[i+1][j] = max(dp[i+1][j], dp[i][j] + abs(i-j-p)*a)\nprint(dp)\nprint(max(dp[-1]))\n\n\n\n\n\n\n", "jacc_sim": 0.9772727272727273, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [232, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u221998589", "n_user": "u221998589", "pos": "#import numpy as np\n#import math\n#from decimal import *\n#from numba import njit\n\n#@njit\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n A = sorted(enumerate(A), key = lambda x: x[1])[::-1]\n\n #dp = np.zeros((N+1,N+1), dtype='int64')\n dp = [[0]*(N+1-i) for i in range(N+1)]\n\n m = 0\n for i in range(1,len(A)+1):\n index,a = A[i-1]\n for j in range(i+1):\n if (i-j,j) == (0,0):\n dp[i-j][j] = 0\n elif i-j == 0:\n dp[i-j][j] = dp[i-j][j-1] + (N-j-index)*a\n elif j == 0:\n dp[i-j][j] = dp[i-j-1][j] + (abs(index-(i-j-1)))*a\n else:\n dp[i-j][j] = max(dp[i-j][j-1] + (N-j-index)*a, dp[i-j-1][j] + (abs(index-(i-j-1)))*a)\n if i == len(A):\n m = max(m, dp[i-j][j])\n\n #print(dp)\n #print(np.max(dp))\n print(m)\n\nmain()\n", "neg": "#import numpy as np\n#import math\n#from decimal import *\n#from numba import njit\n\n#@njit\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n\n A = sorted(enumerate(A), key = lambda x: x[1])[::-1]\n\n #dp = np.zeros((N+1,N+1), dtype='int64')\n dp = [[0]*(N+1-i) for i in range(N+1)]\n\n for i in range(1,len(A)+1):\n index,a = A[i-1]\n for j in range(i+1):\n if (i-j,j) == (0,0):\n dp[i-j][j] = 0\n elif i-j == 0:\n dp[i-j][j] = dp[i-j][j-1] + (N-j-index)*a\n elif j == 0:\n dp[i-j][j] = dp[i-j-1][j] + (abs(index-(i-j-1)))*a\n else:\n dp[i-j][j] = max(dp[i-j][j-1] + (N-j-index)*a, dp[i-j-1][j] + (abs(index-(i-j-1)))*a)\n\n #print(dp)\n #print(np.max(dp))\n\nmain()\n", "jacc_sim": 0.9827586206896551, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [402, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u860657719", "n_user": "u860657719", "pos": "n = int(input())\nA = list(map(int, input().split()))\na = []\nfor i in range(len(A)):\n a.append([A[i], i])\na.sort(key = lambda x: x[0], reverse = True)\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\nfor i in range(n):\n for l in range(i+1):\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + a[i][0]*(n-1-(i-l)-a[i][1]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + a[i][0] * (a[i][1] - l))\nans = 0\nfor now in dp[n]:\n ans = max(now, ans)\nprint(ans)\n\n\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\na = []\nfor i in range(len(A)):\n a.append([A[i], i])\na.sort(key = lambda x: x[0], reverse = True)\ndp = [[0 for i in range(n+1)] for j in range(n+1)]\nfor i in range(n):\n for l in range(i+1):\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + a[i][0]*(n-1-(i-l)-a[i][1]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + a[i][0] * (a[i][1] - l))\nans = 0\nprint(dp)\nfor now in dp[n]:\n ans = max(now, ans)\nprint(ans)\n\n\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [236, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u726285999", "n_user": "u726285999", "pos": "# \u5165\u529b\nN = int(input())\nA = [int(x) for x in input().split()]\n\n# \u521d\u671f\u5316\ndp = [[0] * (N+1) for _ in range(N+1)]\ndp[0][0] = 0\n\nfor i in range(0,N):\n\n # \u6700\u3082\u5b09\u3057\u3055\u306e\u9ad8\u3044\u5b50\u4f9b\u304b\u3089\u5834\u6240\u3092\u9078\u629e\u3057\u3066\u3044\u304f\n a = max(A)\n id = A.index(a)\n \n for x in range(0,i+1):\n y = i - x\n\n d = dp[x][y]\n tmp = d + a * (id - x)\n if dp[x+1][y] < tmp:\n \tdp[x+1][y] = tmp\n tmp = d + a * (((N-1)-y) - id) \n if dp[x][y+1] < tmp:\n \tdp[x][y+1] = tmp\n \n A[id] = 0\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, dp[i][N-i])\nprint(ans)", "neg": "# \u5165\u529b\nN = int(input())\nB = [int(x) for x in input().split()]\n\n# \u521d\u671f\u5316\ndp = [[0] * (N+1) for _ in range(N+1)]\ndp[0][0] = 0\n\nfor i in range(0,N):\n\n # \u6700\u3082\u5b09\u3057\u3055\u306e\u9ad8\u3044\u5b50\u4f9b\u304b\u3089\u5834\u6240\u3092\u9078\u629e\u3057\u3066\u3044\u304f\n id = A.index(max(A))\n \n for x in range(0,i+1):\n y = i - x\n \n dp[x+1][y] = max(dp[x+1][y], dp[x][y] + A[id] * (id - x))\n dp[x][y+1] = max(dp[x][y+1], dp[x][y] + A[id] * (((N-1)-y) - id))\n \n A[id] = 0\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, dp[i][N-i])\nprint(ans)", "jacc_sim": 0.9032258064516129, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [338, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u511379665", "n_user": "u511379665", "pos": "n=int(input())\na=list(map(int,input().split()))\ncost=[]\nfor i,g in enumerate(a):\n cost.append([g,i])\ncost.sort(reverse=True)\n\ndp=[[0] *(n+1) for _ in range(n+1) ]\n\nfor i in range(n):\n for j in range(i+1):\n dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+cost[i][0]*abs(cost[i][1]-j))\n dp[i+1][j]=max(dp[i+1][j],dp[i][j]+cost[i][0]*abs((n-1-(i-j))-cost[i][1]))\n\nprint(max(dp[-1]))", "neg": "n=int(input())\na=list(map(int,input().split()))\ncost=[]\nfor i,g in enumerate(a):\n cost.append([g,i])\ncost.sort(reverse=True)\n\n\ndp=[[0] *(n) for _ in range(n) ]\n\nfor i in range(n-1):\n for j in range(i+1):\n dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+cost[i][0]*(cost[i][1]-j))\n dp[i+1][j]=max(dp[i+1][j],dp[i][j]+cost[i][0]*(n-1-(i-j)-cost[i][1]))\n\nprint(max(dp[-1]))", "jacc_sim": 0.972972972972973, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [205, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u994521204", "n_user": "u994521204", "pos": "# \u89e3\u8aacAC\nimport sys\ninput = sys.stdin.buffer.readline\n\nn = int(input())\nA = list(map(int, input().split()))\nB = []\nfor i, e in enumerate(A):\n B.append((e, i + 1))\nB.sort(reverse=True)\n# dp[i][j]: Ai\u307e\u3067\u5165\u308c\u305f\u6642\u3001\u5de6\u306bj\u500b\u6c7a\u3081\u305f\u6642\u306e\u6700\u5927\u5024\ndp = [[-1] * (n + 1) for _ in range(n + 1)]\ndp[0][0] = 0\n\nfor i in range(n):\n for j in range(i + 1): # \u5de6\u306e\u500b\u6570\n k = i - j # \u53f3\u306e\u500b\u6570\n ni = i + 1\n val, idx = B[i]\n dp[ni][j] = max(dp[ni][j], dp[i][j] + abs(n - k - idx) * val)\n dp[ni][j + 1] = max(dp[ni][j + 1], dp[i][j] + abs(idx - (j + 1)) * val)\nans = 0\nfor i in range(n + 1):\n ans = max(ans, dp[n][i])\nprint(ans)\n", "neg": "# \u89e3\u8aacAC\nn = int(input())\nA = list(map(int, input().split()))\nB = []\nfor i, e in enumerate(A):\n B.append((e, i + 1))\nB.sort(reverse=True)\n# dp[i][j]: Ai\u307e\u3067\u5165\u308c\u305f\u6642\u3001\u5de6\u306bj\u500b\u6c7a\u3081\u305f\u6642\u306e\u6700\u5927\u5024\ndp = [[-1] * (n + 1) for _ in range(n + 1)]\ndp[0][0] = 0\n\nfor i in range(n):\n for j in range(i + 1): # \u5de6\u306e\u500b\u6570\n print(i, j)\n k = i - j # \u53f3\u306e\u500b\u6570\n ni = i + 1\n val, idx = B[i]\n dp[ni][j] = max(dp[ni][j], dp[i][j] + abs(n - k - idx) * val)\n dp[ni][j + 1] = max(dp[ni][j + 1], dp[i][j] + abs(idx - (j + 1)) * val)\nans = 0\nfor i in range(n + 1):\n ans = max(ans, dp[n][i])\nprint(ans)\n", "jacc_sim": 0.9285714285714286, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [359, 352], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u510443740", "n_user": "u510443740", "pos": "def solve(N, A):\n a = [(i, ai) for i, ai in enumerate(A)]\n a.sort(key=lambda x: x[1], reverse=True)\n\n # import numpy as np\n # dp = np.zeros((N+1, N+1), np.int8)\n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n\n dp[0][0] = 0\n for i, ai in enumerate(a):\n for l in range(i+1):\n r = i - l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ai[1] * ((N-1-r) - ai[0]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + ai[1] * (ai[0] - l))\n\n print(max(dp[N]))\n\nN = int(input())\nA = list(map(int, input().split()))\nsolve(N,A)", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\na = [(i, ai) for i, ai in enumerate(A)]\na = sorted(key=lambda x: x[1], reverse=True)\n\n# import numpy as np\n# dp = np.zeros((N+1, N+1), np.int8)\n\ndp = [[0] * (N + 1) for _ in range(N + 1)]\n\ndp[0][0] = 0\nfor i, ai in enumerate(a):\n for l in range(i+1):\n r = i - l\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ai[1] * ((N-1-r) - ai[0]))\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + ai[1] * (ai[0] - l))\n\nprint(max(dp[N]))", "jacc_sim": 0.9183673469387755, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [268, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u667084803", "n_user": "u667084803", "pos": "N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort(reverse=True)\n\n# DP[i][j] \u5de6\u7aef\u306b i \u500b, \u53f3\u7aef\u306b j \u500b\u8caa\u6b32\u306b\u8a70\u3081\u305f\u3068\u304d\u306e\u3046\u308c\u3057\u3055\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n # i \u4eba\u76ee table[i-1] \u306e\u5e7c\u5150\u3092\u79fb\u52d5\u3055\u305b\u308b\n for x in range(i+1):\n y = i - x\n\n #\u5de6\u7aef\u306b\u7f6e\u304f\u5834\u5408\u3068\u53f3\u7aef\u306b\u7f6e\u304f\u5834\u5408\u3067max\n DP[x][y] = max((DP[x-1][y] + table[i-1][0] * abs(table[i-1][1] - x+1)) * (x>0),\\\n (DP[x][y-1] + table[i-1][0] * abs(table[i-1][1] - (N - y))*(y>0)))\n\n\nans = 0\nfor i in range(N+1):\n for j in range(N+1):\n ans = max(ans, DP[i][j])\nprint(ans)\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\ntable = []\n\nfor i, a in enumerate(A):\n table.append([a,i])\ntable.sort(reverse=True)\n\n# DP[i][j] \u5de6\u7aef\u306b i \u500b, \u53f3\u7aef\u306b j \u500b\u8caa\u6b32\u306b\u8a70\u3081\u305f\u3068\u304d\u306e\u3046\u308c\u3057\u3055\nDP = [[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n # i \u4eba\u76ee table[i-1] \u306e\u5e7c\u5150\u3092\u79fb\u52d5\u3055\u305b\u308b\n baby, pos = table.pop()\n for x in range(i+1):\n y = i - x\n\n #\u5de6\u7aef\u306b\u7f6e\u304f\u5834\u5408\u3068\u53f3\u7aef\u306b\u7f6e\u304f\u5834\u5408\u3067max\n DP[x][y] = max((DP[x-1][y] + baby * abs(pos-x+1)) * (x>0),\\\n (DP[x][y-1] + baby * abs(pos-(N-y)) * (y>0)))\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, DP[i][N-i])\nprint(ans)\n", "jacc_sim": 0.9605263157894737, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [428, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u157020659", "n_user": "u157020659", "pos": "import sys\nsys.setrecursionlimit(2000 * 2)\nn = int(input())\na = list(map(int, input().split()))\na = [(i, v) for i, v in enumerate(a)]\na.sort(key=lambda x: x[1], reverse=True)\n\ndp = [[-1] * (m + 1) for m in range(n + 1)]\n# m: \u4f55\u4eba\u9078\u3093\u3060\u304b, l: \u5de6\u3092\u9078\u3093\u3060\u4eba\u6570\ndef f(m, l):\n if m == n: return 0\n if dp[m][l] != -1: return dp[m][l]\n r = n - m + l - 1\n i, v = a[m]\n if i >= l: dp[m + 1][l + 1] = f(m + 1, l + 1)\n if i <= r: dp[m + 1][l] = f(m + 1, l)\n return max(dp[m + 1][l + 1] + v * (i - l), dp[m + 1][l] + v * (r - i))\nprint(f(0, 0))", "neg": "import sys\nsys.setrecursionlimit(2 ** 2000)\nn = int(input())\na = list(map(int, input().split()))\na = [(i, v) for i, v in enumerate(a)]\na.sort(key=lambda x: x[1], reverse=True)\n\ndp = [[-1] * (m + 1) for m in range(n + 1)]\n# m: \u4f55\u4eba\u9078\u3093\u3060\u304b, l: \u5de6\u3092\u9078\u3093\u3060\u4eba\u6570\ndef f(m, l):\n if m == n: return 0\n if dp[m][l] != -1: return dp[m][l]\n r = n - m + l - 1\n i, v = a[m]\n if i >= l: dp[m + 1][l + 1] = f(m + 1, l + 1)\n if i <= r: dp[m + 1][l] = f(m + 1, l)\n return max(dp[m + 1][l + 1] + v * (i - l), dp[m + 1][l] + v * (r - i))\nprint(f(0, 0))", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [299, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u837673618", "n_user": "u837673618", "pos": "N = int(input())\n\ndef solve(a, i, prev):\n r = N - len(prev) - i + 1\n p = -i*a\n for j, s in enumerate(prev):\n yield max(p+abs(j-i)*a, s+abs(j+r)*a)\n p = s\n yield s+abs(len(prev)-i)*a\n\npd = [0]\nA = map(int, input().split())\nfor a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):\n pd = [*solve(a,i, pd)]\n\nprint(max(pd))\n", "neg": "N = int(input())\n\ndef solve(a, i, prev):\n r = N - len(prev) - i + 1\n p = -i*a\n for j, s in enumerate(prev):\n yield max(p+abs(j-i)*a, s+abs(j+r)*a)\n p = s\n yield s+abs(len(prev)-i)*a\n\npd = [0]\nA = map(int, input().split())\nfor a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):\n pd = [*solve(a,i, prev)]\n\nprint(max(prev))\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [164, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u451017206", "n_user": "u451017206", "pos": "N = int(input())\nA = [int(v) for v in input().split()]\nP = sorted([(v, i) for i, v in enumerate(A)], key=lambda x: x[0], reverse=True)\ndp = [[0 for j in range(2005)] for i in range(2005)]\n\nfor i in range(N):\n pi = P[i][1]\n for l in range(i+1):\n r = i - l\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi - l) * A[pi])\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((N-r-1) - pi) * A[pi])\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, dp[N][i])\n\nprint(ans)\n", "neg": "N = int(input())\nA = [(int(v), i) for i, v in enumerate(input().split())]\nA = sorted(A, key=lambda x: x[1])\ndp = [[0 for j in range(2005)] for i in range(2005)]\nfor i in range(N):\n pi = A[i][1]\n for l in range(i+1):\n r = i - l\n dp[i+1][l+1] = max(dp[i+1][l+1], dp[i][l] + (pi - l) * A[pi][0])\n dp[i+1][l] = max(dp[i+1][l], dp[i][l] + ((N-r-1) - pi) * A[pi][0])\n\nans = 0\nfor i in range(N+1):\n ans = max(ans, dp[N][i])\n\nprint(ans)", "jacc_sim": 0.925, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [234, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u969808621", "n_user": "u969808621", "pos": "from collections import defaultdict\n\n#dpa[(0,0)] = 0\n\nn = int(input())\n\na = list(map(int, input().split()))\n\nd = {}\nfor i in range(n):\n\td[i] = a[i]\n\ndp = defaultdict(lambda: 0)\n\ni = 0\nx = 0\ny = 0\nmaxr = 0\nfor k,v in sorted(d.items(), key=lambda x: -x[1]):\n\ti+=1\n#\tprint(k,\": \",v)\n\tfor j in range(i+1):\n\t\tif j == 0:\n\t\t\tmigi = 0\n\t\telse:\n\t\t\tmigi = abs(n - j - k)*v\n\t\t\n\t\tif i - j == 0:\n\t\t\thida = 0\n\t\telse:\n\t\t\thida = abs(k - (i - j)+1)*v\n\t\tdp[(j,i-j)] = max(dp[(j-1,i-j)]+migi,dp[(j,i-j-1)]+hida)\n\t\t\n\t\tif i == n:\n\t\t\tmaxr = max(maxr,dp[(j,i-j)])\n#\t\tprint(j,i-j,k,hida,migi,dp[(j,i-j)])\n\nprint(maxr)", "neg": "from collections import defaultdict\n\n#dpa[(0,0)] = 0\n\nn = int(input())\n\na = list(map(int, input().split()))\n\nd = {}\nfor i in range(n):\n\td[i] = a[i]\n\ndp = defaultdict(lambda: 0)\n\ni = 0\nx = 0\ny = 0\nmaxr = 0\nfor k,v in sorted(d.items(), key=lambda x: -x[1]):\n\ti+=1\n#\tprint(k,\": \",v)\n\tfor j in range(i+1):\n\t\tif j == 0:\n\t\t\tmigi = 0\n\t\telse:\n\t\t\tmigi = abs(n - j - k)*v\n\t\t\n\t\tif i - j == 0:\n\t\t\thida = 0\n\t\telse:\n\t\t\thida = abs(k - (i - j)+1)*v\n\t\tdp[(j,i-j)] = max(dp[(j-1,i-j)]+migi,dp[(j,i-j-1)]+hida)\n\t\t\n\t\tif k == n - 1:\n\t\t\tmaxr = max(maxr,dp[(j,i-j)])\n#\t\tprint(j,i-j,k,hida,migi,dp[(j,i-j)])\n\nprint(maxr)\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [341, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u535236942", "n_user": "u535236942", "pos": "n = int(input())\na = list(map(int, input().split()))\ndp = [[0] * (n+1) for i in range(n+1)]\nA = []\nfor i in range(n):\n A.append([a[i], i])\nA.sort(reverse=True)\nfor i in range(1, n+1):\n for j in range(i+1):\n if j == 0:\n dp[j][i-j] = dp[j][i-j-1] + A[i-1][0] * abs(n-i-A[i-1][1])\n elif j == i:\n dp[j][i-j] = dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-i+1)\n else:\n dp[j][i-j] = max(dp[j][i-j-1] + A[i-1][0] * abs(n-i+j-A[i-1][1]), dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-j+1))\nans = 0\nfor i in range(n+1):\n ans = max(ans, dp[i][n-i])\nprint(ans)", "neg": "n = int(input())\na = list(map(int, input().split()))\ndp = [[-1] * (n+1) for i in range(n+1)]\nA = []\nfor i in range(n):\n A.append([a[i], i])\nA.sort(reverse=True)\nfor i in range(1, n+1):\n for j in range(i+1):\n if j == 0:\n dp[j][i-j] = dp[j][i-j-1] + A[i-1][0] * abs(n-i-A[i-1][1])\n elif j == i:\n dp[j][i-j] = dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-i+1)\n else:\n dp[j][i-j] = max(dp[j][i-j-1] + A[i-1][0] * abs(n-i+j-A[i-1][1]), dp[j-1][i-j] + A[i-1][0] * abs(A[i-1][1]-j+1))\nans = 0\nfor i in range(n+1):\n ans = max(ans, dp[i][n-i])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [326, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u316464887", "n_user": "u316464887", "pos": "def main():\n N = int(input())\n A = list(map(int, input().split()))\n AA = [(v, i) for i, v in enumerate(A)]\n AA.sort(reverse=True)\n dp = [[0] * (N+1) for _ in range(N+1)]\n for i, (a, b) in enumerate(AA, start=1):\n for x in range(i+1):\n y = i - x\n if y == 0:\n dp[x][y] = dp[x-1][y] + abs(b - x+1) * a\n elif x == 0:\n dp[x][y] = dp[x][y-1] + abs(N-y-b) * a\n else:\n dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)\n r = 0\n for i in range(N+1):\n r = max(r, dp[i][N-i])\n return r\nprint(main())\n", "neg": "def main():\n N = int(input())\n A = list(map(int, input().split()))\n AA = [(v, i) for i, v in enumerate(A)]\n AA.sort(reverse=True)\n dp = [[0] * (N+1) for _ in range(N+1)]\n for i, (a, b) in enumerate(AA, start=1):\n for x in range(i+1):\n y = i - x\n if y == 0:\n dp[x][y] = dp[x-1][y] + abs(b - x+1) * a\n elif x == 0:\n dp[x][y] = dp[x][y-1] + abs(N-y-b) * a\n else:\n dp[x][y] = max(dp[x-1][y] + abs(b - x + 1) * a, dp[x][y-1] + abs(N-y-b) * a)\n for i in range(N+1):\n r = max(r, dp[i][N-i])\n return r\nprint(main())\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [281, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u179508038", "n_user": "u179508038", "pos": "n = int(input())\na = list(map(int,input().split()))\nans = 0\nplace = [0]*n\nactive = sorted(a,reverse=True)\nfor i in range(n):\n place[i] = a.index(active[i])\n a[a.index(active[i])] = -1\n\n#dp[x][y] x,y:0~n+1 (x[-1]=x[n+1]=0\u306b\u3059\u308b\u3053\u3068\u3067\u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b)\ndp = [[0 for i in range(n+2)]for j in range(n+2)]\n\nfor i in range(n):\n dp[0][i+1] = dp[0][i]+active[i]*abs(n-i-1-place[i])\n dp[i+1][0] = dp[i][0]+active[i]*abs(place[i]-i)\n\n\n\ndef check(mat):\n for i in range(len(mat)):\n print(mat[i])\n print(\"\\n\")\n\n\nfor i in range(n):\n for x in range(i+2):\n y = i+1 - x\n if x != 0 and y != 0:\n dp[x][y] = max(dp[x-1][y]+active[i]*abs(place[i]-x+1),dp[x][y-1]+active[i]*abs(n-y-place[i]))\n if i == n-1:\n ans = max(ans,dp[x][y])\n\nprint(ans)\n\n\n", "neg": "n = int(input())\na = list(map(int,input().split()))\nans = 0\nplace = [0]*n\nactive = sorted(a,reverse=True)\nfor i in range(n):\n place[i] = a.index(active[i])\n a[a.index(active[i])] = -1\n\n#dp[x][y] x,y:0~n+1 (x[-1]=x[n+1]=0\u306b\u3059\u308b\u3053\u3068\u3067\u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b)\ndp = [[0 for i in range(n+2)]for j in range(n+2)]\n\nfor i in range(n):\n dp[0][i+1] = dp[0][i]+active[i]*abs(n-i-1-place[i])\n dp[i+1][0] = dp[i][0]+active[i]*abs(place[i]-i)\n\n\n\ndef check(mat):\n for i in range(len(mat)):\n print(mat[i])\n print(\"\\n\")\n\ncheck(dp)\n\nfor i in range(n):\n for x in range(i+2):\n y = i+1 - x\n if x != 0 and y != 0:\n dp[x][y] = max(dp[x-1][y]+active[i]*abs(place[i]-x+1),dp[x][y-1]+active[i]*abs(n-y-place[i]))\n if i == n-1:\n ans = max(ans,dp[x][y])\n\nprint(ans)\n\n\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [418, 423], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u671861352", "n_user": "u671861352", "pos": "#!python3\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\n# N = 2000\n# A = [i for i in range(1, N + 1)]\n\n\ndef main():\n P = [(A[i], i + 1) for i in range(N)]\n P.sort(reverse=True)\n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n for n, p in zip(range(1, N + 1), P):\n x, y = p\n for i in range(n):\n j = n - 1 - i\n left = dp[i][j] + x * abs(y - (i + 1))\n dp[i + 1][j] = max(dp[i + 1][j], left)\n right = dp[i][j] + x * abs(y - (N - j))\n dp[i][j + 1] = max(dp[i][j + 1], right)\n\n ans = max([dp[i][N - i] for i in range(N)])\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "#!python3\n\n# input\nN = int(input())\nA = list(map(int, input().split()))\nN = 2000\nA = [i for i in range(1, N + 1)]\n\n\ndef main():\n P = [(A[i], i + 1) for i in range(N)]\n P.sort(reverse=True)\n\n dp = [[0] * (N + 1) for _ in range(N + 1)]\n for n, p in zip(range(1, N + 1), P):\n x, y = p\n for i in range(n):\n j = n - 1 - i\n left = dp[i][j] + x * abs(y - (i + 1))\n dp[i + 1][j] = max(dp[i + 1][j], left)\n right = dp[i][j] + x * abs(y - (N - j))\n dp[i][j + 1] = max(dp[i][j + 1], right)\n\n ans = max([dp[i][N - i] for i in range(N)])\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [291, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u618805180", "n_user": "u618805180", "pos": "N = int(input())\nA = [int(s) for s in input().split(\" \")]\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a,i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n \n prev = curr\n \nprint(max(prev))", "neg": "N = int(input())\n \nA = [int(s) for s in input().split(\" \")]\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a,i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n print(curr,k,i)\n prev = curr\n \nprint(max(prev))", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [161, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u038724782", "n_user": "u038724782", "pos": "n = int(input())\nA_l = [(A,i) for i, A in enumerate(map(int,input().split()))]\nA_l.sort(reverse=True)\n\ndp = []\nfor _ in range(n+1):\n dp.append([0] * (n+1))\nfor j in range(1,n+1): # all go bigger\n a, i = A_l[j-1]\n dp[j][0] = dp[j-1][0] + a*(n-(j-1) - (i+1))\nfor k in range(1,n+1): # all go smaller\n a, i = A_l[k-1]\n dp[0][k] = dp[0][k-1] + a*((i+1) - (1+(k-1)))\n\nfor j in range(1,n+1):\n for k in range(1,n-j+1):\n a, i = A_l[j+k-1]\n j_plus = a*(n-(j-1) - (i+1))\n k_plus = a*((i+1) - (1+(k-1)))\n dp[j][k] = max(dp[j-1][k]+j_plus, dp[j][k-1]+k_plus)\n\nresult = 0\nfor j in range(0,n+1):\n k = n-j\n result = max(result, dp[j][k])\nprint(result)\n#for l in range(n+1):\n# print(dp[l])", "neg": "n = int(input())\nA_l = [(A,i) for i, A in enumerate(map(int,input().split()))]\nA_l.sort()\nA_l.reverse()\n\ndp = []\nfor _ in range(n+1):\n dp.append([0] * (n+1))\nfor j in range(1,n+1): # all go bigger\n yb = n - (j-1)\n a, i = A_l[j-1]\n dp[j][0] = dp[j-1][0] + a*(yb-(i+1))\nfor k in range(1,n+1): # all go smaller\n ys = 1 + (k-1)\n a, i = A_l[k-1]\n dp[0][k] = dp[0][k-1] + a*((i+1)-ys)\n\nfor j in range(1,n+1):\n for k in range(1,n-j+1):\n yb = n - (j-1)\n ys = 1 + (k-1)\n a, x = A_l[j+k-1]\n j_plus = a*(yb-(i+1))\n k_plus = a*((i+1)-ys)\n dp[j][k] = max(dp[j-1][k]+j_plus, dp[j][k-1]+k_plus)\n\nresult = 0\nfor j in range(0,n+1):\n k = n-j\n result = max(result, dp[j][k])\nprint(result)\n#for l in range(n+1):\n# print(dp[l])", "jacc_sim": 0.9166666666666666, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [386, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u837673618", "n_user": "u947047288", "pos": "N = int(input())\n\nA = map(int, input().split())\nABI = sorted(((a, max(N-i, i-1)*a, i) for i, a in enumerate(A, 1)), reverse=True)\n\nprev = [0]\nfor k, (a, b, i) in enumerate(ABI):\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l]+abs(N-i-k+l)*a)\n curr[l+1] = prev[l]+abs(i-l-1)*a\n\n prev = curr\n\nprint(max(prev))\n", "neg": "N = int(input())\nA = np.array(list(map(int,input().split())))\nABI = sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True)\nprev = [0]\nfor k, (a, i) in enumerate(ABI)\n curr = [0]*(k+2)\n for l in range(k+1):\n curr[l] = max(curr[l], prev[l] + a*abs(N-i-(k-l)))\n curr[l+1] = prev[l]+a*abs(i-l-1)\n prev = curr\nprint (max(prev))", "jacc_sim": 0.9024390243902439, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [170, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u837673618", "n_user": "u837673618", "pos": "from collections import *\nfrom itertools import *\n\nN = int(input())\n\nA = map(int, input().split())\nSA = SB = 0\nABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)\n\nprev = {0:0}\nprev_max = 0\nfor k, (a, b, i) in enumerate(ABI):\n curr = defaultdict(int)\n curr_max = 0\n for l, p in prev.items():\n r = k-l\n if p + SB - min(l,r)*SA < prev_max:\n continue\n curr[l] = max(curr[l], p+abs(N-i-r)*a)\n curr[l+1] = p+abs(i-l-1)*a\n curr_max = max(curr_max, curr[l], curr[l+1])\n SA -= a\n SB -= b\n prev = curr\n prev_max = curr_max\n\nprint(curr_max)\n", "neg": "from collections import *\nfrom itertools import *\n\nN = int(input())\n\nA = map(int, input().split())\nSA = SB = 0\nABI = sorted(((b:=max(N-i, i-1)*a, SA:=SA+a, SB:=SB+b) and (a, b, i) for i, a in enumerate(A, 1)), reverse=True)\n\nprev = {0:0}\nprev_max = 0\nfor k, (a, b, i) in enumerate(ABI, 1):\n curr = defaultdict(int)\n curr_max = 0\n for l, p in prev.items():\n r = k-l\n if p + SB - min(l,r)*SA < prev_max:\n continue\n curr[l] = max(curr[l], p+abs(N-i-r)*a)\n curr[l+1] = p+abs(i-l-1)*a\n curr_max = max(curr_max, curr[l], curr[l+1])\n SA -= a\n SB -= b\n prev = curr\n prev_max = curr_max\n\nprint(curr_max)\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [286, 288], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u779455925", "n_user": "u779455925", "pos": "from heapq import *\nimport sys\nfrom collections import *\nfrom itertools import *\nfrom decimal import *\nimport copy\nfrom bisect import *\nimport time\nimport math\ndef gcd(a,b):\n if(a%b==0):return(b)\n return (gcd(b,a%b))\nN=int(input())\nA=list(map(int,input().split()))\nA=[[A[i],i] for i in range(N)]\nA.sort(reverse=True)\ndp=[[0 for i in range(N+1)] for _ in range(N+1)]\nfor n in range(N):\n a,p=A[n]\n for x in range(1,n+2):\n y=n+1-x\n dp[x][y]=max(dp[x][y],dp[x-1][y]+round(abs(x-1 - p))*a)\n for y in range(1,n+2):\n x=n+1-y\n dp[x][y]=max(dp[x][y],dp[x][y-1]+round(abs(N-y - p))*a)\n #print(dp)\nprint(max([dp[x][y] for x in range(N+1) for y in range(N+1) if x+y==N]))\n", "neg": "from heapq import *\nimport sys\nfrom collections import *\nfrom itertools import *\nfrom decimal import *\nimport copy\nfrom bisect import *\nimport time\nimport math\ndef gcd(a,b):\n if(a%b==0):return(b)\n return (gcd(b,a%b))\nN=int(input())\nA=list(map(int,input().split()))\nA=[[A[i],i] for i in range(N)]\nA.sort(reverse=True)\ndp=[[0 for i in range(N+1)] for _ in range(N+1)]\nfor n in range(N):\n a,p=A[n]\n for x in range(1,n+2):\n y=n+1-x\n dp[x][y]=dp[x-1][y]+round(abs(x-1 - p))*a\n for y in range(1,n+2):\n x=n+1-y\n dp[x][y]=dp[x][y-1]+round(abs(N-y - p))*a\n#print(dp)\nprint(max([dp[x][y] for x in range(N+1) for y in range(N+1) if x+y==N]))\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [324, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u802977614", "n_user": "u802977614", "pos": "INF = float('inf')\nmod = 10**9+7\neps = 10**-7\ndef inp():\n '''\n \u4e00\u3064\u306e\u6574\u6570\n '''\n return int(input())\ndef inpl():\n '''\n \u4e00\u884c\u306b\u8907\u6570\u306e\u6574\u6570\n '''\n return list(map(int, input().split()))\ndef inpl_str():\n '''\n \u4e00\u884c\u306b\u8907\u6570\u306e\u6587\u5b57\n '''\n return list(input().split())\n\nn=inp()\na = inpl()\nsorted_a = sorted(a,reverse=True)\nplace=dict()\nfor i in range(n):\n if a[i] not in place:\n place[a[i]]=[i+1]\n else:\n place[a[i]].append(i+1)\nans = 0\ndp=[[-INF]*(n+1) for i in range(n+1)]\ndp[0][0] = 0\nfor i in range(n):\n if i!=0 and sorted_a[i] == sorted_a[i - 1]:\n index += 1\n else:\n index = 0\n for j in range(n):\n _place = place[sorted_a[i]][index]\n #\u53f3\n dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))\n #\u5de6\n dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] * abs(_place - j - 1))\n\nprint(max(dp[n]))\n", "neg": "sys.setrecursionlimit(10**8)\ninput = sys.stdin.readline\nINF = float('inf')\nmod = 10**9+7\neps = 10**-7\ndef inp():\n '''\n \u4e00\u3064\u306e\u6574\u6570\n '''\n return int(input())\ndef inpl():\n '''\n \u4e00\u884c\u306b\u8907\u6570\u306e\u6574\u6570\n '''\n return list(map(int, input().split()))\ndef inpl_str():\n '''\n \u4e00\u884c\u306b\u8907\u6570\u306e\u6587\u5b57\n '''\n return list(input().split())\n\nn=inp()\na = inpl()\nsorted_a = sorted(a,reverse=True)\nplace=dict()\nfor i in range(n):\n if a[i] not in place:\n place[a[i]]=[i+1]\n else:\n place[a[i]].append(i+1)\nans = 0\ndp=[[-INF]*(n+1) for i in range(n+1)]\ndp[0][0] = 0\nfor i in range(n):\n if i!=0 and sorted_a[i] == sorted_a[i - 1]:\n index += 1\n else:\n index = 0\n for j in range(n):\n _place = place[sorted_a[i]][index]\n #\u53f3\n dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + sorted_a[i] * abs(n - (i - j) - _place))\n #\u5de6\n dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + sorted_a[i] * abs(_place - j - 1))\n\nprint(max(dp[n]))", "jacc_sim": 0.9342105263157895, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [460, 479], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u345966487", "n_user": "u876160558", "pos": "import sys\nsys.setrecursionlimit(10**6)\nN = int(input())\nA = list(map(int, input().split()))\nacts = [(x, i) for i, x in enumerate(A)]\nacts.sort()\ndp = [[-1]*N for _ in range(N)]\n\ndef solve(l, r):\n if r < l:\n return 0\n if dp[l][r] >= 0:\n return dp[l][r]\n k = r - l\n act, init_pos = acts[k]\n gain_l = act * abs(l - init_pos)\n gain_r = act * abs(r - init_pos)\n res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))\n return res\n\nprint(solve(0, N-1))\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\nacts = [(x, i) for i, x in enumerate(A)]\nacts.sort()\nprint(acts)\ndp = [[-1]*N for _ in range(N)]\n\ndef solve(l, r):\n if r < l:\n return 0\n if dp[l][r] >= 0:\n return dp[l][r]\n k = r - l\n act, init_pos = acts[k]\n gain_l = act * abs(l - init_pos)\n gain_r = act * abs(r - init_pos)\n res = dp[l][r] = max(gain_l + solve(l+1, r), gain_r + solve(l, r-1))\n return res\n\nprint(solve(0, N-1))\n", "jacc_sim": 0.9038461538461539, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [220, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u268554510", "n_user": "u268554510", "pos": "N = int(input())\nA = list(map(int,input().split()))\nA = [[a,i] for a,i in zip(A,range(1,N+1))]\nA = sorted(A,reverse=True)\nINF = float('inf')\ndp = [[-INF] * (N+1) for _ in range(N+1)]\ndp[0][0] = 0\nans = 0\nfor x_y in range(1,N+1):\n a = A[x_y-1]\n for x in range(x_y+1):\n y = x_y-x\n if x==0:\n dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])\n elif y==0:\n dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)\n else:\n dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))\n \n ans = max(ans,dp[x][y])\nprint(ans)", "neg": "N = int(input())*400\nA = list(map(int,input().split()))*400\nA = [[a,i] for a,i in zip(A,range(1,N+1))]\nA = sorted(A,reverse=True)\nINF = float('inf')\ndp = [[-INF] * (N+1) for _ in range(N+1)]\ndp[0][0] = 0\nans = 0\nfor x_y in range(1,N+1):\n a = A[x_y-1]\n for x in range(x_y+1):\n y = x_y-x\n if x==0:\n dp[x][y] = dp[x][y-1] + a[0]*(N-y+1-a[1])\n elif y==0:\n dp[x][y] = dp[x-1][y] + a[0]*(a[1]-x)\n else:\n dp[x][y] = max(dp[x-1][y]+a[0]*(a[1]-x),dp[x][y-1] + a[0]*(N-y+1-a[1]))\n \n ans = max(ans,dp[x][y])\nprint(ans)", "jacc_sim": 0.9777777777777777, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [304, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u047668580", "n_user": "u047668580", "pos": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\n\nN = int(input())\n#A = list(map(int, input().split()))\nA = [(a, i) for i, a in enumerate(map(int, input().split()))]\nA = sorted(A, reverse=True)\n\nvalues = []\nnum_indcies = {}\nfor i, a in enumerate(A):\n if not a in num_indcies:\n num_indcies[a] = [i]\n values.append(a)\n else:\n num_indcies[a].append(i)\n\nvalues = sorted(values, reverse=True)\nans = 0\n# index\u306e\u914d\u5217\ndp_indices = []\nfor v in values:\n dp_indices.extend(num_indcies[v])\n\n\ndp = [[0] * (N+1) for _ in range(N+1)]\nfor no, (a, pos) in enumerate(A):\n for i in range(no+1):\n j = no - i\n #k = dp_indices[i+j-2]\n #a = A[k]\n dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a * (pos -i))\n dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a * abs(pos - (N-1-j)))\n\nans = 0\nfor i in range(1, N+1):\n ans = max(ans, dp[i][N-i])\nprint(ans)\n\n\n\n", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import deque\n\nN = int(input())\n#A = list(map(int, input().split()))\nA = [(a, i) for i, a in enumerate(map(int, input().split()))]\nA = sorted(A, reverse=True)\n\nvalues = []\nnum_indcies = {}\nfor i, a in enumerate(A):\n if not a in num_indcies:\n num_indcies[a] = [i]\n values.append(a)\n else:\n num_indcies[a].append(i)\n\nvalues = sorted(values, reverse=True)\nans = 0\n# index\u306e\u914d\u5217\ndp_indices = []\nfor v in values:\n dp_indices.extend(num_indcies[v])\n\n\ndp = [[0] * (N+1) for _ in range(N+1)]\nfor no, (a, pos) in enumerate(A):\n for i in range(no+1):\n j = no - i\n #k = dp_indices[i+j-2]\n #a = A[k]\n dp[i+1][j] = max(dp[i+1][j], dp[i][j] + a * (pos -i))\n dp[i][j+1] = max(dp[i][j+1], dp[i][j] + a * abs(pos - (N-1-j)))\n print(i, j, dp[i][j])\n\nans = 0\nfor i in range(1, N+1):\n ans = max(ans, dp[i][N-i])\nprint(ans)\n\n\n\n", "jacc_sim": 1.0, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [399, 413], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u970737570", "n_user": "u970737570", "pos": "n = int(input())\na = list(map(int,input().split()))\nb = []\nfor i in range(n):\n b.append([a[i],i])\nb.sort()\nb = b[::-1]\n#print(b)\ndp = [[0]* (n+1) for i in range(n+1)]\ncnt = 0\nfor i,j in b:\n for k in range(cnt+1):\n dp[cnt-k][k+1] = max(dp[cnt-k][k] + abs(n-1-j-k)*i,dp[cnt-k][k+1])\n dp[cnt-k+1][k] = max(dp[cnt-k][k] + abs(j-(cnt-k))*i,dp[cnt-k+1][k])\n cnt+=1\nans = 0\nfor k in range(n):\n ans = max(ans,dp[n+1-k-1][k])\nprint(ans)", "neg": "n = int(input())\na = list(map(int,input().split()))\nb = []\nfor i in range(n):\n b.append([a[i],i])\nb.sort()\nb = b[::-1]\nprint(b)\ndp = [[0]* (n+1) for i in range(n+1)]\ncnt = 0\nfor i,j in b:\n for k in range(cnt+1):\n dp[cnt-k][k+1] = max(dp[cnt-k][k] + abs(n-1-j-k)*i,dp[cnt-k][k+1])\n dp[cnt-k+1][k] = max(dp[cnt-k][k] + abs(j-(cnt-k))*i,dp[cnt-k+1][k])\n cnt+=1\nans = 0\nfor k in range(n):\n ans = max(ans,dp[n+1-k-1][k])\nprint(ans)", "jacc_sim": 0.9722222222222222, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [242, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02709", "p_user": "u299869545", "n_user": "u408375121", "pos": "n = int(input())\na = map(int, input().split())\n\nbabies = [(a, i) for i, a in enumerate(a)]\n\nbabies.sort(reverse=True)\n\ndp = [[0] * (n+1) for i in range(n+1)]\n\nans = 0\n\nfor l in range(n):\n for r in range(n):\n if l + r == n:\n ans = max(ans, dp[l][r])\n break\n activeness, ind = babies[l+r]\n dp[l+1][r] = max(dp[l+1][r], dp[l][r] + abs(ind - l) * activeness)\n dp[l][r+1] = max(dp[l][r+1], dp[l][r] + abs(ind - (n-1-r)) * activeness)\n\nprint(ans)", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nbabies = [(a, i) for i, a in enumerate(a)]\nbabies.sort(reverse=True)\n\ndp = [[0 for _ in range(n)] for _ in range(n)]\nans = 0\nfor l in range(n):\n for r in range(n):\n if l+r == n:\n ans = max(ans, dp[l][r])\n break\n activeness, ind = babies[l+r]\n dp[l+1][r] = max(dp[l+1][r], dp[l][r] + activeness * abs(ind - l))\n dp[l][r+1] = max(dp[l][r+1], dp[l][r] + activeness * abs(ind - (n - 1 - r)))\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "You are given a line of N children, each with a certain level of activeness. You can rearrange the children once. When a child moves from one position to another, they earn happiness points based on their activeness and the distance moved. Find the maximum total happiness points the children can earn. Constraints: 2 \u2264 N \u2264 2000, 1 \u2264 Ai \u2264 10^9. Input format: N followed by the activeness levels of the children. Output the maximum total happiness points. Example: Input 1: 4, 1 3 4 2. Output 1: 20. Example 2: Input 2: 6, 5 5 6 1 1 1. Output 2: 58. Example 3: Input 3: 6, 8 6 9 1 2 1. Output 3: 85.", "before_after_length": [223, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02728", "p_user": "u837673618", "n_user": "u837673618", "pos": "from functools import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.buffer.readline\n \nM = 10**9+7\nN = int(input())\n\n@lru_cache(maxsize=None)\ndef mod_inv(x):\n if x == 1:\n return 1\n return M // x * -mod_inv(M%x) % M\n\nweight = [0]*(N+1)\nsize = [0]*(N+1)\ndef calc_subtree(v):\n W = 1\n S = 1\n for child in Edge[v]:\n Edge[child].remove(v)\n w, s = calc_subtree(child)\n W = W * w % M\n S += s\n weight[v] = W * S % M\n size[v] = S\n return weight[v], size[v]\n\nans = [0]*(N+1)\ndef set_ans(v, a):\n ans[v] = a\n for child in Edge[v]:\n n = size[child]\n set_ans(child, ans[v] * n * mod_inv(N-n) % M)\n\nEdge = defaultdict(set)\nfact = N\nfor i in range(1, N):\n fact = fact * i % M\n a, b = map(int, input().split())\n Edge[a].add(b)\n Edge[b].add(a)\n \ncalc_subtree(1)\nset_ans(1, mod_inv(weight[1]) * fact % M)\nfor i in range(1, N+1):\n print(ans[i])\n\n", "neg": "from functools import *\nfrom collections import *\nimport sys\nsys.setrecursionlimit(10**6)\ninput = sys.stdin.buffer.readline\n \nM = 10**9+7\nN = int(input())\n\n@lru_cache(maxsize=None)\ndef mod_inv(x):\n if x == 1:\n return 1\n return M // x * -mod_inv(M%x) % M\n\nweght = [0]*(N+1)\nsize = [0]*(N+1)\ndef calc_subtree(v):\n W = 1\n S = 1\n for child in Edge[v]:\n Edge[child].remove(v)\n w, s = calc_subtree(child)\n W = W * w % M\n S += s\n weight[v] = W * S % M\n size[v] = S\n return weight[v], size[v]\n\nans = [0]*(N+1)\ndef set_ans(v, a):\n ans[v] = a\n for child in Edge[v]:\n n = calc_subtree(child)[1]\n set_ans(child, ans[v] * n * mod_inv(N-n) % M)\n\nEdge = defaultdict(set)\nfact = N\nfor i in range(1, N):\n fact = fact * i % M\n a, b = map(int, input().split())\n Edge[a].add(b)\n Edge[b].add(a)\n\nset_ans(1, mod_inv(calc_subtree(1)[0]) * fact % M)\nfor i in range(1, N+1):\n print(ans[i])\n\n", "jacc_sim": 0.9855072463768116, "nl": "You are given a tree with N vertices numbered from 1 to N. For each k from 1 to N, you need to write numbers on the vertices according to specific rules. Find the number of ways to write the numbers on the vertices modulo (10^9+7). The constraints are 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, and the given graph is a tree. The input is given in a specific format, and for each k from 1 to N, you need to print the answer to the problem. There are sample inputs and outputs provided for reference.", "before_after_length": [407, 409], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02728", "p_user": "u197300773", "n_user": "u197300773", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\ndef modinv(a,m=10**9+7):\n if a==0: return 1\n b=m\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return lastx % m\n\ndef cur(p):\n for x in neighbor[p]:\n if x==par[p]: continue\n par[x]=p\n descend[p]+=cur(x)\n return descend[p]\n\ndef cur2(p):\n for x in neighbor[p]:\n if x==par[p]: continue\n ans[x]=ans[p]*descend[x]*modinv(n-descend[x])%mod\n cur2(x)\n\nmod=10**9+7\nn=int(input())\nneighbor=[[] for _ in range(n+1)]\ndescend=[1]*(n+1)\npar=[0]*(n+1)\n\nfor _ in range(n-1):\n a,b=map(int,input().split())\n neighbor[a].append(b)\n neighbor[b].append(a)\ncur(1)\n\nans=[1]*(n+1)\nans1=1\nfor i in range(1,n+1):\n ans1=ans1*i*modinv(descend[i])%mod\nans[1]=ans1\ncur2(1)\nfor i in range(1,n+1):\n print(ans[i])\n", "neg": "import sys\nsys.setrecursionlimit=10**12\n\ndef modinv(a,m=10**9+7):\n if a==0: return 1\n else:\n b=m\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return lastx % m\n\ndef cur(p):\n for x in neighbor[p]:\n if x!=par[p]:\n par[x]=p\n descend[p]+=cur(x)\n return descend[p]\n\ndef cur2(p):\n for x in neighbor[p]:\n if x==par[p]: continue\n ans[x]=ans[p]*descend[x]*modinv(n-descend[x])\n ans[x]%=mod\n cur2(x)\n\nmod=10**9+7\nn=int(input())\nneighbor=[[] for _ in range(n+1)]\ndescend=[1]*(n+1)\npar=[0]*(n+1)\n\nfor _ in range(n-1):\n a,b=map(int,input().split())\n neighbor[a].append(b)\n neighbor[b].append(a)\ncur(1)\n\nans=[1]*(n+1)\nans1=1\nfor i in range(1,n+1):\n ans1=ans1*i*modinv(descend[i])\n ans1%mod\nans[1]=ans1\n\ncur2(1)\n\nfor i in range(1,n+1):\n print(ans[i])", "jacc_sim": 0.9661016949152542, "nl": "You are given a tree with N vertices numbered from 1 to N. For each k from 1 to N, you need to write numbers on the vertices according to specific rules. Find the number of ways to write the numbers on the vertices modulo (10^9+7). The constraints are 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, and the given graph is a tree. The input is given in a specific format, and for each k from 1 to N, you need to print the answer to the problem. There are sample inputs and outputs provided for reference.", "before_after_length": [439, 454], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02728", "p_user": "u197300773", "n_user": "u197300773", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\ndef modinv(a,m=10**9+7):\n if a==0: return 1\n else:\n b=m\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return lastx % m\n\ndef cur(p):\n if neighbor[p]==[]: return\n for x in neighbor[p]:\n par[x]=p\n neighbor[x].remove(p)\n cur(x)\n descend[par[p]]+=descend[p]\n\ndef cur2(p):\n for x in neighbor[p]:\n ans[x]=ans[p]*descend[x]*modinv(n-descend[x])\n ans[x]%=mod\n cur2(x)\n\nmod=10**9+7\nn=int(input())\nneighbor=[set() for _ in range(n+2)]\ndescend=[1 for i in range(n+1)]\npar=[0]+[0]*(n+1)\n\nfor _ in range(n-1):\n a,b=map(int,input().split())\n neighbor[a].add(b)\n neighbor[b].add(a)\n\ncur(1)\n\n\nans=[1]*(n+1)\nans1=1\nfor i in range(1,n+1):\n ans1=ans1*i*modinv(descend[i])\n ans1%=mod\nans[1]=ans1\n\ncur2(1)\n\nfor i in range(1,n+1):\n print(ans[i])", "neg": "import sys\nsys.setrecursionlimit(10**12)\n\ndef modinv(a,m=10**9+7):\n if a==0: return 1\n else:\n b=m\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return lastx % m\n\ndef cur(p):\n if neighbor[p]==[]: return\n for x in neighbor[p]:\n par[x]=p\n neighbor[x].remove(p)\n cur(x)\n descend[par[p]]+=descend[p]\n\ndef cur2(p):\n for x in neighbor[p]:\n ans[x]=ans[p]*descend[x]*modinv(n-descend[x])\n ans[x]%=mod\n cur2(x)\n\nmod=10**9+7\nn=int(input())\nneighbor=[set() for _ in range(n+2)]\ndescend=[1 for i in range(n+1)]\npar=[0]+[0]*(n+1)\n\nfor _ in range(n-1):\n a,b=map(int,input().split())\n neighbor[a].add(b)\n neighbor[b].add(a)\n\ncur(1)\n\n\nans=[1]*(n+1)\nans1=1\nfor i in range(1,n+1):\n ans1=ans1*i*modinv(descend[i])\n ans1%=mod\nans[1]=ans1\n\ncur2(1)\n\nfor i in range(1,n+1):\n print(ans[i])", "jacc_sim": 0.9836065573770492, "nl": "You are given a tree with N vertices numbered from 1 to N. For each k from 1 to N, you need to write numbers on the vertices according to specific rules. Find the number of ways to write the numbers on the vertices modulo (10^9+7). The constraints are 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 a_i, b_i \u2264 N, and the given graph is a tree. The input is given in a specific format, and for each k from 1 to N, you need to print the answer to the problem. There are sample inputs and outputs provided for reference.", "before_after_length": [468, 468], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03230", "p_user": "u020390084", "n_user": "u020390084", "pos": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n N =INT()\n size = 0\n for i in range(1,10**3):\n if i*(i+1)//2 == N:\n size = i \n break\n else:\n print(\"No\")\n return\n \n k = size + 1\n answer = [[] for _ in range(k)]\n\n start = 1\n for i in range(k):\n answer[i] = list(range(start,start+size-i))\n start += size-i\n \n for i in range(k-1):\n for j in range(i+1,k):\n answer[j].append(answer[i][j-i-1])\n \n print(\"Yes\")\n print(k)\n for i in range(k):\n print(size,*answer[i])\n return\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\ndef INT(): return int(input())\ndef MAP(): return map(int,input().split())\ndef LI(): return list(map(int,input().split()))\n\ndef main():\n N =INT()\n size = 0\n for i in range(1,10**3):\n if i*(i+1)//2 == N:\n size = i \n break\n else:\n print(\"No\")\n \n k = size + 1\n answer = [[] for _ in range(k)]\n\n start = 1\n for i in range(k):\n answer[i] = list(range(start,start+size-i))\n start += size-i\n \n for i in range(k-1):\n for j in range(i+1,k):\n answer[j].append(answer[i][j-i-1])\n \n print(\"Yes\")\n print(k)\n for i in range(k):\n print(size,*answer[i])\n return\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given an integer N. Determine if there exists a tuple of subsets of {1,2,...N}, (S_1,S_2,...,S_k), such that each integer 1,2,...,N is contained in exactly two of the sets S_1,S_2,...,S_k, and any two of the sets S_1,S_2,...,S_k have exactly one element in common. If such a tuple exists, construct one such tuple.\n\nConstraints:\n1 \u2264 N \u2264 10^5\nN is an integer.\n\nInput:\nInput is given from Standard Input in the following format:\nN\n\nOutput:\nIf a tuple of subsets of {1,2,...N} that satisfies the conditions does not exist, print \"No\". If such a tuple exists, print \"Yes\" first, then print such subsets in the following format:\nk\n|S_1| S_{1,1} S_{1,2} ... S_{1,|S_1|}\n:\n|S_k| S_{k,1} S_{k,2} ... S_{k,|S_k|}\nwhere S_i={S_{i,1},S_{i,2},...,S_{i,|S_i|}}.\nIf there are multiple such tuples, any of them will be accepted.\n\nSample Input 1:\n3\n\nSample Output 1:\nYes\n3\n2 1 2\n2 3 1\n2 2 3\nIt can be seen that (S_1,S_2,S_3)=({1,2},{3,1},{2,3}) satisfies the conditions.\n\nSample Input 2:\n4\n\nSample Output 2:\nNo", "before_after_length": [284, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u124498235", "n_user": "u124498235", "pos": "import math\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nans = int((n*m)/math.gcd(n,m))\ng = math.gcd(n,m)\nfor i in range(g):\n if s[i*(n//g)] != t[i*(m//g)]:\n print (-1)\n exit()\nprint (ans)", "neg": "from collections import defaultdict\nimport math\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nans = int((n*m)/math.gcd(n,m))\ng = math.gcd(n,m)\nfor i in range(g):\n print (i*(n//g),i*(m//g))\n if s[i*(n//g)] != t[i*(m//g)]:\n print (-1)\n exit()\nprint (ans)", "jacc_sim": 0.9166666666666666, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [100, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u289288647", "n_user": "u289288647", "pos": "import math\nimport sys\nn, m = map(int, input().split())\ns = list(input())\nt = list(input())\na = (n*m)//math.gcd(n, m)\nb0 = [i*(a//n)+1 for i in range(n)]\nb1 = [i*(a//m)+1 for i in range(m)]\nb2 = set(b0)\nb3 = set(b1)\n\nfor j, i in enumerate(b0):\n if i in b3:\n if s[j] != t[b1.index(i)]:\n print(-1)\n sys.exit()\n \nfor j, i in enumerate(b1):\n if i in b2:\n if s[b0.index(i)] != t[j]:\n print(-1)\n sys.exit()\nprint(a)\n", "neg": "import math\nimport sys\nn, m = map(int, input().split())\ns = list(input())\nt = list(input())\na = (n*m)//math.gcd(n, m)\nb0 = [i*(a//n)+1 for i in range(n)]\nb1 = [i*(a//m)+1 for i in range(m)]\n\nfor j, i in enumerate(b0):\n if i in set(b1):\n if s[j] != t[b1.index(i)]:\n print(-1)\n sys.exit()\n \nfor j, i in enumerate(b1):\n if i in set(b0):\n if s[j] != t[b1.index(i)]:\n print(-1)\n sys.exit()\nprint(a)\n", "jacc_sim": 0.9534883720930233, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [212, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u678167152", "n_user": "u678167152", "pos": "from math import gcd\ndef solve():\n N, M = map(int, input().split())\n S = input()\n T = input()\n g = gcd(N,M)\n ans = N*M//g\n for i in range(g):\n if S[N//g*i]!=T[M//g*i]:\n return -1\n return ans\nprint(solve())", "neg": "N, M = map(int, input().split())\nS = input()\nT = input()\n\nfrom collections import gcd\n\ndef solve(N,M,S,T):\n g = gcd(N,M)\n for i in range(g):\n if S[N//g*i]!=T[M//g*i]:\n return -1\n ans = N*M//g\n return ans\nprint(solve(N,M,S,T))", "jacc_sim": 0.9459459459459459, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [97, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u835283937", "n_user": "u835283937", "pos": "import math\ndef main5():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n G = math.gcd(N, M)\n L = (N * M) // G\n\n for i in range(G):\n if S[i * N // G] != T[i * M // G]:\n print(-1)\n exit()\n\n print(L)\n\nif __name__ == \"__main__\":\n main5()", "neg": "import math\ndef main5():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n G = math.gcd(N, M)\n L = (N * M) // G\n\n for i in range(G):\n if S[i * N // G] != T[i * M // G]:\n print(-1)\n exit()\n\n print(L)\n\nif __name__ == \"__main__\":\n main4()", "jacc_sim": 0.9743589743589743, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [121, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u690781906", "n_user": "u690781906", "pos": "def 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\nN, M = map(int, input().split())\nS = input()\nT = input()\nx = gcd(N, M)\nn = N // x\nm = M // x\n\nfor i in range(x):\n if S[n*i] != T[m*i]:\n print(-1)\n exit()\nprint(N*M//x)\n", "neg": "def 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\nN, M = map(int, input().split())\nS = input()\nT = input()\nx = gcd(N, M)\nn = N // x\nm = M // x\n\nfor i in range(3):\n if S[n*i] == T[m*i]:\n print(-1)\n break\nprint(N*M//x)\n", "jacc_sim": 0.9285714285714286, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [138, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u750651325", "n_user": "u750651325", "pos": "import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float(\"inf\")\n\nn,m = I()\ns = v()\nt = v()\nl = lcm(n,m)\ng = math.gcd(n,m)\n\nfor i in range(g):\n if s[n//g*i] != t[m//g*i]:\n print(-1)\n sys.exit()\n\nprint(l)\n", "neg": "import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float(\"inf\")\n\nn,m = I()\ns = v()\nt = v()\nl = lcm(n,m)\ng = gcd(n,m)\n\nfor i in range(g):\n if s[n//g*i] != t[m//g*i]:\n print(-1)\n sys.exit()\n\nprint(l)\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [253, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u088863512", "n_user": "u088863512", "pos": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd\n# def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\n\n\ndef solve():\n n, m = [int(x) for x in input().split()]\n s = input()\n t = input()\n g = gcd(n, m)\n ans = n * m // g\n a, b = n // g, m // g\n x, y = 0, 0\n for i in range(g):\n if s[x] != t[y]:\n print(-1)\n return\n x += a\n y += b\n print(ans)\n \nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\n\n2 2 2 2 2\n\n\"\"\"\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd\n# def input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\n\n\ndef solve():\n n, m = [int(x) for x in input().split()]\n s = input()\n t = input()\n g = gcd(n, m)\n ans = n * m // g\n a, b = n // g, m // g\n x, y = 0, 0\n for i in range(g):\n if s[x] != x[y]:\n print(-1)\n return\n x += a\n y += b\n print(ans)\n \nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\n\n2 2 2 2 2\n\n\"\"\"\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [266, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u941438707", "n_user": "u941438707", "pos": "from math import *\na,b=map(int,input().split())\ns=input()\nt=input()\ng=gcd(a,b)\nfor i in range(g):\n if s[a//g*i]!=t[b//g*i]:\n print(-1)\n exit()\nprint(a*b//g)", "neg": "from math import *\na,b=map(int,input().split())\ns=input()\nt=input()\ng=gcd(a,b)\nif a%b==0 or b%a==0:\n for i in range(g):\n if s[a//g*i]!=t[b//g*i]:\n print(-1)\n exit()\nif t[0]!=s[0]:\n print(-1)\n exit()\nprint(a*b*g)", "jacc_sim": 0.9166666666666666, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [85, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u603958124", "n_user": "u603958124", "pos": "import bisect,copy,heapq,string\nfrom collections import *\nfrom math import *\nfrom itertools import *\nimport sys\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn, m = MAP()\ns = input()\nt = input()\nk = gcd(n,m)\nl = n*m//k\n\nfor i in range(0,l,l//k):\n if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:\n print(-1)\n exit()\nprint(l)", "neg": "import bisect,copy,heapq,string\nfrom collections import *\nfrom math import *\nfrom itertools import *\nimport sys\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn, m = MAP()\ns = input()\nt = input()\nl = n*m//gcd(n,m)\n\nfor i in range(0,l,l-1):\n if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:\n print(-1)\n exit()\nprint(l)", "jacc_sim": 0.9811320754716981, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [182, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u193927973", "n_user": "u193927973", "pos": "N, M=map(int, input().split())\ns=input()\nt=input()\nfrom math import gcd\n\ng=gcd(N,M)\n\nif g==1:\n ans=(N*M)//g\nelse:\n n=N//g\n m=M//g\n import numpy as np\n pn=np.arange(m, M, m)\n qm=np.arange(n, N, n)\n ans=(N*M)//g\n for i in range(len(pn)):\n if s[qm[i]]!=t[pn[i]]:\n ans=-1\n break\nif s[0]!=t[0]:\n ans=-1\nprint(ans)\n \n \n \n", "neg": "N, M=map(int, input().split())\ns=input()\nt=input()\nfrom math import gcd\n\ng=gcd(N,M)\n\nif g==1:\n ans=(N*M)//g\nelse:\n n=N//g\n m=M//g\n import numpy as np\n pn=np.arange(m, N, m)\n qm=np.arange(n, M, n)\n ans=(N*M)//g\n for i in range(len(pn)):\n if s[pn[i]]!=t[qm[i]]:\n ans=-1\n break\nprint(ans)\n \n \n ", "jacc_sim": 0.9777777777777777, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [182, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u230621983", "n_user": "u170201762", "pos": "import math\n\nn, m = map(int, input().split())\ns = input()\nt = input()\n\ngcd = math.gcd(n, m)\nN = n // gcd\nM = m // gcd\nans = n * m // gcd\nfor i in range(gcd):\n if s[i*N] != t[i*M] :\n ans = -1\n break\nprint(ans)", "neg": "from math import gcd\nN,M = map(int,input().split())\ns = input()\nt = input()\ng = gcd(N,M)\nl = N*M//g\n\nn = N//g\nm = M//g\n\nans = l\n\nfor i in range(l):\n if s[i*n]!=t[i*m]:\n ans = -1\n break\nprint(ans)\n\n", "jacc_sim": 0.918918918918919, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [100, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u871841829", "n_user": "u871841829", "pos": "N, M = map(int, input().split())\nS = input()\nT = input()\n\nimport sys\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n return gcd(b%a, a)\n\n\ng = gcd(N, M)\nsn = N//g\nsm = M//g\n\nok = True\nfor k in range(0, g):\n a = k * sn\n b = k * sm\n if S[a] != T[b]:\n ok = False\n break\n\nif ok:\n print(N*M//g)\nelse:\n print(-1)", "neg": "N, M = map(int, input().split())\nS = input()\nT = input()\n\nimport sys\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n gcd(b%a, a)\n\ng = gcd(N, M)\nsn = N/g\nsm = M/g\n\nok = True\nfor k in range(0, g):\n a = k * sn\n b = k * sm\n if S[a] != T[b]:\n ok = False\n break\n\nif ok:\n print(N*M/g)\nelse:\n print(-1)", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [157, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u151785909", "n_user": "u151785909", "pos": "n , m = map(int, input().split())\ns = input()\nt = input()\n\ndef gcd(num1,num2):\n r=1\n while r!=0:\n r=num1%num2\n num1=num2\n num2=r\n return num1\n\ndef lcm(num1,num2):\n return num1*num2//gcd(num1,num2)\n\ng1 = lcm(n,m)\ng2 = lcm(g1//n,g1//m)\n\nfor i in range(g1//g2):\n if s[g2*n*i//g1]!=t[g2*m*i//g1]:\n print('-1')\n exit()\nprint(g1)\n", "neg": "n , m = map(int, input().split())\ns = input()\nt = input()\n\ndef gcd(num1,num2):\n r=1\n while r!=0:\n r=num1%num2\n num1=num2\n num2=r\n return num1\n\ndef lcm(num1,num2):\n return num1*num2//gcd(num1,num2)\n\ng1 = lcm(n,m)\ng2 = lcm(g1//n,g1//m)\n\ns*=g1//n\nt*=g1//m\n\nfor i in range(g1//g2):\n if s[g2*i]!=t[g2*i]:\n print('-1')\n exit()\nprint(g1)\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [192, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u861141787", "n_user": "u861141787", "pos": "#import sys\nn, m = map(int, input().split())\ns = input()\nt = input()\n\nif s[0] != t[0]:\n print(-1)\n exit()\n #sys.exit(0)\n\n#a,b\u306e\u6700\u5927\u516c\u7d04\u6570\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\n#a,b\u306e\u6700\u5c0f\u516c\u500d\u6570\ndef lcm(a, b):\n return a * b // gcd (a, b)\n\nl = lcm(n, m)\nstep = min(l//n, l//m)\n\nfor i in range(0, l, step):\n if i % (l//n) == 0 and i % (l//m) == 0:\n if s[i * n // l] != t[i * m // l]:\n print(-1)\n exit()\n # sys.exit(0)\n\nprint(l)\n", "neg": "#import sys\nn, m = map(int, input().split())\ns = input()\nt = input()\n\nif s[0] != t[0]:\n print(-1)\n exit()\n #sys.exit(0)\n\n#a,b\u306e\u6700\u5927\u516c\u7d04\u6570\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\n#a,b\u306e\u6700\u5c0f\u516c\u500d\u6570\ndef lcm(a, b):\n return a * b // gcd (a, b)\n\nl = lcm(n, m)\nstep = max(l//n, l//m)\n\nfor i in range(1, l, step):\n if i % (l//n) == 0 and i % (l//m) == 0:\n if s[i * n // l] != t[i * m // l]:\n print(-1)\n exit()\n # sys.exit(0)\n\nprint(l)\n", "jacc_sim": 0.9622641509433962, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [261, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u540761833", "n_user": "u540761833", "pos": "N,M = map(int,input().split())\ndef gcd(a,b):\n if a >= b:\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n else:\n if a == 0:\n return b\n else:\n return gcd(a,b%a)\nS = input()\nT = input()\nif S[0] != T[0]:\n print(-1)\nelse:\n flag = True\n L = int((N//gcd(N,M))*M)\n m = L//M\n n = L//N\n for i in range(max(N,M)):\n if i*m <= N-1 and i*n <= M-1:\n if S[i*m] != T[i*n]:\n flag = False\n break\n if flag:\n print(L)\n else:\n print(-1)\n", "neg": "N,M = map(int,input().split())\ndef gcd(a,b):\n if a >= b:\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n else:\n if a == 0:\n return b\n else:\n return gcd(a,b%a)\nS = input()\nT = input()\nif S[0] != T[0]:\n print(-1)\nelse:\n flag = True\n L = int((N//gcd(N,M))*M)\n m = L//M\n n = L//N\n for i in range(min(N,M)):\n if i*m <= N-1 and i*n <= M-1:\n if S[i*m*L//N] != T[i*n*L//M]:\n flag = False\n break\n if flag:\n print(L)\n else:\n print(-1)\n", "jacc_sim": 0.9574468085106383, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [229, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u254871849", "n_user": "u254871849", "pos": "# 2019-11-28 02:28:10(JST)\nimport sys\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef main():\n n, m = map(int, sys.stdin.readline().split())\n s, t = sys.stdin.read().split()\n\n g = gcd(n, m)\n l = lcm(n, m)\n\n if g == 1:\n if s[0] == t[0]:\n ans = l\n else:\n ans = -1\n else:\n for i in range(g):\n if s[i * n // g] == t[i * m // g]:\n continue\n else:\n ans = -1\n break\n else:\n ans = l\n \n print(ans)\n\nif __name__ == '__main__':\n main()\n", "neg": "# 2019-11-28 02:28:10(JST)\nimport sys\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef lcm(a, b):\n return a * b // gcd(a, b)\n\ndef main():\n n, m = map(int, sys.stdin.readline().split())\n s, t = sys.stdin.read().split()\n\n g = gcd(n, m)\n l = lcm(n, m)\n\n if g == 1:\n if s[0] == s[1]:\n ans = l\n else:\n for i in range(g):\n if s[i * n // g] == t[i * m // g]:\n continue\n else:\n ans = -1\n break\n else:\n ans = l\n \n print(ans)\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [247, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u238510421", "n_user": "u238510421", "pos": "N,M = map(int,input().split())\nS = input()\nT = input()\n\ndef gcd(x, y):\n while y > 0:\n x, y = y, x%y\n return x\n \ndef lcm(x, y):\n return int(x/gcd(x, y)*y)\n\nlenx = lcm(N,M)\n\ns_list = list(S)\nt_list = list(T)\n\nbaisuu_s = int(lenx/N)\nbaisuu_t = int(lenx/M)\ndef check():\n for i in range(0,lenx,baisuu_s):\n if i % baisuu_s==0 and i%baisuu_t == 0:\n if s_list[int(i/baisuu_s)] == t_list[int(i/baisuu_t)]:\n pass\n else:\n return False\n return True\n\nif check():\n print(lenx)\nelse:\n print(-1)", "neg": "N,M = map(int,input().split())\nS = input()\nT = input()\n\ndef gcd(x, y):\n while y > 0:\n x, y = y, x%y\n return x\n \ndef lcm(x, y):\n return int(x/gcd(x, y)*y)\n\nlenx = lcm(N,M)\n\ns_list = list(S)\nt_list = list(T)\n\nbaisuu_s = lenx/N\nbaisuu_t = lenx/M\ndef check():\n for i in range(0,lenx,baisuu_s):\n if i % baisuu_s==0 and i%baisuu_t == 0:\n if s_list[int(i/baisuu_s)] == t_list[int(i/baisuu_t)]:\n pass\n else:\n return False\n return True\n\nif check():\n print(lenx)\nelse:\n print(-1)", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [254, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u932913455", "n_user": "u932913455", "pos": "def main28():\n import sys\n N, M = (int(x) for x in input().split())\n\n if N >= M:\n S = input()\n T = input()\n else:\n T = input()\n S = input()\n\n def lcm(n, m):\n gcd = 0\n for i in range(1, min(n, m) + 1):\n if n % i == 0 and m % i == 0:\n gcd = i\n\n return int(n * m / gcd)\n\n LCM = lcm(N, M)\n\n a = int(LCM / max(N, M))\n b = int(LCM / min(N, M))\n\n for i in range(min(N, M)):\n small_index = i * b\n if int(small_index % a) == 0:\n if S[int(small_index / a)] != T[i]:\n print(\"-1\")\n sys.exit()\n print(LCM)\n\nmain28()", "neg": "def main28():\n import sys\n N, M = (int(x) for x in input().split())\n\n if N >= M:\n S = input()\n T = input()\n else:\n T = input()\n S = input()\n\n def lcm(n, m):\n gcd = 0\n for i in range(1, min(n, m)):\n if n % i == 0 and m % i == 0:\n gcd = i\n\n return int(n * m / gcd)\n\n LCM = lcm(N, M)\n a = int(LCM / max(N, M))\n b = int(LCM / min(N, M))\n\n for i in range(b):\n small_index = i * b\n if small_index % a == 0 and S[int(small_index / a)] != T[i]:\n print(\"-1\")\n sys.exit()\n print(LCM)\n\nmain28()", "jacc_sim": 0.98, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [253, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u623819879", "n_user": "u623819879", "pos": "n,m=map(int, input().split())\ns=input()\nt=input()\ndef euc(x,y):\n if max(x,y) % min(x,y)==0:\n return min(x,y)\n else:\n return euc(max(x,y) % min (x,y),min(x,y))\nd=euc(n,m)\nans=n*int(m/d)\nif d==1:\n if s[0]==t[0]:\n print(n*m)\n else:\n print(-1)\nelse:\n for i in range(d):\n if s[i*int(n/d)]!=t[i*int(m/d)]:\n ans=-1\n print(ans)\n", "neg": "n,m=map(int, input().split())\ns=input()\nt=input()\ndef euc(x,y):\n if x % y==0:\n return x\n else:\n return euc(max(x,y) % min (x,y),min(x,y))\nd=euc(n,m)\nans=n*m\nif d==1:\n print(n*m)\nelse:\n for i in range(d):\n if s[i*int(n/d)]!=t[i*int(m/d)]:\n ans=-1\n print(ans)", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [195, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u371763408", "n_user": "u371763408", "pos": "n,m=map(int,input().split())\ns=input()\nt=input()\n\ndef gcd(x,y):\n r=x%y\n return gcd(y,r) if r else y\n#\u6700\u5c0f\u516c\u500d\u6570\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\nL=lcm(n,m)\ng=gcd(n,m)\nfor i in range(g):\n if s[int(i*n/g)]!=t[int(i*m/g)]:\n print(-1)\n exit()\nprint(L)", "neg": "n,m=map(int,input().split())\ns=input()\nt=input()\n\ndef gcd(x,y):\n r=x%y\n return gcd(y,r) if r else y\n#\u6700\u5c0f\u516c\u500d\u6570\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\nL=lcm(n,m)\ng=gcd(n,m)\nif s[0]==t[0]:\n X=[\"\"]*(L+1)\n print(X)\nelse:\n print(-1)\n exit()\nfor i in range(1,g):\n X[int(i*L/n)+1]=s[i]\nfor i in range(1,g):\n if X[int(i*L/m)+1] !=\"\":\n if X[int(i*L/m)+1] !=t[i]:\n print(-1)\n exit()\nprint(L)", "jacc_sim": 0.9183673469387755, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [162, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u130037310", "n_user": "u130037310", "pos": "N,M = map(int,input().split())\nS = input()\nT = input()\nans = 0\na = 2\n\nif S[0] != T[0]:ans = -1\n\nelif N % M != 0 and M % N != 0:\n if N >= M:\n while True:\n if N * a % M == 0:\n ans = N * a\n b = int(N*a/M)\n for i in range(int(N/b)):\n if T[a*i] != S[b*i]:\n ans = -1\n break\n break\n else:\n a += 1\n elif N < M:\n while True:\n if M * a % N == 0:\n ans = M * a\n b = int(M*a/N)\n for i in range(int(M/b)):\n if T[b*i] != S[a*i]:\n ans = -1\n break\n break\n else:\n a += 1\n\nelif N % M == 0:\n b = int(N/M)\n ans = N\n for i in range(M):\n if T[i] != S[b*i]:\n ans = -1\n break \n\nelif M % N == 0:\n b = int(M/N)\n ans = M\n for i in range(N):\n if S[i] != T[b*i]:\n ans = -1\n break \n\nprint(ans)\n", "neg": "N,M = map(int,input().split())\nS = input()\nT = input()\nans = 0\na = 2\n\nif S[0] != T[0]:ans = -1\n\nelif N % M != 0 and M % N != 0:\n if N >= M:\n while True:\n if N * a % M == 0:\n ans = N * a\n b = int(N*a/M)\n for i in range(M):\n if T[i] != S[b*i]:\n ans = -1\n break\n break\n else:\n a += 1\n elif N < M:\n while True:\n if M * a % N == 0:\n ans = M * a\n b = int(M*a/N)\n for i in range(N):\n if S[i] != T[b*i]:\n ans = -1\n break\n break\n else:\n a += 1\n\nelif N % M == 0:\n b = int(N/M)\n ans = N\n for i in range(M):\n if T[i] != S[b*i]:\n ans = -1\n break \n\nelif M % N == 0:\n b = int(M/N)\n ans = M\n for i in range(N):\n if S[i] != T[b*i]:\n ans = -1\n break \n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [369, 355], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u136647933", "n_user": "u136647933", "pos": "def gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\n\nx,y=map(int,input().split())\nS=input()\nT=input()\nGCD=gcd(x,y)\nLCM=(x * y) // GCD\n\nx_new=x//GCD\ny_new=y//GCD\nfor i in range(0,GCD):\n if S[(x_new)*i]==T[(y_new)*i]:\n result=LCM\n else:\n result=-1\n break\nprint(result)", "neg": "def gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\n\nx,y=map(int,input().split())\nS=input()\nT=input()\nGCD=gcd(x,y)\nLCM=(x * y) // GCD\n\nx_new=x//GCD\ny_new=y//GCD\nfor i in range(0,GCD-1):\n if S[(x_new)*i]==T[(y_new)*i]:\n result=LCM\n else:\n result=-1\n break\nprint(result)", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [150, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u236127431", "n_user": "u236127431", "pos": "N,M=map(int,input().split())\nS=input()\nT=input()\nlist_S=list(S)\nlist_T=list(T)\nNumber_i=[i for i in range(N)]\nNumber_iMN=[]\nfor i in Number_i:\n Number_iMN.append(i*M/N)\nNumber_j=[j for j in range(M)]\nKaburi_j=list(set(Number_iMN)&set(Number_j))\nKaburi_i=[]\nfor j in Kaburi_j:\n Kaburi_i.append(int(j*N/M))\ncounter=0\nFlag=0\nKaburi_Size=len(Kaburi_i)\nwhile counter<=Kaburi_Size-1:\n if list_S[int(Kaburi_i[counter])]==list_T[int(Kaburi_j[counter])]:\n pass\n else:\n Flag=1\n break\n counter+=1\ndef gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\nif Flag==1:\n print(-1)\nelse:\n print(int(N*M/gcd(N,M)))\n \n \n \n\n", "neg": "N,M=map(int,input().split())\nS=input()\nT=input()\nlist_S=list(S)\nlist_T=list(T)\nNumber_i=[i for i in range(M-1)]\nNumber_j=[j for j in range(N-1)]\nKaburi_i=[]\nKaburi_j=[]\ncounter=0\nFlag=0\nfor i in Number_i:\n if i*N/M in Number_j:\n Kaburi_i.append(i)\n Kaburi_j.append(int(i*N/M))\nKaburi_Size=len(Kaburi_i)\nwhile counter<=Kaburi_Size-1:\n if list_S[Kaburi_i[counter]]==list_T[Kaburi_j[counter]]:\n pass\n else:\n Flag=1\n break\n counter+=1\ndef gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\nif Flag==1:\n print(-1)\nelse:\n print(int(N*M/gcd(N,M)))\n \n \n\n\n", "jacc_sim": 0.9464285714285714, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [316, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u782098901", "n_user": "u782098901", "pos": "def gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef main():\n N, M = map(int, input().split())\n S = input()\n T = input()\n\n g = gcd(N, M)\n for i in range(g):\n if S[i * N // g] != T[i * M // g]:\n print(\"-1\")\n exit()\n print(N * M // g)\n\nmain()", "neg": "def gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\n\ndef main():\n N, M = map(int, input().split())\n S, T = input().split()\n\n g = gcd(N, M)\n for i in range(g):\n if S[i * N / g] == T[i * M / g]:\n print(\"-1\")\n exit()\n print(N * M / g)\n\nmain()\n", "jacc_sim": 0.975, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [146, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u166696759", "n_user": "u166696759", "pos": "def gcd(a, b):\n if b > a:\n gcd(b, a)\n while b:\n\t a, b = b, a % b\n return a\n\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nl = n * m // gcd(n, m)\na = l // n\nb = l // m\n#print(a, b)\n#a(i-1) = b(j-i) -> ai = bj + (a-b)\nres = False\nclear_all = True\nfor i in range(1,n+1):\n if (a*i - (a-b)) % b == 0:\n j = (a * i - (a-b)) // b\n if not s[i-1] == t[j-1]:\n clear_all = False\nif clear_all:\n res = True\nif res:\n print(l)\nelse:\n print(-1)\n ", "neg": "def gcd(a, b):\n if b > a:\n gcd(b, a)\n while b:\n\t a, b = b, a % b\n return a\n\nn,m = map(int, input().split())\ns = input()\nt = input()\n\nl = n * m // gcd(n, m)\na = l // n\nb = l // m\n#print(a, b)\n#a(i-1) = b(j-i) -> ai = bj + (a-b)\nres = False\nclear_all = True\nfor i in range(1,n+1):\n if (a*i - (a-b)) % b != 0:\n j = a * i - (a-b)\n if not s[i-1] == t[j-1]:\n clear_all = False\nif clear_all:\n res = True\nif res:\n print(l)\nelse:\n print(-1)\n ", "jacc_sim": 0.9791666666666666, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [239, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u189575640", "n_user": "u189575640", "pos": "import sys\nN,M = [int(n) for n in input().split()]\nS = str(input())\nT = str(input())\n\n# N < M\ndef gcd(N,M):\n if(N > M):\n tmp = N\n N = M\n M = tmp\n r = M % N\n while(r != 0):\n M = N\n N = r\n r = M%N\n return N\n\ndef lcm(N,M):\n return(N*M/gcd(N,M))\n\nif (N % M == 0):\n if S == T:\n print(M)\n else:\n p = int(N/M)\n for i in range(M):\n if T[i] != S[i*p]:\n print(-1)\n sys.exit()\n print(N)\nelif (M % N == 0):\n if S == T:\n print(M)\n else:\n p = int(M/N)\n for i in range(N):\n if S[i] != T[i*p]:\n print(-1)\n sys.exit()\n print(M)\nelse:\n mngcd = gcd(N,M)\n k = int(N/mngcd)\n m = int(M/mngcd)\n for i in range(mngcd):\n if S[i*k] != T[i*m]:\n print(-1)\n sys.exit()\n print(int(lcm(N,M)))\n", "neg": "import sys\nN,M = [int(n) for n in input().split()]\nS = str(input())\nT = str(input())\n\n# N < M\ndef gcd(N,M):\n if(N > M):\n tmp = N\n N = M\n M = tmp\n r = M % N\n while(r != 0):\n M = N\n N = r\n r = M%N\n return N\n\ndef lcm(N,M):\n return(N*M/gcd(N,M))\n\nif (N % M == 0):\n if S == T:\n print(M)\n else:\n p = int(N/M)\n for i in range(M):\n print(T[i],S[i*p])\n if T[i] != S[i*p]:\n print(-1)\n sys.exit()\n print(N)\nelif (M % N == 0):\n if S == T:\n print(M)\n else:\n p = int(M/N)\n for i in range(N):\n print(S[i],T[i*p])\n if S[i] != T[i*p]:\n print(-1)\n sys.exit()\n print(M)\nelse:\n print(int(lcm(N,M)))\n", "jacc_sim": 0.9387755102040817, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [380, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u170201762", "n_user": "u170201762", "pos": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n \nN,M = map(int,input().split())\ns = input()\nt = input()\ng = gcd(N,M)\nl = N*M//g\n\nn = N//g\nm = M//g\n\nans = l\n\nfor i in range(g):\n if s[i*n]!=t[i*m]:\n ans = -1\n break\nprint(ans)\n\n\n", "neg": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n \nN,M = map(int,Input().split())\ns = input()\nt = input()\ng = gcd(N,M)\nl = N*M//g\n\nn = N//g\nm = M//g\n\nans = l\n\nfor i in range(g):\n if s[i*n]!=t[i*m]:\n ans = -1\n break\nprint(ans)", "jacc_sim": 0.975609756097561, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [131, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u199295501", "n_user": "u199295501", "pos": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\nN, M = map(int, input().split())\nS = input()\nT = input()\n\nlcm_num = lcm(N,M)\nlN = lcm_num // N\nlM = lcm_num // M\ngcd_num = lN * lM\n\nfor i in range(0,lcm_num,gcd_num):\n if S[i//lN] == T[i//lM]:\n continue\n else:\n print(-1)\n exit()\n\nprint(lcm_num)\n", "neg": "def gcd(a, b):\n\twhile b:\n\t\ta, b = b, a % b\n\treturn a\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\nN, M = map(int, input().split())\nS = input()\nT = input()\n\nlcm_num = lcm(N,M)\nlN = lcm_num // N\nlM = lcm_num // M\ngcd_num = gcd(N,M)\n\nfor i in range(0,lcm_num,gcd_num):\n if i == 0 or (i%(lN) == 0 and i%(lM) == 0):\n if S[i//lN] == T[i//lM]:\n continue\n else:\n print(-1)\n exit()\n\nprint(lcm_num)\n", "jacc_sim": 0.9555555555555556, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [186, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u026788530", "n_user": "u026788530", "pos": "def gcd(a,b):\n if a%b == 0:\n return b\n return gcd(b,a%b)\n\n\nN,M = [int(i) for i in input().split()]\n\nS = input()\nT = input()\n\nx = N * M // gcd(N,M)\nflag = True\n\n#print(S[0 * (N / math.gcd(N,M)) + 1])\nfor i in range(gcd(N,M)):\n if not(S[i * (N //gcd(N,M))] == T[i * (M // gcd(N,M))]):\n flag = False\n# print(S[i * (N // math.gcd(N,M))] , T[i * (M // math.gcd(N,M))])\nif flag:\n print(x)\nelse:\n print('-1')", "neg": "def gcd(a,b):\n if a%b == 0:\n return b\n return gcd(b,a//b)\n\n\nN,M = [int(i) for i in input().split()]\n\nS = input()\nT = input()\n\nx = N * M // gcd(N,M)\nflag = True\n\n#print(S[0 * (N / math.gcd(N,M)) + 1])\nfor i in range(gcd(N,M)):\n if not(S[i * (N //gcd(N,M))] == T[i * (M // gcd(N,M))]):\n flag = False\n# print(S[i * (N // math.gcd(N,M))] , T[i * (M // math.gcd(N,M))])\nif flag:\n print(x)\nelse:\n print('-1')", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [220, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u879870653", "n_user": "u879870653", "pos": "def gcd(m,n) :\n x = max(m,n)\n y = min(m,n)\n if x%y == 0 :\n return y\n else :\n while x%y != 0 :\n z = x%y\n x = y\n y = z\n else :\n return z\n\ndef lcm(m,n) :\n return int(m*n/gcd(m,n))\n\nN,M = map(int,input().split())\nS = list(input())\nT = list(input())\nL = lcm(N,M)\nA = []\nB = []\nflag = 0\ncounter = 0\nif N >= M :\n for i in range(N) :\n A.append(i*L//N+1)\n for j in range(M) :\n b = j*L//M+1\n if j*N % M == 0 :\n index = N*j//M\n if S[index] == T[j] :\n counter += 1\n else :\n flag = 1\n break\n else :\n counter += 1\n if flag == 1 :\n print(-1)\n else :\n if counter == M :\n print(L)\nelse :\n for i in range(M) :\n A.append(i*L//M+1)\n for j in range(N) :\n b = j*L//N+1\n if j*M % N == 0 :\n index = M*j//N\n if T[index] == S[j] :\n counter += 1\n else :\n flag = 1\n break\n else :\n counter += 1\n if flag == 1 :\n print(-1)\n else :\n if counter == N :\n print(L)\n\n ", "neg": "def gcd(m,n) :\n x = max(m,n)\n y = min(m,n)\n if x%y == 0 :\n return y\n else :\n while x%y != 0 :\n z = x%y\n x = y\n y = z\n else :\n return z\n\ndef lcm(m,n) :\n return int(m*n/gcd(m,n))\n\nN,M = map(int,input().split())\nS = list(input())\nT = list(input())\nL = lcm(N,M)\nA = []\nB = []\nflag = 0\ncounter = 0\nfor i in range(N) :\n A.append(i*L//N+1)\nfor j in range(M) :\n b = j*L//M+1\n if j % M == 0 :\n index = N*j//M\n if S[index] == T[j] :\n counter += 1\n else :\n flag = 1\n else :\n counter += 1\nif flag == 1 :\n print(-1)\nelse :\n if counter == M :\n print(L)\n\n", "jacc_sim": 0.9636363636363636, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [440, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u603234915", "n_user": "u603234915", "pos": "def gcb(A, B):\n while B != 0:\n A, B = B, A%B\n return A\n\nN, M = map(int, input().split())\nS = input()\nT = input()\ncan = True\nagc = N // gcb(N, M) * M\nL_N = agc // N\nL_M = agc // M\ni = 0\nwhile i*L_M < N and i*L_N < M:\n if S[i*L_M] != T[i*L_N]:\n can = False\n break\n i += 1\n\nif can:\n print(agc)\nelse:\n print(-1)\n", "neg": "def gcd(A, B):\n while B != 0:\n A, B = B, A%B\n return A\n\nN, M = map(int, input().split())\nS = input()\nT = input()\nagc = N * M // gcd(N, M)\ncan = True\ni = 0\nwhile i*L_M < agc and i*L_N < agc:\n if S[i*L_M] != T[i*L_N]:\n can = False\n break\n i += 1\n if can:\n print(agc)\nelse:\n print(-1)", "jacc_sim": 0.9545454545454546, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [168, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u970738863", "n_user": "u970738863", "pos": "N,M = map(int,input().split())\nS = input()\nT = input()\n\ndef gcd(a,b):\n while b>0:\n a,b = b,a%b\n return a\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nL = lcm(N,M)\nG = gcd(N,M)\nn = L//N\nm = L//M\n\ns = [S[i*m] for i in range(G)]\nt = [T[i*n] for i in range(G)]\n\nif s == t or (G == 1 and S[0]==T[0]):\n print(L)\nelse:\n print(-1)\n", "neg": "N,M = map(int,input().split())\nS = input()\nT = input()\n\ndef gcd(a,b):\n while b>0:\n a,b = b,a%b\n return a\n\ndef lcm(a,b):\n return a*b//gcd(a,b)\n\nL = lcm(N,M)\nG = gcd(N,M)\nn = L//N\nm = L//M\n\ns = [S[i*m] for i in range(G)]\nt = [T[i*n] for i in range(G)]\n\nif s == t or (G == 1 and S[0]==T[0}]):\n print(L)\nelse:\n print(-1)\n", "jacc_sim": 0.9782608695652174, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [182, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u402629484", "n_user": "u402629484", "pos": "N, M = map(int, input().split())\nS = input()\nT = input()\n\ndef _gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\n\ngcd = _gcd(N,M)\nlcm = N*M//gcd\n\ndef check():\n a,b = 0,0\n da,db = N//gcd, M//gcd\n while a < N:\n if S[a]!=T[b]:\n print(-1)\n return\n a+=da\n b+=db\n print(lcm)\n\ncheck() \n\n\n\n\n", "neg": "N, M = map(int, input().split())\nS = input()\nT = input()\n\ndef _gcd(a,b):\n while b>0:\n a,b=b,a%b\n return a\n\ngcd = _gcd(N,M)\nlcm = N*M//gcd\n\ndef check():\n a,b = 0,0\n da,db = N//gcd, M//gcd\n while a < N:\n if S[a]!=T[b]:\n print(a, S[a])\n print(b, T[b])\n print(-1)\n return\n a+=da\n b+=db\n print(lcm)\n\ncheck() \n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [164, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03231", "p_user": "u293992530", "n_user": "u293992530", "pos": "import numpy as np\nimport scipy\ndef gcd(a, b):\n if a % b:\n return gcd(b, (a % b))\n else:\n return b\nN, M = map(int,input().split())\nS = input()\nT = input()\nt = gcd(N,M)\nn = N // t\nm = M // t\nans = n * m * t\nfor i in range(t):\n if(S[n*i]!=T[m*i]):\n ans = -1\n break\nprint(ans)\n\n", "neg": "import numpy as np\nimport scipy\ndef gcd(a, b):\n if a % b:\n return gcd(b, (a % b))\n else:\n return b\nN, M = map(int,input().split())\nS = input()\nT = input()\nt = gcd(N,M)\nn = N // t\nm = M // t\nans = n * m * t\nfor i in range(t):\n if(S[n*m*i]!=T[n*m*i]):\n ans = -1\n break\nprint(ans)\n\n", "jacc_sim": 1.0, "nl": "You are given two strings, S and T, both consisting of lowercase English letters. A string X is considered a \"good string\" if its length is divisible by both the lengths of S and T, and if specific concatenations of its characters result in S and T. Your task is to determine if a good string exists and, if so, find the length of the shortest such string. The input is given in the format N M S T, and the output should be the length of the shortest good string or -1 if it does not exist.", "before_after_length": [137, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u423585790", "n_user": "u423585790", "pos": "m=10**9+7\ni=s=r=0\nf=1\n_,*a=open(0).read().split()\nfor x in a:i+=1;s+=pow(i,m-2,m);r+=int(x)*~-s+int(a[-i])*s;f=f*i%m\nprint(r*f%m)", "neg": "m=10**9+7\ni=s=r=0\nf=1\n*a=open(0).read().split()\nfor x in a[1:]:i+=1;s+=pow(i,m-2,m);r+=int(x)*~-s+int(a[-i])*s;f=f*i\nprint(r*f%m)\n", "jacc_sim": 0.9722222222222222, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [93, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u013408661", "n_user": "u013408661", "pos": "import math\nN=int(input())\nnumber=list(map(int,input().split()))\nSUM=[]\nsum=0\np=10**9 +7\n#N\u306e\u968e\u4e57\nx=math.factorial(N)%p\n#0\u304b\u3089\u306b\u3059\u308b\u30681/0\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\nfor i in range(1,N+1):\n #k\u306f\u9006\u5143\n k=pow(i,p-2,p)\n sum+= (x*k)%p\n sum= sum%p\n SUM.append(sum)\nans=0\n#SUM\u306ei\u756a\u76ee\u306f1/1\u304b\u30891/i\u307e\u3067\u8db3\u3057\u305f\u548c\u306b\u306a\u3063\u3066\u3044\u308b\u3002\n#k=i-1\u3068\u306a\u308b\n#1/1\u3092\u4e8c\u56de\u8db3\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u5f15\u304f\nfor i in range(N):\n ans+= (number[i]*(SUM[i]+SUM[N-i-1]-x))%p\n ans= ans%p\n#\u7b54\u3048\nprint(ans)", "neg": "import math\nN=int(input())\nnumber=list(map(int,input().split()))\nSUM=[]\nsum=0\np=10**9 +7\n#N\u306e\u968e\u4e57\nx=math.factorial(N)%p\n#0\u304b\u3089\u306b\u3059\u308b\u30681/0\u3067\u30a8\u30e9\u30fc\u306b\u306a\u308b\nfor i in range(1,N+1):\n #k\u306f\u9006\u5143\n k=pow(i,p-2,p)\n sum+= (x*k)%p\n SUM.append(sum)\n#SUM\u306ei\u756a\u76ee\u306f1/1\u304b\u30891/i\u307e\u3067\u8db3\u3057\u305f\u548c\u306b\u306a\u3063\u3066\u3044\u308b\u3002\n#k=i-1\u3068\u306a\u308b\n#1/1\u3092\u4e8c\u56de\u8db3\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067\u5f15\u304f\nfor i in range(N):\n ans+= (number[i]*(SUM[i]+SUM[N-i]-x))%p\n ans= ans%p\n#\u7b54\u3048\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [364, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u013408661", "n_user": "u013408661", "pos": "import math\nn=int(input())\nnumber=list(map(int,input().split()))\nSUM=[]\nsum=0\np=10**9 +7\nx=math.factorial(n)%(10**9 +7)\nfor i in range(1,n+1):\n k=pow(i,p-2,p)\n sum+= (x*k)%p\n sum= sum%(p)\n SUM.append(sum)\nans=0\nfor i in range(n):\n ans+= number[i]*(SUM[n-1-i]+SUM[i]-x)\n ans=ans%(p)\nprint(ans)", "neg": "import math\nn=int(input())\nnumber=list(map(int,input().split()))\nSUM=[]\nsum=0\np=10**9 +7\nx=math.factorial(n)%(10**9 +7)\nfor i in range(1,n+1):\n k=pow(i,p-2,p)\n sum+= (x*k)%p\n sum= sum%(10**9 +7)\n SUM.append(sum)\nans=0\nfor i in range(n):\n ans+= number[i]*x*(SUM[n-1-i]+SUM[i]-1)\n ans=ans%(p)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [160, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u089032001", "n_user": "u089032001", "pos": "def multiply(x, y):\n return (x * y) % mod\n\n\ndef power(x, y):\n if y == 0:\n return 1\n elif y == 1:\n return x\n elif x == 1:\n return 1\n elif x == 0:\n return 0\n else:\n # print(mod)\n tmp = power(x, y // 2)\n return (multiply(tmp, tmp) * [1, x][y % 2]) % mod\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\n\nplist = [0]\nnfact = 1\nN\ntmp = 0\nfor i in range(1, N):\n tmp = (tmp + power(i + 1, mod - 2)) % mod\n nfact = (nfact * (i + 1)) % mod\n plist.append(tmp)\n\nans = 0\n# print(plist)\n# print(nfact)\nfor i, a in enumerate(A):\n # print(i, N - i - 1, N)\n tmp = (1 + plist[i] + plist[N - i - 1]) % mod\n ans = (ans + multiply(multiply(a, tmp), nfact)) % mod\n\nprint(ans)", "neg": "ef multiply(x, y):\n return (x * y) % mod\n\n\ndef power(x, y):\n if y == 0:\n return 1\n elif y == 1:\n return x\n elif x == 1:\n return 1\n elif x == 0:\n return 0\n else:\n # print(mod)\n tmp = power(x, y // 2)\n return (multiply(tmp, tmp) * [1, x][y % 2]) % mod\n\n\nN = int(input())\nA = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\n\nplist = [0]\nnfact = 1\nN\ntmp = 0\nfor i in range(1, N):\n tmp = (tmp + power(i + 1, mod - 2)) % mod\n nfact = (nfact * (i + 1)) % mod\n plist.append(tmp)\n\nans = 0\n# print(plist)\n# print(nfact)\nfor i, a in enumerate(A):\n # print(i, N - i - 1, N)\n tmp = (1 + plist[i] + plist[N - i - 1]) % mod\n ans = (ans + multiply(multiply(a, tmp), nfact)) % mod\n\nprint(ans)", "jacc_sim": 0.98, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [312, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u019489252", "n_user": "u423585790", "pos": "m=10**9+7\ni=s=r=0\nf=1\ninput()\na=input().split()\nfor x in a:s+=pow(i+1,m-2,m);r+=int(x)*~-s+int(a[~i])*s;i+=1;f=f*i%m\nprint(r*f%m)", "neg": "m=10**9+7\ni=s=r=0\nf=1\ninput()\na=map(int,input().split())\nfor x in a:i+=1;s+=pow(i,m-2,m);r+=x*~-s+a[-i]*s;f=f*i%m\nprint(r*f%m)\n", "jacc_sim": 0.9714285714285714, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [92, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u562016607", "n_user": "u562016607", "pos": "N=int(input())\nA=[int(i) for i in input().split()]\nP=10**9+7\ndef egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return (lastx, lasty, a)\ndef inv(x):\n return egcd(x,P)[0]%P\nQ=[0 for i in range(N)]\nI=[inv(i) for i in range(1,N+2)]\nU=[0 for i in range(N+2)]\nFact=[0 for i in range(N+1)]\nFact[0]=1\nfor i in range(N):\n Fact[i+1]=((i+1)*Fact[i])%P\nfor i in range(N+1):\n U[i+1]=(U[i]+I[i])%P\nfor j in range(N):\n Q[j]=(U[j+1]+U[N-j]-1)%P\nans=0\nfor j in range(N):\n ans+=A[j]*Q[j]\n ans=ans%P\nprint((ans*Fact[N])%P)\n", "neg": "N=int(input())\nA=[int(i) for i in input().split()]\nP=10**9+7\ndef egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n return (lastx, lasty, a)\ndef inv(x):\n return egcd(x,P)[0]%P\nQ=[0 for i in range(N)]\nI=[inv(i) for i in range(1,N+2)]\nU=[0 for i in range(N+2)]\nfor i in range(N):\n U[i+1]=(U[i]+I[i])%P\nfor j in range(N):\n Q[j]=(U[j+1]+U[N-j-1]-1)%P\nans=0\nfor i in range(N):\n ans+=A[i]*Q[i]\n ans=ans%P\nprint(ans)\n", "jacc_sim": 0.9795918367346939, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [361, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u019489252", "n_user": "u283869437", "pos": "m=10**9+7\ninput()\ni=s=r=0\nf=1\na=input().split()\nfor _ in a:\n s+=pow(i+1,m-2,m)\n r+=int(a[i])*~-s+int(a[~i])*s\n i+=1\n f=f*i%m\nprint(r*f%m)", "neg": "m=10**9+7\ninput()\ni=s=r=0\nf=1\na=map(int,input().split())\nfor _ in a:\n s+=pow(i+1,m-2,m)\n r+=a[i]*~-s+a[~i]*s\n i+=1\n f=f*i%m\nprint(r*f%m)", "jacc_sim": 0.9705882352941176, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [97, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03232", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\nn = int(input())\na = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\ndef extended_euclid(x, y):\n c0, c1 = x, y\n a0, a1 = 1, 0\n b0, b1 = 0, 1\n\n while c1 != 0:\n m = c0 % c1\n q = c0 // c1\n\n c0, c1 = c1, m\n a0, a1 = a1, (a0 - q * a1)\n b0, b1 = b1, (b0 - q * b1)\n\n # return c0, a0, b0\n return a0\n\ndef quotient(p, q): #p: \u5206\u5b50, q: \u5206\u6bcd\n\treturn (extended_euclid(q, MOD) * p) % MOD\n\ndef factorial(i):\n\tif i == 1:\n\t\treturn 1\n\telse:\n\t\treturn (factorial(i-1) * i) % MOD\n\ninv_list = [1]\nfor i in range(2, n+1):\n\tinv_list.append((inv_list[-1] + quotient(1, i)) % MOD)\n\n#print(inv_list[-1])\n#print(factorial(n))\n\nans = 0\nfor i in range(n):\n\tans += ((inv_list[i] + inv_list[n-1-i] - 1) * a[i]) % MOD\n\tans %= MOD\nans *= factorial(n)\nans %= MOD\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10**7)\n\nn = int(input())\n#a = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\ndef extended_euclid(x, y):\n c0, c1 = x, y\n a0, a1 = 1, 0\n b0, b1 = 0, 1\n\n while c1 != 0:\n m = c0 % c1\n q = c0 // c1\n\n c0, c1 = c1, m\n a0, a1 = a1, (a0 - q * a1)\n b0, b1 = b1, (b0 - q * b1)\n\n # return c0, a0, b0\n return a0\n\ndef quotient(p, q): #p: \u5206\u5b50, q: \u5206\u6bcd\n\treturn (extended_euclid(q, MOD) * p) % MOD\n\ndef factorial(i):\n\tif i == 1:\n\t\treturn 1\n\telse:\n\t\treturn (factorial(i-1) * i) % MOD\n\ninv_list = [1]\nfor i in range(2, n+1):\n\tinv_list.append((inv_list[-1] + quotient(1, i)) % MOD)\n\n#print(inv_list[-1])\n#print(factorial(n))\n\nans = 0\nfor i in range(n):\n\tans += ((inv_list[i] + inv_list[n-1-i] - 1) * a[i]) % MOD\n\tans %= MOD\nans *= factorial(n)\nans %= MOD\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N blocks arranged in a row, each with a weight. Snuke will remove blocks N times, choosing one block each time. The cost of removing a block is the sum of the weights of the connected blocks. Find the total cost for all possible orders of removing the blocks, and calculate the sum modulo 10^9+7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N, followed by N weights. Output the sum of total costs modulo 10^9+7 for all N! orders.", "before_after_length": [410, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03233", "p_user": "u488401358", "n_user": "u488401358", "pos": "N=int(input());A=[-1]*N;B=[-1]*N\nfor i in range(N):A[i],B[i]=map(int,input().split())\nans=min(sum(A),sum(B));t=[(A[i],i) for i in range(N)]+[(B[i],i) for i in range(N)];t.sort();d=[0]*N\nfor i in range(N):d[t[i][1]]+=1\nS=sum(t[i][0] for i in range(N))\nif max(d)==2:\n print(S)\nelse:\n ans2=min(S+max(A[i],B[i])-t[N-1-(t[N-1][1]==i)][0] for i in range(N))\n print(min(ans,ans2))", "neg": "N=int(input());A=[-1]*N;B=[-1]*N\nfor i in range(N):A[i],B[i]=map(int,input().split())\nans=min(sum(A),sum(B));t=[(A[i],i) for i in range(N)]+[(B[i],i) for i in range(N)];t.sort();d=[0]*N\nfor i in range(N):d[t[i][1]]+=1\nS=sum(t[i][0] for i in range(N))\nif max(d)==2:\n print(S)\nelse:\n ans=min(S+max(A[i],B[i])-t[N-1-(t[N-1][1]==i)][0] for i in range(N))\n print(ans)\n", "jacc_sim": 0.9736842105263158, "nl": "You are given a directed weighted graph with N vertices, each having two integers A_i and B_i. The weight of an edge from vertex x to vertex y is the minimum of A_x and B_y. Find the minimum total weight of the edges in a directed cycle that visits every vertex exactly once. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input is given as N followed by N lines of A_i and B_i. Output the minimum total weight of the edges in such a cycle.", "before_after_length": [213, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03233", "p_user": "u236127431", "n_user": "u236127431", "pos": "N=int(input())\nA=[]\nnode=[]\nfor i in range(N):\n x,y=map(int,input().split())\n A.append((x,i,\"left\"))\n A.append((y,i,\"right\"))\n node.append((x,y))\n \nA.sort()\nUsed=[[False,False] for i in range(N)]\nUsed_node=0\nfor i in range(N):\n if A[i][2]==\"left\":\n Used[A[i][1]][0]=True\n if not Used[A[i][1]][1]:\n Used_node+=1\n if A[i][2]==\"right\":\n Used[A[i][1]][1]=True\n if not Used[A[i][1]][0]:\n Used_node+=1\nif Used_node!=N:\n ans=0\n for i in range(N):\n ans+=A[i][0]\n print(ans)\nelse:\n if Used[0][0]:\n f=0\n else:\n f=1\n NO=0\n for i in range(N):\n if not Used[i][f]:\n NO=1\n break\n ans=0\n for i in range(N):\n ans+=A[i][0]\n ans2=float(\"inf\")\n if NO==1:\n for w in range(N):\n if A[N][1]==w:\n ans2=min(ans2,ans-min(node[w])+A[N+1][0])\n else:\n ans2=min(ans2,ans-min(node[w])+A[N][0])\n print(ans2)\n exit()\n print(ans)\n ", "neg": "N=int(input())\nA=[]\nnode=[]\nfor i in range(N):\n x,y=map(int,input().split())\n A.append((x,i,\"left\"))\n A.append((y,i,\"right\"))\n node.append((x,y))\n \nA.sort()\nUsed=[[False,False] for i in range(N)]\nUsed_node=0\nfor i in range(N):\n if A[i][2]==\"left\":\n Used[i][0]=True\n if not Used[i][1]:\n Used_node+=1\n if A[i][2]==\"right\":\n Used[i][1]=True\n if not Used[i][0]:\n Used_node+=1\nif Used_node!=N:\n ans=0\n for i in range(N):\n ans+=A[i][0]\n print(ans)\nelse:\n if A[0][0]:\n f=0\n else:\n f=1\n NO=0\n for i in range(N):\n if not Used[i][f]:\n NO=1\n break\n ans=0\n for i in range(N):\n ans+=A[i][0]\n ans2=float(\"inf\")\n if NO==1:\n for w in range(N):\n if A[N][1]==w:\n ans2=min(ans2,ans-min(node[w])+A[N+1][0])\n else:\n ans2=min(ans2,ans-min(node[w])+A[N][0])\n print(ans)\n ", "jacc_sim": 0.98, "nl": "You are given a directed weighted graph with N vertices, each having two integers A_i and B_i. The weight of an edge from vertex x to vertex y is the minimum of A_x and B_y. Find the minimum total weight of the edges in a directed cycle that visits every vertex exactly once. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input is given as N followed by N lines of A_i and B_i. Output the minimum total weight of the edges in such a cycle.", "before_after_length": [443, 412], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03233", "p_user": "u834415466", "n_user": "u834415466", "pos": "n=int(input())\na=[]\nb=[]\nfor i in range(n):\n p,q=map(int,input().split())\n a.append((p,i,0))\n a.append((q,i,1))\na.sort(key=lambda x:x[0])\nresult=0\nl=[0]*n\nflag=0\nfor i in range(n):\n if l[a[i][1]]==1:\n flag=1\n break\n else:\n l[a[i][1]]=1\nt=a[0][2]\ns=0\nfor i in range(n):\n s+=a[i][2]-a[0][2]\nif s==0:\n flag=1\nif flag==1:\n\n for i in range(n):\n result+=a[i][0]\n print(result)\nelse:\n if a[n-1][1]==a[n][1]:\n for i in range(n):\n result+=a[i][0]\n result+=min(a[n+1][0]-a[n-1][0],a[n][0]-a[n-2][0])\n print(result)\n else:\n for i in range(n):\n result+=a[i][0]\n result+=a[n][0]-a[n-1][0]\n print(result)", "neg": "n=int(input())\na=[]\nb=[]\nfor i in range(n):\n p,q=map(int,input().split())\n a.append((p,i,0))\n a.append((q,i,1))\na.sort(key=lambda x:x[0])\nresult=0\nl=[0]*n\nflag=0\nfor i in range(n):\n if l[a[i][1]]==1:\n flag=1\n break\n else:\n l[a[i][1]]=1\nif flag==1:\n\n for i in range(n):\n result+=a[i][0]\n print(result)\nelse:\n if a[n-1][1]==a[n][1]:\n for i in range(n):\n result+=a[i][0]\n result+=min(a[n+1][0]-a[n-1][0],a[n][0]-a[n-2][0])\n print(result)\n else:\n for i in range(n):\n result+=a[i][0]\n result+=a[n][0]-a[n-1][0]\n print(result)\n ", "jacc_sim": 0.9523809523809523, "nl": "You are given a directed weighted graph with N vertices, each having two integers A_i and B_i. The weight of an edge from vertex x to vertex y is the minimum of A_x and B_y. Find the minimum total weight of the edges in a directed cycle that visits every vertex exactly once. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input is given as N followed by N lines of A_i and B_i. Output the minimum total weight of the edges in such a cycle.", "before_after_length": [353, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u013408661", "n_user": "u013408661", "pos": "n,x=map(int,input().split())\nline=list(map(int,input().split()))\nSum=[0]\nsum=0\nfor i in range(n):\n sum+=line.pop()\n Sum.append(sum)\nAns=10**18\nfor k in range(1,n):\n p=0\n for i in range(n+k-1//k):\n if i==0:\n if n>=k:\n p+= (Sum[k])*5\n else:\n p+=(Sum[n])*5\n break\n else:\n if n> (k*i +k):\n p+= (Sum[k*i +k]-Sum[k*(i-1) +k])*(2*i +3)\n else:\n p+= (Sum[n]-Sum[k*(i-1) +k])*(2*i +3)\n break\n ans=(n+k)*x + p\n Ans=min(Ans,ans)\nprint(Ans)", "neg": "n,x=map(int,input().split())\nline=list(map(int,input().split()))\nSum=[0]\nsum=0\nfor i in range(n):\n sum+=line.pop()\n Sum.append(sum)\nAns=10**18\nfor k in range(1,n):\n p=0\n for i in range(n//k):\n if i==0:\n if n>=k:\n p+= (Sum[k])*5\n else:\n p+=(Sum[n])*5\n break\n else:\n if n> (k*i +k):\n p+= (Sum[k*i +k]-Sum[k*(i-1) +k])*(2*i +3)\n else:\n p+= (Sum[n]-Sum[k*(i-1) +k])*(2*i +3)\n break\n ans=(n+k)*x + p\n Ans=min(Ans,ans)\nprint(Ans)", "jacc_sim": 1.0, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [256, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u745087332", "n_user": "u745087332", "pos": "# coding:utf-8\n\n\nINF = float('inf')\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nN, X = inpl()\nA = inpl()\nB = [0]\nfor a in A:\n B.append(B[-1] + a)\n\nans = INF\nfor k in range(1, N + 1):\n e = 5\n cur = N - k\n tmp = e * (B[N] - B[cur]) + (N + k) * X\n cur -= k\n while True:\n tmp += e * (B[cur + k] - B[max(cur, 0)])\n if cur <= 0:\n break\n e += 2\n cur -= k\n\n ans = min(ans, tmp)\n\nprint(ans)\n", "neg": "# coding:utf-8\n\n\nINF = float('inf')\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nN, X = inpl()\nA = inpl()\nB = [0]\nfor a in A:\n B.append(B[-1] + a)\n\nans = INF\nfor k in range(1, N + 1):\n tmp = 0\n i = 0\n cur = N - k\n while True:\n e = 5 if i == 0 else 2 * i + 3\n tmp += e * (B[cur + k] - B[max(cur, 0)])\n if cur - k <= 0:\n break\n i += 1\n cur -= k\n\n ans = min(ans, tmp + (N + k) * X)\n\nprint(ans)", "jacc_sim": 0.9464285714285714, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [199, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u883048396", "n_user": "u883048396", "pos": "\niN ,iX = [int(x) for x in input().split()]\naCum = [0]\nfor x in input().split():\n aCum += [aCum[-1] + int(x)]\n\ndef fCeil(iT,iR):\n return -1 * iT // iR * -1\n\ndef fCalcCost(iN,iX,aCum,iK):\n iCost = (iN + iK ) * iX + 5 * aCum[iN]\n for i in range(2,fCeil(iN,iK) ):\n iCost += 2 * aCum[iN - i * iK ]\n return iCost\n\n#\u679d\u5208\u308a\niTotalCost = fCalcCost(iN,iX,aCum,1)\nfor iK in range(2,fCeil(iN,2) + 1):\n iThisCost = fCalcCost(iN,iX,aCum,iK)\n if iThisCost > iTotalCost:\n break\n else:\n iTotalCost = iThisCost\nprint(iTotalCost)\n", "neg": "iN ,iX = [int(x) for x in input().split()]\n\naCum = [0]\nfor x in input().split():\n aCum += [aCum[-1] + int(x)]\n\ndef fCeil(iT,iR):\n return -1 * iT // iR * -1\n\ndef fCalcCost(iN,iX,aCum,iK):\n iCost = (iN + iK ) * iX + 5 * aCum[-1]\n for i in range(2,fCeil(iN,iK) ):\n iCost += 2 * aCum[- i * iK]\n return iCost\n\niTotalCost = fCalcCost(iN,iX,aCum,1)\nfor iK in range(2,fCeil(iN,2) + 1):\n iThisCost = fCalcCost(iN,iX,aCum,iK)\n if iThisCost > iTotalCost:\n break\n else:\n iTotalCost = iThisCost\nprint(iTotalCost)\n", "jacc_sim": 0.9166666666666666, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [287, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u884982181", "n_user": "u884982181", "pos": "import sys\nn,x= map(int,input().split())\na = list(map(int, sys.stdin.readline().split()))\nru = [0]*(n+1)\nfor i in range(1,n+1):\n ru[i] = ru[i-1]+a[i-1]\nans = float(\"inf\")\nfor i in range(1,(n+1)//2+1):\n tmp = x*i+ru[n]*5\n j = n-i*2\n while j > 0:\n tmp += ru[j]*2\n j -= i\n ans = min(ans,tmp)\nprint(ans+n*x)", "neg": "import sys\nn,x= map(int,input().split())\na = list(map(int, sys.stdin.readline().split()))\nru = [0]*(n+1)\nfor i in range(1,n+1):\n ru[i] = ru[i-1]+a[i-1]\nans = float(\"inf\")\nfor i in range(1,n+1):\n tmp = x*i+ru[n]*5\n j = n-i*2\n k = 2\n while j > 0:\n tmp+= ru[j]*k\n k += 2\n j -= i\n ans = min(ans,tmp)\nprint(ans+n*x)", "jacc_sim": 0.9545454545454546, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [163, 168], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u270681687", "n_user": "u270681687", "pos": "N, X = map(int, input().split())\nx = list(map(int, input().split()))\n\ny = [x[0]]\nfor i in range(N-1):\n x[i+1] += x[i]\n y.append(x[i+1])\n\nans = 10**21\nfor k in range(1, N+1):\n num = N\n memo = k * X + X * N\n i = 0\n while num > k:\n memo += max(i+3, 5) * (y[num-1] - y[num-1-k])\n num -= k\n i += 2\n memo += max(i+3, 5) * (y[num-1])\n ans = min(ans, memo)\n\nprint(ans)\n", "neg": "N, X = map(int, input().split())\nx = list(map(int, input().split()))\n\ny = [x[0]]\nfor i in range(N-1):\n x[i+1] += x[i]\n y.append(x[i+1])\n\nans = 10**21\nfor k in range(1, N+1):\n num = N\n memo = k * X + X * N\n i = 0\n while num > k:\n memo += max(i+3, 5) * (y[num-1] - y[num-1-k])\n num -= k\n memo += max(i+3, 5) * (y[num-1])\n ans = min(ans, memo)\n\nprint(ans)\n", "jacc_sim": 0.975609756097561, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [193, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03255", "p_user": "u729707098", "n_user": "u729707098", "pos": "n,x = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\nb,ans = [0],float(\"inf\")\nfor i in range(n): b.append(b[-1]+a[i])\ndef f(k):\n\tm = 5*(b[n]-b[max(0,n-2*k)])\n\tfor i in range((n-k)//k): m+=(2*i+7)*(b[n-(2+i)*k]-b[max(0,n-(3+i)*k)])\n\treturn m+k*x\nfor i in range(1,(n+1)//2+1): ans = min(f(i),ans)\nprint(ans+n*x)", "neg": "n,x = (int(i) for i in input().split())\na = [int(i) for i in input().split()]\nb,ans = [0],float(\"inf\")\nfor i in range(n): b.append(b[-1]+a[i])\ndef f(k):\n\tm = 5*(b[n]-b[n-2*k])\n\tfor i in range((n-k)//k): m+=(2*i+7)*(b[n-(2+i)*k]-b[max(0,n-(3+i)*k)])\n\treturn m+k*x\nfor i in range(1,(n+1)//2+1): ans = min(f(i),ans)\nprint(ans+n*x)", "jacc_sim": 1.0, "nl": "Snuke wants to use a robot to clean his room. There are N pieces of trash on a number line, each at position xi. The goal is to move all trash to position 0. The robot can move left or right, pick up trash, and deposit it at position 0. It consumes X energy to pick up or deposit trash, and (k+1)^2 energy to move a distance of 1 while carrying k pieces of trash. Find the minimum energy required to move all N pieces of trash to position 0. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 < x1 < ... < xN \u2264 10^9, 1 \u2264 X \u2264 10^9.", "before_after_length": [191, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u488401358", "n_user": "u488401358", "pos": "import sys\n\ninput=sys.stdin.readline\n\ndef main():\n N,M=map(int,input().split())\n s=input()\n dic={\"A\":[0 for i in range(N)],\"B\":[0 for i in range(N)]}\n edge=[[] for i in range(N)]\n\n for i in range(M):\n a,b=map(int,input().split())\n a-=1;b-=1\n edge[a].append(b)\n edge[b].append(a)\n dic[s[a]][b]+=1\n dic[s[b]][a]+=1\n\n que=set([])\n check=0\n for i in range(N):\n if dic[\"A\"][i]==0 or dic[\"B\"][i]==0:\n que.add(i)\n\n\n while que:\n v=que.pop()\n check+=v+1\n dic[\"A\"][v]=float(\"inf\")\n dic[\"B\"][v]=float(\"inf\")\n for nv in edge[v]:\n dic[s[v]][nv]-=1\n if dic[\"A\"][nv]==0 or dic[\"B\"][nv]==0:\n que.add(nv)\n\n if check==N*(N+1)//2:\n print(\"No\")\n else:\n print(\"Yes\")\n\nif __name__==\"__main__\":\n main()", "neg": "import sys\n\ninput=sys.stdin.readline\n\ndef main():\n N,M=map(int,input().split())\n s=input()\n dic={\"A\":[0 for i in range(N)],\"B\":[0 for i in range(N)]}\n edge=[[] for i in range(N)]\n\n for i in range(M):\n a,b=map(int,input().split())\n a-=1;b-=1\n edge[a].append(b)\n edge[b].append(a)\n dic[s[a]][b]+=1\n dic[s[b]][a]+=1\n\n que=set([])\n check=0\n for i in range(N):\n if dic[\"A\"][i]==0 or dic[\"B\"][i]==0:\n que.add(i)\n dic[\"A\"][v]=float(\"inf\")\n dic[\"B\"][v]=float(\"inf\")\n\n while que:\n v=que.pop()\n check+=v+1\n for nv in edge[v]:\n dic[s[v]][nv]-=1\n if dic[\"A\"][nv]==0 or dic[\"B\"][nv]==0:\n dic[\"A\"][v]=float(\"inf\")\n dic[\"B\"][v]=float(\"inf\")\n que.add(nv)\n\n if check==N*(N+1)//2:\n print(\"No\")\n else:\n print(\"Yes\")\n\nif __name__==\"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [364, 391], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n N, M = map(int, input().split())\n S = [i == \"B\" for i in input()]\n ab = [list(map(int, input().split())) for _ in [0]*M]\n graph = [set() for _ in [0]*N]\n [graph[a-1].add(b-1) for a, b in ab]\n [graph[b-1].add(a-1) for a, b in ab]\n\n status = [[0, 0] for _ in [0]*N]\n\n for i in range(N):\n for j in graph[i]:\n status[i][S[j]] += 1\n\n que = []\n for i, (p, q) in enumerate(status):\n if (p == 0) ^ (q == 0):\n que.append(i)\n\n while que:\n i = que.pop()\n c = S[i]\n for j in graph[i]:\n if i != j:\n graph[j].remove(i)\n status[j][c] -= 1\n p, q = status[j]\n if (p == 0) ^ (q == 0):\n que.append(j)\n graph[i] = set()\n\n for i in graph:\n if i:\n print(\"Yes\")\n return\n print(\"No\")\n\n\nmain()\n", "neg": "def main():\n N, M = map(int, input().split())\n S = [i == \"B\" for i in input()]\n ab = [list(map(int, input().split())) for _ in [0]*M]\n graph = [set() for _ in [0]*N]\n [graph[a-1].add(b-1) for a, b in ab]\n [graph[b-1].add(a-1) for a, b in ab]\n\n status = [[0, 0] for _ in [0]*N]\n\n for i in range(N):\n for j in g[i]:\n status[i][S[j]] += 1\n\n que = []\n for i, (p, q) in enumerate(status):\n if (p == 0) ^ (q == 0):\n que.append(i)\n\n while que:\n i = que.pop()\n c = S[i]\n for j in graph[i]:\n if i != j:\n graph[j].remove(i)\n status[j][c] -= 1\n p, q = status[j]\n if (p == 0) ^ (q == 0):\n que.append(j)\n g[i] = set()\n\n for i in g:\n if i:\n print(\"Yes\")\n return\n print(\"No\")\n\n\nmain()\n", "jacc_sim": 0.9818181818181818, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [341, 341], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u077337864", "n_user": "u077337864", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\n\ndef main():\n n, m = map(int, input().split())\n s = input().strip()\n ab = [tuple(map(int, input().split())) for _ in range(m)]\n edges = [[] for _ in range(n)]\n for a, b in ab:\n edges[a - 1].append(b - 1)\n edges[b - 1].append(a - 1)\n \n ab = [[0, 0] for i in range(n)]\n stack = []\n for i in range(n):\n for e in edges[i]:\n if s[e] == 'A':\n ab[i][0] += 1\n else:\n ab[i][1] += 1\n if ab[i][0] == 0 or ab[i][1] == 0:\n stack.append(i)\n \n deleted = [False for i in range(n)]\n while len(stack) > 0:\n q = stack.pop()\n if deleted[q]:\n continue\n deleted[q] = True\n for e in edges[q]:\n if not deleted[e]:\n if s[q] == 'A':\n ab[e][0] -= 1\n if ab[e][0] == 0:\n stack.append(e)\n else:\n ab[e][1] -= 1\n if ab[e][1] == 0:\n stack.append(e)\n \n for d in deleted:\n if not d:\n print(\"Yes\")\n break\n else:\n print(\"No\")\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\n\ndef main():\n n, m = map(int, input().split())\n s = input().strip()\n ab = [tuple(map(int, input().split())) for _ in range(m)]\n edges = [[] for _ in range(n)]\n for a, b in ab:\n edges[a - 1].append(b - 1)\n edges[b - 1].append(a - 1)\n \n ab = [[0, 0] for i in range(n)]\n stack = []\n for i in range(n):\n for e in edges[i]:\n if s[e] == 'A':\n ab[i][0] += 1\n else:\n ab[i][1] += 1\n if ab[i][0] == 0 or ab[i][1] == 0:\n stack.append(i)\n \n deleted = [False for i in range(n)]\n while len(stack) > 0:\n q = stack.pop()\n if deleted[q]:\n continue\n deleted[q] = True\n for e in edges[q]:\n if not deleted[e]:\n if s[q] == 'A':\n ab[e][0] -= 1\n if ab[e][0] == 0:\n stack.append(e)\n else:\n ab[e][1] -= 1\n if ab[e][1] == 0:\n stack.append(e)\n \n for d in deleted:\n if not d:\n print(\"Yes\")\n break\n else:\n print(\"no\")\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9696969696969697, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [424, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u562016607", "n_user": "u562016607", "pos": "from collections import deque\nN,M=map(int,input().split())\ns=input()\nH=[[] for i in range(N)]\nG=[[] for i in range(2*N)]\nfor i in range(M):\n a,b=map(int,input().split())\n a-=1\n b-=1\n H[a].append(b)\n H[b].append(a)\n if s[a]==\"A\":\n if s[b]==\"A\":\n G[a].append(N+b)\n G[b].append(N+a)\n else:\n G[a+N].append(b+N)\n G[b].append(a)\n else:\n if s[b]==\"A\":\n G[a].append(b)\n G[N+b].append(N+a)\n else:\n G[N+a].append(b)\n G[N+b].append(a)\nK=[0 for i in range(2*N)]\nfor i in range(2*N):\n for p in G[i]:\n K[p]+=1\nq=deque(i for i in range(2*N) if K[i]==0)\nres=[]\nwhile q:\n v1=q.popleft()\n res.append(v1)\n for v2 in G[v1]:\n K[v2]-=1\n if K[v2]==0:\n q.append(v2)\nif len(res)==2*N:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "neg": "from collections import deque\nN,M=map(int,input().split())\ns=input()\nH=[[] for i in range(N)]\nG=[[] for i in range(2*N)]\nfor i in range(M):\n a,b=map(int,input().split())\n a-=1\n b-=1\n H[a].append(b)\n H[b].append(a)\n if s[a]==\"A\":\n if s[b]==\"A\":\n G[a].append(N+b)\n G[b].append(N+a)\n else:\n G[a+N].append(b+N)\n G[b].append(a)\n else:\n if s[b]==\"A\":\n G[a].append(b)\n G[N+b].append(N+a)\n else:\n G[N+a].append(b)\n G[N+b].append(a)\nK=[0 for i in range(2*N)]\nfor i in range(2*N):\n for p in G[i]:\n K[p]+=1\nq=deque(i for i in range(2*N) if K[i]==0)\nres=[]\nwhile q:\n v1=q.popleft()\n res.append(v1)\n for v2 in G[v1]:\n K[v2]-=1\n if K[v2]==0:\n q.append(v2)\nif len(res)==2*N:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [397, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u667024514", "n_user": "u667024514", "pos": "import collections\n\nn,m = map(int,input().split())\ns = list(str(input()))\nkey = collections.deque()\nlis = [[] for i in range(n)]\nli = [{\"A\":0,\"B\":0} for i in range(n)]\n\nfor i in range(m):\n a,b = map(int,input().split())\n lis[a-1].append(b-1)\n lis[b-1].append(a-1)\n li[a-1][s[b-1]] += 1\n li[b-1][s[a-1]] += 1\n \nans = [0 for i in range(n)]\n\nfor i in range(n):\n if li[i][\"A\"] == 0 or li[i][\"B\"] == 0:\n key.append(i)\n ans[i] = 1\n \nwhile len(key) > 0:\n num = key.popleft()\n for nu in lis[num]:\n li[nu][s[num]] -= 1\n if li[nu][\"A\"] == 0 or li[nu][\"B\"] == 0:\n if ans[nu] == 0:\n key.append(nu)\n ans[nu] = 1\n\nif sum(ans) == n:print(\"No\")\nelse:print(\"Yes\")", "neg": "import collections\n\nn,m = map(int,input().split())\ns = list(str(input()))\nkey = collection.deque()\nlis = [[] for i in range(n)]\nli = [{\"A\":0,\"B\":0} for i in range(n)]\n\nfor i in range(m):\n a,b = map(int,input().split())\n lis[a-1].append(b-1)\n lis[b-1].append(a-1)\n li[a-1][s[b-1]] += 1\n li[b-1][s[a-1]] += 1\n \nans = [0 for i in range(n)]\n\nfor i in range(n):\n if li[i][\"A\"] == 0 or li[i][\"B\"] == 0:\n key.append(i)\n ans[i] = 1\n \nwhile len(key) > 0:\n num = key.popleft()\n for nu in lis[num]:\n li[j][s[num]] -= 1\n if li[j][\"A\"] == 0 or li[j][\"B\"] == 0:\n if ans[j] == 0:\n key.append(j)\n ans[j] = 1\n\nif sum(ans) == n:print(\"No\")\nelse:print(\"Yes\")", "jacc_sim": 0.9636363636363636, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [326, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03256", "p_user": "u761320129", "n_user": "u761320129", "pos": "import sys,time\nsys.setrecursionlimit(10**7)\n\nstart_time = time.time()\nN,M = map(int,input().split())\nS = input()\nsrc = [tuple(map(lambda x:int(x)-1,sys.stdin.readline().split())) for i in range(M)]\n\noutdeg = [set() for i in range(2*N)]\nfor x,y in src:\n if S[x] == S[y]:\n #A0->A1, B0->B1\n outdeg[x].add(y+N)\n outdeg[y].add(x+N)\n else:\n #A1->B0, B1->A0\n outdeg[x+N].add(y)\n outdeg[y+N].add(x)\n\nmem = [0] * (2*N)\ndef visit(v):\n if time.time() - start_time > 1.8:\n # gori~~~\n print('No')\n exit()\n if mem[v] == 1:\n print('Yes')\n exit()\n if mem[v] == 0:\n mem[v] = 1\n for to in outdeg[v]:\n visit(to)\n mem[v] = 2\n\nfor i in range(2*N):\n visit(i)\n\nprint('No')", "neg": "import sys,time\nsys.setrecursionlimit(10**7)\n\nstart_time = time.time()\nN,M = map(int,input().split())\nS = input()\nsrc = [tuple(map(lambda x:int(x)-1,input().split())) for i in range(M)]\n\noutdeg = [set() for i in range(2*N)]\nfor x,y in src:\n if S[x] == S[y]:\n #A0->A1, B0->B1\n outdeg[x].add(y+N)\n outdeg[y].add(x+N)\n else:\n #A1->B0, B1->A0\n outdeg[x+N].add(y)\n outdeg[y+N].add(x)\n\nmem = [0] * (2*N)\ndef visit(v):\n # gori~~~\n if time.time() - start_time > 1.8:\n break\n if mem[v] == 1:\n print('Yes')\n exit()\n if mem[v] == 0:\n mem[v] = 1\n for to in outdeg[v]:\n visit(to)\n mem[v] = 2\n\nfor i in range(2*N):\n visit(i)\n\nprint('No')", "jacc_sim": 0.953125, "nl": "You are given an undirected graph with N vertices and M edges. Each vertex has a label, A or B. The phantom thief Nusook starts at a vertex and traverses edges to create a string of visited vertex labels. Determine if Nusook can create all possible strings of A and B. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 M \u2264 2 \u00d7 10^5, |s| = N, s_i is A or B, 1 \u2264 a_i, b_i \u2264 N. The input format is N, M, followed by the vertex labels, and the edges. Output \"Yes\" if Nusook can create all strings, otherwise \"No\". Examples are provided.", "before_after_length": [335, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u991713078", "n_user": "u991713078", "pos": "N,M=input().split()\nN=int(N)\nM=int(M)\nif M%2==0:\n print(int(N/M)**3+int((N+M/2)/M)**3)\nelse:\n print(int(N/M)**3)", "neg": "N,M=input().split()\nN=int(N)\nM=int(M)\nif M%2==0:\n print((N/M)**3+((N+M/2)/M)**3)\nelse:\n print((N/M)**3)", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [72, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u651663683", "n_user": "u651663683", "pos": "n,k=list(map(int,input().split()))\nr=0\nr+=(n//k)**3\nif k%2==0:\n r+=((n+k//2)//k)**3\nprint(r)\n", "neg": "n,k=list(map(int,input().split()))\nr=0\nr+=(n//k)**3\nif k%2==0:\n r+=((n-k//2)//k)**3\nprint(r)", "jacc_sim": 0.9583333333333334, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [60, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u995062424", "n_user": "u995062424", "pos": "N, K = map(int, input().split())\n\nif(K%2 != 0):\n a = N//K\n print(a**3)\nelse:\n a = N//K\n if(N%K >= K//2):\n b = a+1\n else:\n b = a\n print(a**3+b**3)", "neg": "N, K = map(int, input().split())\n\nif(K%2 != 0):\n a = N//K\n print(a**3)\nelse:\n a = N//K\n if(K*a+K//2 >= N):\n b = a+1\n else:\n b = a\n print(a**3+b**3)", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [87, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u597622207", "n_user": "u597622207", "pos": "# \u5947\u6570\u306e\u6642\n# a\uff0cb\uff0cc\u306fk\u306e\u500d\u6570\n# k\u304c\u5076\u6570\n# a, b, c\u304ck\u306e\u500d\u6570\n#\u3000\u3082\u3057\u304f\u306f\uff0c\u5168\u3066k/2\u306e\u500d\u6570\n\nN, K = map(int, input().split())\n\nif K % 2 != 0:\n n = N // K \n print(n ** 3)\n\nelse:\n n = N // K\n half_n = N // (K//2)\n print(n ** 3 + (half_n - n)** 3)", "neg": "# \u5947\u6570\u306e\u6642\n# a\uff0cb\uff0cc\u306fk\u306e\u500d\u6570\n# k\u304c\u5076\u6570\n# a, b, c\u304ck\u306e\u500d\u6570\n#\u3000\u3082\u3057\u304f\u306f\uff0c\u5168\u3066k/2\u306e\u500d\u6570\n\nN, K = map(int, input().split())\n\nif K % 2 != 0:\n n = N // K \n print(n ** 3)\n\nelse:\n n = N // K\n half_n = N // (K//2)\n print(half_n)\n print(n ** 3 + (half_n - n)** 3)", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [188, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u106778233", "n_user": "u106778233", "pos": "N,K=map(int,input().split())\nu1=N//K\nu2=N%K\nans=u1**3\n\nA=[u1]*K\nfor i in range(u2):\n A[i+1]+=1\nif K%2==0:\n ans+=A[K//2]**3\nprint(ans)", "neg": "N,K=map(int,input().split())\nu1, u2=divmod(N,K)\nans=u1*3\n\nA=[u1]*K\nfor i in range(u2):\n A[i+1]+=1\nif K%2==0:\n ans+=A[K//2+1]*3\nprint(ans)", "jacc_sim": 0.9696969696969697, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [86, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u201928947", "n_user": "u201928947", "pos": "n,k = map(int,input().split())\ncount = 0\ncount += (n//k) ** 3 \nif k % 2 == 0:\n count += ((n + k/2) // k) ** 3\nprint(int(count)) \n", "neg": "n,k = map(int,input().split())\ncount = 0\ncount += (n//k) ** 3 \nprint(int(count))\nif k % 2 == 0:\n count += ((n + k/2) // k) ** 3\nprint(int(count)) \n", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [59, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u241190159", "n_user": "u241190159", "pos": "import bisect\nimport math\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom copy import copy, deepcopy\nfrom heapq import heapify, heappop, heappush\nfrom itertools import combinations, permutations\nfrom queue import Queue\n\nread = sys.stdin.read\nreadline = sys.stdin.readline \nreadlines = sys.stdin.readlines \n\ndef SI():\n return int(readline())\ndef MI():\n return map(int, readline().split())\ndef MLI():\n return map(int, open(0).read().split())\n\ninf = float(\"inf\")\n\n\ndef main():\n N, K = MI()\n num_factor_K = N // K\n ret = num_factor_K ** 3\n \n if K % 2 == 0:\n num_factor_half_K = N // K\n if N % K >= K // 2:\n num_factor_half_K += 1\n ret += num_factor_half_K ** 3\n \n print(ret)\n \n\nif __name__ == \"__main__\":\n main()", "neg": "import bisect\nimport math\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom copy import copy, deepcopy\nfrom heapq import heapify, heappop, heappush\nfrom itertools import combinations, permutations\nfrom queue import Queue\n\nread = sys.stdin.read\nreadline = sys.stdin.readline \nreadlines = sys.stdin.readlines \n\ndef SI():\n return int(readline())\ndef MI():\n return map(int, readline().split())\ndef MLI():\n return map(int, open(0).read().split())\n\ninf = float(\"inf\")\n\n\ndef main():\n N, K = MI()\n num_factor_K = N // K\n ret = num_factor_K ** 3\n print(ret)\n \n if K % 2 == 0:\n num_factor_half_K = N // K\n if N % K >= K // 2:\n num_factor_half_K += 1\n ret += num_factor_half_K ** 3\n \n print(ret)\n \n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [257, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u815878613", "n_user": "u815878613", "pos": "def main():\n N, K = map(int, input().split())\n\n if K % 2 != 0:\n ans = (N // K)**3\n else:\n n = N // K\n if (n + 0.5) * K <= N:\n ans = (n + 1)**3 + n**3\n else:\n ans = 2 * n**3\n\n print(ans)\n\n\nmain()\n", "neg": "def main():\n N, K = map(int, input().split())\n\n if K % 2 != 0:\n ans = (N // K)**3\n else:\n n = N // K\n if (n + 0.5) * K >= N:\n ans = (n + 1)**3 + n**3\n else:\n ans = 2 * n**3\n\n print(ans)\n\n\nmain()\n", "jacc_sim": 0.9354838709677419, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [105, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u094191970", "n_user": "u094191970", "pos": "n,k=map(int,input().split())\nif k%2==1:\n print((n//k)**3)\nelse:\n kk=k//2\n cnt=0\n for i in range(1,n+1):\n if i%k==kk:\n cnt+=1\n print((n//k)**3+cnt**3)", "neg": "n,k=map(int,input().split())\nif k%2==1:\n print((n//k)**3)\nelse:\n kk=k//2\n cnt=0\n for i in range(1,n+1):\n if i//k==kk:\n cnt+=1\n print((n//k)**3+cnt**3)", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [90, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u937642029", "n_user": "u937642029", "pos": "def main():\n n,k = map(int,input().split())\n if k%2==1:\n a=n//k\n print(a**3)\n else:\n a=n//k\n b=(n+k//2)//k\n print(a**3+b**3)\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n n,k = map(int,input().split())\n if k%2==1:\n a=n//k\n print(a**3)\n else:\n a=n//k\n b=(n+k//2)//k\n print(a,b)\n print(a**3+b**3)\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [91, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u708255304", "n_user": "u708255304", "pos": "N, K = map(int, input().split())\n\n# K\u304c\u5076\u6570\u306e\u5834\u5408, \u5168\u3066K\u306e\u500d\u6570\u307e\u305f\u306f\u5168\u3066K//2\u306b\u500d\u6570\u306e\u4e21\u65b9\u8003\u3048\u308b\u5fc5\u8981\u3042\u308a\nnum = [0]*(K+1) # 1\u4ee5\u4e0aN\u4ee5\u4e0b\u306e\u6574\u6570\u3067\u4f59\u308a\u304c0~K-1\u306e\u500b\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u3059\u308b\nfor i in range(1, N+1):\n num[i % K] += 1 # i % K \u306e\u53d6\u308a\u3046\u308b\u5024\u306f0~K-1\n\nans = 0\nfor a in range(K+1): # a\u306b\u95a2\u3057\u3066\u5168\u63a2\u7d22\u3092\u884c\u3046\n b = (K-a) % K\n c = (K-a) % K\n if (b + c) % K == 0:\n ans += num[a] * num[b] * num[c]\n\nprint(ans)\n", "neg": "N, K = map(int, input().split())\n\n# K\u304c\u5076\u6570\u306e\u5834\u5408, \u5168\u3066K\u306e\u500d\u6570\u307e\u305f\u306f\u5168\u3066K//2\u306b\u500d\u6570\u306e\u4e21\u65b9\u8003\u3048\u308b\u5fc5\u8981\u3042\u308a\nnum = [0]*(K) # 1\u4ee5\u4e0aN\u4ee5\u4e0b\u306e\u6574\u6570\u3067\u4f59\u308a\u304c0~K-1\u306e\u500b\u6570\u3092\u30ab\u30a6\u30f3\u30c8\u3059\u308b\nfor i in range(1, N+1):\n num[i % K] += 1 # i % K \u306e\u53d6\u308a\u3046\u308b\u5024\u306f0~K-1\n\nans = 0\nfor a in range(K+1): # a\u306b\u95a2\u3057\u3066\u5168\u63a2\u7d22\u3092\u884c\u3046\n b = (K-a) % K\n c = (K-a) % K\n if (b + c) % K == 0:\n ans += num[a] * num[b] * num[c]\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [354, 352], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u670180528", "n_user": "u670180528", "pos": "n,k=map(int,input().split())\nif k%2:\n print((n//k)**3)\nelse:\n l=k//2\n print(((n+l)//k)**3+(n//k)**3)", "neg": "n,k=map(int,input())\nif k%2:\n print((n//k)**3)\nelse:\n l=k//2\n if l%2:\n print(((n+l)//k)**3)\n else:\n print(((n+l)//k)**3 + (n//k)**3)", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [62, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u892251744", "n_user": "u892251744", "pos": "N, K = map(int, input().split())\n\nif K%2 == 1:\n cand = N // K\n ans = cand\\\n + cand * (cand-1) * 3\\\n + cand * (cand-1) * (cand-2)\n print(int(ans))\nelse:\n cand_mod0 = N // K\n ans_mod0 = cand_mod0\\\n + cand_mod0 * (cand_mod0-1) * 3\\\n + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)\n cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1\n ans_modhalf = cand_modhalf\\\n + cand_modhalf * (cand_modhalf-1) * 3\\\n + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)\n print(int(ans_mod0 + ans_modhalf))", "neg": "N, K = map(int, input().split())\n\nif K%2 == 1:\n cand = N // K\n print(int(cand + comb(cand,2) * 6 + comb(cand,3) * 6))\nelse:\n cand_mod0 = N // K\n ans_mod0 = cand_mod0\\\n + cand_mod0 * (cand_mod0-1) * 3\\\n + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)\n cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1\n ans_modhalf = cand_modhalf\\\n + cand_modhalf * (cand_modhalf-1) * 3\\\n + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)\n print(int(ans_mod0 + ans_modhalf))", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [247, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u877470159", "n_user": "u519968172", "pos": "n,k=map(int,input().split())\nif k%2==0:\n q=n//(k//2)\n if q%2==0:\n print(2*(q//2)**3)\n else:\n print((q//2)**3+((q//2)+1)**3)\nelse:\n print((n//k)**3)\n\n", "neg": "n,k=map(int,input().split())\nif k%2==1:\n print((n//k)**3)\nelse:\n j=n//(k//2)\n print(j)\n if j %2==0:\n print(2*((j//2)**3))\n else:\n print(((j//2)**3)+((j//2+1)**3))\n \n", "jacc_sim": 0.92, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [94, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u771458127", "n_user": "u771458127", "pos": "import math\nimport sys\n\n\ndef parse(file):\n n, k = map(int, file.readline().split())\n return n, k\n\n\ndef main(n, k):\n if k % 2 == 1:\n return math.floor(n / k) ** 3\n else:\n return math.floor(n / k) ** 3 + math.floor((n + k/2) / k) ** 3\n\n\nif __name__ == '__main__':\n print(main(*parse(sys.stdin)))", "neg": "import math\nimport sys\n\n\ndef parse(file):\n n, k = map(int, file.readline().split())\n return n, k\n\n\ndef main(n, k):\n if n % 2 == 1:\n return math.floor(n / k) ** 3\n else:\n return math.floor(n/k) ** 3 + math.floor(n * 3 / 2 / k) ** 3\n\n\nif __name__ == '__main__':\n print(main(*parse(sys.stdin)))", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [128, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u473633103", "n_user": "u473633103", "pos": "# coding: utf-8\n# Your code here!\n\nn,k = map(int,input().split())\n\nhk = 0\n\nans = (n//k)**3\n\nif k%2==0:\n n -= k//2\n ans += (n//k +1)**3\n \nprint(ans)", "neg": "# coding: utf-8\n# Your code here!\n\nn,k = map(int,input().split())\n\nhk = 0\n\nans = (n//k)**3\n\n\nif k%2==0:\n n -= k//2\n ans += (((n*2)//k)**3)\n \nprint(ans)", "jacc_sim": 0.9696969696969697, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [79, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u470542271", "n_user": "u470542271", "pos": "n, k = map(int, input().split())\n\nmax_alpha = 2 * n // k\nif k % 2 == 0:\n if max_alpha % 2 == 0:\n ans = 2 * ((max_alpha / 2) ** 3)\n else:\n ans = ((max_alpha + 1) /2) ** 3 + ((max_alpha - 1) /2) ** 3\nelse:\n ans = (max_alpha // 2) ** 3\nprint(int(ans))\n", "neg": "n, k = map(int, input().split())\n\nmax_alpha = 2 * n // k\nif k % 2 == 0:\n print((max_alpha - 1) ** 3)\nelse:\n print((max_alpha // 2) ** 3)\n", "jacc_sim": 0.9230769230769231, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [115, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u760171369", "n_user": "u703890795", "pos": "N, K = map(int, input().split())\nif K % 2 == 0:\n print(int((N // K) ** 3 + ( (N // (K/2)) - N // K ) ** 3))\nelse:\n print(int((N // K) ** 3))", "neg": "N, K = map(int, input().split())\nif K%2==1:\n print((N//K)**3)\nelse:\n print((N//K)**3 + (((N//2)//K) - (N//K))**3)", "jacc_sim": 0.9166666666666666, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [66, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u800704240", "n_user": "u800704240", "pos": "from decimal import Decimal, ROUND_HALF_UP\nn,k = map(int,input().split())\nans = 0\nif k % 2 ==0:\n p = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)\n ans = p**3 +(n//k)**3\nelse:\n ans = (n // k)**3\nprint(ans)", "neg": "from decimal import Decimal, ROUND_HALF_UP\nn,k = map(int,input().split())\nans = 0\nif k % 2 ==0:\n k = Decimal(n/k).quantize(Decimal('0'),rounding=ROUND_HALF_UP)\n ans = k**3 +(n//k)**3\nelse:\n ans = (n // k)**3\nprint(ans)", "jacc_sim": 0.96875, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [96, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u807772568", "n_user": "u807772568", "pos": "a,b = map(int,input().split())\n\nif b%2 != 0:\n print(pow(a//b,3))\nelse:\n print(pow(a//b,3)+pow(((a+b//2)//b),3))\n", "neg": "a,b = map(int,input().split())\n\nif b%2 != 0:\n print(pow(a//b,3))\nelse:\n print(pow(a,2))", "jacc_sim": 0.9565217391304348, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [63, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u411537765", "n_user": "u463655976", "pos": "n, k = map(int, input().split())\nans = (n // k) ** 3\nif k % 2 == 0:\n ans += ((n + k // 2) // k) ** 3\nprint(ans)\n", "neg": "n, k = map(int, input().split())\n\nans = pow(n // k, 3)\nif k % 2 == 0:\n ans += pow((n + n // 2) // k, 3)\nprint(ans)", "jacc_sim": 0.9130434782608695, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [52, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u702582248", "n_user": "u702582248", "pos": "a, b=map(int, input().split())\ntry:\n c = a // (b // 2)\n c = c //2 + c%2\nexcept Exception as e:\n c = 0\nif b % 2 == 1:\n c = 0\ntry:\n d = a // b\nexcept Exception as e:\n d = 0\nprint(c**3 + d**3)", "neg": "a, b=map(int, input().split())\ntry:\n c = a // (b // 2)\n c = c //2 + c% 2\nexcept Exception as e:\n c = 0\ntry:\n d = a // b\nexcept Exception as e:\n d = 0\n print(c**3 + d **3)", "jacc_sim": 0.9310344827586207, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [94, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u761320129", "n_user": "u969708690", "pos": "N,K = map(int,input().split())\n\nif K%2:\n a = N//K\n print(a**3)\nelse:\n a = N//K\n b = (N+K//2)//K\n print(a**3 + b**3)", "neg": "N,K=map(int,input().split())\nif K%2==1:\n print(((N//K)+1)**3)\nelse:\n a=K//2\n if a%2==1:\n b=(a//2)+1\n print(2*(b**3))\n else:\n b=(a//2)+1\n c=a//2\n print(b**3+c**3)", "jacc_sim": 0.92, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [69, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u007808656", "n_user": "u007808656", "pos": "n,k=map(int,input().split())\nq=n//k\nr=n%k\nif k%2==1:\n print(q**3)\nelif(q*k+k//2<=n):\n print(q**3+(q+1)**3)\nelse:\n print(q**3+q**3)", "neg": "n,k=map(int,input().split())\nq=n//k\nr=n%k\nif k%2==1:\n print(q**3)\nelif(q*k+k//2 0:\n div = div//2\n print((div*div*div) + (div+1)*(div+1)*(div+1))\n else:\n div = div//2\n print(div*div*div*2)\nelse:\n div = N//K\n print(div*div*div)", "neg": "N,K=map(int,input().split())\n\nif K <=2:\n print(N*N*N)\nelse:\n if K%2 == 0:\n div = N//(K//2)\n if div%2 > 0:\n div = div//2\n print((div*div*div) + (div+1)*(div+1)*(div+1))\n else:\n print(div*div*div)\n else:\n div = N//K\n print(div*div*div)", "jacc_sim": 0.96, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [118, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u944209426", "n_user": "u944209426", "pos": "n,k=map(int, input().split())\ndef com(a,b):\n r=1\n for c in range(b):\n r*=(a-c)\n r//=c+1\n return r\nif k%2==0:\n x=0\n y=0\n for i in range(1,n+1):\n if i%k==k//2:\n x+=1\n if i%k==0:\n y+=1\n ans=0\n if x>=1:\n ans+=com(x,1)\n if x>=2:\n ans+=6*com(x,2)\n if x>=3:\n ans+=6*com(x,3)\n if y>=1:\n ans+=com(y,1)\n if y>=2:\n ans+=6*com(y,2)\n if y>=3:\n ans+=6*com(y,3)\n print(ans)\nelse:\n x=0\n for i in range(1,n+1):\n if i%k==0:\n x+=1\n ans=0\n if x>=1:\n ans+=com(x,1)\n if x>=2:\n ans+=6*com(x,2)\n if x>=3:\n ans+=6*com(x,3)\n print(ans)", "neg": "n,k=map(int, input().split())\nif k%2==0:\n x=0\n y=0\n for i in range(1,n+1):\n if i%k==k//2:\n x+=1\n if i%k==0:\n y+=1\n ans=0\n if x>=1:\n ans+=com(x,1)\n if x>=2:\n ans+=6*com(x,2)\n if x>=3:\n ans+=6*com(x,3)\n if y>=1:\n ans+=com(y,1)\n if y>=2:\n ans+=6*com(y,2)\n if y>=3:\n ans+=6*com(y,3)\n print(ans)\nelse:\n x=0\n for i in range(1,n+1):\n if i%k==0:\n x+=1\n ans=0\n if x>=1:\n ans+=com(x,1)\n if x>=2:\n ans+=6*com(x,2)\n if x>=3:\n ans+=6*com(x,3)\n print(ans)\n \ndef com(a,b):\n r=1\n for i in range(b):\n r*=(a-i)\n r//=i+1\n return r", "jacc_sim": 0.975, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [359, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u833070958", "n_user": "u859897687", "pos": "n, k = map(int, input().split(' '))\n\nans = int(n / k) ** 3\n\nif k % 2 == 0:\n cnt = 0\n for i in range(1, n + 1):\n if i % k == k / 2:\n cnt += 1\n ans += cnt ** 3\n\nprint(ans)", "neg": "n,k=map(int,input().split())\nans=0\nfor i in range(1,n//k+1):\n i*=k\n if i%2==0:\n i//=2\n ans+=(n//i)**3\nprint(ans)", "jacc_sim": 0.9310344827586207, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [82, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u305396672", "n_user": "u670180528", "pos": "n, k = map(int, input().split())\n\nif k % 2 == 0:\n m = n // k\n l = (n+(k//2))//k\n print(m**3+l**3)\nelse:\n m = n // k\n print(m**3)\n", "neg": "n,k=map(int,input().split())\nif k%2:\n print((n//k)**3)\nelse:\n l=k//2\n if l%2:\n print(((n+l)//k)**3)\n else:\n print(((n+l)//k)**3 + (n//k)**3)", "jacc_sim": 0.9166666666666666, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [73, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u872191059", "n_user": "u518064858", "pos": "n, k = map(int, input().split())\n\nif k % 2 == 0:\n x = n // k\n y = (2 * n // k) - x\n ans = x ** 3 + y ** 3\nelse:\n ans = (n // k) ** 3\n\nprint(ans)", "neg": "n,k=map(int,input().split())\nif k%2==0:\n x=(n+k/2)//k\n y=n//k\n print(x**3+y**3)\nelse:\n x=n//k\n print(x**3)\n", "jacc_sim": 0.9230769230769231, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [72, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u531768068", "n_user": "u531768068", "pos": "def getIntList():\n return list(map(int, input().split())) \n \nN, K = getIntList()\n \nres = 0\nc1 =0\nc2 =0\nif K %2 ==0:\n t = K//2\nelse:\n t= -1\n \nif True:\n for i in range(1,N+1):\n if i%K == t:\n c1+=1\n if i%K ==0:\n c2+=1\nres = c1 **3 + c2** 3\nprint(res)\n", "neg": "\ndef getIntList():\n return list(map(int, input().split())) \n\nN, K = getIntList()\n\nres = 0\nc1 ==0\nc2 ==0\nif K %2 ==0:\n t = K//2\nelse:\n t= -1\n\nif True:\n for i in range(1,N+1):\n if i%K == t:\n c1+=1\n if i%K ==0:\n c2+=1\nres = c1 **3 + c2** 3\nprint(res)", "jacc_sim": 1.0, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [139, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u467736898", "n_user": "u024340351", "pos": "N, K = map(int, input().split())\n\nif K%2 == 1:\n print((N//K)**3)\nelse:\n print((N//K)**3 + max(0, ((N+K//2)//K))**3)\n", "neg": "N, K = map(int, input().split())\n\nif K%2 == 1:\n\tprint((N//K)**3)\n \nelse:\n\tprint((N//(K/2)//2)**3+((N+(K/2))//(K/2)//2)**3)", "jacc_sim": 0.9166666666666666, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [64, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u729707098", "n_user": "u859897687", "pos": "n,k = (int(i) for i in input().split())\nans = (n//k)**3\nif k%2==0: ans += (((n-k//2)//k)+1)**3\nprint(ans)", "neg": "n,k=map(int,input().split())\nans=0\nfor i in range(1,n//k+1):\n i*=k\n if i%2==0:\n ans+=(n//(i//2)-n//i)**3\n ans+=(n//i)**3\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [56, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03268", "p_user": "u111421568", "n_user": "u623687794", "pos": "n, k = map(int, input().split())\n\nif k%2 == 1:\n a = n//k\n print(a**3)\nelse:\n a = n//k\n b = (n-(k//2))//k + 1\n print(a**3 + b**3)\n ", "neg": "n,k=map(int,input().split())\nif k%2==1:\n print((n//k)**3)\nelse:\n print((n//(k//2))**3+(n//k-n//(k//2))**3)", "jacc_sim": 0.92, "nl": "You are given two integers, N and K. Find the number of triples (a, b, c) of positive integers not greater than N such that a + b, b + c, and c + a are all multiples of K. The order of a, b, c matters, and some of them can be the same. The input is given in the format N K, and the output should be the number of such triples.", "before_after_length": [76, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03270", "p_user": "u968846084", "n_user": "u968846084", "pos": "def cmb(n,r):\n if n<0:\n return 0\n if n==0:\n if r!=0:\n return 0\n else:\n return 1\n elif r<0:\n return 0\n elif r>n:\n return 0\n elif r==0:\n return 1\n elif r==n:\n return 1\n else:\n return A[n]*B[r]*B[n-r]%mod\nmod=998244353\nA=[1,1]\nB=[1,1]\nfor i in range(2,4005):\n A.append(A[-1]*i%mod)\n B.append(B[-1]*pow(i,mod-2,mod)%mod)\nk,n=map(int,input().split())\nif k==1:\n print(0)\n exit()\nans=[0]*(2*k+1)\nfor i in range(2,k+3):#i,i+1(i%2=0,in:\n return 0\n elif r==0:\n return 1\n elif r==n:\n return 1\n else:\n return A[n]*B[r]*B[n-r]%mod\nmod=998244353\nA=[1,1]\nB=[1,1]\nfor i in range(2,4005):\n A.append(A[-1]*i%mod)\n B.append(B[-1]*pow(i,mod-2,mod))\nk,n=map(int,input().split())\nans=[0]*(2*k+1)\nfor i in range(2,k+3):#i,i+1(i%2=0,i= 0 and 0 <= b <= a): return 0\n return fa[a] * fainv[a-b] * fainv[b] % P\n\nA = []\nfor i in range(1, (K+1)//2+1):\n s = 0\n for j in range(i+1):\n s += C(N+K-1-2*j, K-1) * C(i, j) * (-1) ** j\n s %= P\n A.append(s)\nfor i in range(2*K-1):\n print(A[min(i//2, (2*K-i-2)//2)])", "neg": "K, N = map(int, input().split())\nP = 998244353\nfa = [1]\nfor i in range(1, 10000):\n fa.append(fa[-1] * i % P)\nfainv = [pow(fa[-1], P-2, P)]\nfor i in range(1, 10000)[::-1]:\n fainv.append(fainv[-1] * i % P)\nfainv = fainv[::-1]\n\ndef C(a, b):\n if not (a >= 0 and 0 <= b <= a): return 0\n return fa[a] * fainv[a-b] * fainv[b] % P\n\nA = []\nfor i in range(1, K-2):\n s = 0\n for j in range(i+1):\n s += C(N+K-1-2*j, K-1) * C(i, j) * (-1) ** j\n s %= P\n A.append(s)\nfor a in A:\n print(a)\n print(a)\nprint(A[-1])\nfor a in A[::-1][1:]:\n print(a)\n print(a)", "jacc_sim": 0.9583333333333334, "nl": "Takahashi throws N dice, each with K sides numbered from 1 to K. The dice are indistinguishable. For each i from 2 to 2K, find the value modulo 998244353, representing the number of combinations of N dice showing sides such that no two different sides sum to i. The dice are not distinguishable, meaning two combinations are different if the number of dice showing a particular side is different. Constraints: 1 \u2264 K \u2264 2000, 2 \u2264 N \u2264 2000, K and N are integers. Input format: K N. Output: Print 2K-1 integers, where the t-th integer (1 \u2264 t \u2264 2K-1) is the answer for i=t+1.", "before_after_length": [285, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03270", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\ninput = sys.stdin.readline\n\n# K+1 - x \u3067\u3046\u3064\u3059 -> i \u3068 2K+2-i \u306f\u540c\u3058\n\nMOD = 998244353\nU = 10000\nfact = [1] * (U+1)\nfact_inv = [1] * (U+1)\nfor n in range(1,U+1):\n fact[n] = fact[n-1] * n % MOD\nfact_inv[n] = pow(fact[n], MOD-2, MOD)\nfor n in range(U,0,-1):\n fact_inv[n-1] = fact_inv[n] * n % MOD\n\ndef comb(n,k):\n if not (0 <= k <= n):\n return 0\n return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD\n\nK,N = map(int,input().split())\n\ndef F(x,y,N):\n n = min(x, N)\n return sum(comb(x,i) * pow(2,i,MOD) * comb(N+y-1,i+y-1) for i in range(n+1)) % MOD\n\nanswer = []\nfor S in range(2,K+2):\n if S & 1:\n x = F((S-1)//2, K - S + 1, N)\n else:\n x = F((S-1)//2, K - S + 1, N) + F((S-1)//2, K - S + 1, N - 1)\n answer.append(x % MOD)\n\nanswer += answer[:-1][::-1]\n\nprint('\\n'.join(map(str,answer)))", "neg": "import sys\ninput = sys.stdin.readline\n\n# K+1 - x \u3067\u3046\u3064\u3059 -> i \u3068 2K+2-i \u306f\u540c\u3058\n\nMOD = 998244353\nU = 10000\nfact = [1] * (U+1)\nfact_inv = [1] * (U+1)\nfor n in range(1,U+1):\n fact[n] = fact[n-1] * n % MOD\nfact_inv[n] = pow(fact[n], MOD-2, MOD)\nfor n in range(U,0,-1):\n fact_inv[n-1] = fact_inv[n] * n % MOD\n\ndef comb(n,k):\n if not (0 <= k <= n):\n return 0\n return fact[n] * fact_inv[k] * fact_inv[n-k] % MOD\n\nK,N = map(int,input().split())\n\ndef F(x,y,N):\n n = min(x, N)\n return sum(comb(x,i) * pow(2,i,MOD) * comb(N+y-1,i+y-1) % MOD for i in range(n+1)) % MOD\n\nanswer = []\nfor S in range(3,K+3,2):\n x = F((S-1)//2, K - S + 1, N)\n answer.append(x)\n answer.append(x)\n\nif K & 2:\n answer = answer[:-1]\n answer += answer[:-1][::-1]\nelse:\n answer += answer[:-1][::-1] \n\nprint('\\n'.join(map(str,answer)))\n\n", "jacc_sim": 0.9861111111111112, "nl": "Takahashi throws N dice, each with K sides numbered from 1 to K. The dice are indistinguishable. For each i from 2 to 2K, find the value modulo 998244353, representing the number of combinations of N dice showing sides such that no two different sides sum to i. The dice are not distinguishable, meaning two combinations are different if the number of dice showing a particular side is different. Constraints: 1 \u2264 K \u2264 2000, 2 \u2264 N \u2264 2000, K and N are integers. Input format: K N. Output: Print 2K-1 integers, where the t-th integer (1 \u2264 t \u2264 2K-1) is the answer for i=t+1.", "before_after_length": [435, 428], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03270", "p_user": "u476199965", "n_user": "u476199965", "pos": "k,n = list(map(int,input().split()))\nmod = 998244353\nfact = [1]*(n+k+1)\nrfact = [1]*(n+k+1)\nfor i in range(1, n+k):\n fact[i] = r = (i * fact[i-1]) % mod\n rfact[i] = pow(r, mod-2, mod)\n\nsave = []\nfor p in range(1,int((k+3)/2)):\n i = 2 * p + 1\n temp = 0\n for t in range(min(p+1,n+1)):\n if k-i+t<0:continue\n res = (fact[p] * rfact[t] * rfact[p-t]) % mod\n res *= (fact[n+k-i] * rfact[k-i+t] * rfact[n-t]) % mod\n res *= pow(2,t,mod)\n temp = (temp+res) % mod\n save.append(temp)\noutput = []\ni = 1\nwhile i li + 1:\n i = (li + ri) // 2\n xi = x[i]\n cnt = [0] * n1\n cs = 0\n cnt[cs] = 1\n judge = 0\n s = 0\n for ak in a:\n if ak >= xi:\n cs += 1\n s += cnt[cs] + 1\n else:\n cs -= 1\n s -= cnt[cs + 1] - 1\n cnt[cs] += 1\n judge += s\n if judge >= n_sub_half:\n li = i\n break\n else:\n ri = i\n return x[li]\n\nn = int(input())\nar = [int(i) for i in input().strip().split(\" \")]\nprint(f(n,ar))\n\n\n\n", "neg": "\ndef f(n, a):\n x = sorted(set(a))\n n_sub_half = (n * (n + 1)) // 2 // 2\n n1 = n * 2 + 1\n li = 0\n ri = len(x)\n while ri > li + 1:\n i = (li + ri) // 2\n xi = x[i]\n cnt = [0] * n1\n cs = 0\n cnt[cs] = 1\n judge = 0\n s = 0\n for ak in a:\n if ak >= xi:\n cs += 1\n s += cnt[cs] + 1\n else:\n cs -= 1\n s -= cnt[cs + 1] - 1\n cnt[cs] += 1\n judge += s\n if judge >= n_sub_half:\n li = i\n break\n else:\n ri = i\n return x[ri]\n\nn = int(input())\nar = [int(i) for i in input().strip().split(\" \")]\nprint(f(n,ar))\n\n\n\n", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [263, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u426108351", "n_user": "u426108351", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nclass BIT():\n def __init__(self, n):\n self.size = n\n self.bit = [0] * (n+1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.bit[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.bit[i] += x\n i += i & -i\nok = 0\nng = 10**9+1\n\ndef inversion(a, bit):\n ans = 0\n for i, p in enumerate(b):\n bit.add(p, 1)\n ans += i+1 - bit.sum(p)\n return ans\n\nwhile ng - ok > 1:\n m = ok + (ng-ok)//2\n b = [0]\n for i in range(n):\n if a[i] >= m:\n b.append(b[i]+1)\n else:\n b.append(b[i]-1)\n b = [i+100001 for i in b]\n bit = BIT(200005)\n inversion = 0\n for i, p in enumerate(b):\n bit.add(p, 1)\n inversion += i+1 - bit.sum(p)\n\n if inversion <= n*(n+1)//4:\n ok = m\n else:\n ng = m\n\n\n\nprint(ok)\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nclass BIT():\n def __init__(self, n):\n self.size = n\n self.bit = [0] * (n+1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.bit[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.bit[i] += x\n i += i & -i\nok = 0\nng = 10**9+1\n\ndef inversion(a, bit):\n ans = 0\n for i, p in enumerate(b):\n bit.add(p, 1)\n ans += i+1 - bit.sum(p)\n return ans\n\nwhile ng - ok > 1:\n m = ok + (ng-ok)//2\n b = [0]\n for i in range(n):\n if a[i] >= m:\n b.append(b[i]+1)\n else:\n b.append(b[i]-1)\n b = [i+100001 for i in b]\n bit = BIT(200005)\n inversion = 0\n for i, p in enumerate(b):\n bit.add(p, 1)\n inversion += i+1 - bit.sum(p)\n\n if inversion < n**2//2+1:\n ok = m\n else:\n ng = m\n\n\nprint(ok)\n", "jacc_sim": 0.9830508474576272, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [389, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u543954314", "n_user": "u543954314", "pos": "class BIT:\n '''\n 0-indexed\n '''\n def __init__(self, N):\n self.size = N\n self.tree = [0] * (N + 1)\n self.depth = n.bit_length()\n\n def _bitsum(self, i):\n ret = 0\n while i:\n ret += self.tree[i]\n i ^= i & -i\n return ret\n\n def bitsum(self, l, r=None): # [l, r)\n if r is None:\n return self._bitsum(l)\n else:\n return self._bitsum(r) - self._bitsum(l)\n\n def bitadd(self, i, x):\n i += 1\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n return\n\nn = int(input())\nm = n * (n + 1) // 4\na = list(map(int, input().split()))\nd = dict()\n_a = sorted(set(a + [0]))\nfor i, x in enumerate(_a):\n d[x] = i\na = [d[x] for x in a]\n\n\ndef check(X):\n b = [0] + [(y>=X)*2 - 1 for y in a]\n for i in range(n):\n b[i+1] += b[i]\n c = min(b)\n b = [x-c for x in b] \n bit = BIT(max(b) + 2)\n ans = 0\n for x in b:\n ans += bit.bitsum(x + 1)\n bit.bitadd(x, 1)\n return ans >= m\n\nt = [len(_a), 0]\nwhile t[0] - t[1] > 1:\n mid = (t[0] + t[1]) // 2\n t[check(mid)] = mid\nprint(_a[t[1]])\n", "neg": "class BIT:\n '''\n 0-indexed\n '''\n def __init__(self, N):\n self.size = N\n self.tree = [0] * (N + 1)\n self.depth = n.bit_length()\n\n def _bitsum(self, i):\n ret = 0\n while i:\n ret += self.tree[i]\n i ^= i & -i\n return ret\n\n def bitsum(self, l, r=None): # [l, r)\n if r is None:\n return self._bitsum(l)\n else:\n return self._bitsum(r) - self._bitsum(l)\n\n def bitadd(self, i, x):\n i += 1\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n return\n\nn = int(input())\nm = (n * (n - 1) // 2) // 2\na = list(map(int, input().split()))\nd = dict()\n_a = sorted(set(a))\nfor i, x in enumerate(_a):\n d[x] = i\na = [d[x] for x in a]\n\n\ndef check(X):\n b = [0] + [(y>=X)*2 - 1 for y in a]\n for i in range(n):\n b[i+1] += b[i]\n c = min(b)\n b = [x-c for x in b] \n bit = BIT(n + 10)\n ans = 0\n for x in b:\n ans += bit.bitsum(x+1)\n bit.bitadd(x, 1)\n return ans >= m\n\nt = [len(_a) + 1, -1]\nwhile t[0] - t[1] > 1:\n mid = (t[0] + t[1]) // 2\n t[check(mid)] = mid\nprint(_a[t[1]])\n", "jacc_sim": 0.9615384615384616, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [485, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u905582793", "n_user": "u905582793", "pos": "from itertools import accumulate\nfrom collections import defaultdict\nclass Bit:\n def __init__(self,n):\n self.size = n\n self.tree = [0]*(n+1)\n \n def sum(self,i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self,i,x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\nn = int(input())\na = list(map(int,input().split()))\ndef jdg(x):\n b = [0 for i in range(n)]\n for i in range(n):\n if a[i] >= x:\n b[i] = 1\n else:\n b[i] = -1\n acc = [0]+list(accumulate(b))\n mn = min(acc)\n mx = max(acc)\n dif = mx-mn\n bit = Bit(dif+2)\n ret = 0\n for i in range(n+1):\n p = acc[i]-mn+1\n ret += bit.sum(p)\n bit.add(p,1)\n return ret\nl = 0\nr = max(a)+1\nwhile l+1 < r:\n x = (l+r)//2\n if jdg(x) >= (n+1)*n//4:\n l = x\n else:\n r = x\nprint(l)", "neg": "from itertools import accumulate\nfrom collections import defaultdict\nclass Bit:\n def __init__(self,n):\n self.size = n\n self.tree = [0]*(n+1)\n \n def sum(self,i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self,i,x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\nn = int(input())\na = list(map(int,input().split()))\ndef jdg(x):\n b = [0 for i in range(n)]\n for i in range(n):\n if a[i] >= x:\n b[i] = 1\n else:\n b[i] = -1\n acc = list(accumulate(b))\n mn = min(acc)\n mx = max(acc)\n dif = mx-mn\n bit = Bit(dif+2)\n ret = 0\n for i in range(n):\n p = acc[i]-mn+1\n ret += bit.sum(p)\n bit.add(p,1)\n return ret\nl = 0\nr = max(a)+1\nwhile l+1 (n-1)*n//4+1:\n l = x\n else:\n r = x-1\nprint(r)", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [376, 375], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u547167033", "n_user": "u547167033", "pos": "n=int(input())\na=list(map(int,input().split()))\nsortA=sorted(set(a))+[float('inf')]\ndef isOK(m):\n x=sortA[m]\n cnt=[0]*(2*n+1)\n cnt[n+1]=1\n i=n+1\n s=1\n res=0\n for b in a:\n if b>=x:\n i+=1\n s+=cnt[i]\n else:\n s-=cnt[i]\n i-=1\n res+=s\n cnt[i]+=1\n s+=1\n if res>=n*(n+1)//4:\n return False\n else:\n return True\nl,r=0,len(sortA)-1\nwhile r-l>1:\n mid=(r+l)//2\n if isOK(mid):\n r=mid\n else:\n l=mid\nprint(sortA[l])", "neg": "n=int(input())\na=list(map(int,input().split()))\nsortA=a+[float('inf')]\ndef isOK(m):\n x=sortA[m]\n cnt=[0]*(2*n+1)\n cnt[n+1]=1\n i=n+1\n s=1\n res=0\n for b in a:\n if b>=x:\n i+=1\n s+=cnt[i]\n else:\n s-=cnt[i]\n i-=1\n res+=s\n cnt[i]+=1\n s+=1\n if res>=n*(n+1)//4:\n return False\n else:\n return True\nl,r=0,len(sortA)-1\nwhile r-l>1:\n mid=(r+l)//2\n if isOK(mid):\n r=mid\n else:\n l=mid\nprint(sortA[l])", "jacc_sim": 0.9629629629629629, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [250, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u310678820", "n_user": "u310678820", "pos": "class BIT:\n def __init__(self, n):\n self.N = n\n self.n = 1< 0:\n s += self.data[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.n:\n self.data[i] += x\n i += i & -i\nN = int(input())\nA = list(map(int, input().split()))\nN0 = N*(N+1)//2\ndef C(x):\n B = BIT(N*2+1)\n s = [0]*(N+1)\n for i in range(N):\n a = A[i]\n s[i] = 1 if x1:\n mid = (ok+ng)//2\n if C(mid):#mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u304b\n ok = mid\n else:\n ng = mid\nprint(ok)\n\n \n\n ", "neg": "class BIT:\n def __init__(self, n):\n self.N = n\n self.n = 1< 0:\n s += self.data[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.n:\n self.data[i] += x\n i += i & -i\nN = int(input())\nA = list(map(int, input().split()))\nN0 = N*(N+1)//2\ndef C(x):\n B = BIT(N*2+1)\n s = [0]*(N+1)\n for i in range(N):\n a = A[i]\n s[i] = 1 if x1:\n mid = (ok+ng)//2\n if C(mid):#mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u304b\n ok = mid\n else:\n ng = mid\nprint(ok)\n\n \n\n ", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [397, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u803848678", "n_user": "u803848678", "pos": "from itertools import accumulate\n\nclass BIT_RSQ():\n def __init__(self, n):\n self.n = n\n self.data = [0]*(n+1)\n\n def add(self, i, v):\n while i <= self.n:\n self.data[i-1] += v\n i += i & -i\n\n def sum(self, i):\n ret = 0\n while(i > 0):\n ret += self.data[i-1]\n i -= i & -i\n return ret\n\nn = int(input())\na = list(map(int, input().split()))\n\ndef check(m):\n b = [[-1,1][i>=m] for i in a]\n bit = BIT_RSQ(2*n+1)\n s = [0] + list(accumulate(b))\n res = 0\n for i in range(n):\n bit.add(s[i]+n+1, 1)\n res += bit.sum(s[i+1]+n+1)\n return res >= (n*(n+1)//2+1)//2\n\nleft = 0\nright = 10**9+1\nwhile right-left > 1:\n mid = (right+left)//2\n if check(mid):\n left = mid\n else:\n right = mid\nprint(left)", "neg": "class BIT_RSQ():\n def __init__(self, n):\n self.n = n\n self.data = [0]*(n+1)\n\n def add(self, i, v):\n while i <= self.n:\n self.data[i-1] += v\n i += i & -i\n\n def sum(self, i):\n ret = 0\n while(i > 0):\n ret += self.data[i-1]\n i -= i & -i\n return ret\n\nn = int(input())\na = list(map(int, input().split()))\n\ndef check(m):\n b = [[-1,1][i>=m] for i in a]\n bit = BIT_RSQ(2*n+1)\n s = [0] + list(accumulate(b))\n res = 0\n for i in range(n):\n bit.add(s[i]+n+1, 1)\n res += bit.sum(s[i+1]+n+1)\n return res >= (n*(n+1)//2+1)//2\n\nleft = 0\nright = 10**9+1\nwhile right-left > 1:\n mid = (right+left)//2\n if check(mid):\n left = mid\n else:\n right = mid\nprint(left)", "jacc_sim": 0.9491525423728814, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [336, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u895515293", "n_user": "u895515293", "pos": "import math\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nget_ints = lambda: [int(st) for st in input().split()]\nN=int(input())\ninarr=get_ints()\n\nsorted_in = sorted(inarr)\n# print(sorted_in)\ncomb = N*(N+1) // 2\n\ndef binsearch(lft, rgt):\n half = (lft + rgt) // 2\n # print(\"investigate: lft {} rgt {} half {} value {}\".format(lft, rgt, half, sorted_in[half]))\n if lft >= half:\n return half\n summed = 0\n res = 0\n\n bit = Bit(2*N+1)\n bit.add(N, 1)\n for i, x in enumerate(inarr):\n value = 1 if x >= sorted_in[half] else -1\n summed += value\n # print(\"summed: {}, bit: {}\".format(summed, bit.sum(N + summed)))\n count = bit.sum(N + summed)\n bit.add(N + summed, 1)\n res += count\n\n # print(\"num {} cnt {} judge {}\".format(sorted_in[half], res, math.ceil(comb/2)))\n if res >= math.ceil(comb/2):\n return binsearch(half, rgt)\n else:\n return binsearch(lft, half)\n\n# print(sorted_in)\nres = binsearch(0, N)\n# print(res, sorted_in[res])\nprint(sorted_in[res])\n", "neg": "import math\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nget_ints = lambda: [int(st) for st in input().split()]\nN=int(input())\ninarr=get_ints()\n\nsorted_in = sorted(inarr)\ncomb = N * (N-1) // 2\n\ndef binsearch(lft, rgt):\n half = (lft + rgt) // 2\n # print(\"investigate: lft {} rgt {} value {}\".format(lft, rgt, sorted_in[half]))\n if lft >= half:\n return half\n summed = 0\n res = 0\n\n bit = Bit(2*N+1)\n for i, x in enumerate(inarr):\n value = -1 if x < sorted_in[half] else 1\n summed += value\n print(\"summed: {}, i - bit: {}, bit: {}\".format(summed, i - bit.sum(N + summed), bit.sum(N + summed)))\n count = i - bit.sum(N + summed)\n bit.add(N + summed, 1)\n res += count\n\n # print(res)\n if res < math.ceil(comb/2):\n return binsearch(half, rgt)\n else:\n return binsearch(lft, half)\n\n# print(sorted_in)\nres = binsearch(0, N)\n# print(res, sorted_in[res])\nprint(sorted_in[res])\n", "jacc_sim": 0.9577464788732394, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [498, 469], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u160244242", "n_user": "u160244242", "pos": "import math\n\nn = int(input())\nlst = list(map(int, input().split()))\n \nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n \n \ndef judge(x, lst, n):\n \n length = len(lst)\n all_pair = (length*(length-1) // 2) + length\n \n lst_r = [-1 if i < x else 1 for i in lst]\n lst_accum = []\n a = 0\n for i in lst_r:\n a += i\n lst_accum.append(a)\n \n bit = Bit(n)\n lst_accum_sorted = {b: i for i, b in enumerate(sorted(lst_accum), start=1)}\n count = 0\n for j, b in enumerate(lst_accum):\n count += bit.sum(lst_accum_sorted[b]) + (b >= 0)\n bit.add(lst_accum_sorted[b], 1)\n \n if count >= math.ceil(all_pair/2):\n return True\n else:\n return False\n \n \nsorted_lst = sorted(lst)\nlow = 0\nhigh = len(lst) - 1\nwhile high - low >1:\n t = (low+high) // 2\n i = sorted_lst[t]\n if judge(i, lst, n):\n low = t\n else:\n high = t\n \nprint(sorted_lst[high]) if judge(sorted_lst[high], lst, n) else print(sorted_lst[low])", "neg": "import math\n\nn = int(input())\nlst = list(map(int, input().split()))\n \nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n \n \ndef judge(x, lst, n):\n \n length = len(lst)\n all_pair = (length*(length-1) // 2) + length\n \n lst_r = [-1 if i < x else 1 for i in lst]\n lst_accum = []\n a = 0\n for i in lst_r:\n a += i\n lst_accum.append(a)\n \n bit = Bit(n)\n lst_accum_sorted = {b: i for i, b in enumerate(sorted(lst_accum), start=1)}\n count = 0\n for j, b in enumerate(lst_accum):\n count += bit.sum(lst_accum_sorted[b]) + (b >= 0)\n bit.add(lst_accum_sorted[b], 1)\n \n if count >= math.ceil(all_pair/2):\n return True\n else:\n return False\n \n \nsorted_lst = sorted(lst)\nlow = 0\nhigh = len(lst) - 1\nwhile high - low >1:\n t = (low+high) // 2\n i = sorted_lst[t]\n if judge(i, lst, n):\n low = t\n else:\n high = t\n \nprint(sorted_lst[low])", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [490, 467], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u955251526", "n_user": "u955251526", "pos": "class Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nn = int(input())\na = list(map(int, input().split()))\ndef med(x):\n cum = [0] * (n+1)\n for i in range(n):\n if a[i] >= x:\n cum[i+1] = cum[i] + 1\n else:\n cum[i+1] = cum[i] - 1\n m = min(cum)\n for i in range(n+1):\n cum[i] -= m - 1\n zb = Bit(max(cum))\n ret = 0\n for j in range(n+1):\n ret += zb.sum(cum[j])\n zb.add(cum[j], 1)\n return ret\nb = sorted(a)\nl = 0\nr = n\nwhile(r - l > 1):\n mid = (l + r + 1) // 2\n if 2 * med(b[mid]) >= n * (n+1) // 2:\n l = mid\n else:\n r = mid\nprint(b[l])\n", "neg": "class Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nn = int(input())\na = list(map(int, input().split()))\ndef med(x):\n cum = [0] * (n+1)\n for i in range(n):\n if a[i] >= x:\n cum[i+1] = cum[i] + 1\n else:\n cum[i+1] = cum[i] - 1\n m = min(cum)\n for i in range(n+1):\n cum[i] -= m - 1\n zb = Bit(max(cum))\n ret = 0\n for j in range(n+1):\n ret += zb.sum(cum[j])\n zb.add(cum[j], 1)\n return ret\nb = sorted(a)\nl = 0\nr = n\nwhile(r - l > 1):\n mid = (l + r + 1) // 2\n print(l,mid,r)\n if 2 * med(b[mid]) >= n * (n+1) // 2:\n l = mid\n else:\n r = mid\nprint(b[l])\n", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [377, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u824237520", "n_user": "u824237520", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nif n == 1:\n print(a[0])\n exit()\n\nb = list(sorted(set(a)))\n\ndef count_inversion(ans):\n s = [0 for _ in range(2 * n + 2) ]\n\n def bit_add(i):\n x = i\n while x < 2 * n:\n s[x] += 1\n x += x & -x\n\n def bit_sum(i):\n x = i\n ret = 0\n while x > 0:\n ret += s[x]\n x -= x & -x\n return ret\n\n temp = [n for _ in range(n + 1)]\n temp[0] = n + 1\n for i in range(n):\n if a[i] >= b[ans]:\n temp[i + 1] = temp[i] + 1\n else:\n temp[i + 1] = temp[i] - 1\n res = 0\n for i in range(n + 1):\n x = temp[i]\n res += bit_sum(x)\n bit_add(x)\n return res\n\nm = n * (n + 1) // 2\n\nans = 0\n\nl = 0\nr = len(b)\nwhile 1:\n ans = (l + r) // 2\n if count_inversion(ans) * 2 >= m:\n l = ans\n else:\n r = ans\n if r - l <= 1:\n ans = l\n break\n\nprint(b[ans])\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nb = list(sorted(set(a)))\n\ndef count_inversion(ans):\n s = [0 for _ in range(2 * n)]\n\n def bit_add(i):\n x = i\n while x < 2 * n:\n s[x] += 1\n x += x & -x\n\n def bit_sum(i):\n x = i\n ret = 0\n while x > 0:\n ret += s[x]\n x -= x & -x\n return ret\n\n temp = [n for _ in range(n + 1)]\n temp[0] = n + 1\n for i in range(n):\n if a[i] >= b[ans]:\n temp[i + 1] = temp[i] + 1\n else:\n temp[i + 1] = temp[i] - 1\n res = 0\n for i in range(n + 1):\n x = temp[i]\n res += bit_sum(x)\n bit_add(x)\n return res\n\nm = n * (n + 1) // 2\n\nans = 0\n\nl = 0\nr = len(b)\nwhile 1:\n ans = (l + r) // 2\n if count_inversion(ans) * 2 >= m:\n l = ans\n else:\n r = ans\n if r - l <= 1:\n ans = l\n break\n\nprint(b[ans])\n", "jacc_sim": 0.9814814814814815, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [393, 371], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u614550445", "n_user": "u614550445", "pos": "N = int(input())\nA = [int(_) for _ in input().split()]\n\n\nclass BIT:\n # index 1~\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n\nM = N * (N + 1) // 2 # (N+1)C2\nsorted_A = sorted(A)\n\ninf = 0\nsup = max(A) + 1\nwhile sup - inf > 1:\n x = (sup + inf) // 2\n\n S = [0] * (N + 1)\n for i in range(N):\n if A[i] >= x:\n S[i + 1] = S[i] + 1\n else:\n S[i + 1] = S[i] - 1\n\n min_value = min(S)\n for i in range(N + 1):\n S[i] += abs(min_value) + 1\n\n forward = 0\n bit = BIT(max(S))\n for s in S:\n forward += bit.sum(s)\n bit.add(s, 1)\n\n if forward >= (M + 1) // 2:\n inf = x\n else:\n sup = x\n\nfor a in reversed(sorted_A):\n if inf >= a:\n print(a)\n break\n", "neg": "N = int(input())\nA = [int(_) for _ in input().split()]\n\n\nclass BIT:\n # index 1~\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n\nM = N * (N + 1) // 2 # (N+1)C2\nsorted_A = sorted(A)\n\nprint(M)\ninf = 0\nsup = max(A) + 1\nwhile sup - inf > 1:\n x = (sup + inf) // 2\n print(inf, sup, x)\n\n S = [0] * (N + 1)\n for i in range(N):\n if A[i] >= x:\n S[i + 1] = S[i] + 1\n else:\n S[i + 1] = S[i] - 1\n\n print([1 if a >= x else -1 for a in A])\n\n min_value = min(S)\n for i in range(N + 1):\n S[i] += abs(min_value) + 1\n\n print(S)\n forward = 0\n bit = BIT(max(S))\n for s in S:\n forward += bit.sum(s)\n bit.add(s, 1)\n print(s, bit.tree, bit.sum(s), forward)\n\n if forward >= (M + 1) // 2:\n inf = x\n else:\n sup = x\n\nfor a in reversed(sorted_A):\n if inf >= a:\n print(a)\n break\n", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [417, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03275", "p_user": "u761320129", "n_user": "u761320129", "pos": "N = int(input())\nsrc = list(map(int,input().split()))\n\ncands = list(sorted(set(src)))\n\ndef enough(i):\n bit = [0] * (2*N+10)\n def bit_add(a,w):\n x = a\n while x <= (2*N+9):\n bit[x] += w\n x += (x & -x)\n def bit_sum(a):\n x = a\n ret = 0\n while x > 0:\n ret += bit[x]\n x -= (x & -x)\n return ret\n\n cums = [0]\n for a in src:\n tmp = 1 if a >= cands[i] else -1\n cums.append(cums[-1] + tmp)\n\n cnt = 0\n for i in range(N+1):\n a = cums[i] + N+5\n cnt += bit_sum(a)\n bit_add(a, 1)\n return cnt*2 >= N*(N+1)//2\n\nok = 0\nng = len(cands)\nwhile ng - ok > 1:\n m = (ok+ng)//2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(cands[ok])", "neg": "N = int(input())\nsrc = list(map(int,input().split()))\n\ncands = list(sorted(set(src)))\n\ndef enough(i):\n bit = [0] * (2*N+10)\n def bit_add(a,w):\n x = a\n while x <= (2*N+9):\n bit[x] += w\n x += (x & -x)\n def bit_sum(a):\n x = a\n ret = 0\n while x > 0:\n ret += bit[x]\n x -= (x & -x)\n return ret\n\n cums = [0]\n for a in src:\n tmp = 1 if a >= cands(i) else -1\n cums.append(cums[-1] + tmp)\n\n cnt = 0\n for i in range(N+1):\n a = cums[i] + N+5\n cnt += bit_sum(a)\n bit_add(a, 1)\n return cnt*2 >= N*(N+1)//2\n\nok = 0\nng = len(cands)\nwhile ng - ok > 1:\n m = (ok+ng)//2\n if enough(m):\n ok = m\n else:\n ng = m\nprint(ok)", "jacc_sim": 1.0, "nl": "You are given a sequence \"a\" of length N. For each pair (l, r) (1 \u2264 l \u2264 r \u2264 N), find the median of the contiguous subsequence (a_l, a_{l + 1}, ..., a_r) of \"a\". List the medians for all pairs (l, r) to create a new sequence \"m\". Then, find the median of \"m\". The input is given in the format: N, followed by the elements of the sequence \"a\". Print the median of \"m\".", "before_after_length": [322, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u923172145", "n_user": "u923172145", "pos": "S = input()\nlct_A = 0\nlct_q = 0\nrct_C = S.count(\"C\")\nrct_q = S.count(\"?\")\n\nMOD = 10**9 + 7\n\nans = 0\nfor s in S:\n if s == \"C\":\n rct_C -= 1\n elif s == \"?\":\n rct_q -= 1\n #print(s, lct_A, lct_q, rct_C, rct_q)\n \n if s == \"B\" or s == \"?\":\n ans += (lct_A * rct_C * pow(3, lct_q+rct_q, MOD)) % MOD\n if lct_q > 0:\n ans += (lct_q * rct_C * pow(3, lct_q+rct_q-1, MOD) ) % MOD\n if rct_q > 0:\n ans += (rct_q * lct_A * pow(3, lct_q+rct_q-1, MOD) ) % MOD\n if lct_q > 0 and rct_q > 0:\n ans += (lct_q * rct_q * pow(3, lct_q+rct_q-2, MOD) ) % MOD \n ans %= MOD\n #print(\" \", ans)\n \n if s == \"A\":\n lct_A += 1\n elif s == \"?\":\n lct_q += 1\n \nprint(ans % MOD)", "neg": "S = input()\nlct_A = 0\nlct_q = 0\nrct_C = S.count(\"C\")\nrct_q = S.count(\"?\")\n\nMOD = 10**9 + 7\n\nans = 0\nfor s in S:\n if s == \"C\":\n rct_C -= 1\n elif s == \"?\":\n rct_q -= 1\n \n if s == \"B\" or s == \"?\":\n ans += (lct_A * rct_C * pow(3, lct_q+rct_q, MOD)) % MOD\n if lct_q > 0:\n ans += (lct_q * rct_C * pow(3, lct_q+rct_q-1, MOD) ) % MOD\n if lct_q > 0:\n ans += (rct_q * lct_A * pow(3, lct_q+rct_q-1, MOD) ) % MOD\n if lct_q > 0 and rct_q > 0:\n ans += (lct_q * rct_q * pow(3, lct_q+rct_q-2, MOD) ) % MOD \n ans %= MOD\n \n if s == \"A\":\n lct_A += 1\n elif s == \"?\":\n lct_q += 1\n \nprint(ans % MOD)", "jacc_sim": 0.9761904761904762, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [368, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u562935282", "n_user": "u562935282", "pos": "def main():\n MOD = 10 ** 9 + 7\n\n s = input()\n n = len(s)\n\n acc_a = [0] * (n + 1)\n acc_c = [0] * (n + 1)\n acc_q = [0] * (n + 1)\n\n a = 0\n c = 0\n q = 0\n for i, char in enumerate(s, 1):\n if char == 'A':\n a += 1\n elif char == 'C':\n c += 1\n elif char == '?':\n q += 1\n acc_a[i] = a\n acc_c[i] = c\n acc_q[i] = q\n\n sq = [1]\n for _ in range(acc_q[n]):\n sq.append(sq[-1] * 3 % MOD)\n\n ans = 0\n qn = acc_q[n]\n for i, char in enumerate(s, 1):\n if char == 'B' or char == '?':\n is_q = int(char == '?')\n rq = acc_q[n] - acc_q[i]\n rc = acc_c[n] - acc_c[i]\n t = 0\n if qn - is_q >= 0:\n t += acc_a[i - 1] * rc * sq[acc_q[n] - is_q]\n if qn - 1 - is_q >= 0:\n t += acc_a[i - 1] * rq * sq[acc_q[n] - 1 - is_q]\n t += acc_q[i - 1] * rc * sq[acc_q[n] - 1 - is_q]\n if qn - 2 - is_q >= 0:\n t += acc_q[i - 1] * rq * sq[acc_q[n] - 2 - is_q]\n t %= MOD\n ans = (ans + t) % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n MOD = 10 ** 9 + 7\n\n s = input()\n n = len(s)\n\n acc_a = [0] * (n + 1)\n acc_c = [0] * (n + 1)\n acc_q = [0] * (n + 1)\n\n a = 0\n c = 0\n q = 0\n for i, char in enumerate(s, 1):\n if char == 'A':\n a += 1\n elif char == 'C':\n c += 1\n elif char == '?':\n q += 1\n acc_a[i] = a\n acc_c[i] = c\n acc_q[i] = q\n\n sq = [1]\n for _ in range(acc_q[n]):\n sq.append(sq[-1] * 3 % MOD)\n\n ans = 0\n for i, char in enumerate(s, 1):\n if char == 'B' or char == '?':\n is_q = int(char == '?')\n rq = acc_q[n] - acc_q[i]\n rc = acc_c[n] - acc_c[i]\n t = (acc_a[i - 1] * (\n rc * sq[acc_q[n] - is_q]\n + rq * sq[acc_q[n] - 1 - is_q]\n ) + acc_q[i - 1] * (\n rc * sq[acc_q[n] - 1 - is_q]\n + rq * sq[acc_q[n] - 2 - is_q]\n )) % MOD\n ans = (ans + t) % MOD\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9666666666666667, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [494, 429], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u678167152", "n_user": "u678167152", "pos": "S = input()\n\ndef solve(S):\n mod = 10**9+7\n N = len(S)\n Aquest = []\n Cquest = []\n cntA,cntquest = 0,0\n for i in range(N):\n if S[i] in 'B?':\n Aquest.append([cntA,cntquest])\n if S[i]=='A':\n cntA += 1\n if S[i]=='?':\n cntquest += 1\n cntC,cntquest = 0,0\n for i in range(N-1,-1,-1):\n if S[i] in 'B?':\n Cquest.append([cntC,cntquest])\n if S[i]=='C':\n cntC += 1\n if S[i]=='?':\n cntquest += 1\n Cquest = Cquest[::-1]\n ans = 0\n for aquest,cquest in zip(Aquest,Cquest):\n a = aquest[0]*pow(3,aquest[1],mod)\n if aquest[1]>0:\n a += aquest[1]*pow(3,aquest[1]-1,mod)\n c = cquest[0]*pow(3,cquest[1],mod)\n if cquest[1]>0:\n c += cquest[1]*pow(3,cquest[1]-1,mod)\n ans += a*c%mod\n ans %= mod\n return ans\nprint(solve(S))", "neg": "S = input()\n\ndef solve(S):\n mod = 10**9+7\n N = len(S)\n Aquest = []\n Cquest = []\n cntA,cntquest = 0,0\n for i in range(N):\n if S[i] in 'B?':\n Aquest.append([cntA,cntquest])\n if S[i]=='A':\n cntA += 1\n if S[i]=='?':\n cntquest += 1\n cntC,cntquest = 0,0\n for i in range(N-1,-1,-1):\n if S[i] in 'B?':\n Cquest.append([cntC,cntquest])\n if S[i]=='C':\n cntC += 1\n if S[i]=='?':\n cntquest += 1\n Cquest = Cquest[::-1]\n ans = 0\n for aquest,cquest in zip(Aquest,Cquest):\n a = 0\n for i in range(aquest[1]+1):\n a += (aquest[0]+i)*pow(2,aquest[1]-i,mod)\n c = 0\n for i in range(cquest[1]+1):\n c += (cquest[0]+i)*pow(2,cquest[1]-i,mod)\n ans += a*c%mod\n return ans%mod\nprint(solve(S))", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [369, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u679759899", "n_user": "u679759899", "pos": "MOD = 10 **9 + 7\ns = input()\n\nn = len(s)\no = [1] * (n+1)\na = [0] * (n+1)\nb = [0] * (n+1)\nc = [0] * (n+1)\n\nfor i in range(n):\n if s[i] == '?':\n o[i+1] = o[i] * 3\n a[i+1] = a[i] * 3 + o[i]\n b[i+1] = b[i] * 3 + a[i]\n c[i+1] = c[i] * 3 + b[i]\n else:\n o[i+1] = o[i]\n a[i+1] = a[i]\n b[i+1] = b[i]\n c[i+1] = c[i]\n if s[i] == 'A':\n a[i+1] += o[i]\n if s[i] == 'B':\n b[i+1] += a[i]\n if s[i] == 'C':\n c[i+1] += b[i]\n o[i+1] = o[i+1] % MOD\n a[i+1] = a[i+1] % MOD\n b[i+1] = b[i+1] % MOD\n c[i+1] = c[i+1] % MOD\nprint(c[n])", "neg": "MOD = 10 **9 + 7\ns = input()\n\nn = len(s)\na = [0] * (n+1)\nb = [0] * (n+1)\nc = [0] * (n+1)\n\nfor i in range(n):\n if s[i] == '?':\n a[i+1] = a[i] * 3 + 1\n b[i+1] = b[i] * 3 + a[i]\n c[i+1] = c[i] * 3 + b[i]\n else:\n a[i+1] = a[i]\n b[i+1] = b[i]\n c[i+1] = c[i]\n if s[i] == 'A':\n a[i+1] += 1\n if s[i] == 'B':\n b[i+1] += a[i]\n if s[i] == 'C':\n c[i+1] += b[i]\n a[i+1] = a[i+1] % MOD\n b[i+1] = b[i+1] % MOD\n c[i+1] = c[i+1] % MOD\nprint(c[n])", "jacc_sim": 0.9722222222222222, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [365, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u057109575", "n_user": "u057109575", "pos": "S = input()\n\nMOD = 10 ** 9 + 7\nN = len(S)\ndp = [[0] * 4 for _ in range(N + 1)]\ndp[-1][-1] = 1\n\nfor i in reversed(range(N)):\n m = 3 if S[i] == '?' else 1\n for j in reversed(range(3)):\n dp[i][j] = m * dp[i + 1][j]\n if S[i] == '?' or S[i] == 'ABC'[j]:\n dp[i][j] += dp[i + 1][j + 1]\n dp[i][j] %= MOD\n \n # j == 3\n dp[i][3] = m * dp[i + 1][3] % MOD\n \nprint(dp[0][0] % MOD)\n\n", "neg": "S = input()\n\nMOD = 10 ** 9 + 7\nN = len(S)\ndp = [[0] * 4 for _ in range(N + 1)]\ndp[-1][-1] = 1\n\nfor i in reversed(range(N)):\n m = 3 if S[i] == '?' else 1\n for j in reversed(range(3)):\n dp[i][j] = m * dp[i + 1][j]\n if S[i] == '?' or S[i] == 'ABC'[j]:\n dp[i][j] += m2 * dp[i + 1][j + 1]\n dp[i][j] %= MOD\n \n # j == 3\n dp[i][3] = m * dp[i + 1][3] % MOD\n \nprint(dp[0][0] % MOD)\n\n", "jacc_sim": 0.975, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [199, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u391731808", "n_user": "u391731808", "pos": "S=input()\nN = len(S)\nA = [0]*N\nC = [0]*N\nL = [0]*N\nR = [0]*N\nfor i in range(1,N):\n A[i] = A[i-1] + (S[i-1] == \"A\")\n L[i] = L[i-1] + (S[i-1] == \"?\")\n C[N-1-i] = C[N-i] + (S[N-i] == \"C\")\n R[N-1-i] = R[N-i] + (S[N-i] == \"?\")\nmod = 10**9+7\nd={0:1}\ndef pow_mod(x,n):\n if d.get(n,False) :return d[n]\n if n<0: return pow_mod(x,mod-1+n)\n if n%2 :\n d[n] = (x*pow_mod(x,n-1))%mod\n else:\n d[n] = (pow_mod(x,n//2)**2)%mod\n return d[n]\nans = 0\nfor i in range(1,N-1):\n if S[i] in \"B?\":\n ans += (3*A[i]+L[i])*(3*C[i]+R[i])*pow_mod(3,L[i]+R[i]-2)\n ans %= mod\nprint(ans)", "neg": "S=input()\nN = len(S)\nA = [0]*N\nC = [0]*N\nL = [0]*N\nR = [0]*N\nfor i in range(1,N):\n A[i] = A[i-1] + (S[i-1] == \"A\")\n L[i] = L[i-1] + (S[i-1] == \"?\")\n C[N-1-i] = C[N-i] + (S[N-i] == \"C\")\n R[N-1-i] = R[N-i] + (S[N-i] == \"?\")\nmod = 10**9+7\nd={0:1}\ndef pow_mod(x,n):\n if d.get(n,False) :return d[n]\n if n%2 :\n d[n] = (x*pow_mod(x,n-1))%mod\n else:\n d[n] = (pow_mod(x,n//2)**2)%mod\n return d[n]\nans = 0\nfor i in range(1,N-1):\n if S[i] in \"B?\":\n ans += (3*A[i]+L[i])*(3*C[i]+R[i])*pow_mod(3,L[i]+R[i])//9\n ans %= mod\nprint(ans)", "jacc_sim": 0.9803921568627451, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [363, 342], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u123756661", "n_user": "u123756661", "pos": "mod=1000000007\n\ns=input()\nx=len(s)\ndp=[[0 for i in range(4)] for j in range(100005)]\nfor i in range(x,-1,-1):\n for j in range(3,-1,-1):\n if i==x:\n dp[i][j]=[0,1][j==3]\n else:\n dp[i][j]=dp[i+1][j]*([1,3][s[i]==\"?\"])\n if (j<3 and (s[i]==\"?\" or s[i]==\"ABC\"[j])):\n dp[i][j]+=dp[i+1][j+1]\n dp[i][j]%=mod\nprint(dp[0][0])", "neg": "s=input()\nx=len(s)\ndp=[[0 for i in range(4)] for j in range(100005)]\nfor i in range(x,-1,-1):\n for j in range(3,-1,-1):\n if i==x:\n dp[i][j]=[0,1][j==3]\n else:\n dp[i][j]=dp[i+1][j]*([1,3][s[i]==\"?\"])\n if (j<3 and (s[i]==\"?\" or s[i]==\"ABC\"[j])):\n dp[i][j]+=dp[i+1][j+1]\n dp[i][j]%=mod\nprint(dp[0][0])", "jacc_sim": 0.972972972972973, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [190, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u190405389", "n_user": "u190405389", "pos": "s = input()\n\nans = 0\n\nrc = [0]\nrq = [0]\nla = [0]\nlq = [0]\nq3 = [1]\nt = 10**9+7\n\nfor i in range(len(s)-1):\n if s[len(s)-i-1]=='C':\n rc.append(rc[-1]+1)\n rq.append(rq[-1])\n elif s[len(s)-i-1]=='?':\n rc.append(rc[-1])\n rq.append(rq[-1]+1)\n else:\n rc.append(rc[-1])\n rq.append(rq[-1])\n if s[i]=='A':\n la.append(la[-1]+1)\n lq.append(lq[-1])\n elif s[i]=='?':\n la.append(la[-1])\n lq.append(lq[-1]+1)\n else:\n la.append(la[-1])\n lq.append(lq[-1])\n q3.append(q3[-1] * 3 % t)\nrc.reverse()\nrq.reverse()\n\nq3.append(1/3)\n\nfor i in range(len(s)):\n if s[i]=='B' or s[i]=='?':\n l = q3[lq[i]-1]\n r = q3[rq[i]-1]\n ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t\n\nprint(round(ans%t))\n", "neg": "s = input()\n\nans = 0\n\nrc = [0]\nrq = [0]\nla = [0]\nlq = [0]\nq3 = [1]\nt = 10**9+7\n\nfor i in range(len(s)-1):\n if s[len(s)-i-1]=='C':\n rc.append(rc[-1]+1)\n rq.append(rq[-1])\n elif s[len(s)-i-1]=='?':\n rc.append(rc[-1])\n rq.append(rq[-1]+1)\n else:\n rc.append(rc[-1])\n rq.append(rq[-1])\n if s[i]=='A':\n la.append(la[-1]+1)\n lq.append(lq[-1])\n elif s[i]=='?':\n la.append(la[-1])\n lq.append(lq[-1]+1)\n else:\n la.append(la[-1])\n lq.append(lq[-1])\n q3.append(q3[-1] * 3 % t)\nrc.reverse()\nrq.reverse()\n\nfor i in range(len(s)):\n if s[i]=='B' or s[i]=='?':\n l = q3[lq[i]-1]\n r = q3[rq[i]-1]\n ans += l*r*(3*la[i]+lq[i])*(3*rc[i]+rq[i]) % t\n\nprint(int(ans%t))\n", "jacc_sim": 0.9375, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [404, 393], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u873927631", "n_user": "u873927631", "pos": "#!/usr/bin/env python3\nimport sys\n\nMOD = 1000000007 # type: int\n\n\ndef solve(S: str):\n dp = [[0 for j in range(4)] for i in range(len(S) + 1)]\n STR = \"XABC\"\n dp[0][0] = 1\n for i in range(len(S)):\n c = S[i]\n for j in range(4):\n next = dp[i][j]\n if c == \"?\":\n next *= 3\n if j > 0:\n next += dp[i][j-1]\n if STR[j] == c: # \u9078\u3093\u3060\u6587\u5b57\u5217\u304c\u6b21\u9078\u3076\u3079\u304d\u6587\u5b57\u5217\u3060\u3063\u305f\u3089\n next += dp[i][j-1]\n dp[i+1][j] = next % MOD\n # print(dp)\n print(dp[len(S)][3])\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n S = next(tokens) # type: str\n solve(S)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\n\nMOD = 1000000007 # type: int\n\n\ndef solve(S: str):\n dp = [[0 for j in range(4)] for i in range(len(S) + 1)]\n STR = \"XABC\"\n dp[0][0] = 1\n for i in range(len(S)):\n c = S[i]\n for j in range(4):\n next = dp[i][j]\n if c == \"?\":\n next *= 3\n next += dp[i][j-1]\n if STR[j] == c: # \u9078\u3093\u3060\u6587\u5b57\u5217\u304c\u6b21\u9078\u3076\u3079\u304d\u6587\u5b57\u5217\u3060\u3063\u305f\u3089\n next += dp[i][j-1]\n dp[i+1][j] = next % MOD\n # print(dp)\n print(dp[len(S)][3])\n return\n\n\n# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n S = next(tokens) # type: str\n solve(S)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9893617021276596, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [396, 389], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u947883560", "n_user": "u947883560", "pos": "#!/usr/bin/env python3\nimport sys\nimport itertools\nimport collections\nimport functools\nimport math\nfrom queue import Queue\nINF = float(\"inf\")\n\nMOD = 1000000007 # type: int\n\nd = {}\n\n\ndef thpow(q):\n if q < 0:\n return 0\n if q == 0:\n return 1\n if q in d:\n return d[q]\n else:\n d[q] = (3*thpow(q-1)) % MOD\n return d[q]\n\n\ndef solve(S: str):\n dp = [0, 0, 0]\n q = 0\n for ch in S:\n a, b, c = dp\n if ch == \"A\":\n dp = [(a+thpow(q)) % MOD, b, c]\n elif ch == \"B\":\n dp = [a, (b+a) % MOD, c]\n elif ch == \"C\":\n dp = [a, b, (c+b) % MOD]\n elif ch == \"?\":\n dp = [((a*3 % MOD)+thpow(q)) % MOD,\n ((b*3) % MOD+a) % MOD,\n ((c*3)+b) % MOD]\n q += 1\n # print(dp)\n # print(dp)\n\n # print(d)\n print(dp[2])\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n S = next(tokens) # type: str\n solve(S)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\nimport itertools\nimport collections\nimport functools\nimport math\nfrom queue import Queue\nINF = float(\"inf\")\n\nMOD = 1000000007 # type: int\n\nd = {}\n\n\ndef thpow(q):\n if q < 0:\n return 0\n if q == 0:\n return 1\n if q in d:\n return d[q]\n else:\n d[q] = (3*thpow(q-1)) % MOD\n return d[q]\n\n\ndef solve(S: str):\n dp = [0, 0, 0]\n q = 0\n for ch in S:\n # print(dp)\n a, b, c = dp\n if ch == \"A\":\n dp = [a+1, b, c]\n elif ch == \"B\":\n dp = [a, b+a, c]\n elif ch == \"C\":\n dp = [a, b, c+b]\n elif ch == \"?\":\n dp = [((a*3 % MOD)+thpow(q)) % MOD,\n ((b*3) % MOD+a) % MOD,\n ((c*3) % MOD+b) % MOD]\n q += 1\n # print(dp)\n print(dp[-1])\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n S = next(tokens) # type: str\n solve(S)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.987012987012987, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [421, 401], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u977389981", "n_user": "u977389981", "pos": "mod = 10 ** 9 + 7\nS = input()\ndp = [[0] * 4 for i in range(len(S) + 1)]\n\ndp[0][0] = 1\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i + 1][j] = dp[i][j] * 3 % mod\n else:\n dp[i + 1][j] = dp[i][j]\n \n if S[i] == 'A' or S[i] == '?':\n dp[i + 1][1] += dp[i][0]\n if S[i] == 'B' or S[i] == '?':\n dp[i + 1][2] += dp[i][1]\n if S[i] == 'C' or S[i] == '?':\n dp[i + 1][3] += dp[i][2]\n \nprint(dp[len(S)][3] % mod)", "neg": "mod = 10 ** 9 + 7\nS = input()\ndp = [[0] * 4 for i in range(len(S) + 1)]\n\ndp[0][0] = 1\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i + 1][j] = dp[i][j] * 3 % mod\n else:\n dp[i + 1][j] = dp[i][j]\n \n if S[i] == 'A' or S[i] == '?':\n dp[i + 1][1] += dp[i][0]\n if S[i] == 'B' or S[i] == '?':\n dp[i + 1][2] += dp[i][1]\n if S[i] == 'C' or S[i] == '?':\n dp[i + 1][3] += dp[i][2]\n \nprint(dp[len(S)][3])", "jacc_sim": 1.0, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [241, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u442581202", "n_user": "u442581202", "pos": "s = input()\n\nA = [1,0]\nAB = 0\nABC = 0\nD = 10**9 + 7\nfor c in s:\n if c == 'A':\n A[1] += A[0]\n elif c == 'B':\n AB += A[1]\n elif c == 'C':\n ABC += AB\n elif c == '?':\n ABC = (((ABC%D) *3)%D + (AB)%D)%D\n AB = (((AB%D) *3)%D + (A[1])%D)%D\n A[1] = (((A[1]%D)*3)%D + A[0]%D)%D\n A[0] = ((A[0]%D) * 3)%D\n\nprint(ABC%D) \n", "neg": "s = input()\n\nA = [1,0]\nAB = 0\nABC = 0\nD = 10**9 + 7\nfor c in s:\n if c == 'A':\n A[1] += A[0]\n elif c == 'B':\n AB += A[1]\n elif c == 'C':\n ABC += AB\n elif c == '?':\n ABC = ABC*3 + AB\n AB *= 3#AB + C and AB + B and AB + C\n AB += A[1] # AB + B\n A[1] = A[1]*3 + A[0]\n A[0] *= 3\n print(c+\" \" + str(A)+\" \" + str(AB) + \" \" + str(ABC))\n\nprint(ABC%D) \n", "jacc_sim": 0.9142857142857143, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [199, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u316386814", "n_user": "u316386814", "pos": "S = input()\nN = len(S)\nMOD = 10 ** 9 + 7\n\ndp = [0, 0, 0, 0]\ndp[0] = 1\n\nfor s in S:\n factor = 3 if s == '?' else 1\n for j, c in zip([2, 1, 0], 'CBA'):\n dp[j + 1] = dp[j + 1] * factor % MOD\n if s == c or s == '?':\n dp[j + 1] += dp[j]\n if s == '?':\n dp[0] = (dp[0] * 3) % MOD\n\nans = dp[-1] % MOD\n\nprint(ans)", "neg": "S = input()\nN = len(S)\nMOD = 10 ** 9 + 7\n\ndp = [0, 0, 0, 0]\ndp[0] = 1\n\nfor s in S:\n factor = 3 if s == '?' else 1\n for j, c in zip([2, 1, 0], 'CBA'):\n dp[j + 1] = dp[j + 1] * factor % MODE\n if s == c or s == '?':\n dp[j + 1] += dp[j]\n if s == '?':\n dp[0] = dp[0] % MOD\n\nans = dp[-1] % MOD\n\nprint(ans)", "jacc_sim": 0.975, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [160, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u319818856", "n_user": "u319818856", "pos": "def we_love_abc(S: str)->int:\n ABC = 'ABC'\n MOD = 1000000007\n\n dp = [0, 0, 0, 0]\n dp[3] = 1\n\n for c in reversed(S):\n for j in range(3):\n m1 = 3 if c == '?' else 1\n m2 = 1 if c == '?' or c == ABC[j] else 0\n dp[j] = (m1 * dp[j] + m2 * dp[j+1]) % MOD\n dp[3] = (3 if c == '?' else 1) * dp[3]\n dp[3] %= MOD\n\n return dp[0] % MOD\n\n\nif __name__ == \"__main__\":\n S = input()\n ans = we_love_abc(S)\n print(ans)\n", "neg": "def we_love_abc(S: str)->int:\n ABC = 'ABC'\n\n dp = [0, 0, 0, 0]\n dp[3] = 1\n\n for c in reversed(S):\n if c == '?':\n m, m1, m2 = 3, 3, 1\n else:\n m, m1, m2 = 1, 1, 0\n for j in range(3):\n # m1 = 3 if c == '?' else 1\n # m2 = 1 if c == '?' or c == ABC[j] else 0\n if m2 == 0 and c == ABC[j]:\n m2 = 1\n dp[j] = m1 * dp[j] + m2 * dp[j+1]\n dp[3] = (3 if c == '?' else 1) * dp[3]\n\n return dp[0] % 1000000007\n\n\nif __name__ == \"__main__\":\n S = input()\n ans = we_love_abc(S)\n print(ans)\n", "jacc_sim": 0.9130434782608695, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [205, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u652150585", "n_user": "u652150585", "pos": "s=input()\ntable=[[0 for _ in range(4)] for _ in range(len(s)+1)]\ntable[0][0]=1\nabc='ABC'\nfor i in range(len(s)):\n for j in range(4):\n if s[i]=='?' and j!=0:\n table[i+1][j]=(3*table[i][j]+table[i][j-1])%(10**9+7)\n elif s[i]=='?':\n table[i+1][0]=3*table[i][0]%(10**9+7)\n elif s[i]==abc[j-1] and j!=0:\n table[i+1][j]=(table[i][j]+table[i][j-1])%(10**9+7)\n else:\n table[i+1][j]=table[i][j]%(10**9+7)\n#print(table)\nprint(table[i+1][j]%(10**9+7))", "neg": "s=input()\ntable=[[0 for _ in range(4)] for _ in range(len(s)+1)]\nabc='ABC'\nfor i in range(len(s)):\n table[i][0]=1\n for j in range(3):\n if s[i]=='?':\n table[i+1][j+1]=3*table[i][j+1]+table[i][j]\n elif s[i]==abc[j]:\n table[i+1][j+1]=table[i][j+1]+table[i][j]\n else:\n table[i+1][j+1]=table[i][j+1]\n#print(table)\nprint(table[i+1][j+1]%(10*9+7))", "jacc_sim": 0.9210526315789473, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [250, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u237362582", "n_user": "u237362582", "pos": "def calc_ABC(a, c, bq, aq):\n ans = 0\n if aq != 0:\n if bq != 0:\n ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \\\n * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))\n else:\n ans = ans + (a*pow(3, bq, MOD)) \\\n * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))\n else:\n if bq != 0:\n ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \\\n * (c*pow(3, aq, MOD))\n else:\n ans = ans + (a*pow(3, bq, MOD)) \\\n * (c*pow(3, aq, MOD))\n return ans % MOD\n\n\nMOD = 10**9 + 7\nS = input()\nans = 0\ncount_a = 0\ncount_c = S.count('C')\ncount_afterq = S.count('?')\ncount_beforeq = 0\n\nfor i in range(len(S)):\n if S[i] == 'A':\n count_a += 1\n elif S[i] == 'B':\n ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)\n ans = ans % MOD\n elif S[i] == 'C':\n count_c -= 1\n elif S[i] == '?':\n count_afterq -= 1\n ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)\n ans = ans % MOD\n count_beforeq += 1\nprint(ans)\n", "neg": "def calc_ABC(a, c, bq, aq):\n ans = 0\n if aq != 0:\n if bq != 0:\n ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \\\n * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))\n else:\n ans = ans + (a*pow(3, bq, MOD)) \\\n * (c*pow(3, aq, MOD) + aq*pow(3, (aq-1), MOD))\n else:\n if bq != 0:\n ans = ans + (a*pow(3, bq, MOD) + bq*pow(3, bq-1, MOD)) \\\n * (c*pow(3, aq, MOD))\n else:\n ans = ans + (a*pow(3, bq, MOD)) \\\n * (c*pow(3, aq, MOD))\n return ans % MOD\n\n\nMOD = 10**9 + 7\nS = raw_input()\nans = 0\ncount_a = 0\ncount_c = S.count('C')\ncount_afterq = S.count('?')\ncount_beforeq = 0\n\nfor i in range(len(S)):\n if S[i] == 'A':\n count_a += 1\n elif S[i] == 'B':\n ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)\n ans = ans % MOD\n elif S[i] == 'C':\n count_c -= 1\n elif S[i] == '?':\n count_afterq -= 1\n ans += calc_ABC(count_a, count_c, count_beforeq, count_afterq)\n ans = ans % MOD\n count_beforeq += 1\nprint(ans)\n", "jacc_sim": 0.9615384615384616, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [472, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u170201762", "n_user": "u170201762", "pos": "Mod = 10**9+7\nS = input()\nN = len(S)\nO = 1\nA = [0]*N\nAB = [0]*N\nABC = [0]*N\n\nfor i in range(N):\n A[i] = A[i-1]\n AB[i] = AB[i-1]\n ABC[i] = ABC[i-1]\n if S[i] == 'A':\n A[i] += O\n if S[i] == 'B':\n AB[i] += A[i-1]\n if S[i] == 'C':\n ABC[i] += AB[i-1]\n if S[i] == '?':\n A[i] *= 3\n A[i] += O\n AB[i] *= 3\n AB[i] += A[i-1]\n ABC[i] *= 3\n ABC[i] += AB[i-1]\n O *= 3\n A[i] %= Mod\n AB[i] %= Mod\n ABC[i] %= Mod\n O %= Mod\nprint(ABC[-1])", "neg": "Mod = 10**9+7\nS = input()\nN = len(S)\nA = [0]*N\nAB = [0]*N\nABC = [0]*N\n\nfor i in range(N):\n A[i] = A[i-1]\n AB[i] = AB[i-1]\n ABC[i] = ABC[i-1]\n if S[i] == 'A':\n A[i] += 1\n if S[i] == 'B':\n AB[i] += A[i-1]\n if S[i] == 'C':\n ABC[i] += AB[i-1]\n if S[i] == '?':\n A[i] *= 3\n A[i] += 1\n AB[i] *= 3\n AB[i] += A[i-1]\n ABC[i] *= 3\n ABC[i] += AB[i-1]\n A[i] %= Mod\n AB[i] %= Mod\n ABC[i] %= Mod\n\nprint(ABC[-1])", "jacc_sim": 0.9714285714285714, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [268, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u474270503", "n_user": "u474270503", "pos": "MOD=10**9+7\ndef func(s):\n abc=\"ABC\"\n n = len(s)\n dp=[[0 for _ in range(3+1)] for _ in range(n+1)]\n dp[n][3]=1\n\n for i in range(n-1,-1,-1):\n for j in range(3,-1,-1):\n if j==3:\n if s[i]=='?':\n dp[i][j]=(dp[i+1][j]*3)%MOD\n else:\n dp[i][j]=dp[i+1][j]\n else:\n m1=3 if s[i]=='?' else 1\n m2=1 if s[i]=='?' or s[i]==abc[j] else 0\n dp[i][j]=((m1*dp[i+1][j])%MOD +(m2*dp[i+1][j+1])%MOD)%MOD\n return dp[0][0]\nprint(func(input()))\n", "neg": "MOD=10**9+7\ndef func(s):\n abc=\"ABC\"\n n = len(s)\n dp=[[0 for _ in range(3+1)] for _ in range(n+1)]\n dp[n][3]=1\n\n for i in range(n-1,-1,-1):\n for j in range(3,-1,-1):\n if j==3:\n if s[i]=='?':\n dp[i][j]=(dp[i+1][j]*3)%MOD\n else:\n dp[i][j]=dp[i+1][j]\n else:\n m1=3 if s[i]=='?' else 1\n m2=1 if s[i]=='?' or s[i]==abc[j] else 0\n dp[i][j]=((m1*dp[i+1][j])%MOD +(m2*dp[i+1][j+1])%MOD)%MOD\n print(dp)\n return dp[0][0]\nprint(func(input()))\n", "jacc_sim": 1.0, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [258, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u518378780", "n_user": "u518378780", "pos": "s = input()\n\ndp3 = 1\ndp2 = 0\ndp1 = 0\ndp0 = 0\n\nn = 10 ** 9 + 7\n\nfor i in reversed(range((len(s)))):\n if s[i] == '?':\n m = 3\n else:\n m = 1\n\n if s[i] == '?':\n m1 = 3\n else:\n m1 = 1\n\n if s[i] == '?' or s[i] == 'C':\n m2 = 1\n else:\n m2 = 0\n\n if s[i] == '?' or s[i] == 'B':\n m3 = 1\n else:\n m3 = 0\n\n if s[i] == '?' or s[i] == 'A':\n m4 = 1\n else:\n m4 = 0\n\n t_dp3 = (m * dp3) % n\n t_dp2 = (m1 * dp2 + m2 * dp3) % n\n t_dp1 = (m1 * dp1 + m3 * dp2) % n\n t_dp0 = (m1 * dp0 + m4 * dp1) % n\n dp3 = t_dp3\n dp2 = t_dp2\n dp1 = t_dp1\n dp0 = t_dp0\n\nans = dp0\nprint(ans)", "neg": "s = input()\n\ndp3 = 1\ndp2 = 0\ndp1 = 0\ndp0 = 0\n\nfor i in reversed(range((len(s)))):\n m = 1\n m1 = 1\n m2 = 0\n m3 = 0\n m4 = 0\n if s[i] == '?':\n m = 3\n m1 = 3\n m2 = 1\n m3 = 1\n m4 = 1\n\n if s[i] == 'C':\n m2 = 1\n\n if s[i] == 'B':\n m3 = 1\n\n if ss[i] == 'A':\n m4 = 1\n\n t_dp3 = m * dp3\n t_dp2 = m1 * dp2 + m2 * dp3\n t_dp1 = m1 * dp1 + m3 * dp2\n t_dp0 = m1 * dp0 + m4 * dp1\n dp3 = t_dp3\n dp2 = t_dp2\n dp1 = t_dp1\n dp0 = t_dp0\n\nn = 10 ** 9 + 7\nans = dp0 % n\nprint(ans)", "jacc_sim": 0.9375, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [334, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u690536347", "n_user": "u690536347", "pos": "from itertools import accumulate as ac\ns=input()\nn=len(s)\nmod=int(1e9)+7\n\n*aca,=ac([0]+[1 if i==\"A\" else 0 for i in s])\n*acc,=ac([0]+[1 if i==\"C\" else 0 for i in s])\n*acq,=ac([0]+[1 if i==\"?\" else 0 for i in s])\n\nv=0\nfor i in range(1,n-1):\n if s[i]==\"B\" or s[i]==\"?\":\n a=aca[i]\n l=acq[i]\n c=acc[n]-acc[i+1]\n r=acq[n]-acq[i+1]\n v+=(a*c*pow(3,l+r,mod))\n if l+r-1>=0:\n v+=(a*r*pow(3,l+r-1,mod))+(l*c*pow(3,l+r-1,mod))\n if l+r-2>=0:\n v+=(l*r*pow(3,l+r-2,mod))\n v%=mod\nprint(v)", "neg": "from itertools import accumulate as ac\ns=input()\nn=len(s)\nmod=int(1e9)+7\n\n*aca,=ac([0]+[1 if i==\"A\" else 0 for i in s])\n*acc,=ac([0]+[1 if i==\"C\" else 0 for i in s])\n*acq,=ac([0]+[1 if i==\"?\" else 0 for i in s])\n\nv=0\nfor i in range(1,n-1):\n if s[i]==\"B\" or s[i]==\"?\":\n a=aca[i]\n l=acq[i]\n c=acc[n]-acc[i+1]\n r=acq[n]-acq[i+1]\n v+=(a*c*pow(3,l+r,mod))\n if l+r-1>=0:\n v+=(a*r*pow(3,l+r-1,mod))+(l*c*pow(3,l+r-1,mod))\n if l+r-2>=0:\n v+=(l*r*pow(3,l+r-2,mod))\n v%=mod", "jacc_sim": 0.9807692307692307, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [298, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u653005308", "n_user": "u653005308", "pos": "s=input()\nabc=\"ABCD\"\nn=len(s)\nmod=10**9+7\ndp=[[0]*4 for i in range(n+1)]\ndp[n][3]=1\nfor i in range(n-1,-1,-1):\n for j in range(4):\n if s[i]=='?' :\n if j==3:\n dp[i][j]=3*dp[i+1][j]\n else :\n dp[i][j]=3*dp[i+1][j]+dp[i+1][j+1]\n elif s[i]==abc[j]:\n if j!=3:\n dp[i][j]=dp[i+1][j]+dp[i+1][j+1]\n else :\n dp[i][j]=dp[i+1][j]\n else :\n dp[i][j]=dp[i+1][j]\n dp[i][j]%=mod\nprint(dp[0][0])", "neg": "s=input()\nabc=\"ABCD\"\nn=len(s)\nmod=10**9+7\ndp=[[0]*4 for i in range(n+1)]\ndp[n][3]=1\nfor i in range(n-1,-1,-1):\n for j in range(4):\n if s[i]=='?' :\n if j==3:\n dp[i][j]=3*dp[i+1][j]\n else :\n dp[i][j]=3*dp[i+1][j]+dp[i+1][j+1]\n elif s[i]==abc[j]:\n if j!=3:\n dp[i][j]=dp[i+1][j]+dp[i+1][j+1]\n else :\n dp[i][j]=dp[i+1][j]\n else :\n dp[i][j]=dp[i+1][j]\n dp[i][j]%=mod\nprint(dp[0][0])", "jacc_sim": 1.0, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [253, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u068400994", "n_user": "u068400994", "pos": "# coding: utf-8\n# Your code here!\n\nMOD = 1000000007\nS = input()\n\ndef add(a,b):\n a += b\n if a >= MOD:\n a -= MOD\n return a\n\ndp = [[0 for i in range(5)] for j in range(200000)]\n\ndp[0][0] = 1\n\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i+1][j] = add(dp[i+1][j], dp[i][j] * 3 % MOD)\n else:\n dp[i+1][j] = add(dp[i+1][j], dp[i][j])\n if S[i] == 'A' or S[i] == '?':\n dp[i+1][1] = add(dp[i+1][1], dp[i][0])\n if S[i] == 'B' or S[i] == '?':\n dp[i+1][2] = add(dp[i+1][2], dp[i][1])\n if S[i] == 'C' or S[i] == '?':\n dp[i+1][3] = add(dp[i+1][3], dp[i][2])\n\nprint(dp[len(S)][3])", "neg": "# coding: utf-8\n# Your code here!\n\nMOD = 1000000007\nS = input()\n\ndef add(a,b):\n a += b\n if a >= MOD:\n a -= MOD\n return a\n\ndp = [[0 for i in range(5)] for j in range(2000000)]\n\ndp[0][0] = 1\n\nfor i in range(len(S)):\n for j in range(4):\n if S[i] == '?':\n dp[i+1][j] = add(dp[i+1][j], dp[i][j] * 3 % MOD)\n else:\n dp[i+1][j] = add(dp[i+1][j], dp[i][j])\n if S[i] == 'A' or S[i] == '?':\n dp[i+1][1] = add(dp[i+1][1], dp[i][0])\n if S[i] == 'B' or S[i] == '?':\n dp[i+1][2] = add(dp[i+1][2], dp[i][1])\n if S[i] == 'C' or S[i] == '?':\n dp[i+1][3] = add(dp[i+1][3], dp[i][2])\n\nprint(dp[len(S)][3])", "jacc_sim": 0.9622641509433962, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [330, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u415905784", "n_user": "u415905784", "pos": "S = input()\np = 10 ** 9 + 7\nDP = [0, 0, 0, 1]\ndp = [0] * 4\nfor i in range(len(S) - 1, -1, -1):\n for j in range(3, -1, -1):\n if j == 3:\n dp[j] = DP[3] * (3 if S[i] == '?' else 1) % p\n elif S[i] == '?':\n dp[j] = (3 * DP[j] + DP[j + 1]) % p\n elif S[i] == chr(65 + j):\n dp[j] = (DP[j] + DP[j + 1]) % p\n else:\n dp[j] = DP[j]\n DP = [x for x in dp]\nprint(DP[0] % p)", "neg": "S = input()\np = 10 ** 9 + 7\nDP = [0, 0, 0, 1]\ndp = [0] * 4\nfor i in range(len(S) - 1, -1, -1):\n for j in range(3, -1, -1):\n if j == 3:\n dp[j] = DP[3] * (3 if S[i] == '?' else 1) % p\n else:\n dp[j] += DP[j + 1] * (1 if S[i] == chr(65 + j) or S[i] == '?' else 0)\n dp[j] += DP[j] * (3 if S[i] == '?' else 1)\n dp[j] % p\n DP = [x for x in dp]\nprint(DP[0] % p)", "jacc_sim": 0.9487179487179487, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [209, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u816116805", "n_user": "u816116805", "pos": "S=input()\n\nemp=1\nA=0\nAB=0\nABC=0\n\nbig = 10**9+7\n\n\n\nfor a in S:\n if a == 'A':\n (emp,A,AB,ABC)=(emp,emp+A,AB,ABC)\n if a == 'B':\n (emp,A,AB,ABC)=(emp,A,A+AB,ABC)\n if a == 'C':\n (emp,A,AB,ABC)=(emp,A,AB,AB + ABC)\n if a == '?':\n (emp,A,AB,ABC)=(3*emp%big, (emp+ 3*A) %big, (A+ 3*AB)%big,(AB + 3*ABC)%big)\n\nprint(ABC%big)\n", "neg": "S=input()\n\nemp=1\nA=0\nAB=0\nABC=0\n\nbig = 10**9+7\n\n\n\nfor a in S:\n if a == 'A':\n (emp,A,AB,ABC)=(emp,emp+A,AB,ABC)\n if a == 'B':\n (emp,A,AB,ABC)=(emp,A,A+AB,ABC)\n if a == 'C':\n (emp,A,AB,ABC)=(emp,A,AB,AB + ABC)\n if a == '?':\n (emp,A,AB,ABC)=(3*emp%big, (emp+ 3*A) %big, (A+ 3*AB)%big,(AB + 3*ABC)%big)\n print(emp,A,AB,ABC)\n\nprint(ABC%big)\n", "jacc_sim": 1.0, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [193, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u941407962", "n_user": "u941407962", "pos": "string = input().strip()\nac = 0\nbc = 0\ncc = 0\nac2 = 0\nbc2 = 0\nbc3 = 0\nbc4 = 0\ncc2 = 0\ncc3 = 0\ncc4 = 0\ncc5 = 0\ncc6 = 0\ncc7 = 0\ncc8 = 0\nfor s in string:\n if s == 'A':\n ac += 1\n elif s == 'B':\n bc += ac\n bc2 += ac2\n elif s == 'C':\n cc += bc\n cc2 += bc2\n cc3 += bc3\n cc4 += bc4\n elif s == '?':\n cc5 += bc2\n cc6 += bc3\n cc7 += bc4\n cc8 += bc\n\n bc3 += ac\n bc4 += ac2\n\n ac2 += 1\n\n#print(cc)\n#print(cc3)\nresult = (cc7) + ((cc4+cc5+cc6) * 3) + ((cc2+cc3+cc8)*9) + (cc*27)\n#print(ac2)\nresult *= pow(3, ac2-3)\nprint(int(result%(pow(10,9)+7)))\n", "neg": "string = '????C?????B??????A???????'\n#string = 'A??C'\nac = 0\nbc = 0\ncc = 0\nac2 = 0\nbc2 = 0\nbc3 = 0\nbc4 = 0\ncc2 = 0\ncc3 = 0\ncc4 = 0\ncc5 = 0\ncc6 = 0\ncc7 = 0\ncc8 = 0\nfor s in string:\n if s == 'A':\n ac += 1\n elif s == 'B':\n bc += ac\n bc2 += ac2\n elif s == 'C':\n cc += bc\n cc2 += bc2\n cc3 += bc3\n cc4 += bc4\n elif s == '?':\n cc5 += bc2\n cc6 += bc3\n cc7 += bc4\n cc8 += bc\n\n bc3 += ac\n bc4 += ac2\n\n ac2 += 1\n\n#print(cc)\n#print(cc3)\nresult = (cc7) + ((cc4+cc5+cc6) * 3) + ((cc2+cc3+cc8)*9) + (cc*27)\n#print(ac2)\nresult *= pow(3, ac2-3)\nprint(result%(pow(10,9)+7))", "jacc_sim": 0.9183673469387755, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [290, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u466917094", "n_user": "u466917094", "pos": "import numpy as np\ns=input()\nA=np.array([0,0,0,0])\nB=np.array([0,0,0,0])\nC=np.array([0,0,0,0])\nt=0\nfor c in s:\n\tif c==\"A\":\n\t\tA[0]+=1\n\tif c==\"B\":\n\t\tB+=A\n\tif c=='C':\n\t\tC+=B\n\tif c=='?':\n\t\tC+=np.roll(B,1)\n\t\tB[1]+=A[0]\n\t\tB[2]+=A[1]\n\t\tA[1]+=1\n\t\tt+=1\nans=0\nfor i in range(4):\n\tans+=pow(3,t-i)*C[i]\nprint(int(ans%1000000007))", "neg": "import numpy as np\ns=input()\nA=np.array([0,0,0,0])\nB=np.array([0,0,0,0])\nC=np.array([0,0,0,0])\nt=0\nfor c in s:\n\tif c==\"A\":\n\t\tA[0]+=1\n\tif c==\"B\":\n\t\tB+=A\n\tif c=='C':\n\t\tC+=B\n\tif c=='?':\n\t\tC[1]+=B[0]\n\t\tC[2]+=B[1]\n\t\tC[3]+=B[2]\n\t\tB[1]+=A[0]\n\t\tB[2]+=A[1]\n\t\tA[1]+=1\n\t\tt+=1\nans=0\nfor i in range(4):\n\tans+=pow(3,t-i)*C[i]\nprint(ans%1000000007)", "jacc_sim": 0.9523809523809523, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [209, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u466917094", "n_user": "u466917094", "pos": "import numpy as np\ns=input()\nn=len(s)\nMOD=1000000007\nwayA=np.array([0,0,0,0])\nwayB=np.array([0,0,0,0])\nwayC=np.array([0,0,0,0])\nhatena=0\nfor c in s:\n\tif c==\"A\":\n\t\twayA[0]+=1\n\tif c==\"B\":\n\t\twayB+=wayA\n\tif c=='C':\n\t\twayC+=wayB\n\tif c=='?':\n\t\twayC[1]=wayC[1]+wayB[0]\n\t\twayC[2]=wayC[2]+wayB[1]\n\t\twayC[3]=wayC[3]+wayB[2]\n\t\twayB[1]=wayB[1]+wayA[0]\n\t\twayB[2]=wayB[2]+wayA[1]\n\t\twayA[1]=wayA[1]+1\n\t\thatena+=1\nans=0\nfor i in range(0,4):\n\tans=ans+pow(3,hatena-i)*wayC[i]\n\tans=ans%MOD\nprint(int(ans))", "neg": "import numpy as np\ns=input()\nwayA=np.array([0,0,0,0])\nwayB=np.array([0,0,0,0])\nwayC=np.array([0,0,0,0])\nhatena=0\nfor c in s:\n\tif c==\"A\":\n\t\twayA[0]+=1\n\tif c==\"B\":\n\t\twayB+=wayA\n\tif c=='C':\n\t\twayC+=wayB\n\tif c=='?':\n\t\twayC[1]=wayC[1]+wayB[0]\n\t\twayC[2]=wayC[2]+wayB[1]\n\t\twayC[3]=wayC[3]+wayB[2]\n\t\twayB[1]=wayB[1]+wayA[0]\n\t\twayB[2]=wayB[2]+wayA[1]\n\t\twayA[1]=wayA[1]+1\n\t\thatena+=1\nans=0\nfor i in range(0,4):\n\tans=ans+pow(3,hatena-i)*wayC[i]\nprint(ans%1000000007)", "jacc_sim": 0.9111111111111111, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [303, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03291", "p_user": "u466917094", "n_user": "u466917094", "pos": "import numpy as np\ns=input()\nn=len(s)\nMOD=1000000007\nwayA=np.array([0,0,0,0])\nwayB=np.array([0,0,0,0])\nwayC=np.array([0,0,0,0])\nMOD2=np.array([MOD,MOD,MOD,MOD])\nhatena=0\nfor c in s:\n\tif c==\"A\":\n\t\twayA[0]+=1\n\tif c==\"B\":\n\t\twayB+=wayA\n\tif c=='C':\n\t\twayC+=wayB\n\tif c=='?':\n\t\twayC[1]=wayC[1]+wayB[0]\n\t\twayC[2]=wayC[2]+wayB[1]\n\t\twayC[3]=wayC[3]+wayB[2]\n\t\twayB[1]=wayB[1]+wayA[0]\n\t\twayB[2]=wayB[2]+wayA[1]\n\t\twayA[1]=wayA[1]+1\n\t\thatena+=1\n\twayA%=MOD2\n\twayB%=MOD2\n\twayC%=MOD2\nans=0\nfor i in range(0,4):\n\tans=ans+pow(3,hatena-i)*wayC[i]\n\tans=ans%MOD\nprint(int(ans))", "neg": "import numpy as np\ns=input()\nwayA=np.array([0,0,0,0])\nwayB=np.array([0,0,0,0])\nwayC=np.array([0,0,0,0])\nhatena=0\nfor c in s:\n\tif c==\"A\":\n\t\twayA[0]+=1\n\tif c==\"B\":\n\t\twayB+=wayA\n\tif c=='C':\n\t\twayC+=wayB\n\tif c=='?':\n\t\twayC[1]+=wayB[0]\n\t\twayC[2]+=wayB[1]\n\t\twayC[3]+=wayB[2]\n\t\twayB[1]+=wayA[0]\n\t\twayB[2]+=wayA[1]\n\t\twayA[1]+=1\n\t\thatena+=1\nans=0\nfor i in range(4):\n\tans+=pow(3,hatena-i)*wayC[i]\nprint(int(ans%MOD))", "jacc_sim": 0.9130434782608695, "nl": "You are given a string S containing characters A, B, C, or ?. The ABC number of a string T is the count of triples of indices (i, j, k) satisfying conditions: 1 \u2264 i < j < k \u2264 |T|, T_i = A, T_j = B, and T_k = C. You need to find the sum of the ABC numbers of all strings that can be formed by replacing each ? in S with A, B, or C. The sum may be large, so print it modulo 10^9 + 7. Constraints: 3 \u2264 |S| \u2264 10^5. Input is given as S, and the output is the sum of the ABC numbers of all the 3^Q strings, modulo 10^9 + 7.", "before_after_length": [343, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00740", "p_user": "u135085051", "n_user": "u135085051", "pos": "# n= \u4eba\u6570\u3000p = \u6700\u521d\u306b\u5165\u3063\u3066\u3044\u308b\u500b\u6570\n\ndef solve(n, p):\n tmp = p\n i = 0\n person = [0] * n\n while(1):\n if tmp != 0:\n person[i] += 1\n tmp -= 1\n if person[i] == p:\n return i\n else:\n tmp = person[i]\n person[i] = 0\n\n i += 1\n if i == n:\n i = 0\n\nans = []\nwhile(1):\n n, p = map(int,input().split())\n if n == 0 and p == 0:\n for i in ans:\n print(i)\n\n break\n else:\n ans.append(solve(n, p))\n\n", "neg": "# n= \u4eba\u6570\u3000p = \u6700\u521d\u306b\u5165\u3063\u3066\u3044\u308b\u500b\u6570\nn, p = map(int,input().split())\n\ndef solve(n, p):\n tmp = p\n i = 0\n person = [0] * n\n while(1):\n if tmp != 0:\n person[i] += 1\n tmp -= 1\n if person[i] == p:\n return i\n else:\n tmp = person[i]\n person[i] = 0\n\n i += 1\n if i == n:\n i = 0\n\n if p == 0:\n for i in range(n):\n if person[i] > 0:\n return i + 1\nans = []\nwhile(1):\n n, p = map(int,input().split())\n if n == 0 and p == 0:\n for i in ans:\n print(i)\n break\n else:\n ans.append(solve(n, p))\n\n", "jacc_sim": 0.96, "nl": "Problem A: Next Mayor\n\nOne of the oddest traditions of the town of Gameston is that the next town mayor is chosen through a game. As the current mayor's term approaches expiration, at least three candidates, including the current mayor, play a game of pebbles, and the winner becomes the next mayor.\n\nThe game of pebbles involves a round table, a bowl, and pebbles. The number of pebbles in the bowl is determined by a secret stochastic process. Candidates, numbered from 0 to n-1, sit around the table in a counterclockwise order. The serving mayor initially holds the bowl.\n\nDuring the game, a candidate takes a pebble from the bowl if there are any, and if not, puts all the pebbles they have into the bowl before passing it to the next candidate. The game continues until a winner is decided.\n\nThe game always ends within a finite number of steps, although it may require a large number of steps.\n\nInput:\nThe input consists of a sequence of datasets, each containing two integers n and p separated by a space. n represents the number of candidates, including the current mayor, and p represents the initial number of pebbles in the bowl. The game will end within one million steps.\n\nOutput:\nThe output should contain the winner's candidate number for each input dataset, with no other characters.\n\nSample Input:\n3 2\n3 3\n3 50\n10 29\n31 32\n50 2\n50 50\n0 0\n\nOutput for the Sample Input:\n1\n0\n1\n5\n30\n1\n13", "before_after_length": [222, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00740", "p_user": "u347385753", "n_user": "u347385753", "pos": "while 1:\n n,p = map(int,input().split())\n if n==0:break\n man = [0]*n\n ball,a = p,0\n while 1:\n a%=n\n if ball >0:\n ball-=1\n man[a]+=1\n elif ball == 0:ball,man[a] = man[a],ball\n if man[a]==p:break\n a+=1\n print(a) ", "neg": "while 1:\n n,p = map(int,input().split())\n if n==0:break\n man = [0]*n\n ball,a = p,0\n while 1:\n if ball >0:ball,man[a%n] =ball-1, man[a%n]+1\n elif ball == 0:ball,man[a%n] = man[a%n],ball\n a+=1\n if p in man:break\n print(man.index(max(man))) ) ", "jacc_sim": 0.90625, "nl": "Problem A: Next Mayor\n\nOne of the oddest traditions of the town of Gameston is that the next town mayor is chosen through a game. As the current mayor's term approaches expiration, at least three candidates, including the current mayor, play a game of pebbles, and the winner becomes the next mayor.\n\nThe game of pebbles involves a round table, a bowl, and pebbles. The number of pebbles in the bowl is determined by a secret stochastic process. Candidates, numbered from 0 to n-1, sit around the table in a counterclockwise order. The serving mayor initially holds the bowl.\n\nDuring the game, a candidate takes a pebble from the bowl if there are any, and if not, puts all the pebbles they have into the bowl before passing it to the next candidate. The game continues until a winner is decided.\n\nThe game always ends within a finite number of steps, although it may require a large number of steps.\n\nInput:\nThe input consists of a sequence of datasets, each containing two integers n and p separated by a space. n represents the number of candidates, including the current mayor, and p represents the initial number of pebbles in the bowl. The game will end within one million steps.\n\nOutput:\nThe output should contain the winner's candidate number for each input dataset, with no other characters.\n\nSample Input:\n3 2\n3 3\n3 50\n10 29\n31 32\n50 2\n50 50\n0 0\n\nOutput for the Sample Input:\n1\n0\n1\n5\n30\n1\n13", "before_after_length": [118, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00741", "p_user": "u316268279", "n_user": "u316268279", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\nsys.setrecursionlimit(10**6)\n\ndef dfs(s,Map,H,W,c):\n dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]\n for i in range(len(dxdy)):\n Map[s[0]][s[1]] = c\n nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])\n if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:\n if Map[nextPos[0]][nextPos[1]] == 1:\n dfs(nextPos,Map,H,W,c)\n\nwhile True:\n W,H = map(int,input().split(\" \"))\n if W == 0 and H == 0:\n break\n Map = [list(map(int,input().split())) for i in range(0,H)]\n c = 1\n for i in range(H):\n for j in range(W):\n if Map[i][j] == 1:\n c += 1\n dfs((i,j),Map,H,W,c)\n print(c-1)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef dfs(s,Map,H,W,c):\n dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]\n for i in range(len(dxdy)):\n Map[s[0]][s[1]] = c\n nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])\n # if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:\n # if Map[nextPos[0]][nextPos[1]] == 1:\n # dfs(nextPos,Map,H,W,c)\n\nwhile True:\n W,H = map(int,input().split(\" \"))\n if W == 0 and H == 0:\n break\n Map = [list(map(int,input().split())) for i in range(0,H)]\n c = 1\n for i in range(H):\n for j in range(W):\n if Map[i][j] == 1:\n c += 1\n dfs((i,j),Map,H,W,c)\n print(c-1)", "jacc_sim": 0.9137931034482759, "nl": "Problem B: How Many Islands?\n\nYou are given a marine area map represented as a mesh of squares, each denoting land or sea. You can move from one land square to another if they are horizontally, vertically, or diagonally adjacent. Two areas are part of the same island if you can walk from one to the other through other land areas. The marine area is surrounded by sea, so you cannot walk outside the area. Write a program to count the number of islands on the map. The input consists of datasets, each with the format: width, height, followed by the map. 0 represents sea, and 1 represents land. Output the number of islands for each dataset. The input ends with a line containing two zeros.", "before_after_length": [353, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00741", "p_user": "u966364923", "n_user": "u966364923", "pos": "import sys\ndef dfs(tiles, W, H, x, y):\n tiles[y][x] = '0'\n for dx,dy in ((-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)):\n if 0<=x+dx=3: raw_input=input\n\nn=int(raw_input())\nfor i in range(0,n):\n\ta=[int(e) for e in raw_input().split()]\n\ta[0]-=1;a[1]-=1\n\tprint(196471-a[0]*195-a[0]//3*5-a[1]*20+(a[1]//2 if a[0]%3!=2 else 0)-a[2])", "neg": "import sys\nif sys.version_info[0]>=3: raw_input=input\n\nn=int(raw_input())\nfor i in range(0,n):\n\ta=[int(e) for e in raw_input().split()]\n\ta[0]-=1;a[1]-=1\n\tprint(196471-a[0]*195-a[0]/3*5-a[1]*20+(a[1]/2 if a[0]%3!=2 else 0)-a[2])", "jacc_sim": 1.0, "nl": "Millennium: A wise king introduced a new calendar with 10 months per year. Each year starts with a big month, followed by small months and alternating thereafter. Big months have 20 days, small months have 19, except for years divisible by three, which consist of 10 big months. To celebrate the millennium day (year 1000, month 1, day 1), a royal lottery will gift people based on their age in days. Write a program to calculate the days lived by individuals until the millennium day.\n\nInput: Positive integer n (\u2264 100) followed by n datasets, each containing a person's birth year, month, and day in the king's calendar.\n\nOutput: For each dataset, print the number of days from the birthdate (inclusive) to the millennium day (exclusive).\n\nSample Input:\n8\n1 1 1\n344 3 1\n696 5 1\n182 9 5\n998 8 7\n344 2 19\n696 4 19\n999 10 20\n\nSample Output:\n196470\n128976\n59710\n160715\n252\n128977\n59712\n1", "before_after_length": [129, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00761", "p_user": "u316268279", "n_user": "u316268279", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n a,L = map(int,input().split(\" \"))\n if a == 0 and L == 0:\n break\n a_set = dict()\n a_set[a] = 0\n a = str(a)\n a = a + '0' * ( L - len(a))\n i = 1\n while True:\n a = int(''.join(reversed(sorted(a)))) - int(''.join(sorted(a)))\n if a in a_set:\n break\n else:\n a_set[a] = i\n a = str(a)\n a = a + '0' * (L-len(a))\n i += 1\n print(a_set[a],a,i-a_set[a])", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n a,L = map(int,input().split(\" \"))\n if a == 0 and L == 0:\n break\n a_set = dict()\n a_set[a] = 0\n a = str(a)\n a = a + '0' * ( L - len(a))\n i = 1\n while True:\n a = int(''.join(reversed(sorted(a)))) - int(''.join(sorted(a)))\n if a in a_set:\n break\n else:\n a_set[a] = i\n a = str(a)\n a = a + '0' * (L-len(a))\n i += 1\n print(a_set[a],' ',a,' ',i-a_set[a])", "jacc_sim": 1.0, "nl": "Recurring Decimals\n\nA decimal representation of an integer can be transformed to another integer by rearranging the order of digits. Given a non-negative integer \"a0\" and the number of digits \"L\", the following rules are applied to obtain \"ai+1\" from \"ai\":\n1. Express \"ai\" in decimal notation with \"L\" digits, adding leading zeros if necessary.\n2. Rearrange the digits to find the largest and smallest possible integers.\n3. Obtain a new integer \"ai+1\" by subtracting the smallest possible integer from the largest.\n\nThis process creates a sequence of integers \"a0\", \"a1\", \"a2\", and so on. Eventually, the sequence will contain occurrences of the same integer due to the fixed number of digits. The goal is to find the smallest \"i\" that satisfies the condition \"ai = aj\" (where \"i\" > \"j\").\n\nThe input consists of multiple datasets, each containing \"a0\" and \"L\". The end of the input is indicated by a line containing two zeros. For each dataset, the program should find the smallest \"i\" that satisfies the condition \"ai = aj\" and print \"j\", \"ai\", and \"i - j\". Leading zeros should be suppressed.\n\nThe program can assume that the value of \"i\" is not greater than 20.", "before_after_length": [213, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00773", "p_user": "u316268279", "n_user": "u316268279", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n x,y,s = map(int,input().split())\n if (x,y,s) == (0,0,0):\n break\n ans = 0\n for i in range(1,s//2 + 1):\n for j in range(1,s-i + 1):\n if i*(100+x)//100 + j*(100+x)//100== s:\n ans = max(ans,i*(100+y)//100 + j*(100+y)//100)\n print(ans)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nwhile True:\n x,y,s = map(int,input().split())\n if (x,y,s) == (0,0,0):\n break\n ans = 0\n for i in range(1,s):\n for j in range(1,s-i):\n if i*(100+x)//100 + j*(100+x)//100== s:\n ans = max(ans,i*(100+y)//100 + j*(100+y)//100)\n print(ans)", "jacc_sim": 0.9761904761904762, "nl": "Title: Tax Rate Changed\n\nVAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price. Our store uses rules to calculate after-tax prices. When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price is p (100+x) / 100 yen, rounded off. The total after-tax price of multiple items paid at once is the sum of after-tax prices of the items.\n\nThe VAT rate changes often. Our accountant has noticed that different pairs of items with the same total after-tax price may have different total after-tax prices after VAT rate changes. For example, when the VAT rate rises from 5% to 8%, a pair of items that had a total after-tax price of 105 yen before can now have after-tax prices of 107, 108, or 109 yen.\n\nThe task is to write a program that calculates the possible maximum total after-tax price of two items with the new VAT rate, knowing their total after-tax price before the VAT rate change.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in one line, consisting of three integers x, y, and s separated by a space. x is the VAT rate in percent before the VAT-rate change, y is the VAT rate in percent after the VAT-rate change, and s is the sum of after-tax prices of two items before the VAT-rate change. The end of the input is specified by three zeros separated by a space.\n\nOutput:\nFor each dataset, output in a line the possible maximum total after-tax price when the VAT rate is changed to y%.\n\nSample Input:\n5 8 105\n8 5 105\n1 2 24\n... (other input lines)\n\nSample Output:\n109\n103\n24\n... (other output lines)\n\nHints:\nThe table provides an instance of a before-tax price pair that has the maximum after-tax price after the VAT-rate change for each dataset of the sample input.", "before_after_length": [154, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00773", "p_user": "u878596989", "n_user": "u878596989", "pos": "while True:\n a,b,c = map(int, input().strip().split(' '))\n temp = 0\n if a == 0 and b == 0 and c == 0:\n break\n for i in range(1, c):\n for j in range(i, c):\n if i*(100+a)//100 + j*(100+a)//100 == c:\n if temp < i*(100+b)//100 + j*(100+b)//100:\n temp = i*(100+b)//100 + j*(100+b)//100\n print(temp)\n", "neg": "while True:\n a,b,c = map(int, input().strip().split(' '))\n temp = 0\n if a == 0 and b == 0 and c == 0:\n break\n for i in range(1, 1001):\n for j in range(1, 1001):\n if i*(100+a)//100 + j*(100+a)//100 == c:\n if temp < i*(100+b)//100 + j*(100+b)//100:\n temp = i*(100+b)//100 + j*(100+b)//100\n print(temp)\n\n", "jacc_sim": 0.9714285714285714, "nl": "Title: Tax Rate Changed\n\nVAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price. Our store uses rules to calculate after-tax prices. When the VAT rate is x%, for an item with the before-tax price of p yen, its after-tax price is p (100+x) / 100 yen, rounded off. The total after-tax price of multiple items paid at once is the sum of after-tax prices of the items.\n\nThe VAT rate changes often. Our accountant has noticed that different pairs of items with the same total after-tax price may have different total after-tax prices after VAT rate changes. For example, when the VAT rate rises from 5% to 8%, a pair of items that had a total after-tax price of 105 yen before can now have after-tax prices of 107, 108, or 109 yen.\n\nThe task is to write a program that calculates the possible maximum total after-tax price of two items with the new VAT rate, knowing their total after-tax price before the VAT rate change.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in one line, consisting of three integers x, y, and s separated by a space. x is the VAT rate in percent before the VAT-rate change, y is the VAT rate in percent after the VAT-rate change, and s is the sum of after-tax prices of two items before the VAT-rate change. The end of the input is specified by three zeros separated by a space.\n\nOutput:\nFor each dataset, output in a line the possible maximum total after-tax price when the VAT rate is changed to y%.\n\nSample Input:\n5 8 105\n8 5 105\n1 2 24\n... (other input lines)\n\nSample Output:\n109\n103\n24\n... (other output lines)\n\nHints:\nThe table provides an instance of a before-tax price pair that has the maximum after-tax price after the VAT-rate change for each dataset of the sample input.", "before_after_length": [142, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00774", "p_user": "u797673668", "n_user": "u797673668", "pos": "from itertools import zip_longest\n\nwhile True:\n n = int(input())\n if not n:\n break\n field = [list(map(int, input().split())) for _ in range(n)]\n field.reverse()\n score = 0\n while True:\n no_more_disappear = True\n\n for row in field:\n for i, stone in enumerate(row[:3]):\n if stone is None:\n continue\n cnt = 1\n for stone2 in row[i + 1:]:\n if stone != stone2:\n break\n cnt += 1\n if cnt >= 3:\n row[i:i + cnt] = [None] * cnt\n score += stone * cnt\n no_more_disappear = False\n\n if no_more_disappear:\n break\n\n fieldT = map(lambda row: filter(None, row), zip(*field))\n field = list(map(list, zip_longest(*fieldT)))\n\n print(score)", "neg": "from itertools import zip_longest\n\nwhile True:\n n = int(input())\n if not n:\n break\n field = [list(map(int, input().split())) for _ in range(n)]\n field.reverse()\n score = 0\n while True:\n no_more_disappear = True\n\n for y, row in enumerate(field):\n for i, stone in enumerate(row):\n if stone is None:\n continue\n cnt = 1\n for stone2 in row[i + 1:]:\n if stone != stone2:\n break\n cnt += 1\n if cnt >= 3:\n row[i:i + cnt] = [None] * cnt\n score += stone * cnt\n no_more_disappear = False\n\n if no_more_disappear:\n break\n\n fieldT = map(lambda row: filter(None, row), zip(*field))\n field = map(list, zip_longest(*fieldT))\n\n print(score)", "jacc_sim": 0.9814814814814815, "nl": "Chain Disappearance Puzzle\n\nWe are playing a puzzle. An upright board with H rows by 5 columns of cells is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. If there are stones in the cells above the cell with a disappeared stone, the stones in the above cells will drop down, filling the vacancy.\n\nThe puzzle proceeds taking the following steps:\n1. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. Disappearances of all such groups of stones take place simultaneously.\n2. When stones are in the cells above the emptied cells, these stones drop down so that the emptied cells are filled.\n3. After the completion of all stone drops, if one or more groups of stones satisfy the disappearance condition, repeat by returning to step 1.\n\nThe score of this puzzle is the sum of the digits on the disappeared stones. Write a program that calculates the score of given configurations of stones.\n\nInput:\nThe input consists of multiple datasets. Each dataset is formed as follows:\nBoard height H\nStone placement of each row from top to bottom.\n\nThe first line specifies the height (H) of the puzzle board (1 \u2264 H \u2264 10). The remaining H lines give placement of stones on each of the rows from top to bottom. The placements are given by five digits (1 through 9), separated by a space. These digits are engraved on the five stones in the corresponding row, in the same order. The input ends with a line with a single zero.\n\nOutput:\nFor each dataset, output the score in a line. Output lines may not include any characters except the digits expressing the scores.\n\nSample Input:\n1\n6 9 9 9 9\n5\n5 9 5 5 9\n5 5 6 9 9\n4 6 3 6 9\n3 3 2 9 9\n2 2 1 1 1\n10\n3 5 6 5 6\n2 2 2 8 3\n6 2 5 9 2\n7 7 7 6 1\n4 6 6 4 9\n8 9 1 1 8\n5 6 1 8 1\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n3 4 5 6 7\n3\n2 2 8 7 4\n6 5 7 7 7\n8 8 9 9 9\n0\n\nOutput for the Sample Input:\n36\n38\n99\n0\n72", "before_after_length": [253, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00774", "p_user": "u672443148", "n_user": "u672443148", "pos": "def calc(puzzle,H,score):\n flag=False\n for i in range(H-1,-1,-1):\n stones=[]\n for j in range(5):\n now=[j,puzzle[j][i]]\n if (len(stones)==0 or stones[-1][1]==now[1]) and now[1]!=0: stones.append(now)\n elif len(stones)<3: stones=[now]\n else: break\n if len(stones)>2:\n flag=True\n score+=stones[0][1]*len(stones)\n for stone in stones:\n puzzle[stone[0]].pop(i)\n puzzle[stone[0]].append(0)\n\n if flag==True:\n return calc(puzzle,H,score)\n else:\n return score\n\nif __name__==\"__main__\":\n while True:\n score=0\n H=int(input())\n if H==0:\n break\n puzzle=[[] for _ in range(5)]\n for i in range(H):\n temp=list(map(int,input().split()))\n for j in range(5):\n puzzle[j].insert(0,temp[j])\n score=calc(puzzle,H,score)\n print(score)\n", "neg": "def calc(puzzle,H,score):\n flag=False\n for i in range(H-1,-1,-1):\n stones=[]\n for j in range(5):\n now=puzzle[j][i]\n if (len(stones)==0 or stones[-1]==now) and now!=0: stones.append(now)\n elif len(stones)<3: stones=[now]\n else: break\n if len(stones)>2:\n flag=True\n score+=sum(stones)\n stone=stones[0]\n for j in range(5):\n now=puzzle[j][i]\n if now==stone:\n if (j<4 and now==puzzle[j+1][i]) or (j>0 and now==puzzle[j-1][i]):\n puzzle[j].pop(i)\n puzzle[j].append(0)\n if flag==True:\n return calc(puzzle,H,score)\n else:\n return score\n\nif __name__==\"__main__\":\n while True:\n score=0\n H=int(input())\n if H==0:\n break\n puzzle=[[] for _ in range(5)]\n for i in range(H):\n temp=list(map(int,input().split()))\n for j in range(5):\n puzzle[j].insert(0,temp[j])\n score=calc(puzzle,H,score)\n print(score)\n", "jacc_sim": 0.95, "nl": "Chain Disappearance Puzzle\n\nWe are playing a puzzle. An upright board with H rows by 5 columns of cells is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. If there are stones in the cells above the cell with a disappeared stone, the stones in the above cells will drop down, filling the vacancy.\n\nThe puzzle proceeds taking the following steps:\n1. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. Disappearances of all such groups of stones take place simultaneously.\n2. When stones are in the cells above the emptied cells, these stones drop down so that the emptied cells are filled.\n3. After the completion of all stone drops, if one or more groups of stones satisfy the disappearance condition, repeat by returning to step 1.\n\nThe score of this puzzle is the sum of the digits on the disappeared stones. Write a program that calculates the score of given configurations of stones.\n\nInput:\nThe input consists of multiple datasets. Each dataset is formed as follows:\nBoard height H\nStone placement of each row from top to bottom.\n\nThe first line specifies the height (H) of the puzzle board (1 \u2264 H \u2264 10). The remaining H lines give placement of stones on each of the rows from top to bottom. The placements are given by five digits (1 through 9), separated by a space. These digits are engraved on the five stones in the corresponding row, in the same order. The input ends with a line with a single zero.\n\nOutput:\nFor each dataset, output the score in a line. Output lines may not include any characters except the digits expressing the scores.\n\nSample Input:\n1\n6 9 9 9 9\n5\n5 9 5 5 9\n5 5 6 9 9\n4 6 3 6 9\n3 3 2 9 9\n2 2 1 1 1\n10\n3 5 6 5 6\n2 2 2 8 3\n6 2 5 9 2\n7 7 7 6 1\n4 6 6 4 9\n8 9 1 1 8\n5 6 1 8 1\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n3 4 5 6 7\n3\n2 2 8 7 4\n6 5 7 7 7\n8 8 9 9 9\n0\n\nOutput for the Sample Input:\n36\n38\n99\n0\n72", "before_after_length": [339, 381], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00774", "p_user": "u209989098", "n_user": "u209989098", "pos": "a = int(input())\nglobal s\ns = 0\n\ndef de(ppp,h):\n\tre = False\n\tco = 0\n\tglobal s\n\tfor lo in ppp:\n\t\tfor j ,cell in enumerate(lo):\n\t\t\tk = j\n\t\t\tp = j\n\t\t\tif k <= 2:\n\t\t\t\twhile cell == lo[k+1] and cell != None:\n\t\t\t\t\tco += 1\n\t\t\t\t\tif k == 3:\n\t\t\t\t\t\tj = k+1\n\t\t\t\t\t\tbreak\n\t\t\t\t\tk += 1\n\t\t\t\t\tj = k\n\t\t\t\tif co >= 2:\n\t\t\t\t\tre = True\n\t\t\t\t\ts += (co+1)*cell\n\t\t\t\t\tfor l in range(5):\n\t\t\t\t\t\tif l >= p and l <= j:\n\t\t\t\t\t\t\tlo[l] = None\n\t\t\t\tco = 0\n\n\treturn re\n\n\n\ndef mo(ppp,h):\n\tfor i ,roe in enumerate(ppp):\n\t\tfor j , cell in enumerate(roe):\n\t\t\tkkk = i\n\t\t\twhile i != 0 and ppp[kkk-1][j] == None:\n\t\t\t\tppp[kkk-1][j] = ppp[kkk][j]\n\t\t\t\tppp[kkk][j] = None\n\t\t\t\tif kkk == 1:\n\t\t\t\t\tbreak\n\t\t\t\tkkk -= 1\n\n\nwhile a != 0:\n\tppp = [list(map(int,input().split())) for i in range(a)]\n\tppp.reverse()\n\twhile(de(ppp,a) == True):\n\t\tmo(ppp,a)\n\tprint(s)\n\n\ts = 0\n\n\ta = int(input())\n\n", "neg": "a = int(input())\nglobal s\ns = 0\n\ndef de(ppp,h):\n\tre = False\n\tco = 0\n\tglobal s\n\tfor lo in ppp:\n\t\tfor j ,cell in enumerate(lo):\n\t\t\tk = j\n\t\t\tp = j\n\t\t\tif k <= 2:\n\t\t\t\twhile cell == lo[k+1] and cell != None:\n\t\t\t\t\tco += 1\n\t\t\t\t\tif k == 3:\n\t\t\t\t\t\tj = k+1\n\t\t\t\t\t\tbreak\n\t\t\t\t\tk += 1\n\t\t\t\t\tj = k\n\t\t\t\tif co >= 2:\n\t\t\t\t\tre = True\n\t\t\t\t\ts += (co+1)*cell\n\t\t\t\t\tfor l in range(5):\n\t\t\t\t\t\tif l >= p and l <= j:\n\t\t\t\t\t\t\tlo[l] = None\n\t\t\t\tco = 0\n\n\treturn re\n\n\n\ndef mo(ppp,h):\n\tfor i ,roe in enumerate(ppp):\n\t\tfor j , cell in enumerate(roe):\n\t\t\tkkk = i\n\t\t\twhile i != 0 and ppp[kkk-1][j] == None:\n\t\t\t\tppp[kkk-1][j] = ppp[kkk][j]\n\t\t\t\tppp[kkk][j] = None\n\t\t\t\tif kkk == 1:\n\t\t\t\t\tbreak\n\t\t\t\tkkk -= 1\n\n\nwhile a != 0:\n\tppp = [list(map(int,input().split())) for i in range(a)]\n\tppp.reverse()\n\twhile(de(ppp,a) == True):\n\t\tmo(ppp,a)\n\tprint(ppp)\n\tprint(s)\n\n\ts = 0\n\n\ta = int(input())\n\n\n", "jacc_sim": 1.0, "nl": "Chain Disappearance Puzzle\n\nWe are playing a puzzle. An upright board with H rows by 5 columns of cells is used in this puzzle. A stone engraved with a digit, one of 1 through 9, is placed in each of the cells. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. If there are stones in the cells above the cell with a disappeared stone, the stones in the above cells will drop down, filling the vacancy.\n\nThe puzzle proceeds taking the following steps:\n1. When three or more stones in horizontally adjacent cells are engraved with the same digit, the stones will disappear. Disappearances of all such groups of stones take place simultaneously.\n2. When stones are in the cells above the emptied cells, these stones drop down so that the emptied cells are filled.\n3. After the completion of all stone drops, if one or more groups of stones satisfy the disappearance condition, repeat by returning to step 1.\n\nThe score of this puzzle is the sum of the digits on the disappeared stones. Write a program that calculates the score of given configurations of stones.\n\nInput:\nThe input consists of multiple datasets. Each dataset is formed as follows:\nBoard height H\nStone placement of each row from top to bottom.\n\nThe first line specifies the height (H) of the puzzle board (1 \u2264 H \u2264 10). The remaining H lines give placement of stones on each of the rows from top to bottom. The placements are given by five digits (1 through 9), separated by a space. These digits are engraved on the five stones in the corresponding row, in the same order. The input ends with a line with a single zero.\n\nOutput:\nFor each dataset, output the score in a line. Output lines may not include any characters except the digits expressing the scores.\n\nSample Input:\n1\n6 9 9 9 9\n5\n5 9 5 5 9\n5 5 6 9 9\n4 6 3 6 9\n3 3 2 9 9\n2 2 1 1 1\n10\n3 5 6 5 6\n2 2 2 8 3\n6 2 5 9 2\n7 7 7 6 1\n4 6 6 4 9\n8 9 1 1 8\n5 6 1 8 1\n6 8 2 1 2\n9 6 3 3 5\n5 3 8 8 8\n5\n1 2 3 4 5\n6 7 8 9 1\n2 3 4 5 6\n7 8 9 1 2\n3 4 5 6 7\n3\n2 2 8 7 4\n6 5 7 7 7\n8 8 9 9 9\n0\n\nOutput for the Sample Input:\n36\n38\n99\n0\n72", "before_after_length": [414, 422], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00780", "p_user": "u118506623", "n_user": "u078042885", "pos": "N=32768\np=[ i for i in range(N)]\nfor i in range(2, int(N**0.5)+1):\n if p[i]:\n for j in range(i*i,N,i):\n p[j]=0\n\np=sorted(set(p))[2:]\nwhile True:\n n = int(input())\n if n==0:\n break\n c=0\n if n&1:c=int(n-2 in p)\n else:\n for x in p:\n if x>n//2:\n break\n if n-x in p:\n c += 1\n print(c)\n", "neg": "N=32768\np=[i for i in range(N)]\nfor i in range(2,int(N**0.5)+1):\n if p[i]:\n for j in range(i*i,N,i):p[j]=0\np=sorted(set(p))[2:]\nprint(p)\nwhile 1:\n n=int(input())\n if n==0:break\n c=0\n if n&1:c=int(n-2 in p)\n else:\n for x in p:\n if x>n//2:break\n if n-x in p:c+=1\n print(c)", "jacc_sim": 0.9743589743589743, "nl": "Problem A: Goldbach's Conjecture\n\nGoldbach's Conjecture states that for any even number \"n\" greater than or equal to 4, there exists at least one pair of prime numbers \"p1\" and \"p2\" such that \"n\" equals \"p1\" + \"p2\". This conjecture has not been proven or disproven. The task is to create a program that counts the number of pairs of prime numbers that satisfy this condition for a given even number.\n\nThe program should take a sequence of even numbers as input and output the number of pairs of prime numbers satisfying the conjecture for each given even number. It's important to note that only essentially different pairs should be counted, meaning that pairs like (p1, p2) and (p2, p1) should not be counted separately.\n\nInput:\nAn integer is given in each input line. Each integer is even, greater than or equal to 4, and less than 2^15. The end of the input is indicated by a number 0.\n\nOutput:\nEach output line should contain an integer number. No other characters should appear in the output.\n\nSample Input:\n6\n10\n12\n0\n\nOutput for the Sample Input:\n1\n2\n1", "before_after_length": [165, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00819", "p_user": "u728992264", "n_user": "u728992264", "pos": "\nn = int(input())\n\nfor i in range(n):\n order = input()[::-1]\n message = input()\n\n for s in order:\n if s == 'J':\n message = message[len(message) - 1] + message[:len(message) - 1]\n elif s == 'C':\n message = message[1:] + message[0]\n elif s == 'E':\n message = message[(len(message)+1)//2:] + message[len(message)//2:(len(message) + 1)//2] + message[:len(message)//2]\n elif s == 'A':\n message = message[::-1] \n elif s == 'P':\n temp = ''\n for c in message:\n if c == '0':\n c = '9'\n elif c > '0' and c <= '9':\n c = chr(ord(c) - 1)\n temp += c\n message = temp\n elif s == 'M':\n temp = ''\n for c in message:\n if c == '9':\n c = '0'\n elif c >= '0' and c < '9':\n c = chr(ord(c) + 1)\n temp += c\n message = temp\n print(message) ", "neg": "\nn = int(input())\n\nfor i in range(n):\n order = input()\n message = input()\n\n for s in order:\n if s == 'J':\n message = message[1:] + message[0]\n elif s == 'C':\n message = message[len(message) - 1] + message[:len(message) - 1]\n elif s == 'E':\n message = message[len(message)//2:] + message[:len(message)//2] \n elif s == 'A':\n message = message[::-1]\n elif s == 'P':\n for c in message:\n if c == '9':\n c = '0'\n elif c >= '0' and c < '9':\n c = chr(ord(c) + 1)\n elif s == 'M':\n for c in message:\n if c == '0':\n c = '9'\n elif c > '0' and c <= '9':\n c = chr(ord(c) - 1)\n \n print(message) ", "jacc_sim": 0.975609756097561, "nl": "Problem A: Unreliable Messengers\n\nThe King of a small island kingdom in the Pacific Ocean wants to use a message relaying game for communication. Six messengers, Mr. J, Miss C, Mr. E, Mr. A, Dr. P, and Mr. M, are chosen to relay messages to the King. However, each messenger makes a mistake when relaying the message, causing the King to receive the wrong message. The Minister of the Science and Technology Agency is tasked with developing software to correct these mistakes.\n\nEach messenger makes a specific mistake when relaying a message:\n- Mr. J rotates all characters of the message to the left by one.\n- Miss C rotates all characters of the message to the right by one.\n- Mr. E swaps the left half of the message with the right half.\n- Mr. A reverses the message.\n- Dr. P increments all the digits in the message by one.\n- Mr. M decrements all the digits in the message by one.\n\nThe task is to infer the original message from the final message, given the order of the messengers. The input contains the order of messengers and the message given to the King. The output should provide the inferred original messages.\n\nInput:\n- The input format includes a positive integer n, denoting the number of data sets.\n- Each data set consists of the order of messengers and the message given to the King.\n\nOutput:\n- The inferred messages are printed each on a separate line.\n\nSample Input:\n5\nAJMP\naB23d\nE\n86AE\nAM\n6\nJPEM\nWaEaETC302Q\nCP\nrTurnAGundam1isdefferentf\n\nOutput for the Sample Input:\n32Bad\nAE86\n7\nEC302QTWaEa\nTurnAGundam0isdefferentfr", "before_after_length": [317, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00848", "p_user": "u078042885", "n_user": "u078042885", "pos": "p=[]\nfor i in range(2,1121):\n for j in range(2,int(i**0.5)+1):\n if not i%j:break\n else:p+=[i]\ndp=[[0]*1121 for _ in range(15)]\ndp[0][0]=1\nfor x,y in enumerate(p):\n for i in range(min(x+1,14),0,-1):\n for j in range(y,1121):\n dp[i][j]+=dp[i-1][j-y]\nwhile 1:\n n,k=map(int,input().split())\n if n==0:break\n print(dp[k][n])", "neg": "for i in range(2,1201):\n for j in range(2,int(i**0.5)+1):\n if not i%j:break\n else:p+=[i]\ndp=[[0]*1200 for _ in range(15)]\ndp[0][0]=1\nfor x,y in enumerate(p):\n for i in range(min(x+1,14),0,-1):\n for j in range(p[x],1200):\n dp[i][j]+=dp[i-1][j-y]\nwhile 1:\n n,k=map(int,input().split())\n if n==0:break\n print(dp[k][n])", "jacc_sim": 0.9333333333333333, "nl": "Problem D: Sum of Different Primes\n\nA positive integer can be expressed as a sum of different prime numbers in various ways. Given two positive integers n and k, count the number of ways to express n as a sum of k different primes. Two ways are considered the same if they sum up the same set of primes. For example, 8 can be expressed as 3 + 5 and 5 + 3, but they are not distinguished.\n\nWhen n and k are 24 and 3 respectively, the answer is two because there are two sets {2, 3, 19} and {2, 5, 17} whose sums are equal to 24. There are no other sets of three primes that sum up to 24. For n = 24 and k = 2, the answer is three, because there are three sets {5, 19}, {7, 17}, and {11, 13}. For n = 2 and k = 1, the answer is one, because there is only one set {2} whose sum is 2. For n = 1 and k = 1, the answer is zero. As 1 is not a prime, {1} should not be counted. For n = 4 and k = 2, the answer is zero, because there are no sets of two different primes whose sums are 4.\n\nYour task is to write a program that reports the number of such ways for the given n and k.\n\nInput:\nThe input is a sequence of datasets followed by a line containing two zeros separated by a space. A dataset is a line containing two positive integers n and k separated by a space. You may assume that n \u2264 1120 and k \u2264 14.\n\nOutput:\nThe output should be composed of lines, each corresponding to an input dataset. An output line should contain one non-negative integer indicating the number of ways for n and k specified in the corresponding dataset. You may assume that it is less than 2^31.\n\nSample Input:\n24 3\n24 2\n2 1\n1 1\n4 2\n18 3\n17 1\n17 3\n17 4\n100 5\n1000 10\n1120 14\n0 0\n\nOutput for the Sample Input:\n2\n3\n1\n0\n0\n2\n1\n0\n1\n55\n200102899\n2079324314", "before_after_length": [172, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u125348436", "n_user": "u125348436", "pos": "import math\ns=input()\ndef kaibun(s):\n ls=len(s)\n\n if ls==1:\n print(\"YES\")\n return\n \n ca,cb,cc=0,0,0\n l=[]\n for i in range(ls):\n if s[i]==\"a\":\n ca+=1\n if s[i]==\"b\":\n cb+=1\n if s[i]==\"c\":\n cc+=1\n l.append(ca)\n l.append(cb)\n l.append(cc)\n cnt_zero=0\n for j in l:\n if j==0:\n cnt_zero+=1\n if cnt_zero==2:\n print(\"NO\")\n return\n\n elif cnt_zero==1:\n if ls==2:\n print(\"YES\")\n return\n else:\n print(\"NO\")\n return\n \n #cnt_zero=0\u306e\u3068\u304d\uff0c\u3064\u307e\u308a\u3059\u3079\u3066\u306e\u6587\u5b57\u304c\u6587\u5b57\u5217\u306b\u542b\u307e\u308c\u308b\u3068\u304d\n else:\n if ls==3 or ls==4:\n print(\"YES\")\n return\n nmin=math.floor(ls/3.0)\n nmax=math.ceil(ls/3.0)\n nmax=int(nmax)\n nmin=int(nmin)\n #out=0\n for j in l:\n if j=2:\n print(\"NO\")\n return\n\n print(\"YES\")\n return\n \nkaibun(s)", "jacc_sim": 0.9863013698630136, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [439, 465], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u609814378", "n_user": "u796366385", "pos": "s = input()\na = [s.count(\"a\"), s.count(\"b\"), s.count(\"c\")]\na.sort(reverse=True)\nif a[0] <= a[2] + 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "s = input()\na = [s.count(\"a\"), s.count(\"b\"), s.count(\"c\")]\na.sort(reverse=True)\nprint(a)\nif a[0] <= a[2] + 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 1.0, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [68, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u213580455", "n_user": "u213580455", "pos": "import collections\n\ndef answer(s):\n YES = 'YES'\n NO = 'NO'\n dic = collections.Counter(s)\n vals = sorted([v for k,v in dic.items()], reverse=True)\n if len(vals) == 1:\n if vals[0] == 1: return YES\n else: return NO\n elif len(vals) == 2:\n if vals[0] == 1 and vals[1] == 1: return YES\n else: return NO\n \n _max = vals[0]\n _sum = sum(vals[1:])\n if (_max-1)*2 <= _sum:\n if vals[1]-vals[2] > 1: return NO\n else: return YES\n return NO\n\ns = input()\nprint(answer(s))", "neg": "def answer(s):\n YES = 'YES'\n NO = 'NO'\n dic = collections.Counter(s)\n vals = sorted([v for k,v in dic.items()], reverse=True)\n if len(vals) == 1: return YES\n elif len(vals) == 2:\n if vals[0] == 1 and vals[1] == 1: return YES\n else: return NO\n \n _max = vals[0]\n _sum = sum(vals[1:])\n if (_max-1)*2 <= _sum:\n if vals[1]-vals[2] > 1: return NO\n else: return YES\n return NO\ns = input()\nprint(answer(s))", "jacc_sim": 0.9777777777777777, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [198, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u827202523", "n_user": "u827202523", "pos": "from collections import Counter\n\ns = input().strip() + \"abc\"\nc = Counter(s)\nv = list(c.values())\nif max(v) - min(v) > 1: \n print(\"NO\")\nelse:\n print(\"YES\")", "neg": "from collections import Counter\n\ns = input().strip()\nc = Counter(s)\nv = list(c.values())\nif max(v) - min(v) > 1: \n print(\"NO\")\nelse:\n print(\"YES\")", "jacc_sim": 0.9310344827586207, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [61, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u368780724", "n_user": "u785578220", "pos": "s = input()\na, b, c = [s.count(i) for i in 'abc']\nif max(a, b, c) - min(a, b, c) not in [0, 1]:\n print('NO')\nelse:\n print('YES')", "neg": "s = input()\na, b, c = [s.count(i) for i in 'abc']\nif max(a, b, c) - min(a, b, c) not in [0, 1]:\n print(max(a, b, c) , min(a, b, c))\n print('NO')\nelse:\n print('YES')", "jacc_sim": 1.0, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [65, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u075012704", "n_user": "u075012704", "pos": "S = input()\nC = {\"a\": 0, \"b\": 0, \"c\": 0}\nfor s in S:\n C[s] += 1\nif abs(C[\"a\"] - C[\"b\"]) <= 1 and abs(C[\"b\"] - C[\"c\"]) <= 1 and abs(C[\"c\"] - C[\"a\"]) <= 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "S = input()\nC = {\"a\": 0, \"b\": 0, \"c\": 0}\nfor s in S:\n C[\"s\"] += 1\nif abs(C[\"a\"] - C[\"b\"]) <= 1 and abs(C[\"a\"] - C[\"b\"]) <= 1 and abs(C[\"a\"] - C[\"b\"]) <= 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 1.0, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [99, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u756988562", "n_user": "u756988562", "pos": "import sys\nimport collections\nS = input()\ncount_dict = collections.Counter(S)\nNum_A = count_dict[\"a\"]\nNum_B = count_dict[\"b\"]\nNum_C = count_dict[\"c\"]\n\njudge = sorted([Num_A, Num_B, Num_C])\nif judge[2]-judge[0]>1:\n print('NO')\nelse:\n print('YES')", "neg": "import sys\nimport collections\nS = input()\ncount_dict = collections.Counter(S)\nNum_A = count_dict[\"a\"]\nNum_B = count_dict[\"b\"]\nNum_C = count_dict[\"c\"]\n\njudge = sorted([a, b, c])\nif judge[2]-judge[0]>1:\n print('NO')\nelse:\n print('YES')", "jacc_sim": 1.0, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [104, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03534", "p_user": "u445624660", "n_user": "u445624660", "pos": "s = input()\na, b, c = s.count('a') ,s.count('b'), s.count('c')\nlis = sorted([a, b, c])\nif lis[2]-lis[0]>1:\n print('NO')\nelse:\n print('YES')", "neg": "s = input()\na, b, c = s.count('a') ,s.count('b'), s.count('c')\nlis = sorted([a, b, c])\nif lis[2]-lis[1]>1:\n print('NO')\nelse:\n print('YES')", "jacc_sim": 0.9629629629629629, "nl": "Snuke has a string S consisting of three kinds of letters: a, b, and c. He has a phobia for palindromes and wants to permute the characters in S so that it will not contain a palindrome of length 2 or more as a substring. Determine whether this is possible.\n\nConstraints:\n1 \u2264 |S| \u2264 10^5\nS consists of a, b, and c.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the objective is achievable, print YES; if it is unachievable, print NO.\n\nSample Input 1:\nabac\n\nSample Output 1:\nYES\nAs it stands now, S contains a palindrome \"aba,\" but we can permute the characters to get \"acba,\" for example, that does not contain a palindrome of length 2 or more.\n\nSample Input 2:\naba\n\nSample Output 2:\nNO\n\nSample Input 3:\nbabacccabab\n\nSample Output 3:\nYES", "before_after_length": [73, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03535", "p_user": "u785989355", "n_user": "u785989355", "pos": "N=int(input())\n\nD=list(map(int,input().split()))\nflg =False\nA = [0 for i in range(13)]\nA[0]=1\nfor i in range(N):\n j = min(D[i],24-D[i])\n if j==0:\n flg=True\n break\n elif j==12:\n if A[j]==1:\n flg=True\n break\n else:\n A[j]+=1\n else:\n if A[j]==2:\n flg=True\n break\n else:\n A[j]+=1\n\nimport copy\n\nif flg:\n print(0)\nelse:\n count=0\n one_times=[]\n times=[0]\n for i in range(1,12): \n if A[i]==1:\n count+=1\n one_times.append(i)\n if A[i]==2:\n times.append(i)\n times.append(24-i)\n if A[12]==1:\n times.append(12)\n score_max=0\n for i in range(2**count):\n t=copy.copy(times)\n for j in range(count):\n if (i//(2**j))%2==0:\n t.append(one_times[j])\n else:\n t.append(24-one_times[j])\n t.sort()\n \n score_min=24\n for j in range(len(t)):\n if j==len(t)-1:\n score_min=min(t[0]+24-t[len(t)-1],score_min)\n else:\n score_min=min(t[j+1]-t[j],score_min)\n score_max=max(score_min,score_max)\n print(score_max)", "neg": "\nN=int(input())\n\nD=list(map(int,input().split()))\nflg =False\nA = [0 for i in range(13)]\nA[0]=1\nfor i in range(N):\n j = min(i,24-i)\n if j==0:\n flg=True\n break\n elif j==12:\n if A[j]==1:\n flg=True\n break\n else:\n A[j]+=1\n else:\n if A[j]==2:\n flg=True\n break\n else:\n A[j]+=1\n\nimport copy\n\nif flg:\n print(0)\nelse:\n count=0\n one_times=[]\n times=[0]\n for i in range(1,12): \n if A[i]==1:\n count+=1\n one_times.append(i)\n if A[i]==2:\n times.append(i)\n times.append(24-i)\n if A[12]==1:\n times.append(12)\n score_max=0\n for i in range(2**count):\n t=copy.copy(times)\n for j in range(count):\n if (i//(2**j))%2==0:\n t.append(one_times[j])\n else:\n t.append(24-one_times[j])\n t.sort()\n score_min=24\n for j in range(len(t)):\n if j==len(t)-1:\n score_min=min(t[0]+24-t[len(t)-1],score_min)\n else:\n score_min=min(t[j+1]-t[j],score_min)\n score_max=(score_min,score_max)\n print(score_max)", "jacc_sim": 0.9811320754716981, "nl": "In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi found the time gap between his city and each person's city. The time gap is defined as the minimum hours between the local times in two cities. He wants to find the maximum possible value of the smallest time gap among all pairs of people. Constraints: 1 \u2264 N \u2264 50, 0 \u2264 D_i \u2264 12. Input format: N followed by N integers representing time gaps. Output: Print the maximum possible value of the smallest time gap. Example: Input 3, then 7 12 8. Output: 4.", "before_after_length": [476, 469], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03535", "p_user": "u925364229", "n_user": "u925364229", "pos": "N = int(input())\nD = list(map(int,input().split(\" \")))\n\nans = D[:]\nD.sort()\nD_1 = []\nD_2 = []\n\nfor i in range(N):\n\tif i % 2 == 0:\n\t\tD_1.append(24-D[i])\n\t\tD_2.append(D[i])\n\telse:\n\t\tD_2.append(24-D[i])\n\t\tD_1.append(D[i])\n\n\nfor i in range(N):\n\tfor j in range(i+1,N):\n\t\tdf1 = abs(D_1[j] - D_1[i])\n\t\tdf2 = abs(D_2[j] - D_2[i])\n\t\t\n\t\tdf1 = min([df1,24-df1])\n\t\tdf2 = min([df2,24-df2])\n\t\t\t\n\t\tans.append(df1)\n\t\tans.append(df2)\n\nprint(min(ans))\n\n\n\n\n", "neg": "N = int(input())\nD = list(map(int,input().split(\" \")))\n\nans = D[:]\n\n\nD.sort()\n\nfor i in range(N):\n\tif i % 2 == 0:\n\t\tD_1.append(24-D[i])\n\t\tD_2.appned(D[i])\n\telse:\n\t\tD_2.append(24-D[i])\n\t\tD_1.appned(D[i])\n\n\nfor i in range(N):\n\tfor j in range(i+1,N):\n\t\tdf1 = abs(D_1[j] - D_1[i])\n\t\tdf2 = abs(D_2[j] - D_2[i])\n\t\t\n\t\tdf1 = min([df1,24-df1])\n\t\tdf2 = min([df2,24-df2])\n\t\t\t\n\t\tans.append(df1)\n\t\tans.append(df2)\n\nprint(min(df1))\n\n\n\n\n", "jacc_sim": 0.975609756097561, "nl": "In CODE FESTIVAL XXXX, there are N+1 participants from all over the world, including Takahashi. Takahashi found the time gap between his city and each person's city. The time gap is defined as the minimum hours between the local times in two cities. He wants to find the maximum possible value of the smallest time gap among all pairs of people. Constraints: 1 \u2264 N \u2264 50, 0 \u2264 D_i \u2264 12. Input format: N followed by N integers representing time gaps. Output: Print the maximum possible value of the smallest time gap. Example: Input 3, then 7 12 8. Output: 4.", "before_after_length": [257, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u344959959", "n_user": "u344959959", "pos": "a,b,c = map(int,input().split())\n#lis = list(map(int,input().split()))\nprint((a-c)//(b+c))", "neg": "\na,b,c = map(int,input().split())\n#lis = list(map(int,input().split()))\nprint((a-c)//(b+z))\n", "jacc_sim": 0.95, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [43, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u244836567", "n_user": "u244836567", "pos": "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nprint((a-c)//(b+c))", "neg": "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nprint((a-c)//b)", "jacc_sim": 0.9333333333333333, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [44, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u316603606", "n_user": "u118211443", "pos": "X,Y,Z = map (int, input ().split ())\nX = X-Z\nA = (X/(Y+Z))//1\nprint (round (A))", "neg": "X,Y,Z=map(int,input().split())\nA=int((X-1)/(Y+Z))\nprint(A)", "jacc_sim": 0.9473684210526315, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [42, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u433380437", "n_user": "u433380437", "pos": "# ABC078 B - ISU\n\n# Y*[\u4eba\u6570]+Z*[\u4eba\u6570]+1 <=X\n# 3*q+1*q+1<=13\n# Y*q+(Z+1)*q<=X\n## Y*q+Z*(q+1)<=X\n## q<=(X-Z)/(Y+Z) \n# q<=(X)/(Y+Z+1)\n\nimport math\nx,y,z = map(int,input().split())\nt = (x-z)/(y+z)\nprint(math.floor(t))\n\n\n", "neg": "# ABC078 B - ISU\n\n# Y*[\u4eba\u6570]+Z*[\u4eba\u6570]+1 <=X\n# 3*q+1*q+1<=13\n# Y*q+Z*q+1<=X\n# q<=(X-1)/(Y+Z)\n\nimport math\nx,y,z = map(int,input().split())\nt = (x-1)/(y+z)\nprint(math.floor(t))\n\n\n", "jacc_sim": 1.0, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [150, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u514118270", "n_user": "u514118270", "pos": "import sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef i(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nINF = 10**9\nmod = 10**9+7\n\nX,Y,Z = I()\nprint((X-Z)//(Y+Z))", "neg": "import sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef i(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nINF = 10**9\nmod = 10**9+7\n\nX,Y,Z = I()\nprint(1+(X-Y)//(Y+Z))", "jacc_sim": 0.98, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [164, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u227085629", "n_user": "u102960641", "pos": "x,y,z = map(int,input().split())\na = x-z\nb = a//(y+z)\nprint(b)", "neg": "a,b,c = map(int, input().split())\nprint((x-z)//(y+z))", "jacc_sim": 0.9473684210526315, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [35, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u886142147", "n_user": "u050428930", "pos": "x, y, z = map(int, input().split())\n\nprint((x - 1 * z) // (y + z))", "neg": "x,y,z=map(int,input().split())\nprint((x-y)//(y+z)+1)", "jacc_sim": 0.9444444444444444, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [30, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u021916304", "n_user": "u021916304", "pos": "def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nx,y,z = iim()\nprint((x-z)//(z+y))\n", "neg": "def ii():return int(input())\ndef iim():return map(int,input().split())\ndef iil():return list(map(int,input().split()))\ndef ism():return map(str,input().split())\ndef isl():return list(map(str,input().split()))\n\nx,y,z = iim()\nprint(x//(z+y))\n", "jacc_sim": 0.9615384615384616, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [95, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u361826811", "n_user": "u361826811", "pos": "\"\"\"\nauthor : halo2halo\ndate : 29, Jan, 2020\n\"\"\"\n\nimport sys\n\n# import itertools\n# import numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nX, Y, Z = map(int, readline().split())\nprint((X-Z) // (Y + Z))", "neg": "\"\"\"\nauthor : halo2halo\ndate : 29, Jan, 2020\n\"\"\"\n\nimport sys\n\n# import itertools\n# import numpy as np\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nX, Y, Z = map(int, readline().split())\nprint(X // (Y + Z))", "jacc_sim": 0.9743589743589743, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [110, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u121921603", "n_user": "u706414019", "pos": "import sys\ninput = sys.stdin.readline\nx,y,z=map(int,input().split())\nprint((x-z)//(y+z))\n", "neg": "import sys\ninput = sys.stdin.readline\n\nx,y,z=list(map(int,input().split()))\n\nprint((x+z)//(y+z))", "jacc_sim": 0.9047619047619048, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [40, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u609061751", "n_user": "u609061751", "pos": "import sys\ninput = sys.stdin.readline\nX, Y, Z = [int(x) for x in input().split()]\nans = 0\nX -= Z\nans += (X // (Y + Z))\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nX, Y, Z = [int(x) for x in input().split()]\nans = 1\nX -= Y\nans += (X // (Y + Z))\nprint(ans)", "jacc_sim": 0.9259259259259259, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [55, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u583276018", "n_user": "u432805419", "pos": "a, b, c = map(int, input().split())\na -= c\nd = b + c\nprint(a // d)", "neg": "a,b,c = list(map(int,input().split()))\nd = a - c\n\nprint(int(a /(b + c)))", "jacc_sim": 0.9444444444444444, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [31, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u602677143", "n_user": "u602677143", "pos": "import math\nx,y,z = map(int,input().split())\nx = x-z\nprint(math.floor(x/(y+z)))\n", "neg": "import math\nx,y,z = map(int,input().split())\nx = x-z\nprint(math.floor(y/z))\n", "jacc_sim": 0.9473684210526315, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [39, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u234631479", "n_user": "u729119068", "pos": "a, b, c = map(int, input().split())\nprint((a-b-c*2)//(b+c)+1)", "neg": "a,b,c=map(int, input().split())\nprint((a-b-2*c)//2+1)", "jacc_sim": 1.0, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [33, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u847165882", "n_user": "u847165882", "pos": "X,Y,Z=[int(s) for s in input().split()]\n\nprint((X-Z)//(Z+Y))", "neg": "X,Y,Z=[int(s) for s in input().split()]\n\nprint((X-1)//(Z+Y))", "jacc_sim": 0.9523809523809523, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [32, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u565149926", "n_user": "u580362735", "pos": "X, Y, Z = map(int, input().split())\nprint((X - Z * 2 - Y) // (Y + Z) + 1)\n", "neg": "X,Y,Z = map(int,input().split())\nprint((X - (Y + 2*Z))//(Y+Z))", "jacc_sim": 0.9473684210526315, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [35, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u677393869", "n_user": "u677393869", "pos": "A,B,C=map(int,input().split())\nA=A-C\nans=A//(B+C)\n\nprint(ans)\n", "neg": "A,B,C=map(int,input().split())\nA=A-1\nans=A//(B+C)\n\nprint(ans)", "jacc_sim": 0.9444444444444444, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [37, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u771532493", "n_user": "u771532493", "pos": "import math\na,b,c=map(int,input().split())\na-=c\nprint(math.floor(a/(b+c)))\n", "neg": "import math\na,b,c=map(int,input(),split())\na-=c\nprint(math.floor(a/(b+c))", "jacc_sim": 1.0, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [38, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u586149955", "n_user": "u399721252", "pos": "x, y, z = [int(_) for _ in input().split()]\nprint((x-z)//(y+z))\n", "neg": "x, y, z = [ int(v) for v in input().split() ]\n\nprint((x-z)//(y+x))", "jacc_sim": 0.9047619047619048, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [32, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u644778646", "n_user": "u644778646", "pos": "x,y,z = map(int,input().split())\nans = 0\nprint((x-z)//(y+z))", "neg": "x,y,z = map(int,input().split())\nans = 0\nprint((x-1)//(y+z))", "jacc_sim": 0.9473684210526315, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [31, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u619458041", "n_user": "u619458041", "pos": "import sys\n\ndef main():\n input = sys.stdin.readline\n x, y, z = map(int, input().split())\n\n print((x - z) // (y + z))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\n\ndef main():\n input = sys.stdin.readline\n x, y, z = map(int, input().split())\n\n print(x // ( y + z))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9629629629629629, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [65, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u602850810", "n_user": "u602850810", "pos": "X, Y, Z = [int(x) for x in input().split()]\n\nX -= Z\n\nprint(X // (Y + Z))", "neg": "X, Y, Z = [int(x) for x in input().split()]\n\nprint(X // (Y + Z) + (X % (Y + Z)) // Y)", "jacc_sim": 0.9047619047619048, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [35, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u174394352", "n_user": "u384679440", "pos": "X,Y,Z=map(int,input().split())\nans=1\nX-=Y+2*Z\nans+=X//(Y+Z)\nprint(ans)", "neg": "X, Y, Z = map(int, input().split())\nans = int((X - 2 * Z) / (Y + Z))\nprint(ans)", "jacc_sim": 0.95, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [43, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u063052907", "n_user": "u428397309", "pos": "# coding: utf-8\nX, Y, Z = map(int, input().split())\nprint((X-Z) // (Y+Z))\n", "neg": "# -*- coding: utf-8 -*-\n\nX, Y, Z = map(int, input().split())\n\nans = (X + Z) // Y\nprint(ans)\n", "jacc_sim": 0.9130434782608695, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [35, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u588633699", "n_user": "u588633699", "pos": "from sys import stdin\nimport math\n \nx, y, z = stdin.readline().split()\n \nprint (math.floor(( ( int(x)-int(z) ) / ( int(y) + int(z) ) )))", "neg": "from sys import stdin\n \nx,y,z = stdin.readline().split()\n\nprint (int(x)-int(z))/(int(y)+int(z))\n", "jacc_sim": 0.9047619047619048, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [57, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u039623862", "n_user": "u960171798", "pos": "x, y, z = map(int, input().split())\n\nprint(1 + (x - y - 2*z) // (y + z))\n", "neg": "x,y,z = map(int, input().split())\nans = 1+(x-y-2*z)/(y+z)\nprint(ans)", "jacc_sim": 0.95, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [36, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u599547273", "n_user": "u407730443", "pos": "x, y, z = [int(m) for m in input().split(\" \")]\n\nprint((x-z) // (y+z))", "neg": "x, y, z = [int(m) for m in input().split(\" \")]\n\nprint((x+z) // (y+z))", "jacc_sim": 0.9523809523809523, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [34, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u506302470", "n_user": "u945359338", "pos": "A,B,C=map(int,input().split())\n\nA-=C\n\nprint(A//(B+C))", "neg": "A,B,C = map(int,input().split())\nprint((A+C)//B)", "jacc_sim": 0.9375, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [31, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u200239931", "n_user": "u200239931", "pos": "import math\nimport sys\n\ndef getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\n#\u6905\u5b50\u306f\u3070\nx = int(arr_data[0][0])\ny = int(arr_data[0][1])\nz = int(arr_data[0][2])\n\n#print(x, y, z)\n\nhasi = y + z\n\nnaka = y + z \n\n#\u5ea7\u308c\u308b\u4eba\u6570\u521d\u671f\u5024\ncnt = 0\n\n#\u306f\u3057\u306b\u5ea7\u308c\u308b\u4eba\u6570\n#cnt+=x//(hasi)\n#print(cnt)\n\n\nif x >= hasi * 2:\n \n cnt += 2\n #\u6b8b\u308a\n x -= hasi * 2\n \nelif x >= hasi:\n \n cnt += 1\n #\u6b8b\u308a\n x -= hasi\n\n\n\nx-=z\n#\u4e2d\u306b\u5ea7\u308c\u308b\u4eba\u6570\ncnt += x // naka\n\nprint(cnt)\n\n\n\n", "neg": "import math\nimport sys\n\ndef getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\n#\u6905\u5b50\u306f\u3070\nx = int(arr_data[0][0])\ny = int(arr_data[0][1])\nz = int(arr_data[0][2])\n\nprint(x, y, z)\n\nhasi = y + z\n\nnaka = y + z \n\n#\u5ea7\u308c\u308b\u4eba\u6570\u521d\u671f\u5024\ncnt = 0\n\n#\u306f\u3057\u306b\u5ea7\u308c\u308b\u4eba\u6570\n#cnt+=x//(hasi)\n#print(cnt)\n\n\nif x >= hasi * 2:\n \n cnt += 2\n #\u6b8b\u308a\n x -= hasi * 2\n \nelif x >= hasi:\n \n cnt += 1\n #\u6b8b\u308a\n x -= hasi\n\n\n\nx-=z\n#\u4e2d\u306b\u5ea7\u308c\u308b\u4eba\u6570\ncnt += x // naka\n\nprint(cnt)\n\n\n\n", "jacc_sim": 1.0, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [442, 441], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u390694622", "n_user": "u390694622", "pos": "X,Y,Z = map(int,input().split(\" \"))\nans = (X-Z)//(Y+Z)\nprint(ans)", "neg": "X,Y,Z = map(int,input.split(\" \"))\nans = (X-Z)//(Y+Z)\nprint(ans)", "jacc_sim": 1.0, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [35, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u136553578", "n_user": "u880646180", "pos": "(x, y, z) = [int(i) for i in input().split()]\nprint((x - z) // (y + z))", "neg": "s = input()\nx, y, z = [int(i) for i in s.split()]\nprint(int((x-y)/(y+z))+1)", "jacc_sim": 0.9090909090909091, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [34, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u146706885", "n_user": "u676264453", "pos": "x, y, z = list(map(int, input().split()))\nx -= z\nprint(x // (y + z))", "neg": "x, y, z = list(map(int, input().split()))\n\nprint((x-1) // (y+z))\n", "jacc_sim": 0.9444444444444444, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [31, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u257974487", "n_user": "u143509139", "pos": "a, b, c = map(int,input().split())\nprint((a - c) // (b + c))\n", "neg": "a,b,c=map(int,input().split())\nprint(a-1//(b+c))", "jacc_sim": 0.9411764705882353, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [28, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u813450984", "n_user": "u274907892", "pos": "X, Y, Z = map(int, input().split())\n\nprint((X - Z) // (Y + Z))", "neg": "X, Y, Z = map(int, input().split())\nprint((X-Z)/Y)", "jacc_sim": 0.9375, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [29, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u867069435", "n_user": "u311333072", "pos": "a = list(map(int, input().split()))\nprint((a[0] - a[2]) // (a[1] + a[2]))\n", "neg": "a=list(map(int,input().split()))\na[0]=a[0]-a[2]-a[2]\n#print(a[0])\nprint(int(a[0]/(a[1]+a[2])))", "jacc_sim": 0.9523809523809523, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [37, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u893209854", "n_user": "u612721349", "pos": "x, y, z = map(int, input().split())\nm = x - z\nprint(m // (y + z))", "neg": "x, y, z = map(int, input().split())\nz -= y\nprint(z // (x + y))", "jacc_sim": 0.9411764705882353, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03548", "p_user": "u443170850", "n_user": "u864197622", "pos": "X,Y,Z = list(map(int,input().split()))\nprint( (X-Z) // (Y+Z) )", "neg": "X, Y, Z = map(int, input().split())\nprint((X-Z)//Y+Z)", "jacc_sim": 0.9411764705882353, "nl": "You have a long seat of width X centimeters. People sitting on the seat will occupy an interval of length Y centimeters. There must be a gap of at least Z centimeters between two people and between the end of the seat and a person. Find the maximum number of people that can sit on the seat. All input values are integers, and Y+2Z should be less than or equal to X. Input is given in the format X Y Z, and the output should be the maximum number of people that can sit.", "before_after_length": [32, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u026788530", "n_user": "u026788530", "pos": "n,z,w=[int(x) for x in input().split()]\n \na=[int(x) for x in input().split()]\n \nif(n==1):\n print(abs(a[0]-w))\nelse:\n print(max(abs(a[-1]-w),abs(a[-1]-a[-2])))", "neg": "n,z,w=[int(x) for x in input().split()]\n\na=[int(x) for x in input().split()]\n\nif(n==1):\n print(abs(a[0]-w))\nelse:\n print(min(abs(a[-1]-w),abs(a[-1]-a[-2])))", "jacc_sim": 0.9285714285714286, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [87, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u572142121", "n_user": "u572142121", "pos": "N,Z,W=map(int,input().split())\nA=list(map(int, input().split()))\nif N==1:\n print(abs(A[-1]-W))\nelse:\n a=abs(A[-1]-W)\n b=abs(A[-2]-A[-1])\n print(max(a,b))", "neg": "N,Z,W=map(int,input().split())\nA=list(map(int, input().split()))\nif N==1:\n print(abs(A[-1]-W))\nelif N==2:\n print(abs(A[-1]-W),abs(A[0]-A[-1]))\nelse:\n a=abs(A[-1]-W)\n b=abs(max(A[:N-1])-A[-1])\n print(max(a,b)", "jacc_sim": 0.9310344827586207, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [88, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u941407962", "n_user": "u941407962", "pos": "N, Y, Z = map(int, input().split())\nAs = list(map(int, input().split()))\ndpx, dpy = [0]*(N-1), [0]*(N-1)\n#dpx[i] = min(dpy[i+1]...dpy[N-2], abs(As[N-1]-As[i]))\n#dpy[i] = max(dpx[i+1]...dpx[N-2], abs(As[N-1]-As[i]))\nfor i in range(N-2, -1, -1):\n mny, mxx = 10**10, 0\n for j in range(i+1, N-1):\n mny = min(mny, dpy[j])\n mxx = max(mxx, dpx[j])\n dpx[i] = min(mny, abs(As[N-1]-As[i]))\n dpy[i] = max(mxx, abs(As[N-1]-As[i]))\ndpx.append(abs(As[N-1]-Z))\nprint(max(dpx))\n", "neg": "N, Y, Z = map(int, input().split())\nAs = list(map(int, input().split()))\ndpx, dpy = [0]*(N-1), [0]*(N-1)\n#dpx[i] = min(dpy[i+1]...dpy[N-2], abs(As[N-1]-As[i]))\n#dpy[i] = max(dpx[i+1]...dpx[N-2], abs(As[N-1]-As[i]))\nfor i in range(N-2, -1, -1):\n mny, mxx = 10**10, 0\n for j in range(i+1, N-1):\n mny = min(mny, dpy[j])\n mxx = max(mxx, dpx[j])\n dpx[i] = min(mny, abs(As[N-1]-As[i]))\n dpy[i] = min(mxx, abs(As[N-1]-As[i]))\n#print(dpx)\nprint(max(max(dpx),abs(As[N-1]-Z)))\n", "jacc_sim": 0.9743589743589743, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [279, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u673361376", "n_user": "u673361376", "pos": "N,Z,W = map(int,input().split())\nA = list(map(int,input().split()))\nif N == 1:\n print(abs(A[0]-W))\n exit()\n \nif abs(A[-1]-A[-2]) >= abs(A[-1]-W):\n print(abs(A[-1]-A[-2]))\nelse:\n print(abs(A[-1]-W))\n", "neg": "N,Z,W = map(int,input().split())\nA = list(map(int,input().split()))\nif abs(A[-1]-A[-2]) >= abs(A[-1]-W):\n print(abs(A[-1]-A[-2]))\nelse:\n print(abs(A[-1]-W))\n", "jacc_sim": 0.9259259259259259, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [108, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u015768390", "n_user": "u015768390", "pos": "n,z,w=map(int,input().split())\nA=[int(x) for x in input().split()]\nprint(max(abs(A[n-2]-A[n-1]),abs(A[n-1]-w))) if n!=1 else print(abs(A[0]-w))\n", "neg": "n,z,w=map(int,input().split())\nA=[int(x) for x in input().split()]\nprint(max(abs(A[n-2]-A[n-1]),abs(A[n-1],w))) if n!=1 else print(abs(a[0]-w))", "jacc_sim": 0.9655172413793104, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [79, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u536113865", "n_user": "u536113865", "pos": "ai = lambda: list(map(int,input().split()))\nn, z, w = ai()\na = ai()\nif n == 1:\n print(abs(a[-1]-w))\nelse:\n print(max(abs(a[-1]-w), abs(a[-1]-a[-2])))\n", "neg": "ai = lambda: list(map(int,input().split()))\nn, z, w = ai()\na = ai()\nif n == a:\n print(abs(a[-1]-w))\nelse:\n print(max(abs(a[-1]-w), abs(a[-1]-a[-2])))\n", "jacc_sim": 1.0, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [79, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u692632484", "n_user": "u236127431", "pos": "N,Z,W=[int(i) for i in input().split()]\na=[int(i) for i in input().split()]\n\nif N>1:\n print(max(abs(a[-1]-W),abs(a[-2]-a[-1])))\nelse:\n print(abs(a[0]-W))", "neg": "N,Z,W=map(int,input().split())\na=[int(i) for i in input().split()]\nif N==1:\n print(W-a[0])\nelse:\n print(max(abs(W-a[-1]),abs(a[-2]-a[-1])))", "jacc_sim": 0.9310344827586207, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [83, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u257974487", "n_user": "u257974487", "pos": "N, Z, W = map(int,input().split())\np = list(map(int,input().split()))\na = abs(p[N-2] - p[N-1])\nb = abs(p[N-1] - W)\nprint(max(a, b))\n", "neg": "N, Z, W = map(int,input().split())\np = list(map(int,input().split()))\na = abs(p[1] - p[2])\nb = abs(p[2] - W)\nprint(max(a, b))", "jacc_sim": 1.0, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [70, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u722641375", "n_user": "u722641375", "pos": "\ndef main():\n N,Z,W = map(int,input().split())\n a = list(map(int,input().split()))\n\n print(max(abs(a[N-1]-W),abs(a[N-1]-a[N-2])))\n\nif __name__ == '__main__':\n main()", "neg": "\ndef main():\n N,Z,W = map(int,input().split())\n a = list(map(int,input().split()))\n\n print(max(abs(a[N-1]-W,abs(a[N-1]-a[N-2]))))\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [84, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u410717334", "n_user": "u410717334", "pos": "import math\nN,Z,W=list(map(int,input().split()))\na=list(map(int,input().split()))\nb=math.fabs(a[N-1]-W)\nc=math.fabs(a[N-2]-a[N-1])\nprint(int(max(b,c)))", "neg": "import math\nN,Z,W=list(map(int,input().split()))\ni=0\na=list(map(int,input().split()))\nb=math.fabs(a[N-1]-W)\nc=math.fabs(a[N-2]-a[N-1])\nprint(max(b,c))", "jacc_sim": 0.9285714285714286, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [83, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u751863169", "n_user": "u751863169", "pos": "#!/usr/bin/env python\n\ndef main():\n N, Z, W = map(int, input().split(\" \"))\n a = list(map(int, input().split(\" \")))\n \n if N == 1:\n print(abs(a[0] - W))\n else:\n print(max(abs(a[N - 1] - W), abs(a[N - 2] - a[N - 1])))\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python\n\ndef main():\n N, Z, W = map(int, input().split(\" \"))\n a = list(map(int, input().split(\" \")))\n \n if N == 1:\n print(abs(a[0] - W))\n else:\n print(max(abs(a[0] - W), abs(a[N - 2] - a[N - 1])))\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [123, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u039623862", "n_user": "u039623862", "pos": "n, x, y = map(int, input().split())\na = list(map(int, input().split()))\n\nif n == 1:\n print(abs(a[-1] - y))\nelse:\n print(max(abs(a[-1] - y), abs(a[-1] - a[-2])))\n", "neg": "n, x, y = map(int, input().split())\na = list(map(int, input().split()))\n\nif n == 1:\n print(abs(a[0] - y))\nelse:\n print(max(abs(a[0] - y), abs(a[-1] - a[-2])))\n", "jacc_sim": 0.9615384615384616, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [79, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03552", "p_user": "u422104747", "n_user": "u422104747", "pos": "l=input().split()\nn=int(l[0])\nw=int(l[2])\nl=input().split()\na=[]\nfor i in range(n):\n a.append(int(l[n-1-i]))\ns=[]\nm=[]\nif n>=3:\n s.append(abs(a[1]-a[0]))\n s.append(max(abs(a[2]-a[0]),abs(a[1]-a[0])))\n m=[s[0],min(s[0],s[1])]\n x=min(abs(a[2]-a[0]),m[0])\n for i in range(2,n-2):\n if(max(abs(a[i]-a[0]),m[i-2])>x):\n x=max(abs(a[i]-a[0]),m[i-2])\n s.append(max(abs(a[i+1]-a[0]),x,abs(a[1]-a[0])))\n m.append(min(s[-1],m[-1]))\n s.reverse()\n if n==3:\n del(s[0])\n res=[abs(w-a[0]),abs(a[1]-a[0])]\n a.reverse()\n for i in range(n-2):\n res.append(min(abs(a[-2]-a[-1]),abs(a[i]-a[-1]),min(s[i:])))\n print(max(res))\nif n==2:\n print(max(abs(w-a[0]),abs(a[1]-a[0])))\nif n==1:\n print(abs(w-a[0]))\ns.append", "neg": "l=input().split()\nn=int(l[0])\nw=int(l[2])\nl=input().split()\na=[]\nfor i in range(n):\n a.append(int(l[n-1-i]))\ns=[]\nm=[]\nif n>=3:\n s.append(abs(a[1]-a[0]))\n s.append(max(abs(a[2]-a[0]),abs(a[1]-a[0])))\n m=[s[0],min(s[0],s[1])]\n x=min(abs(a[2]-a[0]),m[0])\n for i in range(2,n-2):\n if(max(abs(a[i]-a[0]),m[i-2])>x):\n x=max(abs(a[i]-a[0]),m[i-2])\n s.append(max(abs(a[i+1]-a[0]),x,abs(a[1]-a[0])))\n m.append(min(s[-1],m[-1]))\n s.reverse()\n if n==3:\n del(s[0])\n res=[abs(w-a[0]),abs(a[-2]-a[-1])]\n a.reverse()\n for i in range(n-2):\n res.append(min(abs(a[-2]-a[-1]),abs(a[i]-a[-1]),min(s[i:])))\n print(max(res))\nif n==2:\n print(max(abs(w-a[0]),abs(a[1]-a[0])))\nif n==1:\n print(abs(w-a[0]))", "jacc_sim": 1.0, "nl": "You have a deck of N cards, each with an integer written on it. Two players, X and Y, take turns drawing cards from the deck and discarding the card in their hand, keeping the last drawn card instead. The game ends when there are no more cards in the deck. The score is the absolute difference of the integers on the cards in the players' hands. X aims to maximize the score, while Y aims to minimize it. The task is to determine the final score of the game. Constraints: N (number of cards) is between 1 and 2000, and the integers on the cards and initial hands are between 1 and 10^9. The input format is N, Z, W, followed by the integers on the cards. The output is the final score.", "before_after_length": [445, 441], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03553", "p_user": "u892251744", "n_user": "u892251744", "pos": "from copy import deepcopy\nN = int(input())\na0 = list(map(int, input().split()))\n\nfor i in range(N, 0, -1):\n if a0[i - 1] < 0:\n tmp = 0\n b = []\n for j in range(1, 101):\n if i * j - 1 >= N:\n break\n tmp += a0[i * j - 1]\n b.append(i * j - 1)\n if tmp < 0:\n for j in b:\n a0[j] = 0\n\nfor k1 in range(N, 0, -1):\n for k2 in range(k1-1, 0, -1):\n a = deepcopy(a0)\n for j in range(1, 101):\n if k1*j-1 >= N:\n break\n a[k1*j-1] = 0\n for j in range(1, 101):\n if k2*j-1 >= N:\n break\n a[k2*j-1] = 0\n for i in range(N, 0, -1):\n if a[i - 1] < 0:\n tmp = 0\n b = []\n for j in range(1, 101):\n if i * j - 1 >= N:\n break\n tmp += a[i * j - 1]\n b.append(i * j - 1)\n if tmp < 0:\n for j in b:\n a[j] = 0\n\n for i in range(N, 0, -1):\n if a0[i - 1] < 0:\n tmp = 0\n b = []\n for j in range(1, 101):\n if i * j - 1 >= N:\n break\n tmp += a0[i * j - 1]\n b.append(i * j - 1)\n if tmp < 0:\n for j in b:\n a0[j] = 0\n\n if sum(a) > sum(a0):\n a0 = a\n\nprint(sum(a0))\n", "neg": "from copy import deepcopy\nN = int(input())\na0 = list(map(int, input().split()))\n\nfor k1 in range(N, 0, -1):\n for k2 in range(k1-1, 0, -1):\n a = deepcopy(a0)\n for j in range(1, 101):\n if k1*j-1 >= N:\n break\n a[k1*j-1] = 0\n for j in range(1, 101):\n if k2*j-1 >= N:\n break\n a[k2*j-1] = 0\n for i in range(N, 0, -1):\n if a[i - 1] < 0:\n tmp = 0\n b = []\n for j in range(1, 101):\n if i * j - 1 >= N:\n break\n tmp += a[i * j - 1]\n b.append(i * j - 1)\n if tmp < 0:\n for j in b:\n a[j] = 0\n if sum(a) > sum(a0):\n a0 = a\n\nprint(sum(a0))\n", "jacc_sim": 1.0, "nl": "You are given N gemstones labeled from 1 to N. You can select a positive integer x and smash all gems labeled with multiples of x. For each gem i that remains without getting smashed, you receive a_i yen. By optimally performing the operation, determine the maximum amount of money that can be earned. Constraints: 1 \u2264 N \u2264 100, |a_i| \u2264 10^9. Input is given as N followed by a list of a_i values. Output the maximum amount of money that can be earned.", "before_after_length": [504, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u533039576", "n_user": "u533039576", "pos": "from heapq import heappush, heappop\n\n\ndef dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:\n # graph[v_from] = [(cost, v_to), ...]\n dist = [INF] * n\n\n dist[v_s] = 0\n heap = [(0, v_s)] # heap = [(dist[v], v), ...]\n while heap:\n dist2v, v_from = heappop(heap)\n if dist[v_from] < dist2v:\n continue\n for cost, v_to in graph[v_from]:\n dist_cand = dist2v + cost\n if dist_cand < dist[v_to]:\n dist[v_to] = dist_cand\n heappush(heap, (dist[v_to], v_to))\n return dist\n\n\nk = int(input())\n\ngraph = [[] for _ in range(k)]\nfor i in range(1, k):\n graph[i].append((1, (i + 1) % k))\n graph[i].append((0, 10 * i % k))\n\ndist = dijkstra(graph, k, 1)\nans = dist[0] + 1\nprint(ans)\n", "neg": "from heapq import heappush, heappop\n\n\ndef dijkstra(graph: list, n: int, v_s: int, INF: int = float('inf')) -> list:\n # graph[v_from] = [(cost, v_to), ...]\n dist = [INF] * n\n\n dist[v_s] = 0\n heap = [(0, v_s)] # heap = [(dist[v], v), ...]\n while heap:\n dist2v, v_from = heappop(heap)\n if dist[v_from] < dist2v:\n continue\n for cost, v_to in graph[v_from]:\n dist_cand = dist2v + cost\n if dist_cand < dist[v_to]:\n dist[v_to] = dist_cand\n heappush(heap, (dist[v_to], v_to))\n return dist\n\n\nk = int(input())\n\ngraph = [[] for _ in range(k)]\nfor i in range(1, k):\n graph[i - 1].append((1, i + 1))\n graph[i].append((0, 10 * i % k))\n\ndist = dijkstra(graph, k, 1)\nans = dist[0]\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [322, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u007550226", "n_user": "u007550226", "pos": "import heapq\ndef main():\n k= int(input())\n brdict = {}\n for i in range(1,k):\n if i==k-1:\n if (10*(k-1))%k==0:\n brdict[i]= [(0,0)]\n else:\n brdict[i] = [(0,1)]\n else:\n if i!=(i*10)%k:\n brdict[i] = [((i*10)%k,0)]\n if (i*10)%k!=i+1:\n brdict[i] = brdict.get(i,[])+[(i+1,1)]\n start=1\n cost=[i for i in range(k)]\n cost[0]=k\n fixed=[False]*k\n fixed[start]=True\n akouho = [(1,start)]\n heapq.heapify(akouho)\n while not all(fixed):\n (fcost,fnode) = heapq.heappop(akouho)\n if fnode==0:break\n fixed[fnode]=True\n for br in brdict[fnode]:\n if not fixed[br[0]]:\n if cost[br[0]] > fcost + br[1]:\n cost[br[0]] = fcost + br[1]\n heapq.heappush(akouho,(cost[br[0]],br[0]))\n if akouho==[]:break\n print(cost[0])\nif __name__ == '__main__':\n main()", "neg": "import heapq\ndef main():\n k=int(input())\n brdict = {}\n for i in range(1,k):\n if i==k-1:brdict[i] = [(0,1)]\n else:\n brdict[i] = [((i*10)%k,0)]\n if (i*10)%k!=i+1:brdict[i] += [(i+1,1)]\n start=1\n cost=[i for i in range(k)]\n cost[0]=k\n fixed=[False]*k\n fixed[start]=True\n akouho = [(1,start)]\n heapq.heapify(akouho)\n while not all(fixed):\n (fnode,fcost) = heapq.heappop(akouho)\n if fnode==0:break\n fixed[fnode]=True\n for br in brdict[fnode]:\n if not fixed[br[0]]:\n if cost[br[0]] > fcost + br[1]:\n cost[br[0]] = fcost + br[1]\n heapq.heappush(akouho,(br[0],cost[br[0]]))\n print(cost[0])\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9814814814814815, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [389, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u332906195", "n_user": "u332906195", "pos": "import collections\n\nK = int(input())\n\nq = collections.deque([(1, 0)])\nv = {1}\n\nwhile len(q) > 0:\n c, p = q.popleft()\n v.add(c)\n if c == 0:\n break\n\n n1, n10 = (c + 1) % K, (c * 10) % K\n if not n1 in v:\n q.append((n1, p + 1))\n if not n10 in v:\n q.appendleft((n10, p))\n\nprint(p + 1)\n", "neg": "import collections\n\nN = int(input())\n\nq = collections.deque([(1, 0)])\nv = {1}\n\nwhile len(q) > 0:\n c, p = deque.popleft()\n v.add(c)\n if c == 0:\n break\n\n n1, n10 = (c + 1) % N, (c * 10) % n\n if not n1 in v:\n q.append((n1, p + 1))\n if not n10 in v:\n q.appendleft((n10, p))\n\nprint(p + 1)\n", "jacc_sim": 0.9285714285714286, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [146, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u844005364", "n_user": "u844005364", "pos": "import heapq\n\n\ndef small_multiple(k):\n # k\u306e\u500d\u6570\u3067\u5404\u6841\u306e\u7dcf\u6570\u304c\u6700\u3082\u5c0f\u3055\u304f\u306a\u308b\u3088\u3046\u306a\u3001\u5404\u6841\u306e\u7dcf\u6570\n dist = [float(\"inf\")] * k\n q = []\n # k\u3067\u5272\u3063\u305f\u4f59\u308a\u304c1\u306b\u306a\u308b\u3088\u3046\u306a\u6700\u5c0f\u306e\u6570\u306f1\n heapq.heappush(q, (1, 1))\n\n while q:\n n, c = heapq.heappop(q)\n if dist[n] <= c:\n continue\n dist[n] = c\n\n if dist[(n + 1) % k] > c + 1:\n heapq.heappush(q, ((n + 1) % k, c + 1))\n if dist[(n * 10) % k] > c:\n heapq.heappush(q, ((n * 10) % k, c))\n\n print(dist[0])\n\n\ndef main():\n k = int(input())\n small_multiple(k)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import heapq\n\n\ndef small_multiple(k):\n # k\u306e\u500d\u6570\u3067\u5404\u6841\u306e\u7dcf\u6570\u304c\u6700\u3082\u5c0f\u3055\u304f\u306a\u308b\u3088\u3046\u306a\u3001\u5404\u6841\u306e\u7dcf\u6570\n dist = [float(\"inf\")] * k\n q = []\n # k\u3067\u5272\u3063\u305f\u4f59\u308a\u304c1\u306b\u306a\u308b\u3088\u3046\u306a\u6700\u5c0f\u306e\u6570\u306f1\n heapq.heappush(q, (1, 1))\n\n while q:\n n, c = heapq.heappop(q)\n if dist[n] <= c:\n continue\n print(n, c)\n dist[n] = c\n\n if dist[(n+1) % k] > c + 1:\n heapq.heappush(q, ((n + 1) % k, c + 1))\n if dist[(n*10) % k] > c:\n heapq.heappush(q, ((n * 10) % k, c))\n\n print(dist[0])\n\n\ndef main():\n\tk = int(input())\n small_multiple(k)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [357, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u391731808", "n_user": "u391731808", "pos": "from collections import deque\nK = int(input())\nE = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] \u304ccost 0, E[i][1]\u304ccost 1\nINF = K*10\nV = [INF] * (K)\nV[1] = 1\nq = deque([1])\ni = 1\nwhile q:\n i = q.popleft()\n if V[E[i][0]] > V[i]:\n q.appendleft(E[i][0])\n V[E[i][0]] = V[i]\n if V[E[i][1]] > V[i]+1:\n q.append(E[i][1])\n V[E[i][1]] = V[i]+1\nprint(V[0])", "neg": "from collections import deque\nK = int(input())\nE = [[(i*10)%K,(i+1)%K] for i in range(K)] # E[i][0] \u304ccost 0, E[i][1]\u304ccost 1\nV = [-1] * (K)\nV[1] = 1\nq = deque([1])\ni = 1\nwhile V[0] == -1:\n i = q.popleft()\n q.appendleft(E[i][0])\n V[E[i][0]] = V[i]\n if V[E[i][1]] == -1:\n q.append(E[i][1])\n V[E[i][1]] = V[i]+1\nprint(V[0])", "jacc_sim": 0.925, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [207, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u997521090", "n_user": "u760794812", "pos": "from collections import deque\nq = deque()\nK = int(input())\nq.append((1, 1))\nm = {}\nwhile len(q):\n n, s = q.popleft()\n if n in m:continue\n m[n] = s\n q.appendleft((n * 10 % K, s))\n q.append(((n + 1) % K, s + 1))\nprint(m[0])", "neg": "from collections import deque\n#q = deque()\nq= []\nm = {}\nK = int(input())\nq.append((1,1))\nwhile len(q):\n #n,s = q.popleft()\n n,s = q.pop(0)\n if n in m:\n continue\n m[n] = s\n #q.appendleft((n*10%K,s))\n q.insert(0,(n*10%K,s))\n #q.append(((n+1)%K,s+1))\n q.append(((n+1)%K,s+1))\nprint(m[0])\nprint(m)", "jacc_sim": 0.9230769230769231, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [97, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03558", "p_user": "u865741247", "n_user": "u865741247", "pos": "import math\nfrom collections import defaultdict,deque\nimport numpy as np\nimport heapq\nINF=10**12+1\na=input()\na=int(a)\ngraph = defaultdict(list)\nfor i in range(a):\n graph[i].append((1,(i+1)%a))\n graph[i].append((0,(i*10)%a))\ncosts=[INF]*a\ncosts[1]=1\nque = [] #\u5f8c\u308d\u306e\u65b9\u304c\u512a\u5148\u5ea6\u9ad8\u3044queue\nque.append((0,1))\nwhile len(que)!=0:\n temp=heapq.heappop(que)\n now=temp[1]\n v_now=graph[now]\n for c,n in v_now: #v now\u304b\u3089\u51fa\u3066\u308b\u7dcf\u3066\u306e\u30ce\u30fc\u30c9\u306b\u3064\u3044\u3066\u64cd\u4f5c\u3059\u308b c\u2192\u30ce\u30fc\u30c9\u306e\u30b3\u30b9\u30c8 n\u2192\u884c\u304d\u5148\n if costs[n]>c+costs[now]: #\u6539\u5584\u3057\u305f\u306e\u3067\u305d\u306ev\u306f\u8d70\u67fb\u306e\u4f59\u5730\u3042\u308a\n costs[n]=c+costs[now]\n heapq.heappush(que,(c,n))\n \nprint(costs[0])\n ", "neg": "import math\nfrom collections import defaultdict,deque\n\nINF=10**12+1\na=input()\na=int(a)\ngraph = defaultdict(list)\nfor i in range(a):\n graph[i].append((1,(i+1)%a))\n graph[i].append((0,(i*10)%a))\ncosts=[INF]*a\ncosts[1]=1\nque = [] #\u5f8c\u308d\u306e\u65b9\u304c\u512a\u5148\u5ea6\u9ad8\u3044queue\nque.append((0,1))\nwhile len(que)!=0:\n temp=que.pop()\n now=temp[1]\n v_now=graph[now]\n for c,n in v_now: #v now\u304b\u3089\u51fa\u3066\u308b\u7dcf\u3066\u306e\u30ce\u30fc\u30c9\u306b\u3064\u3044\u3066\u64cd\u4f5c\u3059\u308b c\u2192\u30ce\u30fc\u30c9\u306e\u30b3\u30b9\u30c8 n\u2192\u884c\u304d\u5148\n if costs[n]>c+costs[now]: #\u6539\u5584\u3057\u305f\u306e\u3067\u305d\u306ev\u306f\u8d70\u67fb\u306e\u4f59\u5730\u3042\u308a\n costs[n]=c+costs[now]\n que.append((c,n))\n que=sorted(que,reverse=True)\nprint(costs[0])\n ", "jacc_sim": 0.900990099009901, "nl": "Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The input is given as a single integer K, and the output should be the smallest possible sum of the digits in the decimal notation of a positive multiple of K. The constraints are that K is an integer and 2 \u2264 K \u2264 10^5.", "before_after_length": [407, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u370721525", "n_user": "u370721525", "pos": "import bisect\nfrom collections import deque\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nd = deque([])\nfor i in range(N):\n n = bisect.bisect_right(C, B[N-1-i])\n if len(d) == 0:\n d.appendleft(N-n)\n else:\n d.appendleft(N-n+d[0])\n \nans = 0\nfor i in range(N):\n m = bisect.bisect_right(B, A[i])\n if m < N:\n ans += d[m]\nprint(ans)", "neg": "import bisect\nfrom collections import deque\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nd = deque([])\nfor i in range(N):\n n = bisect.bisect_right(C, B[N-1-i])\n if len(d) == 0:\n d.appendleft(N-n)\n else:\n d.appendleft(N-n+d[0])\n \nans = 0\nfor i in range(N):\n n = bisect.bisect_right(B, A[i])\n ans += d[n]\nprint(ans)", "jacc_sim": 0.9523809523809523, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [200, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u860649548", "n_user": "u860649548", "pos": "import bisect\nimport sys\nn = int(input())\nup = sorted(list(map(int, input().split())))\nmid = sorted(list(map(int, input().split())))\nlow = sorted(list(map(int, input().split())))\nans = 0\nfor i in range(len(mid)):\n pre = bisect.bisect_left(up, mid[i])\n over = len(low) - bisect.bisect(low, mid[i])\n ans += pre * over\n\nprint(ans)\n", "neg": "import bisect\nimport sys\nn = int(input())\nup = sorted(list(set(map(int, input().split()))))\nmid = sorted(list(set(map(int, input().split()))))\nlow = sorted(list(set(map(int, input().split()))))\nans = 0\nfor i in range(len(mid)):\n pre = bisect.bisect_left(up, mid[i])\n over = len(low) - bisect.bisect(low, mid[i])\n ans += pre * over\n\nprint(ans)\n", "jacc_sim": 0.9722222222222222, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [128, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u452885705", "n_user": "u452885705", "pos": "import bisect\n\nN= int(input())\na = map(int, input().split(\" \"))\nb = map(int, input().split(\" \"))\nc = map(int, input().split(\" \"))\n\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\nresult = 0\nfor i in b:\n ta = bisect.bisect_left(a,i)\n tc = bisect.bisect_right(c,i)\n result += ta*(N-tc)\nprint(result)", "neg": "import bisect\n\nN= int(input())\na = map(int, input().split(\" \"))\nb = map(int, input().split(\" \"))\nc = map(int, input().split(\" \"))\n\na = sorted(a)\nb = sorted(b)\nc = sorted(c,reverse=True)\n\nresult = 0\nfor i in b:\n ta = bisect.bisect_left(a,i)\n tc = bisect.bisect_right(c,i)\n result += ta*(N-tc)\nprint(result)", "jacc_sim": 0.9393939393939394, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [129, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u951480280", "n_user": "u951480280", "pos": "import bisect\n\nn=int(input())\na=sorted(map(int,input().split()))\nb=sorted(map(int,input().split()))\nc=sorted(map(int,input().split()))\n\nans=0\n\nfor i in range(n):\n num1 = bisect.bisect_left(a,b[i])\n num2 = n - bisect.bisect(c,b[i])\n ans += num1*num2\n\nprint(ans)", "neg": "import bisect\n\nn=int(input())\na=sorted(map(int,input().split()))\nb=sorted(map(int,input().split()))\nc=sorted(map(int,input().split()))\n\nans=0\n\nfor i in range(n):\n num1 = bisect.bisect(a,b[i])\n num2 = n - bisect.bisect_left(c,b[i])\n ans += num1*num2\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [119, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u690037900", "n_user": "u690037900", "pos": "import sys\nimport bisect\ninput = sys.stdin.readline\nnum=0\nn=int(input())\ntop=list(map(int,input().split()))\nmid=list(map(int,input().split()))\nund=list(map(int,input().split()))\ntop.sort()\nmid.sort()\nund.sort()\nfor i in mid:\n a=bisect.bisect_left(top,i)\n c=n-bisect.bisect_right(und,i)\n num+=a*c\nprint(num)", "neg": "import bisect\nnum=0\nn=int(input())\ntop=list(map(int,input().split()))\nmid=list(map(int,input().split()))\nund=list(map(int,input().split()))\ntop.sort()\nmid.sort()\nund.sort()\nfor i in mid:\n a=bisect.bisect_left(top,i)\n c=num-bisect.bisect_right(und,i)\n num+=a*c\nprint(num)", "jacc_sim": 0.9117647058823529, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [139, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u241159583", "n_user": "u241159583", "pos": "import bisect\nN = int(input())\nA = []\nfor _ in range(3):\n a = list(map(int, input().split()))\n a.sort()\n A.append(a)\n \nans = 0\nfor b in A[1]:\n a = bisect.bisect_left(A[0], b)\n c = bisect.bisect_right(A[2], b)\n ans += a * (N-c)\nprint(ans) ", "neg": "import bisect\nN = int(input())\nA = []\nfor _ in range(3):\n a = list(map(int, input().split()))\n a.sort()\n A.append(a)\nprint(A)\nans = 0\nfor b in A[1]:\n a = bisect.bisect_left(A[0], b)\n c = bisect.bisect_right(A[2], b)\n ans += a * (N-c)\nprint(ans) ", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [117, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u768896740", "n_user": "u905582793", "pos": "import bisect\n\n\nn = int(input())\na =list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\nans = 0\nfor i in range(n):\n num = b[i]\n x = bisect.bisect_left(a, num)\n y = bisect.bisect_right(c, num)\n ans += x * (n - y)\n\nprint(ans)", "neg": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nb.sort()\nc.sort()\nans=0\nfor i in range(n):\n x=b[i]\n y=bisect.bisect_left(a,x)\n z=bisect.bisect_right(c,x)\n ans+=(n-z)*y\nprint(ans)", "jacc_sim": 0.9444444444444444, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [138, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u345966487", "n_user": "u345966487", "pos": "from bisect import*\nN=int(input())\nr=lambda:sorted(map(int, input().split()))\nA,B,C,w=r(),r(),r(),[0]*(N+1)\nfor i in range(N-1,-1,-1):w[i]=w[i+1]+N-bisect(C,B[i])\nprint(sum(w[bisect(B,A[i])]for i in range(N)))", "neg": "from bisect import*\nr=lambda:sorted(map(int,input().split()))\nN=r()[0]\nA,B,C,w,s=r(),r(),r(),[0]*N,0\nfor i in range(N-1,-1,-1):s=w[i]=s+N-bisect(C,B[i])\nprint(sum(w[bisect(B,A[i])]for i in range(N)))", "jacc_sim": 0.9714285714285714, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [114, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u089142196", "n_user": "u089142196", "pos": "import bisect\n\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\n\nA.sort()\nB.sort()\nC.sort()\nans=0\n\nfor b in B: #O(N)\n s = bisect.bisect_left(A,b) #O(logN)\n t = bisect.bisect_right(C,b) #O(logN)\n #print(s,N-t,s*(N-t))\n ans += s*(N-t)\n \nprint(ans)\n", "neg": "import bisect\n\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\n\nA.sort()\nB.sort()\nC.sort()\nans=0\n\nfor b in B: #O(N)\n s = bisect.bisect_left(A,b) #O(logN)\n t = bisect.bisect_right(C,b) #O(logN)\n print(s,N-t,s*(N-t))\n ans += s*(N-t)\n \nprint(ans)\n", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [163, 162], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u995053308", "n_user": "u995053308", "pos": "import sys\nimport os\nimport re\nimport datetime\nimport bisect\n\ndef Test(value):\n a = [1,3,5]\n #x = 4\n\n insert_index = bisect.bisect_left(a, value)\n \n print(\"insert_index = \", insert_index)\n \nif False: \n while(True): \n Test(int(input('? ')));\n sys.exit()\n \nN = int(input())\n\npartsNumA = sorted(map(int, input().split()))\npartsNumB = sorted(map(int, input().split()))\npartsNumC = sorted(map(int, input().split()))\n\n# B\u306b\u5bfe\u3057\u3066A\u306e\u500b\u6570\u306eB\u306b\u3088\u308b\u30eb\u30fc\u30d7\npartsNumSumBa = []\nsumA = 0\n#for i in range(N):\nfor curPartsB in partsNumB:\n indexA = bisect.bisect_left(partsNumA, curPartsB)\n numA = indexA\n sumA += numA\n partsNumSumBa.append(sumA)\n\nif False:\n print(\"Sorted A\" , partsNumA)\n print(\"Sorted B\" , partsNumB)\n print(\"Sorted C\" , partsNumC)\n\n print(\"B loop\" , partsNumSumBa)\n\n# C\u306b\u5bfe\u3057\u3066B\u306e\u500b\u6570\u306eC\u306b\u3088\u308b\u30eb\u30fc\u30d7\nsumBAll = 0\nfor curPartsC in partsNumC:\n indexB = bisect.bisect_left(partsNumB, curPartsC)\n if indexB == 0:\n continue\n numB = partsNumSumBa[indexB - 1]\n sumBAll += numB\n \nprint(sumBAll)", "neg": "# -*- coding: cp932 -*-\n\nimport sys\nimport os\nimport re\nimport datetime\nimport bisect\n\ndef Test(value):\n a = [1,3,5]\n #x = 4\n\n insert_index = bisect.bisect_left(a, value)\n \n print(\"insert_index = \", insert_index)\n\n####### main #######\n \nif False: \n while(True): \n Test(int(input('? ')));\n sys.exit()\n \nN = int(input())\n\npartsNumA = sorted(map(int, input().split()))\npartsNumB = sorted(map(int, input().split()))\npartsNumC = sorted(map(int, input().split()))\n\n# B\u306b\u5bfe\u3057\u3066A\u306e\u500b\u6570\u306eB\u306b\u3088\u308b\u30eb\u30fc\u30d7\npartsNumSumBa = []\nsumA = 0\nfor curPartsB in partsNumB:\n indexA = bisect.bisect_left(partsNumA, curPartsB)\n numA = indexA\n sumA += numA\n partsNumSumBa.append(sumA)\n\n# C\u306b\u5bfe\u3057\u3066B\u306e\u500b\u6570\u306eC\u306b\u3088\u308b\u30eb\u30fc\u30d7\nsumBAll = 0\nfor curPartsC in partsNumC:\n indexB = bisect.bisect_left(partsNumB, curPartsC)\n if indexB == 0:\n continue\n numB = partsNumSumBa[indexB - 1]\n sumBAll += numB\n \nprint(sumBAll)", "jacc_sim": 0.9012345679012346, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [473, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u426649993", "n_user": "u426649993", "pos": "from bisect import bisect_right\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n a = sorted(a)\n b = sorted(b)\n c = sorted(c)\n\n ans = 0\n\n # \u307e\u305a\u3042\u308bb\u3092\u9078\u3093\u3060\u6642\u306ec\u306e\u7d44\u307f\u5408\u308f\u305b\u306e\u6570\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u308b\u3002\n clist = [0] * n\n clist[n-1] = n - bisect_right(c, b[n-1])\n for i in range(n-2, -1, -1):\n clist[i] = n - bisect_right(c, b[i]) + clist[i+1]\n\n for aa in a:\n b_pos = bisect_right(b, aa)\n if b_pos != n:\n ans += clist[b_pos]\n\n print(ans)\n", "neg": "from bisect import bisect_right\n\nif __name__ == \"__main__\":\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n a = sorted(a)\n b = sorted(b)\n c = sorted(c)\n\n ans = 0\n\n # \u307e\u305a\u3042\u308bb\u3092\u9078\u3093\u3060\u6642\u306ec\u306e\u7d44\u307f\u5408\u308f\u305b\u306e\u6570\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u308b\u3002\n clist = [0] * n\n clist[n-1] = n - bisect_right(c, b[n-1])\n for i in range(n-2, -1, -1):\n clist[i] = n - bisect_right(c, b[i]) + clist[i+1]\n\n for aa in a:\n b_pos = bisect_right(b, aa)\n ans += clist[b_pos]\n\n print(ans)\n", "jacc_sim": 0.984375, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [314, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u871352270", "n_user": "u871352270", "pos": "import bisect\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nali = [0] * (N+1)\nbli = [N - bisect.bisect_left(C,B[i]+1) for i in range(N)]\nfor i in range(N):\n ali[i+1] = ali[i] + bli[i]\nprint(sum([ali[N]-ali[bisect.bisect_left(B,A[i]+1)] for i in range(N)]))", "neg": "import bisect\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nali = [0] * (N+1)\nbli = [N - bisect.bisect_left(C,B[i]) for i in range(N)]\nfor i in range(N):\n ali[i+1] = ali[i] + bli[i]\nprint(sum([ali[N]-ali[bisect.bisect_left(B,A[i])] for i in range(N)]))", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [164, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u871352270", "n_user": "u871352270", "pos": "from collections import defaultdict\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nad = defaultdict(lambda: -1)\ni, j = 0, 0\nwhile i < N and j < N:\n if A[i] < B[j]:\n ad[i] = j\n i += 1\n else:\n j += 1\nbd = defaultdict(lambda: -1)\ni, j = 0, 0\nwhile i < N and j < N:\n if B[i] < C[j]:\n bd[i] = j\n i += 1\n else:\n j += 1\ncsum = [0] * N\nfor i in range(N):\n if bd[i] >= 0:\n csum[i] = N-bd[i]\nbsum = [0]* N\ncnt = 0\nfor i in range(N):\n cnt += csum[N-1-i]\n bsum[N-1-i] = cnt\nans = 0\nfor i in range(N):\n if ad[i] >= 0:\n ans += bsum[ad[i]]\nprint(ans)", "neg": "N = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nad = defaultdict(lambda: -1)\ni, j = 0, 0\nwhile i < N and j < N:\n if A[i] < B[j]:\n ad[i] = j\n i += 1\n else:\n j += 1\nbd = defaultdict(lambda: -1)\ni, j = 0, 0\nwhile i < N and j < N:\n if B[i] < C[j]:\n bd[i] = j\n i += 1\n else:\n j += 1\ncsum = [0] * N\nfor i in range(N):\n if bd[i] >= 0:\n csum[i] = N-bd[i]\nbsum = [0]* N\ncnt = 0\nfor i in range(N):\n cnt += csum[N-1-i]\n bsum[N-1-i] = cnt\nans = 0\nfor i in range(N):\n if ad[i] >= 0:\n ans += bsum[ad[i]]\nprint(ans)", "jacc_sim": 0.9347826086956522, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [308, 303], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u189023301", "n_user": "u189023301", "pos": "import bisect\nimport sys\nreadline = sys.stdin.buffer.readline\n\n\ndef main():\n n = int(readline())\n a = list(map(int,readline().rsplit()))\n b = list(map(int,readline().rsplit()))\n c = list(map(int,readline().rsplit()))\n a.sort()\n c.sort()\n ans = 0\n for i in b:\n d = bisect.bisect_left(a, i)\n e = len(c) - bisect.bisect_right(c, i)\n ans += d * e\n print(ans)\n\nif __name__ == '__main__':\n main()\n", "neg": "import bisect\nimport sys\nreadline = sys.stdin.buffer.readline\n\n\ndef main():\n n = int(readline())\n a = list(map(int,readline().rsplit()))\n b = list(map(int,readline().rsplit()))\n c = list(map(int,readline().rsplit()))\n a.sort()\n c.sort()\n ans = 0\n for i in b:\n d = bisect.bisect_left(a, i)\n e = len(c) - bisect.bisect_right(c, i)\n print(d,e)\n ans += d * e\n print(ans)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [173, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u905582793", "n_user": "u905582793", "pos": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nb.sort()\nc.sort()\nans=0\nfor i in range(n):\n x=b[i]\n y=bisect.bisect_left(a,x)\n z=bisect.bisect_right(c,x)\n ans+=(n-z)*y\nprint(ans)", "neg": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nb.sort()\nc.sort()\nans=0\nfor i in range(n):\n x=a[i]\n y=bisect.bisect_right(x)\n z=bisect.bisect_right(b[y])\n ans+=n-z\nprint(ans)", "jacc_sim": 0.9428571428571428, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [137, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u463775490", "n_user": "u463775490", "pos": "import bisect\nn = int(input())\na = sorted(list(map(int,input().split())))\nb = sorted(list(map(int,input().split())))\nc = sorted(list(map(int,input().split())))\nans = 0\nfor i in range(n):\n l = (bisect.bisect_left(a,b[i]))*(n-bisect.bisect_right(c,b[i]))\n ans += l\nprint(ans)", "neg": "import bisect\nn = int(input())\na = sorted(list(map(int,input().split())))\nb = sorted(list(map(int,input().split())))\nc = sorted(list(map(int,input().split())))\nans = 0\nfor i in range(n):\n l = (bisect.bisect_left(a,b[i]))*(n-bisect.bisect_right(c,b[i]))\n ans += 1\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [119, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u703890795", "n_user": "u703890795", "pos": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\ns = 0\n\nA = sorted(A)\nB = sorted(B)\nC = sorted(C)\n\nia = -1\nic = -1\n\nfor b in B:\n while True:\n if ia == N-1 or A[ia+1]>=b: \n break\n ia += 1\n while True:\n if ic == N-1 or C[ic+1]>b:\n break\n ic += 1\n s += (ia+1)*(N-ic-1)\n \nprint(s)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\ns = 0\n\nA = sorted(A)\nB = sorted(B)\nC = sorted(C)\n\nia = 0\nic = 0\n\nfor b in B:\n while True:\n if ia == N-1 or A[ia+1]>=b: \n break\n ia += 1\n while True:\n if ic == N-1 or C[ic+1]>b:\n break\n ic += 1\n s += (ia+1)*(N-ic-1)\n \nprint(s)", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [178, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u668503853", "n_user": "u668503853", "pos": "import bisect\nN=int(input())\nA=sorted(list(map(int,input().split())))\nB=sorted(list(map(int,input().split())))\nC=sorted(list(map(int,input().split())))\ns=0\nfor b in B:\n a=bisect.bisect_left(A,b)\n c=N-bisect.bisect_right(C,b)\n s+=a*c\nprint(s)\n", "neg": "import bisect\nN=int(input())\nA=sorted(set(map(int,input().split())))\nB=sorted(set(map(int,input().split())))\nC=sorted(set(map(int,input().split())))\ns=0\nfor b in B:\n a=bisect.bisect_left(A,b)\n c=N-bisect.bisect_right(C,b)\n s+=a*c\nprint(s)", "jacc_sim": 0.9375, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [119, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u864453204", "n_user": "u864453204", "pos": "import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\ncnt = 0\nfor bb in b:\n anum = bisect.bisect_left(a, bb)\n cnum = n - bisect.bisect_right(c, bb)\n cnt += (anum * cnum)\nprint(cnt)", "neg": "import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\ncnt = 0\nfor bb in b:\n anum = bisect.bisect_left(a, bb)\n cnum = bisect.bisect_right(c, bb)\n cnt += (anum * cnum)\nprint(cnt)", "jacc_sim": 0.967741935483871, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [119, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u970449052", "n_user": "u537782349", "pos": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=0\na.sort()\nb.sort()\nc.sort()\nfor i in range(n):\n ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))\nprint(ans)", "neg": "import bisect\na = int(input())\nb = list(map(int, input().split()))\nb.sort()\nc = list(map(int, input().split()))\nd = list(map(int, input().split()))\nd.sort()\nans = 0\nfor i in range(a):\n ans += bisect.bisect_left(b, c[i]) * (a - bisect.bisect_right(d, c[i]))\n ", "jacc_sim": 0.9090909090909091, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [123, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u123824541", "n_user": "u123824541", "pos": "import bisect\n\nN = int(input())\n\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\ncount = 0\n\nfor i in range(len(B)):\n a_b = bisect.bisect_left(A,B[i])\n c_b = bisect.bisect_right(C,B[i])\n count += a_b * (N - c_b)\n\nprint(count)", "neg": "import bisect\n\nN = int(input())\n\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\ncount = 0\n\nfor i in range(len(B)):\n a_b = bisect.bisect_left(A,B[i])\n c_b = bisect.bisect_right(C,B[i])\n count += a_b * (N - c_b)\n\nprint(count)", "jacc_sim": 0.9714285714285714, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [146, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u885899351", "n_user": "u943057856", "pos": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nc.sort()\nans=0\nfor i in b:ans+=bisect.bisect_left(a,i)*(n-bisect.bisect_right(c,i))\nprint(ans)", "neg": "import bisect\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\nans=0\nfor i in b:\n x=bisect.bisect_left(a,i)\n y=bisect.bisect_right(c,i)\n ans+=x*(n-y)\n print(x,y)\nprint(ans)", "jacc_sim": 0.9032258064516129, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [110, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u859897687", "n_user": "u859897687", "pos": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nb.sort()\nc.sort()\ni,j,k=0,0,0\nm1=[]\nwhile ka[k]:\n j+=1\n k+=1\n else:\n m1.append(j)\n i+=1\nfor t in range(len(m1),len(b)):\n m1.append(j)\ni,j,k=0,0,0\nm2=[]\nwhile kb[k]:\n j+=m1[k]\n k+=1\n else:\n m2.append(j)\n i+=1\nfor t in range(len(m2),len(c)):\n m2.append(j)\nprint(sum(m2))", "neg": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na.sort()\nb.sort()\nc.sort()\ni,j=0,0\nm1=[]\nfor k in a:\n if b[i]>k:\n j+=1\n else:\n m1.append(j)\nfor t in range(len(m1),len(b)):\n m1.append(j)\ni,j=0,0\nm2=[]\nfor k in range(n):\n if c[i]>k:\n j+=m1[b[k]]\n else:\n m2.append(j)\nfor t in range(len(m2),len(c)):\n m2.append(j)\nprint(sum(m2))\n", "jacc_sim": 0.925, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [265, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u760171369", "n_user": "u760171369", "pos": "from collections import defaultdict\nA = defaultdict(int)\nB = defaultdict(int)\nC = defaultdict(int)\n\nN = int(input())\na = [k for k in map(int, input().split())]\nb = [k for k in map(int, input().split())]\nc = [k for k in map(int, input().split())]\n\nfor k in range(N):\n A[a[k]] += 1\n B[b[k]] += 1\n C[c[k]] += 1\n\nAset = sorted(set(a))\nBset = sorted(set(b))\nCset = sorted(set(c))\n\ncnt = 0\nindex_a = 0\nindex_c = 0\na = 0\nc = N\n\nfor b in Bset:\n flag_a = False\n flag_c = False\n if a < N:\n for k in range(index_a, len(Aset)):\n if Aset[k] < b:\n a += A[Aset[k]] \n else:\n index_a = k\n flag_a = True\n break\n for k in range(index_c, len(Cset)):\n if Cset[k] <= b:\n c -= C[Cset[k]]\n else:\n index_c = k\n flag_c = True\n break\n if flag_a == False:\n a = N\n if flag_c == False:\n break\n cnt += a*c*B[b]\nprint(cnt)", "neg": "from collections import defaultdict\nA = defaultdict(int)\nB = defaultdict(int)\nC = defaultdict(int)\n\nN = int(input())\na = [k for k in map(int, input().split())]\nb = [k for k in map(int, input().split())]\nc = [k for k in map(int, input().split())]\n\nfor k in range(N):\n A[a[k]] += 1\n B[b[k]] += 1\n C[c[k]] += 1\n\nAset = sorted(set(a))\nBset = sorted(set(b))\nCset = sorted(set(c))\n\ncnt = 0\nindex_a = 0\nindex_c = 0\na = 0\nc = N\n\nfor b in Bset:\n flag_a = False\n flag_c = False\n for k in range(index_a, len(Aset)):\n if Aset[k] < b:\n a += A[Aset[k]] \n else:\n index_a = k\n flag_a = True\n break\n for k in range(index_c, len(Cset)):\n if Cset[k] <= b:\n c -= C[Cset[k]]\n else:\n index_c = k\n flag_c = True\n break\n if flag_a == False:\n a = len(Aset)\n if flag_c == False:\n c = 0\n cnt += a*c*B[b]\nprint(cnt)", "jacc_sim": 1.0, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [371, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u397531548", "n_user": "u397531548", "pos": "from bisect import bisect_left, bisect_right\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\nans=0\nfor j in range(N):\n a=bisect_left(A, B[j])\n c=bisect_right(C, B[j])\n ans+=a*(N-c)\nprint(ans)", "neg": "from bisect import bisect_left, bisect_right\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\nans=0\nfor j in range(N):\n a=bisect_left(a, B[i])\n c=bisect_right(a, B[i])\n ans+=a*c\nprint(ans)\n", "jacc_sim": 0.9444444444444444, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [134, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u218843509", "n_user": "u623687794", "pos": "import bisect\n\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\n\nans = 0\n\nfor i in range(n):\n\tans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))\n\nprint(ans)", "neg": "import bisect\nn=int(input())\na=sorted(list(map(int,input().split())))\nb=sorted(list(map(int,input().split())))\nc=sorted(list(map(int,input().split())))\nans=0\nfor i in range(n):\n d=bisect.bisect_left(a,b[i])\n e=bisect.bisect_right(c,b[i])\n ans+=d*e\nprint(ans)\n", "jacc_sim": 0.9117647058823529, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [114, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u341087021", "n_user": "u238510421", "pos": "import bisect\n\nn = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nc = [int(x) for x in input().split()]\n\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\nans = 0\n\nfor x in b:\n aa = bisect.bisect_left(a,x)\n cc = len(c) - bisect.bisect_right(c,x)\n ans += aa * cc\n\nprint(ans)", "neg": "import bisect\n\nn = int(input())\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\nc = [int(x) for x in input().split()]\n\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\nans = 0\n\nfor x in b:\n print(x)\n aa = bisect.bisect_left(a,x)\n cc = len(c) - bisect.bisect_right(c,x)\n ans += aa * cc\n print(\"aa\",aa)\n print(\"cc\",cc)\n print(\"ans\",ans)\n\nprint(ans)\n\n", "jacc_sim": 0.9696969696969697, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [142, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u057916330", "n_user": "u057916330", "pos": "import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nans = 0\nA.sort()\nB.sort()\nC.sort()\n# print(A, B, C)\nfor b in B:\n a_i = bisect.bisect_left(A, b)\n c_i = bisect.bisect_right(C, b)\n cnt = (a_i) * (N - c_i)\n # print(b, a_i, c_i, cnt)\n ans += cnt\n\nprint(ans)", "neg": "import bisect\n\nN = int(input())\nA = list(set(map(int, input().split())))\nB = list(set(map(int, input().split())))\nC = list(set(map(int, input().split())))\nans = 0\nA.sort()\nB.sort()\nC.sort()\n# print(A, B, C)\nfor b in B:\n a_i = bisect.bisect_left(A, b)\n c_i = bisect.bisect_right(C, b)\n cnt = (a_i) * (N - c_i)\n # print(b, a_i, c_i, cnt)\n ans += cnt\n\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [168, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u280269055", "n_user": "u280269055", "pos": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\ni = 0\nj = 0\nk = 0\np = []\nwhile i < n and j < n:\n if a[i] < b[j]:\n i += 1\n else:\n p.append(i + k)\n k = p[-1]\n j += 1\nelse:\n while j < n:\n p.append(n + k)\n k = p[-1]\n j += 1\n \ni = 0\nj = 0\nk = 0\ns = []\nwhile i < n and j < n:\n if b[i] < c[j]:\n i += 1\n else:\n if i == 0:\n s.append(0)\n else:\n s.append(p[i-1] + k)\n k = s[-1]\n j += 1\nelse:\n while j < n:\n s.append(p[-1] + k)\n k = s[-1]\n j += 1\n\nprint(s[-1])", "neg": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\n\ni = 0\nj = 0\nk = 0\np = []\nwhile i < n and j < n:\n if a[i] < b[j]:\n i += 1\n else:\n p.append(i + k)\n k = p[-1]\n j += 1\nelse:\n while j < n:\n p.append(n + k)\n k = p[-1]\n j += 1\n\ni = 0\nj = 0\ns = 0\nwhile i < n and j < n:\n if b[i] < c[j]:\n i += 1\n else:\n s += p[i]\n j += 1\nelse:\n while j < n:\n s += p[-1]\n j += 1\n\nprint(s)", "jacc_sim": 0.9705882352941176, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [308, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03559", "p_user": "u314057689", "n_user": "u314057689", "pos": "from bisect import bisect_left, bisect_right, insort_left, insort_right\n\ndef main():\n N = int(input())\n A = sorted(list(map(int, input().split())))\n B = sorted(list(map(int, input().split())))\n C = sorted(list(map(lambda x: int(x)-1, input().split())))\n\n\n BC = []\n for i in range(N):\n b = B[i]\n BC.append(N - bisect_left(C, b))\n\n Cum = []\n S = sum(BC)\n tmp = S\n for i in range(N):\n Cum.append(tmp)\n tmp -= BC[i]\n Cum.append(0)\n\n count = 0\n for i in range(N):\n a = A[i]\n count += Cum[bisect_right(B, a)]\n\n print(count)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "from bisect import bisect_left, bisect_right, insort_left, insort_right\ndef main():\n N = int(input())\n A = sorted(list(map(int, input().split())))\n B = sorted(list(map(int, input().split())))\n C = sorted(list(map(int, input().split())))\n\n # print(A)\n # print(B)\n # print(C)\n\n BC = []\n for i in range(N):\n b = B[i]\n BC.append(N - bisect_left(C, b))\n # print(BC)\n\n Cum = []\n S = sum(BC)\n tmp = S\n for i in range(N):\n Cum.append(tmp)\n tmp -= BC[i]\n Cum.append(0)\n # print(Cum)\n\n count = 0\n for i in range(N):\n a = A[i]\n count += Cum[bisect_right(B, a)]\n # print(a, Cum[bisect_right(B, a)])\n\n print(count)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9230769230769231, "nl": "Ringo is preparing for the Snuke Festival and needs to build an altar with three parts: upper, middle, and lower. He has N parts for each category, with sizes A_i, B_i, and C_i respectively. To build an altar, the middle part must be larger than the upper part, and the lower part must be larger than the middle part. Ringo needs to determine how many different altars he can build. The input format includes N followed by the sizes of the parts, and the output should be the number of different altars.", "before_after_length": [250, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03561", "p_user": "u905582793", "n_user": "u905582793", "pos": "k,n = map(int,input().split())\nif k%2 == 0:\n ans = [k//2]+[k]*(n-1)\nelse:\n t = n//2\n ans = [k//2+1]*n\n for i in range(t):\n if ans[-1] == 1:\n ans.pop()\n else:\n ans[-1] -= 1\n while len(ans) < n:\n ans.append(k)\nprint(*ans)", "neg": "k,n = map(int,input().split())\nif k%2 == 0:\n ans = [k//2]+[k//2+1]*(n-1)\nelse:\n print(2/0)\n t = n//2\n ans = [k//2+1]*n\n for i in range(t):\n if len(ans) < n:\n ans[-1] -= 1\n ans.append(k)\n elif ans[-1] > 1:\n ans[-1] -= 1\n else:\n ans.pop()\nprint(*ans)", "jacc_sim": 0.9210526315789473, "nl": "You are given a list of integer sequences in the Finite Encyclopedia of Integer Sequences (FEIS). The sequences have lengths between 1 and N, and consist of integers between 1 and K. You need to find the lexicographically smallest sequence at the (X/2)-th position, rounded up to the nearest integer. The input is given as K and N, and the output should be the specified sequence. The constraints are 1 \u2264 N, K \u2264 3 \u00d7 10^5.", "before_after_length": [119, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03561", "p_user": "u353797797", "n_user": "u353797797", "pos": "import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\ndef main():\n k,n=MI()\n end = n - 1\n if k%2:\n ans=[k//2+1]*n\n for _ in range(n//2):\n if ans[end]==1:\n end-=1\n else:\n ans[end]-=1\n if end!=n-1:\n for i in range(end+1,n):\n ans[i]=k\n end=n-1\n else:\n ans=[k//2]+[k]*(n-1)\n print(*ans[:end+1])\n\nmain()", "neg": "import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\n\ndef main():\n k,n=MI()\n if k%2:\n ans=[k//2+1]*n\n end=n-1\n for _ in range(n//2):\n if ans[end]==1:\n end-=1\n else:\n ans[end]-=1\n if end!=n-1:\n for i in range(end+1,n):\n ans[i]=k\n end=n-1\n else:\n ans=[k//2]+[k]*(n-1)\n print(*ans[:end+1])\n\nmain()", "jacc_sim": 1.0, "nl": "You are given a list of integer sequences in the Finite Encyclopedia of Integer Sequences (FEIS). The sequences have lengths between 1 and N, and consist of integers between 1 and K. You need to find the lexicographically smallest sequence at the (X/2)-th position, rounded up to the nearest integer. The input is given as K and N, and the output should be the specified sequence. The constraints are 1 \u2264 N, K \u2264 3 \u00d7 10^5.", "before_after_length": [255, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03561", "p_user": "u226155577", "n_user": "u226155577", "pos": "# seishin.py\nK, N = map(int, input().split())\nif K % 2 == 0:\n print(*[K//2] + [K]*(N-1))\nelse:\n X = [(K+1)//2] * N\n for i in range(N//2):\n if X[-1] == 1:\n X.pop()\n else:\n X[-1] -= 1\n X.extend([K]*(N-len(X)))\n print(*X)\n", "neg": "K, N = map(int, input().split())\nif K % 2 == 0:\n print(*[K//2] + [K]*(N-1))\nelse:\n X = [(K+1)//2] * N\n for i in range((N-1)//2):\n if X[-1] == 1:\n X.pop()\n else:\n X[-1] -= 1\n X.extend([K]*(N-len(X)))\n print(*X)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a list of integer sequences in the Finite Encyclopedia of Integer Sequences (FEIS). The sequences have lengths between 1 and N, and consist of integers between 1 and K. You need to find the lexicographically smallest sequence at the (X/2)-th position, rounded up to the nearest integer. The input is given as K and N, and the output should be the specified sequence. The constraints are 1 \u2264 N, K \u2264 3 \u00d7 10^5.", "before_after_length": [124, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u394731058", "n_user": "u394731058", "pos": "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n n = int(input())\n A = list(map(int, input().split()))\n allB = 3**n\n exc = 1\n for i in range(n):\n if A[i]%2 == 0:\n exc *= 2\n ans = allB - exc\n print(ans)\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n n = int(input())\n A = list(map(int, input().split()))\n allB = exc = 1\n for i in n:\n allB *= 3\n if i%2 == 0:\n exc *= 2\n ans = allB - exc\n print(ans)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.926829268292683, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [113, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u425762225", "n_user": "u425762225", "pos": "def solve(n,a):\n even = 0\n \n for i in range(n):\n if a[i] % 2 == 0:\n even += 1\n \n return 3**n - 2**even\n \ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n print(solve(N,a))\n \nmain()\n", "neg": "def solve(n,a):\n even = 0\n \n for i in range(n):\n if a[i] % 2 == 1:\n even += 1\n \n return 3**n - 2**even\n \ndef main():\n N = int(input())\n a = list(map(int,input().split()))\n print(solve(N,a))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [95, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u711238850", "n_user": "u711238850", "pos": "import itertools\n\nn = int(input())\na = tuple(map(int,input().split()))\nans = 0\nfor l in itertools.product([-1,0,1],repeat=n):\n t = 1\n for i in range(n):\n t*=(a[i]+l[i])\n if t%2==0:\n ans+=1\nprint(ans)", "neg": "import itertools\n\nn = int(input())\na = tuple(map(int,input().split()))\nans = 0\nfor l in itertools.product([-1,0,1],n):\n t = 1\n for i in range(n):\n t*=(a[i]+l[i])\n if t%2==0:\n ans+=1\nprint(ans)", "jacc_sim": 0.9714285714285714, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [94, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n a = LI()\n ans = 3 ** n\n a = sum(map(lambda x: x & 1, a))\n na = n - a\n print(ans - 2 ** na)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef S(): return input().rstrip()\ndef LS(): return S().split()\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n n = II()\n a = LI()\n ans = 3 ** n\n a = sum(map(lambda x: x & 1, a))\n na = n - a\n print(ans - 2 ** na * a)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [390, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u518987899", "n_user": "u518987899", "pos": "N = int(input().strip())\nA = list(map(int, input().strip().split(' ')))\n\nc_even = len([1 for a in A if a % 2 == 0])\nans = 3**len(A) - 2**c_even\nprint(ans)\n", "neg": "N = int(input().strip())\nA = list(map(int, input().strip().split(' ')))\n\nc_even = len(1 for a in A if a % 2 == 0)\nans = 3**len(A) - 2**c_even\nprint(ans)\n", "jacc_sim": 0.9354838709677419, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [66, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u777283665", "n_user": "u777283665", "pos": "n = int(input())\ncnt = 1\nfor i in input().split():\n if int(i) % 2 == 0:\n cnt *= 2\n\nprint(3**n - cnt)", "neg": "for i in input().split():\n if int(i) % 2 == 0:\n cnt *= 2\n\nprint(3**n - cnt)", "jacc_sim": 0.9545454545454546, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [45, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u497046426", "n_user": "u497046426", "pos": "N = int(input())\n*A, = map(int, input().split())\nevens = 0\nfor a in A:\n if a % 2 == 0: evens += 1\nans = 3**N - 2**evens\nprint(ans)", "neg": "N = int(input())\n*A, = map(int, input().split())\nevens = 0\nfor a in A:\n if a % 2 == 1: evens += 1\nans = 3**N - 2**evens\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [59, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u315703650", "n_user": "u403331159", "pos": "n = int(input())\na = list(map(int,input().split()))\ncnt = 0\nfor i in range(n):\n if a[i]%2==0:\n cnt+=1\nprint(3**n-2**cnt)", "neg": "n=int(input())\na=list(map(int,input().split()))\ncnt=0\nfor i range(n):\n if a[i]%2==0:\n cnt+=1\nans=(3*n)-2*cnt\nprint(ans)", "jacc_sim": 0.9354838709677419, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [61, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u614314290", "n_user": "u103902792", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\neven, odd = 0, 0\nfor a in A:\n\tif a % 2:\n\t\todd += 1\n\telse:\n\t\teven += 1\n\nif not even:\n\tprint(3 ** N - 1)\nelse:\n\tprint(3 ** N - 2 ** even)\n", "neg": "n = int(input())\nA = list(map(int,input().split()))\n\neven = odd = 0\n\nfor a in A:\n if a%2:\n odd += 1\n else:\n even += 1\n \nprint(3**n - (odd+(even*2)**n))", "jacc_sim": 0.9032258064516129, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [90, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u885899351", "n_user": "u274635633", "pos": "n=int(input())\na=list(map(int,input().split()))\nx=0\nfor i in a:\n if i%2==0:x+=1\nprint(3**n-2**x)", "neg": "n=map(int,input().split())\na=list(map(int,input().split()))\nx=0\nfor i in a:\n if i%2==0:\n \tx+=1\nprint(3**n-2**x)", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [54, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u163320134", "n_user": "u163320134", "pos": "n=int(input())\narr=list(map(int,input().split()))\ntmp=1\nfor i in range(n):\n if arr[i]%2==0:\n tmp*=2\nprint(3**n-tmp)", "neg": "n=int(input())\narr=list(map(int,input().split()))\ntmp=1\nfor i in range(i):\n if arr[i]%2==0:\n tmp*=2\nprint(3**n-tmp)", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [59, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u859897687", "n_user": "u859897687", "pos": "n=int(input())\nans=3**n\nm=1\nfor a in map(int,input().split()):\n if a%2==0:\n m*=2\nprint(ans-m)", "neg": "n=int(input())\nans=2**n\nm=1\nfor a in map(int,input().split()):\n if a%2==0:\n m*=2\nprint(ans-m)", "jacc_sim": 0.96, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [51, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u118642796", "n_user": "u118642796", "pos": "N = int(input())\nA = [int(i) for i in input().split()]\n\nans = 3**N\ntmp = 1\nfor a in A:\n if a%2==0:\n tmp *= 2\nprint(ans - tmp) \n", "neg": "N = int(input())\nA = [int(i) for i in input().split()]\n\nans = 2**N\ntmp = 1\nfor a in A:\n if a%2==0:\n tmp *= 2\nprint(ans - tmp)", "jacc_sim": 0.9629629629629629, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [61, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u280512618", "n_user": "u280512618", "pos": "from functools import reduce\nn=int(input())\nprint(3**n-reduce(lambda x, y: x * y, (2-int(s)%2 for s in input().split())))", "neg": "from functools import reduce\nn=int(input())\nprint(3**n-reduce(lambda x, y: x * y, 2-int(s)%2 for s in input().split()))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [46, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u367130284", "n_user": "u367130284", "pos": "print(3**int(input())-2**sum(~int(s)%2 for s in input().split()))", "neg": "print(3**int(input())-2**sum(int(s)%2 for s in input().split()))", "jacc_sim": 0.9411764705882353, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [28, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u409064224", "n_user": "u409064224", "pos": "n = int(input())\na = list(map(int,input().split()))\no = 1\n\n\nfor i in range(len(a)):\n if a[i]%2 == 1:\n #odd\n o *= 1\n else:\n #even\n o *= 2\n\nprint(3**len(a)-o)\n", "neg": "n = int(input())\na = list(map(int,input().split()))\nprint(a)\no = 1\n\n\nfor i in range(len(a)):\n if a[i]%2 == 1:\n #odd\n o *= 1\n else:\n #even\n o *= 2\n\nprint(3**len(a)-o)\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [84, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u422104747", "n_user": "u422104747", "pos": "n=int(input())\ns=input().split()\nx=1\nfor i in s:\n if(int(i)%2==0):\n x*=2\nprint(3**n-x)", "neg": "n=int(input())\ns=input().split()\nx=1\nfor i in s:\n if(int(i)%2==0):\n x*=2\nprint(2**n-x)", "jacc_sim": 0.9565217391304348, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [50, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u943004959", "n_user": "u943004959", "pos": "import itertools\n\n\ndef solve():\n N = int(input())\n A = list(map(int, input().split(\" \")))\n matrix = [[] for _ in range(N)]\n for i in range(N):\n matrix[i].append(A[i] - 1)\n matrix[i].append(A[i])\n matrix[i].append(A[i] + 1)\n\n cnt = 0\n for element in list(itertools.product(*matrix)):\n for i in range(N):\n if element[i] % 2 == 0:\n cnt += 1\n break\n\n print(cnt)\n\n\nsolve()", "neg": "import itertools\n\n\ndef solve():\n N = int(input())\n A = list(map(int, input().split(\" \")))\n matrix = [[] for _ in range(N)]\n for i in range(N):\n matrix[i].append(A[i] - 1)\n matrix[i].append(A[i])\n matrix[i].append(A[i] + 1)\n\n cnt = 0\n for element in list(itertools.product(*matrix)):\n for i in range(N):\n if element[i] % 2 == 0:\n cnt += 1\n break\n\n print(cnt)\n\n\n solve()", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [158, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u432042540", "n_user": "u432042540", "pos": "n = int(input())\na = [int(i) for i in input().split()]\n\ncnt = 0\nfor i in range(n):\n if a[i] % 2 == 0:\n cnt += 1\n\nx = 3 ** n - 2 ** cnt\n\nprint(x)\n", "neg": "n = int(input())\na = [int(i) for i in input().split()]\nprint(a)\n\ncnt = 0\nfor i in range(n):\n if a[i] % 2 == 0:\n cnt += 1\n\nx = 3 ** n - 2 ** cnt\n\nprint(x)", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [70, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u153147777", "n_user": "u153147777", "pos": "N = int(input())\na = map(int, input().split())\ntmp = 3 ** N\ng = len([c for c in a if c % 2 == 0])\nprint(tmp - (2 ** g))", "neg": "N = int(input())\na = map(int, input().split())\ntmp = 3 ** N\ng = len([c for c in a if a % 2 == 0])\nprint(tmp - (2 ** g))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [50, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u776189585", "n_user": "u776189585", "pos": "def get_result(A):\n res = 1\n total = 3 ** len(A)\n for i, ai in enumerate(A):\n res *= 2 if ai % 2 == 0 else 1\n return total - res\nn = input()\nA = [int(ai) for ai in input().split()]\nprint(get_result(A))", "neg": "def get_result(A):\n res = 1\n total = 1\n for i, ai in enumerate(A):\n print(ai, res, total)\n res *= 2 if ai % 2 == 0 else 1\n total *= 3 if ai > 1 else 2\n return total - res\n\nA = [int(ai) for ai in input().split()]\nprint(get_result(A))", "jacc_sim": 0.9142857142857143, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [82, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u817328209", "n_user": "u350093546", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nodds = 1\nfor i in range(n) :\n if a[i]%2 == 0 :\n odds *= 2\nelse :\n print(3**n-odds)", "neg": "n=int(input())\nn=3**n\na=list(map(int,input().split()))\n\na=[2 if i%2==0 for i in a else 1]\n\ncnt=1\n\nfor i in a:\n cnt*=i\n \n \nprint(n-cnt)\n", "jacc_sim": 0.9032258064516129, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [67, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u482969053", "n_user": "u767664985", "pos": "N = int(input())\nA = list(map(int, input().split()))\nodd_cand = 1\nans = 1\nfor i in A:\n if i%2==0:\n odd_cand *= 2\n ans *= 3\n\nprint(ans - odd_cand)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nans = 3 ** N\nfor i in A:\n\tif i % 2 == 0:\n\t\tans -= 2\nprint(ans)\n", "jacc_sim": 0.9259259259259259, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [70, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u928782751", "n_user": "u227085629", "pos": "n = int(input())\na = list(map(int, input().split()))\nk = 1\nfor i in a:\n\tif i%2 == 0:\n\t\tk *= 2\nprint(3**n-k)", "neg": "n = int(input())\na = list(map(int,input().split()))\nk = 1\nfor k in a:\n if k%2 == 0:\n k *= 2\nprint(3**n-k)", "jacc_sim": 0.9615384615384616, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [54, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u925364229", "n_user": "u925364229", "pos": "#! usr/bin/env python3\n#B:\n\nN = int(input())\n\nA = list(map(int,input().split(\" \")))\n\ncount = 1\n\nfor i in A:\n\tif i % 2 == 0:\n\t\tcount *= 2\n\telse:\n\t\tpass\n\nans = (3 ** len(A)) - count\n\nprint(ans)", "neg": "#! usr/bin/env python3\n#B:\n\nN = int(input())\n\nA = list(map(int,input().split(\" \")))\n\ncount = 1\n\nfor i in A:\n\tif A % 2 == 0:\n\t\tcount *= 2\n\telse:\n\t\tpass\n\nans = (3 ** len(A)) - count\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [91, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u233747425", "n_user": "u667084803", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(N):\n if A[i] % 2 == 0:\n cnt+= 1\n \nx = 3**N - 2 **cnt\nprint(x)", "neg": "N=int(input())\nA=list(map(int,input().split()))\nodd=0\nfor i in range(N):\n if A[i]%2==1: odd+=1\n\nprint(3**N-2**odd)", "jacc_sim": 0.90625, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [68, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03568", "p_user": "u226155577", "n_user": "u226155577", "pos": "n = int(input())\n*A, = map(int, input().split())\n\nfrom itertools import product\n\nans = 0\nfor P in product(range(3), repeat=n):\n even = 0\n for i in range(n):\n b = A[i] + P[i] - 1\n even |= (b % 2) == 0\n if even:\n ans += 1\nprint(ans)", "neg": "n = int(input())\n*A, = map(int, input().split())\n\nfrom itertools import product\n\nans = 0\nfor P in product(range(3), repeat=10):\n even = 0\n for i in range(n):\n b = A[i] + P[i] - 1\n even |= (b % 2) == 0\n if even:\n ans += 1\nprint(ans)\n\n", "jacc_sim": 0.9743589743589743, "nl": "You are given an integer sequence of length N. Two sequences are considered similar if the absolute difference between their corresponding elements is at most 1. Find the number of sequences that are similar to the given sequence and have an even product. Constraints: 1 \u2264 N \u2264 10, 1 \u2264 Ai \u2264 100. Input is given as N followed by the sequence. Output the number of sequences satisfying the condition. For example, given input 2 and sequence 2 3, the output should be 7, as there are seven satisfying sequences.", "before_after_length": [99, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03570", "p_user": "u905582793", "n_user": "u905582793", "pos": "from collections import defaultdict\ns = input()\nn = len(s)\ndp = defaultdict(int)\ndp[0] = 1\nls = [1<<(ord(s[0])-97)]\nfor i in range(1,n):\n ls.append(ls[-1]^(1<<(ord(s[i])-97)))\nif ls[-1] == 0:\n print(1)\n exit()\nfor i in range(n):\n for b in range(26):\n bit = 1< tr:\n d2[c] = tr\n return d2[c] if d2[c] else 1\n\n\n\nprint(main())\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**15\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n a = [2**(ord(c)-97) for c in S()]\n b = [0]\n d = {}\n d[0] = 0\n c = 0\n ii = [2**i for i in range(26)]\n for t,i in zip(a, range(1,len(a)+1)):\n c ^= t\n tr = inf\n if c in d:\n if c == 0:\n tr = 1\n tr = b[d[c] - 1] + 1\n else:\n d[c] = i\n\n for j in ii:\n e = c ^ j\n if e == 0:\n tr = 1\n break\n if e in d and b[d[e]] + 1 < tr:\n tr = b[d[e]] + 1\n b.append(tr)\n if b[d[c]] > tr:\n b[d[c]] = tr\n return b[-1]\n\n\n\nprint(main())\n\n\n", "jacc_sim": 0.9347826086956522, "nl": "You are given a string consisting of lowercase English letters. The task is to partition the string into non-empty substrings such that each substring can be rearranged to form a palindrome. Find the minimum possible number of substrings that satisfy this condition. The input is the string, and the output is the minimum possible number of substrings. For example, given the input \"aabxyyzz\", the output is 2, as the string can be partitioned into \"aab\" and \"xyyzz\", both of which can be rearranged to form palindromes.", "before_after_length": [423, 459], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03570", "p_user": "u226155577", "n_user": "u226155577", "pos": "s = input()\nn = len(s)\ncA = ord('a')\nP = {0: 0}\ncur = 0\n\ndp = [10**18]*(n+1)\ndp[-1] = 0\n\nfor i in range(n):\n c = ord(s[i]) - cA\n dp[i] = dp[i-1] + 1\n cur ^= 1 << c\n # even\n if cur in P:\n dp[i] = min(dp[i], P[cur] + 1)\n # odd\n for k in range(26):\n need = cur ^ (1 << k)\n if need in P:\n dp[i] = min(dp[i], P[need] + 1)\n P[cur] = min(P.get(cur, 10**18), dp[i])\nprint(dp[n-1])", "neg": "s = input()\nn = len(s)\ncA = ord('a')\nP = {0: -1}\ncur = 0\n\ndp = [10**18]*(n+1)\ndp[-1] = 0\n\nfor i in range(n):\n c = ord(s[i]) - cA\n dp[i] = dp[i-1] + 1\n cur ^= 1 << c\n # even\n if cur in P:\n dp[i] = min(dp[i], P[cur] + 1)\n # odd\n for k in range(26):\n need = cur ^ (1 << k)\n if need in P:\n dp[i] = min(dp[i], P[need] + 1)\n P[cur] = min(P.get(cur, 10**18), dp[i])\nprint(dp[n-1])", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. The task is to partition the string into non-empty substrings such that each substring can be rearranged to form a palindrome. Find the minimum possible number of substrings that satisfy this condition. The input is the string, and the output is the minimum possible number of substrings. For example, given the input \"aabxyyzz\", the output is 2, as the string can be partitioned into \"aab\" and \"xyyzz\", both of which can be rearranged to form palindromes.", "before_after_length": [210, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u468972478", "n_user": "u511379665", "pos": "print(input()[0:-8])", "neg": "print(input()[0:len(input())-8])", "jacc_sim": 0.9090909090909091, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [10, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u673361376", "n_user": "u334712262", "pos": "print(input()[:-len('FESTIVAL')])", "neg": "print(input()[len('FESTIVAL'):])", "jacc_sim": 0.9090909090909091, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [14, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u767664985", "n_user": "u045939752", "pos": "print(input()[: -8])\n", "neg": "print(input()[-8:])", "jacc_sim": 1.0, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [9, 8], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u099918199", "n_user": "u163320134", "pos": "s = str(input())\ns = s[:-8]\nprint(s)\n", "neg": "s=input()\nprint(s[:-8]", "jacc_sim": 0.9166666666666666, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [20, 12], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u544280305", "n_user": "u544280305", "pos": "z=input()\nprint(z[:-8])", "neg": "z=input\nprint(z[:-8])", "jacc_sim": 1.0, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [12, 11], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u257374434", "n_user": "u871596687", "pos": "\n\n\nS = input()\n\nprint(S[:-8])", "neg": "S = input()\n\nprint(s[:-8])\n\n\n \n ", "jacc_sim": 0.9166666666666666, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [17, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03577", "p_user": "u172773620", "n_user": "u426108351", "pos": "s = input()\n\n\ns = s[:-8]\n\nprint(s)", "neg": "s = input()\nprint(s[:len(s)-8]", "jacc_sim": 0.9166666666666666, "nl": "Score: 100 points\n\nProblem Statement:\nRng is going to a festival. The name of the festival is given as a string S, which ends with \"FESTIVAL\". Answer the question: \"Rng is going to a festival of what?\" Output the answer. Assume that the name of \"a festival of s\" is obtained by appending \"FESTIVAL\" to the end of s. For example, \"CODEFESTIVAL\" is a festival of \"CODE\".\n\nConstraints:\n- 9 \u2264 |S| \u2264 50\n- S consists of uppercase English letters.\n- S ends with \"FESTIVAL\".\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nPrint the answer to the question: \"Rng is going to a festival of what?\"\n\nSample Input 1:\nCODEFESTIVAL\n\nSample Output 1:\nCODE\nThis is the same as the example in the statement.\n\nSample Input 2:\nCODEFESTIVALFESTIVAL\n\nSample Output 2:\nCODEFESTIVAL\nThis string is obtained by appending \"FESTIVAL\" to the end of \"CODEFESTIVAL\", so it is a festival of \"CODEFESTIVAL\".\n\nSample Input 3:\nYAKINIKUFESTIVAL\n\nSample Output 3:\nYAKINIKU", "before_after_length": [20, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u137226361", "n_user": "u137226361", "pos": "from collections import deque\nn, m = map(int, input().split())\nconnect = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n connect[a].append(b)\n connect[b].append(a)\n \ncolor = [-1]*n\ncolor[0] = 0\nexplored = {0}\nnext = deque([0])\nexploring =deque()\nYes = True\n \nwhile next:\n now = next.popleft()\n exploring.extend(connect[now])\n while exploring:\n a = exploring.popleft()\n if color[a] == -1:\n color[a]=(color[now]+1)%2\n elif color[a] == (color[now]+1)%2:\n pass\n else:\n Yes = False\n if a not in explored:\n next.append(a)\n explored.add(a)\n \n \n \nif Yes:\n s=sum(color)\n print(s*(n-s)-m)\nelse:\n print(n*(n-1)//2-m)", "neg": "from collections import deque\nn, m = map(int, input().split())\nif n==2 or n==3:\n print(0)\n exit()\n\nconnect = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n connect[a].append(b)\n connect[b].append(a)\n#print(connect)\ncolor= [-1]*n\ncolor[0]=0\nexplored= {0}\nnext = deque(connect[0])\nexploring =deque()\nYes = True\nexplored.add(0)\nwhile next:\n now = next.popleft()\n exploring.extend(connect[now])\n while exploring:\n a=exploring.popleft()\n if color[a]==-1 or color[a]==(color[now]+1)%2:\n color[a]=(color[now]+1)%2\n else:\n Yes = False\n if a not in explored:\n next.append(a)\n explored.add(a)\n\nYes = False\nif Yes:\n s=sum(color)\n print(s*(n-s)-m)\nelse:\n print(int(n*(n-1)/2-m))", "jacc_sim": 0.9032258064516129, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [291, 322], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u137226361", "n_user": "u137226361", "pos": "from collections import deque\nn, m = map(int, input().split())\nconnect = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n connect[a].append(b)\n connect[b].append(a)\n\ncolor = [-1]*n\ncolor[0] = 0\nexplored = {0}\nnext = deque([0])\nexploring =deque()\nYes = True\nexplored.add(0)\nwhile next:\n now = next.popleft()\n for a in connect[now]:\n if color[a] != -1:\n if color[a] != (color[now]+1)%2:\n Yes = False\n continue\n color[a] = (color[now]+1)%2\n next.append(a)\n \n \n '''\n exploring.extend(connect[now])\n while exploring:\n a = exploring.popleft()\n if color[a] == -1:\n color[a]=(color[now]+1)%2\n elif color[a] == (color[now]+1)%2:\n pass\n else:\n Yes = False\n if a not in explored:\n next.append(a)\n explored.add(a)\n '''\nif Yes:\n s=sum(color)\n print(s*(n-s)-m)\nelse:\n print(n*(n-1)//2-m)", "neg": "from collections import deque\nn, m = map(int, input().split())\nconnect = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n connect[a].append(b)\n connect[b].append(a)\n\ncolor = [-1]*n\ncolor[0] = 0\nexplored = {0}\nnext = deque(connect[0])\nexploring =deque()\nYes = True\nexplored.add(0)\nwhile next:\n now = next.popleft()\n exploring.extend(connect[now])\n while exploring:\n a = exploring.popleft()\n if color[a] == -1:\n color[a]=(color[now]+1)%2\n elif color[a] == (color[now]+1)%2:\n pass\n else:\n Yes = False\n if a not in explored:\n next.append(a)\n explored.add(a)\n\nif Yes:\n s=sum(color)\n print(0)\nelse:\n print(int(n*(n-1)/2-m))", "jacc_sim": 0.9508196721311475, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [373, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u383713431", "n_user": "u383713431", "pos": "from collections import deque, defaultdict\nimport sys\n\nsys.setrecursionlimit(10**8)\nN, M = map(int, input().split())\ngraph = [[] for _ in range(N)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1; b -= 1;\n graph[a].append(b)\n graph[b].append(a)\n\n\nvisited = [False for _ in range(N)]\ncolor = [0 for _ in range(N)]\n\ndef dfs(now, c):\n\n color[now] = c\n\n for adj in graph[now]:\n if color[adj] == c:\n return False\n\n if color[adj] == 0 and not dfs(adj, -c):\n return False\n\n return True\n\nans = dfs(0, 1)\nwhite = color.count(-1)\nblack = N - white\nif ans:\n print(black * white - M)\nelse:\n print(N * (N-1)//2 - M)\n", "neg": "from collections import deque, defaultdict\nN, M = map(int, input().split())\ngraph = [[] for _ in range(N)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1; b -= 1;\n graph[a].append(b)\n graph[b].append(a)\n\n\nvisited = [False for _ in range(N)]\ncolor = [0 for _ in range(N)]\n\ndef dfs(now, c):\n\n color[now] = c\n\n for adj in graph[now]:\n if color[adj] == c:\n return False\n\n if color[adj] == 0 and not dfs(adj, -c):\n return False\n\n return True\n\nans = dfs(0, 1)\nwhite = color.count(-1)\nblack = N - white\nif ans:\n print(black * white - M)\nelse:\n print(N * (N+1)//2 - M)\n", "jacc_sim": 0.9152542372881356, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [254, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u842170774", "n_user": "u842170774", "pos": "# CODE FESTIVAL 2017 qualB C 3 Steps\u3000\nfrom collections import deque\n\nf=lambda:map(int,input().split())\nN,M=f()\nG=[[] for _ in [0]*(N+1)]\nfor i in range(M):\n a,b=f()\n if not i:\n fa,fb=a,b\n G[a].append(b)\n G[b].append(a)\n \nres=0\nINF=10**9\n\ndef bfs(a):\n q=deque()\n q.append(a)\n d=[0]*(N+1)\n d[a]=1\n res=0\n while q:\n r=q.popleft()\n for nr in G[r]:\n if d[nr]==0:\n q.append(nr)\n d[nr]=-d[r]\n else:\n if d[nr]==d[r]:\n return (False,[])\n return (True,d)\ncheck=bfs(1)\nif not check[0]:\n print((N*(N-1))//2-M)\nelse:\n print(check[1].count(1)*check[1].count(-1)-M)", "neg": "# CODE FESTIVAL 2017 qualB C 3 Steps\u3000\nfrom collections import deque\n\nf=lambda:map(int,input().split())\nN,M=f()\nG=[[] for _ in [0]*(N+1)]\nfor i in range(M):\n a,b=f()\n if not i:\n fa,fb=a,b\n G[a].append(b)\n G[b].append(a)\n \nres=0\nINF=10**9\n\ndef bfs(a):\n q=deque()\n q.append(a)\n d=[INF]*(N+1)\n d[a]=0\n res=0\n while q:\n r=q.popleft()\n for nr in G[r]:\n if d[nr]==INF:\n q.append(nr)\n d[nr]=(d[r]+1)%2\n res+=1\n return d\n\nd=bfs(1)\nisPer=False\nfor i in G[1]:\n if d[i]==0:\n isPer=True\n break\nif isPer:\n print(N*N-M)\nelse:\n print(((N//2)**2)//1-M)", "jacc_sim": 0.9166666666666666, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [306, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u653837719", "n_user": "u653837719", "pos": "from sys import setrecursionlimit\n\nsetrecursionlimit(10**6)\n\ndef dfs(v):\n flag = True\n\n for nxt in edge[v]:\n if l[v] == l[nxt]:\n return False\n elif l[v] + l[nxt] == 1:\n continue\n else:\n l[nxt] = 1 - l[v]\n cnt[1-l[v]] += 1\n flag &= dfs(nxt)\n \n return flag\n \n\nn, m = map(int, input().split())\nedge = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n edge[a-1].append(b-1)\n edge[b-1].append(a-1)\n\nl = [-1] * n\nl[0] = 0\ncnt = [1, 0]\n\nif dfs(0):\n print(cnt[0] * cnt[1] - m)\nelse:\n print(n * (n - 1) // 2 - m)", "neg": "from sys import setrecursionlimit\n\nsetrecursionlimit(10**10)\n\ndef dfs(v):\n flag = True\n\n for nxt in edge[v]:\n if l[v] == l[nxt]:\n return False\n elif l[v] + l[nxt] == 1:\n continue\n else:\n l[nxt] = 1 - l[v]\n cnt[1-l[v]] += 1\n flag &= dfs(nxt)\n \n return flag\n \n\nn, m = map(int, input().split())\nedge = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n edge[a-1].append(b-1)\n edge[b-1].append(a-1)\n\nl = [-1] * n\nl[0] = 0\ncnt = [1, 0]\n\nif dfs(0):\n print(cnt[0] * cnt[1] - m)\nelse:\n print(n * (n - 1) // 2 - m)", "jacc_sim": 0.9803921568627451, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [263, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u477977638", "n_user": "u477977638", "pos": "import sys\ninput = sys.stdin.buffer.readline\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\ndef II(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int,input().split()))\ndef LF(): return list(map(float,input().split()))\ndef TI(): return tuple(map(int,input().split()))\n# rstrip().decode()\n\nfrom collections import deque\n\ndef main():\n\tn,m=MI()\n\n\tG=[[] for _ in range(n+1)]\n\n\tfor _ in range(m):\n\t\ta,b=MI()\n\t\tG[a].append(b)\n\t\tG[b].append(a)\n\t#print(G)\n\n\tD=[-1]*(n+1)\n\n\n\tQ=deque()\n\tQ.append([1,0])\n\n\t#print(Q)\n\n\tf=0\n\n\twhile Q:\n\t\t#print(Q)\n\t\tnow,d=Q.pop()\n\t\tD[now]=d\n\t\tfor nx in G[now]:\n\t\t\tif D[nx]==-1:\n\t\t\t\tQ.append([nx,1-d])\n\t\t\telif D[nx]!=d:\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tf=1\n\t\t\t\tbreak\n\n\n\tif f==1:\n\t\tans=(n*(n-1))//2\n\telse:\n\t\tans=D.count(0)*D.count(1)\n\n\n\tans-=m\n\n\tprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\tmain()\n", "neg": "import sys\ninput = sys.stdin.buffer.readline\n\n#sys.setrecursionlimit(10**9)\n#from functools import lru_cache\n\ndef RD(): return sys.stdin.read()\ndef II(): return int(input())\ndef MI(): return map(int,input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int,input().split()))\ndef LF(): return list(map(float,input().split()))\ndef TI(): return tuple(map(int,input().split()))\n# rstrip().decode()\n\nfrom collections import deque\n\ndef main():\n\tn,m=MI()\n\n\tG=[[] for _ in range(n+1)]\n\n\tfor _ in range(m):\n\t\ta,b=MI()\n\t\tG[a].append(b)\n\t\tG[b].append(a)\n\t#print(G)\n\n\tD=[-1]*(n+1)\n\n\n\tQ=deque()\n\tQ.append([1,0])\n\n\t#print(Q)\n\n\tf=0\n\n\twhile Q:\n\t\t#print(Q)\n\t\tnow,d=Q.popleft()\n\t\tD[now]=d\n\t\tfor nx in G[now]:\n\t\t\tif D[nx]==-1:\n\t\t\t\tQ.append([nx,d+1])\n\t\t\telif D[nx]%2!=d%2:\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tf=1\n\t\t\t\tbreak\n\n\n\tif f==1:\n\t\tans=(n*(n-1))//2+5\n\telse:\n\t\tans=(n//2+n%2)*(n//2)\n\n\tans-=m\n\n\tprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif __name__ == \"__main__\":\n\tmain()\n", "jacc_sim": 0.9390243902439024, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [457, 464], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u829895669", "n_user": "u829895669", "pos": "# coding:utf-8\nclass Tree(object):\n def __init__(self, N):\n self.tree = [[] for _ in range(N)]\n self.colors = [0 for _ in range(N)]\n\n def add_node(self, a, b):\n self.tree[a].append(b)\n # \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u5224\u5b9a\u3059\u308b\u95a2\u6570\n def is_bipartite_graph(self, v, color):\n self.colors[v] = color\n for to in self.tree[v]:\n if self.colors[to] == color:\n return False\n if self.colors[to] == 0 and not self.is_bipartite_graph(to, -color):\n return False\n return True\n \n def count_node(self, color):\n return self.colors.count(color)\n \nif __name__ == \"__main__\":\n\n import sys\n sys.setrecursionlimit(200000)\n # input data\n N, M = map(int, input().split())\n tree = Tree(N)\n for _ in range(M):\n a, b = map(int, input().split())\n tree.add_node(a-1, b-1)\n tree.add_node(b-1, a-1)\n \n # tree dp\n is_bpr = tree.is_bipartite_graph(0, 1)\n if is_bpr:\n bla = tree.count_node(1)\n whi = N - bla\n print(bla*whi-M)\n else:\n print(int(N*(N-1)/2-M))\n\n", "neg": "# coding:utf-8\nclass Tree(object):\n def __init__(self, N):\n self.tree = [[] for _ in range(N)]\n self.colors = [0 for _ in range(N)]\n\n def add_node(self, a, b):\n self.tree[a].append(b)\n # \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u5224\u5b9a\u3059\u308b\u95a2\u6570\n def is_bipartite_graph(self, v, color):\n self.colors[v] = color\n for to in self.tree[v]:\n if self.colors[to] == color:\n return False\n if self.colors[to] == 0 and not self.is_bipartite_graph(to, -color):\n return False\n return True\n \n def count_node(self, color):\n return self.colors.count(color)\n \nif __name__ == \"__main__\":\n\n # input data\n N, M = map(int, input().split())\n tree = Tree(N)\n for _ in range(M):\n a, b = map(int, input().split())\n tree.add_node(a-1, b-1)\n tree.add_node(b-1, a-1)\n \n # tree dp\n is_bpr = tree.is_bipartite_graph(0, 1)\n if is_bpr:\n bla = tree.count_node(1)\n whi = N - bla\n print(bla*whi-M)\n else:\n print(N*(N-1)/2-M)\n\n", "jacc_sim": 0.9487179487179487, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [437, 420], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u197457087", "n_user": "u197457087", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\nN, M = map(int,input().split())\n\nmichi = [[] for i in range(N)]\nfor i in range(M):\n tempa, tempb = map(int,input().split())\n michi[tempa-1].append(tempb-1)\n michi[tempb-1].append(tempa-1)\n#print(michi)\n \ncolors = [0 for i in range(N)]\n\ndef dfs(v,color):\n colors[v] = color\n for to in michi[v]:\n if colors[to] == color:\n return False\n if colors[to] == 0 and not dfs(to,-color):\n return False\n return True\n\nif dfs(0,1):\n a = colors.count(1)\n b = colors.count(-1)\n #print(colors)\n print(a*b-M)\nelse:\n print(N*(N-1)//2 - M)", "neg": "import sys\nsys.setrecursionlimit(10**7)\n\nN, M = map(int,input().split())\n\nmichi = [[] for i in range(N)]\nfor i in range(M):\n tempa, tempb = map(int,input().split())\n michi[tempa-1].append(tempb-1)\n michi[tempb-1].append(tempa-1)\nprint(michi)\n \ncolors = [0 for i in range(N)]\n\ndef dfs(v,color):\n colors[v] = color\n for to in michi[v]:\n if colors[to] == color:\n return False\n if colors[to] == 0 and not dfs(to,-color):\n return False\n return True\n\nif dfs(0,1):\n a = colors.count(1)\n b = colors.count(-1)\n #print(colors)\n print(a*b-M)\nelse:\n print(N*(N-1)//2 - M)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [256, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u830592648", "n_user": "u830592648", "pos": "import sys\nsys.setrecursionlimit(10**6)\nn,m=map(int,input().split())\ns=[[]for i in range(n+1)]\nc=[0]*(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a].append(b)\n s[b].append(a)\ndef dfs(v,t):\n c[v]=t\n # print('start :'+str(c))\n for i in s[v]:\n if c[i]==t:\n return False\n if c[i]==0 and not dfs(i,-t):\n return False\n else:\n return True\nif dfs(1,1):\n q=c.count(1)\n print((n-q)*q-m)\nelse:\n print((n*(n-1)//2)-m)", "neg": "import sys\nsys.setrecursionlimit(10**6)\nn,m=map(int,input().split())\ns=[[]for i in range(n+1)]\nc=[0]*(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a].append(b)\n s[b].append(a)\ndef dfs(v,t):\n c[v]=t\n print('start :'+str(c))\n for i in s[v]:\n if c[i]==t:\n return False\n if c[i]==0:\n dfs(i,-t)\n # return False\n else:\n return True\nif dfs(1,1):\n q=c.count(1)\n print((n-q)*q-m)\nelse:\n print((n*(n-1)//2)-m)", "jacc_sim": 0.9622641509433962, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [220, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u968404618", "n_user": "u968404618", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\ndef dfs(v, color):\n colors[v] = color\n for to in g[v]:\n if colors[to] == color: return False\n if colors[to] == 0 and not dfs(to, -color):\n return False\n return True\n\nn, m = map(int, input().split())\n\ng = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n g[a].append(b)\n g[b].append(a)\n\ncolors = [0]*n\n\nans = -m\nif dfs(0,1):\n b = (sum(colors)+n)//2\n w = n-b\n ans += b*w\nelse:\n ans += n*(n-1)//2\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10**7)\n\ndef dfs(v, color):\n colors[v] = color\n for to in g[v]:\n if colors[to] == color: return False\n if colors[to] == 0 and not dfs(to, -color):\n return False\n return True\n\nn, m = map(int, input().split())\n\ng = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n g[a].append(b)\n g[b].append(a)\n\ncolors = [0]*n\n\nans = -m\nif dfs(0,1):\n b = sum(colors)//2\n w = n-b\n ans += b*w\nelse:\n ans += n*(n-1)//2\nprint(ans)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [225, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u955125992", "n_user": "u955125992", "pos": "from collections import deque\n\ndef dfs():\n global color\n color = [-1] * n\n q = deque([])\n q.append(0)\n color[0] = 1\n \n while q:\n p = q.pop()\n for u in edge[p]:\n if color[u] == -1:\n color[u] = (color[p] + 1) % 2\n q.append(u)\n else:\n if color[u] == color[p]:\n return False\n return True\n\nn, m = map(int, input().split())\nedge = [[] for _ in range(n)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edge[a].append(b)\n edge[b].append(a)\n\n\nif dfs():\n B = 0\n W = 0\n for i in range(n):\n if color[i] == 1:\n B += 1\n else:\n W += 1\n print(B*W - m)\nelse:\n print(n * (n-1) // 2 - m)", "neg": "from collections import deque\n\ndef dfs():\n global color\n global edge\n color = [-1] * n\n edge = [[] for _ in range(n)]\n\n q = deque([])\n q.append(0)\n color[0] = 1\n \n while q:\n p = q.pop()\n for u in edge[p]:\n if color[u] == -1:\n color[u] = (color[p] + 1) % 2\n q.append(u)\n else:\n if color[u] == color[p]:\n return False\n return True\n\nn, m = map(int, input().split())\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edge[a].append(b)\n edge[b].append(a)\n\n\nif dfs():\n B = 0\n W = 0\n for i in range(n):\n if color[i] == 1:\n B += 1\n else:\n W += 1\n print(B*W - m)\nelse:\n print(n * (n-1) // 2 - m)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [286, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n n,m=map(int,input().split())\n ab=[list(map(int,input().split())) for _ in [0]*m]\n g=[[] for _ in [0]*n]\n [g[a-1].append(b-1) for a,b in ab]\n [g[b-1].append(a-1) for a,b in ab]\n ans=[None]*n\n ans[0]=0\n temp=[0]\n while temp:\n i=temp.pop()\n for j in g[i]:\n if ans[j]==None:\n ans[j]=ans[i]^True\n temp.append(j)\n else:\n if ans[i]^ans[j]==0:\n print(n*(n-1)//2-m)\n return 0\n print(ans.count(0)*ans.count(1)-m)\nmain()", "neg": "def main():\n n,m=map(int,input().split())\n ab=[list(map(int,input().split())) for _ in [0]*m]\n g=[[] for _ in [0]*n]\n [g[a-1].append(b-1) for a,b in ab]\n [g[b-1].append(a-1) for a,b in ab]\n ans=[None]*n\n ans[0]=0\n temp=[0]\n while temp:\n i=temp.pop()\n for j in g[i]:\n if ans[j]==None:\n ans[j]=ans[i]^True\n temp.append(j)\n else:\n if ans[i]^ans[j]==0:\n #print(n*(n-1)//2-m)\n print(1/0)\n return 0\n print((ans.count(0)*(ans.count(0)-1)//2)*(ans.count(1)*(ans.count(1)-1)//2)-m)\nmain()", "jacc_sim": 0.9782608695652174, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [230, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u550943777", "n_user": "u550943777", "pos": "N,M = map(int,input().split())\ne_list = [[] for i in range(N)]\nfor i in range(M):\n a,b = map(lambda x:int(x)-1, input().split())\n e_list[a].append(b)\n e_list[b].append(a)\nbin_or_not = True\nans = (N-1)*N//2 - M\nw_or_b = [-1]*N\nstack = [0]\nw_or_b[0] = 0\nwhile stack:\n x = stack.pop()\n for i in e_list[x]:\n if w_or_b[i] >= 0:\n bin_or_not = w_or_b[x]^w_or_b[i]\n else:\n w_or_b[i] = (w_or_b[x] + 1)%2\n stack.append(i)\n if not bin_or_not:\n break\n if not bin_or_not:\n break\nif bin_or_not:\n w = w_or_b.count(0)\n b = w_or_b.count(1)\n ans = w*b - M\nprint(ans)", "neg": "N,M = map(int,input().split())\ne_list = [[] for i in range(N)]\nfor i in range(M):\n a,b = map(lambda x:int(x)-1, input().split())\n e_list[a].append(b)\n e_list[b].append(a)\nbin_or_not = True\nans = (N-1)*N//2 - M\nw_or_b = [-1]*N\nstack = [0]\nw_or_b[0] = 0\nwhile stack:\n x = stack.pop()\n for i in e_list[x]:\n if w_or_b[i] >= 0:\n bin_or_not = not(w_or_b[x]^w_or_b[i])\n else:\n w_or_b[i] = (w_or_b[x] + 1)%2\n stack.append(i)\n if not bin_or_not:\n break\nif bin_or_not:\n w = w_or_b.count(0)\n b = w_or_b.count(1)\n ans = w*b - M\nprint(ans)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [304, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u310678820", "n_user": "u310678820", "pos": "from collections import deque\nN, M = map(int, input().split())\nG = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n G[a-1].append(b-1)\n G[b-1].append(a-1)\ndef is_bipartite(G):\n n = len(G)\n color = [-1]*n\n que = deque([0])\n color[0] = 0\n while que:\n v = que.pop()\n c = color[v]\n for nv in G[v]:\n if color[nv]<0:\n color[nv] = 1-c\n que.append(nv)\n elif color[nv] == c:\n return False\n return color\ncolor = is_bipartite(G)\nif color:\n a = color.count(0)\n b = N-a\n print(a*b-M)\nelse:\n print(N*(N-1)//2-M)\n \n ", "neg": "N, M = map(int, input().split())\nG = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n G[a-1].append(b-1)\n G[b-1].append(a-1)\ndef is_bipartite(G):\n n = len(G)\n color = [-1]*n\n que = deque([0])\n color[0] = 0\n while que:\n v = que.pop()\n c = color[v]\n for nv in G[v]:\n if color[nv]<0:\n color[nv] = 1-c\n que.append(nv)\n elif color[nv] == c:\n return False\n return color\ncolor = is_bipartite(G)\nif color:\n a = color.count(0)\n b = N-a\n print(a*b-M)\nelse:\n print(N*(N-1)//2-M)\n \n ", "jacc_sim": 0.9411764705882353, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [261, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\nsys.setrecursionlimit(10 ** 7)\n\nN, M = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(M)]\ngraph = [[] for _ in range(N)]\n\nfor a, b in AB:\n graph[a-1].append(b-1)\n graph[b-1].append(a-1)\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u3069\u3046\u304b\u306e\u5224\u5b9a\ncolor = [None] * N\ncolor[0] = 0\nq = [0]\nwhile q:\n x = q.pop()\n for y in graph[x]:\n if color[y] is None:\n color[y] = 1 - color[x]\n q.append(y)\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u3069\u3046\u304b\nis_bg = all(color[a-1] != color[b-1] for a, b in AB)\n\nif is_bg:\n # \u5b8c\u5168\u4e8c\u90e8\u30b0\u30e9\u30d5\u306b\u3059\u308b\n x = sum(color)\n y = N - x\n answer = x*y - M\nelse:\n # \u5b8c\u5168\u30b0\u30e9\u30d5\u306b\u3059\u308b(\u5947\u6570\u9577\u306e\u30d1\u30b9\u304c\u3042\u308b\u5834\u5408\u306f\u5fc5\u305a2\u305a\u3064\u6e1b\u3089\u3057\u3066\u3044\u3051\u3070\u9577\u3055\u304c3\u306b\u306a\u308b)\n answer = N*(N-1)//2 - M\n\nprint(answer)", "neg": "import sys\nsys.setrecursionlimit(10 ** 7)\n\nN, M = map(int,input().split())\n\nAB = [list(map(int, input().split())) for _ in range(M)]\n\ngraph = [[] for _ in range(N)]\nfor a,b in AB:\n graph[a\u22121].append(b-1)\n graph[b-1].append(a-1)\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u3069\u3046\u304b\u306e\u5224\u5b9a\ncolor = [None] * N\ncolor[0] = 0\nq = [0]\nwhile q:\n x = q.pop()\n for y in graph[x]:\n if color[y] is None:\n color[y] = 1 - color[x]\n q.append(y)\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u304b\u3069\u3046\u304b\nbg = all(color[a] != color[b] for a, b in AB)\n\nif bg:\n # \u5b8c\u5168\u4e8c\u90e8\u30b0\u30e9\u30d5\u306b\u3059\u308b\n x = sum(color)\n y = N - x\n answer = x*y - M\nelse:\n # \u5b8c\u5168\u30b0\u30e9\u30d5\u306b\u3059\u308b(\u5947\u6570\u9577\u306e\u30d1\u30b9\u304c\u3042\u308b\u5834\u5408\u306f\u5fc5\u305a2\u305a\u3064\u6e1b\u3089\u3057\u3066\u3044\u3051\u3070\u9577\u3055\u304c3\u306b\u306a\u308b)\n answer = N*(N-1)//2 - M\n\nprint(answer)\n", "jacc_sim": 0.967741935483871, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [476, 472], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u033606236", "n_user": "u033606236", "pos": "import sys\nsys.setrecursionlimit(500000)\n\ndef dfs(v,c):\n color[v] = c\n\n for i in a[v]:\n if color[i] != -1:\n if color[i] == c:return False\n continue\n if dfs(i,1-c) == False:return False\n\nn,m = map(int,input().split())\na = [[]for i in range(n)]\ncolor = [-1 for _ in range(n)]\n\nfor i in range(m):\n x,y= map(int,input().split())\n a[x-1].append(y-1)\n a[y-1].append(x-1)\nif dfs(0,0) == False:\n print(n*(n-1)//2-m)\nelse:print(color.count(0) * color.count(1) -m)", "neg": "import sys\nsys.setrecursionlimit(500000)\n\ndef dfs(v,c):\n color[v] = c\n\n for i in a[v]:\n if color[i] != -1:\n if color[i] == c:return False\n continue\n if dfs(i,1-c) == False:return False\n\nn,m = map(int,input().split())\na = [[]for i in range(n)]\ncolor = [-1 for _ in range(n)]\n\nfor i in range(m):\n x,y= map(int,input().split())\n a[x-1].append(y-1)\n a[y-1].append(x-1)\nprint(a)\nif dfs(0,0) == False:\n print(n*(n-1)//2-m)\nelse:print((n-n//2)*(n//2) - m)", "jacc_sim": 0.9782608695652174, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [217, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u850491413", "n_user": "u850491413", "pos": "\nimport sys\nfrom collections import deque, defaultdict\nimport copy\nimport bisect\n#sys.setrecursionlimit(10 ** 9)\nimport math\nimport heapq\nfrom itertools import combinations, permutations\n\nimport sys\ndef input():\n\treturn sys.stdin.readline().strip()\n\nN, M = list(map(int, input().split()))\n\ngraph = [[] for _ in range(N)]\ngraph2 = [-1 for _ in range(N)]\nfor i in range(M):\n\ta, b = list(map(int, input().split()))\n\ta -= 1\n\tb -= 1\n\tgraph[a].append(b)\n\tgraph[b].append(a)\n\nque = deque([])\nque.append(0)\ngraph2[0] = 0\nnibu = 1\n\nnum01 = dict()\nnum01[0] = 1\nnum01[1] = 0\n\nwhile len(que) > 0:\n\tnode = que.popleft()\n\tfor edge in graph[node]:\n\t\tif graph2[edge] == -1:\n\t\t\tgraph2[edge] = (graph2[node] + 1) % 2\n\t\t\tque.append(edge)\n\t\t\tnum01[graph2[edge]] += 1\n\t\telif graph2[node] == graph2[edge]:\n\t\t\tnibu = 0\n\nif nibu == 0:\n\tprint(N*(N-1)//2 - M)\nelse:\n\tprint(num01[0]*num01[1] - M)", "neg": "\nimport sys\nfrom collections import deque, defaultdict\nimport copy\nimport bisect\n#sys.setrecursionlimit(10 ** 9)\nimport math\nimport heapq\nfrom itertools import combinations, permutations\n\nimport sys\ndef input():\n\treturn sys.stdin.readline().strip()\n\nN, M = list(map(int, input().split()))\n\ngraph = [[] for _ in range(N)]\ngraph2 = [-1 for _ in range(N)]\nfor i in range(M):\n\ta, b = list(map(int, input().split()))\n\ta -= 1\n\tb -= 1\n\tgraph[a].append(b)\n\tgraph[b].append(a)\n\nque = deque([])\nque.append(0)\ngraph2[0] = 0\nnibu = 1\n\nnum01 = dict()\nnum01[0] = 1\nnum01[1] = 0\n\nwhile len(que) > 0:\n\tnode = que.popleft()\n\tfor edge in graph[node]:\n\t\tif graph2[edge] == -1:\n\t\t\tgraph2[edge] = (graph2[node] + 1) % 2\n\t\t\tque.append(edge)\n\t\t\tnum01[graph2[edge]] += 1\n\t\telif graph2[node] == graph2[edge]:\n\t\t\tnibu = 0\n\nif nibu == 0:\n\tprint(N*(N-1)//2 - M)\nelse:\n\tprint(num01[0]*num01[1] - 1)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [361, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u380524497", "n_user": "u380524497", "pos": "from collections import defaultdict\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\nn, m = map(int, (input().split()))\ndic = defaultdict(list)\nseen = [-1] * (n+1)\n\nfor _ in range(m):\n a, b = map(int, input().split())\n dic[a].append(b)\n dic[b].append(a)\n\n\ndef dfs(v, todo, color):\n if seen[v] == color: # \u540c\u3058\u8272\u3067\u623b\u3063\u3066\u304f\u308b = \u5076\u30b5\u30a4\u30af\u30eb\n return\n elif seen[v] == 1-color: # \u7570\u306a\u308b\u8272\u3067\u623b\u3063\u3066\u304f\u308b = \u5947\u30b5\u30a4\u30af\u30eb\n global odd_cycle\n odd_cycle = True\n return\n\n seen[v] = color\n for new_v in todo:\n new_todo = dic[new_v]\n dfs(new_v, new_todo, 1-color)\n\n\nodd_cycle = False\ndfs(1, dic[1], 0)\nif odd_cycle:\n ans = 0.5 * n * (n-1) - m\nelse:\n black = seen.count(0)\n white = seen.count(1)\n ans = black * white - m\n\nprint(int(ans))\n", "neg": "from collections import defaultdict\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\n\nn, m = map(int, (input().split()))\ndic = defaultdict(list)\nseen = [-1] * (n+1)\n\nfor _ in range(m):\n a, b = map(int, input().split())\n dic[a].append(b)\n dic[b].append(a)\n\n\ndef dfs(v, todo, color):\n if seen[v] == color: # \u540c\u3058\u8272\u3067\u623b\u3063\u3066\u304f\u308b = \u5076\u30b5\u30a4\u30af\u30eb\n return\n elif seen[v] == 1-color: # \u7570\u306a\u308b\u8272\u3067\u623b\u3063\u3066\u304f\u308b = \u5947\u30b5\u30a4\u30af\u30eb\n return False\n\n seen[v] = color\n for new_v in todo:\n new_todo = dic[new_v]\n dfs(new_v, new_todo, 1-color)\n\n\nif dfs(1, dic[1], 0) is False:\n ans = 0.5 * n * (n-1) - m\n\nelse:\n black = seen.count(0)\n white = seen.count(1)\n ans = black * white - m\n\nprint(int(ans))", "jacc_sim": 0.9493670886075949, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [384, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u379692329", "n_user": "u379692329", "pos": "import sys\nsys.setrecursionlimit(10**6)\nfrom operator import mul\nfrom functools import reduce\n\ndef comb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\ndef dfs(v, cur):\n color[v] = cur\n \n for next_v in Graph[v]:\n if color[next_v] != -1:\n if color[next_v] != cur:\n continue\n else:\n return False\n elif not dfs(next_v, 1-cur):\n return False\n return True\n \n\n\nN, M = map(int, input().split())\nAB = [[int(_) for _ in input().split()] for _ in range(M)]\nGraph = [[] for _ in range(N)]\ncolor = [-1]*N\n\nfor i in AB:\n Graph[i[0]-1].append(i[1]-1)\n Graph[i[1]-1].append(i[0]-1)\n\nif dfs(0, 0):\n black = color.count(0)\n white = N - black\n print(black*white-M)\nelse:\n print(comb(N, 2)-M)", "neg": "import sys\nsys.setrecursionlimit(10**6)\nfrom operator import mul\nfrom functools import reduce\n\ndef comb(n,r):\n r = min(n-r,r)\n if r == 0: return 1\n over = reduce(mul, range(n, n - r, -1))\n under = reduce(mul, range(1,r + 1))\n return over // under\n\n\ndef dfs(v, cur):\n color[v] = cur\n \n for next_v in Graph[v]:\n if color[next_v] != -1:\n if color[next_v] != cur:\n continue\n else:\n return False\n elif not dfs(next_v, 1-cur):\n return False\n return True\n \n\n\nN, M = map(int, input().split())\nAB = [[int(_) for _ in input().split()] for _ in range(M)]\nGraph = [[] for _ in range(N)]\ncolor = [-1]*N\n\nfor i in AB:\n Graph[i[0]-1].append(i[1]-1)\n Graph[i[1]-1].append(i[0]-1)\n\nif dfs(0, 0):\n \tblack = color.count(0)\n white = N - black\n print(black*white-M)\nelse:\n print(comb(N, 2)-M)", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [339, 340], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u619819312", "n_user": "u619819312", "pos": "import sys\nsys.setrecursionlimit(10**6)\nn,m=map(int,input().split())\ns=[[]for i in range(n+1)]\nc=[0]*(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a].append(b)\n s[b].append(a)\ndef dfs(v,t):\n c[v]=t\n for i in s[v]:\n if c[i]==t:\n return False\n if c[i]==0 and not dfs(i,-t):\n return False\n else:\n return True\nif dfs(1,1):\n q=c.count(1)\n print((n-q)*q-m)\nelse:\n print((n*(n-1)//2)-m)", "neg": "import sys\nsys.setrecursionlimit(10**6)\nn,m=map(int,input().split())\ns=[[]for i in range(n+1)]\nc=[0]*(n+1)\nfor i in range(m):\n a,b=map(int,input().split())\n s[a].append(b)\n s[b].append(a)\ndef dfs(v,t):\n c[v]=t\n for i in s[v]:\n if c[i]==t:\n return false\n if c[i]==0 and not dfs(i,-t):\n return false\n else:\n return True\nif dfs(1,1):\n q=c.count(1)\n print((n-q)*q-m)\nelse:\n print((n*(n-1)//2)-m)", "jacc_sim": 0.96, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [208, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u685263709", "n_user": "u685263709", "pos": "from collections import deque\nN, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor m in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n G[a].append(b)\n G[b].append(a)\n\ncolor = [-1 for i in range(N)]\nvisits = [False for i in range(N)]\npaths = deque()\n\n\ndef Bipartial():\n paths.append(0)\n color[0] = 0\n while paths:\n x = paths.pop()\n visits[x] = True\n for g in G[x]:\n if visits[g] and color[g] == color[x]:\n return False\n elif not visits[g]:\n paths.append(g)\n color[g] = (color[x]+1) % 2\n return True\n\n\nif Bipartial():\n B = color.count(0)\n W = color.count(1)\n ans = B * W - M\nelse:\n ans = (N * (N - 1)) // 2 - M\nprint(ans)", "neg": "from collections import deque\nN, M = map(int, input().split())\nG = [[] for i in range(N)]\nfor m in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n G[a].append(b)\n G[b].append(a)\n\ncolor = [-1 for i in range(N)]\nvisits = [False for i in range(N)]\npaths = deque()\n\n\ndef Bipartial():\n paths.append(0)\n color[0] = 0\n while paths:\n x = paths.pop()\n visits[x] = True\n for g in G[x]:\n if visits[g] and color[g] == color[x]:\n return False\n elif not visits[g]:\n paths.append(g)\n color[g] = (color[x]+1) % 2\n return True\n\n\nif Bipartial():\n B = color.count(0)\n W = color.count(1)\n ans = B * W - M\nelse:\n ans = (N * (N - 1)) // 2 - M\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [287, 288], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u069838609", "n_user": "u069838609", "pos": "import sys\nsys.setrecursionlimit(100000)\nfin = sys.stdin.readline\n\nN, M = [int(elem) for elem in fin().split()]\nadj = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = [int(elem) - 1 for elem in fin().split()]\n adj[a].append(b)\n adj[b].append(a)\n\n\ndef judge_bipartite(adj, v, color, colors):\n colors[v] = color\n for neighbor in adj[v]:\n if colors[neighbor] is None:\n if not judge_bipartite(adj, neighbor, 1 - color, colors):\n return False\n else:\n if colors[neighbor] == color:\n return False\n else:\n return True\n\ncolors = [None] * N\nbipartite = judge_bipartite(adj, 0, 0, colors)\n\nif not bipartite:\n print(N * (N - 1) // 2 - M)\nelse:\n num_b = sum([v == 0 for v in colors])\n num_w = N - num_b\n print(num_b * num_w - M)\n\n", "neg": "import sys\nsys.setrecursionlimit(100000)\nfin = sys.stdin.readline\n\nN, M = [int(elem) for elem in fin().split()]\nadj = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = [int(elem) - 1 for elem in fin().split()]\n adj[a].append(b)\n adj[b].append(a)\n\n\ndef judge_bipartite(adj, v, color, colors):\n colors[v] = color\n for neighbor in adj[v]:\n if colors[neighbor] is None:\n if not judge_bipartite(adj, neighbor, 1 - color, colors):\n return False\n else:\n if colors[neighbor] == color:\n return False\n else:\n return True\n\ncolors = [None] * N\nbipartite = judge_bipartite(adj, 0, 0, colors)\nprint(bipartite, colors)\nif not bipartite:\n print(N * (N - 1) // 2 - M)\nelse:\n num_b = sum([v == 0 for v in colors])\n num_w = N - num_b\n print(num_b * num_w - M)\n", "jacc_sim": 1.0, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [297, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u820560680", "n_user": "u820560680", "pos": "import sys\nsys.setrecursionlimit(1000000)\n\nN, M = map(int, input().split())\n\nG = [[] for i in range(N)]\nfor _ in range(M):\n Ai, Bi = map(int, input().split())\n G[Ai - 1].append(Bi - 1)\n G[Bi - 1].append(Ai - 1)\n\ncolor = [0] * N\ndef dfs(v, c):\n '''\n \u9802\u70b9v\u3092c\u3067\u5857\u308b\u3000\u305d\u3053\u304b\u3089\u6df1\u3055\u512a\u5148\u63a2\u7d22\u3067\u4ea4\u4e92\u306b\u5857\u3063\u3066\u3044\u304f\n '''\n color[v] = c\n for i in G[v]:\n if color[i] == c:\n return False\n if color[i] == 0 and not(dfs(i, -c)):\n return False\n return True\n\nif dfs(0, 1):\n print(color.count(1) * color.count(-1) - M)\nelse:\n print(N * (N - 1) // 2 - M)\n", "neg": "import sys\nsys.getrecursionlimit(1000000)\n\nN, M = map(int, input().split())\n\nG = [[] for i in range(N)]\nfor _ in range(M):\n Ai, Bi = map(int, input().split())\n G[Ai - 1].append(Bi - 1)\n G[Bi - 1].append(Ai - 1)\n\ncolor = [0] * N\ndef dfs(v, c):\n '''\n \u9802\u70b9v\u3092c\u3067\u5857\u308b\u3000\u305d\u3053\u304b\u3089\u6df1\u3055\u512a\u5148\u63a2\u7d22\u3067\u4ea4\u4e92\u306b\u5857\u3063\u3066\u3044\u304f\n '''\n color[v] = c\n for i in G[v]:\n if color[i] == c:\n return False\n if color[i] == 0 and not(dfs(i, -c)):\n return False\n return True\n\nif dfs(0, 1):\n print(color.count(1) * color.count(-1) - M)\nelse:\n print(N * (N - 1) // 2 - M)\n", "jacc_sim": 0.9722222222222222, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [306, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03579", "p_user": "u694433776", "n_user": "u694433776", "pos": "import sys\nsys.setrecursionlimit(10**8)\nn, m = map(int, input().split())\nedge = [[] for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edge[a].append(b)\n edge[b].append(a)\n# -1 \u2192 0,1\u306b\u5857\u3063\u3066\u3044\u304d\u307e\u3059\ncolor=[-1 for i in range(n)]\ndef dfs(pos):\n ret = True\n for i in range(len(edge[pos])):\n to = edge[pos][i]\n if color[to] == -1:\n color[to] = 1 ^ color[pos]\n ret &= dfs(to)\n else:\n ret &= not (color[to]==color[pos])\n return ret\n\ncolor[0]=0\nif dfs(0):\n black, white = 0, 0\n for i in range(n):\n if color[i]==0:\n black += 1\n else:\n white += 1\n print(black*white-m)\nelse:\n print(n*(n-1)//2-m)", "neg": "n, m = map(int, input().split())\nedge = [[] for i in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edge[a].append(b)\n edge[b].append(a)\n# -1 \u2192 0,1\u306b\u5857\u3063\u3066\u3044\u304d\u307e\u3059\ncolor=[-1 for i in range(n)]\ndef dfs(pos):\n ret = True\n for i in range(len(edge[pos])):\n to = edge[pos][i]\n if color[to] == -1:\n color[to] = 1 ^ color[pos]\n ret &= dfs(to)\n else:\n ret &= color[to]==color[pos]\n return ret\n\ncolor[0]=0\nif dfs(0):\n print(color)\n black, white = 0, 0\n for i in range(n):\n if color[i]==0:\n black += 1\n else:\n white += 1\n print(black*white-m)\nelse:\n print(n*(n-1)//2-m)", "jacc_sim": 0.9016393442622951, "nl": "Rng has a connected undirected graph with N vertices and M edges. Rng will add new edges to the graph by choosing two vertices u and v (u \u2260 v) such that v can be reached by traversing exactly three edges from u, and then adding an edge connecting u and v. The task is to find the maximum possible number of edges that can be added. The constraints are 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, and the graph has no self-loops or multiple edges, and is connected. The input is given in the format N M followed by pairs of A and B values. The output should be the maximum possible number of edges that can be added. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [311, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u666550725", "n_user": "u666550725", "pos": "N = int(input())\nans = 0\nfor i in range(6):\n ans += N % 10\n N //= 10\nprint(ans)", "neg": "N = int(input())\nans = 0\nfor i in range(6):\n ans += N % 10\n ans //= 10", "jacc_sim": 0.9473684210526315, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [36, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u029000441", "n_user": "u029000441", "pos": "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n ans=0\n for i in range(6):\n if s[i]==\"1\":\n ans+=1\n print(ans) \n \n\n \n \n \n \n \nif __name__==\"__main__\":\n main()\n\n", "neg": "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return map(int, input().split())\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print('\\n'.join(x))\n def printni(x): print('\\n'.join(list(map(str,x))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n s=SI()\n ans=0\n for i in range(6):\n if s[i]==1:\n ans+=1\n print(ans) \n \n\n \n \n \n \n \nif __name__==\"__main__\":\n main()\n\n", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [330, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u026155812", "n_user": "u026155812", "pos": "s=input()\nnum=0\nfor x in s:\n if x==\"1\":\n num+=1\nprint(num)\n", "neg": "s=input()\nnum=0\nfor x in s:\n if x==1:\n num+=1\nprint(num)", "jacc_sim": 0.9375, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [33, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u683134447", "n_user": "u683134447", "pos": "s = list(input())\n\nans = 0\n\nfor ss in s:\n ans += int(ss)\nprint(ans)", "neg": "s = list(input())\n\nans = 0\n\nfor ss in s:\n ans += int(s)\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [31, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u475503988", "n_user": "u989306199", "pos": "s = input()\nans = 0\nfor c in s:\n if c == '1':\n ans += 1\nprint(ans)\n", "neg": "s=input()\nans = 0\nfor c in s:\n if c==\"1\"\n ans+=1\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [33, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u556371693", "n_user": "u556371693", "pos": "s=input()\nans=0\nfor _ in range(6):\n if s[_]=='1':\n ans+=1\nprint(ans)", "neg": "s=input()\nans=0\nfor_ in range(6):\n if s[_]=='1':\n ans+=1\nprint(ans)\n", "jacc_sim": 0.9047619047619048, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [37, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u316401642", "n_user": "u223904637", "pos": "s = list(input())\nans = 0\nfor i in s:\n if i == '1':\n ans += 1\nprint(ans)", "neg": "s=list(input())\nans=0\nfor i in s:\n if s=='1':\n ans+=1\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [34, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u555962250", "n_user": "u393558821", "pos": "S = input()\nans = 0\nfor i in S:\n if i == '1':\n ans += 1\nprint(ans)", "neg": " ans = 0\n for i in input():\n if i == '1':\n ans += 1\n print(ans)", "jacc_sim": 0.9375, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [32, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u995006955", "n_user": "u898651494", "pos": "s=input()\nans=0\nfor i in s:\n\tif(i=='1'):\n\t\tans+=1\n\nprint(ans)", "neg": "s=input()\nans=0\nfor i in s:\n if i==1:\n ans+=1\nprint(ans)", "jacc_sim": 0.9375, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [36, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u821084099", "n_user": "u953110527", "pos": "S = input()\ncount = 0\nfor i in S:\n if i == '1':\n count += 1\nprint(count)", "neg": "S = input()\ncount = 0\nfor i in S:\n if i == '1':\n count++\nprint(count)", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [31, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u620480037", "n_user": "u131405882", "pos": "S=input()\nans=0\nfor i in range(6):\n if S[i]==\"1\":\n ans+=1\nprint(ans)", "neg": "S = input()\nans = 0\nfor i in range(6):\n if S[i] == 1:\n ans += 1\nprint(ans)", "jacc_sim": 0.95, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [37, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u989385104", "n_user": "u989385104", "pos": "S = int(input())\n\nlst = []\nwhile S > 0:\n lst.append(S%10)\n S //= 10 # \u5fc5\u9808\nlst.reverse()\n\nprint(sum(lst))\n ", "neg": "S = int(input())\n\nlst = []\nwhile i > 0:\n lst.append(S%10)\n S //= 10 # \u5fc5\u9808\nlst.reverse()\n\nprint(sum(lst))\n ", "jacc_sim": 0.96, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [56, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u102960641", "n_user": "u268792407", "pos": "s = input()\na = 0\nfor i in range(6):\n if s[i] == \"1\":\n a += 1\nprint(a)", "neg": "s=input()\na=0\nfor i in range(6):\n if s[i]==\"1\":\n a+-1\nprint(a)", "jacc_sim": 0.9523809523809523, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u898651494", "n_user": "u898651494", "pos": "s=input()\nans=0\nfor i in range (6):\n if int(s[i])==1:\n ans+=1\nprint(ans)", "neg": "s=input()\nans=0\nfor i range 6:\n if int(s[i])==1:\n ans+=1\nprint(ans)", "jacc_sim": 0.95, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [39, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u080990738", "n_user": "u080990738", "pos": "a =input() \nc=0\nfor i in range(0,6):\n if a[i] == \"1\":\n c += 1\n else:\n pass\nprint(c)\n", "neg": "a =input() \nc=0\nfor i in range(0,6):\n if a[i] == 1:\n c += 1\n else:\n pass\nprint(c)\n", "jacc_sim": 0.9565217391304348, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [48, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u780709476", "n_user": "u217627525", "pos": "s = input()\nans = 0\nfor i in range(len(s)):\n if(s[i] == '1'):\n ans += 1\nprint(ans)\n", "neg": "s=input()\nans=0\nfor i in range(n):\n if s[i]==\"1\":\n ans+=1\nprint(ans)", "jacc_sim": 0.9047619047619048, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [43, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u497285470", "n_user": "u497285470", "pos": "inputs = input()\n\nprint(inputs.count('1'))", "neg": "inputs = input().split\n\nprint(inputs.count('1'))", "jacc_sim": 0.9090909090909091, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [14, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u698535708", "n_user": "u698535708", "pos": "a = input()\nans = 0\nfor i in a:\n if i=='1':\n ans += 1\n \nprint(ans)", "neg": "a = input()\nans = 0\nfor i in a:\n if a=='1':\n ans += 1\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [33, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u743272507", "n_user": "u131405882", "pos": "a = input()\nans = 0\nfor i in range(6):\n if a[i] == \"1\": ans += 1\nprint(ans)", "neg": "S = input()\nans = 0\nfor i in range(6):\n if S[i] == \"1\":\n ans += 1\nprint(i)", "jacc_sim": 0.9047619047619048, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [35, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u218984487", "n_user": "u358254559", "pos": "s = list(input())\nprint(s.count(\"1\"))\n", "neg": "s=input()\nprint(s.count(\"1\")", "jacc_sim": 0.9090909090909091, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [17, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03587", "p_user": "u205803237", "n_user": "u943004959", "pos": "S = input()\n\nprint(S.count(\"1\"))", "neg": "S = list(input())\nprint(S.count(\"1\")", "jacc_sim": 0.9090909090909091, "nl": "Snuke has prepared 6 problems for an upcoming programming contest. For each problem, Rng judges whether it can be used. Given a string S of length 6, where each character represents whether a problem is accepted (1) or not (0), determine the number of problems accepted for the contest. Constraints: S consists of 0s and 1s. Input is given as S. Output the number of accepted problems. Example: Input: 111100, Output: 4 (first four problems are accepted).", "before_after_length": [15, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u642012866", "n_user": "u642012866", "pos": "N = int(input())\nx = 0\nans = 0\nfor _ in range(N):\n A, B = map(int, input().split())\n if A > x:\n x = A\n ans = B\nprint(x+ans)", "neg": "N = int(input())\nx = 0\nans = 0\nfor _ in range(N):\n A, B = map(int, input().split())\n if A > x:\n x = A\n ans = B\n print(x+ans)", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [60, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u970198631", "n_user": "u970198631", "pos": "N = int(input())\nmini1 = 0\nmini2 = 0\nfor i in range(N):\n MM = input().split()\n a = int(MM[0])\n b = int(MM[1])\n if a > mini1:\n mini1 = a\n mini2 = b\n \nprint(mini1 + mini2)", "neg": "N = int(input())\nmini1 = 0\nmini2 = 0\nfor i in range(N):\n MM = input().split()\n a = int(MM[0])\n b = int(MM[1])\n if a > mini1:\n mini1 = a\n mini2 = b\nprint(a+b)", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [86, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u503111914", "n_user": "u503111914", "pos": "N = int(input())\nM = 0\nm = 10**9\nc = 0\nfor i in range(N):\n a,b = map(int,input().split())\n if m >= a:\n m = a\n if M < a:\n M = a\n c = b + 1\nans = c+M-1\nprint(ans)\n", "neg": "N = int(input())\nM = 0\nm = 10**9\nc = 0\nfor i in range(N):\n a,b = map(int.input().split())\n if m >= a:\n m = a\n if M < a:\n M = a\n c = b + 1\nprint(c+m-M)", "jacc_sim": 0.96875, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [87, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u657208344", "n_user": "u657208344", "pos": "n = int(input())\nans = 0\nnow = -1\nfor i in range(n):\n a,b = map(int,input().split())\n if a > now:\n now = a\n ans = a + b\n\nprint(ans)", "neg": "n = int(input())\nans = 0\nnow = -1\nfor i in range(n):\n a,b = map(int,input().split())\n if a > now:\n ans = a + b\n\nprint(ans)", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [62, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u086503932", "n_user": "u086503932", "pos": "#!/usr/bin/env python3\nfrom collections import deque, Counter\nfrom heapq import heappop, heappush\nfrom bisect import bisect_right\n\ndef main():\n N = int(input())\n A = [None] * N\n B = [None] * N\n for i in range(N):\n A[i], B[i] = map(int, input().split())\n print(max(A)+B[A.index(max(A))])\n\nif __name__ == \"__main__\":\n main()\n", "neg": "#!/usr/bin/env python3\nfrom collections import deque, Counter\nfrom heapq import heappop, heappush\nfrom bisect import bisect_right\n\ndef main():\n N = int(input())\n A = [None] * N\n B = [None] * N\n for i in range(N):\n A[i], B[i] = map(int, input().split())\n print(max(A[i])+B.index(max(A[i])))\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [130, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u813174766", "n_user": "u813174766", "pos": "n=int(input())\na=0\nans=0\nfor i in range(n):\n x,y=map(int,input().split())\n if a maxi:\n\t\tmaxi = A\n\t\tsc = B\nprint(maxi + sc)", "neg": "N = int(input())\n\nmaxi = -1\nsc = 0\n\nfor i in range(N):\n\tA, B = map(int, input().split())\n\tif A > mini:\n\t\tmini = A\n\t\tsc = B\nprint(mini + sc)\n", "jacc_sim": 0.9629629629629629, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [69, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u794173881", "n_user": "u794173881", "pos": "from operator import itemgetter\n\n\nn = int(input())\ninfo = [list(map(int, input().split())) for i in range(n)]\n\ninfo = sorted(info, key = itemgetter(1))\nprint(info[0][0] + info[0][1])", "neg": "from operator import itemgetter\n\n\nn = int(input())\ninfo = [list(map(int, input().split())) for i in range(n)]\n\ninfo = sorted(info, key = itemgetter(1))\nprint(info[0][0] + info[0][])", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [65, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u377989038", "n_user": "u414458988", "pos": "n = int(input())\na = sorted([list(map(int, input().split())) for _ in range(n)])\nprint(sum(a[-1]))", "neg": "n=int(input())\na=sorted(list(map(int,input().split())) for _ in range(n))\nprint(sum(a[-1])", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [39, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u077291787", "n_user": "u077291787", "pos": "# tenka1-2017-beginnerB - Different Distribution\ndef main():\n N, *AB = map(int, open(0).read().split())\n A = [(i, j) for i, j in zip(*[iter(AB)] * 2)]\n A.sort()\n ans = sum(A[-1])\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# tenka1-2017-beginnerB - Different Distribution\ndef main():\n N, *AB = map(int, open(0).read().split())\n A = [sum(i, j) for i, j in zip(*[iter(AB)] * 2)]\n ans == max(A)\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9333333333333333, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [100, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u787456042", "n_user": "u787456042", "pos": "N,*A=map(int,open(0).read().split())\ni=2*sorted(enumerate(A[::2]),key=lambda x:x[1])[-1][0]\nprint(A[i]+A[i+1])", "neg": "N,*A=map(int,open(0).read().split())\ni=2*sorted(enumerate(A[::2]),lambda x:x[1])[-1][0]\nprint(A[i]+A[i+1])", "jacc_sim": 0.9642857142857143, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [60, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u927534107", "n_user": "u927534107", "pos": "n=int(input())\nprint(sum(sorted([list(map(int,input().split())) for _ in range(n)])[-1]))", "neg": "n=int(input())\nl=[list(map(int,input().split())) for _ in range(n)]\nprint(sum(l[-1]))", "jacc_sim": 0.9130434782608695, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [35, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u399721252", "n_user": "u399721252", "pos": "\nn = int(input())\npoint_list = sorted([[ int(v) for v in input().split() ] for i in range(n) ])\nprint(point_list[-1][0]+point_list[-1][1])", "neg": "n = int(input())\npoint_list = sorted([[ int(v) for v in input().split() ] for i in range(n) ])\nprint(point_list[0][0]+point_list[0][1])\n", "jacc_sim": 0.9545454545454546, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [55, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u918935103", "n_user": "u918935103", "pos": "n = int(input())\na = 0\nb = 0\nfor i in range(n):\n a1,b1 = map(int,input().split())\n if a < a1:\n a = a1\n b = b1\nprint(a+b)", "neg": "n = int(input())\na = 0\nfor i in range(n):\n a1,b1 = map(int,input().split())\n if a < a1:\n a = a1\n b = b1\nprint(a + b-1)", "jacc_sim": 0.9230769230769231, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [65, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u013756322", "n_user": "u013756322", "pos": "n = int(input())\nA = [None] * n\nB = [None] * n\nfor i in range(n):\n A[i], B[i] = list(map(int, input().split()))\n\nprint(A[B.index(min(B))] + min(B))", "neg": "n = int(input())\nA = [None] * n\nB = [None] * n\nfor i in range(n):\n A[i], B[i] = list(map(int, input().split()))\n\nprint(A[B.index(min_point)] + min(B))", "jacc_sim": 0.9629629629629629, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [72, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u367130284", "n_user": "u367130284", "pos": "n,*a=map(int,open(0).read().split())\nb=[a[i]for i in range(0,len(a),2)]\nc=[a[i]for i in range(1,len(a),2)]\nprint(max(b)+c[b.index(max(b))])", "neg": "n,*a=map(int,read(0).split())\nb=max([a[i]for i in range(0,len(a),2)])\nprint(b+a[a.index(b)+1])", "jacc_sim": 0.9310344827586207, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [75, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u359856428", "n_user": "u359856428", "pos": "\nn = int(input())\ntemp = 0\nans = 0\nfor i in range(n):\n a,b = map(int,input().split(' '))\n if a > temp:\n ans = a + b\n temp = a\nprint(ans)", "neg": "\nn = int(input())\ntemp = 0\nans = 0\nfor i in range(n):\n a,b = map(int,input().split(' '))\n if a > temp:\n ans = a + b\nprint ans", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [63, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u853900545", "n_user": "u853900545", "pos": "n=int(input())\na=[0]*n\nb=[0]*n\nfor i in range(n):\n a[i],b[i]=map(int,input().split())\ny=max(a)\nprint(y+b[a.index(y)])", "neg": "n=int(input())\na=[0]*n\nb=[0]*n\nfor i in range(n):\n a[i],b[i]=map(int,input().split())\ny=max(a)\nprint(y+b[y])", "jacc_sim": 0.9615384615384616, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [66, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u433780933", "n_user": "u433780933", "pos": "n = int(input())\na =0\nb =0\nfor i in range(n):\n nums = [int(num) for num in input().split()]\n aa = nums[0]\n bb = nums[1]\n if aa > a:\n a = aa\n b = bb\nprint(a + b)\n ", "neg": "n = int(input())\na =0\nb =0\nfor i in range(n):\n nums = [int(num) for num in input().split]\n aa = nums[0]\n bb = nums[1]\n if aa > a:\n a = aa\n b = bb\nprint(a + b)\n ", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [81, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u098968285", "n_user": "u098968285", "pos": "n = int(input())\n\nmaxm = 0\nnum = -1\n\nfor i in range(n):\n a, b = map(int, input().split())\n if a > maxm:\n maxm = a\n num = b\n\nprint(maxm + num)\n", "neg": "n = int(input())\n\nmaxm = 0\nnum = -1\n\nfor i in range():\n a, b = map(int, input().split())\n if a > maxm:\n maxm = a\n num = b\n\nprint(maxm + num)", "jacc_sim": 1.0, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [69, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u341087021", "n_user": "u341087021", "pos": "n = int(input())\n\np = 0\ns = 0\n\nfor i in range(n):\n a,b = [int(x) for x in input().split()]\n if i == 0:\n p,s = a,b\n else:\n if a > p:\n p,s = a,b\n else:\n pass\n\nprint(p+s)", "neg": "n = int(input())\n\np = 0\ns = 0\n\nfor i in range(n):\n a,b = [int(x) for x in input().split()]\n if p < a:\n p, s = a, b\n else:\n pass\n\nprint(a+b)", "jacc_sim": 0.9310344827586207, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [94, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u855200003", "n_user": "u855200003", "pos": "N = int(input())\ndic = {}\nfor i in range(N):\n a,b = [int(j) for j in input().split(\" \")]\n dic[a] = b\nmax_keys = max(dic.keys())\nmin_value = dic[max_keys]\nprint(max_keys+min_value)", "neg": "N = int(input())\ndic = {}\nfor i in range(N):\n a,b = [int(j) for j in input().split(\" \")]\n dic[a] = b\nans = len(dic)\nmax_keys = max(dic.keys())\nmin_value = dic[max_keys]\nprint(ans + min_value)", "jacc_sim": 0.9354838709677419, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [79, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u895409580", "n_user": "u895409580", "pos": "#!user/bin/env python\n# coding:utf-8\n\nn = int(input())\ninfo = []\n\nfor i in range(n):\n # ai = int(input())\n # bi = int(input())\n abi = input()\n ai, bi = int(abi.split(' ')[0]), int(abi.split(' ')[1])\n \n info.append([ai, bi])\n\ninfo = sorted(info, key=lambda inf: inf[1])\n\nimp = info[0][0] + info[0][1]\nprint(imp)", "neg": "#!user/bin/env python\n# coding:utf-8\n\nn = int(input())\ninfo = []\n\nfor i in range(n):\n ai = int(input())\n bi = int(input())\n info.append([ai, bi])\n\ninfo = sorted(info, key=lambda inf: inf[1])\n\nimp = info[0][0] + info[0][1]\nprint(imp)", "jacc_sim": 0.9285714285714286, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [138, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u796424048", "n_user": "u600261652", "pos": "N = int(input())\nA = []\nB = []\nfor i in range(N):\n a,b = map(int,input().split())\n A.append(a)\n B.append(b)\n\nres = max(A)\nres += min(B)\n\nprint(res)", "neg": "N = int(input())\nA = []\nB = []\nfor i in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nprint(max(A)+B[A.index(min(A))])", "jacc_sim": 0.9285714285714286, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [73, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u069170167", "n_user": "u600261652", "pos": "N = int(input())\nA = []\nB = []\nfor i in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nprint(B[A.index(max(A))]+max(A))", "neg": "N = int(input())\nA = []\nB = []\nfor i in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\nprint(min(A)+B[A.index(min(A))])", "jacc_sim": 0.9259259259259259, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [70, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03588", "p_user": "u054556734", "n_user": "u054556734", "pos": "n=int(input())\n\nmax=0\nfor i in range(n):\n a,b=map(int,input().split())\n if a>max: max=a; ans=a+b\n\nprint(ans)", "neg": "n=int(input())\n\nmax=0\nfor i in range(n):\n a,b=map(int,input().split())\n if a>max: ans=a+b\n\nprint(ans)", "jacc_sim": 0.96, "nl": "In a game, each player has a distinct positive integer score. Takahashi knows N facts about the players' scores. The i-th fact is that the A_i-th highest score among the players is B_i. The task is to find the maximum possible number of players in the game. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 A_i \u2264 10^9, 0 \u2264 B_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and there exists a consistent outcome. The input is given in the format N, followed by N lines of A_i and B_i. The output should be the maximum possible number of players. Example inputs and outputs are provided.", "before_after_length": [55, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03590", "p_user": "u786020649", "n_user": "u786020649", "pos": "import sys\nreadline=sys.stdin.readline\nread=sys.stdin.read\n\ndef main():\n n,k=map(int,readline().split())\n ab=[list(map(int,l.split())) for l in read().splitlines()]\n \n ek=0\n while k>>ek:\n ek+=1\n\n cand=[]\n for i in range(ek):\n if k>>i&1:\n m=(k>>(i+1))<<(i+1)|((1<>ek:\n ek+=1\n ans=0\n for i in range(ek):\n if k>>i&1:\n m=(k>>(i+1))<<(i+1)|((1<>b) & 1:\n\t\ttmp += (1<>b) & 1:\n\t\tprint(b)\n\t\ttmp += (1<> p) << p\n KKK = (K >> p)\n t = sum(b for a, b in ABs if (not(a & v) and (a | KK) >> p == KKK))\n if t > ansK: ansK = t\n return ansK\n \n\nN, K = map(int, input().split())\nABs = []\nfor i in range(N):\n a, b = map(int, input().split())\n if a > K: continue\n ABs.append([a, b])\n\nprint(solve(K, ABs))", "neg": "def solve(K, ABs):\n if not ABs: return 0\n ansK = sum(b for a, b in ABs if (K | a) == K)\n pool = []\n for i in range(30, -1, -1):\n if (K & (1<> p) << p\n t = sum(b for a, b in ABs if (not(a & v) and a <= KK))\n if t > ansK: ansK = t\n return ansK\n \n\nN, K = map(int, input().split())\nABs = []\nfor i in range(N):\n a, b = map(int, input().split())\n if a > K: continue\n ABs.append([a, b])\n\nprint(solve(K, ABs))", "jacc_sim": 0.9782608695652174, "nl": "You are given a store that sells non-negative integers, each with a corresponding utility. Takahashi wants to buy a combination of integers whose bitwise OR is less than or equal to a given value K. The goal is to find the maximum possible sum of utilities of the purchased integers. The constraints are: 1 \u2264 N \u2264 10^5, 0 \u2264 K < 2^30, 0 \u2264 A_i < 2^30 (1 \u2264 i \u2264 N), and 1 \u2264 B_i \u2264 10^9 (1 \u2264 i \u2264 N). The input is given in the format: N K, followed by N lines of A_i and B_i. The output should be the maximum possible sum of utilities. For example, given the input 3 5, with subsequent lines 3 3, 4 4, 2 5, the output should be 8.", "before_after_length": [243, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u882575405", "n_user": "u937238023", "pos": "s = input()\nif len(s) >= 4 and s[:4] == \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\");\n", "neg": "s = input()\nif len(s)>=4 and s[:4] = \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.95, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [39, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u693933222", "n_user": "u075155299", "pos": "s = input()\n\nans = 0\n\nif (len(s) >= 4):\n if (s[0:4] == \"YAKI\"):\n ans = 1\n\nif (ans == 1):\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s=input()\n\nif len(s)>=4:\n if s[0:4]==\"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [65, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u905582793", "n_user": "u905582793", "pos": "print(\"NYoe s\"[input()[:4]==\"YAKI\"::2])", "neg": "print(\"NYoe s\"[int(input())[:4]==\"YAKI\"::2])", "jacc_sim": 0.9333333333333333, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [21, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u186838327", "n_user": "u227082700", "pos": "s = str(input())\nif len(s) <= 3:\n print('No')\nelif s[:4] == 'YAKI':\n print('Yes')\nelse:\n print('No')", "neg": "s=input()\nif len(s)<4:print(\"No\")\nelif s[:3]=print(\"Yes\")\nelse:print(\"No\")", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [49, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u223904637", "n_user": "u223904637", "pos": "s=list(input())\nif len(s)>=4 and s[0:4]==list('YAKI'):\n print('Yes')\nelse:\n print('No')", "neg": "s=list(input())\nif len(s)>=4 and s[0:5]==list('YAKI'):\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9545454545454546, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [45, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u396495667", "n_user": "u476124554", "pos": "s = input()\nprint('Yes' if len(s)>=4 and s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I' else 'No')", "neg": "s = input()\nif s[0] == 'Y' and s[1] == \"A\" and s[2] == \"K\" and s[3] == \"I\" and len(s) >= 4:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9615384615384616, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [53, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u937642029", "n_user": "u674569298", "pos": "s=list(input())\n\nif(len(s)>3 and s[0]==\"Y\" and s[1]==\"A\" and s[2]==\"K\" and s[3]==\"I\"):\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n", "neg": "s = list(input())\nif s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':\n print('Yes')\nelse:\n print('No')\n", "jacc_sim": 0.9230769230769231, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [67, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u303059352", "n_user": "u303059352", "pos": "n = input()\nprint(\"No\" if len(n) < 4 else \"Yes\" if n[:4] == \"YAKI\" else \"No\")", "neg": "n = input()\nprint(\"No\" if len(n) < 4 else \"Yes\" if n[:4] is \"YAKI\" else \"No\")", "jacc_sim": 0.9473684210526315, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [35, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u591779169", "n_user": "u591779169", "pos": "import re\nprint(\"Yes\" if re.search(\"^YAKI,*\", input()) else \"No\")", "neg": "import re\nprint(\"Yes\" if re.search(\"YAKI,*\", input()) else \"No\")", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [25, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u434208140", "n_user": "u434208140", "pos": "s=input()\na=False\nif(len(s)>3):\n if(s[0:4]==\"YAKI\"):\n a=True\nprint(\"Yes\" if a else \"No\")", "neg": "s=input()\na=False\nif(len(s)>3):\n if(s[0:4]=\"YAKI\"):\n a=True\nprint(\"Yes\" if a else \"No\")", "jacc_sim": 1.0, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [50, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u940102677", "n_user": "u940102677", "pos": "s = input()\nn = len(s)\nif n<4:\n print(\"No\")\nelif s[:4] == \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\nn = len(s)\nif n<4:\n print(\"No\")\nelif s[:4] == \"Yaki\":\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [51, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u611509859", "n_user": "u858136677", "pos": "s = list(input())\nif len(s) <= 3:\n print(\"No\")\nelif s[0] == \"Y\" and s[1] == \"A\" and s[2] == \"K\" and s[3] == \"I\":\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\nif len(s) <= 3:\n\tprint('No')\nelse:\n\tif s[0] == Y and s[1] == A and s[2] == K and s[3] == I:\n\t\tprint('Yes')\n\telse:\n\t\tprint('No')", "jacc_sim": 0.9259259259259259, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [74, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u077685310", "n_user": "u077685310", "pos": "a=list(input())\nif len(a)<=3:\n\tprint(\"No\")\nelse:\n\tif a[0]==\"Y\" and a[1]==\"A\" and a[2]==\"K\" and a[3]==\"I\":\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")", "neg": "a=list(input())\nif len(a)<=3:\n\tprint(\"No\")\nelse:\n\tif a[0]==\"T\" and a[1]==\"A\" and a[2]==\"K\" and a[3]==\"I\":\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")", "jacc_sim": 0.9259259259259259, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [77, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u813450984", "n_user": "u371409687", "pos": "s = input()\nif len(s) < 4:\n print('No')\nelse:\n t = s[:4]\n if t == 'YAKI':\n print('Yes')\n else:\n print('No')", "neg": "s=input()\nif len(s)<4:\n print(\"No\")\nif s[:4]==\"YAKI\":\n print(\"Yes\")\nelse:(\"No\")", "jacc_sim": 0.9473684210526315, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [56, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u828744308", "n_user": "u652656291", "pos": "s=str(input())\nif s[:4]==\"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")\n", "neg": "s = input()\nif s[:4] = 'YAKI':\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [33, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u781495081", "n_user": "u898651494", "pos": "s=input()\nif(len(s)>=4) :\n\tif(s[:4]==\"YAKI\"): \n\t\tprint(\"Yes\")\n\telse : print(\"No\")\nelse : print(\"No\")", "neg": "s=input()\nprint(\"Yes\" if len(s)>=4 && s[:4]==\"YAKI\" else \"No\")", "jacc_sim": 0.9473684210526315, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [52, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u885958935", "n_user": "u885958935", "pos": "import sys\nst = input()\nif len(st) < 4:\n print('No')\n sys.exit()\nif st[0] == 'Y':\n if st[1] == 'A':\n if st[2] == 'K':\n if st[3] == 'I':\n print('Yes')\n else:\n print('No')\n else:\n print('No')\n else:\n print('No')\nelse:\n print('No')\n\n\n", "neg": "import sys\nst = input()\nif len(st) < 3:\n print('No')\n sys.exit()\nif st[0] == 'Y':\n if st[1] == 'A':\n if st[2] == 'K':\n if st[3] == 'I':\n print('Yes')\n else:\n print('No')\n else:\n print('No')\n else:\n print('No')\nelse:\n print('No')\n\n\n", "jacc_sim": 0.9655172413793104, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [119, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u665415433", "n_user": "u665415433", "pos": "s = input()\na = 'YAKI'\nans = 0\nif len(s) >= 4:\n for i in range(4):\n if s[i] == a[i]:\n ans = 1\n else:\n ans = 0\n break\nif ans == 1:\n print('Yes')\nelse:\n print('No')", "neg": "s = input()\na = 'YAKI'\nans = 0\nfor i in range(4):\n if s[i] == a[i]:\n ans = 1\n else:\n break\nif ans == 1:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9259259259259259, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [84, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u586577600", "n_user": "u586577600", "pos": "def isYaki(S):\n if len(S) < 4:\n return 'No'\n \n answer = 'YAKI'\n for (a, b) in zip(answer, S):\n if a != b:\n return 'No'\n return 'Yes'\n\nif __name__ == '__main__':\n S = input()\n print(isYaki(S))\n", "neg": "def isYaki(input):\n if len(input) < 4:\n return 'No'\n \n answer = 'YAKI'\n for (a, b) in zip(answer, input):\n if a != b:\n return 'No'\n return 'Yes'\n\nif __name__ == '__main__':\n input = input('> ')\n print(isYaki(input))\n", "jacc_sim": 0.9333333333333333, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [98, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u425448230", "n_user": "u086503932", "pos": "S = input()\nif len(S) >= 4:\n if S[:4] == \"YAKI\":\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "neg": "S = input()\nif len(S) >= 4 and S[::4] == 'YAKI':\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9473684210526315, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [51, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u925364229", "n_user": "u925364229", "pos": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nS = input()\n\nS = S[0:4]\n\nif \"YAKI\" in S:\n\tprint(\"Yes\")\n\nelse:\n\tprint(\"No\")", "neg": "#! /usr/bin/env python3\n# -*- coding: utf-8 -*-\nS = input()\n\nS = S[0:4]\n\nif S in \"YAKI\":\n\tprint(\"Yes\")\n\nelse:\n\tprint(\"No\")", "jacc_sim": 1.0, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [65, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u157461801", "n_user": "u157461801", "pos": "def solution():\n\ts = list(input().strip())\n\tif len(s) < 4:\n\t\tprint('No')\n\telse:\n\t\ts = ''.join(s[:4])\n\t\tif s == 'YAKI':\n\t\t\tprint('Yes')\n\t\telse:\n\t\t\tprint('No')\n\n\n\nsolution()", "neg": "def solution():\n\ts = list(input().strip())\n\tif len(s) < 4:\n\t\tprint('NO')\n\telse:\n\t\ts = ''.join(s[:4])\n\t\tif s == 'YAKI':\n\t\t\tprint('Yes')\n\t\telse:\n\t\t\tprint('NO')\n\n\n\nsolution()", "jacc_sim": 0.92, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [83, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u497285470", "n_user": "u497285470", "pos": "i = input()\n\nif len(i) < 4:\n print('No')\nelif i[:4] == 'YAKI':\n print('Yes')\nelse:\n print('No')", "neg": "i = input()\n\nif len(i) < 4:\n print('NO')\nelif i[:4] == 'YAKI':\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.95, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [48, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u074201886", "n_user": "u074201886", "pos": "s=input()\ntry:\n if s[0]==\"Y\" and s[1]==\"A\" and s[2]==\"K\" and s[3]==\"I\":\n print(\"Yes\")\n else:\n print(\"No\")\nexcept:\n print(\"No\")\n", "neg": "s=input()\nif s[0]==\"Y\" and s[1]==\"A\" and s[2]==\"K\" and s[3]==\"I\":\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.92, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [67, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u909643606", "n_user": "u525117558", "pos": "s=input()\n\nif len(s)>=4:\n if s[0]==\"Y\" and s[1]==\"A\" and s[2]==\"K\" and s[3]==\"I\" :\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "neg": "s=[input().split()]\nif (len(s)>=4 and s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I'):\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9285714285714286, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [73, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u785205215", "n_user": "u619197965", "pos": "s = str(input())\nif len(s) > 3:\n if s[:4] == \"YAKI\":\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "neg": "s=input()\nif len(s)>=4:\n if s[0:3]==\"YAKI\":\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [53, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u098968285", "n_user": "u098968285", "pos": "# def makelist(n, m):\n# return [[0 for i in range(m)] for j in range(n)]\n\n# n = int(input())\n# a, b = map(int, input().split())\n# s = input()\n\nyes = \"Yes\"\ns = input()\nans = \"YAKI\"\n\nif len(s) >= 4:\n if s[:4] == ans:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")\n", "neg": "# def makelist(n, m):\n# return [[0 for i in range(m)] for j in range(n)]\n\n# n = int(input())\n# a, b = map(int, input().split())\n# s = input()\n\n \ns = input()\nans = \"YAKI\"\n\nif len(s) >= 4:\n if s[4:] == ans:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9743589743589743, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [124, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u243492642", "n_user": "u243492642", "pos": "# coding: utf-8\ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\n\n\ndef read():\n S = str(input())\n return (S,)\n\n\ndef solve(S):\n if len(S) < 4:\n return \"No\"\n if \"\".join(S[0:4]) == \"YAKI\":\n return \"Yes\"\n else:\n return \"No\"\n\n\ndef main():\n params = read()\n print(solve(*params))\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# coding: utf-8\ndef II(): return int(input())\ndef ILI(): return list(map(int, input().split()))\n\n\ndef read():\n S = str(input())\n return (S,)\n\n\ndef solve(S):\n if len(S) < 4:\n return \"No\"\n if \"\".join(S[0:3]) == \"YAKI\":\n return \"Yes\"\n else:\n return \"No\"\n\n\ndef main():\n params = read()\n print(solve(*params))\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9772727272727273, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [149, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u278566247", "n_user": "u898651494", "pos": "s = input()\nif len(s) >= 4 and s[:4] == \"YAKI\":\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "neg": "s=input()\nprint(\"Yes\" if \uff08len(s)>=4 and s[:4]==\"YAKI\"\uff09else \"No\")", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [38, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u075012704", "n_user": "u102126195", "pos": "S = input()\nif S[0:4] == \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")\n\n", "neg": "S = input()\nprint(S)\nif S[:4] == \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [35, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u045939752", "n_user": "u107077660", "pos": "S=input()\nprint( 'Yes' if len(S) >= 4 and S[0:4] == 'YAKI' else 'No')", "neg": "S = input()\nif(len(S) >= 4 and A[:4] == \"YAKI\"):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9047619047619048, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [34, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u172773620", "n_user": "u227082700", "pos": "s = input()\n\nif(len(s)< 4):\n print(\"No\")\nelif(s[:4] == \"YAKI\"):\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s=input()\nif len(s)<4:print(\"No\")\nelif s[:3]==\"YAKI\":print(\"Yes\")\nelse:print(\"No\")\n", "jacc_sim": 0.95, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [51, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u579875569", "n_user": "u422104747", "pos": "a = input()\nif(a[:4] == \"YAKI\"): print(\"Yes\")\nelse: print(\"No\")", "neg": "a=input()\nif a[0:4]==\"YAKI\":\n print(\"Yes\")\nelse\n print(\"No\")", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [29, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u315078622", "n_user": "u107077660", "pos": "S = input()\nprint(\"Yes\" if S[:4] == \"YAKI\" else \"No\")\n", "neg": "S = input()\nif(A[:4] == \"YAKI\"):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [25, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03591", "p_user": "u798181098", "n_user": "u210718367", "pos": "s = input()\nif s[:4] == \"YAKI\":\n print(\"Yes\")\nelse:\n print(\"No\") ", "neg": "s = input()\nif s[0:4] == \"YAKI\":\n print \"Yes\"\nelse:\n print \"No\"", "jacc_sim": 0.9411764705882353, "nl": "Ringo wants to give Snuke a present. Snuke loves \"yakiniku\" (grilled meat in Japanese). Ringo believes Snuke only likes things starting with \"YAKI\" in Japanese. Given a string S representing the Japanese name of the present, determine if it starts with \"YAKI\". Constraints: 1 \u2264 |S| \u2264 10, S consists of uppercase English letters. Input is given in the format of S. Output \"Yes\" if S starts with \"YAKI\", otherwise \"No\". Example: Input \"YAKINIKU\", Output \"Yes\" (starts with \"YAKI\"). Input \"TAKOYAKI\", Output \"No\" (does not start with \"YAKI\"). Input \"YAK\", Output \"No\".", "before_after_length": [32, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u375695365", "n_user": "u375695365", "pos": "a,b,c,d,e,f=map(int,input().split())\n\nwater=set()#\u5165\u308c\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u6c34\u306e\u91cfO(A*B)\nsugar=set()#\u5165\u308c\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u4f50\u85e4\u306e\u91cfO(C*D)\n\nfor i in range(31):\n for j in range(31):\n if 100*i*a+100*j*b<=f:\n water.add(100*i*a+100*j*b)\n\nfor i in range(1501):\n for j in range(1501):\n if c*i+d*j<=f:\n sugar.add(c*i+d*j)\nwater=sorted(list(water))\n#print(water)\n#print(sugar)\nsugar=sorted(list(sugar))\n#print(sugar)\nans=0\nsugarans=0\nsumans=0\nfor i in range(1,len(water)):\n for j in range(len(sugar)):\n if water[i]+sugar[j]<=f and sugar[j]<=e*(water[i]/100):\n if ans<(100*sugar[j])/(water[i]+sugar[j]):\n #print(sugar[j],water[j])\n ans=(100*sugar[j])/(water[i]+sugar[j])\n sugarans=sugar[j]\n sumans=water[i]+sugar[j]\n # print(ans)\nif sumans==0:\n print(100*a,sugarans)\nelse:\n print(sumans,sugarans)", "neg": "a,b,c,d,e,f=map(int,input().split())\n\nwater=set()#\u5165\u308c\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u6c34\u306e\u91cfO(A*B)\nsugar=set()#\u5165\u308c\u308b\u53ef\u80fd\u6027\u306e\u3042\u308b\u4f50\u85e4\u306e\u91cfO(C*D)\n\nfor i in range(31):\n for j in range(31):\n water.add(100*i*a+100*j*b)\n\nfor i in range(1501):\n for j in range(1501):\n sugar.add(c*i+d*j)\nwater=sorted(list(water))\n#print(water)\nsugar=sorted(list(sugar))\n#print(sugar)\nans=0\nsumans=0\nfor i in range(1,len(water)):\n for j in range(len(sugar)):\n if water[i]+sugar[j]<=f and (sugar[j]/(water[i]//100))<=e:\n if ans<(100*sugar[j])//(water[i]+sugar[j]):\n #print(sugar[j],water[j])\n ans=(100*sugar[j])/(water[i]+sugar[j])\n sugarans=sugar[j]\n sumans=water[i]+sugar[j]\nprint(sumans,sugarans)\n", "jacc_sim": 0.984375, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [470, 399], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u150117535", "n_user": "u150117535", "pos": "A,B,C,D,E,F=[int(x) for x in input().split()]\nfrom itertools import product\ndef gauss(i):\n return F//i+1\nwaters=set()\nsugers=set()\nans={\"water\":100*A,\"suger\":0}\nfor a,b in product(range(gauss(A)),range(gauss(B))):\n waters.add(100*(a*A+b*B))\nfor c,d in product(range(gauss(C)),range(gauss(D))):\n sugers.add(c*C+d*D)\nfor water in sorted(waters):\n if water==0:\n continue\n for suger in sorted(sugers):\n if water+suger>F:\n break\n if 100*suger>E*water:\n break\n if ans[\"suger\"]*(water+suger)F:\n continue\n if 100*suger>E*(water+suger):\n continue\n if ans[1]*(water+suger) F or s == 0: continue\n re = int(s * E / 100)\n if s + re > F: re = F - s\n # print(s, re)\n result = per1(re)\n # print(result)\n suger = (100 * result) / (s + result)\n if suger > max_suger_per:\n max_suger_per = suger\n max_water = s + result\n max_suger = result\n \nif max_water == 0:\n max_water = An[1]\nprint(max_water, max_suger)\n ", "neg": "A, B, C, D, E, F = [int(v) for v in input().split()]\n# print(A, B, C, D, E, F)\nAn = [(100*A)*(v) for v in range(int(F/(100*A))+1)]\nBn = [(100*B)*(v) for v in range(int(F/(100*B))+1)]\n# print(An, Bn, 1)\n\n\ndef per1(RE):\n Cn = [A*v for v in range(int(RE/A)+1)]\n Dn = [B*v for v in range(int(RE/B)+1)]\n # print(int(RE/C))\n rtn = 0\n for v2 in Cn:\n for w2 in Dn:\n r = v2 + w2\n if rtn < r <= RE:\n rtn = r\n return rtn\n \n \nmax_suger_per = 0\nmax_water = 0\nmax_suger = 0\nfor v in Bn:\n for w in An:\n s = v + w\n if s > F or s == 0: continue\n re = int(s * E / 100)\n if s + re > F: re = F - s\n # print(s, re)\n result = per1(re)\n # print(result)\n suger = (100 * result) / (s + result)\n if suger > max_suger_per:\n max_suger_per = suger\n max_water = s + result\n max_suger = result\n \nprint(max_water, max_suger)\n ", "jacc_sim": 1.0, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [429, 419], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u697658632", "n_user": "u697658632", "pos": "a, b, c, d, e, f = map(int, input().split())\nw = []\ns = []\nfor i in range(f // (100 * a) + 1):\n for j in range((f - 100 * a * i) // (100 * b) + 1):\n if 100 * a * i + 100 * b * j <= f:\n w.append(100 * a * i + 100 * b * j)\nfor i in range(f // c + 1):\n for j in range((f - c * i) // d + 1):\n if c * i + d * j <= f:\n s.append(c * i + d * j)\nw.sort()\ns.sort()\nans = (100 * a, 0)\nl = 0\nfor i in w:\n for j in range(l, len(s)):\n if i + s[j] > f:\n break\n if s[j] > i // 100 * e:\n break\n l = j\n if ans[1] * i < s[j] * ans[0]:\n ans = (i, s[j])\nprint(ans[0] + ans[1], ans[1])\n", "neg": "a, b, c, d, e, f = map(int, input().split())\nw = []\ns = []\nfor i in range(f // (100 * a) + 1):\n for j in range((f - 100 * a * i) // (100 * b) + 1):\n if 100 * a * i + 100 * b * j <= f:\n w.append(100 * a * i + 100 * b * j)\nfor i in range(f // c + 1):\n for j in range((f - c * i) // d + 1):\n if c * i + d * j <= f:\n s.append(c * i + d * j)\nans = (100 * a, 0)\nl = 0\nfor i in w:\n for j in range(l, len(s)):\n if i + s[j] > f:\n break\n if s[j] > i // 100 * e:\n break\n if ans[1] * i < s[j] * ans[0]:\n ans = (i, s[j])\n l = j\nprint(ans[0] + ans[1], ans[1])\n", "jacc_sim": 0.9761904761904762, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [288, 278], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u237316771", "n_user": "u237316771", "pos": "#!/usr/bin/env python3\nimport sys\n\n\ndef v(a: int, b: int, c: int):\n if a < b:\n a, b = b, a\n if c % a == 0:\n return c\n minr = c\n for va in range(c // a + 1):\n minr = min(minr, (c - va * a) % b)\n if minr == 0:\n break\n return c - minr\n\n\ndef solve(A: int, B: int, C: int, D: int, E: int, F: int):\n ansa = A * 100\n anss = 0\n for w in range(1, F // 100 + 1):\n w2 = v(B, A, w)\n if w != w2:\n continue\n s = min(w2 * E, F - w2 * 100)\n s2 = v(D, C, s)\n a2 = s2 + w2 * 100\n if a2 > F:\n continue\n # anss / ansa < s2 / a2\n if anss * a2 < ansa * s2:\n ansa, anss = a2, s2\n print(ansa, anss)\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n A = int(next(tokens)) # type: int\n B = int(next(tokens)) # type: int\n C = int(next(tokens)) # type: int\n D = int(next(tokens)) # type: int\n E = int(next(tokens)) # type: int\n F = int(next(tokens)) # type: int\n solve(A, B, C, D, E, F)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\n\n\ndef v(a: int, b: int, c: int):\n if a < b:\n a, b = b, a\n if c % a == 0:\n return c\n minr = c\n for va in range(c // a + 1):\n minr = min(minr, (c - va * a) % b)\n if minr == 0:\n break\n return c - minr\n\n\ndef solve(A: int, B: int, C: int, D: int, E: int, F: int):\n ansa = 0\n anss = 0\n for w in range(1, F // 100 + 1):\n w2 = v(A, B, w)\n if w != w2:\n continue\n s = w2 * E\n s2 = v(C, D, s)\n a2 = s2 + w2 * 100\n if a2 > F:\n continue\n # anss / ansa <= s2 / a2\n if anss * a2 <= ansa * s2:\n ansa, anss = 100 * w2 + s2, s2\n print(ansa, anss)\n\n\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n A = int(next(tokens)) # type: int\n B = int(next(tokens)) # type: int\n C = int(next(tokens)) # type: int\n D = int(next(tokens)) # type: int\n E = int(next(tokens)) # type: int\n F = int(next(tokens)) # type: int\n solve(A, B, C, D, E, F)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [472, 465], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u790710233", "n_user": "u790710233", "pos": "import itertools\nA, B, C, D, E, F = map(int, input().split())\nU = F\nwater = [0]*(U+1)\nwater[0] = 1\nfor i in range(U+1):\n if water[i]:\n if i+100*A <= U:\n water[i+100*A] = 1\n if i+100*B <= U:\n water[i+100*B] = 1\nwater_val = [val for val in range(1, U+1) if water[val]]\nsuger = [0]*(U+1)\nsuger[0] = 1\nfor i in range(U+1):\n if suger[i]:\n if i+C <= U:\n suger[i+C] = 1\n if i+D <= U:\n suger[i+D] = 1\n\nsuger_val = [val for val in range(U+1) if suger[val]]\nmax_c = -1\nfor w, s in itertools.product(water_val, suger_val):\n if E*w < 100*s:\n continue\n if F < w+s:\n continue\n\n if max_c < 100*s/(w+s):\n max_c = 100*s/(w+s)\n ans = (w+s, s)\n\nprint(*ans)\n", "neg": "import itertools\nA, B, C, D, E, F = map(int, input().split())\nU = F\nwater = [0]*(U+1)\nwater[0] = 1\nfor i in range(U+1):\n if water[i]:\n if i+100*A <= U:\n water[i+100*A] = 1\n if i+100*B <= U:\n water[i+100*B] = 1\n\nwater_val = [val for val in range(1, U+1) if water[val]]\nprint(water_val)\n\nsuger = [0]*(U+1)\nsuger[0] = 1\nfor i in range(U+1):\n if suger[i]:\n if i+C <= U:\n suger[i+C] = 1\n if i+D <= U:\n suger[i+D] = 1\n\nsuger_val = [val for val in range(U+1) if suger[val]]\nmax_c = -1\nfor w, s in itertools.product(water_val, suger_val):\n if E*w < 100*s:\n continue\n if F < w+s:\n continue\n\n if max_c < 100*s/(w+s):\n max_c = 100*s/(w+s)\n ans = (w+s, s)\n\nprint(*ans)", "jacc_sim": 1.0, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [347, 356], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u747602774", "n_user": "u747602774", "pos": "A,B,C,D,E,F = map(int,input().split())\nf = F//100\n\nans = [0,0]\nper = -1\n#\u6c34\u306e\u91cf\u3092100g\u5358\u4f4d\u305a\u3064\u5168\u63a2\u7d22\nfor w in range(1,f+1):\n #\u305d\u306e\u3088\u3046\u306a\u6c34\u306e\u53d6\u308a\u65b9\u304c\u3042\u308b\u304b\u78ba\u8a8d\n wt = 0\n for b in range(0,w+1,B):\n if (w-b)%A == 0:\n wt = 1\n break\n if wt == 0:\n continue\n\n water = w*100\n st = 0\n #\u7802\u7cd6\u3068\u3057\u3066\u8003\u3048\u3089\u308c\u308b\u91cf\u3092\u5927\u304d\u3044\u9806\u306b0g\u307e\u3067\u306b\u5168\u63a2\u7d22\n for s in range(min(w*E,F-water),-1,-1):\n st = 0\n for d in range(0,s+1,D):\n if (s-d)%C == 0:\n st = 1\n break\n if st == 1:\n break\n\n if s/(s+water) > per:\n ans = [s+water,s]\n per = s/(s+water)\n\nprint(' '.join(map(str,ans)))\n", "neg": "A,B,C,D,E,F = map(int,input().split())\nf = F//100\n\nper = 0\n#\u6c34\u306e\u91cf\u3092100g\u5358\u4f4d\u305a\u3064\u5168\u63a2\u7d22\nfor w in range(1,f+1):\n #\u305d\u306e\u3088\u3046\u306a\u6c34\u306e\u53d6\u308a\u65b9\u304c\u3042\u308b\u304b\u78ba\u8a8d\n wt = 0\n for b in range(0,w+1,B):\n if (w-b)%A == 0:\n wt = 1\n break\n if wt == 0:\n continue\n\n water = w*100\n sugar = w*E\n #\u7802\u7cd6\u3068\u3057\u3066\u8003\u3048\u3089\u308c\u308b\u91cf\u3092\u5927\u304d\u3044\u9806\u306b0g\u307e\u3067\u306b\u5168\u63a2\u7d22\n for s in range(sugar,-1,-1):\n \u305d\u306e\u3088\u3046\u306a\u7802\u7cd6\u306e\u53d6\u308a\u65b9\u304c\u3042\u308b\u304b\u78ba\u8a8d\n st = 0\n for d in range(0,s+1,D):\n if (s-d)%C == 0:\n st = 1\n break\n if st == 1:\n break\n if s+water <= F and s/(s+water) > per:\n ans = [s+water,s]\n per = s/(s+water)\n\nprint(' '.join(map(str,ans)))\n", "jacc_sim": 0.9574468085106383, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [406, 451], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u530335051", "n_user": "u530335051", "pos": "import itertools\na,b,c,d,e,f = [int(_) for _ in input().split()]\n\nwater = []\ni = 0\nwhile True:\n j = 0\n if i * 100 * a + j * 100 * b > f:\n break\n while True:\n if i == 0 and j == 0:\n j += 1\n continue\n if i * 100 * a + j * 100 * b > f:\n break\n water.append(i * 100 * a + j * 100 * b)\n j += 1\n i += 1\nset_water = sorted(set(water))\n\nsugar = []\ni = 0\nwhile True:\n j = 0\n if i * c + j * d > f * e // 100:\n break\n while True:\n if i == 0 and j == 0:\n j += 1\n continue\n if i * c + j * d > f * e // 100:\n break\n sugar.append(i * c + j * d)\n j += 1\n i += 1\nset_sugar = sorted(set(sugar))\n\nmost_dense = 0\nfinal_total = 0\nfinal_sugar = 0\nfor i, j in itertools.product(range(0,len(set_water)), range(0, len(set_sugar))):\n density = set_sugar[j] / (set_water[i] + set_sugar[j])\n if density > most_dense and set_water[i] * e // 100 >= set_sugar[j] and set_water[i] + set_sugar[j] <= f:\n most_dense = density\n final_total = set_water[i]+set_sugar[j]\n final_sugar = set_sugar[j]\n\nif final_total == 0:\n final_total = a * 100\nprint(final_total, final_sugar)", "neg": "import itertools\na,b,c,d,e,f = [int(_) for _ in input().split()]\n\nwater = []\ni = 0\nwhile True:\n j = 0\n if i * 100 * a + j * 100 * b > f:\n break\n while True:\n if i == 0 and j == 0:\n j += 1\n continue\n if i * 100 * a + j * 100 * b > f:\n break\n water.append(i * 100 * a + j * 100 * b)\n j += 1\n i += 1\n\nsugar = []\ni = 0\nwhile True:\n j = 0\n if i * c + j * d > f * e // 100:\n break\n while True:\n if i == 0 and j == 0:\n j += 1\n continue\n if i * c + j * d > f * e // 100:\n break\n sugar.append(i * c + j * d)\n j += 1\n i += 1\n\nmost_dense = 0\nfinal_total = 0\nfinal_sugar = 0\nfor i, j in itertools.product(range(0,len(water)), range(0, len(sugar))):\n density = sugar[j] / (water[i] + sugar[j])\n if water[i] + sugar[j] < f and water[i] * e // 100 >= sugar[j] and density >= most_dense:\n most_dense = density\n final_total = water[i]+sugar[j]\n final_sugar = sugar[j]\n\nprint(final_total, final_sugar)", "jacc_sim": 0.9245283018867925, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [471, 396], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u677523557", "n_user": "u677523557", "pos": "A,B,C,D,E,F = map(int, input().split())\n\nL = []\nfor a in range(31):\n for b in range(31):\n k = A*a+B*b\n if 0 < 100*k <= F:\n L.append(k)\n\nL.sort()\n\n\nsu = 0\nfor i, l in enumerate(L):\n limit = min(F-100*l, E*l)\n wd = 100*l\n if i == 0:\n w = wd\n for c in range(3000):\n if C*c >limit:\n break\n d = (limit - C*c) // D\n p = C*c+D*d\n if p*w > wd*su:\n w = wd\n su = p\nprint(w+su, su)", "neg": "A,B,C,D,E,F = map(int, input().split())\n\nL = []\nfor a in range(31):\n for b in range(31):\n k = A*a+B*b\n if 0 < 100*k <= F:\n L.append(k)\n\nL.sort()\n\nlim = 0\nfor l in L:\n limit = min(F-100*l, E*l)\n if limit > lim:\n lim = limit\n w = 100*l\n\nsu = 0\nfor c in range(3000):\n if C*c >lim:\n break\n d = (lim - C*c) // D\n p = C*c+D*d\n if p > su:\n su = p\nprint(w+su, su)", "jacc_sim": 0.9230769230769231, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [205, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u896741788", "n_user": "u896741788", "pos": "from decimal import Decimal as D\nmi1,mi2,sa1,sa2,houwa,lim=map(int,input().split())\nslim=houwa*lim//(100+houwa)\nws=set(mi1*i+mi2*j for i in range(lim//(100*mi1)+2) for j in range(lim//(100*mi2)+2) if 100*(mi1*i+mi2*j)<=lim)\nss=set(sa1*i+sa2*j for i in range(slim//sa1+2) for j in range(slim//sa2+2) if (sa1*i+sa2*j)<=slim)\nans=D(\"0\")\niw,isa=mi1,0\nfor s in ss:\n for w in ws:\n if s>houwa*w or w==0:continue\n if anshouwa*w or s==w==0:continue\n if ans 0 else 1)[0]\nprint(100*A if W[I] == 0 else W[I] + S[I], S[I])", "neg": "A, B, C, D, E, F = map(int, input().split())\n\nW = sorted(list({a*100*A + b*100*B for a in range(F // 100 // A + 1) for b in range(F // 100 // B + 1) if a*100*A + b*100*B <= F}))\nS = [max([c*C + d*D for c in range((E*w / 100) / C + 1) for d in range((E*w / 100) / D + 1) if ((c*C + d*D)*100 <= E*w) and (c*C + d*D + w <= F)]) for w in W]\nI = sorted([i for i in range(len(W))], key=lambda i : W[i]/(W[i] + S[i]) if W[i] > 0 else 1)[0]\nprint(W[I] + S[I], S[I])\n", "jacc_sim": 1.0, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [241, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u830054172", "n_user": "u830054172", "pos": "A, B, C, D, E, F = list(map(int, input().split()))\n\nsugar = []\nwater = []\n\nfor i in range(31):\n for j in range(31):\n x = 100*A*i+100*B*j\n if x != 0 and x <= F:\n water.append(x)\n \nn = int(F/(100+E)*E)\n\nfor k in range(n):\n for l in range(n):\n y = C*k+D*l\n if y != 0: \n sugar.append(y)\n\nans_water_sugar = 100*A\nans_sugar = 0\nconce = 0 \n\nfor s in list(set(sugar)):\n for w in water:\n if w+s <= F:\n if s/w <= E/100:\n if conce < s/w:\n conce = s/w\n ans_water_sugar = s+w\n ans_sugar = s\n\nprint(ans_water_sugar, ans_sugar)", "neg": "A, B, C, D, E, F = list(map(int, input().split()))\n\nsugar = []\nwater = []\n\nfor i in range(31):\n for j in range(31):\n x = 100*A*i+100*B*j\n if x != 0 and x <= F:\n water.append(x)\n y = C*i+D*j\n if y != 0: \n sugar.append(y)\n\nans_water_sugar = 0\nans_sugar = 0\nconce = 0 \n\nfor s in sugar:\n for w in water:\n if w+s <= F:\n if s/w <= E/100:\n if conce < s/w:\n conce = s/w\n ans_water_sugar = s+w\n ans_sugar = s\n\nprint(ans_water_sugar, ans_sugar)", "jacc_sim": 0.9183673469387755, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [268, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03599", "p_user": "u761320129", "n_user": "u761320129", "pos": "A,B,C,D,E,F = map(int,input().split())\n\nwaters = set()\nfor wb in range(0,F+1,100*B):\n wa = 0\n while wa + wb <= F:\n waters.add(wa + wb)\n wa += 100*A\nwaters.remove(0)\n\nsugars = set()\nfor sd in range(0,F+1,D):\n sc = 0\n while sc + sd <= F:\n sugars.add(sc + sd)\n sc += C\n\nbest = -1\nbest_w = best_s = 0\nfor w in sorted(waters):\n for s in sorted(sugars):\n if 100*s > w*E: continue\n if w+s > F: continue\n if best < 100*s / (w+s):\n best = 100*s / (w+s)\n best_w = w\n best_s = s\n\nprint(best_w+best_s, best_s)", "neg": "A,B,C,D,E,F = map(int,input().split())\n\nwaters = set()\nwa = 100*A\nwhile wa <= F:\n waters.add(wa)\n wa += 100*A\nwb = 100*B\nwhile wb <= F:\n waters.add(wb)\n wb += 100*B\n\nsugars = set()\nsc = C\nwhile sc <= F:\n sugars.add(sc)\n sc += C\nsd = D\nwhile sd <= F:\n sugars.add(sd)\n sd += D\n\nbest = 0.0\nbest_w = best_s = 0\nfor w in sorted(waters):\n for s in sorted(sugars):\n if 100*s > w*E: continue\n if w+s > F: continue\n if best < 100*s / (w+s):\n best = 100*s / (w+s)\n best_w = w\n best_s = s\nprint(best_w+best_s, best_s)", "jacc_sim": 0.9148936170212766, "nl": "Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform four types of operations any number of times: pouring 100A or 100B grams of water, and putting C or D grams of sugar into the beaker. E grams of sugar can dissolve into 100 grams of water. Snuke aims to make sugar water with the highest possible density, ensuring the beaker can contain at most F grams of substances without any undissolved sugar. The task is to find the mass of the sugar water Snuke will make and the mass of sugar dissolved in it. The output should be two integers separated by a space. The first integer represents the mass of the desired sugar water, and the second represents the mass of the sugar dissolved in it. The constraints are: 1 \u2264 A < B \u2264 30, 1 \u2264 C < D \u2264 30, 1 \u2264 E \u2264 100, and 100A \u2264 F \u2264 3000. Inputs are given in the format A B C D E F, and the outputs should be two integers.", "before_after_length": [252, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u516554284", "n_user": "u516554284", "pos": "import copy\n\nn=int(input())\na=[]\nans=0\nfor _ in range(n):\n b=list(map(int,input().split()))\n ans+=sum(b)\n a.append(b)\n \nc=copy.deepcopy(a)\n \nfor i in range(n):\n for j in range(n):\n ch=0\n for k in range(n):\n if c[i][j]==c[i][k]+c[k][j] and ch==0 and i!=k and j!=k:\n ans-=c[i][j]\n ch+=1\n c[i][j]=min(c[i][j],c[i][k]+c[k][j])\n \nif a==c:\n \n print(ans//2)\n \nelse:\n print(-1)", "neg": "import copy\n\nn=int(input())\na=[]\nans=0\nfor _ in range(n):\n b=list(map(int,input().split()))\n ans+=sum(b)\n a.append(b)\n \nc=copy.deepcopy(a)\n \nfor i in range(n):\n for j in range(n):\n ch=0\n for k in range(n):\n if c[i][j]==c[i][k]+c[k][j] and ch==0 and i!=k and j!=k:\n ans-=c[i][j]\n ch+=1\n c[i][j]=min(c[i][j],c[i][k]+c[k][j])\n \n \nprint(ans//2)\n ", "jacc_sim": 0.9767441860465116, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [214, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u279493135", "n_user": "u279493135", "pos": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN = INT()\n\ndef warshall_floyd(v_count: int, matrix: list) -> list:\n for i in range(v_count):\n for j, c2 in enumerate(row[i] for row in matrix):\n for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):\n if c1 > c2+c3:\n matrix[j][k] = c2+c3\n return matrix\n\nA = [LIST() for _ in range(N)]\ndist_matrix = warshall_floyd(N, deepcopy(A))\n\nans = 0\nfor i, j in combinations(range(N), 2):\n if A[i][j] != dist_matrix[i][j]:\n print(-1)\n break\n for k in range(N):\n if i == k or j == k:\n continue\n if A[i][k] + A[k][j] == A[i][j]:\n break\n else:\n ans += A[i][j]\nelse:\n print(ans)\n", "neg": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom scipy.sparse import csr_matrix\nfrom scipy.sparse.csgraph import floyd_warshall\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN = INT()\n\ndef warshall_floyd(v_count: int, matrix: list) -> list:\n for i in range(v_count):\n for j, c2 in enumerate(row[i] for row in matrix):\n for k, (c1, c3) in enumerate(zip(matrix[j], matrix[i])):\n if c1 > c2+c3:\n matrix[j][k] = c2+c3\n return matrix\n\nA = [LIST() for _ in range(N)]\ndist_matrix = warshall_floyd(N, A)\n\nans = 0\nfor i, j in combinations(range(N), 2):\n if A[i][j] != dist_matrix[i][j]:\n print(-1)\n break\n for k in range(N):\n if i == k or j == k:\n continue\n if A[i][k] + A[k][j] == A[i][j]:\n break\n else:\n ans += A[i][j]\nelse:\n print(ans)\n", "jacc_sim": 0.9553571428571429, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [472, 496], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u372550522", "n_user": "u372550522", "pos": "import copy\nimport sys\n\nINF = 2**120\n\nn = int(input())\nd = [[] for j in range(n)]\nfor j in range(n):\n d[j] = [int(i) for i in input().split()]\n\nans = sum([sum(d[i]) for i in range(n)])\n\nminus = [[0] * n for i in range(n)]\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n if d[i][j] > d[i][k]+d[k][j]:\n print('-1')\n sys.exit()\n if d[i][j] == d[i][k]+d[k][j] and i != k and j != k:\n minus[i][j] = 1\n\nfor i in range(n):\n for j in range(n):\n if minus[i][j]:\n ans -= d[i][j]\n\nprint(ans//2)", "neg": "import copy\nimport sys\n\nINF = 2**120\n\nn = int(input())\nd = [[] for j in range(n)]\nfor j in range(n):\n d[j] = [int(i) for i in input().split()]\n\nans = sum([sum(d[i]) for i in range(n)])\n\nminus = [[0] * n for i in range(n)]\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n if d[i][j] > d[i][k]+d[k][j]:\n print('-1')\n sys.exit()\n if d[i][j] == d[i][k]+d[k][j] and i != k and j != k:\n print(i, j, k)\n minus[i][j] = 1\n\nfor i in range(n):\n for j in range(n):\n if minus[i][j]:\n ans -= d[i][j]\n\nprint(ans//2)", "jacc_sim": 0.975609756097561, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [244, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u948911484", "n_user": "u948911484", "pos": "import copy\nn = int(input())\n\nans = 0\ndef warshall_floyd(d):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if i == k or j == k:\n continue\n elif d[i][j] > d[i][k] + d[k][j]:\n return -1\n elif d[i][j] == d[i][k] + d[k][j]:\n blist[i][j] = 0\n return sum([sum(l) for l in blist])//2\n\nalist = []\nblist = []\nfor i in range(n):\n a = list(map(int,input().split()))\n alist.append(copy.copy(a))\n blist.append(copy.copy(a))\n\n\nans = warshall_floyd(alist)\nprint(ans)", "neg": "import copy\nn = int(input())\n\nans = 0\ndef warshall_floyd(d):\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if i == k or j == k:\n continue\n elif d[i][j] > d[i][k] + d[k][j]:\n print(i,j,k)\n print(d)\n print(d[i][j],d[i][k],d[k][j])\n return -1\n elif d[i][j] == d[i][k] + d[k][j]:\n blist[i][j] = 0\n return sum([sum(l) for l in blist])//2\n\nalist = []\nblist = []\nfor i in range(n):\n a = list(map(int,input().split()))\n alist.append(copy.copy(a))\n blist.append(copy.copy(a))\n\n\nans = warshall_floyd(alist)\nprint(ans)", "jacc_sim": 1.0, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [225, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u683134447", "n_user": "u683134447", "pos": "n = int(input())\n\ndl = [list(map(int,input().split())) for _ in range(n)]\n\n# d[i][j]\u306f2\u9802\u70b9\u9593i, j\u9593\u306e\u79fb\u52d5\u30b3\u30b9\u30c8\u3092\u683c\u7d0d, V\u306f\u9802\u70b9\u6570\ndef warshall_floyd(d, V):\n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n\n return d # d[i][j]\u306b\u9802\u70b9i, j\u9593\u306e\u6700\u77ed\u8ddd\u96e2\u3092\u683c\u7d0d\nfrom copy import deepcopy\nd = warshall_floyd(deepcopy(dl), n)\n\nif d != dl:\n print(-1)\n exit()\n\nans = 0\nfor i in range(n):\n for j in range(n):\n if i == j:\n continue\n flag = True\n for k in range(n):\n if i == k or k == j:\n continue\n if d[i][j] == d[i][k] + d[k][j]:\n flag = False\n if flag:\n ans += d[i][j]\nprint(ans//2)\n\n", "neg": "n = int(input())\n\ndl = [list(map(int,input().split())) for _ in range(n)]\n\n# d[i][j]\u306f2\u9802\u70b9\u9593i, j\u9593\u306e\u79fb\u52d5\u30b3\u30b9\u30c8\u3092\u683c\u7d0d, V\u306f\u9802\u70b9\u6570\nans = 0\ndef warshall_floyd(d, V):\n global ans\n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n return d # d[i][j]\u306b\u9802\u70b9i, j\u9593\u306e\u6700\u77ed\u8ddd\u96e2\u3092\u683c\u7d0d\n\n\nd = warshall_floyd(dl, n)\n\nif d != dl:\n print(-1)\n exit()\n\nans = 0\nfor i in range(n):\n for j in range(n):\n if i == j:\n continue\n flag = True\n for k in range(n):\n if i == k or k == j:\n continue\n if d[i][j] == d[i][k] + d[k][j]:\n flag = False\n if flag:\n ans += d[i][j]\nprint(ans//2)\n\n", "jacc_sim": 0.927536231884058, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [371, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u709304134", "n_user": "u709304134", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nMOD = 10**9 + 7\n\nN = int(input())\nINF = 10**10\ncost = [[INF]*N for _ in range(N)]\n\nfor u in range(N):\n C = list(map(int, input().split()))\n for v in range(N):\n if u==v: # INF\u306e\u307e\u307e\u306b\u3059\u308b\n continue\n cost[u][v] = C[v]\n \nans = 0\nfor u in range(N):\n for v in range(u+1,N):\n mn = INF # u-w-v\u306e\u3088\u3046\u306a\u7d4c\u8def\u306e\u4e2d\u3067\u6700\u5c0f\u306e\u8ddd\u96e2\u3092\u6c42\u3081\u308b\n for w in range(N):\n mn = min(mn, cost[u][w]+cost[w][v]) \n if (cost[u][v] > mn): # \u4e0e\u3048\u3089\u308c\u305f\u884c\u5217\u304c\u6700\u77ed\u7d4c\u8def\u3067\u306f\u306a\u3044\n print (-1)\n exit()\n elif (cost[u][v] < mn): # \u7b49\u3057\u304f\u306a\u3044\u5834\u5408\u306fu-v\u3092\u76f4\u63a5\u7d50\u3076\u6a4b\u304c\u5fc5\u8981 \n ans += cost[u][v] \nprint (ans)", "neg": "N = int(input())\nINF = 10**10\ncost = [[INF]*N for _ in range(N)]\n\nfor u in range(N):\n C = list(map(int, input().split()))\n for v in range(N):\n if u==v: # INF\u306e\u307e\u307e\u306b\u3059\u308b\n continue\n cost[u][v] = C[u]\n \nans = 0\nfor u in range(N):\n for v in range(j+1,N):\n mn = INF # u-w-v\u306e\u3088\u3046\u306a\u7d4c\u8def\u306e\u4e2d\u3067\u6700\u5c0f\u306e\u8ddd\u96e2\u3092\u6c42\u3081\u308b\n for w in range(N):\n mn = min(mn, cost[u][w]+cost[w][v]) \n if (cost[u][v] > mn): # \u4e0e\u3048\u3089\u308c\u305f\u884c\u5217\u304c\u6700\u77ed\u7d4c\u8def\u3067\u306f\u306a\u3044\n print (-1)\n exit()\n elif (cost[u][v] < mn): # \u7b49\u3057\u304f\u306a\u3044\u5834\u5408\u306fu-v\u3092\u76f4\u63a5\u7d50\u3076\u6a4b\u304c\u5fc5\u8981 \n ans += cost[u][v] \nprint (ans)", "jacc_sim": 0.9021739130434783, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [414, 382], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u898967808", "n_user": "u898967808", "pos": "from copy import deepcopy\nn = int(input())\nINF = 10**12\n\nA = []\nfor i in range(n):\n A.append(list(map(int,input().split())))\n\nB = [[1]*n for _ in range(n)]\nG = deepcopy(A)\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n G[i][j] = min(G[i][j], G[i][k]+G[k][j])\n if not (i==j or j==k or k==i):\n if G[i][j] == G[i][k]+G[k][j]:\n B[i][j] = 0\n \nif A==G:\n ans = 0\n for i in range(n):\n for j in range(i+1,n): \n ans += G[i][j] * B[i][j]\n print(ans)\nelse:\n print(-1)", "neg": "n = int(input())\nINF = 10**12\n\nA = []\nfor i in range(n):\n A.append(list(map(int,input().split())))\n\nB = [[1]*n for _ in range(n)]\nG = A.copy()\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n G[i][j] = min(G[i][j], G[i][k]+G[k][j])\n if not (i==j or j==k or k==i):\n if G[i][j] == G[i][k]+G[k][j]:\n B[i][j] = 0\n \nif A==G:\n ans = 0\n for i in range(n):\n for j in range(i+1,n): \n ans += G[i][j] * B[i][j]\n print(ans)\nelse:\n print(-1)", "jacc_sim": 0.9318181818181818, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [242, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u731448038", "n_user": "u731448038", "pos": "n = int(input())\nA = [list(map(int, input().split())) for _ in range(n)]\n\nans = 0\ncannot = 0\nfor i in range(n-1):\n for j in range(i+1,n):\n detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j]+[10**18])\n if detourA[i][j]:\n ans += A[i][j]\nif cannot:\n print(-1)\nelse:\n print(ans)\n", "neg": "n = int(intpu())\nA = [list(map(int, input().split())) for _ in range(n)]\n\nans = 0\ncannot = 0\nfor i in range(n):\n for j in range(n):\n detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j])\n if detourA[i][j]:\n ans += A[i][j]\nif cannot:\n print(-1)\nelse:\n print(ans)", "jacc_sim": 0.9047619047619048, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [162, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u779455925", "n_user": "u779455925", "pos": "\"\"\"from collections import *\nfrom itertools import *\nfrom bisect import *\nfrom heapq import *\n\nimport math\nfrom fractions import gcd\"\"\"\nfrom heapq import*\nN=int(input())\nA=[list(map(int,input().split())) for i in range(N)]\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n if A[i][j]>A[i][k]+A[k][j]:\n print(-1)\n exit()\nres = 0\nfor i in range(N-1):\n for j in range(i+1, N):\n for k in range(N):\n if k==i or k == j:\n continue\n if A[i][j]==A[i][k]+A[k][j]:\n break\n else:\n res += A[i][j]\nprint(res)\n", "neg": "\"\"\"from collections import *\nfrom itertools import *\nfrom bisect import *\nfrom heapq import *\n\nimport math\nfrom fractions import gcd\"\"\"\nfrom heapq import*\nN=int(input())\nA=[list(map(int,input().split())) for i in range(N)]\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n if A[i][j]>A[i][k]+A[k][j]:\n print(-1)\n exit()\nres = 0\nfor i in range(N-1):\n for j in range(i+1, N):\n for k in range(N):\n if k==i or k == j:\n continue\n if A[i][j]==A[i][k]+A[k][j]:\n break\n else:\n res += A[i][j]\nprint(res)\n", "jacc_sim": 1.0, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [219, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u385244248", "n_user": "u385244248", "pos": "import sys\nimport math\nimport fractions\nimport itertools\nfrom collections import deque\nimport copy\nimport heapq\nimport bisect\n\n\ndef warshall_floyd(d):\n \"\"\"\n d[i][l]\u304ci\u2192l\u3078\u306e\u30b3\u30b9\u30c8\u3092\u793a\u3059\u96a3\u63a5\u884c\u5217\n \u7d50\u679c\u3068\u3057\u3066d[i][l]\u306fi\u2192l\u3078\u306e\u6700\u77ed\u30b3\u30b9\u30c8\u306b\u306a\u308b\u3002\n \"\"\"\n info = copy.deepcopy(d)\n for i in range(len(info)):\n for l in range(len(info)):\n for k in range(len(info)):\n info[l][k] = min(info[l][k], info[l][i] + info[i][k])\n return info\n\n\nMOD = float('inf')\nINF = 10 ** 18 + 7\ninput = lambda: sys.stdin.readline().strip()\n\nN = int(input())\nA = [list(map(int, input().split())) for _ in range(N)]\n\nresult = warshall_floyd(A)\nans = 0\nfor i in range(N):\n for l in range(N):\n if result[i][l] != A[i][l]:\n print(-1)\n sys.exit()\n ans += A[i][l]\n if A[i][l] == 0:\n A[i][l] = INF\n\nans /= 2\nfor i in range(N - 1):\n for l in range(i + 1, N):\n for k in range(N):\n if A[i][l] == A[i][k] + A[k][l]:\n ans -= A[i][l]\n break\nprint(int(ans))\n", "neg": "import sys\nimport math\nimport fractions\nimport itertools\nfrom collections import deque\nimport copy\nimport heapq\nimport bisect\n\n\ndef warshall_floyd(d):\n \"\"\"\n d[i][l]\u304ci\u2192l\u3078\u306e\u30b3\u30b9\u30c8\u3092\u793a\u3059\u96a3\u63a5\u884c\u5217\n \u7d50\u679c\u3068\u3057\u3066d[i][l]\u306fi\u2192l\u3078\u306e\u6700\u77ed\u30b3\u30b9\u30c8\u306b\u306a\u308b\u3002\n \"\"\"\n for i in range(len(d)):\n for l in range(len(d)):\n for k in range(len(d)):\n d[l][k] = min(d[l][k], d[l][i] + d[i][k])\n return d\n\n\nMOD = float('inf')\nINF = 10 ** 18 + 7\ninput = lambda: sys.stdin.readline().strip()\n\nN = int(input())\nA = [list(map(int, input().split())) for _ in range(N)]\n\nresult = warshall_floyd(A)\nans = 0\nfor i in range(N):\n for l in range(N):\n if result[i][l] != A[i][l]:\n print(-1)\n sys.exit()\n ans += A[i][l]\n if A[i][l] == 0:\n A[i][l] = INF\n\nans /= 2\nfor i in range(N - 1):\n for l in range(i + 1, N):\n for k in range(N):\n if A[i][l] == A[i][k] + A[k][l]:\n ans -= A[i][l]\n break\nprint(int(ans))\n", "jacc_sim": 0.978494623655914, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [480, 469], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u476604182", "n_user": "u476604182", "pos": "from collections import defaultdict\nN = int(input())\ncost = [[0]*N for i in range(N)]\ndist = [[0]*N for i in range(N)]\nlog = defaultdict(int)\nfor i in range(N):\n inf = [int(c) for c in input().split()]\n for j in range(N):\n cost[i][j] = inf[j]\nfor i in range(N):\n for j in range(i+1,N):\n m = float('inf')\n for k in range(N):\n if cost[i][j]>=cost[i][k]+cost[k][j]:\n m = min(m,cost[i][k]+cost[k][j])\n if k != i and k!= j:\n log[(min(i,j),max(i,j))] = 1\n dist[i][j] = m\n dist[j][i] = m\nans = 0\nfor i in range(N):\n for j in range(i+1,N):\n flag = False\n if dist[i][j]=cost[i][k]+cost[k][j]:\n m = cost[i][k]+cost[k][j]\n if k != i and k!= j:\n log[(min(i,j),max(i,j))] = 1\n dist[i][j] = m\n dist[j][i] = m\nans = 0\nfor i in range(N):\n for j in range(i+1,N):\n flag = False\n if dist[i][j]=j:\n continue\n edge.append((arr[i][j],(i,j)))\nedge=sorted(edge,key=lambda x:x[0])\ng=[[float('inf')]*n for _ in range(n)]\nfor i in range(n):\n for j in range(n):\n g[i][j]=arr[i][j]\nd=Warshall_Floyd(g,n)\nans=0\nfor w,(a,b) in edge:\n if d[a][b]=j:\n continue\n edge.append((arr[i][j],(i,j)))\nedge=sorted(edge,key=lambda x:x[0])\ng=[[float('inf')]*n for _ in range(n)]\nfor i in range(n):\n for j in range(n):\n g[i][j]=arr[i][j]\nd=Warshall_Floyd(g,n)\nprint(d)\nans=0\nfor w,(a,b) in edge:\n if d[a][b] via -> j \u306e\u8ddd\u96e2\n R = sum(np.meshgrid(A[via], A[via]))\n R[via] = np.inf\n R[:, via] = np.inf\n useless |= R == A\n impossible |= R < A\nif impossible.sum():\n print(-1)\nelse:\n print(int(A[~useless].sum() // 2))\n", "neg": "import sys\n\nimport numpy as np\n\nsys.setrecursionlimit(10000)\nINF = float('inf')\n\nN = int(sys.stdin.readline())\nA = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\nA = np.array(A, dtype=float) + np.diag([np.inf] * N)\n\nuseless = np.zeros((N, N), dtype=bool)\nimpossible = np.zeros((N, N), dtype=bool)\nfor via in range(N):\n # R[i][j]: i -> via -> j \u306e\u8ddd\u96e2\n R = sum(np.meshgrid(A[via], A[via]))\n useless |= R == A\n impossible |= R < A\n\nif impossible.sum():\n print(-1)\nelse:\n print(int(A[~useless].sum() // 2))\n", "jacc_sim": 0.9508196721311475, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [231, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u391731808", "n_user": "u391731808", "pos": "import numpy as np\nN = int(input())\nA = np.array([list(map(int,input().split())) for _ in range(N)],dtype=np.int64)\n\nINF = 10**9+10\nE = np.zeros(((N*(N-1))//2,3),dtype=np.int64)\nk = 0\nfor i in range(N):\n for j in range(i+1,N):\n E[k,0] = A[i][j]\n E[k,1] = i\n E[k,2] = j\n k += 1\nE = E[E.argsort(0)[:,0]]\nB = np.ones((N,N),dtype=np.int64)*INF\nans = 0\nfor l,i,j in E:\n l_min = np.min(B[i]+B[j])\n if l > l_min:\n ans = -1\n break\n elif l < l_min:\n ans += l\n B[i][j] = l\n B[j][i] = l\nprint(ans)", "neg": "import numpy as np\nN = int(input())\nA = np.array([list(map(int,input().split())) for _ in range(N)],dtype=np.int64)\n\nINF = 10**9+10\nE = np.zeros(((N*(N-1))//2,3),dtype=np.int64)\nk = 0\nfor i in range(N):\n for j in range(i+1,N):\n E[k,0] = A[i][j]\n E[k,1] = i\n E[k,2] = j\n k += 1\nE = E[E.argsort(0)[0]]\nB = np.ones((N,N),dtype=np.int64)*INF\nans = 0\nfor l,i,j in E:\n l_min = np.min(B[i]+B[j])\n if l > l_min:\n ans = -1\n break\n elif l < l_min:\n ans += l\n B[i][j] = l\n B[j][i] = l\nprint(ans)", "jacc_sim": 1.0, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [268, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03600", "p_user": "u667084803", "n_user": "u667084803", "pos": "def Warshall_Floyd(edges,N):\n import copy\n d=copy.deepcopy(edges)\n for k in range(N):\n for i in range(N):\n for j in range(N):\n d[i][j]=min(d[i][j],d[i][k]+d[k][j])\n return d\n\nimport sys\nN=int(input())\nA=[list(map(int,input().split())) for i in range(N)]\nB=Warshall_Floyd(A,N)\nif A!=B:\n print(-1)\n sys.exit()\n\nans=0\nfor i in range(N):\n for j in range(i):\n need=1\n for k in range(N):\n if k!=i and k!=j:\n if A[i][j]==A[i][k]+A[k][j]: need=0\n ans+=need*A[i][j]\nprint(ans)", "neg": "def Warshall_Floyd(edges,N):\n for k in range(N):\n for i in range(N):\n for j in range(N):\n edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])\n return edges\n\nimport sys\nN=int(input())\nA=[list(map(int,input().split())) for i in range(N)]\nB=Warshall_Floyd(A,N)\nif A!=B:\n print(-1)\n sys.exit()\n\nans=0\nfor i in range(N):\n for j in range(i):\n need=1\n for k in range(N):\n if k!=i and k!=j:\n if A[i][j]==A[i][k]+A[k][j]: need=0\n ans+=need*A[i][j]\nprint(ans)", "jacc_sim": 0.9318181818181818, "nl": "In the ancient Takahashi Kingdom, there are N cities connected by bidirectional roads. The shortest distances between cities are represented in a table A. The task is to determine if there exists a road network where the shortest path from each city u to v matches the values in table A. If such a network exists, find the shortest total length of the roads. Constraints: 1 \u2264 N \u2264 300, A[i,j] = A[j,i] if i \u2260 j, 1 \u2264 A[i,j] \u2264 10^9, A[i,i] = 0. The input format is N followed by the table A. If no satisfying network exists, print -1; otherwise, print the shortest total road length. Sample inputs and outputs are provided.", "before_after_length": [244, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03603", "p_user": "u095021077", "n_user": "u095021077", "pos": "N=int(input())\nP=list(map(int, input().split()))\nX=[0]+list(map(int, input().split()))\nko=[[] for _ in range(N+1)]\nfor i, p in enumerate(P, 2):\n ko[p].append(i)\n \ndef f(p):\n n=len(ko[p])\n if n==0:\n return X[p], 0\n \n dp=[[float('inf')]*5001 for _ in range(n+1)]\n dp[0][0]=0\n for i, c in enumerate(ko[p], 1):\n a, b=f(c)\n for j in range(a, 5001):\n dp[i][j]=min(dp[i][j], dp[i-1][j-a]+b)\n for j in range(b, 5001):\n dp[i][j]=min(dp[i][j], dp[i-1][j-b]+a)\n \n out=min(dp[-1][:X[p]+1])\n if out==float('inf'):\n print('IMPOSSIBLE')\n exit()\n elif out>X[p]:\n return out, X[p]\n else:\n return X[p], out\n \nprint('POSSIBLE') if min(f(1))<=X[1] else print('IMPOSSIBLE')", "neg": "N=int(input())\nP=list(map(int, input().split()))\nX=[0]+list(map(int, input().split()))\nko=[[] for _ in range(N+1)]\nfor i, p in enumerate(P, 2):\n ko[p].append(i)\n \ndef f(p):\n n=len(ko[p])\n if n==0:\n return X[p], 0\n \n dp=[[float('inf')]*(X[p]+1) for _ in range(n+1)]\n dp[0][0]=0\n for i, c in enumerate(ko[p], 1):\n a, b=f(c)\n for j in range(a, 5001):\n dp[i][j]=min(dp[i][j], dp[i-1][j-a]+b)\n for j in range(b, 5001):\n dp[i][j]=min(dp[i][j], dp[i-1][j-b]+a)\n \n out=min(dp[-1])\n if out==float('inf'):\n print('IMPOSSIBLE')\n exit()\n elif out>X[p]:\n return out, X[p]\n else:\n return X[p], out\n \nprint('POSSIBLE') if min(f(1))<=X[1] else print('IMPOSSIBLE')", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where vertex 1 is the root and the parent of vertex i (2 \u2264 i \u2264 N) is vertex P_i. Each vertex is assigned a color (black or white) and a non-negative integer weight. You are also given a favorite integer sequence, X_1, X_2, ..., X_N. The goal is to allocate colors and weights so that the total weight of vertices with the same color among the subtree rooted at each vertex v is equal to X_v. Determine if it's possible to allocate colors and weights to satisfy this condition. The constraints are 1 \u2264 N \u2264 1000, 1 \u2264 P_i \u2264 i - 1, and 0 \u2264 X_i \u2264 5000. The input format is N, followed by P_2, P_3, ..., P_N, and X_1, X_2, ..., X_N. If possible, output \"POSSIBLE\"; otherwise, output \"IMPOSSIBLE\".", "before_after_length": [349, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03603", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\ndef main():\n n = I()\n p = LI_()\n x = LI()\n e = collections.defaultdict(list)\n for i in range(n-1):\n e[p[i]].append(i+1)\n\n def f(i):\n if not e[i]:\n return [0,x[i]]\n a = 0\n xi = x[i]\n xi1 = xi + 1\n tx = [0] * xi1\n tx[0] = 1\n for c in e[i]:\n rc = f(c)\n if not rc:\n return\n a += sum(rc)\n tt = [0] * xi1\n for i in range(xi1):\n if tx[i] == 0:\n continue\n for c in rc:\n if i+c < xi1:\n tt[i+c] = 1\n tx = tt\n for i in range(xi,-1,-1):\n if tx[i] == 1:\n return [xi, a-i]\n return\n\n if f(0):\n return 'POSSIBLE'\n\n return 'IMPOSSIBLE'\n\n\nprint(main())\n\n\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 10**9+7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\ndef main():\n n = I()\n p = LI_()\n x = LI()\n e = collections.defaultdict(list)\n for i in range(n-1):\n e[p[i]].append(i+1)\n\n def f(i):\n if not e[i]:\n return [0,x[i]]\n a = []\n xi = x[i]\n tx = xi\n for c in e[i]:\n rc = f(c)\n if not rc:\n return\n tx += rc[1]\n a.append(rc[0])\n s = sum(a)\n if s <= xi:\n return [min(tx-xi, xi), tx]\n return\n\n if f(0):\n return 'POSSIBLE'\n\n return 'IMPOSSIBLE'\n\n\nprint(main())\n\n\n\n", "jacc_sim": 0.9397590361445783, "nl": "You are given a tree with N vertices, where vertex 1 is the root and the parent of vertex i (2 \u2264 i \u2264 N) is vertex P_i. Each vertex is assigned a color (black or white) and a non-negative integer weight. You are also given a favorite integer sequence, X_1, X_2, ..., X_N. The goal is to allocate colors and weights so that the total weight of vertices with the same color among the subtree rooted at each vertex v is equal to X_v. Determine if it's possible to allocate colors and weights to satisfy this condition. The constraints are 1 \u2264 N \u2264 1000, 1 \u2264 P_i \u2264 i - 1, and 0 \u2264 X_i \u2264 5000. The input format is N, followed by P_2, P_3, ..., P_N, and X_1, X_2, ..., X_N. If possible, output \"POSSIBLE\"; otherwise, output \"IMPOSSIBLE\".", "before_after_length": [496, 413], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03603", "p_user": "u226155577", "n_user": "u226155577", "pos": "n = int(input())\nP = list(map(int, input().split()))\nX = list(map(int, input().split()))\n\ndp = [0]*n\nchild = [[] for i in range(n)]\nfor i in range(n-1):\n child[P[i]-1].append(i+1)\n\nfor i in range(n-1, -1, -1):\n if not child[i]:\n dp[i] = 0\n else:\n su = 0\n re = 0\n for c in child[i]:\n z = min(X[c], dp[c])\n su += z\n if su > X[i]:\n print(\"IMPOSSIBLE\")\n exit(0)\n can = X[i] - su\n ss = set([0])\n for c in child[i]:\n z = min(X[c], dp[c])\n rest = max(X[c], dp[c]) - z\n re += rest\n pp = set(ss)\n for s in ss:\n if s + rest <= can:\n pp.add(s + rest)\n ss = pp\n dp[i] = su + re - max(ss)\nprint(\"POSSIBLE\")\n", "neg": "n = int(input())\nP = list(map(int, input().split()))\nX = list(map(int, input().split()))\n\ndp = [0]*n\nchild = [[] for i in range(n)]\nfor i in range(n-1):\n child[P[i]-1].append(i+1)\n\nfor i in range(n-1, -1, -1):\n if not child[i]:\n dp[i] = 0\n else:\n su = 0\n re = 0\n for c in child[i]:\n z = min(X[c], dp[c])\n su += z\n if su > X[i]:\n print(\"IMPOSSIBLE\")\n exit(0)\n can = X[i] - su\n ss = set([0])\n for c in child[i]:\n z = min(X[c], dp[c])\n rest = max(X[c], dp[c]) - z\n re += rest\n pp = set(ss)\n for s in ss:\n if s + rest <= can:\n pp.add(s + rest)\n ss = pp\n print(ss, can)\n dp[i] = su + re - max(ss)\nprint(\"POSSIBLE\")\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, where vertex 1 is the root and the parent of vertex i (2 \u2264 i \u2264 N) is vertex P_i. Each vertex is assigned a color (black or white) and a non-negative integer weight. You are also given a favorite integer sequence, X_1, X_2, ..., X_N. The goal is to allocate colors and weights so that the total weight of vertices with the same color among the subtree rooted at each vertex v is equal to X_v. Determine if it's possible to allocate colors and weights to satisfy this condition. The constraints are 1 \u2264 N \u2264 1000, 1 \u2264 P_i \u2264 i - 1, and 0 \u2264 X_i \u2264 5000. The input format is N, followed by P_2, P_3, ..., P_N, and X_1, X_2, ..., X_N. If possible, output \"POSSIBLE\"; otherwise, output \"IMPOSSIBLE\".", "before_after_length": [306, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00542", "p_user": "u327546577", "n_user": "u327546577", "pos": "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nE = int(input())\nF = int(input())\n\nprint(sum(sorted([A, B, C, D], reverse=True)[:3]) + max(E, F))\n", "neg": "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nE = int(input())\nF = int(input())\n\nprint(sum(sorted([A, B, C, D])[:3]) + max(E, F))\n", "jacc_sim": 0.9130434782608695, "nl": "Title: Selecting Subjects\n\nProblem:\nJOI took tests in 6 subjects: physics, chemistry, biology, geology, history, and geography. Each test was scored out of 100 points.\n\nJOI must choose 3 subjects from physics, chemistry, biology, and geology, and 1 subject from history and geography.\n\nFind the total score of the selected subjects to maximize JOI's total points.\n\nInput:\nConsists of 6 lines, each containing an integer.\n1st line: JOI's score in physics (A)\n2nd line: JOI's score in chemistry (B)\n3rd line: JOI's score in biology (C)\n4th line: JOI's score in geology (D)\n5th line: JOI's score in history (E)\n6th line: JOI's score in geography (F)\n\nAll integers A, B, C, D, E, F are between 0 and 100 (inclusive).\n\nOutput:\nOutput the total score of the selected subjects in a single line.\n\nExample:\nInput 1:\n100\n34\n76\n42\n10\n0\n\nOutput 1:\n228\n\nInput 2:\n15\n21\n15\n42\n15\n62\n\nOutput 2:\n140\n\nExplanation:\nIn Example 1, JOI selects physics, biology, geology, and history, resulting in a total score of 228.\nIn Example 2, JOI selects chemistry, biology, geology, and geography, resulting in a total score of 140.", "before_after_length": [72, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00542", "p_user": "u476754031", "n_user": "u452212317", "pos": "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\ne = int(input())\nf = int(input())\nx = a + b + c + d + e + f\ny = 100000\nfor i in (a,b,c,d):\n if y > i : y = i\nz = 0\nif e < f : z = e\nelse : z = f\nprint (x - y - z)\n", "neg": "a,b,c,d,e,f = map(int, input().split())\nx = a + b + c + d + e + f\ny = 100000\nfor i in (a,b,c,d):\n if y > i : y = i\nz = 0\nif e < f : z = f\nelse : z = e\nprint (x - y - z)", "jacc_sim": 0.9032258064516129, "nl": "Title: Selecting Subjects\n\nProblem:\nJOI took tests in 6 subjects: physics, chemistry, biology, geology, history, and geography. Each test was scored out of 100 points.\n\nJOI must choose 3 subjects from physics, chemistry, biology, and geology, and 1 subject from history and geography.\n\nFind the total score of the selected subjects to maximize JOI's total points.\n\nInput:\nConsists of 6 lines, each containing an integer.\n1st line: JOI's score in physics (A)\n2nd line: JOI's score in chemistry (B)\n3rd line: JOI's score in biology (C)\n4th line: JOI's score in geology (D)\n5th line: JOI's score in history (E)\n6th line: JOI's score in geography (F)\n\nAll integers A, B, C, D, E, F are between 0 and 100 (inclusive).\n\nOutput:\nOutput the total score of the selected subjects in a single line.\n\nExample:\nInput 1:\n100\n34\n76\n42\n10\n0\n\nOutput 1:\n228\n\nInput 2:\n15\n21\n15\n42\n15\n62\n\nOutput 2:\n140\n\nExplanation:\nIn Example 1, JOI selects physics, biology, geology, and history, resulting in a total score of 228.\nIn Example 2, JOI selects chemistry, biology, geology, and geography, resulting in a total score of 140.", "before_after_length": [111, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00586", "p_user": "u617990214", "n_user": "u617990214", "pos": "out=[]\nwhile True:\n\ttry:\n\t\tk=list(map(int,input().split(\" \")))\n\texcept:\n\t\tbreak\n\n\tout.append(k[0]+k[1])\n\nfor i in out:\n\tprint(i)", "neg": "out=[]\nwhile True:\n\ttry:\n\t\tk=list(map(int,input().split(\" \")))\n\t out.append(k[0]+k[1])\n\texcept:\n\t\tbreak\n\nfor i in out:\n\tprint(i)", "jacc_sim": 1.0, "nl": "Title: A + B Problem\n\nCompute the sum of two integers A and B.\n\nInput:\nThe input will consist of a series of pairs of integers A and B separated by a space, with one pair of integers per line. The input will be terminated by the end of the file (EOF).\n\nOutput:\nFor each pair of input integers A and B, output the sum of A and B in one line.\n\nConstraints:\n-1000 \u2264 A, B \u2264 1000\n\nSample Input:\n1 2\n10 5\n100 20\n\nOutput for the Sample Input:\n3\n15\n120\n\nSample Program:\n#include\n\nint main(){\n int a, b;\n while( scanf(\"%d %d\", &a, &b) != EOF ){\n printf(\"%d\\n\", a + b);\n }\n return 0;\n}", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00586", "p_user": "u545973195", "n_user": "u545973195", "pos": "ans=\"\"\nwhile True:\n\ttry:\n\t\tinfo=input()\n\texcept:\n\t\tbreak\n\tif ans!=\"\":\n\t\tans+=\"\\n\"\n\tinfo_2=info.split()\n\tans+=str(int(info_2[0])+int(info_2[1]))\nprint(ans)", "neg": "ans=\"\"\nwhile True:\n\ttry:\n\t\tinfo=input()\n\texcept:\n\t\tbreak\n\tif ans!=\"\":\n\t\tans+=\"\\n\"\n info_2=info.split()\n ans+=str(int(info_2[0])+int(info_2[1]))\nprint(ans)", "jacc_sim": 1.0, "nl": "Title: A + B Problem\n\nCompute the sum of two integers A and B.\n\nInput:\nThe input will consist of a series of pairs of integers A and B separated by a space, with one pair of integers per line. The input will be terminated by the end of the file (EOF).\n\nOutput:\nFor each pair of input integers A and B, output the sum of A and B in one line.\n\nConstraints:\n-1000 \u2264 A, B \u2264 1000\n\nSample Input:\n1 2\n10 5\n100 20\n\nOutput for the Sample Input:\n3\n15\n120\n\nSample Program:\n#include\n\nint main(){\n int a, b;\n while( scanf(\"%d %d\", &a, &b) != EOF ){\n printf(\"%d\\n\", a + b);\n }\n return 0;\n}", "before_after_length": [81, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00586", "p_user": "u014788538", "n_user": "u617183767", "pos": "import sys\n\nfor line in sys.stdin:\n a, b = map(int, line.split())\n print(a+b)", "neg": "import sys\n\nfor line in sys.stdin.readline():\n\ta, b = map(int, line.split())\n\tprint a + b", "jacc_sim": 0.95, "nl": "Title: A + B Problem\n\nCompute the sum of two integers A and B.\n\nInput:\nThe input will consist of a series of pairs of integers A and B separated by a space, with one pair of integers per line. The input will be terminated by the end of the file (EOF).\n\nOutput:\nFor each pair of input integers A and B, output the sum of A and B in one line.\n\nConstraints:\n-1000 \u2264 A, B \u2264 1000\n\nSample Input:\n1 2\n10 5\n100 20\n\nOutput for the Sample Input:\n3\n15\n120\n\nSample Program:\n#include\n\nint main(){\n int a, b;\n while( scanf(\"%d %d\", &a, &b) != EOF ){\n printf(\"%d\\n\", a + b);\n }\n return 0;\n}", "before_after_length": [33, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00586", "p_user": "u501510481", "n_user": "u501510481", "pos": "import sys\nfor line in sys.stdin:\n items = line.split()\n print( int(items[0]) + int(items[1]) )", "neg": "import sys\nfor line in sys.stdin:\n items = line.split()\n print( items[0] + items[1] )", "jacc_sim": 0.95, "nl": "Title: A + B Problem\n\nCompute the sum of two integers A and B.\n\nInput:\nThe input will consist of a series of pairs of integers A and B separated by a space, with one pair of integers per line. The input will be terminated by the end of the file (EOF).\n\nOutput:\nFor each pair of input integers A and B, output the sum of A and B in one line.\n\nConstraints:\n-1000 \u2264 A, B \u2264 1000\n\nSample Input:\n1 2\n10 5\n100 20\n\nOutput for the Sample Input:\n3\n15\n120\n\nSample Program:\n#include\n\nint main(){\n int a, b;\n while( scanf(\"%d %d\", &a, &b) != EOF ){\n printf(\"%d\\n\", a + b);\n }\n return 0;\n}", "before_after_length": [36, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00586", "p_user": "u350508326", "n_user": "u350508326", "pos": "while True:\n try:\n a, b = map(int, input().split())\n print(a+b)\n except EOFError as e:\n break", "neg": "while True:\n try:\n a, b = map(int, input().split())\n printe(a+b)\n except EOFError as e:\n break", "jacc_sim": 0.9130434782608695, "nl": "Title: A + B Problem\n\nCompute the sum of two integers A and B.\n\nInput:\nThe input will consist of a series of pairs of integers A and B separated by a space, with one pair of integers per line. The input will be terminated by the end of the file (EOF).\n\nOutput:\nFor each pair of input integers A and B, output the sum of A and B in one line.\n\nConstraints:\n-1000 \u2264 A, B \u2264 1000\n\nSample Input:\n1 2\n10 5\n100 20\n\nOutput for the Sample Input:\n3\n15\n120\n\nSample Program:\n#include\n\nint main(){\n int a, b;\n while( scanf(\"%d %d\", &a, &b) != EOF ){\n printf(\"%d\\n\", a + b);\n }\n return 0;\n}", "before_after_length": [40, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00589", "p_user": "u078042885", "n_user": "u078042885", "pos": "a=[['\\'',',','.','!','?'],\n ['a','b','c','A','B','C'],\n ['d','e','f','D','E','F'],\n ['g','h','i','G','H','I'],\n ['j','k','l','J','K','L'],\n ['m','n','o','M','N','O'],\n ['p','q','r','s','P','Q','R','S'],\n ['t','u','v','T','U','V'],\n ['w','x','y','z','W','X','Y','Z']]\nwhile 1:\n try:b=input()+'@'\n except:break\n c=0\n ans=''\n for i in range(len(b)-1):\n if b[i]!=b[i+1]:\n if b[i]!='0':\n d=int(b[i])-1\n ans+=a[d][c%len(a[d])]\n c=0\n else: c+=1\n if b[i]==b[i+1]=='0':ans+=' '\n print(ans)", "neg": "a=[['\\'',',','.','!','?'],\n ['a','b','c','A','B','C'],\n ['d','e','f','D','E','F'],\n ['g','h','i','G','H','I'],\n ['j','k','l','J','K','L'],\n ['m','n','o','M','N','O'],\n ['p','q','r','s','P','Q','R','S'],\n ['t','u','v','T','U','V'],\n ['w','x','y','z','W','X','Y','Z']]\nwhile 1:\n try:b=input()+'@'\n except:pass\n c=0\n ans=''\n for i in range(len(b)-1):\n if b[i]!=b[i+1]:\n if b[i]!='0':\n d=int(b[i])-1\n ans+=a[d][c%len(a[d])]\n c=0\n else: c+=1\n if b[i]==b[i+1]=='0':ans+=' '\n print(ans)", "jacc_sim": 0.9764705882352941, "nl": "Title: Extraordinary Girl (II)\n\nThe girl loves sending emails using her cellular phone. Each button on her phone corresponds to a specific set of characters. For example, pressing button 1 once displays a single quote (') and pressing it twice displays a comma (,). Button 0 is a special button used for inputting characters in series. For instance, pressing \"20202\" displays \"aaa\" and \"660666\" displays \"no\". The input consists of sequences of button numbers, and the task is to convert these sequences into the corresponding characters. Each line of input contains a sequence of button numbers without spaces, and the output should display the corresponding sequence of characters in one line. The input terminates with EOF.", "before_after_length": [280, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00590", "p_user": "u546285759", "n_user": "u546285759", "pos": "primes = [0, 0] + [1] * 9999\nfor i in range(2, 101):\n if primes[i]:\n for j in range(i*i, 10001, i):\n primes[j] = 0\n\nwhile True:\n try:\n N = int(input())\n except:\n break\n print(sum(primes[i] and primes[N-i+1] for i in range(1, N+1)))", "neg": "primes = [0, 0] + [1] * 9999\nfor i in range(2, 101):\n if primes[i]:\n for j in range(i*i, 10001, i):\n primes[j] = 0\n\nwhile True:\n try:\n N = int(input())\n except:\n break\n print(sum(primes[i] & primes[-i] for i in range(1, N+1)))", "jacc_sim": 0.9428571428571428, "nl": "Pair of Primes\n\nWe arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order. Two numbers facing each other form a pair. The task is to compute the number of pairs P such that both numbers in the pairs are prime.\n\nInput\n\nInput contains several test cases. Each test case consists of an integer N in one line.\n\nOutput\n\nFor each line of input, output P.\n\nSample Input\n1\n4\n7\n51\n\nOutput for the Sample Input\n0\n2\n2\n6", "before_after_length": [113, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00590", "p_user": "u269391636", "n_user": "u269391636", "pos": "import math\n\ndef ifprime(num):\n if num == 1:\n return False\n for i in range(2,math.floor(num ** 0.5) + 1):\n if num % i:\n continue\n else:\n return False\n return True\n\nwhile(True):\n try:\n num = int(input())\n except:\n break\n count = 0\n for i in range(1,num+1):\n if ifprime(i) and ifprime(num+1-i):\n count += 1\n print(count)\n\n", "neg": "import math\n\ndef ifprime(num):\n if num == 1:\n return False\n for i in range(2,math.floor(num ** 0.5) + 1):\n if num % i:\n continue\n else:\n return False\n return True\n\nwhile(True):\n try:\n num = int(input())\n except:\n break\n if num % 2 == 0:\n print(0)\n else:\n count = 0\n for i in range(1,num+1):\n if ifprime(i) and ifprime(num+1-i):\n count += 1\n print(count)\n\n", "jacc_sim": 1.0, "nl": "Pair of Primes\n\nWe arrange the numbers between 1 and N (1 <= N <= 10000) in increasing order and decreasing order. Two numbers facing each other form a pair. The task is to compute the number of pairs P such that both numbers in the pairs are prime.\n\nInput\n\nInput contains several test cases. Each test case consists of an integer N in one line.\n\nOutput\n\nFor each line of input, output P.\n\nSample Input\n1\n4\n7\n51\n\nOutput for the Sample Input\n0\n2\n2\n6", "before_after_length": [140, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00594", "p_user": "u372789658", "n_user": "u372789658", "pos": "while True:\n num=int(input())\n if num==0:\n break\n stars=sorted(input().split())\n if stars.count(stars[num//2]) > num/2 :\n print(stars[num//2])\n else:\n print(\"NO COLOR\")", "neg": "while True:\n num=int(input())\n if num==0:\n break\n stars=sorted(input().split())\n print(stars)\n if stars.count(stars[num//2]) > num/2 :\n print(stars[num//2])\n else:\n print(\"NO COLOR\")", "jacc_sim": 1.0, "nl": "Title: What Color Is The Universe?\n\nOn a clear night, a boy named Campanella gazed at the sky, observing stars of various colors. Lost in time, he pondered, \"There are many stars in space. What color is the universe if I observe it from outside?\" He proposed a hypothesis: \"When I observe the stars, if more than half have the same color, that is the color of the universe.\"\n\nSick in bed, he sought help to develop a program to identify the color of the universe. Given an array A, find m such that Nm > (|A| / 2). If no such m exists, report \"NO COLOR.\"\n\nInput: For each test case, the first line contains |A|, followed by |A| integers. The input terminates with a line containing a single 0.\n\nOutput: For each test case, output m in a line. If there is no answer, output \"NO COLOR.\"\n\nSample Input:\n8\n3 1 2 3 3 1 5 3\n7\n5 2 5 3 4 5 5\n0\n\nOutput for the Sample Input:\nNO COLOR\n5", "before_after_length": [72, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00613", "p_user": "u471400255", "n_user": "u471400255", "pos": "while True:\n K = int(input())\n if K == 0:\n break\n elif K == 1:\n print(int(input()))\n else:\n po = [int(i) for i in input().split()]\n print(int(sum(po)/(K-1)))", "neg": "while True:\n K = int(input())\n if K == 0:\n break\n else:\n po = [int(i) for i in input().split()]\n print(sum(po)/(K-1))", "jacc_sim": 0.9629629629629629, "nl": "Problem I: A Piece of Cake\n\nIn the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although the cause of his shop's unpopularity is the incredibly awful taste of its cakes, he never improved it. He was just growing hate, ill, envy, and jealousy.\n\nFinally, he decided to vandalize the rival.\n\nHis vandalize is to mess up sales record of cakes. The rival shop sells K kinds of cakes and sales quantity is recorded for each kind. He calculates the sum of sales quantities for all pairs of cakes. Getting K(K-1)/2 numbers, then he rearranges them randomly, and replaces the original sales record with them.\n\nThe owner of the rival shop is bothered. Could you write, at least, a program that finds the total sales quantity of all cakes for the pitiful owner?\n\nInput\n\nInput file contains several data sets. A single data set has the following format:\n\nK\nc1 c2 ... c(K*(K-1)/2)\n\nK is an integer that denotes how many kinds of cakes are sold. ci is an integer that denotes a number written on the card.\n\nThe end of input is denoted by a case where K = 0. You should output nothing for this case.\n\nOutput\n\nFor each data set, output the total sales quantity in one line.\n\nConstraints\n- Judge data contains at most 100 data sets.\n- 2 <= K <= 100\n- 0 <= ci <= 100\n\nSample Input\n2\n2\n3\n5 4 3\n0\n\nOutput for the Sample Input\n2\n6", "before_after_length": [73, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00613", "p_user": "u352394527", "n_user": "u633068244", "pos": "while True:\n k = int(input())\n if k == 0:\n break\n\n print(sum(map(int, input().split())) // (k - 1))\n", "neg": "while 1:\n k=input()-1\n if k==0:break\n print sum(map(int, raw_input().split()))/k", "jacc_sim": 0.9090909090909091, "nl": "Problem I: A Piece of Cake\n\nIn the city, there are two pastry shops. One shop was very popular because its cakes are pretty tasty. However, there was a man who is displeased at the shop. He was an owner of another shop. Although the cause of his shop's unpopularity is the incredibly awful taste of its cakes, he never improved it. He was just growing hate, ill, envy, and jealousy.\n\nFinally, he decided to vandalize the rival.\n\nHis vandalize is to mess up sales record of cakes. The rival shop sells K kinds of cakes and sales quantity is recorded for each kind. He calculates the sum of sales quantities for all pairs of cakes. Getting K(K-1)/2 numbers, then he rearranges them randomly, and replaces the original sales record with them.\n\nThe owner of the rival shop is bothered. Could you write, at least, a program that finds the total sales quantity of all cakes for the pitiful owner?\n\nInput\n\nInput file contains several data sets. A single data set has the following format:\n\nK\nc1 c2 ... c(K*(K-1)/2)\n\nK is an integer that denotes how many kinds of cakes are sold. ci is an integer that denotes a number written on the card.\n\nThe end of input is denoted by a case where K = 0. You should output nothing for this case.\n\nOutput\n\nFor each data set, output the total sales quantity in one line.\n\nConstraints\n- Judge data contains at most 100 data sets.\n- 2 <= K <= 100\n- 0 <= ci <= 100\n\nSample Input\n2\n2\n3\n5 4 3\n0\n\nOutput for the Sample Input\n2\n6", "before_after_length": [44, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00627", "p_user": "u662126750", "n_user": "u778333573", "pos": "while True:\n n = int(input())\n if n==0: break\n ans = 0\n for i in range(n//4):\n ans += int(input())\n print(ans)", "neg": "while True:\n n = input()\n if n == 0: break\n print ans(input() for i in range(n/4))", "jacc_sim": 0.9047619047619048, "nl": "Problem 01: Kyudo: A Japanese Art of Archery\n\nIto joined the archery club after entering high school. Initially struggling to hit the target, he eventually improved enough to reach it by the fall of his first year. One day, his senior, Kato, suggested, \"Why not participate in a close-range archery competition?\" Ito, eager for the challenge, agreed to compete in his first tournament.\n\nIn close-range archery, participants shoot four arrows in a round, recording the number of hits. This process is repeated multiple times, and the total number of hits is compared.\n\nTo help Ito prepare for the competition, Kato decided to create a program that calculates the total number of hits expected during the actual event. The program reads the total number of shots, \"n,\" and the number of hits for each round, then outputs the total number of hits.\n\nFor instance, if the total number of shots, \"n,\" is 20, and each round consists of 4 shots, the program will repeat this process 5 times, and the number of hits for each round will be input 5 times.\n\nInput:\nMultiple datasets are provided as input. For each dataset, the first line contains \"n\" (an integer that is a multiple of 4), followed by \"n/4\" integers representing the number of hits for each round.\n\nThe input ends when \"n\" is 0, and no output should be provided for this input.\n\nOutput:\nFor each dataset, output the total number of hits on a single line.\n\nSample Input:\n20\n4\n3\n2\n1\n3\n8\n2\n0\n0\n\nOutput for the Sample Input:\n13\n2", "before_after_length": [49, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00627", "p_user": "u003684951", "n_user": "u546285759", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n print(sum([int(input()) for _ in range(n // 4)]))\n", "neg": "while True:\n n = int(input())\n if n == 0: break\n print(sum([int(input()) for _ in range(n//5)]))", "jacc_sim": 0.9130434782608695, "nl": "Problem 01: Kyudo: A Japanese Art of Archery\n\nIto joined the archery club after entering high school. Initially struggling to hit the target, he eventually improved enough to reach it by the fall of his first year. One day, his senior, Kato, suggested, \"Why not participate in a close-range archery competition?\" Ito, eager for the challenge, agreed to compete in his first tournament.\n\nIn close-range archery, participants shoot four arrows in a round, recording the number of hits. This process is repeated multiple times, and the total number of hits is compared.\n\nTo help Ito prepare for the competition, Kato decided to create a program that calculates the total number of hits expected during the actual event. The program reads the total number of shots, \"n,\" and the number of hits for each round, then outputs the total number of hits.\n\nFor instance, if the total number of shots, \"n,\" is 20, and each round consists of 4 shots, the program will repeat this process 5 times, and the number of hits for each round will be input 5 times.\n\nInput:\nMultiple datasets are provided as input. For each dataset, the first line contains \"n\" (an integer that is a multiple of 4), followed by \"n/4\" integers representing the number of hits for each round.\n\nThe input ends when \"n\" is 0, and no output should be provided for this input.\n\nOutput:\nFor each dataset, output the total number of hits on a single line.\n\nSample Input:\n20\n4\n3\n2\n1\n3\n8\n2\n0\n0\n\nOutput for the Sample Input:\n13\n2", "before_after_length": [42, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00638", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n n = int(input())\n if n == 0:\n break\n z = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])\n total = 0\n for a, b in z:\n total += a\n if total > b:\n print(\"No\")\n break\n else:\n print(\"Yes\")", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n z = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])\n cnt = total = 0\n for a, b in z:\n total += a\n if total > b:\n cnt = 1\n break\n print(\"Yes\" if cnt else \"No\")", "jacc_sim": 0.975, "nl": "Problem B: Old Bridges\n\nLong long ago, there was a thief searching for treasures on various islands. He found n islands with treasures and one empty island. Most islands had a seashore, and he could only land on the empty island. Each island had an old bridge connecting it to the others. The thief aims to visit all islands, collecting treasures without the bridges breaking due to carrying too much. Write a program to determine if he can collect all treasures and return to the initial island by choosing a suitable visiting order.\n\nInput:\nSeveral datasets. Each dataset starts with an integer n. The next n lines contain information about the islands: the amount of treasures and the maximum amount he can carry when crossing the bridge to each island.\n\nOutput:\nFor each dataset, print \"Yes\" if he can collect all treasures and return, otherwise print \"No\".\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input:\n3\n2 3\n3 6\n1 2\n3\n2 3\n3 5\n1 2\n0\n\nSample Output:\nYes\nNo", "before_after_length": [101, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00638", "p_user": "u531592024", "n_user": "u531592024", "pos": "def sky(x):\n return x[1]\n\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n \n arr = [[] for i in range(n)]\n sumh = 0\n for i in range(n):\n arr[i] = list(map(int, input().split()))\n arr.sort(key=sky)\n res = True\n for e in arr:\n sumh += e[0]\n if sumh > e[1]:\n res = False\n break\n if res:\n print(\"Yes\")\n else:\n print(\"No\")\n\n", "neg": "def sky(x):\n return x[1]\n\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n \n arr = [[] for i in range(n)]\n sumh = 0\n for i in range(n):\n arr[i] = list(map(int, input().split()))\n sumh += arr[i][0]\n arr.sort(key=sky, reverse=True)\n print(arr)\n res = True\n for e in arr:\n if sumh > e[1]:\n res = False\n break\n sumh -= e[0]\n if res:\n print(\"Yes\")\n else:\n print(\"No\")\n\n", "jacc_sim": 0.9545454545454546, "nl": "Problem B: Old Bridges\n\nLong long ago, there was a thief searching for treasures on various islands. He found n islands with treasures and one empty island. Most islands had a seashore, and he could only land on the empty island. Each island had an old bridge connecting it to the others. The thief aims to visit all islands, collecting treasures without the bridges breaking due to carrying too much. Write a program to determine if he can collect all treasures and return to the initial island by choosing a suitable visiting order.\n\nInput:\nSeveral datasets. Each dataset starts with an integer n. The next n lines contain information about the islands: the amount of treasures and the maximum amount he can carry when crossing the bridge to each island.\n\nOutput:\nFor each dataset, print \"Yes\" if he can collect all treasures and return, otherwise print \"No\".\n\nConstraints:\n1 \u2264 n \u2264 25\n\nSample Input:\n3\n2 3\n3 6\n1 2\n3\n2 3\n3 5\n1 2\n0\n\nSample Output:\nYes\nNo", "before_after_length": [156, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u067983636", "n_user": "u067983636", "pos": "import sys\nfrom collections import deque\nimport bisect\nimport copy\nimport heapq\nimport itertools\nimport math\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nmod = 10 ** 9 + 7\n\ndef read_values(): return map(int, input().split())\ndef read_index(): return map(lambda x: int(x) - 1, input().split())\ndef read_list(): return list(read_values())\ndef read_lists(N): return [read_list() for n in range(N)]\n\n\ndef main():\n N = int(input())\n S = [input().strip() for _ in range(N)]\n print(sum(N if all(S[(i - a) % N][j] == S[(j - a) % N][i] for i in range(N) for j in range(N)) else 0 for a in range(N)))\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\nfrom collections import deque\nimport bisect\nimport copy\nimport heapq\nimport itertools\nimport math\ninput = sys.stdin.readline\nsys.setrecursionlimit(1000000)\nmod = 10 ** 9 + 7\n\ndef read_values(): return map(int, input().split())\ndef read_index(): return map(lambda x: int(x) - 1, input().split())\ndef read_list(): return list(read_values())\ndef read_lists(N): return [read_list() for n in range(N)]\n\n\ndef main():\n N = int(input())\n S = [input().strip() for _ in range(N)]\n print(sum(N if all(S[(i - a) % N][j] != S[(j - a) % N][i] for i in range(N) for j in range(N)) else 0 for a in range(N)))\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9848484848484849, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [228, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u545368057", "n_user": "u545368057", "pos": "\"\"\"\n\u4e0d\u5909\u306a\u3082\u306e\n- \u79fb\u52d5\u3057\u305f\u884c/\u5217\u5185\u306e\u9806\u756a\n\u25cb A\u3068B\u306e\u5dee\u306b\u3088\u3063\u3066\u3001\u7dda\u5bfe\u79f0(\u5bfe\u89d2\u7dda\u4e0a)\u306e\u3082\u306e\u304c\u6c7a\u307e\u308b\n\"\"\"\nn = int(input())\nfs = []\nfor i in range(n):\n rs = list(input())\n fs.append(rs)\ncnt = 0\nfor a in range(n):\n flg = True\n tmp = []\n for r in fs:\n r_ = r[a:] + r[:a]\n tmp.append(r_)\n for i in range(n):\n for j in range(n):\n flg &= tmp[i][j] == tmp[j][i]\n \n cnt += flg\nprint(cnt*n)", "neg": "\"\"\"\n\u4e0d\u5909\u306a\u3082\u306e\n- \u79fb\u52d5\u3057\u305f\u884c/\u5217\u5185\u306e\u9806\u756a\n\u25cb A\u3068B\u306e\u5dee\u306b\u3088\u3063\u3066\u3001\u7dda\u5bfe\u79f0(\u5bfe\u89d2\u7dda\u4e0a)\u306e\u3082\u306e\u304c\u6c7a\u307e\u308b\n\"\"\"\nn = int(input())\nfs = []\nfor i in range(n):\n rs = list(input())\n fs.append(rs)\ncnt = 0\nfor b in range(n):\n flg = True\n for i in range(n):\n for j in range(n):\n flg &= fs[i][j] == fs[i][(j+b)%n]\n cnt += flg\nprint(cnt*n)", "jacc_sim": 0.9130434782608695, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [266, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u923270446", "n_user": "u923270446", "pos": "I,R=input,range\nn=int(I())\ns=[I()for i in R(n)]\na=0\nfor i in R(n):\n if all(s[(i+j)%n][k]==s[(i+k)%n][j]for j in R(n)for k in R(j+1,n)):a+=n\nprint(a)", "neg": "I,R=input,range\nn=int(I())\ns=[I()for i in R(n)]\na=0\nfor i in R(n):\n if all(s[(i+j)%n][k]==s[(i+j)%n][j]for j in R(n) for k in R(i+1,n)):a+=n\nprint(a)", "jacc_sim": 1.0, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [95, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u678167152", "n_user": "u678167152", "pos": "def solve():\n N = int(input())\n S2 = [0]*N\n for i in range(N):\n S2[i] = input()\n ans = 0\n for k in range(N):\n cum = [[0]*(N+1) for _ in range(N+1)]\n for i in range(1,N+1):\n for j in range(1,N+1):\n cum[i][j] = cum[i-1][j]+cum[i][j-1]-cum[i-1][j-1]+(S2[i-1][j-1]==S2[(j-1+k)%N][(i-1-k)%N])\n if i==N and j==N:\n ans += (cum[i][j]==N*N)*N\n return ans\nprint(solve())", "neg": "def solve():\n N = int(input())\n S2 = [0]*N\n for i in range(N):\n S2[i] = input()\n ans = 0\n for k in range(N):\n cum = [[0]*(N+1) for _ in range(N+1)]\n for i in range(1,N+1):\n for j in range(1,N+1):\n cum[i][j] = cum[i-1][j]+cum[i][j-1]-cum[i-1][j-1]+(S2[i-1][j-1]==S2[(j-1+k)%N][(i-1-k)%N])\n for k in range(N):\n ans += (cum[-1][-1]==N*N)*N\n return ans\nprint(solve())", "jacc_sim": 0.9375, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [209, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u375616706", "n_user": "u375616706", "pos": "N = int(input())\ngrid=[[v for v in input()] for _ in range(N)]\n\nans=0\nfor a in range(N):\n new_grid=[]\n new_grid.extend(grid[a:])\n new_grid.extend(grid[:a])\n\n flag=True\n for i in range(N):\n for j in range(N):\n if new_grid[i][j]==new_grid[j][i]:\n continue\n else:\n flag=False\n break\n if flag:\n ans+=1\nprint(ans*N)\n", "neg": "N = int(input())\ngrid=[[v for v in input()] for _ in range(N)]\n\nans=0\nfor a in range(N):\n for b in range(1):\n new_grid=[]\n new_grid.extend(grid[a:])\n new_grid.extend(grid[:a])\n for i in range(N):\n new_grid[i] = new_grid[i][b:]+new_grid[i][:b]\n print(new_grid)\n\n flag=True\n for i in range(N):\n for j in range(N):\n if new_grid[i][j]==new_grid[j][i]:\n continue\n else:\n flag=False\n break\n if flag:\n ans+=1\nprint(ans)\n", "jacc_sim": 0.9428571428571428, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [147, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u145600939", "n_user": "u145600939", "pos": "n = int(input())\ns = [list(input()) for i in range(n)]\ns += s\n\ndef ok(array):\n for i in range(1,n):\n for j in range(i):\n if array[i][j] != array[j][i]:\n return False\n return True\nans = 0\nfor i in range(n):\n if ok(s[i:i+n]):\n ans += n\nprint(ans)\n", "neg": "n = int(input())\ns = [list(input()) for i in range(h)]\ns += s\n\ndef ok(array):\n for i in range(1,n):\n for j in range(i):\n if array[i][j] != array[j][i]:\n return False\n return True\nans = 0\nfor i in range(n-1):\n if ok(s[i:i+n]):\n ans += n\nprint(ans)\n", "jacc_sim": 0.9375, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [113, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u223904637", "n_user": "u223904637", "pos": "n=int(input())\nl=[]\nfor i in range(n):\n s=list(input())\n l.append(s+s)\nans=0\nfor i in range(n):\n f=0\n for h in range(n):\n for w in range(n):\n #0,0+i 1,1+i h,h+i\n if l[h][w+i]!=l[w][h+i]:\n f+=1\n if f==0:\n ans+=1\nprint(ans*n)\n", "neg": "n=int(input())\nl=[]\nfor i in range(n):\n s=list(input())\n l.append(s+s)\nans=0\nfor i in range(n):\n f=0\n for h in range(n):\n for w in range(n):\n #0,0+i 1,1+i h,h+i\n if l[h][w+i]!=l[h-w][h+i]:\n f+=1\n if f==0:\n ans+=1\nprint(ans*n)", "jacc_sim": 0.96875, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [137, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u561083515", "n_user": "u561083515", "pos": "# \u89e3\u8aacAC\nimport numpy as np\n\ndef is_symmetric(a):\n \"\"\"\n \u5bfe\u8c61\u884c\u5217\u5224\u5b9a O(N * N)\n \"\"\"\n return np.array_equal(a, a.T)\n\ndef main():\n N = int(input())\n S = [[ord(s) - ord(\"a\") for s in list(input())] for _ in range(N)]\n\n S = np.array(S)\n\n ans = 0\n for B in range(N):\n if is_symmetric(np.roll(S, B, axis=1)):\n ans += N\n\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "neg": "# \u89e3\u8aacAC\nimport numpy as np\n\ndef is_symmetric(a):\n \"\"\"\n \u5bfe\u8c61\u884c\u5217\u5224\u5b9a O(N * N)\n \"\"\"\n return np.array_equal(a, a.T)\n\ndef main():\n N = int(input())\n S = [[ord(s) - ord(\"a\") for s in list(input())] for _ in range(N)]\n\n S = np.array(S)\n\n ans = 0\n for B in range(N):\n if is_symmetric(np.roll(S, B, axis=1)):\n ans += N\n\n print(ans)", "jacc_sim": 0.9642857142857143, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [188, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u476604182", "n_user": "u476604182", "pos": "N, *S = open(0).read().split()\nN = int(N)\nans = 0\nfor p in range(N):\n flag = False\n for i in range(N):\n for j in range(N):\n x = i\n y = (j-p)%N\n a,b = y, (x+p)%N\n if S[i][j] != S[a][b]:\n flag = True\n break\n if flag:\n break\n else:\n ans+= N\nprint(ans)\n ", "neg": "N, *S = open('0').read().split()\nN = int(N)\nans = 0\nfor p in range(N):\n flag = False\n for i in range(N):\n for j in range(N):\n x = i\n y = (j-p)%N\n a,b = y, (x+p)%N\n if S[i][j] != S[a][b]:\n flag = True\n break\n if flag:\n break\n else:\n ans+= N\nprint(ans)", "jacc_sim": 0.9743589743589743, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [135, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u644907318", "n_user": "u644907318", "pos": "N = int(input())\nS = [input().strip() for _ in range(N)]\ncnt = 0\nfor k in range(N):\n flag = 0\n T = [S[i][k:]+S[i][:k] for i in range(N)]\n for i in range(N-1):\n for j in range(i+1,N):\n if T[i][j]!=T[j][i]:\n flag = 1\n break\n if flag==1:break\n if flag==0:\n cnt += 1\nprint(cnt*N)", "neg": "N = int(input())\nS = [input().strip() for _ in range(N)]\ncnt = 0\nfor k in range(N):\n flag = 0\n T = [S[i][k:]+S[i][:k] for i in range(N)]\n for i in range(N-1):\n for j in range(i+1,N):\n if T[i][j]!=T[j][i]:\n flag = 1\n break\n if flag==1:break\n if flag==0:\n cnt += 1\nprint(cnt**2)", "jacc_sim": 0.9696969696969697, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [140, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u543954314", "n_user": "u543954314", "pos": "n = int(input())\na = [list(input()) for _ in range(n)]\nans = 0\nfor s in range(n):\n f = 1\n for i in range(n):\n if not f:\n break\n for j in range(n):\n if a[(i+s)%n][j] != a[(j+s)%n][i]:\n f = 0\n break\n if f:\n ans += n\nprint(ans)", "neg": "n = int(input())\na = [list(input()) for _ in range(n)]\nans = 0\nfor s in range(n):\n f = 1\n for i in range(n):\n if not f:\n break\n for j in range(n):\n if a[(i+s)%n][j] != a[j][(i+s)%n]:\n f = 0\n break\n if f:\n ans += n\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [116, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u631277801", "n_user": "u631277801", "pos": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n \nn = ni()\ngrid = []\n \nfor _ in range(n):\n s = ns()\n s = s+s\n grid.append(s)\n \nfor i in range(n):\n grid.append(grid[i])\n \nvert = []\nhrzn = []\n \nfor i in range(2*n):\n hrzn.append(grid[i])\n \nfor j in range(2*n):\n temp = \"\"\n for i in range(2*n):\n temp += grid[i][j:j+1]\n \n vert.append(temp)\n \n \nans = 0\n \nfor a in range(n):\n for b in range(1):\n \n ok = True\n for i in range(n-1):\n \n if vert[b+i][a+i:a+n] != hrzn[a+i][b+i:b+n]:\n ok = False\n break\n \n if ok:\n ans += 1\n \nprint(ans*n)", "neg": "import sys\nstdin = sys.stdin\n\nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nn = ni()\ngrid = []\n\nfor _ in range(n):\n s = ns()\n s = s+s\n grid.append(s)\n \nfor i in range(n):\n grid.append(grid[i])\n \nvert = []\nhrzn = []\n\nfor i in range(2*n):\n hrzn.append(grid[i])\n \nfor j in range(2*n):\n temp = \"\"\n for i in range(2*n):\n temp += grid[i][j:j+1]\n \n vert.append(temp)\n \n \nans = 0\n\nfor a in range(n):\n for b in range(n):\n \n ok = True\n for i in range(1,n):\n if vert[b+i][a+i:a+n] != hrzn[a+i][b+i:b+n]:\n ok = False\n break\n \n if ok:\n ans += 1\n \nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [396, 388], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u562016607", "n_user": "u562016607", "pos": "N=int(input())\nS=[list(input()) for i in range(N)]\ndef issym(IL):\n for i in range(N):\n for j in range(i+1,N):\n if IL[i][j]!=IL[j][i]:\n return False\n return True\ndef changelist(A,B):\n T=[[\"\" for i in range(N)] for j in range(N)]\n for i in range(N):\n for j in range(N):\n T[i][j]=S[(i+A)%N][(j+B)%N]\n return T\nans=0\nfor i in range(N):\n L=changelist(i,0)\n if issym(L):\n ans+=N\nprint(ans)\n", "neg": "N=int(input())\nS=[list(input()) for i in range(N)]\ndef issym(IL):\n for i in range(N):\n for j in range(i+1,N):\n if IL[i][j]!=IL[j][i]:\n return False\n return True\ndef changelist(A,B):\n T=[[\"\" for i in range(N)] for j in range(N)]\n for i in range(N):\n for j in range(N):\n T[i][j]=S[(i+A)%N][(j+B)%N]\n return T\nans=0\nfor i in range(N):\n L=changelist(i,N-1-i)\n if issym(L):\n ans+=N\nprint(ans)\n", "jacc_sim": 0.9736842105263158, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [196, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u547085427", "n_user": "u547085427", "pos": "n = int(input())\nA = [input() for _ in range(n)]\nA_t = [''] * n\nfor c in A:\n for i in range(n):\n A_t[i] += c[i]\n\ndef checkTable(shift):\n for i in range(n):\n if A_t[(i + shift) % n] != A[i][shift:] + A[i][:shift]:\n return False\n return True\n\ncount = 0\nfor i in range(n):\n if checkTable(i):\n count += 1\nprint(count * n)", "neg": "n = int(input())\nA = [input() for _ in range(n)]\nA_t = [''] * n\nfor c in A:\n for i in range(n):\n A_t[i] += c[i]\n\ndef checkTable(shift):\n for i in range(n):\n if A_t[i] != A[i][shift:] + A[i][:shift]:\n return False\n return True\n\ncount = 0\nfor i in range(n):\n if checkTable(i):\n count += 1\nprint(count * n)", "jacc_sim": 0.9705882352941176, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [144, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u876442898", "n_user": "u876442898", "pos": "N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(S, A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(S[i:] + S[:i], 0, i)\nprint(cnt * N)", "neg": "N = int(input())\nS = []\nfor i in range(N):\n S.append(input())\n\ndef check(A, B):\n for i in range(N):\n for j in range(i+1, N):\n if S[i][j] != S[j][i]:\n return 0\n return 1\n\ncnt = 0\nfor i in range(N):\n cnt += check(0, i)\nprint(cnt * N)", "jacc_sim": 1.0, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [122, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u268793453", "n_user": "u268793453", "pos": "n = int(input())\ns = [input() for i in range(n)]\nst = [str().join(s_) for s_ in zip(*s)]\n\ncnt = 0\n\nfor i in range(n):\n i_ = (n+i)%n\n for k in range(n):\n if s[k] != st[k]:\n break\n else:\n cnt += 1\n s = [s_[-1]+s_[:-1] for s_ in s]\n st = [st[-1]] + st[:-1]\n\nprint(cnt*n)", "neg": "n = int(input())\ns = [input() for i in range(n)]\nst = [str().join(s_) for s_ in zip(*s)]\n\ncnt = 0\n\nfor i in range(n):\n i_ = (n+i)%n\n for k in range(n):\n if s[(i_+k)%n] != st[(i_+k)%n]:\n break\n else:\n cnt += 1\n\nprint(cnt*n)", "jacc_sim": 0.9705882352941176, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [142, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u302957509", "n_user": "u302957509", "pos": "\n\ndef is_symmetric(board):\n for i in range(N):\n for j in range(i, N):\n if board(j, i) != board(i, j):\n return False\n return True\n\n\ndef translate(board, a, b):\n def get(i, j):\n return board[(i + a) % N][(j + b) % N]\n \n return get\n\n\ndef solve(board):\n ans = 0\n for a in range(N):\n if is_symmetric(translate(board, a, 0)):\n ans += N - a\n for b in range(N):\n if b == 0:\n continue\n if is_symmetric(translate(board, 0, b)):\n ans += N - b\n return ans\n\n\nN = int(input())\nboard = []\nfor i in range(N):\n board.append(input())\n\n\nprint(solve(board))", "neg": "def is_symmetric(board):\n for i in range(N):\n for j in range(N):\n if board(j, i) != board(i, j):\n return False\n return True\n\n\ndef translate(board, a, b):\n def get(i, j):\n return board[(i + a) % N][(j + b) % N]\n \n return get\n\n\ndef solve(board):\n ans = 0\n for a in range(N):\n if is_symmetric(translate(board, a, 0)):\n ans += N - a\n for b in range(N):\n if b == 0:\n continue\n if is_symmetric(translate(board, 0, b)):\n ans += N - b\n return ans\n\n\nN = int(input())\nboard = []\nfor i in range(N):\n board.append(input())", "jacc_sim": 0.972972972972973, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [233, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03364", "p_user": "u314057689", "n_user": "u314057689", "pos": "def solve():\n global S, N\n N = int(input())\n\n S = []\n for n in range(N):\n S.append(list(input()))\n\n\n res = 0\n for n in range(N):\n if check(n):\n res += N\n\n print(res)\n\ndef check(move):\n for i in range(N):\n for j in range(i+1, N):\n if S[(i-move)%N][j] != S[(j-move)%N][i]:\n return False\n return True\n\n\nif __name__ == \"__main__\":\n solve()", "neg": "def solve():\n global S, N\n N = int(input())\n\n S = []\n for n in range(N):\n S.append(list(input()))\n\n\n res = 0\n for n in range(N):\n if check(n):\n res += N\n\n print(res)\n\ndef check(move):\n for i in range(N):\n for j in range(i+1, N):\n if S[(i-move)%Nj] != S[(j-move)%N][i]:\n return False\n return True\n\n\nif __name__ == \"__main__\":\n solve()", "jacc_sim": 0.975609756097561, "nl": "Snuke has two boards, each with a grid of N rows and N columns. The first board has lowercase English letters in each square, denoted as S(i,j). The second board is initially empty. Snuke will write letters on the second board by choosing two integers A and B (0 \u2264 A, B < N) and writing the letter from the first board's square (i+A, j+B) into the corresponding square (i,j) on the second board. The second board is considered \"good\" if, for every i and j (1 \u2264 i, j \u2264 N), the letter in square (i,j) is equal to the letter in square (j,i). The task is to find the number of ways to choose integers A and B such that the second board is \"good\". The constraints are 1 \u2264 N \u2264 300 and S(i,j) (1 \u2264 i, j \u2264 N) is a lowercase English letter. The input format consists of N followed by the letters in the grid, and the output is the number of ways to choose A and B. Examples of input and output are provided.", "before_after_length": [159, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03365", "p_user": "u729707098", "n_user": "u729707098", "pos": "n = int(input())\nfn,fk,mod = [1]*n,[1]*n,10**9+7\nfor i in range(n-1): fn[i+1] = (fn[i]*(i+2))%mod\ndef power(n,k):\n\tif k==1: return n\n\telif k%2==0: return power((n**2)%mod,k//2)\n\telse: return (n*power(n,k-1))%mod\ndef comb(n,k):\n\tif n v_2d_max:\n v_2d_max = v - x_i*2\n v_sub = msr[n - 2 - i][0]\n v_max = max(v_max, v_2d_max + v_sub)\n return v_max\n\n\nl = solve(sushi, max_sushi_reversed)\nr = solve(sushi_reversed, max_sushi)\nprint(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))\n", "neg": "n, c = map(int, input().split())\nsushi = []\nfor i in range(n):\n x, v = map(int, input().split())\n sushi.append((x, v))\nsushi.sort()\nsushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))\n\n\ndef accum_max(s):\n v = 0\n res = [(0, 0)]\n for x_i, v_i in s:\n v += v_i\n res.append(max(res[-1], (v-x_i, x_i)))\n return res[1:]\n\n\nmax_sushi = accum_max(sushi)\nmax_sushi_reversed = accum_max(sushi_reversed)\n\n\ndef solve(s, msr):\n v_max = 0\n v_2d_max = 0\n v = 0\n n = len(s)\n for i in range(n-1):\n x_i, v_i = s[i]\n v += v_i\n if v - x_i*2 > v_2d_max:\n v_2d_max = v - x_i*2\n v_sub = msr[n - 2 - i][0]\n v_max = max(v_max, v_2d_max + v_sub)\n print(i,v_max,v_2d_max,v_sub)\n return v_max\n\n\nl = solve(sushi, max_sushi_reversed)\nr = solve(sushi_reversed, max_sushi)\nprint(max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0]))\n", "jacc_sim": 1.0, "nl": "Teishi-zushi, a Japanese restaurant, has a single round counter with an outer circumference of C meters. Nakahashi enters the restaurant and is guided to the counter where N pieces of sushi are placed at specific distances x_i and have nutritive values v_i. Nakahashi can walk around the counter, consuming 1 kilocalorie per meter, and eat sushi at specific points. The goal is to find the maximum nutrition he can take in before leaving, considering the energy consumed. Constraints include N (1 \u2264 N \u2264 10^5), C (2 \u2264 C \u2264 10^14), x_i values, and v_i values (1 \u2264 v_i \u2264 10^9). The input format is N C followed by N lines of x_i and v_i. The output should be the maximum nutrition Nakahashi can take in on balance before leaving. Sample inputs and outputs are provided for illustration.", "before_after_length": [425, 446], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03374", "p_user": "u846150137", "n_user": "u846150137", "pos": "n,c= [int(i) for i in input().split()]\nt_tk_r=0\nt_md_r=0\ng_tk_r=0\ng_md_r=0\nt_tk_m=0\nt_md_m=0\ng_tk_m=0\ng_md_m=0\nt_tk=[]\nt_md=[]\ng_tk=[]\ng_md=[]\na=[]\nd1=0\n\nfor i in range(n):\n a.append([int(i) for i in input().split()])\n\nfor d0,v0 in a:\n t_tk_r += v0-(d0-d1)\n t_md_r += v0-(d0-d1)*2\n t_tk_m = max(t_tk_m,t_tk_r)\n t_md_m = max(t_md_m,t_md_r)\n t_tk.append(t_tk_m)\n t_md.append(t_md_m)\n d1=d0\n \nd1=0 \nfor d0,v0 in a[::-1]:\n g_tk_r += v0-((c-d0)-d1)\n g_md_r += v0-((c-d0)-d1)*2\n g_tk_m = max(g_tk_m,g_tk_r)\n g_md_m = max(g_md_m,g_md_r)\n g_tk.append(g_tk_m)\n g_md.append(g_md_m)\n d1=(c-d0) \nmx=max(max(t_tk),max(g_tk),0)\n\nfor i in range(n-1):\n mx=max(mx,t_tk[i]+g_md[n-2-i],t_md[i]+g_tk[n-i-2])\nprint(mx)\n", "neg": "n,c= [int(i) for i in input().split()]\nt_tk_r=0\nt_md_r=0\ng_tk_r=0\ng_md_r=0\nt_tk=[]\nt_md=[]\ng_tk=[]\ng_md=[]\na=[]\nd1=0\nfor i in range(n):\n a.append([int(i) for i in input().split()])\nfor d0,v0 in a:\n t_tk_r+=v0-(d0-d1)\n t_md_r+=v0-(d0-d1)*2\n t_tk.append(t_tk_r)\n t_md.append(t_md_r)\n d1=d0\nd1=0 \nfor d0,v0 in a[::-1]:\n g_tk_r+=v0-(c-d0)-d1\n g_md_r+=v0-((c-d0)-d1)*2\n g_tk.append(g_tk_r)\n g_md.append(g_md_r)\n d1=(c-d0)\nmx=max(max(t_tk),max(g_tk),0)\nfor i in range(1,n):\n print(t_tk[:i],g_md[:n-i])\n mx=max(mx,max(t_tk[:i])+max(g_md[:n-i]),max(t_md[:i])+max(g_tk[:n-i]))\n", "jacc_sim": 0.9069767441860465, "nl": "Teishi-zushi, a Japanese restaurant, has a single round counter with an outer circumference of C meters. Nakahashi enters the restaurant and is guided to the counter where N pieces of sushi are placed at specific distances x_i and have nutritive values v_i. Nakahashi can walk around the counter, consuming 1 kilocalorie per meter, and eat sushi at specific points. The goal is to find the maximum nutrition he can take in before leaving, considering the energy consumed. Constraints include N (1 \u2264 N \u2264 10^5), C (2 \u2264 C \u2264 10^14), x_i values, and v_i values (1 \u2264 v_i \u2264 10^9). The input format is N C followed by N lines of x_i and v_i. The output should be the maximum nutrition Nakahashi can take in on balance before leaving. Sample inputs and outputs are provided for illustration.", "before_after_length": [490, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03374", "p_user": "u792078574", "n_user": "u792078574", "pos": "N, C = map(int, input().split())\nX = []\nV = []\nfor i in range(N):\n x, v = map(int, input().split())\n X.append(x)\n V.append(v)\n\nfrontS = []\n# \u524di\u500b\u306e\u4e2d\u3067\u306e\u7d2f\u8a08MAX\nfrontMaxS = []\nprevX = 0\nv = 0\ntmpMax = float('-inf')\nfor i in range(N):\n v = v + V[i] - (X[i] - prevX)\n frontS.append(v)\n tmpMax = max(tmpMax, v)\n frontMaxS.append(tmpMax)\n prevX= X[i]\nfrontMaxS.reverse()\nfrontMaxS.append(0)\n\nbackS = []\n# \u5f8c\u308di\u500b\u306e\u4e2d\u3067\u306e\u7d2f\u8a08MAX\nbackMaxS = []\nprevX = C\nv = 0\ntmpMax = float('-inf')\nfor i in range(N-1, -1, -1):\n v = v + V[i] - (prevX - X[i])\n backS.append(v)\n tmpMax = max(tmpMax, v)\n backMaxS.append(tmpMax)\n prevX = X[i]\nbackMaxS.reverse()\nbackMaxS.append(0)\n\nans = max(0, backMaxS[0], frontMaxS[0])\nfor i in range(N):\n # X\u500b\u307e\u3067\u98df\u3079\u3066\u3001\u9000\u51fa or \u5f15\u304d\u8fd4\u3059\n ans = max(\n ans,\n frontS[i],\n frontS[i] - X[i] + backMaxS[i+1],\n backS[i],\n backS[i] - (C-X[-i-1]) + frontMaxS[i+1]\n )\n\nprint(ans)", "neg": "N, C = map(int, input().split())\nX = []\nV = []\nfor i in range(N):\n x, v = map(int, input().split())\n X.append(x)\n V.append(v)\n\nfrontS = []\nprevX = 0\nv = 0\nfor i in range(N):\n v = v + V[i] - (X[i] - prevX)\n frontS.append(v)\n prevX= X[i]\n\n# \u5f8c\u308di\u500b\u306e\u4e2d\u3067\u306e\u7d2f\u8a08MAX\nbackMaxS = []\nprevX = C\nv = 0\ntmpMax = float('-inf')\nfor i in range(N-1, -1, -1):\n v = v + V[i] - (prevX - X[i])\n tmpMax = max(tmpMax, v)\n backMaxS.append(tmpMax)\n prevX = X[i]\nbackMaxS.reverse()\nbackMaxS.append(0)\n\nans = backMaxS[0]\nfor i in range(N):\n # X\u500b\u307e\u3067\u98df\u3079\u3066\u3001\u9000\u51fa or \u5f15\u304d\u8fd4\u3059\n ans = max(\n ans,\n frontS[i],\n frontS[i] - X[i] + backMaxS[i+1]\n )\n\nprint(ans)", "jacc_sim": 0.9841269841269841, "nl": "Teishi-zushi, a Japanese restaurant, has a single round counter with an outer circumference of C meters. Nakahashi enters the restaurant and is guided to the counter where N pieces of sushi are placed at specific distances x_i and have nutritive values v_i. Nakahashi can walk around the counter, consuming 1 kilocalorie per meter, and eat sushi at specific points. The goal is to find the maximum nutrition he can take in before leaving, considering the energy consumed. Constraints include N (1 \u2264 N \u2264 10^5), C (2 \u2264 C \u2264 10^14), x_i values, and v_i values (1 \u2264 v_i \u2264 10^9). The input format is N C followed by N lines of x_i and v_i. The output should be the maximum nutrition Nakahashi can take in on balance before leaving. Sample inputs and outputs are provided for illustration.", "before_after_length": [509, 369], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03374", "p_user": "u340781749", "n_user": "u340781749", "pos": "import numpy as np\n\n\ndef get_max():\n a = 0\n\n def _max(x):\n nonlocal a\n a = max(a, x)\n return a\n\n return _max\n\n\ndef solve(fwd, bck):\n dp = []\n cur = 0\n for x, v in fwd:\n cur -= x\n cur += v\n dp.append(cur)\n\n dp = list(map(get_max(), dp))\n\n cur = 0\n ans = dp[-1]\n for i, (x, v) in enumerate(bck[:-1]):\n cur -= 2 * x\n cur += v\n # print(i, x, v, ans, cur, dp[n - i - 2])\n ans = max(ans, dp[n - i - 2] + cur)\n # print(i, x, v, ans, cur, dp[n - i - 2])\n\n return ans\n\n\nn, c = map(int, input().split())\nsushi = [list(map(int, input().split())) for _ in range(n)]\n\nfwd = np.array(sushi).T\nfwd[0] = np.diff(np.concatenate(([0], fwd[0])))\nfwd = fwd.T.tolist()\n\nbck = np.array(sushi).T\nbck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))\nbck[1] = bck[1][::-1]\nbck = bck.T.tolist()\n\n# print(fwd)\n# print(bck)\n\nprint(max(solve(fwd, bck), solve(bck, fwd)))\n", "neg": "from functools import reduce\n\nimport numpy as np\n\n\ndef get_max():\n a = 0\n\n def _max(x):\n nonlocal a\n a = max(a, x)\n return a\n\n return _max\n\n\ndef solve(fwd, bck):\n dp = []\n cur = 0\n for x, v in fwd:\n cur -= x\n cur += v\n dp.append(cur)\n\n dp = list(map(get_max(), dp))\n\n cur = 0\n ans = 0\n for i, (x, v) in enumerate(bck[:-1]):\n cur -= 2 * x\n cur += v\n # print(i, x, v, ans, cur, dp[n - i - 2])\n ans = max(ans, dp[n - i - 2] + cur)\n # print(i, x, v, ans, cur, dp[n - i - 2])\n\n return ans\n\n\nn, c = map(int, input().split())\nsushi = [list(map(int, input().split())) for _ in range(n)]\n\nfwd = np.array(sushi).T\nfwd[0] = np.diff(np.concatenate(([0], fwd[0])))\nfwd = fwd.T.tolist()\n\nbck = np.array(sushi).T\nbck[0] = np.diff(np.concatenate(([0], (c - bck[0])[::-1])))\nbck[1] = bck[1][::-1]\nbck = bck.T.tolist()\n\nprint(max(solve(fwd, bck), solve(bck, fwd)))\n", "jacc_sim": 0.9482758620689655, "nl": "Teishi-zushi, a Japanese restaurant, has a single round counter with an outer circumference of C meters. Nakahashi enters the restaurant and is guided to the counter where N pieces of sushi are placed at specific distances x_i and have nutritive values v_i. Nakahashi can walk around the counter, consuming 1 kilocalorie per meter, and eat sushi at specific points. The goal is to find the maximum nutrition he can take in before leaving, considering the energy consumed. Constraints include N (1 \u2264 N \u2264 10^5), C (2 \u2264 C \u2264 10^14), x_i values, and v_i values (1 \u2264 v_i \u2264 10^9). The input format is N C followed by N lines of x_i and v_i. The output should be the maximum nutrition Nakahashi can take in on balance before leaving. Sample inputs and outputs are provided for illustration.", "before_after_length": [427, 416], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u835482198", "n_user": "u835482198", "pos": "n = int(input())\nx = list(map(int, input().split()))\nsorted_x = sorted(x)\n\nif sorted_x[n // 2] == sorted_x[n // 2 - 1]:\n ret = [sorted_x[n // 2]] * n\nelse:\n ret = []\n for i in range(n):\n if x[i] >= sorted_x[n // 2]:\n ret.append(sorted_x[n // 2 - 1])\n else:\n ret.append(sorted_x[n // 2])\nfor i in ret:\n print(i)\n", "neg": "n = int(input())\nx = list(map(int, input().split()))\nsorted_x = sorted(x)\n\nif sorted_x[n // 2] == sorted_x[n // 2 - 1]:\n print(' '.join([sorted_x[n // 2] * n]))\nelse:\n ret = []\n for i in range(n):\n if x[i] >= sorted_x[n // 2]:\n ret.append(sorted_x[n // 2])\n else:\n ret.append(sorted_x[n // 2 - 1])\n print(' '.join(ret))\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [146, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u404459933", "n_user": "u404459933", "pos": "def find(A):\n X=[(A[i],i) for i in range(len(A))]\n X=sorted(X)\n ans=[0]*len(X)\n p1=(len(A)-1)//2\n p2=len(A)//2\n #print(p1,p2)\n for i in range(len(X)):\n a,b=X[i]\n if i 2:\n for i in range(int(N/2)):\n print(sorted_a[int(N/2)])\n for i in range(int(N/2)):\n print(sorted_a[int(N/2)-1])\nelse:\n print(a[0])\n", "jacc_sim": 0.90625, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [97, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u476199965", "n_user": "u476199965", "pos": "n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n//2-1]\nr = y[n//2]\nfor i in range(n):\n if x[i] <= l:print(r)\n else:print(l)\n", "neg": "n = list(map(int,input().split()))\nx = list(map(int,input().split()))\ny = sorted(x)\nl = y[n/2-2]\nr = y[n/2-1]\nfor i in range(n):\n if x[I] <= l:print(r)\n else:print(l)", "jacc_sim": 0.96875, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [78, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u092650292", "n_user": "u092650292", "pos": "from numpy import median\nfrom copy import deepcopy\n\nn = int(input())\nx = list(map(int,input().split()))\n\nsx = sorted(x)\nnewl = deepcopy(sx)\ndel newl[0]\nmaxm = median(newl)\nnewl = deepcopy(sx)\ndel newl[-1]\nminm = median(newl)\n\nmed = median(x)\n\nfor i in x:\n if i > med:\n print(int(minm))\n else:\n print(int(maxm))\n", "neg": "from numpy import median\nfrom copy import deepcopy\n\nn = int(input())\nx = list(map(int,input().split()))\n\nsx = x.sorted()\nnewl = deepcopy(sx)\ndel newl[0]\nbigm = median(newl)\nnewl = deepcopy(sx)\ndel newl[-1]\nminm = median(newl)\n\nmed = median(x)\n\nfor i in x:\n if i > med:\n print(minm)\n else:\n print(maxm)\n", "jacc_sim": 0.9743589743589743, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [132, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u399810298", "n_user": "u399810298", "pos": "N=int(input())\ninp=list(map(int, input().strip().split(' ')))\nXsort=sorted(inp)\nmed = int(N/2)\nfor i in range(N):\n if Xsort[med-1] >= inp[i] :\n print(Xsort[med])\n else:\n print(Xsort[med-1])", "neg": "N=int(input())\ninp=list(map(int, input().strip().split(' ')))\nXsort=sorted(inp)\nmed = int(N/2)\nfor i in range(N):\n if Xsort[med-1] > inp[i]:\n print(Xsort[med])\n else:\n print(Xsort[med-1])", "jacc_sim": 1.0, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [88, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u547085427", "n_user": "u547085427", "pos": "N = int(input())\nN_d = int(N/2)\nX1 = list(map(int,input().split()))\nX = X1[:]\nX1.sort()\n\ndef getMed(i):\n if i < X1[N_d]:\n print(X1[N_d])\n else:\n print( X1[N_d -1])\n\nfor i in X:\n getMed(i)", "neg": "N = int(input())\nN_d = int(N/2)\nX1 = list(map(int,input().split()))\nX = X1[:]\nX1.sort()\n\ndef getMed(i):\n if i < X[N_d]:\n print(X[N_d])\n else:\n print( X[N_d -1])\n\nfor i in X:\n getMed(i)\n ", "jacc_sim": 1.0, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [108, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u411158173", "n_user": "u411158173", "pos": "import copy\n\nN = int(input())\nX = []\nX = [int(i) for i in input().split()]\n\nY = copy.deepcopy(X)\nY.sort()\n\nlargeMedian = Y[int(N / 2)]\nsmallMedian = Y[int(N / 2)-1]\n\nfor i in range(N):\n if X[i] <= smallMedian:\n X[i] = largeMedian\n else:\n X[i] = smallMedian\n\nfor i in range(N):\n print(X[i])\n", "neg": "import copy\n\nN = int(input())\nX = []\nX = [int(i) for i in input().split()]\n\nY = copy.deepcopy(X)\nY.sort()\n\nlargeMedian = Y[int(N / 2)]\nsmallMedian = Y[int(N / 2)-1]\n\n\nprint(X)\nprint(Y)\nprint(smallMedian)\nprint(largeMedian)\n\nfor i in range(N):\n if X[i] <= smallMedian:\n X[i] = largeMedian\n else:\n X[i] = smallMedian\n\nfor i in range(N):\n print(X[i], end=' ')\n", "jacc_sim": 0.9142857142857143, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [138, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u657541767", "n_user": "u657541767", "pos": "n = int(input())\nx = [int(a) for a in input().split()]\nsorted_x = sorted(x)\nfor elem in x:\n if elem >= sorted_x[(len(x) + 1) // 2]:\n print(sorted_x[(len(x) + 1) // 2 - 1])\n else:\n print(sorted_x[(len(x) + 1) // 2])\n ", "neg": "n = int(input())\nx = [int(a) for a in input().split()]\nsorted_x = sorted(x)\nprint(x)\nprint(sorted_x)\nfor elem in x:\n if elem >= sorted_x[(len(x) + 1) // 2]:\n print(sorted_x[(len(x) + 1) // 2 - 1])\n else:\n print(sorted_x[(len(x) + 1) // 2])\n ", "jacc_sim": 1.0, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [103, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u966000628", "n_user": "u966000628", "pos": "n = int(input())\ncn = n//2\nlis = list(map(int,input().split()))\nslis = sorted(lis)\nif slis[cn-1] == slis[cn]:\n\tfor i in range(len(lis)):\n\t\tprint(slis[cn])\nelse:\n\tfor item in lis:\n\t\tif item >= slis[cn]:\n\t\t\tprint(slis[cn-1])\n\t\telse:\n\t\t\tprint(slis[cn])", "neg": "n = int(input())\ncn = n//2\nlis = list(map(int,input().split()))\nslis = sorted(lis)\nif slis[cn-1] == slis[cn]:\n\tprint(slis[cn])\nelse:\n\tfor item in lis:\n\t\tif item >= slis[cn]:\n\t\t\tprint(slis[cn-1])\n\t\telse:\n\t\t\tprint(slis[cn])", "jacc_sim": 0.90625, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [123, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u459737327", "n_user": "u459737327", "pos": "n = int(input())\na = sorted(zip(map(int, input().split()), range(n)))\nb = [0] * n\nfor i in range(n//2):\n b[i], b[n - i - 1] = (a[n//2][0], a[i][1]), (a[n//2 - 1][0], a[n - i - 1][1])\nprint('\\n'.join(map(lambda x: str(x[0]), sorted(b, key = lambda x: x[1]))))\n", "neg": "n = int(input())\na = sorted(zip(map(int, input().split()), range(n)))\nfor i in range(n//2):\n a[i] = a[n//2 - 1]\n a[i + n//2] = a[n//2]\nprint('\\n'.join(map(lambda x: str(x[0]), sorted(a, key = lambda x: x[1]))))\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [131, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u228759454", "n_user": "u228759454", "pos": "import numpy as np\n\nN = int(input())\nn_list1 = list(map(int, input().split()))\n\nn_list2 = list(n_list1)\nn_list_test = list(n_list1)\n\n\nn_list_max = np.max(n_list1)\nn_list_min = np.min(n_list2)\n\nn_list1.remove(n_list_max)\nn_list2.remove(n_list_min)\n\n# print(np.max(n_list))\n# np.median(n_list - )\nn_list1_median = int(np.median(n_list1))\nn_list2_median = int(np.median(n_list2))\n\nfor x in n_list_test:\n if n_list1_median >= x:\n print(n_list2_median)\n else:\n print(n_list1_median)\n \n \n\n", "neg": "import numpy as np\n\nN = int(input())\nn_list1 = list(map(int, input().split()))\n\nn_list2 = list(n_list1)\nn_list_test = list(n_list1)\n\nprint(n_list_test)\n\nn_list_max = np.max(n_list1)\nn_list_min = np.min(n_list2)\n\nn_list1.remove(n_list_max)\nn_list2.remove(n_list_min)\n\n# print(np.max(n_list))\n# np.median(n_list - )\nn_list1_median = int(np.median(n_list1))\nn_list2_median = int(np.median(n_list2))\n\nprint(n_list1_median)\nprint(n_list2_median)\n\nfor x in n_list_test:\n if n_list1_median >= x:\n print(n_list2_median)\n else:\n print(n_list1_median)\n \n \n\n", "jacc_sim": 1.0, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [236, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u584749014", "n_user": "u584749014", "pos": "n = int(input())\nl0 = list(map(int, input().split()))\nl = sorted(l0)\n\nm1 = l[n//2 - 1]\nm2 = l[n//2]\nfor i in range(len(l0)):\n if l0[i] < m2:\n print(m2)\n elif l0[i] > m1:\n print(m1)\n elif l0[i] == m1:\n print(m2)\n elif l0[i] == m2:\n print(m1)", "neg": "n = int(input())\nl0 = list(map(int, input().split()))\nl = sorted(l0)\n\nm1 = l[n//2 - 1]\nm2 = l[n//2]\nfor i in range(len(l0)):\n if l0[i] <= m2:\n print(m2)\n if l0[i] > m1:\n print(m1)\n", "jacc_sim": 0.9696969696969697, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [140, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03381", "p_user": "u257374434", "n_user": "u112002050", "pos": "N = int(input(\n))\nX = list(map(int,input().split()))\n\nX_sorted = sorted(X)\n\nfor i in range(N):\n x = X[i]\n if x < X_sorted[N//2]:\n print(X_sorted[N//2])\n else:\n print(X_sorted[N//2-1])\n", "neg": "N = int(input())\nx = sorted(list(map(int, input().split())))\nfor i in range(N):\n if i <= N // 2 - 1:\n print(x[N//2])\n else:\n print(x[N//2-1])\n", "jacc_sim": 0.9333333333333333, "nl": "You are given a set of N numbers, where N is even. For each i from 1 to N, find the median of the set excluding Xi. The median of a set of numbers is the middle value when the numbers are ordered. The input is given in the format N followed by X1 to XN. Output N lines, where each line contains the median Bi. The constraints are 2 \u2264 N \u2264 200,000, N is even, 1 \u2264 Xi \u2264 10^9, and all input values are integers.", "before_after_length": [93, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03383", "p_user": "u905582793", "n_user": "u905582793", "pos": "from collections import Counter\nn,m = map(int,input().split())\ngrid = [list(input()) for i in range(n)]\ndef jc(a,b):\n l = len(a)\n used = [0]*l\n for i in range(l):\n if used[i]:\n continue\n for j in range(i+1,l):\n if used[j]:\n continue\n if a[i] == b[j] and b[i] == a[j]:\n used[i] = 1\n used[j] = 1\n break\n if used.count(0) <= l%2:\n return True\n else:\n return False\ndef judge(a):\n h = len(a)\n w = len(a[0])\n used = [0]*h\n for i in range(h):\n if used[i]:\n continue\n ci = Counter(a[i])\n for j in range(i+1,h):\n if used[j]:\n continue\n cj = Counter(a[j])\n if ci == cj:\n if jc(a[i],a[j]):\n used[i] = 1\n used[j] = 1\n break\n if used.count(0) <= h%2:\n return True\n else:\n return False\ngt = list(zip(*grid))\nif judge(grid) & judge(gt):\n print(\"YES\")\nelse:\n print(\"NO\")", "neg": "from collections import Counter\nn,m = map(int,input().split())\ngrid = [list(input()) for i in range(n)]\ndef jc(a,b):\n l = len(a)\n used = [0]*l\n for i in range(l):\n if used[i]:\n continue\n for j in range(i,l):\n if used[j]:\n continue\n if a[i] == b[j] and b[i] == a[j]:\n used[i] = 1\n used[j] = 1\n break\n if used.count(1) == l:\n return True\n else:\n return False\ndef judge(a):\n h = len(a)\n w = len(a[0])\n if h%2 == 0:\n flg = 1\n else:\n flg = 2\n used = [0]*h\n for i in range(h):\n if used[i]:\n continue\n ci = Counter(a[i])\n for j in range(i+1,h):\n if used[j]:\n continue\n cj = Counter(a[j])\n if ci == cj:\n if jc(a[i],a[j]):\n used[i] = 1\n used[j] = 1\n break\n if used.count(0) < flg:\n return True\n else:\n return False\ngt = list(zip(*grid))\nif n == 3:\n print(2/0)\nif judge(grid) & judge(gt):\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 0.9523809523809523, "nl": "You are given an H x W grid with lowercase English letters. You can swap rows or columns any number of times. Determine if the grid can be made symmetric, where the letters in each square and its symmetric counterpart are equal. Constraints: 1 \u2264 H, W \u2264 12, |S_i| = W, and S_i consists of lowercase English letters. Input format: H, W, followed by S_1 to S_H. Output \"YES\" if the grid can be made symmetric, \"NO\" otherwise.", "before_after_length": [363, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03383", "p_user": "u236127431", "n_user": "u236127431", "pos": "H,W=map(int,input().split())\nG=[list(input()) for i in range(H)]\nG_t=[list(x) for x in list(zip(*G))]\ndef Check(G,H,W):\n Paired_y=[False]*H\n for y1 in range(H):\n if Paired_y[y1]:\n continue\n for y2 in range(H):\n if y1==y2 or Paired_y[y2]:\n continue\n Paired_x=[False]*W\n for x1 in range(W):\n if Paired_x[x1]:\n continue\n for x2 in range(W):\n if x1==x2 or Paired_x[x2]:\n continue\n if G[y1][x1]==G[y2][x2] and G[y1][x2]==G[y2][x1]:\n Paired_x[x1]=True\n Paired_x[x2]=True\n break\n if W%2==1:\n if Paired_x.count(False)==1:\n r=Paired_x.index(False)\n if G[y1][r]==G[y2][r]:\n Paired_y[y1]=True\n Paired_y[y2]=True\n break\n else:\n if Paired_x.count(False)==0:\n Paired_y[y1]=True\n Paired_y[y2]=True\n break\n if H%2==1:\n if Paired_y.count(False)==1:\n return True\n else:\n return False\n else:\n if Paired_y.count(False)==0:\n return True\n else:\n return False\n \nif Check(G,H,W) and Check(G_t,W,H):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n \n \n \n \n \n", "neg": "H,W=map(int,input().split())\nG=[list(input()) for i in range(H)]\nG_t=[list(x) for x in list(zip(*G))]\nPaired_y=[False]*H\ndef Check(G,H,W):\n for y1 in range(H):\n if Paired_y[y1]:\n continue\n for y2 in range(H):\n if y1==y2 or Paired_y[y2]:\n continue\n Paired_x=[False]*W\n for x1 in range(W):\n if Paired_x[x1]:\n continue\n for x2 in range(W):\n if x1==x2 or Paired_x[x2]:\n continue\n if G[y1][x1]==G[y2][x2] and G[y1][x2]==G[y2][x1]:\n Paired_x[x1]=True\n Paired_x[x2]=True\n break\n if W%2==1:\n if Paired_x.count(False)==1:\n Paired_y[y1]=True\n Paired_y[y2]=True\n else:\n if Paired_x.count(False)==0:\n Paired_y[y1]=True\n Paired_y[y2]=True\n if H%2==1:\n if Paired_y.count(False)==1:\n return True\n else:\n return False\n else:\n if Paired_y.count(False)==0:\n return True\n else:\n return False\n \nif Check(G,H,W) and Check(G_t,W,H):\n print(\"YES\")\nelse:\n print(\"NO\")\n\n \n \n \n \n \n \n", "jacc_sim": 0.9615384615384616, "nl": "You are given an H x W grid with lowercase English letters. You can swap rows or columns any number of times. Determine if the grid can be made symmetric, where the letters in each square and its symmetric counterpart are equal. Constraints: 1 \u2264 H, W \u2264 12, |S_i| = W, and S_i consists of lowercase English letters. Input format: H, W, followed by S_1 to S_H. Output \"YES\" if the grid can be made symmetric, \"NO\" otherwise.", "before_after_length": [495, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u572142121", "n_user": "u572142121", "pos": "N=int(input())\nd=0\ns=10**9+1\nfor i in range(N):\n a,b=map(int, input().split())\n d+=a\n if a>b:\n s=min(s,b)\nif s==10**9+1:\n print(0)\n exit()\nprint(d-s)", "neg": "N=int(input())\nd=0\ns=10**9+1\nfor i in range(N):\n a,b=map(int, input().split())\n d+=a\n if a>b:\n s=min(s,b)\nprint(d-s)", "jacc_sim": 0.967741935483871, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [90, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u102445737", "n_user": "u102445737", "pos": "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nn = inn()\na = []\nb = []\nxb = 10**9+1\nfor i in range(n):\n aa,bb = inm()\n a.append(aa)\n b.append(bb)\n if aa>bb and xb>bb:\n xb = bb\n xi = i\nif n==-2 and a[0]==1:\n 3/0\nprint(0 if xb>10**9 else sum(a)-b[xi])\n", "neg": "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nn = inn()\na = []\nb = []\nxb = 10**9+1\nfor i in range(n):\n aa,bb = inm()\n a.append(aa)\n b.append(bb)\n if aa>bb and xb>bb:\n xb = bb\n xi = i\nif n==2 and a[0]==1:\n 3/0\nprint(0 if xb>10**9 else sum(a)-b[xi])\n", "jacc_sim": 1.0, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [243, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u674959776", "n_user": "u674959776", "pos": "n=int(input())\nINF=10**9+7\nsum=0\nm=INF\nfor i in range(n):\n a,b=map(int,input().split())\n sum+=a\n if a>b:\n m=min(m,b)\nif m==INF:\n print(0)\nelse:\n print(sum-m)", "neg": "n=int(input())\nINF=10**9+7\nsum=0\nm=INF\nfor i in range(n):\n a,b=map(int,input().split())\n sum+=a\n if a>b:\n m=min(m,b)\nprint(sum-m)", "jacc_sim": 0.96875, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [90, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u623687794", "n_user": "u623687794", "pos": "n=int(input())\nrem=10**10\nS=0\nallissame=0\nfor i in range(n):\n a,b=map(int,input().split())\n S+=a\n if ab:\n if rem > b:\n rem=b\n allissame|=1\n else:pass\nif not allissame:\n print(0)\nelse:\n print(S-rem)\n", "neg": "n=int(input())\nrem=0\nS=0\nallissame=0\nfor i in range(n):\n a,b=map(int,input().split())\n S+=a\n if ab:\n if rem > b:\n rem=b\n allissame|=1\n else:pass\nif not allissame:\n print(0)\nelse:\n print(S-rem)\n", "jacc_sim": 0.9444444444444444, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [125, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\nres = 0\nf = 1\nt = 10 ** 10\nfor _ in range(N):\n x, y = map(int, input().split())\n if x != y: f = 0\n if x > y:\n t = min(t, y)\n res += y\nif f:\n print(0)\n exit(0)\n\nprint(res - t)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\nres = 0\nt = 10 ** 10\nfor _ in range(N):\n x, y = map(int, input().split())\n if x != y: f = 0\n if x > y:\n t = min(t, y)\n res += y\nif f:\n print(0)\n exit(0)\n\nprint(res - t)", "jacc_sim": 0.9722222222222222, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [110, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u392319141", "n_user": "u392319141", "pos": "N = int(input())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\nif(A == B):\n print(0)\n exit()\n\nans = sum(A)\ndis = 10**10\nfor a, b in zip(A, B):\n if a > b:\n dis = min(dis, b)\nprint(ans - dis)\n", "neg": "N = int(input())\nA = []\nB = []\nfor _ in range(N):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\nif(A == B):\n print(1)\n exit()\n\nans = sum(A)\ndis = 10**10\nfor a, b in zip(A, B):\n if a > b:\n dis = min(dis, b)\nprint(ans - dis)\n", "jacc_sim": 0.9444444444444444, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [121, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u543954314", "n_user": "u543954314", "pos": "n,*l = map(int,open(0).read().split())\na = l[::2]\nb = l[1::2]\nprint(0 if a==b else sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))\n", "neg": "n,*l = map(int,open(0).read().split())\na = l[::2]\nb = l[1::2]\nprint(sum(a) - min(b[i] for i in range(n) if b[i] < a[i]))", "jacc_sim": 0.96875, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [72, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\niptls = [list(map(int,input().split())) for i in range(n)]\na,b = zip(*iptls)\nif a == b:\n print(0)\n exit()\nans = 10**18\nfor i in range(n):\n if a[i]>b[i]:\n ans = min(ans,b[i])\nprint(sum(b)-ans)", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\niptls = [list(map(int,input().split())) for i in range(n)]\na,b = zip(*iptls)\nif a == b:\n print(0)\n exit()\nans = 10**18\nfor i in range(n):\n if a[i]<=b[i]:\n ans = min(ans,b[i])\nprint(sum(b)-ans)", "jacc_sim": 0.9487179487179487, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [114, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u754022296", "n_user": "u754022296", "pos": "n = int(input())\ns = 0\nminb = float(\"inf\")\nf = False\nfor _ in range(n):\n a, b = map(int, input().split())\n if a > b:\n f = True\n minb = min(b, minb)\n s += a\nif f:\n print(s - minb)\nelse:\n print(0)", "neg": "n = int(input())\ns = 0\nminb = float(\"inf\")\nfor _ in range(n):\n a, b = map(int, input().split())\n if a > b:\n minb = min(b, minb)\n s += a\nif b == float(\"inf\"):\n print(s - minb)\nelse:\n print(0)", "jacc_sim": 0.9090909090909091, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [95, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\nres = 0\nt = float(\"inf\")\nc = 0\nfor _ in range(N):\n x, y = map(int, input().split())\n if x > y: t = min(y, t)\n if x == y: c += 1\n res += x\nif c == N:\n print(0)\n exit(0)\nprint(res - t)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\nres = 0\nt = float(\"inf\")\nfor _ in range(N):\n x, y = map(int, input().split())\n if x > y: t = min(y, t)\n res += x\nprint(res - t)", "jacc_sim": 0.9166666666666666, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [110, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u729133443", "n_user": "u729133443", "pos": "_,*t=open(0).read().split()\nt=map(int,t)\ns=0\nm=1e18\nfor a,b in zip(t,t):\n s+=a\n if a>b:m=min(m,b)\nprint(max(0,s-m))", "neg": "_,*t=open(0).read().split()\nt=map(int,t)\ns=0\nm=9e9\nfor a,b in zip(t,t):\n s+=a\n if a>b:m=min(m,b)\nprint(s-m)", "jacc_sim": 0.9032258064516129, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [74, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u692632484", "n_user": "u692632484", "pos": "N=int(input())\nab=[[int(i) for i in input().split()] for j in range(N)]\ntotal = sum([sum(row) for row in ab])//2\ndiff = [row[1] for row in ab if row[0]>row[1]]\nif len(diff)==0:\n print(0)\nelse:\n print(total-min(diff))\n", "neg": "N=int(input())\nab=[[int(i) for i in input().split()] for j in range(N)]\ntotal = sum([sum(row) for row in ab])//2\ndiff = [row[1] for row in ab if row[0]>row[1]]\nif len(diff)==0:\n print(0)\nelse:\n print(total-diff)\n", "jacc_sim": 0.96875, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [96, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u608088992", "n_user": "u608088992", "pos": "import sys, math, collections, heapq, itertools\nF = sys.stdin\ndef single_input(): return F.readline().strip(\"\\n\")\ndef line_input(): return F.readline().strip(\"\\n\").split()\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n while a % b > 0: a, b = b, a % b\n return b\n \ndef solve():\n N = int(single_input())\n sum = 0\n smallestB = 10 ** 20\n for i in range(N):\n a, b = map(int, line_input())\n sum += a\n if a > b: smallestB = min(smallestB, b)\n print(max(0, sum - smallestB))\n return 0\n \nif __name__ == \"__main__\":\n solve()", "neg": "import sys, math, collections, heapq, itertools\nF = sys.stdin\ndef single_input(): return F.readline().strip(\"\\n\")\ndef line_input(): return F.readline().strip(\"\\n\").split()\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n while a % b > 0: a, b = b, a % b\n return b\n \ndef solve():\n N = int(single_input())\n sum = 0\n smallestB = 10 ** 10\n for i in range(N):\n a, b = map(int, line_input())\n sum += a\n if a > b: smallestB = min(smallestB, b)\n print(sum - smallestB)\n return 0\n \nif __name__ == \"__main__\":\n solve()", "jacc_sim": 0.9811320754716981, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [207, 203], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u186426563", "n_user": "u186426563", "pos": "n = int(input())\na, b, c = [], [], []\nfor i in range(n):\n ab = list(map(int, input().split()))\n a.append(ab[0])\n b.append(ab[1])\n if(ab[0] > ab[1]):\n c.append(ab[1])\nif(len(c) == 0):\n print(0)\nelse:\n print(sum(a) - min(c))", "neg": "n = int(input())\na, b, c = [], [], []\nfor i in range(n):\n ab = list(map(int, input().split()))\n a.append(ab[0])\n b.append(ab[1])\n if(ab[0] > ab[1]):\n c.append(ab[1])\nif(len(c) == 0):\n print(0)\nelse:\n sort.c()\n print(sum(a) - c[0])", "jacc_sim": 0.9411764705882353, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [117, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u876442898", "n_user": "u876442898", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nContents : AtCoder Regular Contest094 e\u554f\u984c \u672a\u5b8c\u6210\nAuthor : Kitaura Hiromi\nLastUpdate : 20180420\nSince : 20180414\n\"\"\"\ninf = 10**20\n# \u6700\u7d42\u7684\u306b, 1\u7d44\u4ee5\u5916\u306f\u3059\u3079\u30660\u306b\u306a\u308b\nN = int(input())\ns = 0\nm = inf\nfor i in range(N):\n a, b = map(int, input().split(\" \"))\n if a > b:\n if m > b:\n m = b\n s += a\nif m == inf:\n print(0)\nelse:\n print(s - m)", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nContents : AtCoder Regular Contest094 e\u554f\u984c \u672a\u5b8c\u6210\nAuthor : Kitaura Hiromi\nLastUpdate : 20180420\nSince : 20180414\n\"\"\"\ninf = 10**20\n# \u6700\u7d42\u7684\u306b, 1\u7d44\u4ee5\u5916\u306f\u3059\u3079\u30660\u306b\u306a\u308b\nN = int(input())\ns = 0\nm = inf\nfor i in range(N):\n a, b = map(int, input().split(\" \"))\n if a > b:\n if m < b:\n m = b\n s += a\nif m == inf:\n print(0)\nelse:\n print(s - m)", "jacc_sim": 0.9855072463768116, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [210, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03391", "p_user": "u226155577", "n_user": "u226155577", "pos": "N = int(input())\nans = 0\nm = INF = 10**9+7\nd = []\nfor i in range(N):\n a, b = map(int, input().split())\n ans += a\n if a > b:\n m = min(m, b)\nprint(0 if INF == m else ans-m)", "neg": "N = int(input())\nans = 0\nm = 10**9+7\nd = []\nfor i in range(N):\n a, b = map(int, input().split())\n ans += a\n if a > b:\n m = min(m, b)\nprint(ans-m)", "jacc_sim": 0.9428571428571428, "nl": "You are given two sequences, A and B, each consisting of non-negative integers. Both A and B have lengths of N, and the sums of their elements are equal. Tozan and Gezan repeat a sequence of operations: if A and B are equal, the process terminates. Otherwise, Tozan chooses a positive element in A and decreases it by 1, then Gezan does the same with a positive element in B. They then give one candy to Takahashi, their pet. Tozan wants to maximize the candies given, while Gezan wants to minimize them. Find the number of candies given when both perform optimally. Constraints: 1 \u2264 N \u2264 2 \u00d7 10^5, 0 \u2264 A_i, B_i \u2264 10^9 (1 \u2264 i \u2264 N), and the sums of A and B are equal. Input is given as N followed by A_1 B_1 ... A_N B_N. Output the number of candies given to Takahashi.", "before_after_length": [81, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03395", "p_user": "u794173881", "n_user": "u794173881", "pos": "def solve(bit_state, num, mod):\n for div in range(1, num + 1):\n if num % div == mod:\n cand[i].append(bit_state | (1 << div))\n if num % div > mod:\n solve(bit_state | (1 << div), num % div, mod)\n\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ncand = [[] for i in range(n)]\nfor i in range(n):\n solve(0, a[i], b[i])\n if a[i] == b[i]:\n cand[i].append(0)\n\nans = 0\nwhile True:\n max_ = 0\n for j in range(n):\n min_ = 10 ** 5\n for num in cand[j]:\n min_ = min(min_, num.bit_length() - 1)\n max_ = max(max_, min_)\n\n if max_ == 0:\n print(ans)\n break\n if max_ == 10 ** 5:\n print(-1)\n break\n ans += 2 ** max_\n \n tmp = [[] for i in range(n)]\n for j in range(n):\n for num in cand[j]:\n if num & (1 << max_):\n tmp[j].append(num - (1 << max_))\n else:\n tmp[j].append(num)\n cand = tmp[0:]\n ", "neg": "def solve(bit_state, num, mod):\n for div in range(1, num + 1):\n if num % div == mod:\n cand[i].append(bit_state | (1 << div))\n if num % div > mod:\n solve(bit_state | (1 << div), num % div, mod)\n\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ncand = [[] for i in range(n)]\nfor i in range(n):\n solve(0, a[i], b[i])\n\nans = 0\nfor i in range(50):\n max_ = 0\n for j in range(n):\n min_ = 10 ** 5\n for num in cand[j]:\n min_ = min(min_, num.bit_length() - 1)\n max_ = max(max_, min_)\n\n if max_ == 0:\n print(ans)\n break\n if max_ == 10 ** 5:\n print(-1)\n break\n ans += 2 ** max_\n \n tmp = [[] for i in range(n)]\n for j in range(n):\n for num in cand[j]:\n if num & (1 << max_):\n tmp[j].append(num - (1 << max_))\n else:\n tmp[j].append(num)\n cand = tmp[0:]\n ", "jacc_sim": 0.9464285714285714, "nl": "Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every second, he performs the following operation: Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this operation is 2^{k} (regardless of how many elements he changes). Aoki wants to turn the sequence into b_{1}, b_{2}, ..., b_{N} (the order of the elements is important). Determine if it is possible for Aoki to perform this task and if yes, find the minimum cost required.\n\nConstraints:\n1 \u2264 N \u2264 50\n0 \u2264 a_{i}, b_{i} \u2264 50\nAll values in the input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_{1} a_{2} ... a_{N}\nb_{1} b_{2} ... b_{N}\n\nOutput:\nPrint the minimum cost required to turn the original sequence into b_{1}, b_{2}, ..., b_{N}. If the task is impossible, output -1 instead.\n\nSample Input 1:\n3\n19 10 14\n0 3 4\n\nSample Output 1:\n160\nHere's a possible sequence of operations:\nChoose k = 7. Replace 19 with 5, 10 with 3 and do nothing to 14. The sequence is now 5, 3, 14.\nChoose k = 5. Replace 5 with 0, do nothing to 3 and replace 14 with 4. The sequence is now 0, 3, 4.\nThe total cost is 2^{7} + 2^{5} = 160.\n\nSample Input 2:\n3\n19 15 14\n0 0 0\n\nSample Output 2:\n2\nAoki can just choose k = 1 and turn everything into 0. The cost is 2^{1} = 2.\n\nSample Input 3:\n2\n8 13\n5 13\n\nSample Output 3:\n-1\nThe task is impossible because we can never turn 8 into 5 using the given operation.\n\nSample Input 4:\n4\n2 0 1 8\n2 0 1 8\n\nSample Output 4:\n0\nAoki doesn't need to do anything here. The cost is 0.\n\nSample Input 5:\n1\n50\n13\n\nSample Output 5:\n137438953472\nBeware of overflow issues.", "before_after_length": [375, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03395", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsame = 0\nfor i in range(n):\n\tif a[i] == b[i]:\n\t\tsame += 1\n\telif b[i]*2 >= a[i]:\n\t\tprint(-1)\n\t\tsys.exit()\n\nif same == n:\n\tprint(0)\n\tsys.exit()\n\nedges = [[] for _ in range(51)]\nfor i in range(1, 51):\n\tfor j in range(1, i+1):\n\t\tedges[i].append([i%j, j])\n\navailable = [True for _ in range(51)]\nvisited = [False for _ in range(51)]\n\ndef dfs(start, goal, cur):\n\tglobal visited\n\tif cur == goal:\n\t\treturn True\n\tfor e, k in edges[cur]:\n\t\tif visited[e] == False and available[k] == True:\n\t\t\tvisited[e] = True\n\t\t\tif dfs(start, goal, e) == True:\n\t\t\t\treturn True\n\treturn False\n\nans = 0\nfor k in range(50, 0, -1):\n\tavailable[k] = False\n\tok = True\n\tfor i in range(n):\n\t\tvisited = [False for _ in range(51)]\n\t\tvisited[a[i]] = True\n\t\tif dfs(a[i], b[i], a[i]) == False:\n\t\t\tok = False\n\t\t\tbreak\n\tif not ok:\n\t\tans += 2**k\n\t\tavailable[k] = True\n\nprint(ans)", "neg": "import sys\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsame = 0\nfor i in range(n):\n\tif b[i]*2 >= a[i]:\n\t\tprint(-1)\n\t\tsys.exit()\n\telif a[i] == b[i]:\n\t\tsame += 1\nif same == n:\n\tprint(0)\n\tsys.exit()\n\nedges = [[] for _ in range(51)]\nfor i in range(1, 51):\n\tfor j in range(1, i+1):\n\t\tedges[i].append([i%j, j])\n\navailable = [True for _ in range(51)]\nvisited = [False for _ in range(51)]\n\ndef dfs(start, goal, cur):\n\tglobal visited\n\tif cur == goal:\n\t\treturn True\n\tfor e, k in edges[cur]:\n\t\tif visited[e] == False and available[k] == True:\n\t\t\tvisited[e] = True\n\t\t\tif dfs(start, goal, e) == True:\n\t\t\t\treturn True\n\treturn False\n\nans = 0\nfor k in range(50, 0, -1):\n\tavailable[k] = False\n\tok = True\n\tfor i in range(n):\n\t\tvisited = [False for _ in range(51)]\n\t\tvisited[a[i]] = True\n\t\tif dfs(a[i], b[i], a[i]) == False:\n\t\t\tok = False\n\t\t\tbreak\n\tif not ok:\n\t\tans += 2**k\n\t\tavailable[k] = True\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every second, he performs the following operation: Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this operation is 2^{k} (regardless of how many elements he changes). Aoki wants to turn the sequence into b_{1}, b_{2}, ..., b_{N} (the order of the elements is important). Determine if it is possible for Aoki to perform this task and if yes, find the minimum cost required.\n\nConstraints:\n1 \u2264 N \u2264 50\n0 \u2264 a_{i}, b_{i} \u2264 50\nAll values in the input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_{1} a_{2} ... a_{N}\nb_{1} b_{2} ... b_{N}\n\nOutput:\nPrint the minimum cost required to turn the original sequence into b_{1}, b_{2}, ..., b_{N}. If the task is impossible, output -1 instead.\n\nSample Input 1:\n3\n19 10 14\n0 3 4\n\nSample Output 1:\n160\nHere's a possible sequence of operations:\nChoose k = 7. Replace 19 with 5, 10 with 3 and do nothing to 14. The sequence is now 5, 3, 14.\nChoose k = 5. Replace 5 with 0, do nothing to 3 and replace 14 with 4. The sequence is now 0, 3, 4.\nThe total cost is 2^{7} + 2^{5} = 160.\n\nSample Input 2:\n3\n19 15 14\n0 0 0\n\nSample Output 2:\n2\nAoki can just choose k = 1 and turn everything into 0. The cost is 2^{1} = 2.\n\nSample Input 3:\n2\n8 13\n5 13\n\nSample Output 3:\n-1\nThe task is impossible because we can never turn 8 into 5 using the given operation.\n\nSample Input 4:\n4\n2 0 1 8\n2 0 1 8\n\nSample Output 4:\n0\nAoki doesn't need to do anything here. The cost is 0.\n\nSample Input 5:\n1\n50\n13\n\nSample Output 5:\n137438953472\nBeware of overflow issues.", "before_after_length": [406, 405], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03395", "p_user": "u729707098", "n_user": "u729707098", "pos": "n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nx,ans = [],0\ndef f(m):\n\tq = [i+1 for i in range(m)]+x\n\tc = [[True]*51 for i in range(51)]\n\tfor i in range(51): c[i][i] = False\n\tfor i in q:\n\t\tfor j in range(i,51): c[j][j%i] = False\n\tfor k in range(51):\n\t\tfor i in range(51):\n\t\t\tfor j in range(51): c[i][j]*=bool(c[i][k]+c[k][j])\n\treturn any(c[a[i]][b[i]] for i in range(n))\nif f(50): print(-1)\nelse:\n\tfor i in range(49,-1,-1):\n\t\tif f(i): x.append(i+1)\n\tfor i in x: ans+=2**i\n\tprint(ans)", "neg": "n = int(input())\na = [int(i) for i in input().split()]\nb = [int(i) for i in input().split()]\nx,ans = [],0\ndef f(m):\n\tq = [i+1 for i in range(m)]+x\n\tc = [[True]*51 for i in range(51)]\n\tfor i in q:\n\t\tfor j in range(i,51): c[j][j%i] = False\n\tfor k in range(51):\n\t\tfor i in range(51):\n\t\t\tfor j in range(51): c[i][j]*=bool(c[i][k]+c[k][j])\n\treturn any(c[a[i]][b[i]] for i in range(n))\nif f(50): print(-1)\nelse:\n\tfor i in range(49,-1,-1):\n\t\tif f(i): x.append(i+1)\n\tfor i in x: ans+=2**i\n\tprint(ans)", "jacc_sim": 1.0, "nl": "Aoki is playing with a sequence of numbers a_{1}, a_{2}, ..., a_{N}. Every second, he performs the following operation: Choose a positive integer k. For each element of the sequence v, Aoki may choose to replace v with its remainder when divided by k, or do nothing with v. The cost of this operation is 2^{k} (regardless of how many elements he changes). Aoki wants to turn the sequence into b_{1}, b_{2}, ..., b_{N} (the order of the elements is important). Determine if it is possible for Aoki to perform this task and if yes, find the minimum cost required.\n\nConstraints:\n1 \u2264 N \u2264 50\n0 \u2264 a_{i}, b_{i} \u2264 50\nAll values in the input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_{1} a_{2} ... a_{N}\nb_{1} b_{2} ... b_{N}\n\nOutput:\nPrint the minimum cost required to turn the original sequence into b_{1}, b_{2}, ..., b_{N}. If the task is impossible, output -1 instead.\n\nSample Input 1:\n3\n19 10 14\n0 3 4\n\nSample Output 1:\n160\nHere's a possible sequence of operations:\nChoose k = 7. Replace 19 with 5, 10 with 3 and do nothing to 14. The sequence is now 5, 3, 14.\nChoose k = 5. Replace 5 with 0, do nothing to 3 and replace 14 with 4. The sequence is now 0, 3, 4.\nThe total cost is 2^{7} + 2^{5} = 160.\n\nSample Input 2:\n3\n19 15 14\n0 0 0\n\nSample Output 2:\n2\nAoki can just choose k = 1 and turn everything into 0. The cost is 2^{1} = 2.\n\nSample Input 3:\n2\n8 13\n5 13\n\nSample Output 3:\n-1\nThe task is impossible because we can never turn 8 into 5 using the given operation.\n\nSample Input 4:\n4\n2 0 1 8\n2 0 1 8\n\nSample Output 4:\n0\nAoki doesn't need to do anything here. The cost is 0.\n\nSample Input 5:\n1\n50\n13\n\nSample Output 5:\n137438953472\nBeware of overflow issues.", "before_after_length": [266, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u496727432", "n_user": "u496727432", "pos": "n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nans = 0\nanslist = [0] * n\nfor j in range(1, n + 2):\n if j == 1:\n ans += abs(a[j])\n elif j == n + 1:\n ans += abs(a[n])\n else:\n ans += abs(a[j]-a[j - 1])\n\nfor i in range(1, n + 1):\n anslist[i - 1] = ans - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])\n \nfor k in anslist:\n print(k)", "neg": "n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nans = 0\nanslist = [0] * n\nfor j in range(n + 1):\n if j == 0:\n ans += abs(a[0])\n elif j == n:\n ans += abs(a[n - 1])\n else:\n ans += abs(a[j]-a[j - 1])\n\nfor i in range(1, n + 1):\n anslist[i - 1] = ans - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) + abs(a[i - 1] - a[i + 1])\n \nfor k in anslist:\n print(k)\n", "jacc_sim": 0.9705882352941176, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [193, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u896741788", "n_user": "u896741788", "pos": "n=input()\nl=[0]+list(map(int,input().split()))+[0]\nans=0\npre=0\nfor i in l:ans+=abs(pre-i);pre=i\nfor i in range(1,int(n)+1):\n dif=-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1])\n if l[i]in(l[i-1],l[i+1]):print(ans)\n elif l[i]l[i] else ans+dif)", "neg": "n=input()\nl=[0]+list(map(int,input().split()))+[0]\nans=0\npre=0\nfor i in l:ans+=abs(pre-i);pre=i\nfor i in range(1,int(n)+1):\n dif=-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1])\n if l[i]in(l[i-1],l[i+1]):print(ans)\n elif l[i]l[i] else ans+dif)", "jacc_sim": 0.9714285714285714, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [197, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u131464432", "n_user": "u131464432", "pos": "N = int(input())\nA = list(map(int,input().split()))\nnow = 0\ndis = 0\nfor i in A:\n dis += abs(now-i)\n now = i\nans = dis+abs(now)\nB = [0]\nB.extend(A)\nB.append(0)\nfor i in range(1,N+1):\n if B[i-1] < B[i] > B[i+1] or B[i-1] > B[i] < B[i+1]:\n print(ans - 2*min(abs(B[i-1]-B[i]),abs(B[i]-B[i+1])))\n else:\n print(ans)", "neg": "N = int(input())\nA = list(map(int,input().split()))\nnow = 0\ndis = 0\nfor i in A:\n dis += abs(now-i)\n now = i\nans = dis+abs(now)\nB = [0]\nB.extend(A)\nB.append(0)\nprint(B)\nfor i in range(1,N+1):\n if B[i-1] < B[i] > B[i+1] or B[i-1] > B[i] < B[i+1]:\n print(ans - 2*min(abs(B[i-1]-B[i]),abs(B[i]-B[i+1])))\n else:\n print(ans)", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [178, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u536034761", "n_user": "u536034761", "pos": "from itertools import accumulate\nN = int(input())\nA = tuple([0,] + list(map(int, input().split())) + [0,])\nD = []\nsum = 0\nfor i, a in enumerate(A[1:-1]):\n i += 1\n pre = A[i - 1]\n tem = A[i]\n nex = A[i + 1]\n x = abs(pre - tem)\n y = abs(tem - nex)\n sum += x\n D.append(abs(pre - nex) - x - y)\nsum += y\nfor d in D:\n print(sum + d)", "neg": "from itertools import accumulate\nN = int(input())\nA = tuple([0,] + list(map(int, input().split())) + [0,])\nD = []\nsum = 0\nfor i, a in enumarate(A[1:-1]):\n i += 1\n pre = A[i - 1]\n tem = A[i]\n nex = A[i + 1]\n x = abs(pre - tem) + abs(tem - nex)\n sum += x\n D.append(abs(pre - nex) - x)\nfor d in D:\n print(sum + d)", "jacc_sim": 0.926829268292683, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [156, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u318427318", "n_user": "u318427318", "pos": "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n \ndef main():\n plan=[0]\n n = int(input())\n plan+=list(map(int,input().split()))\n plan.append(0)\n pay_sum = 0\n for i in range(1,n+2):\n pay_sum += abs(plan[i] - plan[i-1])\n \n for i in range(1,n+1):\n result = abs(plan[i-1] - plan[i+1])\n result -= abs(plan[i-1] - plan[i])\n result -= abs(plan[i+1] - plan[i])\n print(pay_sum + result)\n\nif __name__==\"__main__\":\n main()", "neg": "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n \ndef main():\n plan=[0]\n n = int(input())\n plan+=list(map(int,input().split()))\n plan.append(0)\n pay_sum = 0\n for i in range(1,n+2):\n pay_sum += abs(plan[i] - plan[i-1])\n \n for i in range(1,n+1):\n result = abs(plan[i-1] - plan[i+1])\n result -= abs(plan[i-1] - plan[i])\n result -= abs(plan[i+1] - plan[i])\n print(pay_sum - result)\n\nif __name__==\"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [200, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u397496203", "n_user": "u397496203", "pos": "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input().strip())\n A = [int(i) for i in input().strip().split()]\n A = [0] + A + [0] ## append start and goal (1-indexed table)\n diff = [0] * n # 0-indexed table\n prev = 0\n _sum = 0\n for i in range(1,n+1):\n _sum += abs(prev - A[i])\n prev = A[i]\n diff[i-1] = abs(A[i-1] - A[i+1]) - (abs(A[i]-A[i-1]) + abs(A[i+1] - A[i]))\n ## add the cost until goal.\n _sum += abs(A[n])\n for i in range(n):\n print(_sum + diff[i])\n\nif __name__ == \"__main__\":\n main()", "neg": "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n n = int(input().strip())\n A = [int(i) for i in input().strip().split()]\n A = [0] + A + [0] ## append start and goal (1-indexed table)\n diff = [0] * n # 0-indexed table\n prev = 0\n _sum = 0\n for i in range(1,n):\n _sum += abs(prev - A[i])\n prev = A[i]\n diff[i-1] = abs(A[i-1] - A[i+1]) - (abs(A[i]-A[i-1]) + abs(A[i+1] - A[i]))\n ## add the cost until goal.\n _sum += abs(A[i] - A[i+1])\n \n for i in range(n):\n print(_sum + diff[i])\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [236, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u644907318", "n_user": "u644907318", "pos": "N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\ntot = 0\nfor i in range(1,N+1):\n tot += abs(A[i]-A[i-1])\ntot += abs(A[0]-A[N])\nfor i in range(1,N):\n a = tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])\n print(a)\na = tot-abs(A[N]-A[N-1])-abs(0-A[N])+abs(0-A[N-1])\nprint(a)", "neg": "A = list(map(int,input().split()))\nA.insert(0,0)\ntot = 0\nfor i in range(1,N+1):\n tot += abs(A[i]-A[i-1])\ntot += abs(A[0]-A[N])\nfor i in range(1,N):\n a = tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])\n print(a)\na = tot-abs(A[N]-A[N-1])-abs(0-A[N])+abs(0-A[N-1])\nprint(a)", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [184, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u593567568", "n_user": "u593567568", "pos": "import itertools\n\nN = int(input())\nA = [0] + list(map(int,input().split())) + [0]\n\nacc = []\nprev = 0\nt = 0\nfor i in range(N+2):\n if i == 0:\n continue\n a = A[i]\n t += abs(a - prev)\n acc.append(t)\n prev = a\n \nans = []\nfor i in range(N+1):\n if i == 0:\n continue\n t = 0\n\n if 1 < i:\n t += acc[i-2]\n if i < N:\n t += acc[N] - acc[i]\n t += abs(A[i+1] - A[i-1])\n \n ans.append(t)\n \nprint(\"\\n\".join(map(str,ans)))\n", "neg": "import itertools\n\nN = int(input())\nA = list(map(int,input().split()))\n\nacc = []\nprev = 0\nfor a in A:\n t = abs(a - prev)\n acc.append(t)\n prev = a\n \n\nans = []\nfor i in range(N):\n t = 0\n if 0 < i:\n t += acc[i-1]\n \n if i < N-1:\n t += acc[N-1] - acc[i]\n \n ans.append(t)\n \nprint(\"\\n\".join(map(str,ans)))", "jacc_sim": 0.9523809523809523, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [210, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u955125992", "n_user": "u955125992", "pos": "n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.insert(0, 0)\ndis = [0] * (n+1)\nfor i in range(1, n+2):\n dis[i-1] = abs(a[i] - a[i-1])\n\nS = sum(dis)\nfor i in range(1, n+1):\n A = a[i-1]\n B = a[i]\n C = a[i+1]\n if A > C:\n A, C = C, A\n if A<=B<=C:\n print(S)\n else:\n print(S-2*min(abs(A-B), abs(C-B)))", "neg": "n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.insert(0, 0)\ndis = [0] * (n+1)\nfor i in range(1, n+2):\n dis[i-1] = abs(a[i] - a[i-1])\n\nS = sum(dis)\nprint(S)\nfor i in range(1, n+1):\n A = a[i-1]\n B = a[i]\n C = a[i+1]\n if A > C:\n A, C = C, A\n if A<=B<=C:\n print(S)\n else:\n print(S-2*min(abs(A-B), abs(C-B)))", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [189, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u860002137", "n_user": "u860002137", "pos": "import numpy as np\nn = int(input())\na = np.array([0] + list(map(int, input().split())) + [0])\n\nwhole = np.abs((np.diff(a))).sum()\n\nfor i in range(n):\n print(whole - abs(a[i + 1] - a[i]) -\n abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))", "neg": "n = int(input())\na = np.array([0] + list(map(int, input().split())) + [0])\n\nwhole = np.abs((np.diff(a))).sum()\n\nfor i in range(n):\n print(whole - abs(a[i + 1] - a[i]) -\n abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]))", "jacc_sim": 0.9117647058823529, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [115, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u064434060", "n_user": "u064434060", "pos": "import sys\n#import numpy as np\nimport math\nfrom fractions import Fraction\nimport itertools\n\ninput=sys.stdin.readline\n\nn=int(input())\ns=list(map(int,input().split()))\n\nd=[0]*(n+1)\nd[1]=abs(s[0])\nfor i in range(2,n+1):\n d[i]=d[i-1]+abs(s[i-1]-s[i-2])\nans=abs(s[n-1])+d[n]-d[2]+d[0]+abs(s[1])\nprint(ans)\nfor i in range(1,n-1):\n ans=abs(s[n-1])+d[i]+d[n]-d[i+2]+abs(s[i+1]-s[i-1])\n print(ans)\nans=d[n-1]+abs(s[n-2])\nprint(ans)", "neg": "import sys\n#import numpy as np\nimport math\nfrom fractions import Fraction\nimport itertools\n\ninput=sys.stdin.readline\n\nn=int(input())\ns=list(map(int,input().split()))\n\nd=[0]*(n+1)\nd[1]=abs(s[0])\nfor i in range(2,n+1):\n d[i]=d[i-1]+abs(s[i-1]-s[i-2])\nans=abs(s[n-1])+d[n]-d[2]+d[0]+s[1]\nprint(ans)\nfor i in range(1,n-1):\n ans=abs(s[n-1])+d[i]+d[n]-d[i+2]+abs(s[i+1]-s[i-1])\n print(ans)\nans=d[n-1]+abs(s[n-2])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [235, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u644907318", "n_user": "u644907318", "pos": "N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\ntot = abs(A[1])+abs(A[N])\nfor i in range(2,N+1):\n tot += abs(A[i]-A[i-1])\nfor i in range(1,N+1):\n if i==1:\n print(tot-abs(A[1])-abs(A[2]-A[1])+abs(A[2]))\n elif i==N:\n print(tot-abs(A[N])-abs(A[N]-A[N-1])+abs(A[N-1]))\n else:\n print(tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))", "neg": "N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\ntot = abs(A[1])\nfor i in range(2,N+1):\n tot += abs(A[i]-A[i-1])\ntot += abs(A[N])\nprint(tot-abs(A[1])-abs(A[2]-A[1])+abs(A[2]))\nfor i in range(2,N):\n print(tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))\nprint(tot-abs(A[N])-abs(A[N]-A[N-1])+A[N-1])", "jacc_sim": 0.9032258064516129, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [219, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u217627525", "n_user": "u217627525", "pos": "def main():\n n=int(input())\n a=list(map(int,input().split()))\n b=[a[0]]\n ans=abs(a[0])\n for i in range(n-1):\n b.append(a[i+1]-a[i])\n ans+=abs(a[i+1]-a[i])\n b.append(-1*a[n-1])\n ans+=abs(a[n-1])\n for i in range(n):\n if b[i]*b[i+1]>=0:\n print(ans)\n else:\n print(ans-abs(b[i])-abs(b[i+1])+abs(b[i]+b[i+1]))\nif __name__==\"__main__\":\n main()", "neg": "def main():\n n=int(input())\n a=list(map(int,input().split()))\n b=[a[0]]\n ans=abs(a[0])\n for i in range(n-1):\n b.append(a[i+1]-a[i])\n ans+=abs(a[i+1]-a[i])\n b.append(-1*a[n-1])\n ans+=abs(a[n-1])\n for i in range(n):\n if b[i]*b[i+1]>=0:\n print(ans)\n else:\n print(ans-b[i]-b[i+1]+abs(b[i]+b[i+1]))\nif __name__==\"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [201, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u931462344", "n_user": "u931462344", "pos": "N = int(input())\nA = [0]\nA = A + list(map(int, input().split()))\nA.append(0)\nsumOfRoute = 0\ntmp = 0\nfor a in A:\n sumOfRoute += abs(tmp-a)\n tmp = a\n\nprev = 0\nfor i in range(1, N+1):\n nexti = A[i+1]\n print(sumOfRoute + abs(prev - nexti) - abs(A[i] - nexti) - abs(prev - A[i]))\n prev = A[i]\n", "neg": "N = int(input())\nA = [0]\nA = A + list(map(int, input().split()))\nA.append(0)\nprint(A)\nsumOfRoute = 0\ntmp = 0\nfor a in A:\n sumOfRoute += abs(tmp-a)\n tmp = a\n\nprev = 0\nfor i in range(1, N+1):\n nexti = A[i+1]\n print(sumOfRoute + abs(prev - nexti) - abs(A[i] - nexti) - abs(prev - A[i]))\n prev = A[i]\n", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [140, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u185325486", "n_user": "u185325486", "pos": "N = int(input())\nA = [int(i) for i in input().split()]\ntotal = abs(A[0])\nfor i in range(N-1):\n total += abs(A[i+1]-A[i])\ntotal += abs(A[N-1])\nprint(total+abs(A[1])-abs(A[1]-A[0])-abs(A[0]))\nfor i in range(1,N-1): \n print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])) \nprint(total+abs(A[N-2])-abs(A[N-2]-A[N-1])-abs(A[N-1]))", "neg": " N = int(input())\n A = [int(i) for i in input().split()]\n total, plus = A[0], A[1]\n for i in range(N-1):\n total += abs(A[i+1]-A[i])\n total += abs(A[N-1])\n print(total+A[1]-abs(A[1]-A[0])-A[0])\n for i in range(1,N-1): \n print(total+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])) \n print(total+A[N-2]-abs(A[N-2]-A[N-1])-abs(A[N-1]))", "jacc_sim": 0.9615384615384616, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [200, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u781262926", "n_user": "u781262926", "pos": "n, *A = map(int, open(0).read().split())\nA = [0] + A + [0]\nB = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]\ns = sum(B)\nfor i in range(1, n+1):\n print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])", "neg": "n, *A = map(int, open(0).input().split())\nA = [0] + A + [0]\nB = [abs(a1-a0) for a0, a1 in zip(A, A[1:])]\ns = sum(B)\nfor i in range(1, n+1):\n print(s + abs(A[i-1]-A[i+1]) - B[i-1] - B[i])", "jacc_sim": 0.9393939393939394, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [110, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u861141787", "n_user": "u861141787", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nb = [0] + a + [0]\nc = []\nfor i in range(n+1):\n c.append(abs(b[i] - b[i+1]))\n\nl = sum(c)\n\nfor i in range(n):\n ans = l - c[i] - c[i+1]\n ans += abs(b[i] - b[i+2])\n print(ans)\n\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nb = [0] + a + [0]\nc = []\nfor i in range(n+1):\n c.append(abs(b[i] - b[i+1]))\n\nfor i in range(n):\n ans = l - c[i] - c[i+1]\n ans += abs(b[i] - b[i+2])\n print(ans)\n", "jacc_sim": 0.96875, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [125, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u278356323", "n_user": "u278356323", "pos": "# ARC093c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n from collections import Counter\n\n n = int(input())\n a = [0]\n a.extend(list(map(int, input().split())))\n a.append(0)\n # print(a)\n\n total = 0\n for i in range(1, n+2):\n total += abs(a[i]-a[i-1])\n # print(total)\n\n for j in range(1, n+1):\n if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:\n print(total)\n continue\n print(total-abs(a[j]-a[j-1])-abs(a[j+1]-a[j])+abs(a[j+1]-a[j-1]))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# ARC093c\ndef main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**6)\n from collections import Counter\n\n n = int(input())\n a = [0]\n a.extend(list(map(int, input().split())))\n a.append(0)\n print(a)\n\n total = 0\n for i in range(1, n+2):\n total += abs(a[i]-a[i-1])\n # print(total)\n\n for j in range(1, n+1):\n if a[j-1] <= a[j] <= a[j+1] or a[j-1] >= a[j] >= a[j+1]:\n print(total)\n continue\n print(total-abs(a[j]-a[j-1])-abs(a[j+1]-a[j])+abs(a[j+1]-a[j-1]))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [262, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u183896397", "n_user": "u241159583", "pos": "n = int(input())\na = list(map(int,input().split()))\na = [0] + a + [0]\nsum = 0\nfor i in range(n+1):\n sum += abs(a[i] - a[i+1])\nfor i in range(n):\n ans = (sum \n - abs(a[i] - a[i+1]) \n - abs(a[i+1] -a[i+2])\n + abs(a[i] - a[i+2]))\n print(ans)", "neg": "n = int(input())\na = [0]+list(map(int, input().split()))+[0]\n\nmoney = [0]\nfor i in range(n+1):\n money.append(abs(a[i]-a[i+1]))\nprint(money)\nans = sum(money)\nfor i in range(n):\n print(ans - sum(money[i+1:i+3]) + abs(a[i]-a[i+2]))", "jacc_sim": 0.9032258064516129, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [133, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u813098295", "n_user": "u813098295", "pos": "n = int(input())\na = [ int(x) for x in input().split() ]\n\nans = abs(a[0] )\n\nfor i in range(1, len(a)):\n ans += abs(a[i] - a[i-1])\n\nans += abs(a[-1] - 0)\n\nfor i, v in enumerate(a):\n if i == 0:\n if 0 <= v <= a[i+1] or a[i+1] <= v <= 0:\n print(ans)\n elif 0 <= a[i+1] <= v or v <= a[i+1] <= 0:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= 0 <= a[i+1] or a[i+1] <= 0 <= v:\n print(ans-abs(v)*2)\n\n elif i == n-1:\n if a[i-1] <= v <= 0 or 0 <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= 0 <= v or v <= 0 <= a[i-1]:\n print(ans-abs(v)*2)\n elif v <= a[i-1] <= 0 or 0 <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n else:\n if a[i-1] <= v <= a[i+1] or a[i+1] <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= a[i+1] <= v or v <= a[i+1] <= a[i-1]:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n\n", "neg": "n = int(input())\na = [ int(x) for x in input().split() ]\n\nans = a[0] \n\nfor i in range(1, len(a)):\n ans += abs(a[i] - a[i-1])\n\nans += abs(a[-1] - 0)\n\nfor i, v in enumerate(a):\n if i == 0:\n if 0 <= v <= a[i+1] or a[i+1] <= v <= 0:\n print(ans)\n else:\n print(ans-2*abs(v))\n elif i == n-1:\n if a[i-1] <= v <= 0 or 0 <= v <= a[i-1]: \n print(ans)\n else:\n print(ans-2*abs(v))\n else:\n if a[i-1] <= v <= a[i+1] or a[i+1] <= v <= a[i-1]:\n print(ans)\n elif a[i-1] <= a[i+1] <= v or v <= a[i+1] <= a[i-1]:\n print(ans-abs(a[i+1]-v)*2)\n elif v <= a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= v:\n print(ans-abs(a[i-1]-v)*2)\n\n", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [482, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u136090046", "n_user": "u136090046", "pos": "n = int(input())\narray = [int(x) for x in input().split()]\nsum_array = [0]\nnow = 0\nfor i in range(n):\n sum_array.append(sum_array[i] + abs(array[i] - now))\n now = array[i]\nelse:\n sum_array.append(sum_array[-1] + abs(array[-1] - 0))\n\nfor j in range(n):\n if j == 0:\n print(sum_array[-1] -\n (sum_array[j + 1] - sum_array[j]) -\n (sum_array[j + 2] - sum_array[j + 1]) +\n (abs(array[j + 1] - 0))\n )\n elif j == n - 1:\n print(sum_array[-3] + abs(array[-2]))\n else:\n print(sum_array[-1] -\n (sum_array[j + 1] - sum_array[j]) -\n (sum_array[j + 2] - sum_array[j + 1]) +\n (abs(array[j + 1] - array[j - 1]))\n )", "neg": "n = int(input())\narray = [int(x) for x in input().split()]\nsum_array = [0 for x in range(n+1)]\nnow = 0\nfor i in range(n):\n sum_array[i] = abs(array[i]-now)\n now = array[i]\nelse:\n sum_array[-1] = abs(now)\n\nfor j in range(n):\n if j == 0:\n print(sum_array[-1])\n elif j == n-1:\n print(sum_array[-2]+abs(array[-2]))\n else:\n print(sum_array[-1]-(sum_array[j]-sum_array[j-1])-(sum_array[j+1]-sum_array[j])+(abs(array[j+1]-array[j-1]))", "jacc_sim": 0.9375, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [287, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u623349537", "n_user": "u644907318", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\nsum_A = abs(A[0])\nfor i in range(1, N):\n sum_A= sum_A + abs(A[i - 1] - A[i])\nsum_A += abs(A[N - 1])\n\nfor i in range(N):\n if i == 0:\n print(sum_A - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))\n elif i == N - 1:\n print(sum_A - abs(A[N - 1] - A[N - 2]) - abs(A[N - 1]) + abs(A[N - 2]))\n else:\n print(sum_A - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]))", "neg": "N = int(input())\nA = list(map(int,input().split()))\nA.insert(0,0)\ntot = abs(A[1])\nfor i in range(2,N+1):\n tot += abs(A[i]-A[i-1])\ntot += abs(A[N])\nfor i in range(1,N+1):\n if i==1:\n print(tot-abs(A[1])-abs(A[2]-A[1])+A[2])\n elif i==N:\n print(tot-abs(A[N])-abs(A[N]-A[N-1])+abs(A[N-1]))\n else:\n print(tot-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))", "jacc_sim": 0.90625, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [233, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u473291366", "n_user": "u473291366", "pos": "N = int(input())\nA = [0] + list(map(int,input().split())) + [0]\n\nF = [0]\nfor i in range(1, N+1):\n F.append(abs(A[i] - A[i-1]) + F[i-1])\n\nB = [0]\nfor i in range(1, N+1):\n B.append(abs(A[N+1-i] - A[N+2-i]) + B[i-1])\nB.reverse()\n\nfor i in range(1, N+1):\n print(abs(A[i+1]-A[i-1]) + F[i-1] + B[i])", "neg": "N = int(input())\nA = [0] + list(map(int,input().split())) + [0]\nprint(A)\n\nF = [0]\nfor i in range(1, N+1):\n F.append(abs(A[i] - A[i-1]) + F[i-1])\n\nB = [0]\nfor i in range(1, N+1):\n B.append(abs(A[N+1-i] - A[N+2-i]) + B[i-1])\nB.reverse()\n\nfor i in range(1, N+1):\n print(abs(A[i+1]-A[i-1]) + F[i-1] + B[i])", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [173, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u410118019", "n_user": "u410118019", "pos": "n = int(input())\nai = list(map(int,input().split()))\na = [0]\nfor i in ai:\n a.append(i)\nal = [0] * (n+1)\nfor i in range(n+1):\n al[i] = abs(a[(i+1)%(n+1)] - a[i])\ns = sum(al)\nfor i in range(1,n+1):\n print(s-al[i-1]-al[i]+abs(a[(i+1)%(n+1)]-a[i-1]))", "neg": "n = int(input())\na = list(map(int,input().split()))\nal = [0] * n\nfor i in range(n):\n al[i] = abs(a[i+1] - a[i])\ns = sum(al)\nfor i in range(n):\n print(s-al[i-1]-al[i]+abs(a[i+1]-a[i-1]))", "jacc_sim": 0.90625, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [145, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u600896094", "n_user": "u600896094", "pos": "def main():\n N = int(input())\n A = [0] + list(map(int, input().split())) + [0]\n\n sum = 0\n for i in range(1, N+2): sum += abs(A[i] - A[i-1])\n\n for i in range(1, N+1):\n if A[i-1] <= A[i] <= A[i+1]: print(sum)\n elif A[i-1] >= A[i] >= A[i+1]: print(sum)\n elif A[i-1] < A[i+1] < A[i] or A[i-1] > A[i+1] > A[i]: print(sum - abs(A[i+1] - A[i]) * 2)\n else: print(sum - abs(A[i] - A[i-1]) * 2)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n N = int(input())\n A = [0] + list(map(int, input().split())) + [0]\n\n sum = 0\n for i in range(1, N+2): sum += abs(A[i] - A[i-1])\n\n for i in range(1, N+1):\n if (A[i-1] <= A[i] <= A[i+1]): print(sum)\n elif (A[i-1] >= A[i] >= A[i+1]): print(sum)\n else: print(sum - abs(A[i] - A[i-1]) * 2)\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9743589743589743, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [233, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u710789518", "n_user": "u710789518", "pos": "N = int(input())\nA = list(map(int, input().split()))\ns = abs(A[0]) + abs(A[-1])\nfor i in range(N-1):\n s += abs(A[i+1] - A[i])\n#print(s)\nfor i in range(N):\n b = A[i]\n if i == 0:\n a = 0\n else:\n a = A[i-1]\n if i == N-1:\n c = 0\n else:\n c = A[i+1]\n if a <= b and b <= c:\n print(s)\n elif a <= c and c <= b:\n print(s-(b-c)*2)\n elif b <= a and a <= c:\n print(s-(a-b)*2)\n elif b <= c and c <= a:\n print(s-(c-b)*2)\n elif c <= a and a <= b:\n print(s-(b-a)*2)\n else:\n print(s)\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\ns = abs(A[0]) + abs(A[-1])\nfor i in range(N-1):\n s += abs(A[i+1] - A[i])\n#print(s)\nfor i in range(N):\n b = A[i]\n if i == 0:\n a = 0\n else:\n a = A[i-1]\n if i == N-1:\n c = 0\n else:\n c = A[i+1]\n if a < b and b < c:\n print(s)\n elif a < c and c < b:\n print(s-(b-c)*2)\n elif b < a and a < c:\n print(s-(c-a)*2)\n elif b < c and c < a:\n print(s-(c-b)*2)\n elif c < a and a < b:\n print(s-(b-a)*2)\n else:\n print(s)\n", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [263, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u778814286", "n_user": "u778814286", "pos": "n = int(input())\ntmpa = list(map(int, input().split()))\nA = [0] * (n+2)\nA[0] = 0\nA[n+1] = 0\nfor i in range(1,n+1,1): A[i] = tmpa[i-1]\n\n\n#\u666e\u901a\u306b\u7dcf\u548c\u3092\u51fa\u3059\nsum = 0\nfor i, a in enumerate(A):\n if i == n+1: break #n+1\u306f\u30b4\u30fc\u30eb\u306a\u306e\u3067\u5148\u306b\u884c\u304b\u306a\u3044\n sum += abs(a - A[i+1]) #a:A[i]\n \n#\u5f15\u3044\u3066\u8db3\u3059\nfor i in range(1, n+1, 1): #1\uff5eN\u3092\u7701\u3044\u305f\u3068\u304d\n nowsum = sum\n nowsum -= abs(A[i-1]-A[i])\n nowsum -= abs(A[i]-A[i+1])\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n", "neg": "n = int(input\nA = [0] + list(map(int, input().split())) + [0]\n\n#\u666e\u901a\u306b\u7dcf\u548c\u3092\u51fa\u3059\nsum = 0\nfor i, a in enumerate(A):\n if i == n+1: break #n+1\u306f\u30b4\u30fc\u30eb\u306a\u306e\u3067\u5148\u306b\u884c\u304b\u306a\u3044\n sum += abs(a - A[i+1]) #a:A[i]\n \n#\u5f15\u3044\u3066\u8db3\u3059\nfor i in range(1, n+1, 1): #1\uff5eN\u3092\u7701\u3044\u305f\u3068\u304d\n nowsum = sum\n nowsum -= abs(A[i-1]-A[i])\n nowsum -= abs(A[i]-A[i+1])\n nowsum += abs(A[i-1]-A[i+1])\n print(nowsum)\n", "jacc_sim": 0.9523809523809523, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [318, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u814781830", "n_user": "u814781830", "pos": "N = int(input())\nA = [0] * (N + 2)\nfor i, v in enumerate(input().split()):\n A[i+1] = int(v)\nnum = sum([abs(A[i] - A[i+1]) for i in range(N+1)])\nfor i in range(1,N+1):\n ret = num + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))\n print(ret)", "neg": "N = int(input())\nA = [0] * (N + 2)\nfor i, v in enumerate(input().split()):\n A[i+1] = int(v)\nnum = sum([abs(A[i] - A[i+1]) for i in range(N+1)])\nfor i in range(N):\n ret = num + abs(A[i-1] - A[i+1]) - (abs(A[i-1] - A[i]) + abs(A[i] - A[i+1]))\n print(ret)", "jacc_sim": 1.0, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [140, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u397531548", "n_user": "u397531548", "pos": "A=int(input())\nB=list(map(int,input().split()))\na=0\nS=0\nfor i in range(len(B)):\n S+=abs(B[i]-a)\n a=B[i]\nS+=abs(B[-1])\nfor j in range(len(B)):\n if j==0:\n if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:\n print(S)\n elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:\n print(S-2*abs(B[0]))\n else:\n print(S-2*abs(B[1]-B[0]))\n elif j==len(B)-1:\n if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:\n print(S)\n elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:\n print(S-2*abs(B[-1]))\n else:\n print(S-2*abs(B[-1]-B[-2]))\n else:\n if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:\n print(S)\n elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:\n print(S-2*abs(B[j-1]-B[j]))\n else:\n print(S-2*abs(B[j+1]-B[j]))\n", "neg": "A=int(input())\nB=list(map(int,input().split()))\na=0\nS=0\nfor i in range(len(B)):\n S+=abs(B[i]-a)\n a=B[i]\nS+=abs(B[-1])\nfor j in range(len(B)):\n if j=0:\n if 0<=B[0]<=B[1] or 0>=B[0]>=B[1]:\n print(S)\n elif B[0]<=0<=B[1] or B[0]>=0>=B[1]:\n print(S-abs(B[0]))\n else:\n print(S-abs(B[1]-B[0]))\n elif j=len(B)-1:\n if 0<=B[-1]<=B[-2] or 0>=B[-1]>=B[-2]:\n print(S)\n elif B[-1]<=0<=B[-2] or B[-1]>=0>=B[-2]:\n print(S-abs(B[-1]))\n else:\n print(S-abs(B[-1]-B[-2]))\n else:\n if B[j-1]<=B[j]<=B[j+1] or B[j-1]>=B[j]>=B[j+1]:\n print(S)\n elif B[j]<=B[j-1]<=B[j+1] or B[j]>=B[j-1]>=B[j+1]:\n print(S-abs(B[j-1]-B[j]))\n else:\n print(S-abs(B[j+1]-B[j]))", "jacc_sim": 0.972972972972973, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [451, 438], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u607865971", "n_user": "u607865971", "pos": "N = int(input())\nA = [int(x) for x in input().split()]\n\n\nA = [0] + A + [0]\nsum = 0\nfor i in range(N+1):\n sum += abs(A[i] - A[i+1])\n\nfor i in range(1, N + 1):\n d1 = abs(A[i - 1] - A[i])\n d2 = abs(A[i + 1] - A[i])\n d3 = abs(A[i - 1] - A[i + 1])\n print(sum - d1 - d2 + d3)\n", "neg": "N = int(input())\nA = [int(x) for x in input().split()]\n\n\nA = [0] + A + [0]\nsum = 0\nfor i in range(N+2):\n sum += abs(A[i] - A[+1])\n\nfor i in range(1, N + 1):\n d1 = abs(A[i - 1] - A[i])\n d2 = abs(A[i + 1] - A[i])\n d3 = abs(A[i - 1] - A[i + 1])\n print(sum - d1 - d2 + d3)", "jacc_sim": 0.9655172413793104, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [152, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u362829196", "n_user": "u362829196", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\nN = int(sys.stdin.readline())\n\nA = sys.stdin.readline().split(' ')\n\nA = [int(x) for x in A]\n\nA.insert(0, 0)\nA.append(0)\n\ntotal = 0\n\nfor i in range(N + 1):\n\ttotal += abs(A[i] - A[i+1])\n\nfor i in range(1, N + 1):\n\tprint(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))\n", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport sys\n\nN = int(sys.stdin.readline())\n\nA = map(lambda x: int(x), sys.stdin.readline().split(' '))\n\ntotal = 0\nA.insert(0, 0)\nA.append(0)\n\nfor i in range(N + 1):\n\ttotal += abs(A[i] - A[i+1])\n\nfor i in range(1, N + 1):\n\tprint(str(total - abs(A[i] - A[i + 1]) - abs(A[i] - A[i - 1]) + abs(A[i -1] - A[i + 1])))\n", "jacc_sim": 0.9555555555555556, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [183, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u851326509", "n_user": "u832152513", "pos": "n = int(input())\nl = [0] + list(map(int,input().split())) + [0]\n\ns = 0\nfor i in range(n+1):\n s += abs(l[i+1]-l[i])\n\nfor i in range(1,n+1):\n if (l[i-1] <= l[i] and l[i] <= l[i+1]) or (l[i-1] >= l[i] and l[i] >= l[i+1]):\n print(s)\n elif l[i-1] < l[i] and l[i] > l[i+1]:\n print(s - 2*abs(l[i] - max(l[i-1],l[i+1])))\n else:\n print(s - 2*abs(l[i] - min(l[i-1],l[i+1])))", "neg": "n = int(input())\na = list(map(int, input().split()))\n\ns = abs(a[0]) + abs(a[-1])\nl = [abs(a[0])]\na.append(0)\nfor i in range(n-1):\n if a[i] >= 0 and a[i+1] >= 0 or a[i] < 0 and a[i+1] < 0:\n l.append(max(abs(a[i]), abs(a[i+1])) - min(abs(a[i]), abs(a[i+1])))\n s += l[i+1]\n else:\n l.append(abs(a[i]) + abs(a[i+1]))\n s += l[i+1]\nl.append(abs(a[-2]))\n\na = [0]+a\nfor i in range(1, n+1):\n if 0 <= a[i] <= a[i+1] or 0 > a[i] > a[i+1]:\n print(s)\n elif a[i] <= a[i-1] <= a[i+1] or a[i+1] <= a[i-1] <= a[i]:\n print(s-l[i-1]*2)\n else:\n print(s-l[i]*2,2)", "jacc_sim": 0.9487179487179487, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [222, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03403", "p_user": "u702582248", "n_user": "u562015767", "pos": "n = int(input())\na= [0] + list(map(int, input().split())) + [0]\n\nb = 0\nfor i in range(n + 1):\n b += abs(a[i] - a[i+1])\n\nfor i in range(n):\n print(b - abs(a[i] - a[i+1]) - abs(a[i+1] - a[i+2]) + abs(a[i] - a[i+2]))", "neg": "n = int(input())\na = list(map(int,input().split()))\na = [0] + a + [0]\n\ns = 0\n\nfor i in range(n):\n s += abs(a[i]-a[i+1])\n\nfor i in range(n):\n print(s+abs(a[i]-a[i+2])-(abs(a[i]-a[i+1])+abs(a[i+1]-a[i+2])))", "jacc_sim": 0.9285714285714286, "nl": "You are given N sightseeing spots on the x-axis, each with a corresponding coordinate. It costs |a - b| yen to travel from point a to point b along the axis. You plan to visit all N spots in order, departing from and returning to the origin. Due to time constraints, you may choose to cancel the visit to a specific spot. For each spot, find the total cost of travel when that spot's visit is canceled. Constraints: 2 \u2264 N \u2264 10^5, -5000 \u2264 A_i \u2264 5000 (1 \u2264 i \u2264 N). Input format: N followed by N coordinates. Output format: N lines, each representing the total cost of travel when a specific spot's visit is canceled.", "before_after_length": [118, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u185424824", "n_user": "u185424824", "pos": "N,M = map(int,input().split())\n\nn = min(N,M)\nm = max(N,M)\n\nif n == 1 and m == 1:\n print(1)\n exit()\nif n == 1:\n print(m-2)\n exit()\nprint((n-2)*(m-2))\n", "neg": "N,M = map(int,input().split())\n\nn = min(N,M)\nm = max(N,M)\n\nif n == 1 & m == 1:\n print(1)\n exit()\nif n == 1:\n print(m-2)\n exit()\nprint((n-2)*(m-2))", "jacc_sim": 0.92, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [83, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u416011173", "n_user": "u416011173", "pos": "# -*- coding: utf-8 -*-\n# \u6a19\u6e96\u5165\u529b\u306e\u53d6\u5f97\nN, M = list(map(int, input().split()))\nN, M = min(N, M), max(N, M)\n\n# \u6c42\u89e3\u51e6\u7406\nN, M = min(N, M), max(N, M)\nresult = 0\nif N == 1:\n if M == 1:\n result = 1\n else:\n result = M - 2\nelse:\n result = (N - 2) * (M - 2)\n\n# \u7d50\u679c\u51fa\u529b\nprint(result)\n", "neg": "# -*- coding: utf-8 -*-\n# \u6a19\u6e96\u5165\u529b\u306e\u53d6\u5f97\nN, M = list(map(int, input().split()))\n\n# \u6c42\u89e3\u51e6\u7406\nresult = max((N - 2) * (M - 2), 0)\n\n# \u7d50\u679c\u51fa\u529b\nprint(result)\n", "jacc_sim": 0.9047619047619048, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [175, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u836737505", "n_user": "u362563655", "pos": "n,m = map(int, input().split())\nif n == m== 1:\n print(1)\nelif n == 1 or m == 1:\n print(max(n,m)-2)\nelse:\n print((n-2)*(m-2))", "neg": "N,M = map(int, input().split())\nif N==M==1:\n print(1)\nelif n == 1 or m == 1:\n print(max(N,M)-2)\nelse:\n print((N-2) * (M-2))", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [65, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u241159583", "n_user": "u241159583", "pos": "n, m = map(int, input().split())\nif n != 1 and m != 1:\n ans = (n-2) * (m-2)\nelif n == m == 1:\n ans = 1\nelif n == 1 and m != 1:\n ans = m-2\nelse:\n ans = n-2\nprint(ans)", "neg": "n, m = map(int, input().split())\n\nif n == 1 and m == 1: ans = 1\nelif n == 1 and m != 1: ans = n-2\nelif n != 1 and m == 1: ans = m-2\nelse: ans = (n-2) * (m-2)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [84, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u995062424", "n_user": "u503111914", "pos": "N, M = map(int, input().split())\n\nif(N == 1):\n n = 1\nelse:\n n = N-2\nif(M == 1):\n m = 1\nelse:\n m = M-2\nprint(n*m)", "neg": "N,M = map(int, input().split())\nif n == 1:\n if m == 1:\n print(1)\n else:\n print(m - 2)\nelif m == 1:\n print(n - 2)\nelse: \n print((N-2)*(M-2))\n", "jacc_sim": 0.9545454545454546, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [64, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u189023301", "n_user": "u020962106", "pos": "n,m = map(int, input().split())\nif n == 1 and m==1:\n print(1)\nelif n == 1 or m == 1:\n print(max(n-2, m-2))\nelse:\n print((n-2)*(m-2))", "neg": "n,m=map(int,input().split())\nif n==1 and m==1:\n print(1)\nelif n==1 or M==1:\n print(n*m-2)\nelse:\n print((m-2)*(n-2))\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [69, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u500297289", "n_user": "u170324846", "pos": "N, M = map(int, input().split())\n\nif N == 1 and M == 1:\n print(1)\n exit()\n\nif N == 1 or M == 1:\n print(max(N - 2, M - 2))\nelse:\n print((N - 2) * (M - 2))\n", "neg": "N, M = map(int, input().split())\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n print(max(N, M) - 1)\nelse:\n print((N - 2) * (M - 2))", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [76, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u460245024", "n_user": "u752774573", "pos": "N, M = sorted(list(map(int, input().split())))\nif N == 1 and M == 1:\n\tprint(1)\nelif N == 1 and M > 1:\n\tprint(M-2)\nelse:\n\tprint((N-2)*(M-2))", "neg": "N,M=list(map(int, input().split()))\nif N>1 and M>1:\n print(N*M - (N-2)*(M-2))\nelse:\n print(N*M-2)", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [68, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u614314290", "n_user": "u614314290", "pos": "H, W = map(int, input().split())\n\n\"\"\"\nstage = [[0 for _ in range(W)] for _ in range(H)]\nds = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))\n\ndef setv(p, v):\n\tglobal stage\n\tstage[p[1]][p[0]] = v\n\ndef getv(p):\n\treturn stage[p[1]][p[0]]\n\ndef move(p, d):\n\tr = (p[0] + d[0], p[1] + d[1])\n\tif not (0 <= r[0] < W) or not (0 <= r[1] < H):\n\t\treturn None\n\treturn r\n\nfor h in range(H):\n\tfor w in range(W):\n\t\tfor d in ds:\n\t\t\tnextp = move((w, h), d)\n\t\t\tif not nextp:\n\t\t\t\tcontinue\n\t\t\tsetv(nextp, (getv(nextp) + 1) % 2)\n\t\t\t#setv(nextp, (getv(nextp) + 1))\n\nfor h in range(H):\n\tprint(*stage[h], sep=\"\")\nprint()\n\"\"\"\n\nif 1 == H == W:\n\tprint(1)\n\texit()\n\nif 1 == H and not 1 == W:\n\tprint(W - 2)\n\texit()\n\nif 1 == W and not 1 == H:\n\tprint(H - 2)\n\texit()\n\nprint((H - 2) * (W - 2))\n", "neg": "H, W = map(int, input().split())\nprint((H - 2) * (W - 2))\n\n\"\"\"\nstage = [[0 for _ in range(W)] for _ in range(H)]\nds = ((0, 0), (1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1))\n\ndef setv(p, v):\n\tglobal stage\n\tstage[p[1]][p[0]] = v\n\ndef getv(p):\n\treturn stage[p[1]][p[0]]\n\ndef move(p, d):\n\tr = (p[0] + d[0], p[1] + d[1])\n\tif not (0 <= r[0] < W) or not (0 <= r[1] < H):\n\t\treturn None\n\treturn r\n\nfor h in range(H):\n\tfor w in range(W):\n\t\tfor d in ds:\n\t\t\tnextp = move((w, h), d)\n\t\t\tif not nextp:\n\t\t\t\tcontinue\n\t\t\tsetv(nextp, (getv(nextp) + 1) % 2)\n\t\t\t#setv(nextp, (getv(nextp) + 1))\n\nfor h in range(H):\n\tprint(*stage[h], sep=\"\")\nprint()\n\"\"\"", "jacc_sim": 0.9615384615384616, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [404, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u859897687", "n_user": "u859897687", "pos": "a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelse:\n print((a-2)*(b-2))", "neg": "a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelse:\n print(a+a+b+b-8+(a-2)*(b-2))", "jacc_sim": 0.92, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [67, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u367130284", "n_user": "u859897687", "pos": "a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelif a==2 or b==2:\n print(0)\nelse:\n print(a*b-2*a-2*b+4)\n ", "neg": "a,b=map(int,input().split())\nif a==1 and b==1:\n print(1)\nelif a==1 or b==1:\n print(max(a,b)-2)\nelse:\n print(a+a+b+b-4)", "jacc_sim": 0.9230769230769231, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [91, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u619819312", "n_user": "u060793972", "pos": "n,m=map(int,input().split())\nif n==1 and m==1:\n print(1)\nelif n==1 or m==1:\n print(max(max(n,m)-2,0))\nelse:\n print((n-2)*(m-2))", "neg": "n,m=map(int,input().split())\nif n==2 or m==2:\n print(0)\nelif n==m==1:\n print(1)\nelif n==1 or m==1:\n print(max(n,m)-2)\nelse:\n print((n-2)(m-2))", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [72, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u047668580", "n_user": "u047668580", "pos": "N,M = list(map(int,input().split()))\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n print(max([N,M]) -2)\nelse:\n print( N * M + 4 - 2*(N+M))\n", "neg": "N,N = list(map(int,input().split()))\nif N == 1 and M == 1:\n print(1)\nelif N == 1 or M == 1:\n print(max([N,M]) -2)\nelse:\n print( N * M + 4 - 2*(N+M))\n", "jacc_sim": 1.0, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u807772568", "n_user": "u807772568", "pos": "b = list(map(int,input().split()))\n\nif b[0] == 1 and b[1] == 1:\n\tprint(1)\nelif b[0] == 1:\n\tprint(b[1]-2)\nelif b[1] == 1:\n\tprint(b[0] -2)\n\nelse:\n\tprint(b[0]*b[1] - 2*(b[0] + b[1] - 2))", "neg": "b = list(map(int,input().split()))\n\nif b[0] == 1 and b[1] == 1:\n\tprint(1)\nelif b[0] == 1:\n\tprint(b[1]-2)\nelif b[1] == 1:\n\tprint(b[0] -2)\n\nelse:\n\tprint(b[0]*b[1] - 2(b[0] + b[1] - 2))", "jacc_sim": 1.0, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u364439209", "n_user": "u364439209", "pos": "N, M = map(int, input().split(\" \"))\n\nif M > N:\n tmp = M\n M = N\n N = tmp\n\nif N == 1 and M == 1: print(1)\nelif M == 1: print(N-2)\nelse: print((N-2)*(M-2))", "neg": "N, M = map(int, input().split(\" \"))\n\nif M > N:\n tmp = N\n M = N\n N = tmp\n\nif N == 1 and M == 1: print(1)\nelif M == 1: print(N-2)\nelse: print((N-2)*(M-2))", "jacc_sim": 1.0, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [78, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u341087021", "n_user": "u655048024", "pos": "n, m = map(int,input().split())\n\nif n==1 or m==1:\n if n==1 and m==1:\n print(1)\n else:\n if n == 1:\n print(m-2)\n else:\n print(n-2)\nelse:\n if n == 2 or m == 2:\n print(0)\n else:\n print((n-2)*(m-2))", "neg": "n,m = map(int,input().split())\nif(n==2)or(m==2):\n print(0)\nelif(n==1)or(m==1):\n if(n==1)and(m==1):\n print(1)\n else:\n print(max(0,max(n,m)-2))\nelse:\n print((n-2)*(m-1))", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [108, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u759590494", "n_user": "u759590494", "pos": "N,M = map(int, input().split())\nif M==1 and N==1:\n print(1)\nelif M==1:\n print(N-2)\nelif N==1:\n print(M-2)\nelse:\n print((N-2)*(M-2))\n", "neg": "N,M = map(int, input().split())\n if M==1 and N==1:\n return 1\n elif M==1:\n return N-2\n elif N==1:\n return M-2\n else:\n return (N-2)*(M-2)", "jacc_sim": 0.9090909090909091, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [75, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u314057689", "n_user": "u314057689", "pos": "def solve():\n N, M = map(int, input().split())\n\n if N == 1 and M == 1:\n print(1)\n return\n\n if N == 1:\n print(M-2)\n return\n\n if M == 1:\n print(N-2)\n return\n\n print((N-2) * (M-2))\n\n\nif __name__ == \"__main__\":\n solve()\n\n\n", "neg": "def solve():\n N, M = map(int, input().split())\n\n if N == 1:\n print(N-2)\n return\n\n if M == 1:\n print(M-2)\n return\n\n print((N-2) * (M-2))\n\n\nif __name__ == \"__main__\":\n solve()\n\n", "jacc_sim": 0.96, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [110, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u665415433", "n_user": "u046158516", "pos": "N,M = map(int,input().split())\nif N == M and N == 1:\n print(1)\nelif min(N,M) == 1:\n print(max(N,M)-2)\nelif min(N,M) == 2:\n print(0)\nelse:\n print((N-2)*(M-2))\n", "neg": "N,M=map(int,input().split())\nif N==1:\n if M==1:\n print(1)\n else:\n print(M-2)\nelif M==1:\n print(N-2)\nelse:\n print(N*M-max(0,N-2)-max(0,M-2))", "jacc_sim": 0.9166666666666666, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [87, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u743272507", "n_user": "u185896732", "pos": "n,m = map(int,input().split())\nif n>m: n,m = m,n\nif n== 1:\n if m==1:\n print(1)\n else:\n print(m-2)\nelif n== 2:\n print(0)\nelse:\n print((n-2)*(m-2))\n", "neg": "n,m=map(int,input().split())\nif n>m:\n n,m=m,n\nif n==1 and m==1:\n print(1)\nelif n==1:\n print(2)\nelse:\n print((n-2)*(m-2))", "jacc_sim": 0.9130434782608695, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [86, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03419", "p_user": "u792078574", "n_user": "u759590494", "pos": "N, M = map(int, input().split())\nif N == M == 1:\n print(1)\nelif N == 1:\n print(M-2)\nelif M == 1:\n print(N-2)\nelse:\n print((N-2)*(M-2))", "neg": "N,M = map(int, input().split())\n if M==1 and N==1:\n print(1)\n elif M==1:\n print(N-2)\n elif N==1:\n print(M-2)\n else:\n print((N-2)*(M-2))\n", "jacc_sim": 0.9523809523809523, "nl": "You are given a grid with infinitely many rows and columns. In this grid, there is a rectangular region with consecutive N rows and M columns, and a card is placed in each square in this region. The front and back sides of these cards can be distinguished, and initially, every card faces up. For each square containing a card, you will flip the card and its neighboring eight cards. The order of operations does not affect the final result. Find the number of cards that face down after all the operations. Constraints: 1 \u2264 N, M \u2264 10^9. Input is given as N and M, and you need to output the number of cards that face down after all the operations. Example inputs and outputs are provided.", "before_after_length": [72, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03422", "p_user": "u490642448", "n_user": "u490642448", "pos": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(readline())\ndata = list(map(int,read().split()))\n\ndef calc_g(x,k):\n while(x>=k):\n if(x%k==0):\n return x//k\n fn = x//k\n x1 = x - (fn + 1)\n x2 = fn*k + (x%k)%(fn+1)\n x = min(x1,x2)\n return 0\n\ngrundy = 0\nit = iter(data)\nfor a,k in zip(it,it):\n grundy = grundy ^ calc_g(a,k)\n\nif(grundy==0):\n print('Aoki')\nelse:\n print('Takahashi')", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nn = int(readline())\ndata = list(map(int,read().split()))\n\ndef calc_g(x,k):\n while(x>=k):\n if(x%k==0):\n return x//k\n fn = x//k\n x1 = x - fn + 1\n x2 = fn*k + (x%k)%(fn+1)\n x = min(x1,x2)\n return 0\n\ngrundy = 0\nit = iter(data)\nfor a,k in zip(it,it):\n grundy = grundy ^ calc_g(a,k)\n\nif(grundy==0):\n print('Aoki')\nelse:\n print('Takahashi')", "jacc_sim": 1.0, "nl": "In a stone-taking game, Takahashi and Aoki take turns removing stones from piles. Each pile has a specific number of stones and an associated integer. Players can remove a certain number of stones from a pile based on its associated integer. The first player unable to make a move loses. Given optimal play, determine the winner. Constraints: 1 \u2264 N \u2264 200, 1 \u2264 A_i, K_i \u2264 10^9. Input format: N, A_1, K_1, ..., A_N, K_N. Output \"Takahashi\" if Takahashi wins, \"Aoki\" if Aoki wins. Examples: (1) 2 piles with 5 stones, associated with 2, and 3 stones, associated with 3. Aoki wins. (2) 3 piles with 3, 4, and 5 stones, associated with 2, 3, and 1. Takahashi wins. (3) 3 piles with 28, 16, and 19 stones, associated with 3, 4, and 2. Aoki wins. (4) 4 piles with specific stone counts and associated integers. Takahashi wins.", "before_after_length": [224, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03422", "p_user": "u499381410", "n_user": "u499381410", "pos": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\nfrom operator import mul\nfrom functools import reduce\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 13\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 10 ** 9 + 7\n\n\n\ndef solve(n, k):\n if n % k == 0:\n return n // k\n diff = (n // k) + 1\n target = n - n % k\n if (n - target) % diff == 0:\n return solve(target, k)\n n -= -((-(n - target)) // diff) * diff\n return solve(n, k)\n\n\nn = I()\nret = 0\nfor i in range(n):\n a, k = LI()\n ret ^= solve(a, k)\n\nprint(\"Takahashi\" if ret else \"Aoki\")", "neg": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\nfrom operator import mul\nfrom functools import reduce\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 13\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 10 ** 9 + 7\n\n\n\ndef solve(n, k):\n if n % k == 0:\n return n // k\n diff = (n // k) + 1\n target = n - n % k\n r = n % k\n if r % diff == 0:\n return solve(n - r, k)\n n -= r // diff * diff\n return solve(n, k)\n\n\nn = I()\nret = 0\nfor i in range(n):\n a, k = LI()\n ret ^= solve(a, k)\n\nprint(\"Takahashi\" if ret else \"Aoki\")\n", "jacc_sim": 0.9894736842105263, "nl": "In a stone-taking game, Takahashi and Aoki take turns removing stones from piles. Each pile has a specific number of stones and an associated integer. Players can remove a certain number of stones from a pile based on its associated integer. The first player unable to make a move loses. Given optimal play, determine the winner. Constraints: 1 \u2264 N \u2264 200, 1 \u2264 A_i, K_i \u2264 10^9. Input format: N, A_1, K_1, ..., A_N, K_N. Output \"Takahashi\" if Takahashi wins, \"Aoki\" if Aoki wins. Examples: (1) 2 piles with 5 stones, associated with 2, and 3 stones, associated with 3. Aoki wins. (2) 3 piles with 3, 4, and 5 stones, associated with 2, 3, and 1. Takahashi wins. (3) 3 piles with 28, 16, and 19 stones, associated with 3, 4, and 2. Aoki wins. (4) 4 piles with specific stone counts and associated integers. Takahashi wins.", "before_after_length": [459, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03422", "p_user": "u677523557", "n_user": "u677523557", "pos": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nAK = [list(map(int, input().split())) for _ in range(N)]\n# N = 40\n# AK = [(i+1, 4) for i in range(N)]\n\ndef grundy(A, K):\n if K == 1:\n return A\n X = (A+K-1)//K\n num = X*K - A\n while X*K-num > K*K:\n #print(X, num)\n if num%K == 0:\n return X - num//K\n if num//K == X//K:\n num = num%K\n else:\n num = X%K+1 + (K-1)*(num//K) + (num%K-1)\n X = X - X//K\n \n S = X*K - num\n while S >= K:\n if S%K == 0:\n return S//K\n delta = S//K + 1\n S -= max(((S%K)//delta)*delta, delta)\n return 0\n \ng = 0\nfor A, K in AK:\n # print(A, A//K, grundy(A, K))\n # print()\n g ^= grundy(A, K)\n\nprint(\"Takahashi\" if g else \"Aoki\")", "neg": "import sys\ninput = sys.stdin.readline\n\nN = int(input())\nAK = [list(map(int, input().split())) for _ in range(N)]\n# N = 25\n# AK = [(i+1, 3) for i in range(N)]\n\ndef grundy(A, K):\n if K == 1:\n return A\n X = (A+K-1)//K\n num = X*K - A\n while X*K-num > K*K:\n if num%K == 0:\n return X - num//K\n if num//K == X//K:\n num = (num%K-1)\n else:\n num = X%K+1 + (K-1)*(num//K) + (num%K-1)\n X = X - X//K\n \n S = X*K - num\n while S >= K:\n if S%K == 0:\n return S//K\n delta = S//K + 1\n S -= ((S%K)//delta)*delta\n return 0\n \ng = 0\nfor A, K in AK:\n #print(A, grundy(A, K))\n #print()\n g ^= grundy(A, K)\n\nprint(\"Takahashi\" if g else \"Aoki\")", "jacc_sim": 0.9107142857142857, "nl": "In a stone-taking game, Takahashi and Aoki take turns removing stones from piles. Each pile has a specific number of stones and an associated integer. Players can remove a certain number of stones from a pile based on its associated integer. The first player unable to make a move loses. Given optimal play, determine the winner. Constraints: 1 \u2264 N \u2264 200, 1 \u2264 A_i, K_i \u2264 10^9. Input format: N, A_1, K_1, ..., A_N, K_N. Output \"Takahashi\" if Takahashi wins, \"Aoki\" if Aoki wins. Examples: (1) 2 piles with 5 stones, associated with 2, and 3 stones, associated with 3. Aoki wins. (2) 3 piles with 3, 4, and 5 stones, associated with 2, 3, and 1. Takahashi wins. (3) 3 piles with 28, 16, and 19 stones, associated with 3, 4, and 2. Aoki wins. (4) 4 piles with specific stone counts and associated integers. Takahashi wins.", "before_after_length": [341, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03422", "p_user": "u132350318", "n_user": "u132350318", "pos": "def main():\n n = int(input())\n res = 0\n for (a, k) in [map(int, input().split()) for _ in range(n)]:\n while a >= k:\n m = a // k\n if a % k == 0:\n res ^= m\n break\n x = (a - k * m - 1) // (m + 1)\n a -= max(1, x) * (m + 1)\n print('Takahashi' if res != 0 else 'Aoki')\n\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n n = int(input())\n res = 0\n\n for (a, k) in [[int(x) for x in input().split()] for _ in range(n)]:\n while a >= k:\n m, u = a // k, (a - k * m)\n if a % k == 0 or (a % k) % (m + 1) == 0:\n res ^= m\n break\n x = u // (m + 1)\n a -= (x + 1) * (m + 1)\n\n print('Takahashi' if res != 0 else 'Aoki')\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9148936170212766, "nl": "In a stone-taking game, Takahashi and Aoki take turns removing stones from piles. Each pile has a specific number of stones and an associated integer. Players can remove a certain number of stones from a pile based on its associated integer. The first player unable to make a move loses. Given optimal play, determine the winner. Constraints: 1 \u2264 N \u2264 200, 1 \u2264 A_i, K_i \u2264 10^9. Input format: N, A_1, K_1, ..., A_N, K_N. Output \"Takahashi\" if Takahashi wins, \"Aoki\" if Aoki wins. Examples: (1) 2 piles with 5 stones, associated with 2, and 3 stones, associated with 3. Aoki wins. (2) 3 piles with 3, 4, and 5 stones, associated with 2, 3, and 1. Takahashi wins. (3) 3 piles with 28, 16, and 19 stones, associated with 3, 4, and 2. Aoki wins. (4) 4 piles with specific stone counts and associated integers. Takahashi wins.", "before_after_length": [144, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u519923151", "n_user": "u519923151", "pos": "h,w,d = map(int, input().split())\n\ndp= [0]*(h*w+1)\n\nab = [list(map(int, input().split())) for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n s = ab[i][j]\n dp[s] =[i,j]\n \ndpp= [0]*(h*w+1)\n\nfor k in range(d+1,h*w+1):\n# print(k)\n dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])\n \nq = int(input())\n\nfor x in range(q):\n a,b = map(int, input().split())\n print(dpp[b]-dpp[a])", "neg": "h,w,d = map(int, input().split())\n\ndp= [0]*(h*w+1)\n\nab = [list(map(int, input().split())) for _ in range(h)]\n\nfor i in range(w):\n for j in range(h):\n s = ab[i][j]\n dp[s] =[i,j]\n \ndpp= [0]*(h*w+1)\n\nfor k in range(d+1,h*w+1):\n# print(k)\n dpp[k] = dpp[k-d] + abs(dp[k][0]-dp[k-d][0]) +abs(dp[k][1]-dp[k-d][1])\n \nq = int(input())\n\nfor x in range(q):\n a,b = map(int, input().split())\n print(dpp[b]-dpp[a])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [229, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u263830634", "n_user": "u263830634", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 9)\nMOD = 10 ** 9 + 7\n\nfrom collections import defaultdict\n\nH, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(H)]\n\ndic = defaultdict(list)\n\nfor h in range(H):\n for w in range(W):\n dic[A[h][w]] = [h, w]\n\ndef calc(l, r):\n return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])\n\nlst = [0] * (H * W + 1)\nfor d in range(1, D + 1):\n tmp = d\n while tmp + D <= (H * W):\n lst[tmp + D] = lst[tmp] + calc(tmp, tmp + D)\n tmp += D\n\n# print (lst)\nQ = int(input())\nfor _ in range(Q):\n L, R = map(int, input().split())\n ans = lst[R] - lst[L]\n print (ans)\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 9)\nMOD = 10 ** 9 + 7\n\nfrom collections import defaultdict\n\nH, W, D = map(int, input().split())\nA = [list(map(int, input().split())) for _ in range(H)]\n\ndic = defaultdict(list)\n\nfor h in range(W):\n for w in range(W):\n dic[A[h][w]] = [h, w]\n\ndef calc(l, r):\n return abs(dic[l][0] - dic[r][0]) + abs(dic[l][1] - dic[r][1])\n\nlst = [0] * (H * W + 1)\nfor d in range(1, D + 1):\n tmp = d\n while tmp + D <= (H * W):\n lst[tmp + D] = lst[tmp] + calc(tmp, tmp + D)\n tmp += D\n\n# print (lst)\nQ = int(input())\nfor _ in range(Q):\n L, R = map(int, input().split())\n ans = lst[R] - lst[L]\n print (ans)\n", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [287, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u827951256", "n_user": "u827951256", "pos": "n,m,d = map(int, input().split())\n\ngrid = []\n\nbuf = {}\n\nfor j in range(n):\n grid.append(list(map(int, input().split())))\n for k in range(len(grid[j])):\n buf[grid[j][k]] = (j,k)\nq = int(input())\nal = []\n\ncost = [0] * ((n*m)+1)\n\nfor i in range(d+1,n*m+1):\n cost[i] = cost[i-d] + abs(buf[i-d][0] - buf[i][0]) + abs(buf[i-d][1] - buf[i][1])\n\nfor _ in range(q):\n l,r = map(int, input().split())\n al.append([l,r])\n \n\nfor l,r in al:\n print(cost[r]-cost[l])\n \n \n", "neg": "n,m,d = map(int, input().split())\n\ngrid = []\n\nbuf = {}\n\nfor j in range(n):\n grid.append(list(map(int, input().split())))\n for k in range(len(grid[j])):\n buf[grid[j][k]] = (j,k)\nq = int(input())\nal = []\n\ncost = [0] * ((n*m)+1)\n\nfor i in range(d+1,n*m):\n cost[i] = cost[i-d] + abs(buf[i-d][0] - buf[i][0]) + abs(buf[i-d][1] - buf[i][1])\nprint(cost)\nfor _ in range(q):\n l,r = map(int, input().split())\n al.append([l,r])\n \n\nfor l,r in al:\n print(cost[r]-cost[l])\n \n \n", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [234, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u595289165", "n_user": "u595289165", "pos": "import numpy as np\nimport sys\ninput = sys.stdin.readline\nh, w, d = map(int, input().split())\nnum = h * w\nmass = np.array([(0, 0) for _ in range(num + 1)])\nmp = np.zeros(num+1)\nfor i in range(1, h+1):\n for j, a in enumerate(map(int, input().split())):\n mass[a] = [i, j+1]\nfor i in range(d+1, num+1):\n mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))\nq = int(input())\nfor _ in range(q):\n l, r = map(int, input().split())\n print(int(mp[r]-mp[l]))\n", "neg": "import numpy as np\nimport sys\ninput = sys.stdin\nh, w, d = map(int, input().split())\nnum = h * w\nmass = np.array([[0, 0] for _ in range(num + 1)])\nmp = np.zeros(num+1, dtype=int)\nfor i in range(h):\n for j, a in enumerate(list(map(int, input().split()))):\n mass[a] += [i, j]\nfor i in range(d+1, num+1):\n mp[i] = mp[i-d] + np.sum(abs(mass[i]-mass[i-d]))\nq = int(input())\nfor _ in range(q):\n l, r = map(int, input().split())\n print(mp[r]-mp[l])\n", "jacc_sim": 0.9375, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [205, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u798818115", "n_user": "u798818115", "pos": "# coding: utf-8\n# Your code here!\n#\u9014\u4e2d\n\nH,W,D=map(int,input().split())\n\nA=[]\nfor i in range(H):\n A.append(list(map(int,input().split())))\n\nloc=[[0,0] for i in range(W*H)]\n\n#print(loc)\n\nfor i in range(H):\n for j in range(W):\n loc[A[i][j]-1][0]=i\n loc[A[i][j]-1][1]=j\n #print(loc)\n#print(loc)\n\ncost=[[0]*((H*W)//D) for i in range(D)]\n\nfor i in range((H*W)%D):\n cost[i].append(0)\n\nfor i in range(D):\n pass\n count=1\n temp=i\n while temp+D<(H*W):\n temp=i+D*count\n cost[temp%D][temp//D]=abs(loc[temp][0]-loc[temp-D][0])+abs(loc[temp][1]-loc[temp-D][1])+cost[temp%D][temp//D-1]\n count+=1\n #print(cost)\ncost[-1]=[0]+cost[-1]\n\nQ=int(input())\nfor _ in range(Q):\n x,y=map(int,input().split())\n #print(cost[x%D-1][x//D-1])\n print(cost[y%D-1][y//D]-cost[x%D-1][x//D])\n\n#print(cost)\n\n", "neg": "# coding: utf-8\n# Your code here!\n#\u9014\u4e2d\n\nH,W,D=map(int,input().split())\n\nA=[]\nfor i in range(H):\n A.append(list(map(int,input().split())))\n\nloc=[[0,0] for i in range(W*H)]\n\n#print(loc)\n\nfor i in range(H):\n for j in range(W):\n loc[A[i][j]-1][0]=i\n loc[A[i][j]-1][1]=j\n #print(loc)\nprint(loc)\n\ncost=[[0]*((H*W)//D) for i in range(D)]\n\nfor i in range((H*W)%D):\n cost[i].append(0)\n\nfor i in range(D):\n pass\n count=1\n temp=0\n while temp<(H*W):\n temp=i+D*count\n cost[temp%D][temp//D]=abs(loc[temp][0]-loc[temp-D][0])+abs(loc[temp][1]-loc[temp-D][1])+cost[temp%D][temp//D-1]\n count+=1\n\nprint(cost)\n\n", "jacc_sim": 0.9245283018867925, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [418, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u346308892", "n_user": "u346308892", "pos": "\n#import numpy as np\n\n\ndef acinput():\n return list(map(int, input().split(\" \")))\n\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\nH, W, D = acinput()\n# Ad={}\nAd = [0]*(H*W+1)\nfor i in range(H):\n ar = acinput()\n for j, sar in enumerate(ar):\n # Ad[sar]=np.array((i,j))\n Ad[sar] = (i, j)\n\n#dp = [[0 for j in range(H*W+1)]for i in range(H*W+1)]\nd = [0]*(H*W+1)\n\n# for x in range(1, H*W+1):\n# dp[x][x]=0\n\ny = D+1\nwhile True:\n if y > H*W:\n break\n # print(x,y)\n #tmp = Ad[y]-Ad[y-D]\n #S = np.sum(np.abs(tmp[0])+abs(tmp[1]))\n #tmp = Ad[y]-Ad[y-D]\n S = abs(Ad[y][0]-Ad[y-D][0])+abs(Ad[y][1]-Ad[y-D][1])\n\n # dp[x][y]=dp[x][y-D]+S\n d[y] = d[y-D]+S\n y += 1\n\n\n# print(np.array(dp))\n\nQ = int(input())\nfor i in range(Q):\n l, r = acinput()\n print(d[r]-d[l])\n\n\n# print(Ad)\n# print(np.array(dp))\n#print(d)", "neg": "\n#import numpy as np\n\n\ndef acinput():\n return list(map(int, input().split(\" \")))\n\n\nmod = 10**9+7\n\n\ndef factorial(n):\n fact = 1\n for integer in range(1, n + 1):\n fact *= integer\n return fact\n\n\nH, W, D = acinput()\n# Ad={}\nAd = [0]*(H*W+1)\nfor i in range(H):\n ar = acinput()\n for j, sar in enumerate(ar):\n # Ad[sar]=np.array((i,j))\n Ad[sar] = (i, j)\n\n#dp = [[0 for j in range(H*W+1)]for i in range(H*W+1)]\nd = [0]*(H*W+1)\n\n# for x in range(1, H*W+1):\n# dp[x][x]=0\n\ny = D+1\nwhile True:\n if y > H*W:\n break\n # print(x,y)\n #tmp = Ad[y]-Ad[y-D]\n #S = np.sum(np.abs(tmp[0])+abs(tmp[1]))\n #tmp = Ad[y]-Ad[y-D]\n S = abs(Ad[y][0]-Ad[y-D][0])+abs(Ad[y][1]-Ad[y-D][1])\n\n # dp[x][y]=dp[x][y-D]+S\n d[y] = d[y-D]+S\n y += 1\n\n\n# print(np.array(dp))\n\nQ = int(input())\nfor i in range(Q):\n l, r = acinput()\n print(d[r]-d[l])\n\n\n# print(Ad)\n# print(np.array(dp))\nprint(d)", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [469, 468], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u691896522", "n_user": "u691896522", "pos": "import math\nh, w, d = list(map(int, input().split()))\ngrid = []\nnum = [[] for i in range(h*w+1)]\nfor i in range(h):\n grid.append(list(map(int, input().split())))\nfor i in range(h):\n for j in range(w):\n num[grid[i][j]]=[j+1, i+1]\nk = math.ceil((h*w+1) / d)\n#initialize\ncost = [[0 for i in range(k)] for j in range(d)]\nfor i in range(d + 1,h*w+1):\n x, y = num[i]\n prex, prey = num[i - d]\n cost[i % d][i//d] = abs(prex - x) + abs(prey - y)\n cost[i % d][i//d] += cost[i % d][(i - d)// d]\nq = int(input())\nfor i in range(q):\n l, r = map(int, input().split())\n print(cost[r%d][r//d] - cost[l%d][l//d])\n", "neg": "import math\nh, w, d = list(map(int, input().split()))\ngrid = []\nnum = [[] for i in range(h*w+1)]\nfor i in range(h):\n grid.append(list(map(int, input().split())))\nfor i in range(h):\n for j in range(w):\n num[grid[i][j]]=[j+1, i+1]\nk = math.ceil((h*w+1) / d)\n#initialize\ncost = [[0 for i in range(k)] for j in range(d)]\nfor i in range(d + 1,h*w+1):\n x, y = num[i]\n prex, prey = num[i - d]\n cost[i % d][i//d] = abs(prex - x) + abs(prey - y)\n cost[i % d][i//d] += cost[i % d][(i - d)// d]\nprint(cost) \nq = int(input())\nfor i in range(q):\n l, r = map(int, input().split())\n print(cost[r%d][r//d] - cost[l%d][l//d])\n", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [290, 296], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nH, W, D = lr()\nA = [lr() for _ in range(H)]\nQ = ir()\ngrid = [None] * (H*W + 1) # 1-indexed\nfor i in range(H):\n for j in range(W):\n grid[A[i][j]] = (i, j)\n\nnext_D = [0] * (H*W + 1)\nfor i in range(1+D, H*W + 1):\n next_D[i] = abs(grid[i][0] - grid[i-D][0]) + abs(grid[i][1] - grid[i-D][1])\n next_D[i] += next_D[i-D]\n\nfor i in range(Q):\n l, r = lr()\n answer = next_D[r] - next_D[l]\n print(answer)\n\n# 49\n", "neg": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nH, W, D = lr()\nA = [lr() for _ in range(H)]\nQ = ir()\ngrid = [None] * (H*W + 1) # 1-indexed\nfor i in range(H):\n for j in range(W):\n grid[A[i][j]] = (i, j)\n\nnext_D = [0] * (H*W + 1)\nfor i in range(1, H*W + 1 - D):\n next_D[i] = abs(grid[i+D][0] - grid[i][0]) + abs(grid[i+D][1] - grid[i][1])\n\njump = [[0] * (H*W + 1) for i in range(H*W + 1)]\nfor i in range(1, H*W + 1 - D):\n for j in range(i+D, H*W + 1 - D, D):\n jump[i][j] = next_D[j-D]\n if j-D > i:\n jump[i][j] += jump[i][j-D]\n\n#print(next_D)\n#print(jump)\nfor i in range(Q):\n l, r = lr()\n answer = jump[l][r]\n print(answer)\n\n# 49\n", "jacc_sim": 0.9411764705882353, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [261, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u037430802", "n_user": "u037430802", "pos": "h,w,d = map(int, input().split())\n\na = [[0 for _ in range(w)] for _ in range(h)]\nmasu = {}\nfor i in range(h):\n a[i] = list(map(int, input().split()))\n for j in range(w):\n masu[a[i][j]] = (i,j)\n\npoint = [0] * (h*w+10)\nfor i in range(d+1,h*w+1):\n point[i] = point[i-d] + abs(masu[i][0] - masu[i-d][0]) + abs(masu[i][1] - masu[i-d][1])\n\n\nq = int(input())\nans = [0] * q\nfor i in range(q):\n l, r = map(int, input().split())\n if l == r:\n ans[i] = 0\n else:\n ans[i] = point[r] - point[l]\n \nfor i in range(q):\n print(ans[i])\n", "neg": "h,w,d = map(int, input().split())\n\na = [[0 for _ in range(w)] for _ in range(h)]\nmasu = {}\nfor i in range(h):\n a[i] = list(map(int, input().split())\n for j in range(w):\n masu[a[i][j]] = (i,j)\n\"\"\"\nmasu = {}\nfor i in range(h):\n for j in range(w):\n masu[a[i][j]] = (i,j)\n\"\"\"\npoint = [0] * (h*w)\nfor i in range(1,h*w-d+1):\n point[i] = abs(masu[i][0] - masu[i+d][0]) + abs(masu[i][1] - masu[i+d][1])\n\n\nq = int(input())\nans = [0] * q\nfor i in range(q):\n l, r = map(int, input().split())\n if l == r:\n ans[i] = 0\n else:\n ans[i] = sum(point[l:r:d])\n \nfor i in range(q):\n print(ans[i])\n", "jacc_sim": 0.9302325581395349, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [268, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u046187684", "n_user": "u046187684", "pos": "from functools import partial\nfrom itertools import islice\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\ndef chunked(iterable, n):\n return iter(partial(take, n, iter(iterable)), [])\n\n\ndef distance(x, y):\n return abs(x[0] - y[0]) + abs(x[1] - y[1])\n\n\ndef solve(s):\n h, w, d, *aqlr = map(int, s.split())\n a, q, lr = aqlr[:h * w], aqlr[h * w], aqlr[h * w + 1:]\n n = h * w\n pos = [0] * (n + 1)\n for i, _a in enumerate(a):\n pos[_a] = (i // w, i % w)\n cost = [0] * (n + 1)\n for i in range(d + 1, n + 1):\n cost[i] = cost[i-d]+distance(pos[i - d], pos[i])\n ans = []\n for l, r in chunked(lr, 2):\n ans.append(\"%d\" % (cost[r] - cost[l]))\n return \"\\n\".join(ans)\n\n\nn, m, d = map(int, input().split())\nl = '{} {} {}\\n'.format(n, m, d) + '\\n'.join([input() for _ in range(n)])\nq, = map(int, input().split())\nl += '\\n{}\\n'.format(q) + '\\n'.join([input() for _ in range(q)])\nprint(solve(l))\n", "neg": "from functools import partial\nfrom itertools import islice\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\ndef chunked(iterable, n):\n return iter(partial(take, n, iter(iterable)), [])\n\n\ndef distance(x, y):\n return abs(x[0] - y[0]) + abs(x[1] - y[1])\n\n\ndef solve(s):\n h, w, d, *aqlr = map(int, s.split())\n n = h * w\n pos = [(i // w, i % w) for i, _a in enumerate(aqlr[:n])]\n cost = [0] * (n + 1)\n for i in range(d + 1, n + 1):\n cost[i] = cost[i - d] + distance(pos[i - d], pos[i])\n return \"\\n\".join([\"%d\" % (cost[r] - cost[l]) for l, r in chunked(aqlr[n + 1:], 2)])\n\n\nn, m, d = map(int, input().split())\nl = '{} {} {}\\n'.format(n, m, d) + '\\n'.join([input() for _ in range(n)])\nq, = map(int, input().split())\nl += '\\n{}\\n'.format(q) + '\\n'.join([input() for _ in range(q)])\nprint(solve(l))\n", "jacc_sim": 0.9411764705882353, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [405, 353], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u017810624", "n_user": "u017810624", "pos": "h,w,d=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(h)]\nL=[0 for i in range(h*w)]\nfor i in range(h):\n for j in range(w):\n L[l[i][j]-1]=[i,j]\n\nsumL=[0 for i in range(h*w+1)]\nfor i in range(h*w):\n if i>=d:\n sumL[i+1]=sumL[i+1-d]+abs(L[i][0]-L[i-d][0])+abs(L[i][1]-L[i-d][1])\n\nq=int(input())\nQL=[list(map(int,input().split())) for i in range(q)]\nfor i in range(q):\n print(sumL[QL[i][1]]-sumL[QL[i][0]])", "neg": "h,w,d=map(int,input().split())\nl=[list(map(int,input().split())) for i in range(h)]\nL=[0 for i in range(h*w)]\nfor i in range(h):\n for j in range(w):\n L[l[i][j]-1]=[i,j]\n\nsumL=[0 for i in range(h*w+1)]\nfor i in range(h*w):\n if i>=d:\n sumL[i+1]=sumL[i+1-d]+abs(L[i][0]-L[i-d][0])+abs(L[i][1]-L[i-d][1])\nprint(sumL)\nq=int(input())\nQL=[list(map(int,input().split())) for i in range(q)]\nfor i in range(q):\n print(sumL[QL[i][1]]-sumL[QL[i][0]])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [233, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u343523393", "n_user": "u343523393", "pos": "import sys\nimport math\nimport numpy as np\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, input().split()))\nns = lambda: input()\nH,W,D = na()\nf= [list(map(int,input().split())) for i in range(H)]\n#print(f)\nf = np.array(f)\nQ=int(input())\n'''\nli = [0]*(H*W+2)\nfor i in range(1,D+1):\n li[i]=0\n h_=int(np.where(f==i)[0])\n w_=int(np.where(f==i)[1])\n for j in range(i+D,H*W+1,D):\n h_n=int(np.where(f==j)[0])\n w_n=int(np.where(f==j)[1])\n li[j] = li[j-D]+abs(h_ - h_n)+abs(w_ - w_n)\n h_ = h_n\n w_ = w_n\nfor i in range(Q):\n L,R = na()\n print(li[R]-li[L])\n'''\n\nli ={}\nfor i in range(H):\n for j in range(W):\n li[f[i][j]]=[i+1,j+1]\nres=[0]*(H*W+1)\nfor i in range(1,D+1):\n for j in range(i+D,W*H+1,D):\n #print(\"j\",j)\n #print(li[j][0],li[j][1])\n res[j] = res[j-D] +abs(li[j-D][0]-li[j][0]) + abs(li[j-D][1]-li[j][1])\n#print(res)\nfor i in range(Q):\n L,R = na()\n print(res[R]-res[L])\n", "neg": "import sys\nimport math\nimport numpy as np\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, input().split()))\nns = lambda: input()\nH,W,D = na()\nf= [list(map(int,input().split())) for i in range(H)]\n#print(f)\nf = np.array(f)\nQ=int(input())\n'''\nli = [0]*(H*W+2)\nfor i in range(1,D+1):\n li[i]=0\n h_=int(np.where(f==i)[0])\n w_=int(np.where(f==i)[1])\n for j in range(i+D,H*W+1,D):\n h_n=int(np.where(f==j)[0])\n w_n=int(np.where(f==j)[1])\n li[j] = li[j-D]+abs(h_ - h_n)+abs(w_ - w_n)\n h_ = h_n\n w_ = w_n\nfor i in range(Q):\n L,R = na()\n print(li[R]-li[L])\n'''\n\nli ={}\nfor i in range(H):\n for j in range(W):\n li[f[i][j]]=[i,j]\nres=[0]*(H*W+1)\nfor i in range(1,D+1):\n for j in range(i+D,W*H+1,D):\n res[j] += abs(li[j-D][0]-li[j][0]) + abs(li[j-D][1]-li[j][1])\n\nfor i in range(Q):\n L,R = na()\n print(res[R]-res[L])\n", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [500, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u175034939", "n_user": "u175034939", "pos": "h,w,d = map(int,input().split())\nhw = [[] for _ in range(h*w+1)]\nfor i in range(h):\n row = list(map(int,input().split()))\n for j in range(w):\n hw[row[j]] = [i,j]\n \na = [0 for _ in range(h*w+1)]\nfor i in range(d+1,h*w+1):\n a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])\n \nq = int(input())\nfor i in range(q):\n L,R = map(int,input().split())\n print(a[R] - a[L])", "neg": "h,w,d = map(int,input().split())\nhw = [[] for _ in range(h*w+1)]\nhw[0] = [0,0]\nfor i in range(h):\n row = list(map(int,input().split()))\n for j in range(w):\n hw[row[j]] = [i,j]\nprint(hw)\n\na = [0 for _ in range(h*w+1)]\nfor i in range(d+1,h*w+1):\n a[i] = a[i-d] + abs(hw[i][0] - hw[i-d][0]) + abs(hw[i][1] - hw[i-d][1])\n\nq = int(input())\nfor i in range(q):\n L,R = map(int,input().split())\n print(a[R] - a[L])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [203, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u201234972", "n_user": "u210827208", "pos": "H, W, D = map( int, input().split())\nA = [ list( map( int, input().split())) for _ in range(H)]\nP = [(0,0)]*(H*W+1)\nfor i in range(H):\n for j in range(W):\n P[A[i][j]] = (i,j)\nd = [0]*(H*W+1)\nfor i in range(D+1,H*W+1):\n d[i] = d[i-D] + abs(P[i][0] - P[i-D][0]) + abs(P[i][1] - P[i-D][1])\nQ = int( input())\nfor _ in range(Q):\n L, R = map( int, input().split())\n print(d[R]-d[L])", "neg": "H,W,D=map(int,input().split())\nA=[list(map(int,input().split())) for _ in range(H)]\nQ=int(input())\nX=[[0,0] for _ in range(H*W)]\nfor i in range(H):\n for j in range(W):\n X[A[i][j]][0]=i\n X[A[i][j]][1]=j\nM=[0]*(H*W+1)\nfor d in range(D+1,H*W+1):\n M[d]=abs(X[d][0]-X[d-D][0])+abs(X[d][1]-X[d-D][1])+M[d-D]\n\nfor i in range(Q):\n L,R=map(int,input().split())\n print(M[R]-M[L])", "jacc_sim": 0.918918918918919, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [206, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u536113865", "n_user": "u536113865", "pos": "ai = lambda: list(map(int, input().split()))\n\nh,w,d = ai()\nph = [0 for _ in range(h*w + 1)]\npw = [0 for _ in range(h*w + 1)]\n\nfor i in range(h):\n a = ai()\n for j in range(w):\n ph[a[j]] = i\n pw[a[j]] = j\n\n\nscore = [0 for _ in range(h*w + 1)]\nfor i in range(d+1, h*w+1):\n score[i] = score[i-d] + abs(ph[i]-ph[i-d]) + abs(pw[i]-pw[i-d])\n\n\nq = int(input())\nfor _ in range(q):\n l,r = ai()\n print(score[r]-score[l])\n\n", "neg": "ai = lambda: list(map(int, input().split()))\n\nh,w,d = ai()\nph = [0 for _ in range(h*w + 1)]\npw = [0 for _ in range(h*w + 1)]\n\nfor i in range(h):\n a = ai()\n for j in range(w):\n ph[a[j]] = i\n pw[a[j]] = j\n\n\nscore = [0 for _ in range(h*w + 1)]\nfor i in range(d+1, h*w+1):\n score[i] = score[i-d] + abs(ph[i]-ph[i-d]) + abs(pw[i]-pw[i-d])\n\nprint(score)\n\nq = int(input())\nfor _ in range(q):\n l,r = ai()\n print(score[r]-score[l])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [216, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u474270503", "n_user": "u474270503", "pos": "H, W, D=map(int, input().split())\npos={}\nfor i in range(H):\n A=list(map(int, input().split()))\n for j in range(W):\n pos[A[j]]=(i, j)\np=[0]*(H*W+1)\nfor i in range(D+1,H*W+1):\n p[i]=p[i-D]+abs(pos[i][0]-pos[i-D][0])+abs(pos[i][1]-pos[i-D][1])\nQ=int(input())\nfor _ in range(Q):\n L, R=map(int, input().split())\n print(p[R]-p[L])\n", "neg": "H, W, D=map(int, input().split())\npos={}\nfor i in range(H):\n A=list(map(int, input().split()))\n for j in range(W):\n pos[A[j]]=(i, j)\nQ=int(input())\np=0\nfor i in range(Q):\n L, R=list(map(int, input().split()))\n for j in range((R-L)//D):\n p+=abs(pos[L+D*j][0]-pos[L+D*(j+1)][0])+abs(pos[L+D*j][1]-pos[L+D*(j+1)][1])\n print(p)\n", "jacc_sim": 0.9473684210526315, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [181, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u870092796", "n_user": "u870092796", "pos": "H,W,D=list(map(int,input().split()))\nX=[(0,0) for i in range(H*W+1)]\n\nfor i in range(1,H+1):\n\tA=list(map(int,input().split()))\n\tfor idx,a in enumerate(A):\n\t\tX[a]=(i,idx+1)\n\nQ=int(input())\nL=[]\nR=[]\nS=[0]*(H*W+1)\n\nfor i in range(Q):\n\tl,r=list(map(int,input().split()))\n\tL.append(l)\n\tR.append(r)\n\nfor i in range(D+1,H*W+1):\n\tS[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])\n\nfor i in range(Q):\n\tprint(S[R[i]]-S[L[i]])\n\t", "neg": "H,W,D=list(map(int,input().split()))\nX=[(0,0) for i in range(H*W+1)]\n\nfor i in range(1,H+1):\n\tA=list(map(int,input().split()))\n\tfor idx,a in enumerate(A):\n\t\tX[a]=(i,idx+1)\n\nQ=int(input())\nL=R=[]\nS=[0]*(H*W+1)\n\nfor i in range(Q):\n\tl,r=list(map(int,input().split()))\n\tL.append(l)\n\tR.append(r)\n\nfor i in range(D+1,H*W+1):\n\tS[i]=S[i-D]+abs(X[i][0]-X[i-D][0])+abs(X[i][1]-X[i-D][1])\n\nfor i in range(Q):\n\tprint(S[R[i]]-S[L[i]])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [253, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u650950012", "n_user": "u650950012", "pos": "h, w, d = map(int, input().split(' '))\n\ncomp = {}\nfor i in range(h):\n tmp = list(map(int, input().split(' ')))\n for j in range(w):\n comp[tmp[j]] = [i, j]\n\nq = int(input())\nlr = [map(int, input().split(' ')) for _ in range(q)]\n\ndp = [0] * (h * w + 1)\nfor i in range(d + 1, h * w + 1):\n cnt = dp[i - d]\n cnt += abs(comp[i][0] - comp[i - d][0])\n cnt += abs(comp[i][1] - comp[i - d][1]) \n dp[i] = cnt\n \n\nfor l, r in lr:\n print(dp[r] - dp[l])", "neg": "h, w, d = map(int, input().split(' '))\nq = int(input())\nlr = [map(int, input().split(' ')) for _ in range(q)]\n\ncomp = {}\nfor i in range(h):\n tmp = list(map(int, input().split(' ')))\n for j in range(w):\n comp[tmp[j]] = [i, j]\n\ndp = [0] * (h * w + 1)\nfor i in range(d + 1, h * w + 1):\n cnt = dp[i - d]\n cnt += abs(comp[i][0] - comp[i - d][0])\n cnt += abs(comp[i][1] - comp[i - d][1]) \n dp[i] = cnt\n \n\nfor l, r in lr:\n print(dp[r] - dp[l])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [213, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u604693716", "n_user": "u604693716", "pos": "line = input().split(\" \")\na = list(map(int, line))\ndata = [0] * 90001\nans = 0\nfor i in range(0, a[0]):\n line = input().split(\" \")\n temp = list(map(int, line))\n for j in range(0, a[1]):\n data[temp[j]] = [i, j]\n\nmemo = [0] * 90001\n\nfor i in range(1, a[0] * a[1]+1):\n if i < a[2]+1:\n memo[i] = 0\n else:\n memo[i] = memo[i - a[2]] + abs(data[i][0] - data[i - a[2]][0]) + abs(data[i][1] - data[i - a[2]][1])\ntimes = int(input())\nfor i in range(0, times):\n line = list(map(int, input().split(\" \")))\n print(memo[line[1]] - memo[line[0]])", "neg": "line = input().split(\" \")\na = list(map(int, line))\ndata = [0] * 90001\nans = 0\nfor i in range(0, a[0]):\n line = input().split(\" \")\n temp = list(map(int, line))\n for j in range(0, a[1]):\n data[temp[j]] = [i, j]\n\nmemo = [0] * 90001\n\nfor i in range(0, a[0] * a[1]):\n if i < a[2]:\n memo[i] = 0\n else:\n memo[i] = memo[i - a[2]] + abs(data[i][0] - data[i - a[2]][0]) + abs(data[i][1] - data[i - a[2]][1])\ntimes = int(input())\nfor i in range(0, times):\n line = list(map(int, input().split(\" \")))\n print(memo[line[1]] - memo[line[0]])", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [254, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u620868411", "n_user": "u620868411", "pos": "# coding=utf-8\nline = input().split(\" \")\nh = int(line[0])\nw = int(line[1])\nd = int(line[2])\n\ntable = [0 for _ in range(h*w+1)]\nfor hi in range(h):\n line = list(map(int, input().split(\" \")))\n\n for wi in range(w):\n table[line[wi]] = (hi+1, wi+1)\n\ndef calc(l,r):\n ret = 0\n if l!=r:\n c1 = table[l]\n c2 = table[r]\n ret += abs(c1[0]-c2[0])+abs(c1[1]-c2[1])\n return ret\n\nacc = [0 for _ in range(h*w+1)]\nfor dd in range(1,d+1):\n s = dd+d\n while s<=h*w:\n acc[s] = calc(s-d,s)+acc[s-d]\n s += d\n\nq = int(input())\nfor _ in range(q):\n line = input().split(\" \")\n l = int(line[0])\n r = int(line[1])\n\n ret = acc[r] - acc[l]\n print(ret)\n", "neg": "# coding=utf-8\nline = input().split(\" \")\nh = int(line[0])\nw = int(line[1])\nd = int(line[2])\n\ntable = [0 for _ in range(h*w+1)]\nfor hi in range(h):\n line = list(map(int, input().split(\" \")))\n\n for wi in range(w):\n table[line[wi]] = (hi+1, wi+1)\n\ndef calc(l,r):\n ret = 0\n if l!=r:\n c1 = table[l]\n c2 = table[r]\n ret += abs(c1[0]-c2[0])+abs(c1[1]-c2[1])\n return ret\n\nacc = [0 for _ in range(h*w+1)]\nfor dd in range(1,d+1):\n s = dd+d\n while s+d<=h*w:\n acc[s] = calc(s-d,s)+acc[s-d]\n s += d\n\nq = int(input())\nfor _ in range(q):\n line = input().split(\" \")\n l = int(line[0])\n r = int(line[1])\n\n ret = acc[r] - acc[l]\n print(ret)\n", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [324, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03426", "p_user": "u391475811", "n_user": "u391475811", "pos": "H,W,D=map(int,input().split())\nd=[[0,0] for i in range(H*W+1)]\nd2=[0 for i in range(H*W+1)]\nfor j in range(H):\n a=[int(x) for x in input().split()]\n for k in range(W):\n d[a[k]]=[j+1,k+1]\nfor l in range(D+1,H*W+1):\n d2[l]=abs(d[l][0]-d[l-D][0])+abs(d[l][1]-d[l-D][1])\nfor m in range(D+1,H*W+1):\n d2[m]+=d2[m-D]\nQ=int(input())\nfor i in range(Q):\n a,b=map(int,input().split())\n if a==b:\n print(0)\n else:\n ans=d2[b]-d2[a]\n print(ans)", "neg": "H,W,D=map(int,input().split())\nd=[[0,0] for i in range(H*W+1)]\nd2=[0 for i in range(H*W+1)]\nfor j in range(H):\n a=[int(x) for x in input().split()]\n for k in range(W):\n d[a[k]]=[j+1,k+1]\nfor l in range(D+1,H*W+1-D):\n d2[l]=abs(d[l][0]-d[l-D][0])+abs(d[l][1]-d[l-D][1])\nfor m in range(D+1,H*W+1-D):\n d2[m]+=d2[m-D]\nQ=int(input())\nfor i in range(Q):\n a,b=map(int,input().split())\n if a==b:\n print(0)\n else:\n ans=d2[b]-d2[a]\n print(ans)", "jacc_sim": 1.0, "nl": "You are a magical girl with the ability to teleport pieces on a grid. The grid has H rows and W columns, with integers from 1 to H\u00d7W written throughout. You need to take Q tests, each involving moving a piece from L to R, where R-L is a multiple of D. For each test, find the sum of magic points consumed. Constraints: 1 \u2264 H,W \u2264 300, 1 \u2264 D \u2264 H\u00d7W, 1 \u2264 A_{i,j} \u2264 H\u00d7W, A_{i,j} \u2260 A_{x,y} ((i,j) \u2260 (x,y)), 1 \u2264 Q \u2264 10^5, 1 \u2264 L_i \u2264 R_i \u2264 H\u00d7W. Input format: H W D, followed by the grid, Q, and test details. Output the sum of magic points for each test. Examples are provided.", "before_after_length": [256, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03430", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n s = input()\n n = len(s)\n k = int(input())\n # dp[\u4f7f\u3063\u305f\u56de\u6570][\u5de6\u7aef\u304b\u3089\u306e\u8ddd\u96e2][\u5de6\u7aef]\n dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]\n\n for i in range(n-1):\n if s[i] == s[i+1]:\n dp[0][1][i] = 2\n if k > 0:\n for cnt in range(1, k+1):\n for i in range(n-1):\n dp[cnt][1][i] = 2\n\n for cnt in range(k):\n for d in range(2, n):\n for left in range(n-d):\n right = left+d\n plus = (s[left] == s[right])*2\n dp[cnt][d][left] = max(\n dp[cnt][d][left], dp[cnt][d-1][left],\n dp[cnt][d-1][left+1], dp[cnt][d-2][left+1]+plus)\n dp[cnt+1][d][left] = max(\n dp[cnt+1][d][left], dp[cnt][d][left], dp[cnt][d-2][left+1]+2)\n for d in range(2, n):\n for left in range(n-d):\n right = left+d\n plus = (s[left] == s[right])*2\n dp[k][d][left] = max(\n dp[k][d][left], dp[k][d-1][left], dp[k][d-1][left+1], dp[k][d-2][left+1]+plus)\n print(dp[-1][-1][0])\n\n\nmain()", "neg": "def main():\n s = input()\n n = len(s)\n k = int(input())\n # dp[\u4f7f\u3063\u305f\u56de\u6570][\u5de6\u7aef\u304b\u3089\u306e\u8ddd\u96e2][\u5de6\u7aef]\n dp = [[[1]*(n-i) for i in range(n)] for _ in range(k+1)]\n\n dp2 = dp[0][1]\n for i in range(n-1):\n if s[i] == s[i+1]:\n dp2[i] = 2\n if k > 0:\n for cnt in range(1, k+1):\n dp2 = dp[cnt][1]\n for i in range(n-1):\n dp2[i] = 2\n\n for cnt in range(k):\n dp2 = dp[cnt]\n for d in range(2, n):\n dp3 = dp2[d]\n for left in range(n-d):\n right = left+d\n plus = (s[left] == s[right])*2\n dp3[left] = max(\n dp3[left], dp2[d-1][left],\n dp2[d-1][left+1], dp2[d-2][left+1]+plus)\n dp[cnt+1][d][left] = max(\n dp[cnt+1][d][left], dp3[left], dp2[d-2][left+1]+2)\n dp2 = dp[k]\n for d in range(2, n):\n dp3 = dp[d]\n for left in range(n-d):\n right = left+d\n plus = (s[left] == s[right])*2\n dp3[left] = max(\n dp3[left], dp2[d-1][left], dp2[d-1][left+1], dp2[d-2][left+1]+plus)\n print(dp[-1][-1][0])\n\n\nmain()", "jacc_sim": 0.9607843137254902, "nl": "Takahashi wants to give his mother a string with the highest possible value. The value of a string T is the length of the longest common subsequence of T and its reverse, T'. Takahashi has a string S and can change at most K characters in S to obtain the highest possible value. Find the highest possible value achievable. Constraints: 1 \u2264 |S| \u2264 300, 0 \u2264 K \u2264 |S|, S consists of lowercase English letters, and K is an integer. Input is given as S and K, and the output should be the highest possible value achievable. For example, if the input is \"abcabcabc\" and 1, the output should be 7. If the input is \"atcodergrandcontest\" and 3, the output should be 15.", "before_after_length": [472, 503], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u731368968", "n_user": "u731368968", "pos": "H, W = map(int, input().split())\n\ns = ['#' * (W + 2)] + ['#' + input() + '#' for i in range(H)] + ['#' * (W + 2)]\n\n# m : \u305d\u3053\u306b\u305f\u3069\u308a\u7740\u304f\u305f\u3081\u306b\u5fc5\u8981\u306a\u767d\u30de\u30b9\u306e\u6570\nm = [[-1 for x in range(W+2)] for y in range(H+2)]\nm[1][1] = 1\n\n\nfrom collections import deque\nqx = deque([1])\nqy = deque([1])\n\ndx = [1, 0, -1, 0]\ndy = [0, 1, 0, -1]\n\n\nwhile len(qx) > 0:\n x, y = qx.popleft(), qy.popleft()\n for d in range(4):\n nx, ny = x + dx[d], y + dy[d]\n # \u8a2a\u308c\u305f\u3053\u3068\u304c\u3042\u308b\u306a\u3089\u8abf\u3079\u306a\u3044\n if m[ny][nx] != -1: continue\n\n if s[ny][nx] == '.':\n qx.append(nx), qy.append(ny)\n m[ny][nx] = m[y][x] + 1\n\nif m[H][W] == -1:\n print(-1)\n\nelse:\n print(sum([c.count('.') for c in s]) - m[H][W])\n", "neg": "H, W = map(int, input().split())\n\ns = ['#' * (W + 2)] + ['#' + input() + '#' for i in range(H)] + ['#' * (W + 2)]\n\n# m : \u305d\u3053\u306b\u305f\u3069\u308a\u7740\u304f\u305f\u3081\u306b\u5fc5\u8981\u306a\u767d\u30de\u30b9\u306e\u6570\nm = [[-1 for x in range(W+2)] for y in range(H+2)]\nm[1][1] = 1\n\n\nfrom collections import deque\nqx = deque([1])\nqy = deque([1])\n\ndx = [1, 0, -1, 0]\ndy = [0, 1, 0, -1]\n\n\nwhile len(qx) > 0:\n x, y = qx.popleft(), qy.popleft()\n for d in range(4):\n nx, ny = x + dx[d], y + dy[d]\n\n # \u8a2a\u308c\u305f\u3053\u3068\u304c\u3042\u308b\u306a\u3089\u8abf\u3079\u306a\u3044\n if m[nx][ny] != -1: continue\n\n if s[ny][nx] == '.':\n qx.append(nx), qy.append(ny)\n m[ny][nx] = m[y][x] + 1\n\nif m[H][W] == -1:\n print(-1)\n\nelse:\n print(sum([c.count('.') for c in s]) - m[H][W])\n\n", "jacc_sim": 1.0, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [405, 407], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u333945892", "n_user": "u333945892", "pos": "import sys\nimport queue\n\nH,W = map(int,input().split())\nwhite = 0\nmaze = [['#']*(W+2)]\nfor y in range(H):\n\tli = list(input())\n\twhite += li.count('.')\n\tmaze.append(['#'] + li + ['#'])\nmaze.append(['#']*(W+2))\n\n\n\ndef check(x,y,n):\n\tif 1 <= x < W+1 and 1 <= y < H+1:\n\t\tif x == W and y == H:\n\t\t\tprint (white - n - 1)\n\t\t\tsys.exit()\n\t\telif maze[y][x] == '.':\n\t\t\tmaze[y][x] = n\n\t\t\tq.put([x-1,y,n+1])\n\t\t\tq.put([x+1,y,n+1])\n\t\t\tq.put([x,y-1,n+1])\n\t\t\tq.put([x,y+1,n+1])\n\t\telse:\n\t\t\treturn\n\telse:\n\t\treturn\n\nq = queue.Queue()\nq.put([1,1,0])\nwhile not q.empty():\n\tx,y,n = q.get()\n\tcheck(x,y,n)\n\nprint(-1)\n", "neg": "import sys\nimport queue\n\nH,W = map(int,input().split())\nwhite = 0\nmaze = [['#']*(W+2)]\nfor y in range(H):\n\tli = list(input())\n\twhite += li.count('.')\n\tmaze.append(['#'] + li + ['#'])\nmaze.append(['#']*(W+2))\n\n\n\ndef check(x,y,n):\n\tif 1 <= x < W+1 and 1 <= y < H+1:\n\t\tif x == W-1 and y == H-1:\n\t\t\tprint (white - n - 1)\n\t\t\tsys.exit()\n\t\telif maze[y][x] == '.':\n\t\t\tmaze[y][x] = n\n\t\t\tq.put([x-1,y,n+1])\n\t\t\tq.put([x+1,y,n+1])\n\t\t\tq.put([x,y-1,n+1])\n\t\t\tq.put([x,y+1,n+1])\n\t\telse:\n\t\t\treturn\n\telse:\n\t\treturn\n\nq = queue.Queue()\nq.put([1,1,0])\nwhile not q.empty():\n\tx,y,n = q.get()\n\tcheck(x,y,n)\n\nprint(-1)\n", "jacc_sim": 1.0, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [326, 330], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u054274920", "n_user": "u054274920", "pos": "from collections import deque\nimport sys\n\nH,W = map(int, input().split())\nsx, sy = 1,1\ngx, gy = W,H\ncount=-1\nmaze=[0]*(H+2)\nmaze[0] = list(\"#\"*(W+2))\nfor i in range(1,H+1):\n maze[i] = list(\"#\"+input()+\"#\")\n count+=maze[i].count('.')\nmaze[H+1] = list(\"#\"*(W+2))\nans = [[-1 for i in range(W+2)] for j in range(H+2)]\nq = deque()\ndx = [1, 0, -1, 0]\ndy = [0, 1, 0, -1]\nq.append((sx, sy))\nans[sx][sy] = 0\n \nwhile q:\n cx, cy = q.popleft()\n if cx == gx and cy == gy:\n print(count-ans[gy][gx])\n sys.exit()\n for i in range(4):\n nx, ny = cx + dx[i], cy + dy[i]\n if ans[ny][nx] == -1 and maze[ny][nx] != \"#\":\n q.append((nx, ny))\n ans[ny][nx] = ans[cy][cx] + 1\nprint(-1)", "neg": "from collections import deque\n \nH,W = map(int, input().split())\nsx, sy = 1,1\ngx, gy = W,H\ncount=-1\nmaze=[0]*(H+2)\nmaze[0] = list(\"#\"*(W+2))\nfor i in range(1,H+1):\n maze[i] = list(\"#\"+input()+\"#\")\n count+=maze[i].count('.')\nmaze[H+1] = list(\"#\"*(W+2))\nans = [[-1 for i in range(W+2)] for j in range(H+2)]\nq = deque()\ndx = [1, 0, -1, 0]\ndy = [0, 1, 0, -1]\nq.append((sx, sy))\nans[sx][sy] = 0\n \nwhile q:\n cx, cy = q.popleft()\n if cx == gx and cy == gy:\n print(count-ans[gx][gy])\n break\n for i in range(2):\n nx, ny = cx + dx[i], cy + dy[i]\n if ans[nx][ny] == -1 and maze[nx][ny] != \"#\":\n q.append((nx, ny))\n ans[nx][ny] = ans[cx][cy] + 1", "jacc_sim": 0.9298245614035088, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [339, 329], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u595952233", "n_user": "u595952233", "pos": "from collections import deque\nH, W = map(int, input().split())\narea = [['#']*(W+2)]\nspace = 0\nfor i in range(H):\n temp = ['#']+list(input())+['#']\n for t in temp:\n if t=='.': space+=1 \n area.append(temp)\narea.append(['#']*(W+2))\nmove = ((1, 0), (-1, 0), (0, 1), (0, -1))\n\ndq = deque([(1,1)])\ndist = [[-1]*(W+2) for _ in range(H+2)]\ndist[1][1] = 1\n\nwhile dq:\n nowx, nowy = dq.popleft()\n # if (nowx, nowy) == (W, H): break\n for dx, dy in move:\n nxtx, nxty = nowx+dx, nowy+dy\n if not 0<=nxtx=0 or area[nxty][nxtx]=='#': continue\n dist[nxty][nxtx] = dist[nowy][nowx]+1\n dq.append((nxtx, nxty))\nif dist[H][W]==-1: print(-1)\nelse: print(space-dist[H][W])", "neg": "from collections import deque\nH, W = map(int, input().split())\narea = [['#']*(W+2)]\nspace = 0\nfor i in range(H):\n temp = ['#']+list(input())+['#']\n for t in temp:\n if t=='.': space+=1 \n area.append(temp)\narea.append(['#']*(W+2))\nmove = ((1, 0), (-1, 0), (0, 1), (0, -1))\n\ndq = deque([(1,1)])\ndist = [[-1]*(W+2) for _ in range(H+2)]\ndist[1][1] = 0\n\nmax_dist = 0\nwhile dq:\n nowx, nowy = dq.popleft()\n if (nowx, nowy) == (W, H): break\n for dx, dy in move:\n nxtx, nxty = nowx+dx, nowy+dy\n if not 0<=nxtx=0 or area[nxty][nxtx]=='#': continue\n nxtd = dist[nowy][nowx]+1\n dist[nxty][nxtx] = nxtd\n max_dist = max(max_dist, nxtd)\n dq.append((nxtx, nxty))\nprint(space-(max_dist+1))", "jacc_sim": 0.9344262295081968, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [338, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u707498674", "n_user": "u707498674", "pos": "from collections import deque\nMAX_VAL = 10 ** 9\nH, W = map(int, input().split())\n \n \n \nborder_row = \"#\"*(W+2)\nfield = [border_row]\nnum_blacks = 0\nfor i in range(H):\n line = input()\n num_blacks += line.count(\".\")\n field.append(\"#\"+line+\"#\")\nfield.append(border_row)\n \ncost = [[MAX_VAL]*(W+2) for _ in range(H+2)]\n \nif field[1][1] == \".\":\n cost[1][1] = 1\nelse:\n cost[1][1] = MAX_VAL\n \nvisited = [[False]*(W+2) for _ in range(H+2)]\ndxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]\ndef bfs():\n q = deque()\n q.append((1, 1))\n visited[1][1] = True\n while len(q):\n x, y = q.popleft()\n for dx, dy in dxdy:\n nx = x + dx\n ny = y + dy\n if field[ny][nx] == \".\" and not visited[ny][nx]:\n cost[ny][nx] = cost[y][x]+1\n visited[ny][nx] = True\n q.append((nx, ny))\n return \nbfs()\nprint(num_blacks - cost[H][W]) if cost[H][W] < MAX_VAL else print(-1)", "neg": "from collections import deque\nMAX_VAL = 10 ** 9\nH, W = map(int, input().split())\n\n\n\nborder_row = \"#\"*(W+2)\nfield = [border_row]\nnum_blacks = 0\nfor i in range(H):\n line = input()\n for c in line:\n if c == \"#\":\n num_blacks += 1\n field.append(\"#\"+line+\"#\")\nfield.append(border_row)\n\ncost = [[MAX_VAL]*(W+2) for _ in range(H+2)]\n\nif field[1][1] == \".\":\n cost[1][1] = 1\nelse:\n cost[1][1] = MAX_VAL\n\nvisited = [[False]*(W+2) for _ in range(H+2)] \ndxdy = [(-1, 0), (1, 0), (0, -1), (0, 1)]\ndef bfs():\n q = deque()\n q.append((1, 1))\n while len(q):\n x, y = q.popleft()\n for dx, dy in dxdy:\n nx = x + dx\n ny = y + dy\n if field[ny][nx] == \".\":\n cost[ny][nx] = min(cost[ny][nx], cost[y][x]+1)\n if not visited[ny][nx]:\n q.append((nx, ny))\n visited[y][x] = True\n\nbfs()\nprint(H*W-num_blacks-cost[H][W]) if cost[H][W] < MAX_VAL else print(-1)\n\n\n", "jacc_sim": 0.9242424242424242, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [380, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u574189773", "n_user": "u574189773", "pos": "from queue import Queue\n\n\ndef main():\n H, W = map(int, input().split())\n\n white = 0\n\n grid = [[-1 for _ in range(W + 2)]]\n for _ in range(H):\n line = input()\n white += line.count(\".\")\n grid.append([-1] + [-1 if char == \"#\" else -2 for char in line] + [-1])\n grid.append([-1 for _ in range(W + 2)])\n\n grid[1][1] = 0\n\n tosearch = Queue()\n tosearch.put((1, 1))\n\n movement = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n\n while not tosearch.empty():\n y, x = tosearch.get()\n\n if (y, x) == (H, W):\n print(white - (grid[H][W] + 1))\n break\n\n for move in movement:\n ny, nx = y + move[0], x + move[1]\n\n if grid[ny][nx] == -2:\n grid[ny][nx] = grid[y][x] + 1\n tosearch.put((ny, nx))\n else:\n print(-1)\n\n\n\nif __name__ == '__main__':\n main()\n", "neg": "from queue import Queue\n\n\ndef main():\n H, W = map(int, input().split())\n\n black = 0\n\n grid = [[-1 for _ in range(W + 2)]]\n for _ in range(H):\n line = input()\n black += line.count(\"#\")\n grid.append([-1] + [-1 if char == \"#\" else -2 for char in line] + [-1])\n grid.append([-1 for _ in range(W + 2)])\n\n grid[1][1] = 0\n\n tosearch = Queue()\n tosearch.put((1, 1))\n\n movement = [(-1, 0), (1, 0), (0, -1), (0, 1)]\n\n while not tosearch.empty():\n y, x = tosearch.get()\n\n if (y, x) == (H, W):\n break\n\n for move in movement:\n ny, nx = y + move[0], x + move[1]\n\n if grid[ny][nx] == -2:\n grid[ny][nx] = grid[y][x] + 1\n tosearch.put((ny, nx))\n\n print(H * W - (grid[H][W] + 1) - black)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9473684210526315, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [327, 322], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u064408584", "n_user": "u064408584", "pos": "h, w =map(int, input().split())\n\na=['#'*(w+2)]\nfor i in range(h):\n b='#'+input()+'#'\n a.append(b)\na.append('#'*(w+2))\n#print(a)\n\nfrom collections import Counter\n\nn=[(1,1)]\nroute={(1,1):0}\np=[[1,0],[0,1],[-1,0],[0,-1]]\ncount=1\nwhile route.get((h,w),0)==0 and count != 10000:\n n2=[]\n #print(n,route)\n for i in n:\n for j in p:\n np=(i[0]+j[0],i[1]+j[1])\n if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:\n n2.append(np)\n if route.get(np,1000)>count:\n route[np]=count\n n=n2\n #print(n,route)\n count+=1\n\n \na2=[]\nfor i in a:\n for j in range(len(i)):\n a2.append(i[j])\ncon=Counter(a2)\n\n\nif count==10000:\n print('-1')\nelse:\n print(con['.']-route[(h,w)]-1)", "neg": "a=['#'*(w+2)]\nfor i in range(h):\n b='#'+input()+'#'\n a.append(b)\na.append('#'*(w+2))\n#print(a)\n\nfrom collections import Counter\n\nn=[(1,1)]\nroute={(1,1):0}\np=[[1,0],[0,1],[-1,0],[0,-1]]\ncount=1\nwhile route.get((h,w),0)==0 and count != 10000:\n n2=[]\n #print(n,route)\n for i in n:\n for j in p:\n np=(i[0]+j[0],i[1]+j[1])\n if a[np[0]][np[1]]=='.' and route.get(np,-1)==-1:\n n2.append(np)\n if route.get(np,1000)>count:\n route[np]=count\n n=n2\n #print(n,route)\n count+=1\n\n \na2=[]\nfor i in a:\n for j in range(len(i)):\n a2.append(i[j])\ncon=Counter(a2)\n\n\nif count==10000:\n print('-1')\nelse:\n print(con['.']-route[(h,w)]-1)", "jacc_sim": 0.9454545454545454, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [351, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u551909378", "n_user": "u551909378", "pos": "import queue\n\nH, W = map(int, input().split())\ns, count = [], 0\nfor _ in range(H):\n h = list(input())\n count += h.count('.')\n s.append(['#'] + h + ['#'])\ns = [['#'] * (W+2)] + s + [['#'] * (W+2)]\naround = [[-1, 0], [0, -1], [1, 0], [0, 1]]\n\nans, que, already = count + 1, queue.Queue(), set([1 + W])\nque.put([1, 1, 1])\nwhile not que.empty():\n q = que.get()\n if q[0] == W and q[1] == H:\n ans = q[2]\n break\n else:\n for a in around:\n nextx, nexty = q[0] + a[0], q[1] + a[1]\n if nextx + W*nexty not in already and s[nexty][nextx] == '.':\n que.put([nextx, nexty, q[2] + 1])\n already.add(nextx + W*nexty)\n\nprint(count - ans)", "neg": "import queue\n\nH, W = map(int, input().split())\ns, count = [], 0\nfor _ in range(H):\n h = list(input())\n count += h.count('.')\n s.append(['#'] + h + ['#'])\ns = [['#'] * (W+2)] + s + [['#'] * (W+2)]\naround = [[-1, 0], [0, -1], [1, 0], [0, 1]]\n\nans, que, already = count + 1, queue.Queue(), set([1 + H])\nque.put([1, 1, 1])\nwhile not que.empty():\n q = que.get()\n if q[0] == W and q[1] == H:\n ans = q[2]\n Goal = True\n break\n elif q[0] + H*q[1] not in already:\n for a in around:\n nextx, nexty = q[0] + a[0], q[1] + a[1]\n if s[nexty][nextx] == '.':\n que.put([nextx, nexty, q[2] + 1])\n already.add(nextx + H*nexty)\n\nprint(count - ans)", "jacc_sim": 0.9298245614035088, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [295, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u627325970", "n_user": "u627325970", "pos": "from collections import deque\n\nimport numpy as np\nimport sys\n#input = sys.stdin.readline\n\nsys.setrecursionlimit(5000)\n\ndef bfs(point, field, target, H, W):\n visited = [[-1 for _ in range(W+2)] for _ in range(H+2)]\n visited[point[0]][point[1]] = 1\n que = deque()\n que.append(point)\n\n while True:\n v = que.popleft()\n depth = visited[v[0]][v[1]]\n for a in [(v[0]-1, v[1]), (v[0]+1, v[1]), (v[0], v[1]-1), (v[0], v[1]+1)]:\n if field[a[0]][a[1]] == 0 and visited[a[0]][a[1]] == -1:\n visited[a[0]][a[1]] = 1 + depth\n if a == target:\n return visited[a[0]][a[1]]\n else:\n que.append(a)\n if len(que) == 0:\n return 0\n\nH, W = list(map(int, input().split()))\ntarget = (H, W)\nfield = [[-1] * (W+2)]\nnumber_of_whites = 0\nfor _ in range(H):\n s = input()\n number_of_whites += s.count('.')\n field.append([-1] + [0 if c=='.' else -1 for c in s] + [-1])\nfield += [[-1] * (W+2)]\n\nshortest_path = bfs((1, 1), field, target, H, W)\nif shortest_path > 0:\n print(number_of_whites - shortest_path)\nelse:\n print(-1)", "neg": "from collections import deque\n\nimport numpy as np\nimport sys\n#input = sys.stdin.readline\n\nsys.setrecursionlimit(5000)\n\ndef bfs(point, field, target, H, W):\n visited = [[-1 for _ in range(W+2)] for _ in range(H+2)]\n visited[point[0]][point[1]] = 1\n que = deque()\n que.append(point)\n\n while True:\n v = que.popleft()\n depth = visited[v[0]][v[1]]\n for a in [(v[0]-1, v[1]), (v[0]+1, v[1]), (v[0], v[1]-1), (v[0], v[1]+1)]:\n if field[a[0]][a[1]] == 0 and visited[a[0]][a[1]] == -1:\n visited[a[0]][a[1]] = 1 + depth\n if a == target:\n print(visited)\n return visited[a[0]][a[1]]\n else:\n que.append(a)\n if len(que) == 0:\n return 0\n\nH, W = list(map(int, input().split()))\ntarget = (H, W)\nfield = [[-1] * (W+2)]\nnumber_of_whites = 0\nfor _ in range(H):\n s = input()\n number_of_whites += s.count('.')\n field.append([-1] + [0 if c=='.' else -1 for c in s] + [-1])\nfield += [[-1] * (W+2)]\n\nshortest_path = bfs((1, 1), field, target, H, W)\nif shortest_path > 0:\n print(number_of_whites - shortest_path)\nelse:\n print(-1)", "jacc_sim": 1.0, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [456, 462], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u627325970", "n_user": "u627325970", "pos": "H, W = list(map(int, input().split()))\nM = [[-1]*(W+2)]\nans = 0\nfor _ in range(H):\n s = input()\n ans += s.count('.')\n M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])\nM += [[-1]*(W+2)]\n\nqueue = [(1,1)]\nM[1][1] = 1\ndr = [(+1,0),(-1,0),(0,+1),(0,-1)]\nturn = 1\nwhile len(queue)>0:\n turn += 1\n queue_new = []\n for qx, qy in queue:\n for dx, dy in dr:\n x, y = qx+dx, qy+dy\n if M[y][x]==0:\n M[y][x] = turn\n queue_new.append((x,y))\n queue = queue_new\n\nprint(ans-M[H][W] if M[H][W]>0 else -1)", "neg": "H, W = list(map(int, input().split()))\nM = [[-1]*(W+2)]\nans = 0\nfor _ in range(H):\n s = input()\n ans += s.count('.')\n M.append([-1]+[0 if c=='.' else -1 for c in s]+[-1])\n M += [[-1]*(W+2)]\n\n queue = [(1,1)]\n M[1][1] = 1\n dr = [(+1,0),(-1,0),(0,+1),(0,-1)]\n turn = 1\n while len(queue)>0:\n turn += 1\n queue_new = []\n for qx, qy in queue:\n for dx, dy in dr:\n x, y = qx+dx, qy+dy\n if M[y][x]==0:\n M[y][x] = turn\n queue_new.append((x,y))\n queue = queue_new\n\n print(ans-M[H][W] if M[H][W]>0 else -1)", "jacc_sim": 1.0, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [265, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03436", "p_user": "u231122239", "n_user": "u231122239", "pos": "from collections import deque\n\nH, W = map(int, input().split())\nS = ['#'*(W+2)]\nwhite_num = 0\nfor _ in range(H):\n s = input()\n white_num += s.count('.')\n S.append('#'+s+'#')\nS.append('#'*(W+2))\n\nC = [[-1]*(W+2) for _ in range(H+2)]\nC[1][1] = 1\nq = deque()\nq.append((1, 1))\nxlist = [0, 0, 1, -1]\nylist = [1, -1, 0, 0]\nwhile len(q) > 0:\n x, y = q.popleft()\n for i in range(4):\n mx = x + xlist[i]\n my = y + ylist[i]\n if S[mx][my] == '#' or C[mx][my] >= 0:\n continue\n C[mx][my] = C[x][y] + 1\n q.append((mx, my))\nif C[H][W] == -1:\n print(-1)\nelse:\n print(white_num - C[H][W])\n", "neg": "from collections import deque\n\nH, W = map(int, input().split())\nS = []\nwhite_num = 0\nfor _ in range(H):\n s = input()\n white_num += s.count('.')\n S.append(s)\n\nC = [[-1]*W for _ in range(H)]\nC[0][0] = 0\nq = deque()\nq.append((0, 0, 0))\nxlist = [0, 0, 1, -1]\nylist = [1, -1, 0, 0]\nwhile len(q) > 0:\n x, y, c = q.popleft()\n C[x][y] = c + 1\n for i in range(4):\n mx = x + xlist[i]\n my = y + ylist[i]\n if mx < 0 or my < 0 or mx >= H or my >= W or S[mx][my] == '#' or C[mx][my] >= 0:\n continue\n q.append((mx, my, c+1))\nif C[H-1][W-1] == -1:\n print(-1)\nelse:\n print(white_num - C[H-1][W-1])\n", "jacc_sim": 0.9464285714285714, "nl": "You are given an H x W grid with black or white squares. A character named Kenus starts at (1, 1) and moves up, down, left, or right. The game ends when Kenus reaches (H, W) passing only white squares. Before the game, Snuke can change some white squares to black, except (1, 1) and (H, W). The score is the number of color changes. Find the maximum score or print -1 if Kenus can't reach (H, W). Constraints: H, W <= 50. Input format: H, W, followed by the grid. Output: maximum score or -1.", "before_after_length": [294, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03440", "p_user": "u423585790", "n_user": "u423585790", "pos": "from heapq import heappush, heappop\nfrom collections import defaultdict\nn,m = map(int,input().split())\na = list(map(int,input().split()))\n# edg = [[] for i in range(n)]\nrank = [1] * n\npar = [i for i in range(n)]\ndef root(x):\n if x == par[x]:\n return x\n par[x] = root(par[x])\n return par[x]\ndef union(a,b):\n a = root(a)\n b = root(b)\n if rank[a] < rank[b]:a,b = b,a\n if a == b: return False\n par[b] = a\n rank[a] += rank[b]\n return True\nfor _ in range(m):\n x,y = map(int, input().split())\n union(x,y)\nd = defaultdict(list)\nq = []\nfor i in range(n):\n ai = a[i]\n heappush(q,(ai,i))\n ri = root(i)\n heappush(d[ri],(ai,i))\nif len(d.keys()) == 1:\n print(0)\nelse:\n ans = 0\n tmp = 0\n c = [0] * n\n\n for i in d.keys():\n tmp += 1\n t,p = heappop(d[i])\n c[p] = 1\n ans += t\n if 2*tmp-2 > n:\n print(\"Impossible\")\n else:\n for _ in range(tmp-2):\n p,i = heappop(q)\n while c[i]:\n p,i = heappop(q)\n ans += p\n print(ans)\n", "neg": "from heapq import heappush, heappop\nfrom collections import defaultdict\nn,m = map(int,input().split())\na = list(map(int,input().split()))\n# edg = [[] for i in range(n)]\nrank = [1] * n\npar = [i for i in range(n)]\ndef root(x):\n if x == par[x]:\n return x\n par[x] = root(par[x])\n return par[x]\ndef union(a,b):\n a = root(a)\n b = root(b)\n if rank[a] < rank[b]:a,b = b,a\n if a == b: return False\n par[b] = a\n rank[a] += rank[b]\n return True\nfor _ in range(m):\n x,y = map(int, input().split())\n union(x,y)\nd = defaultdict(list)\nq = []\nfor i in range(n):\n ai = a[i]\n heappush(q,(ai,i))\n ri = root(i)\n heappush(d[ri],(ai,i))\n\nans = 0\ntmp = 0\nc = [0] * n\n\nfor i in d.keys():\n tmp += 1\n t,p = heappop(d[i])\n c[p] = 1\n ans += t\nif 2*tmp > n:\n print(\"Impossible\")\nelse:\n for _ in range(tmp):\n p,i = heappop(q)\n while c[i]:\n p,i = heappop(q)\n ans += p\n print(ans)", "jacc_sim": 0.9696969696969697, "nl": "You are given a forest with N vertices and M edges. Each vertex has a value. You want to add edges to connect the forest. Adding an edge between vertices i and j costs ai + aj dollars. Find the minimum total cost to connect the forest, or print \"Impossible\" if it's not possible. Constraints: 1 \u2264 N \u2264 100,000, 0 \u2264 M \u2264 N-1, 1 \u2264 ai \u2264 10^9, 0 \u2264 xi, yi \u2264 N-1. Input format: N M, followed by ai values, followed by M pairs of xi and yi. Output the minimum total cost or \"Impossible\". Example input and output are provided.", "before_after_length": [440, 410], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03440", "p_user": "u794173881", "n_user": "u794173881", "pos": "import heapq\nfrom collections import deque\n\n\nn, m = map(int, input().split())\na = list(map(int, input().split()))\ninfo = [list(map(int, input().split())) for i in range(m)]\ntree = [[] for i in range(n)]\n\nfor b, c in info:\n tree[b].append(c)\n tree[c].append(b)\n\nvisited = [False] * n\ngroup = []\nfor i in range(n):\n if visited[i]:\n continue\n q = deque([i])\n visited[i] = True\n tmp = [a[i]]\n while q:\n pos = q.pop()\n for next_pos in tree[pos]:\n if visited[next_pos]:\n continue\n visited[next_pos] = True\n q.append(next_pos)\n tmp.append(a[next_pos])\n group.append(tmp)\n\nfor i in range(len(group)):\n group[i] = sorted(group[i])\n\nans = 0\ncnt = len(group)*2 - 2\n\nif cnt == 0:\n print(0)\n exit()\n \nfor i in range(len(group)):\n ans += group[i][0]\n cnt -= 1\n group[i][0] = 10**9 + 7\n\nq = []\nfor i in range(len(group)):\n for num in group[i]:\n if num != 10**9 +7:\n heapq.heappush(q, num)\n\nfor i in range(cnt):\n if not q:\n print(\"Impossible\")\n exit()\n ans += heapq.heappop(q)\nprint(ans)\n ", "neg": "import heapq\nfrom collections import deque\n\n\nn, m = map(int, input().split())\na = list(map(int, input().split()))\ninfo = [list(map(int, input().split())) for i in range(m)]\ntree = [[] for i in range(n)]\n\nfor b, c in info:\n tree[b].append(c)\n tree[c].append(b)\n\nvisited = [False] * n\ngroup = []\nfor i in range(n):\n if visited[i]:\n continue\n q = deque([i])\n visited[i] = True\n tmp = [a[i]]\n while q:\n pos = q.pop()\n for next_pos in tree[pos]:\n if visited[next_pos]:\n continue\n visited[next_pos] = True\n q.append(next_pos)\n tmp.append(a[next_pos])\n group.append(tmp)\n\nfor i in range(len(group)):\n group[i] = sorted(group[i])\n\nans = 0\ncnt = len(group)*2 - 2\n\nif cnt == 0:\n print(0)\n exit()\n \nfor i in range(len(group)):\n ans += group[i][0]\n cnt -= 1\n group[i][0] = 10**9 + 7\n\nq = []\nfor i in range(len(group)):\n for num in group[i]:\n if num != 10**9 +7:\n heapq.heappush(q, num)\nprint(1)\nexit()\nfor i in range(cnt):\n if not q:\n print(\"Impossible\")\n exit()\n ans += heapq.heappush(q)\nprint(ans)\n ", "jacc_sim": 0.984375, "nl": "You are given a forest with N vertices and M edges. Each vertex has a value. You want to add edges to connect the forest. Adding an edge between vertices i and j costs ai + aj dollars. Find the minimum total cost to connect the forest, or print \"Impossible\" if it's not possible. Constraints: 1 \u2264 N \u2264 100,000, 0 \u2264 M \u2264 N-1, 1 \u2264 ai \u2264 10^9, 0 \u2264 xi, yi \u2264 N-1. Input format: N M, followed by ai values, followed by M pairs of xi and yi. Output the minimum total cost or \"Impossible\". Example input and output are provided.", "before_after_length": [426, 433], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03440", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\nsys.setrecursionlimit(10**6)\n\ndef input():\n\treturn sys.stdin.readline()[:-1]\n\nn, m = map(int, input().split())\na = list(map(int, input().split()))\nadj = [[] for _ in range(n)]\nfor _ in range(m):\n\tx, y = map(int, input().split())\n\tadj[x].append(y)\n\tadj[y].append(x)\n\nroot = [-1 for _ in range(n)]\nis_minimum = [False for _ in range(n)]\n\ndef dfs(x, r):\n\tglobal mi, mi_ind\n\tif a[x] < mi:\n\t\tmi = a[x]\n\t\tmi_ind = x\n\tfor v in adj[x]:\n\t\tif root[v] < 0:\n\t\t\troot[v] = r\n\t\t\tdfs(v, r)\n\treturn mi_ind\n\nfor i in range(n):\n\tif root[i] < 0:\n\t\tmi, mi_ind = 10**10, -1\n\t\troot[i] = i\n\t\tis_minimum[dfs(i, i)] = True\n\ncon_num = len(set(root))\n#print(con_num)\nif (con_num-1) * 2 > n:\n\tprint(\"Impossible\")\n\tsys.exit()\nelif con_num == 1:\n\tprint(0)\n\tsys.exit()\nans = sum([a[i] for i in range(n) if is_minimum[i]])\nans += sum(sorted([a[i] for i in range(n) if not is_minimum[i]])[:con_num-2])\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10**6)\n\ndef input():\n\treturn sys.stdin.readline()[:-1]\n\nn, m = map(int, input().split())\na = list(map(int, input().split()))\nadj = [[] for _ in range(n)]\nfor _ in range(m):\n\tx, y = map(int, input().split())\n\tadj[x].append(y)\n\tadj[y].append(x)\n\nroot = [-1 for _ in range(n)]\nis_minimum = [False for _ in range(n)]\n\ndef dfs(x, r):\n\tglobal mi, mi_ind\n\tif a[x] < mi:\n\t\tmi = a[x]\n\t\tmi_ind = x\n\tfor v in adj[x]:\n\t\tif root[v] < 0:\n\t\t\troot[v] = r\n\t\t\tdfs(v, r)\n\treturn mi_ind\n\nfor i in range(n):\n\tif root[i] < 0:\n\t\tmi, mi_ind = 10**10, -1\n\t\troot[i] = i\n\t\tis_minimum[dfs(i, i)] = True\n\ncon_num = len(set(root))\n#print(con_num)\nif (con_num-1) * 2 > n:\n\tprint(\"Impossible\")\n\tsys.exit()\nelif con_num == 0:\n\tprint(0)\n\tsys.exit()\nans = sum([a[i] for i in range(n) if is_minimum[i]])\nans += sum(sorted([a[i] for i in range(n) if not is_minimum[i]])[:con_num-2])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a forest with N vertices and M edges. Each vertex has a value. You want to add edges to connect the forest. Adding an edge between vertices i and j costs ai + aj dollars. Find the minimum total cost to connect the forest, or print \"Impossible\" if it's not possible. Constraints: 1 \u2264 N \u2264 100,000, 0 \u2264 M \u2264 N-1, 1 \u2264 ai \u2264 10^9, 0 \u2264 xi, yi \u2264 N-1. Input format: N M, followed by ai values, followed by M pairs of xi and yi. Output the minimum total cost or \"Impossible\". Example input and output are provided.", "before_after_length": [418, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u775133993", "n_user": "u775133993", "pos": "from collections import deque\nfrom math import ceil\n\n# n\u4e2a\u602a\u7269\uff0cd\u6740\u4f24\u534a\u5f84\uff0ca\u6740\u4f24\u503c\nn, d, a = map(int,input().split())\n\nms = [map(int, input().split()) for i in range(n)]\nms = sorted([(pos, ceil(hp / a)) for pos, hp in ms])\n \nbombs = deque()\n \nans = 0\nvalid_bomb = 0\nfor pos, hp in ms:\n # \u67e5\u770b\u961f\u5217\u91cc\u7684bomb\u662f\u5426\u5bf9\u5f53\u524d\u602a\u7269\u6709\u6548\n while bombs and bombs[0][0] < pos:\n bomb_border, bomb_cnt = bombs.popleft()\n valid_bomb -= bomb_cnt\n \n # \u8fd8\u9700\u65b0\u52a0\u591a\u5c11bomb\u624d\u80fd\u706d\u6389\u5f53\u524d\u602a\u7269\n bomb_cnt = max(0, hp - valid_bomb)\n valid_bomb += bomb_cnt\n ans += bomb_cnt\n \n # \u65b0\u52a0\u7684bomb\u653e\u5165\u961f\u5217\n if bomb_cnt > 0:\n bombs.append([pos + d * 2, bomb_cnt])\n \nprint(ans) \n", "neg": "from collections import deque\nfrom math import ceil\n\n# n\u4e2a\u602a\u7269\uff0cd\u6740\u4f24\u534a\u5f84\uff0ca\u6740\u4f24\u503c\nn, d, a = map(int,input().split())\n\nms = sorted([(pos, ceil(hp / a)) for pos, hp in [map(int, input().split()) for i in range(n)])\n \nbombs = deque()\n \nans = 0\nvalid_bomb = 0\nfor pos, hp in ms:\n # \u67e5\u770b\u961f\u5217\u91cc\u7684bomb\u662f\u5426\u5bf9\u5f53\u524d\u602a\u7269\u6709\u6548\n while que and que[0][0] < pos:\n bomb_border, bomb_cnt = bombs.popleft()\n valid_bomb -= bomb_cnt\n \n # \u8fd8\u9700\u65b0\u52a0\u591a\u5c11bomb\u624d\u80fd\u706d\u6389\u5f53\u524d\u602a\u7269\n bomb_cnt = max(0, hp - valid_bomb)\n valid_bomb += bomb_cnt\n ans += bomb_cnt\n \n # \u65b0\u52a0\u7684bomb\u653e\u5165\u961f\u5217\n if bomb_cnt > 0:\n que.append([pos + d * 2, bomb_cnt])\n \nprint(ans) \n", "jacc_sim": 0.9883720930232558, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [383, 376], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u723711163", "n_user": "u723711163", "pos": "import math\nfrom collections import deque\nN,D,A = map(int,input().split())\nmonsters = sorted([ list(map(int,input().split())) for _ in range(N) ])\nmonsters = [ [x, math.ceil(h/A)] for x,h in monsters ]\n# print(monsters)\nque = deque()\ncur = 0\nans = 0\nfor x,h in monsters:\n while que and x > que[0][0]:\n _,n = que.popleft()\n cur -= n\n\n need = max(0, h-cur)\n ans += need\n cur += need\n\n if h:\n # \u5bfe\u8c61\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u3092\u6700\u3082\u5de6\u7aef\u306b\u3044\u308b\u3053\u3068\u3092\u60f3\u5b9a\n que.append([x+2*D, need])\n\nprint(ans)", "neg": "import math\nfrom collections import deque\nN,D,A = map(int,input().split())\nmonsters = [ list(map(int,input().split())) for _ in range(N) ]\nmonsters = [ [x, math.ceil(h/A)] for x,h in monsters ]\n\nprint(monsters)\n\nque = deque()\ncur = 0\nans = 0\nfor x,h in monsters:\n while que and x > que[0][0]:\n _,n = que.popleft()\n cur -= n\n\n need = max(0, h-cur)\n ans += need\n cur += need\n\n if h:\n # \u5bfe\u8c61\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u3092\u6700\u3082\u5de6\u7aef\u306b\u3044\u308b\u3053\u3068\u3092\u60f3\u5b9a\n que.append([x+2*D, need])\n\nprint(ans)", "jacc_sim": 0.9857142857142858, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [252, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u493520238", "n_user": "u493520238", "pos": "from collections import deque\n\nn,d,a = map(int, input().split())\nxhl = []\nfor _ in range(n):\n x,h = map(int, input().split())\n cnt = (h-1)//a + 1\n xhl.append((x,cnt))\n\nxhl.sort()\n\nattack_q = deque([])\nattack_sum = 0\nans = 0\nfor x,h in xhl:\n # print('----',((x,h)))\n # print(attack_q)\n # print(attack_sum)\n while attack_q and attack_q[0][0] < x:\n poped_cnt = attack_q.popleft()[1]\n attack_sum -= poped_cnt\n # print(attack_q)\n # print(attack_sum)\n rem = h-attack_sum\n if rem <= 0:\n continue\n attack_sum += rem\n ans += rem\n attack_q.append((x+2*d, rem))\n # print(rem)\n\nprint(ans)\n# print(xhl)", "neg": "from collections import deque\n\nn,d,a = map(int, input().split())\nxhl = []\nfor _ in range(n):\n x,h = map(int, input().split())\n cnt = (h-1)//a + 1\n xhl.append((x,cnt))\n\nattack_q = deque([])\nattack_sum = 0\nans = 0\nfor x,h in xhl:\n while attack_q and attack_q[0][0] < x:\n poped_cnt = attack_q.popleft()[1]\n attack_sum -= poped_cnt\n rem = h-attack_sum\n if rem <= 0:\n continue\n attack_sum += rem\n ans += rem\n attack_q.append((x+2*d, rem))\n\nprint(ans)", "jacc_sim": 0.94, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [273, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u333700164", "n_user": "u333700164", "pos": "from collections import deque\nn,d,a=map(int,input().split())\nxh=[list(map(int,input().split())) for _ in range(n)]\nxh.sort()\nd=2*d\nans=0\ntotal=0\nq=deque()\nfor i in range(n):\n x,h=xh[i]\n while len(q)>=1 and x>q[0][0]:\n total-=q.popleft()[1]\n h-=total\n if h>0:\n num=(h-1)//a+1\n damage=a*num\n ans+=num\n total+=damage\n q.append([x+d,damage])\nprint(ans)\n", "neg": "from collections import deque\nn,d,a=map(int,input().split())\nxh=[map(int,input().split()) for _ in range(n)]\nxh.sort()\nD=2*D\nans=0\ntotal=0\nq=deque()\nfor i in range(n):\n x,h=xh[i]\n while len(q)>=1 and x>q[0][0]:\n total-=q.popleft()[1]\n h-=total\n if h>0:\n num=(h-h%a)//a\n damage=a*nim\n ans+=num\n total+=damage\n q.append([x+D,damage])\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [186, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u353402627", "n_user": "u353402627", "pos": "from collections import deque\nn, d, a = map(int, input().split())\n\nmons = []\n\nfor i in range(n):\n x, h = map(int, input().split())\n mons.append((x, h))\n\nmons = sorted(mons)\n\nq = deque()\n\ndm_sum = 0\n\nans = 0\n\nfor i in range(n):\n while dm_sum > 0:\n if q[0][0] < mons[i][0]:\n cur = q.popleft()\n dm_sum -= cur[1]\n else:\n break\n if mons[i][1] <= dm_sum:\n continue\n rem = mons[i][1] - dm_sum\n at_num = rem // a\n if rem % a != 0:\n at_num += 1\n ans += at_num\n\n q.append((mons[i][0] + 2 * d, at_num*a))\n dm_sum += at_num*a\n\nprint(ans)\n", "neg": "from collections import deque\nn, d, a = map(int, input().split())\n\nmons = []\n\nfor i in range(n):\n x, h = map(int, input().split())\n mons.append((x, h))\n\nmons = sorted(mons)\n\nprint(mons)\n\nq = deque()\n\ndm_sum = 0\n\nans = 0\n\nfor i in range(n):\n while dm_sum > 0:\n if q[0][0] < mons[i][0]:\n cur = q.popleft()\n dm_sum -= cur[1]\n else:\n break\n if mons[i][1] <= dm_sum:\n continue\n rem = mons[i][1] - dm_sum\n at_num = rem // a\n if rem % a != 0:\n at_num += 1\n ans += at_num\n\n q.append((mons[i][0] + 2 * d, at_num*a))\n dm_sum += at_num*a\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [256, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u653837719", "n_user": "u653837719", "pos": "from math import ceil\nfrom collections import deque\n\nn, d, a = map(int, input().split())\nm = sorted([list(map(int, input().split())) for _ in range(n)])\nm = [[x, ceil(h / a)] for x, h in m]\n\nacc_damage = 0\nque = deque()\nans = 0\nfor x, h in m:\n while que and x > que[0][0]:\n limit, damage = que.popleft()\n acc_damage -= damage\n\n need = max(0, h - acc_damage)\n ans += need\n acc_damage += need\n\n if need:\n que.append([x + 2 * d, need])\n\nprint(ans)\n", "neg": "from math import ceil\nfrom collections import deque\n\nn, d, a = map(int, input().split())\nm = [list(map(int, input().split())) for _ in range(n)]\nm = [[x, ceil(h/a)] for x, h in m]\n\nacc_damage = 0\nque = deque()\nans = 0\nfor x, h in m:\n while que and x > que[0][0]:\n limit, damage = que.popleft()\n acc_damage -= damage\n\n rest_h = max(0, h - acc_damage)\n ans += rest_h\n acc_damage += rest_h\n\n if rest_h:\n que.append([x + 2 * d, rest_h])\n\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [189, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u844789719", "n_user": "u844789719", "pos": "import sys, heapq\ninput = sys.stdin.readline\nN, D, A = [int(_) for _ in input().split()]\nXH = [[int(_) for _ in input().split()] for _ in range(N)]\nHe = [[2 * x, h, 0] for x, h in XH]\nheapq.heapify(He)\nnow = 0\nans = 0\nwhile He:\n x, h, t = heapq.heappop(He)\n if t:\n now -= h\n else:\n if h - A * now > 0:\n diff = (h - A * now - 1) // A + 1\n now += diff\n ans += diff\n heapq.heappush(He, [x + 4 * D + 1, diff, 1])\nprint(ans)\n", "neg": "import sys, heapq\ninput = sys.stdin.readline\nN, D, A = [int(_) for _ in input().split()]\nXH = [[int(_) for _ in input().split()] for _ in range(N)]\nHe = [[2 * x, h, 0] for x, h in XH]\nheapq.heapify(He)\nnow = 0\nans = 0\nwhile He:\n x, h, t = heapq.heappop(He)\n if t:\n now -= h\n else:\n if h - D * now > 0:\n diff = (h - now - 1) // A + 1\n now += diff\n ans += diff\n heapq.heappush(He, [x + 4 * D + 1, diff, 1])\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [196, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u169350228", "n_user": "u169350228", "pos": "import math\nn, d, a = map(int,input().split())\ne = [[] for i in range(n)]\nfor i in range(n):\n x, h = map(int,input().split())\n e[i] = [x,h]\nnum = 0\n\ne.sort()\nsd = [0 for i in range(n)]\nl = [i for i in range(n)]\nfor i in range(n):\n for j in range(l[i-1],i):\n if e[i][0]-e[j][0] <= 2*d:\n l[i] = j\n break\n\nfor i in range(n):\n res = e[i][1] - sd[i-1] + sd[l[i]-1]\n if res < 0:\n sd[i] = sd[i-1]\n else:\n k = math.ceil(res/a)\n sd[i] = sd[i-1]+k*a\n num += k\n\nprint(num)\n", "neg": "import math\nn, d, a = map(int,input().split())\ne = [[] for i in range(n)]\nfor i in range(n):\n x, h = map(int,input().split())\n e[i] = [x,h]\nnum = 0\n\ne.sort()\nsd = [0 for i in range(n)]\nl = [i for i in range(n)]\nfor i in range(n):\n for j in range(l[i-1],i):\n if e[i][0]-e[j][0] <= 2*d:\n l[i] = j\n break\n\nfor i in range(n):\n res = x[i][1] - sd[i-1] + sd[l[i]-1]\n if res < 0:\n sd[i] = sd[i-1]\n else:\n k = math.ceil(res/a)\n sd[i] = sd[i-1]+k*a\n num += k\n \nprint(num)\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [253, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u814986259", "n_user": "u814986259", "pos": "import math\nimport collections\nN, D, A = map(int, input().split())\n\nXH = [tuple(map(int, input().split())) for i in range(N)]\nXH.sort()\nq = collections.deque()\nc = 0\nans = 0\nfor x, h in XH:\n while(q and q[0][0] < x):\n c -= q[0][1]\n q.popleft()\n h -= c * A\n if h < 0:\n h = 0\n ans += math.ceil(h/A)\n c += math.ceil(h/A)\n\n q.append((x+2*D, math.ceil(h/A)))\n\nprint(ans)\n", "neg": "import math\nimport collections\nN, D, A = map(int, input().split())\n\nXH = [tuple(map(int, input().split())) for i in range(N)]\n\nq = collections.deque()\nc = 0\nans = 0\nfor x, h in XH:\n while(q and q[0][0] < x):\n c -= q[0][1]\n q.popleft()\n\n h -= c * A\n ans += math.ceil(h/A)\n c += math.ceil(h/A)\n q.append((x+2*D, math.ceil(x/A)))\n #print(ans, x)\nprint(ans)\n", "jacc_sim": 0.9361702127659575, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [181, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u970899068", "n_user": "u970899068", "pos": "import sys\ninput = sys.stdin.readline\nimport bisect\nimport collections\nfrom collections import deque\nn,d,a= map(int, input().split())\nx= [list(map(int, input().split())) for i in range(n)]\n\nx.sort()\ny=[]\nfor i in range(n):\n y.append(x[i][0])\n x[i][1]=-(-x[i][1]//a)\n\n# \u3069\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u307e\u3067\u5012\u3057\u305f\u304b\u7ba1\u7406\u3057\u306a\u304c\u3089\u9032\u3081\u308b\u3002\n# \u7d2f\u7a4d\u30c0\u30e1\u30fc\u30b8\u3092\u7ba1\u7406\nqq=deque([])\nans=0\natk=0\nfor i in range(n):\n w=x[i][1]\n # i\u304c\u30c0\u30e1\u30fc\u30b8\u306e\u6709\u52b9\u671f\u9650\u3092\u8d85\u904e\u3057\u3066\u3044\u308b\u5834\u5408\n while len(qq)>0 and i > qq[0][0]:\n atk-=qq[0][1]\n qq.popleft()\n\n if w-atk>0:\n ans+=w-atk\n q=bisect.bisect_right(y,x[i][0]+2*d)-1\n # \u6709\u52b9\u671f\u9650\u3000\u30c0\u30e1\u30fc\u30b8\n qq.append([q,w-atk])\n atk += w - atk\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nimport bisect\nimport collections\nfrom collections import deque\nn,d,a= map(int, input().split())\nx= [list(map(int, input().split())) for i in range(n)]\n\nx.sort()\ny=[]\nfor i in range(n):\n y.append(x[i][0])\n x[i][1]=-(-x[i][1]//a)\n\n# \u3069\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u307e\u3067\u5012\u3057\u305f\u304b\u7ba1\u7406\u3057\u306a\u304c\u3089\u9032\u3081\u308b\u3002\n# \u7d2f\u7a4d\u30c0\u30e1\u30fc\u30b8\u3092\u7ba1\u7406\nqq=deque([])\nans=0\natk=0\nfor i in range(n):\n w=x[i][1]\n # i\u304c\u30c0\u30e1\u30fc\u30b8\u306e\u6709\u52b9\u671f\u9650\u3092\u8d85\u904e\u3057\u3066\u3044\u308b\u5834\u5408\n while qq and i > qq[0][0]:\n atk-=qq[0][1]\n qq.popleft()\n\n if w-atk>0:\n ans+=w-atk\n q=bisect.bisect_right(y,x[i][0]+2*d)-1\n # \u6709\u52b9\u671f\u9650\u3000\u30c0\u30e1\u30fc\u30b8\n qq.append([q,w-atk])\n atk += w - atk\n print(atk,qq)\nprint(ans)", "jacc_sim": 0.989010989010989, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [444, 447], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u186838327", "n_user": "u186838327", "pos": "n, d, a = map(int, input().split())\nl = [[0, 0] for _ in range(n)]\nfor i in range(n):\n x, h = map(int, input().split())\n l[i][0] = x\n l[i][1] = h\n \nl.sort()\nfrom collections import deque\nd = 2*d\nq = deque([])\ntotal = 0\n\nans = 0\nfor i in range(n):\n x = l[i][0]\n h = l[i][1]\n if q:\n while q[0][0] < x:\n total -= q[0][1]\n q.popleft()\n if not q:\n break\n h -= total\n if h > 0:\n num = (h+a-1)//a\n ans += num\n damage = num*a\n total += damage\n q.append([x+d, damage])\n\nprint(ans)", "neg": "n, d, a = map(int, input().split())\nl = [[0, 0] for _ in range(n)]\nfor i in range(n):\n x, h = map(int, input().split())\n l[i][0] = x\n l[i][1] = h\n \nl.sort()\nprint(l)\nfrom collections import deque\nd = 2*d\nq = deque([])\ntotal = 0\n\nans = 0\nfor i in range(n):\n x = l[i][0]\n h = l[i][1]\n if q:\n while q[0][0] < x:\n total -= q[0][1]\n q.popleft()\n if not q:\n break\n h -= total\n if h > 0:\n num = (h+a-1)//a\n ans += num\n damage = num*a\n total += damage\n q.append([x+d, damage])\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [241, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u905582793", "n_user": "u905582793", "pos": "import bisect\nimport sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\nn,d,a = map(int,input().split())\nxh = [list(map(int,input().split())) for i in range(n)]\nfor i in range(n):\n xh[i][1] = (xh[i][1]+a-1)//a\nxh.sort()\nx = [xh[i][0] for i in range(n)]\nremain = [xh[i][1] for i in range(n)]\nans = 0\nbit = Bit(n+1)\n\nfor i in range(n):\n if bit.sum(i+1) >= remain[i]:\n continue\n br = bisect.bisect_right(x,x[i]+2*d)\n y = remain[i]-bit.sum(i+1)\n ans += y\n bit.add(i+1,y)\n bit.add(br+1,-y)\nprint(ans)", "neg": "import bisect\nimport sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\nn,d,a = map(int,input().split())\nxh = [list(map(int,input().split())) for i in range(n)]\nfor i in range(n):\n xh[i][1] = (xh[i][1]+a-1)//a\nxh.sort()\nx = [xh[i][0] for i in range(n)]\nremain = [xh[i][1] for i in range(n)]\nans = 0\nbit = Bit(n)\nfor i in range(n):\n if bit.sum(i+1) >= remain[i]:\n continue\n br = bisect.bisect_right(x,x[i]+2*d)\n ans += remain[i]\n bit.add(i+1,remain[i])\n bit.add(br+1,-remain[i])\nprint(ans)", "jacc_sim": 0.9838709677419355, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [367, 356], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u563676207", "n_user": "u563676207", "pos": "from collections import deque\n\n# input\nN, D, A = map(int, input().split())\nXH = [tuple(map(int, input().split())) for _ in range(N)]\n\n# process\nXH.sort()\n#print(XH)\n\nans = 0\ndq = deque()\ndam = 0\nfor x, h in XH:\n while dq:\n x2, h2 = dq[0]\n if x > x2:\n dam -= h2\n dq.popleft()\n else:\n break\n\n h -= dam\n if h <= 0:\n# print(\"x,h,dam: {},{},{}\".format(x,h,dam))\n continue\n\n c = -(-h//A)\n ans += c\n d = A*c\n dam += d\n dq.append((x+D*2, d))\n# print(\"x,h,dam,ans,dq: {},{},{},{},{}\".format(x,h,dam,ans,dq))\n \n# output\nprint(ans)\n", "neg": "from collections import deque\n\n# input\nN, D, A = map(int, input().split())\nXH = [tuple(map(int, input().split())) for _ in range(N)]\n\n# process\nXH.sort()\nprint(XH)\n\nans = 0\ndq = deque()\ndam = 0\nfor x, h in XH:\n while dq:\n x2, h2 = dq[0]\n if x > x2:\n dam -= h2\n dq.popleft()\n else:\n break\n\n h -= dam\n if h <= 0:\n continue\n\n c = -(-h//A)\n ans += c\n d = A*c\n dam += d\n dq.append((x+D*2, d))\n \n# output\nprint(ans)\n", "jacc_sim": 0.9310344827586207, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [271, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u102960641", "n_user": "u102960641", "pos": "from operator import itemgetter\nimport bisect\nimport math\n\nN,d,a = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0))\nx = []\nfor X,h in xh:\n x.append(X)\nans = 0\nattack_start = [i for i in range(N)]\nnow = 0\ncumsum = [0] * (N+1)\nfor L,(X,H) in enumerate(xh):\n R = bisect.bisect_right(x,X+2*d)\n for i in range(now,R):\n attack_start[i] = L\n now = R\n damage = (cumsum[L] - cumsum[attack_start[L]]) * a\n attack_time = max(0,math.ceil((H - damage) / a))\n ans += attack_time\n cumsum[L+1] = ans\nprint(ans)\n\n", "neg": "from operator import itemgetter\nimport bisect\nimport math\n\nN,d,a = map(int, input().split())\nxh = sorted([list(map(int, input().split())) for i in range(N)], key=itemgetter(0))\nx = []\nfor X,h in xh:\n x.append(X)\nans = 0\nattack_start = [i for i in range(N)]\nnow = 0\ncumsum = [0] * (N+1)\nfor L,(X,H) in enumerate(xh):\n R = bisect.bisect_right(x,X+2*d)\n for i in range(now,R):\n attack_start[i] = L\n now = R\n damage = (cumsum[L] - cumsum[attack_start[L]]) * a\n attack_time = max(0,math.ceil((H - damage) / a))\n ans += attack_time\n cumsum[L+1] = ans\nprint(ans) \nprint(attack_start)\nprint(cumsum)\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [249, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u419877586", "n_user": "u419877586", "pos": "from collections import deque\n\nN, D, A=map(int, input().split())\nXH=[list(map(int, input().split())) for _ in range(N)]\nXH.sort(key=lambda x:x[0])\ntotal=0\nq=deque()\nans=0\n\nfor i in range(N):\n X, H=XH[i]\n while len(q) and q[0][0]0:\n attack_cnt=(H-1)//A+1\n ans+=attack_cnt\n damage=attack_cnt*A\n total+=damage\n q.append([X+2*D, damage])\nprint(ans)", "neg": "from collections import deque\n\nN, D, A=map(int, input().split())\nXH=[list(map(int, input().split())) for _ in range(N)]\nXH.sort(key=lambda x:x[0])\ntotal=0\nq=deque()\nans=0\n\nfor i in range(N):\n X, H=XH[i]\n while len(q) and q[0][0]0:\n attack_cnt=(H-1)//A+1\n ans+=attack_cnt\n damage=attack_cnt*A\n total+=damage\n q.append([X+2*D, damage])\nprint(ans)", "jacc_sim": 0.9629629629629629, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [198, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u638057737", "n_user": "u638057737", "pos": "from math import ceil\nfrom collections import deque\n\nN,D,A = map(int,input().split())\nmonsters = sorted([list(map(int,input().split())) for _ in range(N)])\n\nq = deque([])\ns = 0\n\nans = 0\nfor i in range(N):\n while len(q) > 0 and q[0][0] < monsters[i][0]:\n s -= q[0][1]\n q.popleft()\n\n h = monsters[i][1] - s * A\n if h > 0:\n num_bombs = ceil(h / A)\n\n q.append((monsters[i][0] + 2 * D, num_bombs))\n s += num_bombs\n ans += num_bombs\n \nprint(ans)\n", "neg": "from math import ceil\nfrom collections import deque\n\nN,D,A = map(int,input().split())\nmonsters = sorted([list(map(int,input().split())) for _ in range(N)])\n\nq = deque([])\ns = 0\n\nans = 0\nfor i in range(N):\n print(q)\n while len(q) > 0 and q[0][0] < monsters[i][0]:\n s -= q[0][1]\n q.popleft()\n\n h = monsters[i][1] - s * A\n if h > 0:\n num_bombs = ceil(h / A)\n\n q.append((monsters[i][0] + 2 * D, num_bombs))\n s += num_bombs\n ans += num_bombs\n \nprint(ans)\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [207, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u554954744", "n_user": "u554954744", "pos": "n, d, a = map(int, input().split())\np = []\nfor i in range(n):\n x, h = map(int, input().split())\n p.append((x, h))\n\nfrom collections import deque\n\np.sort()\n\nq = deque()\ntotal = 0\nans = 0\nfor i in range(n):\n x, h = p[i][0], p[i][1]\n while q and q[0][0] < x:\n total -= q[0][1]\n q.popleft()\n h -= total\n if h > 0:\n num = (h+a-1)//a\n ans += num\n damage = num*a\n total += damage\n q.append((x+2*d, damage))\n\nprint(ans)", "neg": "n, d, a = map(int, input().split())\np = []\nfor i in range(n):\n x, h = map(int, input().split())\n p.append((x, h))\n\nfrom collections import deque\n\np.sort()\n\nq = deque()\ntotal = 0\nans = 0\nfor i in range(n):\n x, h = p[i][0], p[i][1]\n while q and q[0][0] <= x:\n total -= q[0][1]\n q.popleft()\n h -= total\n if h > 0:\n num = (h+a-1)//a\n ans += num\n damage = num*a\n total += damage\n q.append((x+2*d, damage))\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [201, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u255382385", "n_user": "u516927307", "pos": "from collections import deque\nn, d, a = map(int, input().split())\nmonster = []\nfor i in range(n):\n monster.append(list(map(int, input().split())))\n\nd *= 2\nmonster.sort()\n\ncount = 0\ndamage_total = 0\nq = deque([])\n\nfor i in range(n):\n x = monster[i][0]\n h = monster[i][1]\n while len(q) > 0 and q[0][0] < x:\n damage_total -= q[0][1]\n q.popleft()\n\n h -= damage_total\n if h > 0:\n count_now = (h + a - 1) // a\n count += count_now\n damage_now = a * count_now\n damage_total += damage_now\n q.append([x + d, damage_now])\n\nprint(count)", "neg": "from collections import deque\nn, d, a = map(int, input().split())\nd *= 2\n\ncount = 0\ndamage_total = 0\nq = deque([])\n\nfor i in range(n):\n x, h = map(int, input().split())\n while len(q) > 0 and q[0][0] < x:\n damage_total -= q[0][1]\n q.popleft()\n\n h -= damage_total\n if h > 0:\n count_now = (h + a - 1) // a\n count += count_now\n damage_now = a * count_now\n damage_total += damage_now\n q.append([x + d, damage_now])\n\nprint(count)", "jacc_sim": 0.9387755102040817, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [238, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u922965680", "n_user": "u922965680", "pos": "import sys\nimport math\n\ndef main():\n n_d_a = sys.stdin.readline().strip().split(' ')\n n, d, a = [int(s) for s in n_d_a]\n xh = [[]] * n\n\n for i in range(n):\n x, h = [int(s) for s in sys.stdin.readline().strip().split(' ')]\n xh[i] = [x, h]\n # n = 3\n # d = 1\n # a = 1\n # xh = [[1, 4], [2, 1], [3, 100]]\n xh.sort()\n\n cur = 0\n right_indices = [0] * n\n for i in range(n):\n cur = max(cur, i)\n x, h = xh[i]\n right_val = x + d * 2\n while cur < n-1 and xh[cur+1][0] <= right_val:\n cur += 1\n right_indices[i] = cur\n\n imos = [0] * (n+1)\n ans = 0\n for i in range(n):\n if imos[i] < xh[i][1]:\n need = math.ceil((xh[i][1] - imos[i]) / a)\n ans += need\n imos[i] += need * a\n right_idx = right_indices[i]\n imos[right_idx+1] -= need * a\n imos[i+1] += imos[i]\n print(ans)\n\nif __name__ == '__main__':\n main()\n\n", "neg": "import sys\nimport math\n\ndef main():\n n_d_a = sys.stdin.readline().strip().split(' ')\n n, d, a = [int(s) for s in n_d_a]\n xh = [[]] * n\n\n for i in range(n):\n x, h = [int(s) for s in sys.stdin.readline().strip().split(' ')]\n xh[i] = [x, h]\n xh.sort()\n\n cur = 0\n right_indices = [0] * n\n for i in range(n):\n cur = max(cur, i)\n x, h = xh[i]\n right_val = x + d * 2\n while cur < n-1 and xh[cur+1][1] <= right_val:\n cur += 1\n right_indices[i] = cur\n\n imos = [0] * (n+1)\n ans = 0\n for i in range(n):\n if imos[i] < xh[i][1]:\n need = math.ceil((xh[i][1] - imos[i]) / a)\n print('need', need)\n ans += need\n imos[i] += need * a\n right_idx = right_indices[i]\n imos[right_idx+1] -= need * a\n imos[i+1] += imos[i]\n print(ans)\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 0.9322033898305084, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [405, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u779455925", "n_user": "u779455925", "pos": "# input = sys.stdin.readline\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\n# import functools\n# import itertools\n# import math\nN,D,A=map(int,input().split())\nXH=[list(map(int,input().split())) for i in range(N)]\nXH=sorted(XH,key=lambda x:x[0])\n\nlst=[]\nbomb=[]\ncount=0\nnowbomb=0\nidx=0\n#print(XH)\nfor x,h in XH:\n #print(lst,bomb)\n if lst:\n while idx0:\n\n b=a//A+(a%A>0)*1\n #print(a,b)\n nowbomb+=b*A\n count+=b\n lst.append(x+D)\n bomb.append(b*A)\n\nprint(count)\n", "neg": "# input = sys.stdin.readline\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\n# import functools\n# import itertools\n# import math\nN,D,A=map(int,input().split())\nXH=[list(map(int,input().split())) for i in range(N)]\nXH=sorted(XH,key=lambda x:x[0])\n\nlst=[]\nbomb=[]\ncount=0\nnowbomb=0\nidx=0\n#print(XH)\nfor x,h in XH:\n print(lst,bomb)\n if lst:\n while idx0:\n\n b=a//A\n #print(b)\n nowbomb+=D*b\n count+=b\n lst.append(x+D)\n bomb.append(b*D)\n\nprint(count)\n", "jacc_sim": 0.9833333333333333, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [279, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u566529875", "n_user": "u566529875", "pos": "n,d,a=map(int,input().split())\nxh=[list(map(int,input().split())) for _ in range(n)]\nxh.sort()\n\nimport collections\npq=collections.deque()\n\nans = 0\ntotalDamage = 0\n\n\nfor i in range(n):\n x,h = xh[i]\n while len(pq) > 0 and pq[0][0] < x:\n totalDamage -= pq[0][1]\n pq.popleft()\n h -=totalDamage\n if h <= 0:\n continue\n num = (h + a -1) //a\n ans += num\n dam = num*a\n totalDamage += dam\n pq.append((x+2*d,dam))\n\nprint(ans)", "neg": "n,d,a=map(int,input().split())\nxh=[list(map(int,input().split())) for _ in range(n)]\nxh.sort(key=itemgetter(0))\n\nimport collections\npq=collections.deque()\n\nans = 0\ntotalDamage = 0\n\n\nfor i in range(n):\n x,h = xh[i]\n if len(pq) and pq[0][0] < x:\n totalDamage -= pq[0][1]\n pq.popleft()\n h -=totalDamage\n if h <= 0:\n continue\n num = (h + a -1) //a\n ans += num\n dam = num*a\n totalDamage += dam\n pq.append((x+2*d,dam))\n\nprint(ans)", "jacc_sim": 0.9245283018867925, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [202, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u691896522", "n_user": "u691896522", "pos": "from collections import deque\nimport math\nn, d, a = map(int, input().split())\ndata = []\nfor i in range(n):\n data.append(list(map(int, input().split())))\ndata.sort()\ndam = 0\nans = 0\nq = deque()\nfor i in range(n):\n x,h = data[i]\n while q:\n k = q.popleft()\n if k[1] >= x:\n q.appendleft(k)\n break\n else:\n dam -= k[0]\n h -= dam\n h = max(h, 0)\n count = math.ceil(h / a)\n dam += count * a\n q.append([count * a, x + 2*d])\n ans += count\nprint(ans)\n\n", "neg": "from collections import deque\nimport math\nn, d, a = map(int, input().split())\ndata = []\nfor i in range(n):\n data.append(list(map(int, input().split())))\ndata.sort()\ndam = 0\nans = 0\nq = deque()\nfor i in range(n):\n x,h = data[i]\n while q:\n k = q.popleft()\n if k[1] >= x:\n q.appendleft(k)\n break\n else:\n dam -= k[0]\n print(q)\n h -= dam\n h = max(h, 0)\n count = math.ceil(h / a)\n dam += count * a\n q.append([count * a, x + 2*d])\n ans += count\nprint(ans)\n\n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [202, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u594518120", "n_user": "u594518120", "pos": "import sys\nn, D, a = map(int, input().split())\ntg = []\nfor _ in range(n):\n x, h = map(int, sys.stdin.readline().split())\n c = h // a\n if h % a > 0:\n c+=1\n tg.append([x, c])\n\nclass BIT:\n def __init__(self, n):\n self.n = n\n self.N = 1 << n.bit_length()\n self.data = [0] * (self.N +1)\n\n def add(self, i, x):\n while i <= self.N:\n self.data[i] += x\n i += i & -i\n\n def sum(self, i):\n total = 0\n while i > 0:\n total += self.data[i]\n i -= i&-i\n return total\n\n def search(self, w):\n if w <= 0:\n return 0\n x = 0\n k = self.N >> 1\n while k > 0:\n if x+k <= self.N and self.data[x+k] < w:\n w -= self.data[x+k]\n x += k\n k = k >> 1\n return x+1\n\n def len(self):\n return self.data[self.N]\n\ntg = sorted(tg, key=lambda x:x[0])\nbit = BIT(n+2)\nresult = 0\nind = 0\nfor i in range(n):\n c = tg[i][1] - bit.sum(i+1)\n d = tg[i][0]\n if c <= 0:\n continue\n result += c\n wd = d + 2*D\n if ind < i:\n ind = i\n for j in range(ind, n):\n if tg[j][0] <= wd:\n ind = j\n else:\n break\n bit.add(i+1, c)\n bit.add(ind+2, -c)\nprint(result)", "neg": "import sys\nn, D, a = map(int, input().split())\ntg = []\nfor _ in range(n):\n x, h = map(int, sys.stdin.readline().split())\n c = h // a\n if h % a > 0:\n c+=1\n tg.append([x, c])\n\nclass BIT:\n def __init__(self, n):\n self.n = n\n self.N = 1 << n.bit_length()\n self.data = [0] * (self.N +1)\n\n def add(self, i, x):\n while i <= self.N:\n self.data[i] += x\n i += i & -i\n\n def sum(self, i):\n total = 0\n while i > 0:\n total += self.data[i]\n i -= i&-i\n return total\n\n def search(self, w):\n if w <= 0:\n return 0\n x = 0\n k = self.N >> 1\n while k > 0:\n if x+k <= self.N and self.data[x+k] < w:\n w -= self.data[x+k]\n x += k\n k = k >> 1\n return x+1\n\n def len(self):\n return self.data[self.N]\n\ntg = sorted(tg, key=lambda x:x[0])\nbit = BIT(n+2)\nresult = 0\nind = 0\nfor i in range(n):\n c = tg[i][1] - bit.sum(i+1)\n d = tg[i][0]\n if c <= 0:\n continue\n result += c\n wd = d + 2*D\n if ind < c:\n ind = c\n for j in range(ind, n):\n if tg[j][0] <= wd:\n ind = j\n else:\n break\n bit.add(d+1, c)\n bit.add(ind+2, -c)\nprint(result)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [505, 505], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u399721252", "n_user": "u399721252", "pos": "import collections\nimport bisect\nimport sys\ninput = sys.stdin.readline\n\n# mod = 998244353\n# mod = 1000000007\n\nn, d, a = [ int(v) for v in input().split() ]\nmonster = []\nfor _ in range(n):\n x, h = [ int(v) for v in input().split() ]\n monster.append([x, h])\nmonster.sort()\n\n\nmonster_x, monster_h = [], []\nfor x, h in monster:\n monster_x.append(x)\n monster_h.append(h)\n \n\ndeq = collections.deque([])\ntotaldamage = 0\nans = 0\n\nfor i in range(n):\n \n stop = 1\n while stop == 1 and len(deq) > 0:\n if deq[-1][0] < monster_x[i]:\n totaldamage -= deq[-1][1]\n deq.pop()\n else:\n stop = 0\n \n monster_h[i] -= totaldamage\n if monster_h[i] > 0:\n index = monster_x[i] + 2*d\n \n f = (monster_h[i] + a - 1) // a\n ans += f \n totaldamage += f * a\n deq.appendleft([index, f*a])\n monster_h[i] = 0\n\nprint(ans)", "neg": "import collections\nimport bisect\nimport sys\ninput = sys.stdin.readline\n\n# mod = 998244353\n# mod = 1000000007\n\nn, d, a = [ int(v) for v in input().split() ]\nmonster = []\nfor _ in range(n):\n x, h = [ int(v) for v in input().split() ]\n monster.append([x, h])\nmonster.sort()\n\n\nmonster_x, monster_h = [], []\nfor x, h in monster:\n monster_x.append(x)\n monster_h.append(h)\n \n\n\ndeq = collections.deque([])\ntotaldamage = 0\nans = 0\n\nfor i in range(n):\n monster_h[i] -= totaldamage\n\n\n stop = 1\n while stop == 0 and len(deq) > 0:\n\n if deq[-1][0] == i:\n totaldamage -= deq[-1][1]\n deq.pop()\n else:\n stop = 0\n\n if monster_h[i] > 0:\n index = bisect.bisect_left(monster_x, monster_x[i]+2*d)\n deq.appendleft([index, monster_h[i]])\n f = (monster_h[i] + a - 1) // a\n ans += f \n totaldamage += f* a\n monster_h[i] = 0\n\n\n\nprint(ans)", "jacc_sim": 0.967741935483871, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [366, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u504836877", "n_user": "u504836877", "pos": "N,D,A = map(int, input().split())\nL = [[int(l) for l in input().split()] for _ in range(N)]\n\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nbit = Bit(N)\nL.sort()\nX = []\nfor i in range(N):\n X.append(L[i][0])\n\nimport bisect\nans = 0\nfor i in range(N):\n L[i][1] -= bit.sum(N)-bit.sum(i)\n if L[i][1] <= 0:\n continue\n num = L[i][1]//A+min(1, L[i][1]%A)\n ans += num\n j = bisect.bisect_right(X, L[i][0]+2*D)\n if j > i:\n bit.add(j, num*A)\n \nprint(ans)\n", "neg": "N,D,A = map(int, input().split())\nL = [[int(l) for l in input().split()] for _ in range(N)]\n\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nbit = Bit(N)\nL.sort()\nX = []\nfor i in range(N):\n X.append(L[i][0])\n\nimport bisect\nans = 0\nfor i in range(N):\n L[i][1] -= bit.sum(N)-bit.sum(i)\n if L[i][1] <= 0:\n continue\n num = L[i][1]//A+min(1, L[i][1]%A)\n ans += num\n j = bisect.bisect_right(X, L[i][0]+2*D)\n j -= 1\n if j > i:\n bit.add(i+1, num*A)\n \nprint(ans)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [329, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u729417323", "n_user": "u729417323", "pos": "# --*-coding:utf-8-*--\n\nimport math\n\nN,D,A = map(int, input().split())\nXH = sorted(tuple(map(int, input().split())) for _ in range(N))\n\nQ = []\nqIdx = 0\ns = 0\nt = 0\n\nfor (x, h) in XH:\n while qIdx < len(Q) and Q[qIdx][0] < x:\n s -= Q[qIdx][1]\n qIdx += 1\n\n if s < h:\n q = int(math.ceil((h-s)/A))\n Q.append((x+2*D, q*A))\n s += q*A\n t += q\n\nprint(t)\n \n \n", "neg": "# --*-coding:utf-8-*--\n\nimport math\n\nN,D,A = map(int, input().split())\nXH = sorted(tuple(map(int, input().split())) for _ in range(N))\n\nQ = []\nqIdx = 0\ns = 0\nt = 0\n\nfor (x, h) in XH:\n while qIdx < len(Q) and Q[qIdx][0] < x:\n s -= Q[qIdx][1]\n qIdx += 1\n\n if s < h:\n q = int(math.ceil((h-s)/A))\n Q.append((x+2*D, q))\n s += q\n t += q\n\nprint(t)\n \n \n", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [190, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u619819312", "n_user": "u619819312", "pos": "from bisect import bisect_left as bl\nn,d,a=map(int,input().split())\ns=sorted([list(map(int,input().split()))for i in range(n)])\nc=0\np=[0]\nq=[0]\nfor i in range(n):\n g=bl(q,s[i][0])\n s[i][1]-=a*(p[-1]-p[g-1])\n if s[i][1]>0:\n t=((s[i][1]-1)//a+1)\n c+=t\n p.append(p[-1]+t)\n q.append(s[i][0]+2*d)\nprint(c)", "neg": "from bisect import bisect_left as bl\nn,d,a=map(int,input().split())\ns=sorted([list(map(int,input().split()))for i in range(n)])\nc=0\np=[0]\nq=[0]\nfor i in range(n):\n a=bl(q,s[i][0])\n s[i][1]-=p[-1]-p[a-1]\n if s[i][1]>0:\n t=((s[i][1]-1)//a+1)\n c+=t\n p.append(p[-1]+t)\n q.append(s[i][0]+2*d)\nprint(c)", "jacc_sim": 0.9772727272727273, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [176, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u170201762", "n_user": "u170201762", "pos": "from math import ceil\nfrom bisect import bisect\nfrom operator import itemgetter\nclass BIT:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n \n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n \n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nN,D,A = map(int,input().split())\nXH = [list(map(int,input().split())) for _ in range(N)]\nXH.sort(key=itemgetter(0))\nX = [XH[i][0] for i in range(N)]\nH = [XH[i][1] for i in range(N)]\n\nbit = BIT(N)\nans = 0\nfor i in range(N):\n bit.add(i+1,H[i])\n bit.add(i+2,-H[i])\n h = bit.sum(i+1)\n if h>0:\n ans += ceil(h/A)\n x = -ceil(h/A)*A\n j = bisect(X,X[i]+2*D)\n bit.add(i+1,x)\n bit.add(j+1,-x)\n\nprint(ans)\n", "neg": "from math import ceil\nfrom bisect import bisect\nfrom operator import itemgetter\nclass BIT:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n i += 1\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\nN,D,A = map(int,input().split())\nXH = [list(map(int,input().split())) for _ in range(N)]\nXH.sort(key=itemgetter(0))\nX = [XH[i][0] for i in range(N)]\nH = [XH[i][1] for i in range(N)]\n\nbit = BIT(N)\n\nans = 0\nfor i in range(N):\n bit.add(i+1,H[i])\n bit.add(i+2,-H[i])\n h = bit.sum(i+1)\n if h>0:\n ans += ceil(h/A)\n x = -ceil(h/A)*A\n j = bisect(X,X[i]+2*D)\n bit.add(i+1,x)\n bit.add(j+1,-x)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [361, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u887142477", "n_user": "u887142477", "pos": "N, D, A = map(int, input().split())\nXH = [[0, 0] for _ in range(N)]\n\nfor i in range(N):\n XH[i][0], XH[i][1] = map(int, input().split())\n\nXH.sort()\n# XH\n\nans = 0\nP = 0\nhist = []\nj = 0\nfor i in range(N):\n X, H = XH[i]\n while True:\n if j >= len(hist):\n break\n if hist[j][0] >= X:\n break\n if hist[j][0] < X:\n P -= hist[j][1]\n j += 1\n \n if H - P > 0:\n if (H - P) % A == 0:\n bomb = (H - P) // A\n else:\n bomb = (H - P) // A + 1\n ans += bomb\n P += bomb * A\n hist.append((X + 2 * D, bomb * A))\n \n\nprint(ans)", "neg": "N, D, A = map(int, input().split())\nXH = [[0, 0] for _ in range(N)]\n\nfor i in range(N):\n XH[i][0], XH[i][1] = map(int, input().split())\n\nXH.sort()\n# XH\n\nans = 0\nP = 0\nhist = []\nj = 0\nfor i in range(N):\n X, H = XH[i]\n while True:\n if j >= len(hist):\n break\n if hist[j][0] >= 0:\n break\n if hist[j][0] < X:\n P -= hist[0][1]\n j += 1\n \n if H - P > 0:\n if (H - P) % A == 0:\n bomb = (H - P) // A\n else:\n bomb = (H - P) // A + 1\n ans += bomb\n P += bomb * A\n hist.append((X + 2 * D, bomb * A))\n \n\nprint(ans)", "jacc_sim": 1.0, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [263, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02788", "p_user": "u620868411", "n_user": "u620868411", "pos": "# -*- coding: utf-8 -*-\nimport heapq\nfrom math import ceil\nn,d,a = map(int, input().split())\nxh = [list(map(int, input().split())) for _ in range(n)]\nxh.sort()\n\nres = 0\nb = []\nheapq.heapify(b)\nr = 0\nfor i in range(n):\n x,h = xh[i]\n\n while len(b)>0 and b[0][0]<=x:\n r += b[0][1]\n heapq.heappop(b)\n c = max(ceil((h-r)/a), 0)\n res += c\n r += c*a\n \n if c>0:\n heapq.heappush(b, (x+2*d+1, -c*a))\n\nprint(res)", "neg": "# -*- coding: utf-8 -*-\nimport heapq\nfrom math import ceil\nn,d,a = map(int, input().split())\nxh = [list(map(int, input().split())) for _ in range(n)]\nxh.sort()\nprint(xh)\nres = 0\nb = []\nheapq.heapify(b)\nr = 0\nfor i in range(n):\n x,h = xh[i]\n\n j = 0\n while len(b)>0 and b[j][0]<=x:\n r += b[j][1]\n heapq.heappop(b)\n c = ceil((h-r)/a)\n res += c\n r += c*a\n \n if c>0:\n heapq.heappush(b, (x+2*d+1, -c*a))\n\nprint(res)", "jacc_sim": 0.9649122807017544, "nl": "Silver Fox is fighting with N monsters. The monsters are standing in a row on a number line. The i-th monster at coordinate X_i has health H_i. Silver Fox can use bombs to attack the monsters. Using a bomb at coordinate x decreases the health of monsters between x-D and x+D (inclusive) by A. Silver Fox wins when all monsters' health becomes 0 or below. Find the minimum number of bombs needed to win.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 0 \u2264 D \u2264 10^9\n- 1 \u2264 A \u2264 10^9\n- 0 \u2264 X_i \u2264 10^9\n- 1 \u2264 H_i \u2264 10^9\n- X_i are distinct\n- All input values are integers\n\nInput:\nN D A\nX_1 H_1\n...\nX_N H_N\n\nOutput:\nPrint the minimum number of bombs needed to win.\n\nSample Input 1:\n3 3 2\n1 2\n5 4\n9 2\n\nSample Output 1:\n2\nFirst, use a bomb at coordinate 4 to decrease the first and second monsters' health by 2. Then, use a bomb at coordinate 6 to decrease the second and third monsters' health by 2. Now, all monsters' healths are 0.\n\nSample Input 2:\n9 4 1\n1 5\n2 4\n3 3\n4 2\n5 1\n6 2\n7 3\n8 4\n9 5\n\nSample Output 2:\n5\nUse five bombs at coordinate 5.\n\nSample Input 3:\n3 0 1\n300000000 1000000000\n100000000 1000000000\n200000000 1000000000\n\nSample Output 3:\n3000000000\nWatch out for overflow.", "before_after_length": [217, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u170201762", "n_user": "u170201762", "pos": "from collections import defaultdict\nfrom operator import itemgetter\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nans = 1000\nfor n in range(2**N):\n n = bin(n)[2:]\n if n.count('1')%2!=0:\n continue\n n = '0'*(N-len(n))+n\n l = []\n for i in range(N):\n if n[i]=='0':\n l.append([A[i],i])\n else:\n l.append([B[i],i+1])\n inversion = 0\n for i in range(N):\n if inversion>=ans:\n break\n for j in range(i+1,N):\n if l[i][0]>l[j][0]:\n inversion += 1\n if inversion>=ans:\n continue\n l.sort(key=itemgetter(0))\n d = defaultdict(list)\n for i in range(N):\n v,j = l[i]\n if (i-j)%2==1:\n d[v].append(i)\n possible = True\n for v in d:\n if len(d[v])%2==1:\n possible = False\n else:\n for i in range(len(d[v])//2):\n if (d[v][2*i+1]-d[v][2*i])%2==1:\n inversion += d[v][2*i+1]-d[v][2*i]\n else:\n possible = False\n break\n if not possible:\n break\n if possible:\n ans = min(ans,inversion)\n\nif ans == 1000:\n ans = -1\nprint(ans)", "neg": "from collections import defaultdict\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nans = 1000\nfor n in range(2**N):\n n = bin(n)[2:]\n n = '0'*(N-len(n))+n\n l = []\n for i in range(N):\n if n[i]=='0':\n l.append([A[i],i,0])\n else:\n l.append([B[i],i,1])\n inversion = 0\n for i in range(N):\n if inversion>=ans:\n break\n for j in range(i+1,N):\n if l[i][0]>l[j][0]:\n inversion += 1\n if inversion>=ans:\n continue\n l.sort()\n d = defaultdict(list)\n for i in range(N):\n v,j,k = l[i]\n if (i-j+k)%2==1:\n d[v].append(i)\n possible = True\n for v in d:\n if len(d[v])%2==1:\n possible = False\n else:\n for i in range(len(d[v])//2):\n if (d[v][2*i+1]-d[v][2*i])%2==1:\n inversion += d[v][2*i+1]-d[v][2*i]\n else:\n possible = False\n break\n if not possible:\n break\n if possible:\n ans = min(ans,inversion)\n\nif ans == 1000):\n ans = -1\nprint(ans)", "jacc_sim": 0.9032258064516129, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [452, 428], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u864197622", "n_user": "u864197622", "pos": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAB = sorted(list(set(A + B)))\nD = {ab: i+1 for i, ab in enumerate(AB)}\nA = [D[a] for a in A]\nB = [D[a] for a in B]\n\nans = 1 << 100\nfor m in range(1<> i & 1\n q = p + i & 1\n C[q].append(((A[i] if p == 0 else B[i]) << 5) + i)\n if len(C[1]) != N // 2: continue\n C[0].sort()\n C[1].sort()\n CC = [C[i&1][i//2] for i in range(N)]\n for i in range(1, N):\n if CC[i-1] >> 5 > CC[i] >> 5: break\n else:\n CCC = [c % 32 for c in CC]\n t = 0\n for i in range(N):\n for j in range(i):\n if CCC[i] < CCC[j]: t += 1\n ans = min(ans, t)\nprint(ans if ans < 1 << 100 else -1)", "neg": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAB = sorted(list(set(A + B)))\nD = {ab: i+1 for i, ab in enumerate(AB)}\nA = [D[a] for a in A]\nB = [D[a] for a in B]\n\nans = 1 << 100\nfor m in range(1<> i & 1\n q = p + i & 1\n C[q].append(((A[i] if p == 0 else B[i]) << 5) + i)\n if len(C[1]) != N // 2: continue\n C[0].sort()\n C[1].sort()\n CC = [C[i&1][i//2] for i in range(N)]\n for i in range(1, N):\n if CC[i-1] >> 5 > CC[i] >> 5: break\n else:\n CCC = [c % 32 for c in CC]\n ans = min(ans, chk(CCC))\nprint(ans if ans < 1 << 100 else -1)", "jacc_sim": 0.9393939393939394, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [374, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u333945892", "n_user": "u333945892", "pos": "# from collections import defaultdict,deque\n# import sys,heapq,bisect,math,itertools,string,queue,copy,time\n# sys.setrecursionlimit(10**8)\n#\n#\nimport sys\nimport itertools\nINF = float(\"INF\")\n\nN = int(input())\nAA = list(map(int, sys.stdin.readline().split()))\nBB = list(map(int, sys.stdin.readline().split()))\n\ncards = set()\nfor i,(a,b) in enumerate(zip(AA,BB)):\n if i%2 == 0:\n cards.add((a, b, i))\n else:\n cards.add((b, a, i))\n\ndef solve(ii):\n tmp = 0\n for i in range(N):\n for j in range(i+1,N):\n if ii[i] > ii[j]:\n tmp += 1\n return tmp\n\nans = INF\nfor Acards in itertools.combinations(cards, (N+1)//2):\n Bcards = cards - set(Acards)\n\n Ais = sorted([(card[0], card[2]) for card in Acards])\n Bis = sorted([(card[1], card[2]) for card in Bcards])\n\n bn = -1\n ii = []\n flag = False\n for i in range(N):\n if i%2 == 0:\n n,i = Ais[i//2]\n else:\n n,i = Bis[i//2]\n if bn > n:\n flag = True\n bn = n\n ii.append(i)\n\n if flag: continue\n\n ans = min(ans,solve(ii))\n\n\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n", "neg": "# from collections import defaultdict,deque\n# import sys,heapq,bisect,math,itertools,string,queue,copy,time\n# sys.setrecursionlimit(10**8)\n#\n#\nimport sys\nimport itertools\nINF = float(\"INF\")\n\nN = int(input())\nAA = list(map(int, sys.stdin.readline().split()))\nBB = list(map(int, sys.stdin.readline().split()))\n\ncards = set()\nfor i,(a,b) in enumerate(zip(AA,BB)):\n if i%2 == 0:\n cards.add((a, b, i))\n else:\n cards.add((b, a, i))\n\ndef solve(ii):\n tmp = 0\n for _ in range(N):\n next = []\n for k, i in enumerate(ii):\n if i == 0:\n tmp += k\n else:\n next.append(i-1)\n ii = next[:]\n return tmp\n\nans = INF\nfor Acards in itertools.combinations(cards, (N+1)//2):\n Bcards = cards - set(Acards)\n\n Ais = sorted([(card[0], card[2]) for card in Acards])\n Bis = sorted([(card[1], card[2]) for card in Bcards])\n\n bn = -1\n ii = []\n flag = False\n for i in range(N):\n if i%2 == 0:\n n,i = Ais[i//2]\n else:\n n,i = Bis[i//2]\n if bn > n:\n flag = True\n ii.append(i)\n\n if flag:\n continue\n\n ans = min(ans,solve(ii))\n\n\nif ans == INF:\n print(-1)\nelse:\n print(ans)\n", "jacc_sim": 0.9540229885057471, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [448, 464], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u211160392", "n_user": "u342869120", "pos": "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 10**9+7\nfor i in range(2**N):\n card = [[],[]]\n num = []\n iii = i\n for j in range(N):\n if i&1:\n num.append(B[j])\n card[(j+1)%2].append(j)\n else:\n num.append(A[j])\n card[(j)%2].append(j)\n i >>= 1\n if len(card[1]) != N//2:\n continue\n card[0].sort(key=lambda x:[num[x],x])\n card[1].sort(key=lambda x:[num[x],x])\n hoge = []\n for i in range(N):\n hoge.append(card[i%2][i//2])\n flag = True\n for i in range(N-1):\n if num[hoge[i]] > num[hoge[i+1]]:\n flag = False\n if flag:\n huga = []\n count = 0\n for i in range(N):\n l = bisect.bisect_left(huga,hoge[i])\n huga.insert(l,hoge[i])\n count += i-l\n if count < ans:\n ans = count\nif ans >= 10**9:\n print(-1)\nelse:\n print(ans)", "neg": "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nans = 10**9+7\nfor i in range(2**N):\n card = [[],[]]\n num = []\n iii = i\n for j in range(N):\n if i&1:\n num.append(B[j])\n card[(j+1)%2].append(j)\n else:\n num.append(A[j])\n card[(j)%2].append(j)\n i >>= 1\n if len(card[0]) != N//2:\n continue\n card[0].sort(key=lambda x:[num[x],x])\n card[1].sort(key=lambda x:[num[x],x])\n hoge = []\n for i in range(N):\n hoge.append(card[i%2][i//2])\n flag = True\n for i in range(N-1):\n if num[hoge[i]] > num[hoge[i+1]]:\n flag = False\n if flag:\n huga = []\n count = 0\n for i in range(N):\n l = bisect.bisect_left(huga,hoge[i])\n huga.insert(l,hoge[i])\n count += i-l\n if count < ans:\n ans = count\nif ans >= 10**9:\n print(-1)\nelse:\n print(ans)", "jacc_sim": 1.0, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [390, 390], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u864197622", "n_user": "u864197622", "pos": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAB = sorted(list(set(A + B)))\nD = {ab: i+1 for i, ab in enumerate(AB)}\nA = [D[a] for a in A]\nB = [D[a] for a in B]\ndef chk(L):\n NN = 5\n BIT=[0] * (2**NN+1)\n def addbit(i):\n while i <= 2**NN:\n BIT[i] += 1\n i += i & (-i)\n \n def getsum(i):\n ret = 0\n while i != 0:\n ret += BIT[i]\n i -= i&(-i)\n return ret\n s = 0\n for l in L[::-1]:\n s += getsum(l+1)\n addbit(l+1)\n return s\nans = 1 << 100\nfor m in range(1<> i & 1\n q = p + i & 1\n C[q].append(((A[i] if p == 0 else B[i]) << 5) + i)\n if len(C[1]) != N // 2: continue\n C[0].sort()\n C[1].sort()\n CC = [C[i&1][i//2] for i in range(N)]\n for i in range(1, N):\n if CC[i-1] >> 5 > CC[i] >> 5: break\n else:\n CCC = [c % 32 for c in CC]\n ans = min(ans, chk(CCC))\nprint(ans if ans < 1 << 100 else -1)", "neg": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAB = sorted(list(set(A + B)))\nD = {ab: i+1 for i, ab in enumerate(AB)}\nA = [D[a] for a in A]\nB = [D[a] for a in B]\n\ndef chk(L):\n NN = 5\n BIT=[0] * (2**NN+1)\n def addbit(i):\n while i <= 2**NN:\n BIT[i] += 1\n i += i & (-i)\n\n def getsum(i):\n ret = 0\n while i != 0:\n ret += BIT[i]\n i -= i&(-i)\n return ret\n s = 0\n for l in L[::-1]:\n s += getsum(l+1)\n addbit(l+1)\n return s\nans = 0\nfor m in range(1<> i & 1\n q = p + i & 1\n C[q].append(A[i] if p == 0 else B[i])\n CC = sorted(C[0] + C[1])\n if CC[::2] != sorted(C[0]): continue\n CCC = [C[i%2][i//2] for i in range(N)]\n ans += chk(CCC)\nprint(ans)", "jacc_sim": 0.9066666666666666, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [459, 391], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02798", "p_user": "u877470159", "n_user": "u342869120", "pos": "import sys\ninput=sys.stdin.readline\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=10**9\ndef bubble_sort(arr):\n change = True\n num=0\n while change:\n change = False\n for i in range(len(arr) - 1):\n if arr[i] > arr[i + 1]:\n arr[i], arr[i + 1] = arr[i + 1], arr[i]\n change = True\n num+=1\n return num\nfor i in range(2**n):\n even=[]\n odd=[]\n for j in range(n):\n x=(i>>j)%2\n if j%2==0:\n if x==0:\n even.append((a[j],j))\n else:\n odd.append((b[j],j))\n else:\n if x==0:\n odd.append((a[j],j))\n else:\n even.append((b[j],j))\n if len(odd)!=n//2:\n continue\n even.sort()\n odd.sort()\n check=True\n order=[]\n new=[]\n for j in range(n//2):\n order.append(even[j][1])\n order.append(odd[j][1])\n new.append(even[j][0])\n new.append(odd[j][0])\n if n%2!=0:\n new.append(even[-1][0])\n order.append(even[-1][1])\n for j in range(n-1):\n if new[j]>new[j+1]:\n check=False\n if not check:\n continue\n x=bubble_sort(order)\n ans=min(ans,x)\nif ans==10**9:\n print(-1)\nelse:\n print(ans)\n \n \n \n \n", "neg": "import sys\ninput=sys.stdin.readline\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nans=10**9\ndef bubble_sort(arr):\n change = True\n num=0\n while change:\n change = False\n for i in range(len(arr) - 1):\n if arr[i] > arr[i + 1]:\n arr[i], arr[i + 1] = arr[i + 1], arr[i]\n change = True\n num+=1\n return num\nfor i in range(2**n):\n even=[]\n odd=[]\n for j in range(n):\n x=(i>>j)%2\n if j%2==0:\n if x==0:\n even.append((a[j],j))\n else:\n odd.append((b[j],j))\n else:\n if x==0:\n odd.append((a[j],j))\n else:\n even.append((b[j],j))\n #if len(odd)!=n//2:\n # continue\n even.sort()\n odd.sort()\n check=True\n order=[]\n new=[]\n for j in range(n//2):\n order.append(even[j][1])\n order.append(odd[j][1])\n new.append(even[j][0])\n new.append(odd[j][0])\n if n%2!=0:\n new.append(even[-1][0])\n order.append(even[-1][1])\n for j in range(n-1):\n if new[j]>new[j+1]:\n check=False\n if not check:\n continue\n x=bubble_sort(order)\n ans=min(ans,x)\nif ans==10**9:\n print(-1)\nelse:\n print(ans)", "jacc_sim": 0.9841269841269841, "nl": "You are given N cards with red and blue numbers. You can swap and flip the cards to create a non-decreasing sequence of red numbers facing up. Determine if it's possible and find the minimum number of operations needed. Constraints: 1 \u2264 N \u2264 18, 1 \u2264 A_i, B_i \u2264 50. Input format: N, A values, B values. Output -1 if not possible, else print the minimum operations. Example: Input 3, 3 4 3, 3 2 3. Output 1, as [2, 3, 3] is non-decreasing.", "before_after_length": [496, 490], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u311379832", "n_user": "u311379832", "pos": "import math\nN = int(input())\nx = list(map(int, input().split()))\nkyori = [x[i + 1] - x[i] for i in range(N - 1)]\nMOD = 10 ** 9 + 7\nkai = [0] * (N + 1)\nkai[0] = 1\nfor i in range(1, N + 1):\n kai[i] = (kai[i - 1] * i) % MOD\nc = [0] * N\nc[0] = 0\nfor i in range(1, N):\n c[i] = ((kai[N - 1] * pow(i, MOD - 2, MOD) % MOD) + c[i - 1]) % MOD\nans = 0\nfor i in range(N - 1):\n ans = (ans + kyori[i] * c[i + 1] % MOD) % MOD\n\nprint(ans)", "neg": "import math\nN = int(input())\nx = list(map(int, input().split()))\nkyori = [x[i + 1] - x[i] for i in range(N - 1)]\nMOD = 10 ** 9 + 7\nkai = [0] * (N + 1)\nkai[0] = 1\nfor i in range(1, N + 1):\n kai[i] = (kai[i - 1] * i) % MOD\nc = [0] * N\nc[0] = 1\nfor i in range(1, N):\n c[i] = c[i - 1] + (1 / (i + 1))\nans = 0\nfor i in range(N - 1):\n ans += (c[i] * kyori[i]) % MOD\n\nprint(ans * kai[N - 1] % MOD)", "jacc_sim": 0.9230769230769231, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [220, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u163320134", "n_user": "u163320134", "pos": "mod=10**9+7\nn=int(input())\narr=list(map(int,input().split()))\nacum=[0]\nfor i in range(1,n+1):\n tmp=acum[-1]+pow(i,mod-2,mod)*pow(i+1,mod-2,mod)\n tmp%=mod\n acum.append(tmp)\nans=0\nfor i in range(n-1):\n ans+=arr[i]*acum[i]\n ans%=mod\n ans-=arr[i]*acum[n-2-i]\n ans%=mod\n ans-=arr[i]*pow(n-1-i,mod-2,mod)\n ans%=mod\nfor i in range(1,n):\n ans+=arr[-1]*pow(i,mod-2,mod)\n ans%=mod\nfor i in range(1,n):\n ans*=i\n ans%=mod\nprint(ans)", "neg": "mod=10**9+7\nn=int(input())\narr=list(map(int,input().split()))\nacum=[1]\nfor i in range(2,n+1):\n tmp=acum+pow(i,mod-2,mod)\n tmp%=mod\n acum.append(tmp)\nans=0\nfor i in range(n-1):\n ans+=(arr[i+1]-arr[i])*acum[i]\n ans%=mod\nfor i in range(1,n):\n ans*=i\n ans%=mod\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [241, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u644907318", "n_user": "u644907318", "pos": "p = 10**9+7\ndef pow(x,m):\n if m==0:\n return 1\n if m==1:\n return x\n if m%2==0:\n return (pow(x,m//2)**2)%p\n else:\n return (x*(pow(x,(m-1)//2)**2)%p)%p\nN = int(input())\nA = [1 for _ in range(N)]\nfor i in range(2,N):\n A[i] = (i*A[i-1])%p\nX = list(map(int,input().split()))\nX.insert(0,0)\ncnt = 0\nfor i in range(1,N):\n cnt = (cnt+((X[N]-X[i])*pow(i,p-2))%p)%p\nprint((cnt*A[N-1])%p)", "neg": "p = 10**9+7\ndef pow(x,m):\n if m==0:\n return 1\n if m==1:\n return x\n if m%2==0:\n return (pow(x,m//2)**2)%p\n else:\n return (x*(pow(x,(m-1)//2)**2)%p)%p\n\nN = int(input())\nA = [1 for _ in range(N+1)]\nfor i in range(2,N+1):\n A[i] = (A[i-1]*i)%p\nB = [1 for _ in range(N+1)]\nB[N] = pow(A[N],p-2)\nfor i in range(N-1,1,-1):\n B[i] = (B[i+1]*(i+1))%p\nX = list(map(int,input().split()))\nX.insert(0,0)\nC = [0 for i in range(N+1)]\nC[1] = A[N-1]\nfor i in range(2,N):\n C[i] = (C[i-1]-A[N-1]*B[i])%p\nC[N] = 0\nfor i in range(1,N):\n C[N] = (C[N]+C[i])%p\nans = (C[N]*X[N])%p\nfor i in range(1,N):\n ans = (ans-C[i]*X[i])%p\nprint(ans)", "jacc_sim": 0.9130434782608695, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [222, 378], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u434872492", "n_user": "u434872492", "pos": "MOD = 10**9+7\nN = int(input())\nx = list(map(int,input().split()))\ndef mod_pow(x,n,mod):\n res = 1\n while(n > 0):\n if n&1:\n res = res * x % mod\n x = x * x % mod\n n >>= 1\n return res\nprob = []\na = 0\nfor i in range(1,N):\n a += mod_pow(i,MOD-2,MOD)\n #koko\n a %= MOD\n prob.append(a)\nans = 0\nfor i in range(1,N):\n\n \"\"\"for j in range(1,i+1):\n prob += 1/j\n \"\"\"\n ans += (x[i]-x[i-1]) * prob[i-1]\n ans %= MOD\n\nfor i in range(1,N):\n ans *= i\n ans %= MOD\nans = int(ans)\nprint(ans)", "neg": "MOD = 10**9+7\nN = int(input())\nx = list(map(int,input().split()))\ndef mod_pow(x,n,mod):\n res = 1\n while(n > 0):\n if(n and 1):\n res = res * x % mod\n x = x * x % mod\n n >>= 1\n return res\nprob = []\na = 0\nfor i in range(1,N):\n a += mod_pow(i,MOD-2,MOD)\n a %= MOD\n prob.append(a)\nans = 0\nfor i in range(1,N):\n\n \"\"\"for j in range(1,i+1):\n prob += 1/j\n \"\"\"\n ans += (x[i]-x[i-1]) * prob[i-1]\n ans %= MOD\nfor i in range(1,N):\n ans *= i\n ans %= MOD\nans = int(ans)\nprint(ans)", "jacc_sim": 0.9215686274509803, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [240, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u667135132", "n_user": "u667135132", "pos": "import math\nimport sys \ninput = sys.stdin.readline\n\nN = int(input())\nx = list(map(int,input().split()))\nmod = 10**9+7\n\nd = [0]*(N-1)\n\nfor i in range(N-1):\n d[i] = x[i+1]-x[i]\n d[i] %= mod\n\n\nkaijou = 1\nfor i in range(1,N):\n kaijou *= i\n kaijou %= mod\n\n\nans=0\nx=0\n\ndef pow_r(x, n):\n \"\"\"\n O(log n)\n \"\"\"\n x %= mod\n if n == 0: # exit case\n return 1\n if n % 2 == 0: # standard case \u2460 n is even\n return pow_r(x ** 2, n // 2)%mod\n else: # standard case \u2461 n is odd\n return (x * (pow_r(x ** 2, (n - 1) // 2)))%mod\n\nfor i in range(N-1):\n #(i+1)%(mod-2)\u3092\u8a08\u7b97\u3057\u3066y\u3078\n y = pow_r(i+1,mod-2)\n #x+= kaijou//(i+1))%(10**9+7)\n x += kaijou*y\n ans += d[i]*x\n ans %= mod\n\nprint(ans)\n", "neg": "import math\nimport sys \ninput = sys.stdin.readline\nN = int(input())\nx = list(map(int,input().split()))\n\nd = [0]*(N-1)\nfor i in range(N-1):\n d[i] = x[i+1]-x[i]\n d[i] %= 10**9+7\n\nmod = 10**9+7\nkaijou = 1\nfor i in range(1,N):\n kaijou *= i%mod\nkaijou %= mod\n\nans=0\nx=0\n\ndef pow_r(x, n):\n \"\"\"\n O(log n)\n \"\"\"\n x %= mod\n if n == 0: # exit case\n return 1\n if n % 2 == 0: # standard case \u2460 n is even\n return pow_r(x ** 2, n // 2)%mod\n else: # standard case \u2461 n is odd\n return (x * (pow_r(x ** 2, (n - 1) // 2)))%mod\n\nfor i in range(N-1):\n #(i+1)**(10**9+5)\u3092\u8a08\u7b97\u3057\u3066y\u3078\n y = pow_r(i+1,k)\n #x+= kaijou//(i+1))%(10**9+7)\n x += (kaijou*y)%mod\n ans+= (d[i]*x)%mod\n\nprint(ans%mod)", "jacc_sim": 0.9701492537313433, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [368, 375], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u927078824", "n_user": "u927078824", "pos": "import statistics\nimport math\n\nMOD = 10**9+7\n\n\ndef main():\n n = int(input())\n x = list(map(int, input().split()))\n\n c = 0\n t = 0\n for i in range(n-1):\n c += pow(i+1, MOD-2, MOD)\n t += c * (x[i+1]-x[i])\n t %= MOD\n\n fact = math.factorial(n-1) % MOD\n print(t * fact % MOD)\n\n\nmain()\n", "neg": "import statistics\nimport math\n\nMOD = 10**9+7\n\n\ndef main():\n n = int(input())\n x = list(map(int, input().split()))\n\n c = 0\n t = 0\n for i in range(n-1):\n c += 1/(i+1)\n c %= MOD\n t += c * (x[i+1]-x[i])\n t %= MOD\n\n fact = math.factorial(n-1) % MOD\n print(t * fact % MOD)\n\n\nmain()\n", "jacc_sim": 0.9285714285714286, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [136, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u006425112", "n_user": "u006425112", "pos": "import numpy as np\nfrom math import factorial\nMOD = 10**9 + 7\n\nn = int(input())\n\ndist = np.diff(list(map(int, input().split())))\nL = np.cumsum(np.array([1 / x for x in range(1, n)]))\nn_1 = factorial(n-1) % MOD\n\n# fac = [1] * n\n# for i in range(1,n):\n# \tfac[i] = fac[i-1] * i % MOD\n\n# print(int(np.sum(L * dist * n_1)) % MOD)\n# ans = 0\n# for l, d in zip(L, dist):\n# print(\"l d \", l * d)\n# ans += l * d\n# ans %= MOD\n\nans = 0\ntmp = 0\nfor i, d in enumerate(dist):\n tmp += pow(i+1, MOD-2, MOD)\n ans += tmp * d\n ans %= MOD\n\n# print(n_1)\nprint(ans * n_1 % MOD)\n# print(int(np.sum(dist * L * n_1) % MOD))", "neg": "import numpy as np\nfrom math import factorial\nMOD = 10**9 + 7\n\nn = int(input())\n\ndist = np.diff(list(map(int, input().split()))) % MOD\nL = np.cumsum(np.array([1 / x for x in range(1, n)])) % MOD\nn_1 = factorial(n-1) % MOD\n\n# fac = [1] * n\n# for i in range(1,n):\n# \tfac[i] = fac[i-1] * i % MOD\n\n# print(int(np.sum(L * dist * n_1)) % MOD)\nans = 0\nfor l, d in zip(L, dist):\n ans += l * d\n ans %= MOD\nprint(ans * n_1 % MOD)\n# print(int(np.sum(dist * L * n_1) % MOD))", "jacc_sim": 0.9107142857142857, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [278, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u065621181", "n_user": "u065621181", "pos": "import math\n\nmod = 10**9 + 7\n\nn = int(input())\nx = list(map(int,input().split()))\ndis = [x[i]-x[i-1] for i in range(1,n)]\nf = (math.factorial(n-1))%mod\ndef modinv(a, mod=mod):\n return pow(a, mod-2, mod)\n\ncount = 0\nsuminv = 0\nfor i in range(1,n):\n suminv += modinv(i)\n suminv %= mod\n count += dis[i-1]*suminv\n count %= mod\ncount = (count*f)%mod\n\nprint(int(count))", "neg": "import math\n\nmod = 10**9 + 7\n\nn = int(input())\nx = list(map(int,input().split()))\ndis = [x[i]-x[i-1] for i in range(1,n)]\n\n\nf = math.factorial(n-1)\nf %= mod\n\ndef modinv(a, mod=mod):\n return pow(a, mod-2, mod)\ninv2 = modinv(2)\n\ncount = 0\nfor i in range(1,n):\n e = (i+1)*inv2%mod\n count = (count + e*dis[i-1])%mod\ncount = count*f%mod\n\nprint(int(count)%mod)\n", "jacc_sim": 0.9333333333333333, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [167, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u368796742", "n_user": "u368796742", "pos": "n = int(input())\nl = list(map(int,input().split()))\nsa = []\nfor i in range(n-1):\n sa.append(l[i+1]-l[i])\n\nmod = 10**9+7\nans = 0\ncount = 0\nkai = 1\nfor i in range(1,n):\n kai *= i\n kai %= mod\n \nfor i in range(n-1):\n count += pow((i+1),mod-2,mod)\n \n ans += sa[i]*count\n ans %= mod\n\n\nprint(int(kai*ans%mod))\n", "neg": "n = int(input())\nl = list(map(int,input().split()))\nsa = []\nfor i in range(n-1):\n sa.append(l[i+1]-l[i])\n\nmod = 10**9+7\nans = 0\ncount = 0\nkai = 1\n\n \nfor i in range(n-1):\n count += 1/(i+1)\n \n \n ans += sa[i]*count\n ans %= mod\nfor i in range(n-1):\n ans *= (i+1)\n ans %= mod\n\nprint(int(ans%mod))\n", "jacc_sim": 0.9210526315789473, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [154, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u270681687", "n_user": "u270681687", "pos": "n = int(input())\nx = list(map(int, input().split()))\n\nmod = 10**9 + 7\n\nfac = [1, 1]\ninv = [1, 1]\nfinv = [1, 1]\nfor i in range(2, n+5):\n fac.append(fac[i-1] * i % mod)\n inv.append(mod - inv[mod%i] * (mod//i) % mod)\n finv.append(finv[i-1] * inv[i] % mod)\n\nans = 0\nj_inv = []\nnum = 0\nfor j in range(1, n):\n num += inv[j]\n num %= mod\n j_inv.append(num)\n\nfor i in range(n-1):\n ans += j_inv[i] * (x[i+1] - x[i])\n ans %= mod\n\nans *=fac[n-1]\nans %= mod\n\nprint(ans)\n\n", "neg": "n = int(input())\nx = list(map(int, input().split()))\n\nmod = 10**9 + 7\n\nfac = [1, 1]\ninv = [1, 1]\nfinv = [1, 1]\nfor i in range(2, n+5):\n fac.append(fac[i-1] * i % mod)\n inv.append(mod - inv[mod%i] * (mod//i) % mod)\n finv.append(finv[i-1] * inv[i] % mod)\n\nans = 0\nj_inv = []\nnum = 0\nfor j in range(1, n):\n num += inv[j]\n num %= mod\n j_inv.append(num)\n\nfor i in range(n-1):\n ans += j_inv[i]\n ans %= mod\n\nans *=fac[n-1]\nans %= mod\n\nprint(ans)\n\n", "jacc_sim": 1.0, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [238, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u268554510", "n_user": "u268554510", "pos": "N = int(input())\nX = list(map(int,input().split()))\nimport math\nans = 0\nmod = 10**9+7\na = 0\nans = 0\nfor i in range(N-1):\n a += pow(i+1,mod-2,mod)\n ans += ((X[i+1]-X[i])%mod)*(a%mod)\n ans %= mod\n \nans *= math.factorial(N-1)%mod\n\nprint(ans%mod)", "neg": "N = int(input())\nX = list(map(int,input().split()))\nimport math\nans = 0\nmod = 10**9+7\na = 0\nans = 0\nfor i in range(N-1):\n a += 1/(i+1)\n ans += (X[i+1]-X[i])%mod*a\n\nans *= math.factorial(N-1)%mod\nprint(int(ans)%mod)", "jacc_sim": 0.9210526315789473, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [122, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u552357043", "n_user": "u662062459", "pos": "from math import factorial\n\nN = int(input())\nx = list(map(int, input().split()))\nmod = 10**9 + 7\nx_dis = [x[i+1] - x[i] for i in range(N-1)]\nans = 0\nm = N-1\nfac = factorial(m) % mod\ntmp = fac\nfor i in range(m):\n ans += x_dis[i] * tmp\n ans %= mod\n tmp += (fac*pow((i+2),(mod-2), mod))%mod\nprint(ans)\n", "neg": "from math import factorial\n \nN = int(input())\nx = list(map(int, input().split()))\nmod = 10**9 + 7\nx_dis = [x[i+1] - x[i] for i in range(N-1)]\nans = 0\nm = N-1\nfac = factorial(m) % mod\ntmp = fac\nfor i in range(m):\n ans += x_dis[i] * tmp\n ans %= mod\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [138, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\nx = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nclass Factorial:\n def __init__(self, n, mod):\n self.f = [1]\n for i in range(1, n + 1):\n self.f.append(self.f[-1] * i % mod)\n self.i = [pow(self.f[-1], mod - 2, mod)]\n for i in range(1, n + 1)[: : -1]:\n self.i.append(self.i[-1] * i % mod)\n self.i.reverse()\n def factorial(self, i):\n return self.f[i]\n def ifactorial(self, i):\n return self.i[i]\n def combi(self, n, k):\n return self.f[n] * self.i[n - k] % mod * self.i[k] % mod\n\nf = Factorial(N, mod)\nres = 0\nt = [0] * (N + 1)\nfor i in range(N):\n t[i + 1] = t[i] * (i + 1) + f.factorial(i) % mod\n t[i + 1] %= mod\n#print(t)\nfor i in range(N - 2, -1, -1):\n res += (x[i + 1] - x[i]) * t[i + 1] * f.factorial(N - 1) % mod * f.ifactorial(i + 1) % mod\n res %= mod\nprint(res)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\nx = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nclass Factorial:\n def __init__(self, n, mod):\n self.f = [1]\n for i in range(1, n + 1):\n self.f.append(self.f[-1] * i % mod)\n self.i = [pow(self.f[-1], mod - 2, mod)]\n for i in range(1, n + 1)[: : -1]:\n self.i.append(self.i[-1] * i % mod)\n self.i.reverse()\n def factorial(self, i):\n return self.f[i]\n def ifactorial(self, i):\n return self.i[i]\n def combi(self, n, k):\n return self.f[n] * self.i[n - k] % mod * self.i[k] % mod\n\nf = Factorial(N, mod)\ndp = [0] * N\nres = 0\nfor i in range(N - 2):\n for j in range(i + 1, N):\n t = f.combi(N - 1, min(j - i + 1 - (j == N - 1), N - 1)) * f.factorial(j - i - 1) % mod\n #print(i, j, t)\n #t *= f.factorial(N - 1) * f.ifactorial(t) % mod\n #print(i, j, t)\n dp[i] += t * (x[j] - x[i])\n dp[i] %= mod\ndp[N - 2] = f.factorial(N - 1) * (x[-1] - x[-2]) % mod\nfor i in range(N):\n res += dp[i]\n res %= mod\nprint(res)", "jacc_sim": 0.9464285714285714, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [400, 468], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u852690916", "n_user": "u852690916", "pos": "N=int(input())\nX=list(map(int,input().split()))\nMOD=10**9+7\n\nfacN_1=1\nsuminv=[1]*N\ninv=[1]*N\nfor i in range(2,N):\n facN_1=facN_1*i%MOD\n inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD\n suminv[i]=(suminv[i-1]+inv[i])%MOD\n\nans=0\nfor i in range(N-1):\n tmp=X[i+1]-X[i]\n tmp*=suminv[i+1]%MOD\n ans+=tmp\n ans%=MOD\nprint(ans*facN_1%MOD)\n", "neg": "N=int(input())\nX=list(map(int,input().split()))\nMOD=10**9+7\n\nfacN_1=1\nfor i in range(2,N):\n facN_1*=i\n\nP=[0]*N\nfor i in range(1,N):\n P[i]=facN_1//i\n\nans=0\nfor i in range(N-1):\n tmp=X[i+1]-X[i]\n tmp*=(i+1)*(i+2)//2\n tmp*=P[i+1]%MOD\n ans+=tmp\n ans%=MOD\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [186, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u711539583", "n_user": "u711539583", "pos": "n = int(input())\nx = list(map(int, input().split()))\nd = []\nfor x1, x2 in zip(x, x[1:]):\n d.append(x2 - x1)\nmod = 10 ** 9 + 7\nbase = 1\n\nP = 10**9 + 7\nN = n+2\ninv_t = [0]+[1]\nfor i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\nfor i in range(1, n):\n base *= i\n base %= mod\nans = 0\nb = base\nfor i, di in enumerate(d):\n ans += (base * di) % mod\n ans %= mod\n base += b * inv_t[i+2]\n base % mod\nprint(ans)\n", "neg": "n = int(input())\nx = list(map(int, input().split()))\nd = []\nfor x1, x2 in zip(x, x[1:]):\n d.append(x2 - x1)\nmod = 10 ** 9 + 7\nbase = 1\n\nP = 10**9 + 7\nN = n\ninv_t = [0]+[1]\nfor i in range(2,N):\n inv_t += [inv_t[P % i] * (P - int(P / i)) % P]\n\nfor i in range(1, n):\n base *= i\n base %= mod\nans = 0\nb = base\nfor i, di in enumerate(d):\n ans += (base * di) % mod\n ans %= mod\n base += b * inv_t[i+2]\n base % mod\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [210, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u984276646", "n_user": "u984276646", "pos": "N = int(input())\nA = list(map(int, input().split()))\nmod = int(1e+9 + 7)\np = mod - 2\nS = []\nwhile p != 0:\n S = [p%2] + S[:]\n p //= 2\nfrac = 1\nfor i in range(N - 1):\n frac *= i+1\n frac %= mod\nT = 0\nfor i in range(N - 1):\n k = 1\n for j in range(len(S)):\n if S[j] == 1:\n k *= i+1\n k %= mod\n if j != len(S) - 1:\n k *= k\n k %= mod\n T += (frac * k * (A[N - 1] - A[i])) % mod\n T %= mod\nprint(T%mod)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nmod = 1e+9 + 7\np = mod - 2\nS = []\nwhile p != 0:\n S = [p%2] + S[:]\n p //= 2\nfrac = 1\nfor i in range(N - 1):\n frac *= i+1\n frac %= mod\nT = 0\nfor i in range(N - 1):\n k = 1\n for j in range(len(S)):\n if S[j] == 1:\n k *= i+1\n k %= mod\n if j != len(S) - 1:\n k *= k\n k %= mod\n T += (frac * k * (A[N - 1] - A[i])) % mod\n T %= mod\nprint(T%mod)", "jacc_sim": 1.0, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [203, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u144913062", "n_user": "u144913062", "pos": "import sys\nsys.setrecursionlimit(10**6)\n\n\ndef mod_inverse(n, mod=10**9+7):\n return pow(n, mod-2, mod)\n\n\ndef combination(n, k, mod=10**9+7):\n numer = denom = 1\n for i in range(k):\n numer = (numer * (n-i)) % mod\n denom = (denom * (i+1)) % mod\n return (numer * mod_inverse(denom, mod)) % mod\n\n\ndef factorial(n):\n if n == 0:\n return 1\n return n * factorial(n-1) % mod\n\n\nmod = 10**9+7\nN = int(input())\nx = [0] + list(map(int, input().split()))\nfact = factorial(N-1)\n\nans = 0\nfor k in range(2, N):\n ans = (ans + x[k] * (1 - mod_inverse(k)))\n\nfor k in range(1, N-1):\n ans = (ans - x[k] * (1 - mod_inverse(N-k))) % mod\n\nans = ans * fact % mod\n\nans = (ans + fact * sum((x[N] - x[k]) * mod_inverse(N-k) for k in range(1, N))) % mod\n\nprint(ans)\n", "neg": "import sys\nsys.setrecursionlimit(10**6)\n\n\ndef mod_inverse(n, mod=10**9+7):\n return pow(n, mod-2, mod)\n\n\ndef combination(n, k, mod=10**9+7):\n numer = denom = 1\n for i in range(k):\n numer = (numer * (n-i)) % mod\n denom = (denom * (i+1)) % mod\n return (numer * mod_inverse(denom, mod)) % mod\n\n\ndef factorial(n):\n if n == 0:\n return 1\n return n * factorial(n-1) % mod\n\n\nmod = 10**9+7\nN = int(input())\nx = [0] + list(map(int, input().split()))\n\nans = 0\nfor k in range(2, N):\n ans = (ans + x[k] * (1 - mod_inverse(k))) % mod\n\nfor k in range(1, N-1):\n ans = (ans - x[k] * (1 - mod_inverse(N-k))) % mod\n\nans = (ans + sum((x[N] - x[k]) * mod_inverse(N-k) for k in range(1, N))) % mod\n\nans = ans * factorial(N-1) * mod\n\nprint(ans)\n", "jacc_sim": 0.9795918367346939, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [335, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02807", "p_user": "u623231048", "n_user": "u623231048", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\nx = list(map(int,input().split()))\n\n#n = 10**5\n#x = list(range(10**5))\nmod = 10**9 + 7\n\nli = []\nfor i in range(n-1):\n li.append(x[i+1] - x[i])\n\ndp = [0] * (n-1)\ndp2 = [0] * (n-1)\ndp3 = [0] * n\ndp3[0] = 1\n\nfor i in range(n-1):\n dp3[i+1] = dp3[i] * (i+2)\n dp3[i+1] %= mod\n\ndp[0] = x[1] - x[0]\ndp2[0] = 1\n\nfor i in range(n-2):\n dp2[i+1] = dp2[i] * (i+2) + dp3[i]\n dp2[i+1] %= mod\nans = 0\nfor i in range(n-2):\n dp[i+1] = dp[i] * (i+2) + (x[i+2] - x[i+1]) * dp2[i+1]\n dp[i+1] %= mod\n\nprint(dp[-1] % mod)\n", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\n\nx = list(map(int,input().split()))\n\nmod = 10**9 + 7\n\nli = []\nfor i in range(n-1):\n li.append(x[i+1] - x[i])\n\ndp = [0] * (n-1)\ndp2 = [0] * (n-1)\ndp3 = [0] * n\ndp3[0] = 1\n\nfor i in range(n-1):\n dp3[i+1] = dp3[i] * (i+2)\n\ndp[0] = x[1] - x[0]\ndp2[0] = 1\n\nfor i in range(n-2):\n dp2[i+1] = dp2[i] * (i+2) + dp3[i]\n\nans = 0\n\nfor i in range(n-2):\n print(dp[i] * (i+2),(x[i+2] - x[i+1]) * dp3[i+1])\n dp[i+1] = dp[i] * (i+2) + (x[i+2] - x[i+1]) * dp2[i+1]\n dp[i+1] %= mod\n\nprint(dp[-1] % mod)\n", "jacc_sim": 0.9534883720930233, "nl": "You are given N slimes standing on a number line at positions x1, x2, ..., xN. Niwango will perform N-1 operations, each involving choosing an integer k between 1 and N-i, moving the k-th slime to the position of the neighboring slime to the right, and fusing the two slimes. Find the total distance traveled by the slimes multiplied by (N-1)!, modulo (10^9+7). The input format is N followed by x1, x2, ..., xN, and the output is the answer. For example, given N=3 and positions 1, 2, 3, the output is 5.", "before_after_length": [329, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02815", "p_user": "u327466606", "n_user": "u327466606", "pos": "MOD = 10**9+7\n\ndef solve(C):\n N = len(C)\n C.sort()\n\n dp1 = 0\n dp2 = 0\n for k,c in enumerate(C):\n ndp2 = 2*pow(4,k,MOD)*c + 4*dp2\n dp1 = 4*dp1 + ndp2 - 2*dp2\n dp2 = ndp2\n dp1 %= MOD\n dp2 %= MOD\n\n return dp1\n\ndef naive(C):\n from itertools import product\n N = len(C)\n C.sort()\n s = 0\n for a in product(range(2),repeat=N):\n for b in product(range(2),repeat=N):\n pop = 1\n for x,y,c in zip(a,b,reversed(C)):\n if x != y:\n s += c*pop\n pop += 1\n return s\n\nif __name__ == '__main__':\n N = int(input())\n C = list(map(int,input().split()))\n print(solve(C))", "neg": "MOD = 10**9+7\n\ndef solve(C):\n N = len(C)\n C.sort()\n\n dp1 = 0\n dp2 = 0\n for k,c in enumerate(C):\n ndp2 = 2*(4**k)*c + 4*dp2\n dp1 = 4*dp1 + ndp2 - 2*dp2\n dp2 = ndp2\n\n return dp1\n\ndef naive(C):\n from itertools import product\n N = len(C)\n C.sort()\n s = 0\n for a in product(range(2),repeat=N):\n for b in product(range(2),repeat=N):\n pop = 1\n for x,y,c in zip(a,b,reversed(C)):\n if x != y:\n s += c*pop\n pop += 1\n return s\n\nif __name__ == '__main__':\n N = int(input())\n C = list(map(int,input().split()))\n print(solve(C))", "jacc_sim": 0.9666666666666667, "nl": "You are given two sequences, S and T, each of length N, consisting of 0s and 1s. The function f(S, T) calculates the minimum total cost to transform S into T. The cost of changing S_i (from 0 to 1 or vice versa) is D * C_i, where D is the number of indices j such that S_j \u2260 T_j just before the change. You need to compute the sum of f(S, T) over all pairs of sequences (S, T) and output the result modulo (10^9+7). The input consists of N followed by N values of C_i. Output the sum of f(S, T) modulo (10^9+7).", "before_after_length": [271, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02815", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\nn = int(input())\na = list(map(int, input().split()))\na.sort()\na = a[::-1]\nM = 10**9+7\nans = 0\nans += a[0]*(pow(2, 0, M))*pow(2, n-1,M)\nfor i in range(1,n):\n num = a[i]\n ans += num*(pow(2, i, M) + i*pow(2,i-1,M))*pow(2,n-i-1,M)\n ans %= M\nans *= pow(2,n,M)\nans %= M\nprint(ans)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\npp = [None]*n\nv = 1\nfor i in range(n):\n pp[i] = v\n v *= 2\n v %= M\n \nn = int(input())\na = list(map(int, input().split()))\na.sort()\na = a[::-1]\nM = 10**9+7\nans = 0\nans += a[0]*(pow(2, 0, M))*pow(2, n-1,M)\nfor i in range(1,n):\n num = a[i]\n ans += num*(pp[i] + i*pp[i-1])*pp[n-i-1]\n ans %= M\nans *= pow(2,n,M)\nans %= M\nprint(ans)", "jacc_sim": 0.9423076923076923, "nl": "You are given two sequences, S and T, each of length N, consisting of 0s and 1s. The function f(S, T) calculates the minimum total cost to transform S into T. The cost of changing S_i (from 0 to 1 or vice versa) is D * C_i, where D is the number of indices j such that S_j \u2260 T_j just before the change. You need to compute the sum of f(S, T) over all pairs of sequences (S, T) and output the result modulo (10^9+7). The input consists of N followed by N values of C_i. Output the sum of f(S, T) modulo (10^9+7).", "before_after_length": [207, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02815", "p_user": "u334712262", "n_user": "u334712262", "pos": "# -*- coding: utf-8 -*-\nimport queue\nimport sys\n# sys.setrecursionlimit(10**6)\n# buff_readline = sys.stdin.buffer.readline\nbuff_readline = sys.stdin.readline\nreadline = sys.stdin.readline\n\nINF = 2**62-1\n\n\ndef read_int():\n return int(buff_readline())\n\n\ndef read_int_n():\n return list(map(int, buff_readline().split()))\n\n\ndef read_float():\n return float(buff_readline())\n\n\ndef read_float_n():\n return list(map(float, buff_readline().split()))\n\n\ndef read_str():\n return readline().strip()\n\n\ndef read_str_n():\n return readline().strip().split()\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, C):\n mod = 10**9 + 7\n if N == 1:\n return (C[0] * 2) % mod\n\n C.sort()\n ans = 0\n a = pow(2, N, mod)\n b = pow(2, N-1, mod)\n c = pow(2, N-2, mod)\n for i in range(N):\n d = (N-i-1) * c\n d %= mod\n n = a * (b + d)\n n %= mod\n ans += n * C[i]\n ans %= mod\n\n return ans % mod\n\n\n\n\ndef main():\n N = read_int()\n C = read_int_n()\n print(slv(N, C))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\n# sys.setrecursionlimit(10**6)\n# buff_readline = sys.stdin.buffer.readline\nbuff_readline = sys.stdin.readline\nreadline = sys.stdin.readline\n\nINF = 2**62-1\n\n\ndef read_int():\n return int(buff_readline())\n\n\ndef read_int_n():\n return list(map(int, buff_readline().split()))\n\n\ndef read_float():\n return float(buff_readline())\n\n\ndef read_float_n():\n return list(map(float, buff_readline().split()))\n\n\ndef read_str():\n return readline().strip()\n\n\ndef read_str_n():\n return readline().strip().split()\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, C):\n bp = [0]\n mod = 10**9 + 7\n for i in range(N+1):\n bp.append(bp[-1] + (1<= n:\n res.append(((n - k) % n, A[0] ^ B[k]))\n res.sort()\n for pair in res:\n print(*pair)\nresolve()", "neg": "import sys\nsys.setrecursionlimit(2147483647)\nINF = 1 << 60\nMOD = 10**9 + 7 # 998244353\ninput = lambda:sys.stdin.readline().rstrip()\n\ndef Z(S):\n n = len(S)\n res = [0] * n\n res[0] = n\n l = r = 0\n for i in range(1, n):\n if res[i - l] < r - i: # \u904e\u53bb\u306e\u7d50\u679c\u304c\u5168\u3066\u4f7f\u3048\u308b\n res[i] = res[i - l]\n else:\n l = i\n r = max(i, r) # i < r \u306a\u3089\u3070\u904e\u53bb\u306e\u7d50\u679c\u304c\u4e00\u90e8\u4f7f\u3048\u308b\n while r < n and S[r - l] == S[r]: r += 1\n res[i] = r - l\n return res\n\ndef resolve():\n n = int(input())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n C = [A[i] ^ A[(i + 1) % n] for i in range(n)]\n D = [B[i] ^ B[(i + 1) % n] for i in range(n)]\n prefix = Z(C + D + D)\n res = []\n for k in range(n):\n if prefix[n + k] >= n:\n print((n - k) % n, A[0] ^ B[k])\nresolve()", "jacc_sim": 0.963855421686747, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [444, 422], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02816", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nclass KmpSearch:\n def __init__(self, word):\n self.word = word\n self.table = [0] * (len(word) + 1)\n self.table[0] = -1\n i, j = 0, 1\n while j < len(self.word):\n matched = self.word[i] == self.word[j]\n if not matched and i > 0:\n i = self.table[i]\n else:\n if matched:\n i += 1\n j += 1\n self.table[j] = i\n def search(self, text):\n table = self.table\n word = self.word\n i, p = 0, 0\n res = []\n while i < len(text):\n if text[i] == word[p]:\n i += 1\n p += 1\n elif p == 0:\n i += 1\n else:\n p = table[p]\n if p == len(word):\n res.append(i - p)\n p = table[p]\n return res\n\nxa = [0] * N\nxb = [0] * N\nfor i in range(N):\n xa[i] = a[i - 1] ^ a[i]\n xb[i] = b[i - 1] ^ b[i]\n\nkmp = KmpSearch(xa)\nres = kmp.search(xb + xb[: -1])\nrres = []\nfor x in res: rres.append(((N - x) % N, a[0] ^ b[x]))\nrres.sort(key = lambda x: (x[0], x[1]))\nfor r in rres: print(*r)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nclass KmpSearch:\n def __init__(self, word):\n self.word = word\n self.table = [0] * (len(word) + 1)\n self.table[0] = -1\n i, j = 0, 1\n while j < len(self.word):\n matched = self.word[i] == self.word[j]\n if not matched and i > 0:\n i = self.table[i]\n else:\n if matched:\n i += 1\n j += 1\n self.table[j] = i\n def search(self, text):\n table = self.table\n word = self.word\n i, p = 0, 0\n res = []\n while i < len(text):\n if text[i] == word[p]:\n i += 1\n p += 1\n elif p == 0:\n i += 1\n else:\n p = table[p]\n if p == len(word):\n res.append(i - p)\n p = table[p]\n return res\n\nxa = [0] * N\nxb = [0] * N\nfor i in range(N):\n xa[i] = a[i - 1] ^ a[i]\n xb[i] = b[i - 1] ^ b[i]\n\nkmp = KmpSearch(xa)\nres = kmp.search(xb + xb[: -1])\nrres = []\nfor x in res: rres.append((N - x, a[0] ^ b[x]))\nrres.sort(key = lambda x: (x[0], x[1]))\nfor r in rres: print(*r)", "jacc_sim": 0.9848484848484849, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [460, 456], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02816", "p_user": "u927078824", "n_user": "u927078824", "pos": "def xor_next(values):\n result = [0] * len(values)\n for i in range(len(values)):\n result[i] = values[i] ^ values[(i+1) % len(values)]\n return result\n\n\ndef make_mp_table(values):\n result = [-1] * (len(values) + 1)\n j = -1\n for i in range(len(values)):\n while j != -1 and values[j] != values[i]:\n j = result[j]\n j += 1\n result[i+1] = j\n return result\n\n\ndef mp_find(target, pattern, table):\n result = []\n j = 0\n for i in range(len(target)):\n while(j != -1 and pattern[j] != target[i]):\n j = table[j]\n j += 1\n if j == len(pattern):\n result.append(i-(j-1))\n j = table[j]\n return result\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n\n xa = xor_next(a)\n xb = xor_next(b)\n mp_t = make_mp_table(xa)\n xb += xb\n res = mp_find(xb, xa, mp_t)\n res.sort(reverse=True)\n for i in range(len(res)):\n k = n-res[i]\n if(k >= n):\n continue\n x = a[k] ^ b[0]\n print(str(k) + ' ' + str(x))\n\n\nmain()\n", "neg": "def xor_next(values):\n result = [0] * len(values)\n for i in range(len(values)):\n result[i] = values[i] ^ values[(i+1) % len(values)]\n return result\n\n\ndef make_mp_table(values):\n result = [-1] * (len(values) + 1)\n j = -1\n for i in range(len(values)):\n while j != -1 and values[j] != values[i]:\n j = result[j]\n j += 1\n result[i+1] = j\n return result\n\n\ndef mp_find(target, pattern, table):\n result = []\n j = 0\n for i in range(len(target)):\n while(j != -1 and pattern[j] != target[i]):\n j = table[j]\n j += 1\n if j == len(pattern):\n result.append(i-(j-1))\n j = table[j]\n return result\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n\n xa = xor_next(a)\n xb = xor_next(b)\n mp_t = make_mp_table(xa)\n xb += xb\n res = mp_find(xb, xa, mp_t)\n print(res)\n res.sort(reverse=True)\n for i in range(len(res)):\n k = n-res[i]\n if(k >= n):\n continue\n x = a[k] ^ b[0]\n print(str(k) + ' ' + str(x))\n\n\nmain()\n", "jacc_sim": 1.0, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [429, 435], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02816", "p_user": "u864197622", "n_user": "u864197622", "pos": "def Z_algorithm(s):\n n = len(s)\n A = [n] + [0] * (n-1)\n i, j = 1, 0\n while i < n:\n while i + j < n and s[j] == s[i+j]:\n j += 1\n A[i] = j\n if j == 0:\n i += 1\n continue\n k = 1\n while i + k < n and k + A[k] < j:\n A[i+k] = A[k]\n k += 1\n i += k\n j -= k\n return A\n\nN = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAA = [A[i] ^ A[i-1] for i in range(N)]\nBB = [B[i] ^ B[i-1] for i in range(N)]\n\nT = Z_algorithm(AA + BB + BB)\nfor i in range(N, 0, -1):\n if T[N+i] >= N:\n print(N-i, A[-i%N] ^ B[0])", "neg": "def Z_algorithm(s):\n n = len(s)\n A = [n] + [0] * (n-1)\n i, j = 1, 0\n while i < n:\n while i + j < n and s[j] == s[i+j]:\n j += 1\n A[i] = j\n if j == 0:\n i += 1\n continue\n k = 1\n while i + k < n and k + A[k] < j:\n A[i+k] = A[k]\n k += 1\n i += k\n j -= k\n return A\n\nN = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nAA = [A[i] ^ A[i-1] for i in range(N)]\nBB = [B[i] ^ B[i-1] for i in range(N)]\n\nT = Z_algorithm(AA + BB + BB)\nfor i in range(N)[::-1]:\n if T[N+i] >= N:\n j = - i % N\n print(j, A[j] ^ B[0])", "jacc_sim": 1.0, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [293, 296], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02816", "p_user": "u340781749", "n_user": "u340781749", "pos": "def check(ccc, ddd, e, ans):\n m = 2147483647\n g = 1000000007\n for l in range(e):\n cl = ccc[l]\n if any(c != cl for c in ccc[l::e]):\n return\n dl = ddd[l]\n if any(d != dl for d in ddd[l::e]):\n return\n s = 0\n for c in ccc[:e]:\n s = (s * g + c) % m\n t = 0\n for d in ddd[:e]:\n t = (t * g + d) % m\n u = pow(g, e, m)\n for h in range(e):\n if s == t:\n bh = bbb[h]\n ans.update(((i - h) % n, aaa[i] ^ bh) for i in range(0, n, e))\n return\n t = (t * g + ddd[(e + h) % n] - ddd[h] * u) % m\n\n\ndef solve(n, aaa, bbb):\n ccc = [a1 ^ a2 for a1, a2 in zip(aaa, aaa[1:])] + [aaa[-1] ^ aaa[0]]\n ddd = [b1 ^ b2 for b1, b2 in zip(bbb, bbb[1:])] + [bbb[-1] ^ bbb[0]]\n\n ans = set()\n\n e = 1\n while e * e <= n:\n if n % e != 0:\n e += 1\n continue\n check(ccc, ddd, e, ans)\n check(ccc, ddd, n // e, ans)\n e += 1\n\n return ans\n\n\nn = int(input())\naaa = list(map(int, input().split()))\nbbb = list(map(int, input().split()))\nans = solve(n, aaa, bbb)\nprint(''.join('{} {}\\n'.format(*answer) for answer in sorted(ans)))\n", "neg": "def check(ccc, ddd, e, ans):\n m = 2147483647\n g = 1000000007\n for l in range(e):\n cl = ccc[l]\n if any(c != cl for c in ccc[l::e]):\n return\n dl = ddd[l]\n if any(d != dl for d in ddd[l::e]):\n return\n s = 0\n for c in ccc[:e]:\n s = (s * g + c) % m\n t = 0\n for d in ddd[:e]:\n t = (t * g + d) % m\n u = pow(g, e, m)\n for h in range(e):\n if s == t:\n bh = bbb[h]\n ans.update(((i - h) % n, aaa[i] ^ bh) for i in range(0, n, e))\n return\n t = (t * g + ddd[(e + h) % n] - ddd[h] * u) % m\n\n\ndef solve(n, aaa, bbb):\n ccc = [a1 ^ a2 for a1, a2 in zip(aaa, aaa[1:])] + [aaa[-1] ^ aaa[0]]\n ddd = [b1 ^ b2 for b1, b2 in zip(bbb, bbb[1:])] + [bbb[-1] ^ bbb[0]]\n\n ans = set()\n\n e = 1\n while e * e <= n:\n if n % e != 0:\n e += 1\n continue\n check(ccc, ddd, e, ans)\n check(ccc, ddd, n // e, ans)\n e += 1\n\n return ans\n\n\nn = int(input())\naaa = list(map(int, input().split()))\nbbb = list(map(int, input().split()))\nans = solve(n, aaa, bbb)\nprint(''.join('{} {}\\n'.format(*answer) for answer in ans))\n", "jacc_sim": 0.9863013698630136, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [508, 506], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02816", "p_user": "u922449550", "n_user": "u922449550", "pos": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nC = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]\nC = C + C\nD = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]\n\nK = []\nk = 0\nwhile k < N:\n next_k = k\n is_first = True\n for i in range(N):\n if is_first and i>0 and C[k+i]==D[0]:\n next_k = k + i\n is_first = False\n if C[k+i] != D[i]:\n if next_k == k:\n k = k + i + 1\n else:\n if D[k+i-next_k] == C[k+i]:\n k = next_k\n else:\n k = k + i + 1\n break\n \n if i == N-1:\n K.append(k)\n if next_k == k:\n break\n else:\n k = next_k\n if len(K) == 2:\n diff = K[1] - K[0]\n while K[-1] < N:\n K.append(K[-1]+diff)\n \n _ = K.pop()\n break\n\nfor k in K:\n print(k, A[k]^B[0])", "neg": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nC = [a1^a2 for a1, a2 in zip(A, A[1:])] + [A[0]^A[-1]]\nC = C + C\nD = [b1^b2 for b1, b2 in zip(B, B[1:])] + [B[0]^B[-1]]\n\nK = []\nk = 0\nwhile k < N:\n next_k = k\n is_first = True\n for i in range(N):\n if is_first and i>0 and C[k+i]==D[0]:\n next_k = k + i\n if C[k+i] != D[i]:\n if next_k == k:\n k = k + i + 1\n else:\n if D[k+i-next_k] == C[k+i]:\n k = next_k\n else:\n k = k + i + 1\n break\n \n if i == N-1:\n K.append(k)\n if next_k == k:\n break\n else:\n k = next_k\n if len(K) == 2:\n diff = K[1] - K[0]\n while K[-1] < N:\n K.append(K[-1]+diff)\n \n _ = K.pop()\n break\n\nfor k in K:\n print(k, A[k]^B[0])", "jacc_sim": 0.9811320754716981, "nl": "You are given two sequences, a and b, each consisting of N non-negative integers. Snuke will choose an integer k (0 \u2264 k < N) and an integer x (not less than 0) to create a new sequence a' of length N. The new sequence a' is formed by taking each element a_i and performing the operation a_i' = a_{i+k mod N} XOR x. Find all pairs (k, x) such that a' will be equal to b. The XOR of integers A and B, denoted as A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. The input consists of N, a_0, a_1, ..., a_{N-1}, b_0, b_1, ..., b_{N-1}. Print all pairs (k, x) such that a' and b will be equal, using one line for each pair, in ascending order of k (ascending order of x for pairs with the same k). If there are no such pairs, the output should be empty.", "before_after_length": [391, 384], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02822", "p_user": "u923270446", "n_user": "u923270446", "pos": "import sys\nsys.setrecursionlimit(10 ** 7)\nmod = 10 ** 9 + 7\nn = int(input())\nedges = [[] for i in range(n)]\nfor i in range(n - 1):\n a, b = map(int, input().split())\n edges[a - 1].append((b - 1, i))\n edges[b - 1].append((a - 1, i))\nl = [0 for i in range(n)]\ndef dfs(cur, x):\n res = 1\n for i in edges[cur]:\n if i[1] != x:\n res += dfs(i[0], i[1])\n l[x] = res\n return res\ndfs(0, -1)\nl2 = [1]\ni2 = pow(2, mod - 2, mod)\nfor i in range(n):\n l2.append(l2[-1] * i2 % mod)\ncnt = 0\nfor i in l:\n cnt += (1 - l2[i]) * (1 - l2[n - i])\nprint((-n * i2 - l2[-1] + cnt + 1) % mod)", "neg": "import sys\nsys.setrecursionlimit(10 ** 7)\nedges = [[] for i in range(n)]\nfor i in range(n - 1):\n a, b = map(int, input().split())\n edges[a - 1].append((b - 1, i))\n edges[b - 1].append((a - 1, i))\nl = [0 for i in range(n)]\ndef dfs(cur, x):\n res = 1\n for i in edges[cur]:\n if i[1] != x:\n res += dfs(i[0], i[1])\n l[x] = res\n return res\ndfs(0, -1)\nl2 = [1]\ni2 = pow(2, mod - 2, mod)\nfor i in range(n):\n l2.append(l2[-1] * i2 % mod)\ncnt = 0\nfor i in l:\n cnt += (1 - l2[i]) * (1 - l2[n - i])\nprint((-n * i2 - l2[-1] + cnt + 1) % mod)", "jacc_sim": 0.9795918367346939, "nl": "You are given a tree with N vertices. Each vertex is painted black with a 1/2 probability and white with a 1/2 probability, independently from other vertices. Find the expected number of white vertices in the smallest subtree containing all the black vertices. Print the result modulo 10^9+7. The input is given in the format N, followed by pairs of vertices. Output the expected number of white vertices modulo 10^9+7.", "before_after_length": [276, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02822", "p_user": "u780962115", "n_user": "u780962115", "pos": "# Surrounded Nodes\nfrom collections import deque\nimport sys\nsys.setrecursionlimit(10**8)\nmod = 10**9 + 7\nN = int(input())\nG = [[] for i in range(N+1)]\nfor i in range(N-1):\n a, b = map(int, input().split())\n G[a].append(b)\n G[b].append(a)\nS = -1\nfor i in range(1, N+1):\n if len(G[i]) == 1:\n S = i\n break\nvisited = [False for i in range(N+1)]\nparent = [-1 for i in range(N+1)]\ncount = [1 for i in range(N+1)]\n\nans = N*pow(2, N-1, mod)\nstack = deque()\n\n\ndef dfs(node):\n visited[node] = True\n for child in G[node]:\n if visited[child] == False:\n parent[child] = node\n stack.append((node, child))\n dfs(child)\n\n\npowers = [1 for i in range(2*10**5+1)]\nfor i in range(1, 2*10**5+1):\n powers[i] = powers[i-1]*2 % mod\n\ndfs(S)\nwhile stack:\n mom, child = stack.pop()\n count[mom] += count[child]\nans = 0\nfor i in range(1, N+1):\n if len(G[i]) > 1:\n ans += powers[N-1]\n for x in G[i]:\n if x != parent[i]:\n ans -= powers[count[x]]\n ans -= powers[N-count[i]]\n ans += len(G[i]) - 1\n ans %= mod\nD = pow(2, N, mod)\nprint(ans*pow(D, mod-2, mod) % mod)", "neg": "# Surrounded Nodes\nfrom collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\nmod = 10**9 + 7\nN = int(input())\nG = [[] for i in range(N+1)]\nfor i in range(N-1):\n a, b = map(int, input().split())\n G[a].append(b)\n G[b].append(a)\nS = -1\nfor i in range(1, N+1):\n if len(G[i]) == 1:\n S = i\n break\nvisited = [False for i in range(N+1)]\nparent = [-1 for i in range(N+1)]\ncount = [1 for i in range(N+1)]\n\nans = N*pow(2, N-1, mod)\nstack = deque()\n\n\ndef dfs(node):\n visited[node] = True\n for child in G[node]:\n if visited[child] == False:\n parent[child] = node\n stack.append((node, child))\n dfs(child)\n\n\ndfs(S)\nwhile stack:\n mom, child = stack.pop()\n count[mom] += count[child]\nans = 0\nfor i in range(1, N+1):\n if len(G[i]) > 1:\n c = 2**(N-1)\n for x in G[i]:\n if x != parent[i]:\n c -= 2**count[x]\n c -= 2**(N-count[i])\n c += len(G[i])-1\n ans += c\nD = pow(2, N, mod)\nprint(c*pow(D, mod-2, mod) % mod)", "jacc_sim": 0.9420289855072463, "nl": "You are given a tree with N vertices. Each vertex is painted black with a 1/2 probability and white with a 1/2 probability, independently from other vertices. Find the expected number of white vertices in the smallest subtree containing all the black vertices. Print the result modulo 10^9+7. The input is given in the format N, followed by pairs of vertices. Output the expected number of white vertices modulo 10^9+7.", "before_after_length": [470, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02822", "p_user": "u968166680", "n_user": "u968166680", "pos": "from sys import stdin, setrecursionlimit\nfrom collections import deque\n\nsetrecursionlimit(10 ** 9)\nINF = 1 << 60\n\n\ndef input():\n return stdin.readline().strip()\n\n\nMOD = 1000000007\nN = int(input())\nG = [[] for _ in range(N)]\nfor _ in range(N - 1):\n a, b = map(int, input().split())\n G[a - 1].append(b - 1)\n G[b - 1].append(a - 1)\n\npow2 = [1] * (N + 1)\nfor i in range(N):\n pow2[i + 1] = pow2[i] * 2 % MOD\n\norder = []\nparent = [-1] * N\n\nstack = deque([0])\nwhile stack:\n v = stack.pop()\n order.append(v)\n for nv in G[v]:\n if parent[v] != nv:\n parent[nv] = v\n stack.append(nv)\n\nnumer = 0\nnums = [0] * N\n\nfor v in reversed(order):\n tmp = 1\n for nv in G[v]:\n if parent[v] != nv:\n c = nums[nv] + 1\n nums[v] += c\n tmp += pow2[c] - 1\n tmp += pow2[N - nums[v] - 1] - 1\n numer = (numer + pow2[N - 1] - tmp) % MOD\n\ndenom = pow2[N]\nans = numer * pow(denom, MOD - 2, MOD) % MOD\nprint(ans)\n", "neg": "from sys import stdin, setrecursionlimit\nfrom collections import deque\n\nsetrecursionlimit(10 ** 9)\nINF = 1 << 60\n\n\ndef input():\n return stdin.readline().strip()\n\n\nMOD = 1000000007\nN = int(input())\nm = map(int, stdin.buffer.read().split())\nAB = zip(m, m)\nG = [[] for _ in range(N)]\nfor a, b in AB:\n G[a - 1].append(b - 1)\n G[b - 1].append(a - 1)\n\npow2 = [1] * (N + 1)\nfor i in range(N):\n pow2[i + 1] = pow2[i] * 2 % MOD\n\norder = []\nparent = [-1] * N\n\nstack = deque([0])\nwhile stack:\n v = stack.pop()\n order.append(v)\n for nv in G[v]:\n if parent[v] != nv:\n parent[nv] = v\n stack.append(nv)\n\nnumer = 0\nnums = [0] * N\n\nfor v in reversed(order):\n tmp = 1\n for nv in G[v]:\n if parent[v] != nv:\n nums[v] += nums[nv] + 1\n tmp += pow2[nums[nv] + 1] - 1\n tmp += pow2[N - nums[v] - 1] - 1\n numer = (numer + pow2[N - 1] - tmp) % MOD\n\ndenom = pow2[N]\nans = numer * pow(denom, MOD - 2, MOD) % MOD\nprint(ans)\n", "jacc_sim": 0.9154929577464789, "nl": "You are given a tree with N vertices. Each vertex is painted black with a 1/2 probability and white with a 1/2 probability, independently from other vertices. Find the expected number of white vertices in the smallest subtree containing all the black vertices. Print the result modulo 10^9+7. The input is given in the format N, followed by pairs of vertices. Output the expected number of white vertices modulo 10^9+7.", "before_after_length": [389, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02822", "p_user": "u693716675", "n_user": "u693716675", "pos": "#f\nimport sys\nsys.setrecursionlimit(2 * 10 ** 5 + 10)\n \n\nn = int(input())\nE = [[] for _ in range(n)]\nmod = 10**9 + 7\n\nfor i in range(n-1):\n a,b = [int(x) for x in input().split()]\n E[a-1].append((b-1, i)) \n E[b-1].append((a-1, i)) \n \nX = [0] * n\n \ndef dfs(u,e):\n num = 1\n for v,c in E[u]:\n if c != e:\n num += dfs(v,c)\n X[e] = num \n return num\n\ndfs(0, -1)\n\nI = [1]\ninv = pow(2, mod-2, mod)\nfor i in range(n):\n I.append(I[-1] * inv % mod)\n\nans = 0\nfor i in range(n):\n x = X[i]\n ans += (1-I[x])*(1-I[n-x]) % mod\n \nans -= n * I[1]\nans += 1 - I[n]\nans %= mod\nprint(ans)\n\n", "neg": "#f\n\nn = int(input())\nE = [[] for _ in range(n)]\nmod = 10**9 + 7\n\nfor i in range(n-1):\n a,b = [int(x) for x in input().split()]\n E[a-1].append((b-1, i)) \n E[b-1].append((a-1, i)) \n \nX = [0] * n\n \ndef dfs(u,e):\n num = 1\n for v,c in E[u]:\n if c != e:\n num += dfs(v,c)\n X[e] = num \n return num\n\ndfs(0, -1)\n\nI = [1]\nfor i in range(n):\n I.append(I[-1] * pow(2, mod-2, mod) % mod)\n\nans = 0\nfor i in range(n):\n ans += (1-I[i])*(1-I[n-i])\n \nans -= n * I[1]\nans += 1 - I[n]\nans %= mod\nprint(ans)\n\n", "jacc_sim": 0.9090909090909091, "nl": "You are given a tree with N vertices. Each vertex is painted black with a 1/2 probability and white with a 1/2 probability, independently from other vertices. Find the expected number of white vertices in the smallest subtree containing all the black vertices. Print the result modulo 10^9+7. The input is given in the format N, followed by pairs of vertices. Output the expected number of white vertices modulo 10^9+7.", "before_after_length": [302, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u562016607", "n_user": "u562016607", "pos": "H,W=map(int,input().split())\nA=[[int(i) for i in input().split()] for j in range(H)]\nB=[[int(i) for i in input().split()] for j in range(H)]\ndp=[[0 for j in range(W)] for i in range(H)]\nM=161*161\ndp[0][0]|=1<<(A[0][0]-B[0][0]+M)\ndp[0][0]|=1<<(-A[0][0]+B[0][0]+M)\n\nfor i in range(H):\n for j in range(W):\n dij=abs(A[i][j]-B[i][j])\n if i>0:\n dp[i][j]|=dp[i-1][j]<>dij\n if j>0:\n dp[i][j]|=dp[i][j-1]>>dij\n dp[i][j]|=dp[i][j-1]<0:\n dp[i][j]|=dp[i-1][j]<>dij\n if j>0:\n dp[i][j]|=dp[i][j-1]>>dij\n dp[i][j]|=dp[i][j-1]<=0 and J=0 and J>a[i][j+1]) \n \n if 0<=i+1>a[i+1][j])\n \nA=str(bin(dp[H-1][W-1]))[::-1]\nL=len(A)\nans=3200\nfor i in range(L):\n if A[i]==\"1\":\n ans=min(ans,abs(i-X))\nprint(ans)", "neg": "# Atcoder Problem Solving\nH,W=map(int,input().split())\na=[list(map(int,input().split())) for i in range(H)]\nb=[list(map(int,input().split())) for i in range(H)]\nfor i in range(H):\n for j in range(W):\n a[i][j]=abs(a[i][j]-b[i][j])\ndp=[[0 for i in range(W)] for j in range(H)]\n\n# Bitset\u6f14\u7b97\n# \u7b54\u3048\u306f\u7d76\u5bfe\u5024\u304c\u7d76\u5bfe-80\u304b\u308980\u4ee5\u5185\u306b\u53ce\u307e\u308b\n\nX=80\n\ndp[0][0]|= (1<<(X+a[0][0])) \ndp[0][0]|= (1<<(X-a[0][0]))\n# \u521d\u671f\u5316\u306e\u6761\u4ef6\n\nfor i in range(H):\n for j in range(W):\n if 0<=i-1>dd) \n \n if 0<=i>d)\n \nA=str(bin(dp[H-1][W-1]))[::-1]\nL=len(A)\n\nans=80\nfor i in range(L-2):\n if A[i]==\"1\":\n ans=min(ans,abs(i-X))\nprint(ans)\n", "jacc_sim": 0.935064935064935, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [510, 497], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u626881915", "n_user": "u626881915", "pos": "h, w = map(int, input().split())\nmat = []\nfor i in range(h):\n a = list(map(int, input().split()))\n mat.append(a)\nfor i in range(h):\n b = list(map(int, input().split()))\n for j in range(w):\n mat[i][j] = abs(mat[i][j]-b[j])\nm = max(map(max, mat))\ndp = [[0b0 for i in range(w)] for k in range(h)]\ndp[0][0] |= 0b1 << mat[0][0]\nfor y in range(h):\n for x in range(w):\n if x > 0:\n dp[y][x] |= dp[y][x-1] << mat[y][x]\n dp[y][x] |= dp[y][x-1] >> mat[y][x]\n anded = dp[y][x-1] & int('1'*(mat[y][x]+1), 2)\n reverse = format(anded, \"0\"+str(mat[y][x]+1)+\"b\")[::-1]\n\n dp[y][x] |= int(reverse, 2)\n if y > 0:\n dp[y][x] |= dp[y-1][x] << mat[y][x]\n dp[y][x] |= dp[y-1][x] >> mat[y][x]\n anded = dp[y-1][x] & int('1'*(mat[y][x]+1), 2)\n reverse = format(anded, \"0\"+str(mat[y][x]+1)+\"b\")[::-1]\n\n dp[y][x] |= int(reverse, 2)\n #print(bin(dp[y][x]))\n\nketa = 0\nwhile dp[h-1][w-1] % 2 == 0:\n keta += 1\n dp[h-1][w-1] //= 2\nprint(keta)\n", "neg": "h, w = map(int, input().split())\nmat = []\nfor i in range(h):\n a = list(map(int, input().split()))\n mat.append(a)\nfor i in range(h):\n b = list(map(int, input().split()))\n for j in range(w):\n mat[i][j] = abs(mat[i][j]-b[j])\nm = max(map(max, mat))\ndp = [[0b0 for i in range(w)] for k in range(h)]\ndp[0][0] |= 0b1 << mat[0][0]\nfor y in range(h):\n for x in range(w):\n if x > 0:\n dp[y][x] |= dp[y][x-1] << mat[y][x]\n dp[y][x] |= dp[y][x-1] >> mat[y][x]\n anded = dp[y][x-1] & int('1'*(mat[y][x]+1), 2)\n reverse = format(anded, \"0\"+str(mat[y][x]+1)+\"b\")[::-1]\n\n dp[y][x] |= int(reverse, 2)\n if y > 0:\n dp[y][x] |= dp[y-1][x] << mat[y][x]\n dp[y][x] |= dp[y-1][x] >> mat[y][x]\n anded = dp[y-1][x] & int('1'*(mat[y][x]+1), 2)\n reverse = format(anded, \"0\"+str(mat[y][x]+1)+\"b\")[::-1]\n\n dp[y][x] |= int(reverse, 2)\n print(bin(dp[y][x]))\n\nketa = 0\nwhile dp[h-1][w-1] % 2 == 0:\n keta += 1\n dp[h-1][w-1] //= 2\nprint(keta)\n", "jacc_sim": 0.9821428571428571, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [492, 491], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u211706121", "n_user": "u211706121", "pos": "h,w=map(int,input().split())\na=[list(map(int,input().split())) for i in range(h)]\nb=[list(map(int,input().split())) for i in range(h)]\n\npos = 160*80\ndp=[[0]*w for i in range(h)]\nsub=abs(a[0][0]-b[0][0])\ndp[0][0]=1<<(pos-sub)\ndp[0][0]=1<<(pos+sub)\n\nfor c in range(h):\n for l in range(w):\n sub=abs(a[c][l]-b[c][l])\n if l!=0:\n dp[c][l]|=dp[c][l-1]<>sub\n if c!=0:\n dp[c][l]|=dp[c-1][l]<>sub\nbit=dp[-1][-1]\nfor i in range(pos):\n if (bit&1<<(pos+i))or(bit&1<<(pos-i)):\n print(i)\n break", "neg": "h,w=map(int,input().split())\na=[list(map(int,input().split())) for i in range(h)]\nb=[list(map(int,input().split())) for i in range(h)]\n\npos = 160*80\ndp=[[0]*w for i in range(h)]\nsub=abs(a[0][0]-b[0][0])\ndp[0][0]=1<>sub\n if c!=0:\n dp[c][l]|=dp[c-1][l]<>sub\nbit=dp[-1][-1]\nfor i in range(pos):\n if (bit&1<<(pos+i))or(bit&1<<(pos-i)):\n print(i)\n break", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [304, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u816587940", "n_user": "u816587940", "pos": "import sys\ndef main():\n input=sys.stdin.readline\n h,w=map(int,input().split())\n a=[list(map(int,input().split())) for _ in range(h)]\n b=[list(map(int,input().split())) for _ in range(h)]\n ofset = 80*164\n mask = (1 << (ofset*2)) - 1\n dp=[[0 for i in range(w)] for j in range(h)]\n dp[0][0] |= 1 << (a[0][0] - b[0][0] + ofset)\n dp[0][0] |= 1 << (b[0][0] - a[0][0] + ofset)\n for i in range(h):\n for j in range(w):\n if i < h - 1:\n A = abs(a[i+1][j] - b[i+1][j])\n dp[i+1][j] |= (dp[i][j] << A) & mask\n dp[i+1][j] |= (dp[i][j] >> A) & mask\n if j < w - 1:\n A = abs(a[i][j+1] - b[i][j+1])\n dp[i][j+1] |= (dp[i][j] << A) & mask\n dp[i][j+1] |= (dp[i][j] >> A) & mask\n ans = 10000000000\n for i in range(ofset, 80*330):\n if (dp[h-1][w-1]>>i)&1: ans = min(ans, i - ofset)\n for i in range(ofset):\n if (dp[h-1][w-1]>>i)&1: ans = min(ans, ofset - i)\n print(ans)\nif __name__=='__main__':\n main()\n", "neg": "import sys\ndef main():\n input=sys.stdin.readline\n h,w=map(int,input().split())\n a=[list(map(int,input().split())) for _ in range(h)]\n b=[list(map(int,input().split())) for _ in range(h)]\n \"\"\"\n ofset = 80*164\n #mask = (1 << (ofset*2)) - 1\n dp=[[0 for i in range(w)] for j in range(h)]\n dp[0][0] |= 1 << (a[0][0] - b[0][0] + ofset)\n dp[0][0] |= 1 << (b[0][0] - a[0][0] + ofset)\n for i in range(h):\n for j in range(w):\n if i < h - 1:\n A = abs(a[i+1][j] - b[i+1][j])\n dp[i+1][j] |= (dp[i][j] << A)\n dp[i+1][j] |= (dp[i][j] >> A)\n if j < w - 1:\n A = abs(a[i][j+1] - b[i][j+1])\n dp[i][j+1] |= (dp[i][j] << A)\n dp[i][j+1] |= (dp[i][j] >> A)\n ans = 10000000000\n for i in range(ofset, 80*330):\n if (dp[h-1][w-1]>>i)&1:\n ans = i - ofset\n break\n for i in reversed(range(ofset)):\n if (dp[h-1][w-1]>>i)&1:\n ans = min(ans, ofset - i)\n break\n print(ans)\n \"\"\"\nif __name__=='__main__':\n main()\n", "jacc_sim": 0.9482758620689655, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [463, 470], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u201928947", "n_user": "u201928947", "pos": "import time\nt1 = time.time()\nh,w = map(int,input().split())\ngrid = []\nfor i in range(h):\n grid.append(list(map(int,input().split())))\nfor i in range(h):\n lst = list(map(int,input().split()))\n for j in range(w):\n grid[i][j] = abs(grid[i][j]-lst[j])\nlst = [[set() for _ in range(w)] for _ in range(h)]\nlst[0][0].add(grid[0][0])\nfor j in range(1,w):\n for x in lst[0][j-1]:\n lst[0][j].add(abs(grid[0][j]-x))\n if (grid[0][j] + x) <= 6400:\n lst[0][j].add(grid[0][j]+x)\nfor i in range(1,h):\n for x in lst[i-1][0]:\n lst[i][0].add(abs(grid[i][0]-x))\n if grid[i][0] + x <= 6400:\n lst[i][0].add(grid[i][0]+x)\nfor i in range(1,h):\n for j in range(1,w):\n for x in lst[i][j-1]:\n lst[i][j].add(abs(grid[i][j]-x))\n if grid[i][j] + x <= 6400:\n lst[i][j].add(grid[i][j]+x)\n for x in lst[i-1][j]:\n lst[i][j].add(abs(grid[i][j]-x))\n if grid[i][j] + x <= 6400:\n lst[i][j].add(grid[i][j]+x)\n t = time.time()\n if t - t1 > 1.8:\n print(0)\n exit()\nprint(min(lst[h-1][w-1]))\n", "neg": "import time\nt1 = time.time()\nh,w = map(int,input().split())\ngrid = []\nfor i in range(h):\n grid.append(list(map(int,input().split())))\nfor i in range(h):\n lsti = list(map(int,input().split()))\n for j in range(w):\n grid[i][j] = abs(grid[i][j]-lst[j])\nlst = [[set() for _ in range(w)] for _ in range(h)]\nlst[0][0].add(grid[0][0])\nfor j in range(1,w):\n for x in lst[0][j-1]:\n lst[0][j].add(abs(grid[0][j]-x))\n if (grid[0][j] + x) <= 6400:\n lst[0][j].add(grid[0][j]+x)\nfor i in range(1,h):\n for x in lst[i-1][0]:\n lst[i][0].add(abs(grid[i][0]-x))\n if grid[i][0] + x <= 6400:\n lst[i][0].add(grid[i][0]+x)\nfor i in range(1,h):\n for j in range(1,w):\n for x in lst[i][j-1]:\n lst[i][j].add(abs(grid[i][j]-x))\n if grid[i][j] + x <= 6400:\n lst[i][j].add(grid[i][j]+x)\n for x in lst[i-1][j]:\n lst[i][j].add(abs(grid[i][j]-x))\n if grid[i][j] + x <= 6400:\n lst[i][j].add(grid[i][j]+x)\n t = time.time()\n if t - t1 > 1.8:\n print(0)\n exit()\nprint(min(lst[h-1][w-1]))", "jacc_sim": 0.9777777777777777, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [498, 498], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u919730120", "n_user": "u919730120", "pos": "import sys\n#input = sys.stdin.readline\n\ndef main():\n inp = lambda: list(map(int, input().split())) \n h,w=inp()\n a=[inp() for _ in range(h)]\n b=[inp() for _ in range(h)]\n d=[[0]*w for _ in range(h)]\n for i in range(h):\n for j in range(w):\n d[i][j]=abs(a[i][j]-b[i][j])\n zero=80*(h+w)+2\n dp=[[0]*w for _ in range(h)]\n dp[0][0]=1<<(zero+d[0][0])|1<<(zero-d[0][0])\n for i in range(h):\n for j in range(w):\n if i==0:\n if j==0:\n continue\n else:\n dp[i][j]=dp[i][j-1]<>d[i][j]\n else:\n if j==0:\n dp[i][j]=dp[i-1][j]<>d[i][j]\n else:\n dp[i][j]=dp[i-1][j]<>d[i][j]\n dp[i][j]=dp[i][j]|(dp[i][j-1]<>d[i][j])\n ans=dp[-1][-1]\n for i in range(zero):\n if ans>>(zero+i)&1 or ans>>(zero-i)&1:\n print(i)\n exit()\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n#input = sys.stdin.readline\n\ndef main():\n inp = lambda: list(map(int, input().split())) \n h,w=inp()\n a=[inp() for _ in range(h)]\n b=[inp() for _ in range(h)]\n d=[[0]*w for _ in range(h)]\n for i in range(h):\n for j in range(w):\n d[i][j]=abs(a[i][j]-b[i][j])\n zero=80*(h+w)+2\n dp=[[0]*w for _ in range(h)]\n dp[0][0]=1<<(zero+d[0][0])|1<<(zero-d[0][0])\n for i in range(h):\n for j in range(w):\n if i==0:\n if j==0:\n continue\n else:\n dp[i][j]=dp[i][j-1]<>d[i][j]\n else:\n if j==0:\n dp[i][j]=dp[i-1][j]<>d[i][j]\n else:\n dp[i][j]=dp[i-1][j]<>d[i][j]\n dp[i][j]=dp[i][j]|(dp[i][j-1]<>d[i][j])\n ans=dp[-1][-1]\n print(dp)\n for i in range(zero):\n if ans>>(zero+i)&1 or ans>>(zero-i)&1:\n print(i)\n exit()\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [468, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u905582793", "n_user": "u905582793", "pos": "h,w = map(int,input().split())\na = [list(map(int,input().split())) for i in range(h)]\nb = [list(map(int,input().split())) for i in range(h)]\ngrid = [[0 for i in range(w)] for j in range(h)]\nfor i in range(h):\n for j in range(w):\n grid[i][j] = abs(a[i][j]-b[i][j])\ndp = [[0 for j in range(w)] for k in range(h)]\nbuf = (h+w)*80\nfor i in range(h):\n for j in range(w):\n t = grid[i][j]\n if i == j == 0:\n dp[i][j] = 1 << buf+t | 1 << buf-t\n if j > 0:\n dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t\n if i > 0:\n dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t\nfor i in range(buf):\n if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):\n print(i)\n exit()", "neg": "h,w = map(int,input().split())\na = [list(map(int,input().split())) for i in range(h)]\nb = [list(map(int,input().split())) for i in range(h)]\ngrid = [[0 for i in range(w)] for j in range(h)]\nfor i in range(h):\n for j in range(w):\n grid[i][j] = abs(a[i][j]-b[i][j])\ndp = [[0 for j in range(w)] for k in range(h)]\nbuf = (h+w)*80\nfor i in range(h):\n for j in range(w):\n t = grid[i][j]\n if i == j == 0:\n dp[i][j] = 1 << buf+t | 1 << buf-t\n if j > 0:\n dp[i][j] = dp[i][j] | dp[i][j-1] << t | dp[i][j-1] >> t\n if i > 0:\n dp[i][j] = dp[i][j] | dp[i-1][j] << t | dp[i-1][j] >> t\nprint(bin(dp[h-1][w-1]))\nfor i in range(buf):\n if (dp[h-1][w-1] & 1 << buf+i) or (dp[h-1][w-1] & 1 << buf-i):\n print(i)\n exit()", "jacc_sim": 0.9767441860465116, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [346, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u700278227", "n_user": "u700278227", "pos": "import numpy as np\n\nH,W = map(int,input().split())\nA = np.zeros((H,W))\nfor c in [1,-1]:\n for i in range(H):\n num = list(map(int,input().split()))\n A[i,:] += np.array(num) * c\n\nM = 160*80\ndp = [[0]*W for _ in range(H)]\ndp[0][0] = 1 << M\nfor i in range(H):\n for j in range(W):\n if i > 0:\n dp[i][j] |= dp[i-1][j]\n if j > 0:\n dp[i][j] |= dp[i][j-1]\n a = abs(A[i,j])\n dp[i][j] = (dp[i][j] << int(a)) | (dp[i][j] >> int(a))\ni = M\nwhile True:\n if (dp[H-1][W-1] >> i) & 1:\n print(i-M)\n break\n i += 1", "neg": "H,W = map(int,input().split())\nA = np.zeros((H,W))\nfor c in [1,-1]:\n for i in range(H):\n num = list(map(int,input().split()))\n A[i,:] += np.array(num) * c\n\nM = 160*80\ndp = [[0]*W for _ in range(H)]\ndp[0][0] = 1 << M\nfor i in range(H):\n for j in range(W):\n if i > 0:\n dp[i][j] |= dp[i-1][j]\n if j > 0:\n dp[i][j] |= dp[i][j-1]\n a = abs(A[i,j])\n dp[i][j] = (dp[i][j] << int(a)) | (dp[i][j] >> int(a))\ni = M\nwhile True:\n if (dp[H-1][W-1] >> i) & 1:\n print(i-M)\n break\n i += 1", "jacc_sim": 0.94, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [266, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u379629675", "n_user": "u379629675", "pos": "# -*- coding: utf-8 -*-\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nwrite = sys.stdout.write\n# template\n\n\ndef solve():\n ofs = 700\n h, w = map(int, readline().split())\n A = [list(map(int, readline().split())) for i in range(h)]\n B = [list(map(int, readline().split())) for i in range(h)]\n dp = [0 for _ in range(w+1)]\n x = abs(A[0][0]-B[0][0])\n dp[0] = 1 << ofs\n\n for i in range(h):\n for j in range(w):\n x = abs(A[i][j]-B[i][j])\n t = dp[j] | dp[j-1]\n dp[j] = (t << x) | (t >> x)\n\n for i, s in enumerate(bin(dp[w-1])[-ofs-1:]):\n if(int(s)):\n print(i)\n return\n\n\nif __name__ == \"__main__\":\n solve()\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nwrite = sys.stdout.write\n# template\n\n\ndef resolve():\n ofs = 1000\n h, w = map(int, readline().split())\n A = [list(map(int, readline().split())) for i in range(h)]\n B = [list(map(int, readline().split())) for i in range(h)]\n dp = [[0]*(w+1) for _ in range(h+1)]\n x = abs(A[0][0]-B[0][0])\n dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))\n\n for i in range(h):\n for j in range(w):\n x = abs(A[i][j]-B[i][j])\n t = 0\n t |= dp[i-1][j]\n t |= dp[i][j-1]\n dp[i][j] |= ((t << x) | (t >> x))\n\n b = map(int, list(bin(dp[h-1][w-1])[-ofs-1:]))\n for i, s in enumerate(b):\n if(s):\n print(i)\n print(0)\n return\n\n\nif __name__ == \"__main__\":\n resolve()\n", "jacc_sim": 0.9206349206349206, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [295, 353], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u893063840", "n_user": "u893063840", "pos": "h, w = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(h)]\nb = [list(map(int, input().split())) for _ in range(h)]\n\nx = (h + w) * 80\n\ndp = [[0] * w for _ in range(h)]\nd = abs(a[0][0] - b[0][0])\ndp[0][0] = 1 << (x - d)\n\nfor i in range(h):\n for j, (ae, be) in enumerate(zip(a[i], b[i])):\n if i == j == 0:\n continue\n\n d = abs(ae - be)\n bt = 0\n if i != 0:\n bt |= dp[i-1][j] << d\n bt |= dp[i-1][j] >> d\n\n if j != 0:\n bt |= dp[i][j-1] << d\n bt |= dp[i][j-1] >> d\n\n dp[i][j] = bt\n\ndp = dp[-1][-1]\n\nb = bin(dp)[2:]\ncan_make = [i - x for i, be in enumerate(b[::-1]) if be == \"1\"]\n\nans = min(x if x >= 0 else -x for x in can_make)\nprint(ans)\n", "neg": "h, w = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(h)]\nb = [list(map(int, input().split())) for _ in range(h)]\n\nx = (h + w) * 80\n\ndp = [[0] * w for _ in range(h)]\nd = abs(a[0][0] - b[0][0])\ndp[0][0] = 1 << (x - d)\n\nfor i in range(h):\n for j, (ae, be) in enumerate(zip(a[i], b[i])):\n if h == w == 0:\n continue\n\n d = abs(ae - be)\n bt = 0\n if i != 0:\n bt |= dp[i-1][j] << d\n bt |= dp[i-1][j] >> d\n\n if j != 0:\n bt |= dp[i][j-1] << d\n bt |= dp[i][j-1] >> d\n\n dp[i][j] = bt\n\ndp = dp[-1][-1]\n\nb = bin(dp)[2:]\ncan_make = [i - x for i, be in enumerate(b[::-1]) if be == \"1\"]\n\nans = min(x if x >= 0 else -x for x in can_make)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [335, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u379629675", "n_user": "u379629675", "pos": "# -*- coding: utf-8 -*-\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nwrite = sys.stdout.write\n# template\n\n\ndef resolve():\n ofs = 6400\n h, w = map(int, readline().split())\n A = [list(map(int, readline().split())) for i in range(h)]\n B = [list(map(int, readline().split())) for i in range(h)]\n dp = [[0]*w for _ in range(h)]\n x = abs(A[0][0]-B[0][0])\n dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))\n\n from itertools import product\n for i, j in product(range(h), range(w)):\n x = abs(A[i][j]-B[i][j])\n t = 0\n if(i-1 >= 0):\n t |= dp[i-1][j]\n if(j-1 >= 0):\n t |= dp[i][j-1]\n dp[i][j] |= ((t << x) | (t >> x))\n\n for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):\n if(s == '1'):\n write(\"%d\\n\" % i)\n return\n\n\nif __name__ == \"__main__\":\n INF = float(\"inf\")\n MOD = 10**9+7\n resolve()\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nwrite = sys.stdout.write\n# template\n\n\ndef resolve():\n ofs = 6400\n h, w = map(int, readline().split())\n A = [list(map(int, readline().split())) for i in range(h)]\n B = [list(map(int, readline().split())) for i in range(h)]\n dp = [[0]*w for _ in range(h)]\n x = abs(A[0][0]-B[0][0])\n dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))\n\n for i in range(h):\n for j in range(w):\n x = abs(A[i][j]-B[i][j])\n t = 0\n if(i-1 >= 0):\n t |= dp[i-1][j]\n if(j-1 >= 0):\n t |= dp[i][j-1]\n dp[i][j] |= ((t << x) | (t >> x))\n\n for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):\n if(s == '1'):\n write(\"%d\\n\" % i+1)\n return\n\n\nif __name__ == \"__main__\":\n INF = float(\"inf\")\n MOD = 10**9+7\n resolve()\n", "jacc_sim": 0.958904109589041, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [379, 375], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u711539583", "n_user": "u711539583", "pos": "import sys\ndef main():\n input = sys.stdin.readline\n h, w = map(int, input().split())\n A = []\n AB = []\n A_append = A.append\n AB_append = AB.append\n for i in range(h):\n row = list(map(int, input().split()))\n A_append(row)\n for i in range(h):\n row = [abs(A[i][j] - int(b)) for j, b in enumerate(input().split())]\n AB_append(row)\n \n dp_cur = [set([]) for _ in range(w)]\n dp_cur[0].add(AB[0][0])\n for i in range(h):\n dp_next = [set([]) for _ in range(w)]\n for j in range(w):\n if j < w - 1:\n add1 = dp_cur[j+1].add\n dif1 = AB[i][j+1]\n if i < h - 1:\n add2 = dp_next[j].add\n dif2 = AB[i+1][j]\n for item in dp_cur[j]:\n if j < w - 1:\n add1(item+dif1)\n add1(abs(item-dif1))\n if i < h - 1:\n add2(item+dif2)\n add2(abs(item-dif2))\n if i == h - 1:\n break\n dp_cur = dp_next\n print(min(dp_cur[w-1]))\nif __name__ == '__main__':\n main()\n", "neg": "import sys\ndef main():\n input = sys.stdin.readline\n h, w = map(int, input().split())\n A = []\n AB = []\n A_append = A.append\n AB_append = AB_append\n for i in range(h):\n row = list(map(int, input().split()))\n A_append(row)\n for i in range(h):\n row = [abs(A[i][j] - int(b)) for j, b in enumerate(input().split())]\n AB_append(row)\n \n dp = [[set([]) for j in range(w+1)] for i in range(h+1)]\n dp[0][0].add(AB[0][0])\n for i in range(h):\n for j in range(w):\n dif1 = 0\n dif2 = 0\n if j < w - 1:\n add1 = dp[i][j+1].add\n dif1 = AB[i][j+1]\n if i < h - 1:\n add2 = dp[j+1][i].add\n dif2 = AB[i+1][j]\n for item in dp[i][j]:\n if j < w - 1:\n add1(item+dif1)\n add1(abs(item-dif1))\n if i < h - 1:\n add2(item+dif2)\n add2(abs(item-dif2))\n print(min(dp[h-1][w-1]))\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9137931034482759, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [399, 386], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u638282348", "n_user": "u638282348", "pos": "R, C = map(int, input().split())\n\nA = [list(map(int, input().split())) for _ in range(R)]\nB = [list(map(int, input().split())) for _ in range(R)]\n\ndp = [0] * C\ndp[0] = s = 1 << 6400\n\nfor row_a, row_b in zip(A, B):\n for i, (a, b) in enumerate(zip(row_a, row_b)):\n d = abs(a - b)\n if i > 0:\n dp[i] |= dp[i - 1]\n dp[i] = (dp[i] << d) | (dp[i] >> d)\n\ng = dp[-1]\nfor i in range(6401):\n if g & (s << i) or g & (s >> i):\n print(i)\n quit()\n", "neg": "R, C = map(int, input().split())\n\nA = [list(map(int, input().split())) for _ in range(R)]\nB = [list(map(int, input().split())) for _ in range(R)]\n\ndp = [0] * R\ndp[0] = s = 1 << 6400\n\nfor row_a, row_b in zip(A, B):\n for i, (a, b) in enumerate(zip(row_a, row_b)):\n d = abs(a - b)\n if i > 0:\n dp[i] |= dp[i - 1]\n dp[i] <<= d\n dp[i] >>= d\n\ng = dp[-1]\nfor i in range(6401):\n if g & (s << i) or g & (s >> i):\n print(i)\n quit()", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [219, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u780475861", "n_user": "u780475861", "pos": "import numpy as np\n\nH, W = map(int, input().split())\nlst1 = []\nlst2 = []\nfor _ in range(H):\n lst1.append([int(i) for i in input().split()])\nfor _ in range(H):\n lst2.append([int(i) for i in input().split()])\narr1, arr2 = np.array(lst1), np.array(lst2)\narr = np.abs(arr1 - arr2)\n\nd = [[0] * W for _ in range(H)]\nm = 80 * (H + W)\nd[0][0] = 1 << m\nfor h in range(H):\n for w in range(W):\n x = arr[h][w]\n if h > 0:\n d[h][w] |= d[h - 1][w]\n if w > 0:\n d[h][w] |= d[h][w - 1]\n d[h][w] = d[h][w] << x | d[h][w] >> x\n\nx, y= 1 << m, 1 << m\nfor i in range(m + 1):\n if d[H - 1][W - 1] & x or d[H - 1][W - 1] & y:\n print(i)\n quit()\n x<<=1\n y>>=1", "neg": "import numpy as np\n\nH, W = map(int, input().split())\nlst1 = []\nlst2 = []\nfor _ in range(H):\n lst1.append([int(i) for i in input().split()])\nfor _ in range(H):\n lst2.append([int(i) for i in input().split()])\narr1, arr2 = np.array(lst1), np.array(lst2)\narr = np.abs(arr1 - arr2)\n\nd = [[0] * W for _ in range(H)]\nm = 80 * (H + W)\nd[0][0] = 1 << m\nfor h in range(H):\n for w in range(W):\n x = arr[h][w]\n if h > 0:\n print(h,w)\n d[h][w] |= d[h - 1][w]\n if w > 0:\n d[h][w] |= d[h][w - 1]\n d[h][w] = d[h][w] << x | d[h][w] >> x\n\nx, y= 1 << m, 1 << m\nfor i in range(m + 1):\n if d[H - 1][W - 1] & x or d[H - 1][W - 1] & y:\n print(i)\n quit()\n x<<=1\n y>>=1", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [328, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u777923818", "n_user": "u777923818", "pos": "def inpl(): return list(map(int, input().split()))\n\nH, W = inpl()\nA = [inpl() for _ in range(H)]\nB = [inpl() for _ in range(H)]\n\nDP = [[0 for _ in range(W+1)] for _ in range(H+1)]\nDP[0][0] = 1 << 12800\n\nfor h in range(H):\n for w in range(W):\n d = abs(A[h][w] - B[h][w])\n DP[h+1][w] |= DP[h][w] >> d\n DP[h+1][w] |= DP[h][w] << d\n DP[h][w+1] |= DP[h][w] >> d\n DP[h][w+1] |= DP[h][w] << d\nl = 1 << 12800\nr = 1 << 12800\nfor i in range(12801):\n if (DP[-1][-2]& l) | (DP[-1][-2] & r):\n print(i)\n break\n l = l << 1\n r = r >> 1", "neg": "def inpl(): return list(map(int, input().split()))\n\nH, W = inpl()\nA = [inpl() for _ in range(H)]\nB = [inpl() for _ in range(W)]\n\nDP = [[0 for _ in range(W+1)] for _ in range(H+1)]\nDP[0][0] = 1 << 12800\n\nfor h in range(H):\n for w in range(W):\n d = abs(A[h][w] - B[h][w])\n DP[h+1][w] |= DP[h][w] >> d\n DP[h+1][w] |= DP[h][w] << d\n DP[h][w+1] |= DP[h][w] >> d\n DP[h][w+1] |= DP[h][w] << d\nl = 1 << 12800\nr = 1 << 12800\nfor i in range(12800):\n if (DP[-1][-2]& l) | (DP[-1][-2] & r):\n print(i)\n break\n l = l << 1\n r = r >> 1", "jacc_sim": 0.9782608695652174, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [282, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u392319141", "n_user": "u392319141", "pos": "H, W = map(int, input().split())\nM = (H + W) * 80\n\nA = [tuple(map(int, input().split())) for _ in range(H)]\nB = [tuple(map(int, input().split())) for _ in range(H)]\n\ndp = [[0] * W for _ in range(H)]\ndp[0][0] = (1 << (M - abs(A[0][0] - B[0][0])))\n\nfor h in range(H):\n for w, (a, b) in enumerate(zip(A[h], B[h])):\n d = abs(a - b)\n mask = 0\n if h > 0:\n mask |= (dp[h - 1][w] << d)\n mask |= (dp[h - 1][w] >> d)\n if w > 0:\n mask |= (dp[h][w - 1] << d)\n mask |= (dp[h][w - 1] >> d)\n dp[h][w] |= mask\n\nstate = dp[-1][-1]\nnums = []\nfor digit, b in enumerate(bin(state)[2:][:: -1]):\n if b == '1':\n nums.append(digit - M)\nans = min(abs(n) for n in nums)\nprint(ans)\n", "neg": "H, W = map(int, input().split())\nM = (H + W) * 80\n\nA = [tuple(map(int, input().split())) for _ in range(H)]\nB = [tuple(map(int, input().split())) for _ in range(H)]\n\ndp = [[0] * W for _ in range(H)]\ndp[0][0] |= (1 << (M - abs(A[0][0] - B[0][0])))\n\nfor h in range(H):\n for w, (a, b) in enumerate(zip(A[h], B[h])):\n d = abs(a - b)\n if d == 0:\n continue\n mask = 0\n if h > 0:\n mask |= (dp[h - 1][w] << d)\n mask |= (dp[h - 1][w] >> d)\n if w > 0:\n mask |= (dp[h][w - 1] << d)\n mask |= (dp[h][w - 1] >> d)\n dp[h][w] = mask\n\nstate = dp[-1][-1]\nnums = []\nfor digit, b in enumerate(bin(state)[2:][:: -1]):\n if b == '1':\n nums.append(M - digit)\nans = min(abs(n) for n in nums)\nprint(ans)\n", "jacc_sim": 0.9814814814814815, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [322, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u708618797", "n_user": "u708618797", "pos": "#https://atcoder.jp/contests/abc147/submissions/8874645\nimport sys\nsys.setrecursionlimit(2147483647)\nINF=float(\"inf\")\nMOD=10**9+7\ninput=lambda:sys.stdin.readline().rstrip()\ndef resolve():\n ofs=6400\n h,w=map(int,input().split())\n A=[list(map(int,input().split())) for _ in range(h)]\n B=[list(map(int,input().split())) for _ in range(h)]\n dp=[[0]*w for _ in range(h)]\n x=abs(A[0][0]-B[0][0])\n dp[0][0]|=((1<<(ofs+x))|(1<<(ofs-x)))\n\n from itertools import product\n for i,j in product(range(h),range(w)):\n x=abs(A[i][j]-B[i][j])\n t=0\n if(i-1>=0):\n t|=dp[i-1][j]\n if(j-1>=0):\n t|=dp[i][j-1]\n dp[i][j]|=((t<>x))\n\n for i,s in enumerate(bin(dp[-1][-1])[-ofs-1:]):\n if(s=='1'):\n print(i)\n return\n \nresolve()\n", "neg": "#https://atcoder.jp/contests/abc147/submissions/8874645\nimport sys\nsys.setrecursionlimit(2147483647)\nINF=float(\"inf\")\nMOD=10**9+7\ninput=lambda:sys.stdin.readline().rstrip()\ndef resolve():\n ofs=6400\n h,w=map(int,input().split())\n A=[list(map(int,input().split())) for _ in range(h)]\n B=[list(map(int,input().split())) for _ in range(h)]\n dp=[[0]*w for _ in range(h)]\n x=abs(A[0][0]-B[0][0])\n dp[0][0]|=(1<<(ofs+x))|(1<<(ofs-x))\n\n from itertools import product\n for i,j in product(range(h),range(w)):\n x=abs(A[i][j]-B[i][j])\n t=0\n if(i-1>=0):\n t|=dp[i-1][j]\n if(j-1>=0):\n t|=dp[i][j-1]\n dp[i][j]=(t<>x)\n\n for i,s in enumerate(bin(dp[-1][-1])[ofs:]):\n if(s=='1'):\n print(i)\n return\n \nresolve()\n", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [361, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u497046426", "n_user": "u497046426", "pos": "from itertools import product\n\ndef offset(a, b):\n result = 0\n if b == 0: return 0\n for i in range(b+1):\n if (a >> i) & 1:\n result |= (1 << b) >> i\n return result\n\nH, W = map(int, input().split())\ndiff = [list(map(int, input().split())) for _ in range(H)]\nM = 80\nfor i in range(H):\n B = list(map(int, input().split()))\n for j in range(W):\n diff[i][j] = abs(diff[i][j] - B[j])\ndp = [[0]*W for _ in range(H)]\ndp[0][0] = 1 << diff[0][0]\nfor i, j in product(range(H), range(W)):\n if (i, j) == (H-1, W-1): break\n if i+1 < H:\n k = diff[i+1][j]\n dp[i+1][j] |= (dp[i][j] >> k) | (dp[i][j] << k) | (offset(dp[i][j], k))\n if j+1 < W:\n k = diff[i][j+1]\n dp[i][j+1] |= (dp[i][j] >> k) | (dp[i][j] << k) | (offset(dp[i][j], k))\nans = dp[H-1][W-1]\nprint((ans & -ans).bit_length() - 1)", "neg": "from itertools import product\n\ndef offset(a, b):\n result = 0\n for i in range(b+1):\n if (a >> i) & 1:\n result |= (1 << b) >> i\n return result\n\nH, W = map(int, input().split())\ndiff = [list(map(int, input().split())) for _ in range(H)]\nM = 80\nfor i in range(H):\n B = list(map(int, input().split()))\n for j in range(W):\n diff[i][j] = abs(diff[i][j] - B[j])\ndp = [[0]*W for _ in range(H)]\ndp[0][0] = 1 << diff[0][0]\nfor i, j in product(range(H), range(W)):\n if (i, j) == (H-1, W-1): break\n if i+1 < H:\n k = diff[i+1][j]\n dp[i+1][j] = (dp[i][j] >> k) | (dp[i][j] << k) | (offset(dp[i][j], k))\n if j+1 < W:\n k = diff[i][j+1]\n dp[i][j+1] = (dp[i][j] >> k) | (dp[i][j] << k) | (offset(dp[i][j], k))\nans = dp[H-1][W-1]\nprint((ans & -ans).bit_length() - 1)", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [382, 373], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u150641538", "n_user": "u150641538", "pos": "import sys\ndef input():\n return sys.stdin.readline()[:-1]\nh,w=map(int,input().split())\na=[list(map(int,input().split())) for i in range(h)]\nb=[list(map(int,input().split())) for i in range(h)]\nd=[[0 for i in range(w)] for j in range(h)]\nmaxd=1\nfor i in range(h):\n for j in range(w):\n d[i][j] = abs(a[i][j]-b[i][j])\n maxd=max(maxd,d[i][j])\ndp=[[0 for j in range(w)] for k in range(h)]\nc=20000\ndp[0][0] |= 1 << c+d[0][0]\nfor i in range(h):\n for j in range(w):\n if i+1> d[i+1][j]\n if j+1> d[i][j+1]\nm=1000000\ncnt = 0\nfor x in bin(dp[h-1][w-1])[2:][::-1]:\n if x=='1':\n m=min(m,abs(cnt-c))\n cnt+=1\nprint(m)", "neg": "import sys\ndef input():\n return sys.stdin.readline()[:-1]\nh,w=map(int,input().split())\na=[list(map(int,input().split())) for i in range(h)]\nb=[list(map(int,input().split())) for i in range(h)]\nd=[[0 for i in range(w)] for j in range(h)]\nmaxd=1\nfor i in range(h):\n for j in range(w):\n d[i][j] = abs(a[i][j]-b[i][j])\n maxd=max(maxd,d[i][j])\ndp=[[0 for j in range(w)] for k in range(h)]\nc=20000\ndp[0][0] |= 1 << c+d[0][0]\nfor i in range(h):\n for j in range(w):\n if i+1> d[i+1][j]\n if j+1> d[i][j+1]\nm=1000000\ncnt = 0\nfor x in bin(dp[h-1][w-1])[2:][::-1]:\n m=min(m,abs(cnt-c))\n cnt+=1\nprint(m)", "jacc_sim": 0.9811320754716981, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [402, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02839", "p_user": "u314396879", "n_user": "u207576418", "pos": "H, W = [int(x) for x in input().split()]\n\nA = [[0]*W for i in range(H)]\nfor c in [1, -1]:\n for i in range(H):\n arr = [int(x) for x in input().split()]\n for j in range(W):\n A[i][j] += arr[j] * c\n\nM = 160*80\ndp = [[0]*W for i in range(H)]\ndp[0][0] = 1 << M\nfor i in range(H):\n for j in range(W):\n if i > 0:\n dp[i][j] |= dp[i-1][j]\n if j > 0:\n dp[i][j] |= dp[i][j-1]\n a = abs(A[i][j])\n dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a)\n\nans = M\nfor i in range(2*M):\n if dp[H-1][W-1] & (1 << i) > 0:\n ans = min(ans, abs(M-i))\nprint(ans)", "neg": "H, W = [int(x) for x in input().split()] A = [[0]*W for i in range(H)] for c in [1, -1]: for i in range(H): arr = [int(x) for x in input().split()] for j in range(W): A[i][j] += arr[j] * c M = 160*80 dp = [[0]*W for i in range(H)] dp[0][0] = 1 << M for i in range(H): for j in range(W): if i > 0: dp[i][j] |= dp[i-1][j] if j > 0: dp[i][j] |= dp[i][j-1] a = abs(A[i][j]) dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a) ans = M for i in range(2*M): if dp[H-1][W-1] & (1 << i) > 0: ans = min(ans, abs(M-i)) print(ans)\n", "jacc_sim": 1.0, "nl": "You are given a grid with H horizontal rows and W vertical columns. Each square (i, j) on the grid has two numbers Aij and Bij written on it. Takahashi paints one of the numbers red and the other blue for each square. He then travels from square (1, 1) to square (H, W), moving only to adjacent squares. The goal is to minimize the absolute difference between the sum of red numbers and the sum of blue numbers along Takahashi's path. Find the minimum unbalancedness possible. Constraints: 2 \u2264 H, W \u2264 80, 0 \u2264 Aij, Bij \u2264 80. Input format: H, W, followed by the grid of Aij and Bij values. Output the minimum unbalancedness.", "before_after_length": [287, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02840", "p_user": "u211706121", "n_user": "u211706121", "pos": "n,a,d=map(int,input().split())\n\ndic={}\n\nans=0\n\nif d==0:\n if a==0:\n print(1)\n else:\n print(n+1)\nelse:\n for k in range(n+1):\n l=k*a+k*(k-1)*d//2\n r=l+k*(n-k)*d\n idx=l%d\n l//=d\n r//=d\n if idx in dic:\n prel,prer=dic[idx]\n #\u5171\u901a\u90e8\u5206\u3042\u308a\u304b\u3001\u306a\u3057\u304b\u3067\u5206\u5c90\n if prerr:\n dic[idx]=(l,r)\n ans+=r-l+1 \n else:\n nl=min(prel,l)\n nr=max(prer,r)\n ans+=prel-nl+nr-prer\n dic[idx]=(nl,nr)\n else:\n ans+=r-l+1 \n dic[idx]=(l,r)\n print(ans)", "neg": "n,a,d=map(int,input().split())\n\ndic={}\n\nans=0\nfor k in range(n+1):\n l=k*a+k*(k-1)*d//2\n r=l+k*(n-k)*d\n idx=l%d\n l//=d\n r//=d\n print(l,r,idx)\n if idx in dic:\n prel,prer=dic[idx]\n #\u5171\u901a\u90e8\u5206\u3042\u308a\u304b\u3001\u306a\u3057\u304b\u3067\u5206\u5c90\n if prerr:\n dic[idx]=(l,r)\n ans+=r-l+1 \n else:\n nl=min(prel,l)\n nr=max(prer,r)\n ans+=prel-nl+nr-prer\n dic[idx]=(nl,nr)\n else:\n ans+=r-l+1 \n dic[idx]=(l,r)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an integer sequence A of length N, where A_1 = X, A_{i+1} = A_i + D (1 <= i < N) holds. Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others. Let S and T be the sum of the numbers taken by Takahashi and Aoki, respectively. Find the number of possible values of S - T. Constraints: -10^8 <= X, D <= 10^8, 1 <= N <= 2 * 10^5. Input is given in the format: N X D. Output the number of possible values of S - T.", "before_after_length": [298, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02840", "p_user": "u941407962", "n_user": "u941407962", "pos": "N,X,D=map(int,input().split())\nf,c,r={},[0]*10**8,0\nfor x,y,z in sorted((((N-k)*j+~-k)*k//2+k*X//D,j,k*X%D) if D else (0,j,k*(X!=0))for k in range(N+1)for j in[0,2]):\n if c[z]+y<1:\n f[z]=x\n r+=(x-f[z]+1)*(c[z]0:\n memo[x]=solve(x-1)+solve(x-2)+solve(x-3)\n return memo[x]\n elif x==0:\n memo[x]=1\n return 1\n else:\n return 0\n else:\n return memo[x]\n\ndef main():\n while True:\n inp=int(input())\n if inp==0:\n break\n print((solve(inp)-1)//3650+1)\n\nmain()", "neg": "#coding:utf-8\nfrom __future__ import division,print_function\ntry:\n input = raw_input\nexcept NameError:\n pass\n# \u4e0a\u8a18\u306e\u30b3\u30fc\u30c9\u306fPython2\u3068Python3\u306e\u9055\u3044\u3092\u4e00\u90e8\u5438\u53ce\u3059\u308b\u305f\u3081\u306e\u3082\u306e\nmemo=[0]*31\ndef solve(x):\n if memo[x]==0:\n if x>1:\n memo[x]=solve(x-1)+solve(x-2)+solve(x-3)\n return memo[x]\n elif x==0:\n memo[x]=1\n return 1\n else:\n return 0\n else:\n return memo[x]\n\ndef main():\n while True:\n inp=int(input())\n if inp==0:\n break\n print(solve(inp))\n\nmain()", "jacc_sim": 0.971830985915493, "nl": "Title: \u89b3\u97f3\u5802\n\nIn the backyard of Ichiro's house, there is a Kannon temple. To reach this temple, there are 30 steps from the base, and Ichiro visits the temple almost every day. Ichiro can climb 3 steps at a time. He realized that there are numerous ways to climb the stairs while playing. Wanting to try 10 types of climbs in a day, he needs help to calculate the time required to execute all climb types. The input consists of the number of steps, and the output should be the number of years required for Ichiro to execute all climb types. Each dataset ends with a single zero. The number of datasets does not exceed 30.\n\nSample Input:\n1\n10\n20\n25\n0\n\nOutput for the Sample Input:\n1\n1\n34\n701", "before_after_length": [257, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00169", "p_user": "u553058997", "n_user": "u553058997", "pos": "while True:\n inp = input()\n if inp == '0': break\n\n\n inp = inp.replace('11', '10')\n inp = inp.replace('12', '10')\n inp = inp.replace('13', '10')\n\n cards = tuple(map(int, inp.split()))\n ans = sum(cards)\n\n for i in range(cards.count(1)):\n if sum(cards) + 10 * (i+1) > 21:\n break\n elif ans < sum(cards) + 10 * (i+1):\n ans = sum(cards) + 10 * (i+1)\n\n if ans > 21: ans = 0\n print(ans)", "neg": "if input() == '1':\n pass\n\nwhile True:\n inp = input()\n if inp == '0': break\n\n\n inp = inp.replace('11', '10')\n inp = inp.replace('12', '10')\n inp = inp.replace('13', '10')\n\n cards = tuple(map(int, inp.split()))\n ans = sum(cards)\n\n for i in range(cards.count(1)):\n if sum(cards) + 10 * (i+1) > 21:\n break\n elif ans < sum(cards) + 10 * (i+1):\n ans = sum(cards) + 10 * (i+1)\n\n if ans > 21: ans = 0\n print(ans)", "jacc_sim": 0.975, "nl": "Title: Blackjack\n\nBlackjack is a card game played in casinos using cards numbered from 1 to 13. Each card has a specific point value as follows:\n- 1 is worth either 1 or 11 points\n- 2 to 9 are worth their face value\n- 10 to 13 are worth 10 points\n\nIn this game, there are multiple participants, including a dealer, each holding a set of cards, referred to as a \"hand.\" The hand's score is the sum of the card values, calculated as follows:\n- If the total exceeds 21, the hand's score is 0\n- For the value 1, it can be counted as 1 or 11, with the higher value chosen if it maximizes the hand's score\n\nCreate a program that takes the dealt card information as input and outputs the hand's score.\n\nInput:\nMultiple datasets are provided as input, ending with a single line containing only 0. Each dataset is in the following format:\nc1 c2 ... cn\nWhere each ci (1 \u2264 ci \u2264 13) represents the integer written on the ith card, separated by a space. The number of cards, n, does not exceed 100, and the number of datasets does not exceed 200.\n\nOutput:\nFor each dataset, output the hand's score on a new line.\n\nSample Input:\n1\n7 7 7\n7 7 8\n12 1\n10 1 1\n0\n\nOutput for the Sample Input:\n11\n21\n0\n21\n12", "before_after_length": [174, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00181", "p_user": "u514808940", "n_user": "u514808940", "pos": "\nclass Solve:\n def __init__(self):\n self.M, self.N = map(int, input().split())\n self.bs = [int(input()) for i in range(self.N)]\n\n self.S = min(sum(self.bs), 1500000)\n self.l, self.r = 0, self.S \n\n def check(self, W):\n w = W\n i = 1\n for b in self.bs:\n if(w >= b):\n w -= b\n elif(W >= b):\n if(i >= self.M):\n return False\n i += 1\n w = W - b\n else:\n return False\n return True\n\n def solve(self):\n while self.r - self.l > 1:\n m = (self.l + self.r) // 2\n if self.check(m):\n self.r = m\n else:\n self.l = m\n return self.r\n\nwhile True:\n s = Solve()\n if s.M == 0 and s.N == 0:\n break\n print(s.solve())", "neg": "\nclass Solve:\n def __init__(self):\n self.M, self.N = map(int, input().split())\n self.bs = [int(input()) for i in range(self.N)]\n\n self.S = min(sum(self.bs), 1500000)\n self.l, self.r = 0, self.S\n\n def check(self, W):\n w = W\n i = 1\n for b in self.bs:\n if(w >= b):\n w -= b\n elif(W >= b):\n if(i >= self.M):\n return False\n i += 1\n w = W - b\n else:\n return False\n return True\n\n def solve(self):\n while self.r - self.l > 1:\n m = (self.l + self.r) // 2\n if self.check(m):\n self.r = m\n else:\n self.l = m\n return self.r\n\nwhile True:\n print(Solve().solve())", "jacc_sim": 0.9444444444444444, "nl": "Taro is engrossed in a novel series. The series consists of \"n\" volumes, each with varying thickness. He wants to buy a bookshelf dedicated to this series, but due to limited space, he needs to minimize the shelf width. He can place the bookshelf in \"m\" levels. The task is to determine how to divide the \"n\" volumes to minimize the shelf width. Taro insists that the volumes must be arranged in numerical order on each level. Given the number of levels, volume count, and thickness of each volume, create a program to find the minimum shelf width. The frame size of the bookshelf is not included in the width. The input consists of multiple datasets, each ending with two zeros. The output should display the minimum shelf width for each dataset. The width of the bookshelf will not exceed 1,500,000. The number of datasets will not exceed 50.", "before_after_length": [281, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00184", "p_user": "u814278309", "n_user": "u814278309", "pos": "while True:\n x=[0 for i in range(7)]\n n=int(input())\n if n==0:\n break\n for i in range(n):\n a=int(input())\n if 0<=a<10:\n x[0]+=1\n elif 10<=a<20:\n x[1]+=1\n elif 20<=a<30:\n x[2]+=1\n elif 30<=a<40:\n x[3]+=1\n elif 40<=a<50:\n x[4]+=1 \n elif 50<=a<60:\n x[5]+=1\n else:\n x[6]+=1\n for i in range(7):\n print(x[i])\n", "neg": "n=int(input())\nx=[0 for i in range(7)]\nwhile True:\n if n==0:\n break\n for i in range(n):\n a=int(input())\n if 0<=a<10:\n x[0]+=1\n elif 10<=a<20:\n x[1]+=1\n elif 20<=a<30:\n x[2]+=1\n elif 30<=a<40:\n x[3]+=1\n elif 40<=a<50:\n x[4]+=1 \n elif 50<=a<60:\n x[5]+=1\n else:\n x[6]+=1\n for i in range(7):\n if x[i]==0:\n print(0)\n else:\n print(x[i])\n", "jacc_sim": 1.0, "nl": "Title: \u9db4\u30f6\u57ce\n\nThe symbol of Aizuwakamatsu City, Tsurugajo Castle, was built by Gamo Ujisato with a full-fledged castle tower and named \"Tsurugajo Castle.\" The Aizu Basin can be seen from the castle tower. On clear days, visitors can see Tsurugajo Castle from the mountaintop of Iimoriyama, famous for the Byakkotai.\n\nFor future public relations activities in Aizuwakamatsu City, a survey of the ages of visitors to Tsurugajo Castle has been decided. Create a program that takes the age of visitors as input and outputs the number of people in the following age groups for reference.\n\nInput\nMultiple datasets are given as input. The end of the input is indicated by a single line with a zero.\nEach dataset is given in the following format.\n\nn\na1\na2\n:\nan\n\nThe first line contains the number of visitors n (1 \u2264 n \u2264 1000000), followed by n lines containing the age ai of the i-th visitor (0 \u2264 ai \u2264 120).\n\nOutput\nOutput the number of people for each dataset in the following format.\n\n1st line: Number of people under 10 years old\n2nd line: Number of people in their teens\n3rd line: Number of people in their twenties\n4th line: Number of people in their thirties\n5th line: Number of people in their forties\n6th line: Number of people in their fifties\n7th line: Number of people aged 60 and above\n\nSample Input\n8\n71\n34\n65\n11\n41\n39\n6\n5\n4\n67\n81\n78\n65\n0\n\nOutput for the Sample Input\n2\n1\n0\n2\n1\n0\n2\n0\n0\n0\n0\n0\n0\n4", "before_after_length": [188, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00184", "p_user": "u812047151", "n_user": "u812047151", "pos": "while True:\n\tn = int(input())\n\tif n == 0: break\n\tans = [0 for _ in range(7)]\n\tfor _ in range(n):\n\t\tage = int(input())\n\t\tif age < 10:\n\t\t\tans[0] += 1\n\t\telif age < 20:\n\t\t\tans[1] += 1\n\t\telif age < 30:\n\t\t\tans[2] += 1\n\t\telif age < 40:\n\t\t\tans[3] += 1\n\t\telif age < 50:\n\t\t\tans[4] += 1\n\t\telif age < 60:\n\t\t\tans[5] += 1\n\t\telse:\n\t\t\tans[6] += 1\n\tfor a in ans:\n\t\tprint(a)", "neg": "while True:\n\tn = int(input())\n\tans = [0 for _ in range(7)]\n\tfor _ in range(n):\n\t\tage = int(input())\n\t\tif age < 10:\n\t\t\tans[0] += 1\n\t\telif age < 20:\n\t\t\tans[1] += 1\n\t\telif age < 30:\n\t\t\tans[2] += 1\n\t\telif age < 40:\n\t\t\tans[3] += 1\n\t\telif age < 50:\n\t\t\tans[4] += 1\n\t\telif age < 60:\n\t\t\tans[5] += 1\n\t\telse:\n\t\t\tans[6] += 1\n\tfor a in ans:\n\t\tprint(a)", "jacc_sim": 0.9743589743589743, "nl": "Title: \u9db4\u30f6\u57ce\n\nThe symbol of Aizuwakamatsu City, Tsurugajo Castle, was built by Gamo Ujisato with a full-fledged castle tower and named \"Tsurugajo Castle.\" The Aizu Basin can be seen from the castle tower. On clear days, visitors can see Tsurugajo Castle from the mountaintop of Iimoriyama, famous for the Byakkotai.\n\nFor future public relations activities in Aizuwakamatsu City, a survey of the ages of visitors to Tsurugajo Castle has been decided. Create a program that takes the age of visitors as input and outputs the number of people in the following age groups for reference.\n\nInput\nMultiple datasets are given as input. The end of the input is indicated by a single line with a zero.\nEach dataset is given in the following format.\n\nn\na1\na2\n:\nan\n\nThe first line contains the number of visitors n (1 \u2264 n \u2264 1000000), followed by n lines containing the age ai of the i-th visitor (0 \u2264 ai \u2264 120).\n\nOutput\nOutput the number of people for each dataset in the following format.\n\n1st line: Number of people under 10 years old\n2nd line: Number of people in their teens\n3rd line: Number of people in their twenties\n4th line: Number of people in their thirties\n5th line: Number of people in their forties\n6th line: Number of people in their fifties\n7th line: Number of people aged 60 and above\n\nSample Input\n8\n71\n34\n65\n11\n41\n39\n6\n5\n4\n67\n81\n78\n65\n0\n\nOutput for the Sample Input\n2\n1\n0\n2\n1\n0\n2\n0\n0\n0\n0\n0\n0\n4", "before_after_length": [185, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00186", "p_user": "u957021183", "n_user": "u957021183", "pos": "# Aizu Problem 0186: Aizu Chicken\n#\nimport sys, math, os, bisect\n\n# read input:\nPYDEV = os.environ.get('PYDEV')\nif PYDEV==\"True\":\n sys.stdin = open(\"sample-input.txt\", \"rt\")\n\n\ndef aizu_chicken(q1, b, c1, c2, q2):\n for i in range(q2, 0, -1):\n cj = i * c1\n normal = int((b - cj) // c2)\n if i + normal < q1:\n continue\n elif normal >= 0:\n print(i, normal)\n break\n else:\n print(\"NA\")\n\n\nwhile True:\n inp = [int(_) for _ in input().split()]\n if len(inp) == 1:\n break\n q1, b, c1, c2, q2 = inp[:]\n aizu_chicken(q1, b, c1, c2, q2)", "neg": "# Aizu Problem 0186: Aizu Chicken\n#\nimport sys, math, os, bisect\n\n# read input:\nPYDEV = os.environ.get('PYDEV')\nif PYDEV==\"True\":\n sys.stdin = open(\"sample-input.txt\", \"rt\")\n\n\ndef aizu_chicken(q1, b, c1, c2, q2):\n for i in range(q2, 0, -1):\n cj = i * c1\n normal = int((b - cj) / c2)\n if i + normal < q1:\n continue\n elif normal >= 0:\n print(i, normal)\n break\n else:\n print(\"NA\")\n\n\nwhile True:\n inp = [int(_) for _ in input().split()]\n if len(inp) == 1:\n break\n q1, b, c1, c2, q2 = inp[:]\n aizu_chicken(q1, b, c1, c2, q2)", "jacc_sim": 1.0, "nl": "Title: \u4f1a\u6d25\u5730\u9d8f\n\nIn April 2008, Aizuwakamatsu City successfully attempted to make a 20.85-meter-long yakitori. The chicken used at that time was Aizu local chicken, known for its delicious taste but limited production and high price due to the difficulty of breeding. Today, Ichiro's relatives are visiting, and his mother plans to treat them with chicken hot pot. She instructs Ichiro to buy chicken from a nearby butcher shop, with specific guidelines:\n\n1. Buy more than the specified amount of chicken to avoid running out.\n2. Purchase as much Aizu local chicken as possible within the budget (must buy Aizu local chicken).\n3. Buy as much regular chicken as possible with the remaining amount after purchasing Aizu local chicken (if budget allows).\n\nWhen Ichiro visits the butcher shop, he finds that there is a limit on the amount of Aizu local chicken one person can buy due to its scarcity. Given the minimum amount of chicken to buy (q1), budget (b), price of Aizu local chicken per 100 grams (c1), price of regular chicken per 100 grams (c2), and the limit on the amount of Aizu local chicken one person can buy (q2), create a program to output the amounts of Aizu local chicken and regular chicken Ichiro should buy in 100-gram units. If Ichiro cannot buy according to his mother's instructions, output \"NA\".\n\nInput:\nMultiple datasets are provided until a single zero is given to indicate the end of input. Each dataset is in the format:\nq1 b c1 c2 q2\n\nThe chicken amounts q1 and q2 are specified in 100-gram units. Additionally, b, c1, c2, q1, and q2 are integers between 1 and 1,000,000.\n\nNo more than 50 datasets are provided.\n\nOutput:\nFor each dataset, output the amount of Aizu local chicken and regular chicken Ichiro should purchase (separated by a space) or \"NA\" on a single line.\n\nSample Input:\n(Provided in the original problem)\n\nOutput for the Sample Input:\n(Provided in the original problem)", "before_after_length": [251, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00189", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189\nAC\n\"\"\"\nimport sys\nfrom sys import stdin\ninput = stdin.readline\n\n\ndef warshallFloyd(V, dp):\n for k in range(V):\n for i in range(V):\n for j in range(V):\n dp_ik = dp[i][k]\n dp_kj = dp[k][j]\n if dp[i][j] > dp_ik + dp_kj:\n dp[i][j] = dp_ik + dp_kj\n\n\ndef main(args):\n while True:\n n_max = 9+1\n n = int(input())\n if n == 0:\n break\n dp = [[float('inf')] * n_max for _ in range(n_max)]\n for i in range(n_max):\n dp[i][i] = 0\n\n max_town = 0\n for _ in range(n):\n a, b, c = map(int, input().split())\n dp[a][b] = c\n dp[b][a] = c\n if a > max_town:\n max_town = a\n if b > max_town:\n max_town = b\n\n warshallFloyd(max_town + 1, dp)\n\n\n min_dist = float('inf')\n town_live = -1\n for i, d in enumerate(dp[:max_town+1]):\n sum_dist = sum(d[:max_town+1])\n if sum_dist < min_dist:\n min_dist = sum_dist\n town_live = i\n\n print('{} {}'.format(town_live, min_dist))\n\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])\n ", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189\nAC\n\"\"\"\nimport sys\nfrom sys import stdin\ninput = stdin.readline\n\n\ndef warshallFloyd(V, dp):\n for k in range(V):\n for i in range(V):\n for j in range(V):\n dp_ik = dp[i][k]\n dp_kj = dp[k][j]\n if dp[i][j] < dp_ik + dp_kj:\n dp[i][j] = dp_ik + dp_kj\n\n\ndef main(args):\n while True:\n n_max = 9+1\n n = int(input())\n if n == 0:\n break\n dp = [[float('inf')] * n_max for _ in range(n_max)]\n for i in range(n_max):\n dp[i][i] = 0\n\n max_town = 0\n for _ in range(n):\n a, b, c = map(int, input().split())\n dp[a][b] = c\n dp[b][a] = c\n max_town = max(max_town, a, b)\n\n warshallFloyd(max_town + 1, dp)\n\n\n min_dist = float('inf')\n town_live = -1\n for i, d in enumerate(dp[:max_town+1]):\n sum_dist = 0\n for ele in d[:max_town+1]:\n sum_dist += ele\n if sum_dist < min_dist:\n min_dist = sum_dist\n town_live = i\n\n print('{} {}'.format(town_live, min_dist))\n\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])\n ", "jacc_sim": 0.9540229885057471, "nl": "Title: Convenient Town\n\nA graduate, A, plans to move for a new job. The company has offices in several towns, and A needs to find the most convenient town to live in, considering commuting times to different offices. Given town numbers and commuting times between them, find the town with the shortest total commuting time. If multiple towns have the same minimum total commuting time, output the town with the smallest number. Town count is at most 10, and road count is at most 45. All roads are bidirectional, and commuting times are the same in both directions. There is a path from any town to any other town.\n\nInput:\nMultiple datasets are given. Each dataset has the format:\nn\na1 b1 c1\na2 b2 c2\n...\nan bn cn\n\nOutput:\nFor each dataset, output the town number with the minimum total commuting time and the corresponding total commuting time.\n\nSample Input:\n6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 60\n1 4 90\n2\n0 1 1\n1 2 1\n0\n\nOutput for the Sample Input:\n2 240\n1 2", "before_after_length": [478, 473], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00189", "p_user": "u798803522", "n_user": "u798803522", "pos": "import sys\nfrom sys import stdin\ninput = stdin.readline\n\nroad = int(input())\nwhile road > 0:\n answer = [[float(\"inf\") if n != m else 0 for n in range(10)] for m in range(10)]\n city = 0\n for _ in range(road):\n c1, c2, w = (int(n) for n in input().split(\" \"))\n answer[c1][c2] = w\n answer[c2][c1] = w\n city = max(city, c1, c2)\n city += 1\n for i in range(city):\n for j in range(city):\n for k in range(city):\n answer[j][k] = min(answer[j][k], answer[j][i] + answer[i][k])\n sum_ans = [-1 , float(\"inf\")]\n for i in range(city):\n if sum(answer[i][:city]) < sum_ans[1]:\n sum_ans = [i, sum(answer[i][:city])]\n print(*sum_ans)\n road = int(input())", "neg": "road = int(input())\nwhile road > 0:\n answer = [[float(\"inf\") if n != m else 0 for n in range(10)] for m in range(10)]\n city = 0\n for _ in range(road):\n c1, c2, w = (int(n) for n in input().split(\" \"))\n answer[c1][c2] = w\n answer[c2][c1] = w\n city = max(city, c1, c2)\n for i in range(city):\n for j in range(city):\n for k in range(city):\n answer[j][k] = min(answer[j][k], answer[j][i] + answer[i][k])\n sum_ans = [-1 , float(\"inf\")]\n for i in range(city):\n if sum(answer[i][:city]) < sum_ans[1]:\n sum_ans = [i, sum(answer[i][:city])]\n print(*sum_ans)\n road = int(input())", "jacc_sim": 0.9019607843137255, "nl": "Title: Convenient Town\n\nA graduate, A, plans to move for a new job. The company has offices in several towns, and A needs to find the most convenient town to live in, considering commuting times to different offices. Given town numbers and commuting times between them, find the town with the shortest total commuting time. If multiple towns have the same minimum total commuting time, output the town with the smallest number. Town count is at most 10, and road count is at most 45. All roads are bidirectional, and commuting times are the same in both directions. There is a path from any town to any other town.\n\nInput:\nMultiple datasets are given. Each dataset has the format:\nn\na1 b1 c1\na2 b2 c2\n...\nan bn cn\n\nOutput:\nFor each dataset, output the town number with the minimum total commuting time and the corresponding total commuting time.\n\nSample Input:\n6\n0 1 80\n1 2 20\n0 2 60\n2 3 50\n3 4 60\n1 4 90\n2\n0 1 1\n1 2 1\n0\n\nOutput for the Sample Input:\n2 240\n1 2", "before_after_length": [274, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00196", "p_user": "u567380442", "n_user": "u567380442", "pos": "import sys\nimport operator\nf = sys.stdin\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n teams = [f.readline().split() for i in range(n)]\n \n teams = [(t[0], -t.count('0'), t.count('1'), i) for i, t in enumerate(teams)]\n \n teams.sort(key=operator.itemgetter(1,2,3))\n \n print('\\n'.join([t[0] for t in teams]))", "neg": "import sys\nf = sys.stdin\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n teams = [f.readline().split() for i in range(n)]\n \n teams = [(t[0], -t.count('0'), t.count('1'), i) for i, t in enumerate(teams)]\n \n teams.sort(key=operator.itemgetter(1,2,3))\n \n print('\\n'.join([t[0] for t in teams]))", "jacc_sim": 1.0, "nl": "Title: Baseball Tournament\n\nIn the World Baseball Classic (WBC), Japan achieved back-to-back victories! With the increasing popularity of baseball, a baseball tournament was held at Aizu Gakuen High School. In this tournament, a round-robin league was conducted to determine the rankings using the following methods:\n\n1. Teams with more wins are ranked higher.\n2. In case of equal wins, the team with fewer losses is ranked higher.\n\nCreate a program that takes input of each team's performance and outputs the team names in descending order of ranking. If teams have the same ranking, output them in the order they were input. The number of teams, n, is an integer between 2 and 10. Each team name, t, is a single alphanumeric character. The performance for each match, r, is represented by n-1 numbers, where 0 denotes a win, 1 denotes a loss, and 2 denotes a draw. Team names are unique.\n\nInput:\nMultiple datasets are provided as input until a single line with a zero is encountered. Each dataset is in the following format:\n\nn\nscore1\nscore2\n...\nscoren\n\nThe first line contains the number of teams, n (2 \u2264 n \u2264 10), followed by n lines containing the performance score of each team, scorei. Each score is in the format:\n\nt r1 r2 ... rn-1\n\nwhere t is the team name (a single alphanumeric character) and ri represents the performance of team t in each match (0, 1, or 2), separated by spaces.\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the team names in descending order of ranking.\n\nSample Input:\n6\nA 1 0 0 2 0\nB 0 0 1 1 0\nC 1 1 1 1 1\nD 1 0 0 1 2\nE 2 0 0 0 0\nF 1 1 0 2 1\n4\ng 1 1 1\nh 0 1 2\nw 0 0 0\nb 0 2 1\n0\n\nOutput for the Sample Input:\nE\nA\nB\nD\nF\nC\nw\nh\nb\ng", "before_after_length": [133, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00201", "p_user": "u567380442", "n_user": "u567380442", "pos": "def price(target, item, recipe):\n ret = []\n \n if target in recipe:\n ret.append(sum(price(r,item, recipe) for r in recipe[target]))\n if target in item:\n ret.append(item[target])\n if len(ret) == 0:\n return 0\n\n return min(ret)\n\nimport sys\nf = sys.stdin\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n item = [f.readline().split() for _ in range(n)]\n item = {name:int(price) for name, price in item}\n recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]\n recipe = {r[0]:r[2:] for r in recipe}\n print(price(f.readline().strip(), item, recipe))", "neg": "def price(target, item, recipe):\n ret = [0]\n \n if target in recipe:\n ret.append(sum(price(r,item, recipe) for r in recipe[target]))\n if target in item:\n ret.append(item[target])\n\n return min(ret)\n\nimport sys\nf = sys.stdin\n\n\nwhile True:\n n = int(f.readline())\n if n == 0:\n break\n item = [f.readline().split() for _ in range(n)]\n item = {name:int(price) for name, price in item}\n recipe = [f.readline().strip().split() for _ in range(int(f.readline()))]\n recipe = {r[0]:r[2:] for r in recipe}\n print(price(f.readline().strip(), item, recipe))", "jacc_sim": 0.9767441860465116, "nl": "Title: Alchemy Master\n\nYou have finally acquired a magical cauldron, an alchemy cauldron. By placing multiple items into the cauldron, you can create new items. The newly created items can also be placed back into the cauldron to create other items. The list of items required to create an item is referred to as an alchemy recipe. Below are three examples of alchemy recipes:\n\n1. A racket can be made with wood and string.\n2. Onigiri can be made with rice and water.\n3. A guitar can be made with a racket, a microphone, and onigiri.\n\nItems can be obtained by purchasing them with money, but it may be cheaper to create them in the alchemy cauldron. For example, if the purchase prices for each item are given as follows:\n\nItem Name | Purchase Price (Yen)\n- Wood: 3000\n- String: 800\n- Rice: 36\n- Water: 0\n- Racket: 5000\n- Microphone: 9800\n- Onigiri: 140\n- Guitar: 98000\n\nA racket can be purchased for 5000 yen, but by purchasing wood and string and using the cauldron, it can be obtained for 3800 yen. Furthermore, by stacking alchemy, items can be obtained very economically. Figure 1 combines the above three alchemy recipe examples. A guitar can be purchased for 98000 yen, but by purchasing wood, string, rice, water, and a microphone and using the cauldron, it can be obtained for just 13636 yen.\n\nYou have decided to create a program to output the minimum amount of money required to create a specified item, in order to progress through your adventure more easily. The program will take as input a list of items, a list of alchemy recipes, and the specified item, and output the minimum amount of money required to create the specified item.\n\nAssumptions:\n- The number of item types in the item list, n, is an integer between 1 and 100.\n- The price, p, for purchasing each item is between 0 and 1000000.\n- The name of each item, i, is an alphanumeric string of 1 to 100 characters.\n- The number of alchemy recipes, m, is an integer between 0 and 100.\n- Each alchemy recipe is given by the item name, o, the number of required items, k, and a list of k item names, q.\n- The quantity of each item is unlimited.\n- Each item can be used in multiple recipes, but each item has at most one recipe to create it.\n- When following a recipe, an item will not reappear in subsequent recipes.\n\nInput:\nMultiple datasets are provided as input, ending with a single line containing only zero. Each dataset is in the following format:\n- The number of item types, n (1 \u2264 n \u2264 100), followed by n lines containing the name, s_i, and purchase price, p_i, for each item.\n- The number of alchemy recipes, m (0 \u2264 m \u2264 100), followed by m lines containing the recipe information for each recipe, including the item name, o_i, the number of required items, k_i, and a list of k_i item names, q.\n- The specified item name, t.\n\nOutput:\nFor each input dataset, output the minimum price on a single line.\n\nSample Input:\n8\nwood 3000\nstring 800\nrice 36\nwater 0\nracket 5000\nmicrophone 9800\nonigiri 140\nguitar 98000\n3\nracket 2 wood string\nonigiri 2 rice water\nguitar 3 racket microphone onigiri\nguitar\n1\ncomputer 300000\n0\ncomputer\n0\n\nOutput for the Sample Input:\n13636\n300000", "before_after_length": [221, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00205", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n h = int(input())\n if h == 0:\n break\n dataset = [h] + [int(input()) for _ in range(4)]\n if len(set(dataset)) == 3 or len(set(dataset)) == 1:\n print(*[3]*5, sep=\"\\n\")\n continue\n \n for data in dataset:\n if data == 1:\n print(2 if 3 in dataset else 1)\n elif data == 2:\n print(2 if 1 in dataset else 1)\n else:\n print(2 if 2 in dataset else 1)", "neg": "while True:\n h = int(input())\n if h == 0:\n break\n dataset = [h] + [int(input()) for _ in range(4)]\n if len(set(dataset)) == 3 or len(set(dataset)) == 1:\n print(*[3]*5, sep=\"\\n\")\n for data in dataset:\n if data == 1:\n print(2 if 3 in dataset else 1)\n elif data == 2:\n print(2 if 1 in dataset else 1)\n else:\n print(2 if 2 in dataset else 1)", "jacc_sim": 0.9743589743589743, "nl": "Title: Rock-Paper-Scissors\n\nA group of 5 friends decided to play rock-paper-scissors. In this game, there are three hand signs: rock, paper, and scissors. Rock beats scissors, scissors beats paper, and paper beats rock. If all players show the same hand sign or if all three signs are shown, it's a tie.\n\nCreate a program that takes the hand signs of the 5 players as input and outputs the result of each player's match. Rock is represented by 1, scissors by 2, and paper by 3. The result is represented by 1 for win, 2 for loss, and 3 for a tie, and should be output in the order of input.\n\nInput:\nMultiple datasets are given as input, ending with a single line containing zero. Each dataset is in the format:\nh1\nh2\nh3\nh4\nh5\nwhere hi represents the hand sign (1, 2, or 3) of the i-th person.\n\nThe number of datasets does not exceed 200.\n\nOutput:\nFor each dataset, output the results of the 5 players' matches. Each line should contain the result (1, 2, or 3) for the i-th player.\n\nSample Input:\n1\n2\n3\n2\n1\n1\n2\n2\n2\n1\n0\n\nOutput for the Sample Input:\n3\n3\n3\n3\n3\n1\n2\n2\n2\n1", "before_after_length": [142, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00205", "p_user": "u032662562", "n_user": "u032662562", "pos": "# -*- coding: utf-8 -*-\n#import pdb; pdb.set_trace()\nimport sys\n\ndef solv(v):\n w = set(v)\n if len(w)==1 or len(w)==3:\n d={1:3, 2:3, 3:3}\n elif 1 in w and 2 in w:\n d={1:1, 2:2}\n elif 2 in w and 3 in w:\n d={2:1, 3:2}\n else:\n d={3:1, 1:2}\n return(list(map(lambda x:d[x], v) ))\ndef main():\n if True:\n fh = sys.stdin\n else:\n fh = open('vol2_0205.txt', 'r')\n try:\n while True:\n te = []\n for _ in range(5):\n x=int(fh.readline().strip())\n if x==0:\n raise Exception\n te.append(x)\n b=(solv(te))\n for i in b:\n print(i)\n except Exception:\n 1\n fh.close()\n \nif __name__ == '__main__':\n main()\n\n", "neg": "# -*- coding: utf-8 -*-\n#import pdb; pdb.set_trace()\nimport sys\n\ndef solv(v):\n w = set(v)\n if len(w)==1 or len(w)==3:\n d={1:2, 2:2, 3:2}\n elif 1 in w and 2 in w:\n d={1:1, 2:2}\n elif 2 in w and 3 in w:\n d={2:1, 3:2}\n else:\n d={3:1, 1:2}\n return(list(map(lambda x:d[x], v) ))\ndef main():\n if True:\n fh = sys.stdin\n else:\n fh = open('vol2_0205.txt', 'r')\n try:\n while True:\n te = []\n for _ in range(5):\n x=int(fh.readline().strip())\n if x==0:\n raise Exception\n te.append(x)\n b=(solv(te))\n for i in b:\n print(i)\n except Exception:\n 1\n fh.close()\n \nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 1.0, "nl": "Title: Rock-Paper-Scissors\n\nA group of 5 friends decided to play rock-paper-scissors. In this game, there are three hand signs: rock, paper, and scissors. Rock beats scissors, scissors beats paper, and paper beats rock. If all players show the same hand sign or if all three signs are shown, it's a tie.\n\nCreate a program that takes the hand signs of the 5 players as input and outputs the result of each player's match. Rock is represented by 1, scissors by 2, and paper by 3. The result is represented by 1 for win, 2 for loss, and 3 for a tie, and should be output in the order of input.\n\nInput:\nMultiple datasets are given as input, ending with a single line containing zero. Each dataset is in the format:\nh1\nh2\nh3\nh4\nh5\nwhere hi represents the hand sign (1, 2, or 3) of the i-th person.\n\nThe number of datasets does not exceed 200.\n\nOutput:\nFor each dataset, output the results of the 5 players' matches. Each line should contain the result (1, 2, or 3) for the i-th player.\n\nSample Input:\n1\n2\n3\n2\n1\n1\n2\n2\n2\n1\n0\n\nOutput for the Sample Input:\n3\n3\n3\n3\n3\n1\n2\n2\n2\n1", "before_after_length": [302, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00205", "p_user": "u847467233", "n_user": "u847467233", "pos": "# AOJ 0205: Rock, Paper, Scissors\n# Python3 2018.6.25 bal4u\n\nh = [0]*5\nwhile True:\n\ttry:\n\t\tfor i in range(5): h[i] = int(input())\n\texcept: break\n\tif len(set(h)) == 1 or len(set(h)) == 3:\n\t\tprint(*[3]*5, sep='\\n')\n\t\tcontinue\n\tans = [1]*5\n\tfor i in range(5):\n\t\tif h[i] == 1: ans[i] += (h.count(3) > 0)\n\t\telif h[i] == 2: ans[i] += (h.count(1) > 0)\n\t\telse: ans[i] += (h.count(2) > 0)\n\tprint(*ans, sep='\\n')\n", "neg": "# AOJ 0205: Rock, Paper, Scissors\n# Python3 2018.6.25 bal4u\n\nh = [0]*5\nwhile True:\n\ttry:\n\t\tfor i in range(5): h[i] = int(input())\n\texcept: break\n\tprint(type(h), h)\n\tif len(set(h)) == 1 or len(set(h)) == 3:\n\t\tprint(*[3]*5, sep='\\n')\n\t\tcontinue\n\tans = [1]*5\n\tfor i in range(5):\n\t\tif h[i] == 1: ans[i] += (h.count(3) > 0)\n\t\telif h[i] == 2: ans[i] += (h.count(1) > 0)\n\t\telse: ans[i] += (h.count(2) > 0)\n\tprint(*ans, sep='\\n')\n", "jacc_sim": 0.9814814814814815, "nl": "Title: Rock-Paper-Scissors\n\nA group of 5 friends decided to play rock-paper-scissors. In this game, there are three hand signs: rock, paper, and scissors. Rock beats scissors, scissors beats paper, and paper beats rock. If all players show the same hand sign or if all three signs are shown, it's a tie.\n\nCreate a program that takes the hand signs of the 5 players as input and outputs the result of each player's match. Rock is represented by 1, scissors by 2, and paper by 3. The result is represented by 1 for win, 2 for loss, and 3 for a tie, and should be output in the order of input.\n\nInput:\nMultiple datasets are given as input, ending with a single line containing zero. Each dataset is in the format:\nh1\nh2\nh3\nh4\nh5\nwhere hi represents the hand sign (1, 2, or 3) of the i-th person.\n\nThe number of datasets does not exceed 200.\n\nOutput:\nFor each dataset, output the results of the 5 players' matches. Each line should contain the result (1, 2, or 3) for the i-th player.\n\nSample Input:\n1\n2\n3\n2\n1\n1\n2\n2\n2\n1\n0\n\nOutput for the Sample Input:\n3\n3\n3\n3\n3\n1\n2\n2\n2\n1", "before_after_length": [212, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00206", "p_user": "u755162050", "n_user": "u755162050", "pos": "\ndef algorithm():\n while True:\n budget = int(input())\n if budget == 0:\n break\n\n total, months = 0, 0\n for _ in range(12):\n income, outcome = map(int, input().split())\n total += income - outcome\n if total >= budget and months == 0:\n months = _ + 1\n\n print('NA' if total < budget else months)\n\n\ndef main():\n algorithm()\n\n\nif __name__ == '__main__':\n main()", "neg": "def alogrithm():\n while True:\n budget = int(input())\n if budget == 0:\n break\n\n total = 0\n months = 0\n for _ in range(12):\n income, outcome = map(int, input().split())\n total += income - outcome\n months += 1 if income > outcome else 0\n\n if total < budget:\n print('NA')\n else:\n print(months)\n\n\ndef main():\n alogrithm()\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.926829268292683, "nl": "Title: When is the Trip?\n\nYou are considering going on a trip with a friend. However, your friend, who has a habit of overspending, struggles to save up for the trip. If your friend continues their current lifestyle, it's uncertain when the trip will happen. To expedite the trip, you decide to create a program to help your friend save systematically.\n\nGiven the allowance for a specific month as M yen and the amount spent in that month as N yen, the savings for that month will be (M - N) yen. Create a program that takes the monthly income and expenses (M, N) as input and outputs the number of months it will take for the savings to reach the travel cost L. If the savings do not reach the travel cost even after 12 months, output \"NA\".\n\nInput:\nMultiple datasets are provided as input until a single zero is encountered.\nEach dataset is in the following format:\nL\nM1 N1\nM2 N2\n...\nM12 N12\n\nThe first line contains the travel cost L (1 \u2264 L \u2264 1000000, integer). The subsequent 12 lines contain the income and expense information for the i-th month, M_i, N_i (0 \u2264 M_i, N_i \u2264 100000, N_i \u2264 M_i, integers).\n\nThe number of datasets does not exceed 1000.\n\nOutput:\nFor each input dataset, output the number of months it will take for the savings to reach the travel cost on a single line.\n\nSample Input:\n10000\n5000 3150\n5000 5000\n0 0\n5000 1050\n5000 3980\n5000 210\n5000 5000\n5000 5000\n0 0\n5000 2100\n5000 2100\n5000 2100\n29170\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 70831\n0\n\nOutput for the Sample Input:\n6\nNA", "before_after_length": [127, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00206", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n L= int(input())\n if L== 0: break\n mn= [list(map(int, input().split())) for _ in range(12)]\n ans=c=0\n b= True\n for m, n in mn:\n ans+= m-n\n c+= 1\n if ans>= L:\n print(c)\n b= False\n break\n if b: print(\"NA\")", "neg": "while True:\n L= int(input())\n if L== 0: break\n mn= [list(map(int, input().split())) for _ in range(12)]\n ans=c=1\n b= True\n for m, n in mn:\n ans+= m-n\n if ans>= L:\n print(c)\n b= False\n break\n c+= 1\n if b: print(\"NA\")", "jacc_sim": 1.0, "nl": "Title: When is the Trip?\n\nYou are considering going on a trip with a friend. However, your friend, who has a habit of overspending, struggles to save up for the trip. If your friend continues their current lifestyle, it's uncertain when the trip will happen. To expedite the trip, you decide to create a program to help your friend save systematically.\n\nGiven the allowance for a specific month as M yen and the amount spent in that month as N yen, the savings for that month will be (M - N) yen. Create a program that takes the monthly income and expenses (M, N) as input and outputs the number of months it will take for the savings to reach the travel cost L. If the savings do not reach the travel cost even after 12 months, output \"NA\".\n\nInput:\nMultiple datasets are provided as input until a single zero is encountered.\nEach dataset is in the following format:\nL\nM1 N1\nM2 N2\n...\nM12 N12\n\nThe first line contains the travel cost L (1 \u2264 L \u2264 1000000, integer). The subsequent 12 lines contain the income and expense information for the i-th month, M_i, N_i (0 \u2264 M_i, N_i \u2264 100000, N_i \u2264 M_i, integers).\n\nThe number of datasets does not exceed 1000.\n\nOutput:\nFor each input dataset, output the number of months it will take for the savings to reach the travel cost on a single line.\n\nSample Input:\n10000\n5000 3150\n5000 5000\n0 0\n5000 1050\n5000 3980\n5000 210\n5000 5000\n5000 5000\n0 0\n5000 2100\n5000 2100\n5000 2100\n29170\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 70831\n0\n\nOutput for the Sample Input:\n6\nNA", "before_after_length": [108, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00208", "p_user": "u531592024", "n_user": "u531592024", "pos": "def ge(arr):\n for i in range(len(arr)):\n tmp = int(arr[i])\n if tmp >= 4:\n tmp += 1\n if tmp >= 6:\n tmp += 1\n arr[i] = str(tmp)\n return arr\n\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n print(\"\".join(ge(list(oct(n))[2:])))\n\n", "neg": "def ge(arr):\n for i in range(len(arr)):\n tmp = int(arr[i])\n if tmp >= 4:\n tmp += 1\n if tmp >= 6:\n tmp += 1\n arr[i] = str(tmp)\n\n\nwhile True:\n n = int(input)\n if n == 0:\n break\n print(\"\".join(ge(list(oct(n))[2:])))\n", "jacc_sim": 0.972972972972973, "nl": "Title: Hospital Room Numbers\n\nIn the town of Waterdeben, architect Mr. Debenkey received a request to renovate an old hospital. Some people dislike using certain numbers as room numbers due to superstitions (in Japan, 4 and 9 are famous examples). However, the hospital's room numbers were assigned sequentially from 1, regardless of superstitions.\n\nMr. Debenkey, concerned about superstitions in Waterdeben, renumbered the rooms excluding the unlucky numbers 4 and 6 before the equipment and bed rearrangement was completed. However, the remaining tasks were planned using the old room numbers, so it's necessary to convert the old room numbers to the new ones. Mr. Debenkey, not good at calculations, is dismayed by this realization.\n\nFor Mr. Debenkey's sake, create a program that takes the old room number as input and outputs the corresponding new room number.\n\nThe table for the first 15 room numbers is as follows:\n\nOld Room Number: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\nNew Room Number: 1 2 3 5 7 8 9 10 11 12 13 15 17 18 19\n\nInput:\nMultiple datasets are given as input. The end of input is indicated by a single line containing zero. Each dataset consists of an integer n (1 \u2264 n \u2264 1,000,000,000) representing the old room number.\n\nThe number of datasets does not exceed 30,000.\n\nOutput:\nFor each input dataset, output the new room number on a single line.\n\nSample Input:\n15\n100\n1000000000\n3\n0\n\nOutput for the Sample Input:\n19\n155\n9358757000\n3", "before_after_length": [111, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00212", "p_user": "u319725914", "n_user": "u319725914", "pos": "from sys import stdin\nfrom heapq import heappush,heappop\n\nwhile(True):\n c,n,m,s,d = map(int, stdin.readline().split())\n if not c: break\n ma = [[] for _ in range(n)]\n s -= 1\n d -= 1\n for _ in range(m):\n a,b,f = map(int, stdin.readline().split())\n a -= 1\n b -= 1\n ma[a].append([f,b])\n ma[b].append([f,a])\n cost = [[10**10]*(c+1) for _ in range(n)]\n cost[s][c] = 0\n que = [[ cost[s][c], s, c ]]\n while que:\n co, pl, ti = heappop(que)\n for fee, town in ma[pl]:\n if cost[town][ti] > co+fee:\n cost[town][ti] = co+fee\n heappush(que,[cost[town][ti],town,ti])\n if ti and cost[town][ti-1] > co+fee//2:\n cost[town][ti-1] = co+fee//2\n heappush(que,[cost[town][ti-1],town,ti-1])\n print(min(cost[d]))\n", "neg": "from sys import stdin\nfrom heapq import heappush,heappop\n\nwhile(True):\n c,n,m,s,d = map(int, stdin.readline().split())\n if not c: break\n ma = [[] for _ in range(n)]\n s -= 1\n d -= 1\n for _ in range(m):\n a,b,f = map(int, stdin.readline().split())\n a -= 1\n b -= 1\n ma[a].append([f,b])\n ma[b].append([f,a])\n cost = [[10**10]*(c+1) for _ in range(n)]\n cost[s][c] = 0\n que = [[ cost[s][c], s, c ]]\n while que:\n co, pl, ti = heappop(que)\n for fee, town in ma[pl]:\n if cost[town][ti] > co + fee:\n cost[town][ti] = co+fee\n heappush(que,[cost[town][ti],town,ti])\n if ti and cost[town][ti-1] > co+fee:\n cost[town][ti-1] = co + fee//2\n heappush(que,[cost[town][ti-1],town,ti-1])\n print(min(ma[d])[0])\n", "jacc_sim": 1.0, "nl": "Title: Highway Bus\n\nA is planning a solo trip using a highway bus during high school break. A has chosen a destination and needs to determine the route to take from the departure point to the destination. A has received some discount tickets from a relative. Each ticket allows purchasing one bus ticket at half price. A wants to minimize transportation costs to allocate more money for sightseeing. A needs a program to find the cheapest transportation cost from the departure point to the destination.\n\nInput:\nMultiple datasets are provided. The end of input is indicated by five zeros.\nEach dataset is in the following format:\nc n m s d\na1 b1 f1\na2 b2 f2\n...\nam bm fm\n\nThe first line contains the number of discount tickets c (1 \u2264 c \u2264 10), the number of towns connected by buses n (2 \u2264 n \u2264 100), the number of bus routes m (1 \u2264 m \u2264 500), the departure town number s, and the destination town number d (s \u2260 d).\nThe next m lines contain the route information for each bus: ai bi fi (1 \u2264 ai, bi \u2264 n, 1000 \u2264 fi \u2264 10000), where ai and bi are the start and end town numbers of the bus route, and fi is the fare for this route in increments of 100.\n\nThe number of datasets does not exceed 100.\n\nOutput:\nFor each input dataset, output the cheapest transportation cost on a single line.\n\nSample Input:\n1 3 3 1 3\n1 3 2000\n1 2 1000\n2 3 1000\n2 3 3 1 3\n1 3 2300\n1 2 1000\n2 3 1200\n2 6 6 5 1\n1 2 1500\n1 3 4500\n2 6 2000\n5 4 1000\n6 4 2200\n3 5 3000\n0 0 0 0 0\n\nOutput for the Sample Input:\n1000\n1100\n3750", "before_after_length": [330, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00218", "p_user": "u433250944", "n_user": "u814278309", "pos": "while True:\n n = int(input())\n if n==0: break\n\n for i in range(n):\n m,e,j = map(int,input().split())\n if (m==100 or e==100 or j ==100) or ((m+e)/2 >= 90) or ((m+e+j)/3 >=80):\n print(\"A\")\n elif((m+e+j)/3 >=70) or (((m+e+j)/3>=50) and (m>=80 or e>=80)):\n print(\"B\")\n else:\n print(\"C\")\n", "neg": "n=int(input())\nwhile True:\n if n==0:\n break\n for i in range(n):\n m,e,j=map(int,input().split())\n if m==100 or e==100 or j==100:\n print('{}'.format('A'))\n elif (m+e)/2>=90:\n print('{}'.format('A'))\n elif (m+e+j)/3>=80:\n print('{}'.format('A'))\n elif (m+e+j)/3>=70:\n print('{}'.format('B'))\n elif (m+e+j)/3>=50:\n if m>=80 or e>=80:\n print('{}'.format('B'))\n else:\n print('{}'.format('C'))\n else:\n print('{}'.format('C'))\n", "jacc_sim": 0.9111111111111111, "nl": "Title: Class Assignment\n\nAt Aizu Academy, students take proficiency tests in math, English, and Japanese upon entering the academy to determine their class assignment (A, B, or C). Class A represents the highest level, followed by B and then C.\n\nThe class assignment is based on the following criteria:\n\n- If a subject has a score of 100, the student is assigned to class A.\n- If the average score of math and English is 90 or above, the student is assigned to class A.\n- If the average score of all three subjects is 80 or above, the student is assigned to class A.\n- If the average score of all three subjects is 70 or above, the student is assigned to class B.\n- If the average score of all three subjects is 50 or above and either math or English has a score of 80 or above, the student is assigned to class B.\n- If none of the above conditions are met, the student is assigned to class C.\n\nIn cases where multiple conditions are met, the student is assigned to the higher-level class.\n\nThe program should take as input the number of students (n) (1 \u2264 n \u2264 10000), the math scores (pm_i), English scores (pe_i), and Japanese scores (pj_i) for each student (0 \u2264 pm_i, pe_i, pj_i \u2264 100), and output the class assignment (A, B, or C) for each student.\n\nInput:\nMultiple datasets are provided as input, with a single line containing a single zero indicating the end of the input. Each dataset is in the following format:\nn\npm_1 pe_1 pj_1\npm_2 pe_2 pj_2\n...\npm_n pe_n pj_n\n\nAll input values are integers, and the number of datasets does not exceed 1000.\n\nOutput:\nFor each input dataset, output the class assignment for each student in order.\n\nSample Input:\n4\n100 70 20\n98 86 55\n80 34 36\n65 79 65\n2\n99 81 20\n66 72 90\n0\n\nOutput for the Sample Input:\nA\nA\nB\nC\nA\nB", "before_after_length": [147, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00219", "p_user": "u814278309", "n_user": "u814278309", "pos": "while True:\n n=int(input())\n x=[0 for i in range(10)]\n if n==0:\n break\n for i in range(n):\n a=int(input())\n if a==0:\n x[0]+=1\n elif a==1:\n x[1]+=1\n elif a==2:\n x[2]+=1\n elif a==3:\n x[3]+=1\n elif a==4:\n x[4]+=1\n elif a==5:\n x[5]+=1 \n elif a==6:\n x[6]+=1\n elif a==7:\n x[7]+=1\n elif a==8:\n x[8]+=1\n else:\n x[9]+=1\n for i in range(10):\n if x[i]==0:\n print('{}'.format('-')) \n else:\n print('{}'.format(x[i]*'*'))\n", "neg": "n=int(input())\nx=[0 for i in range(10)]\nwhile True:\n if n==0:\n break\n for i in range(n):\n a=int(input())\n if a==0:\n x[0]+=1\n elif a==1:\n x[1]+=1\n elif a==2:\n x[2]+=1\n elif a==3:\n x[3]+=1\n elif a==4:\n x[4]+=1\n elif a==5:\n x[5]+=1 \n elif a==6:\n x[6]+=1\n elif a==7:\n x[7]+=1\n elif a==8:\n x[8]+=1\n else:\n x[9]+=1\n for i in range(10):\n if x[i]==0:\n print('{}'.format('-')) \n else:\n print('{}'.format(x[i]*'*'))\n", "jacc_sim": 1.0, "nl": "Title: Histogram\n\nTenA Ice Cream is a shop that always displays 10 types of ice cream. The manager creates a graph daily to track the sales of each ice cream for product development reference.\n\nYou are tasked with creating a program to display the sales of each ice cream as a graph for the manager. The input consists of the total number of ice creams sold in a day and the numbers of the sold ice creams. Create a program to output the number of sales for each type of ice cream using asterisks (*), and a hyphen (-) for types with zero sales. Ice cream types are represented by integers from 0 to 9.\n\nInput:\nMultiple datasets are provided as input until a single zero is encountered at the end. Each dataset is in the following format:\nn\nc1\nc2\n...\ncn\nWhere n (1 \u2264 n \u2264 10000) represents the total number of ice creams sold in a day, and the following n lines represent the type ci (0 \u2264 ci \u2264 9) of the ice creams sold.\n\nThe number of datasets does not exceed 20.\n\nOutput:\nFor each input dataset, output the sales count for each type of ice cream in ascending order of their numbers.\n\nSample Input:\n15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n\nOutput for the Sample Input:\n*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*", "before_after_length": [246, 244], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00219", "p_user": "u350508326", "n_user": "u350508326", "pos": "#!/usr/bin/env python3\n\nwhile True:\n n = int(input())\n data = [0] * 10\n if n == 0:\n break\n\n for _ in range(n):\n in_data = int(input())\n data[in_data] += 1\n\n for d in data:\n if d == 0:\n print(\"-\")\n else:\n print(\"*\" * d)", "neg": "#!/usr/bin/env python3\n\nwhile True:\n n = int(input())\n data = [0] * 10\n if n == 0:\n break\n\n for _ in range(n):\n in_data = int(input())\n data[in_data - 1] += 1\n\n for d in data:\n for _ in range(d):\n print(\"*\", end=\"\")\n\n if d == 0:\n print(\"-\")\n else:\n print(end=\"\\n\")", "jacc_sim": 0.9230769230769231, "nl": "Title: Histogram\n\nTenA Ice Cream is a shop that always displays 10 types of ice cream. The manager creates a graph daily to track the sales of each ice cream for product development reference.\n\nYou are tasked with creating a program to display the sales of each ice cream as a graph for the manager. The input consists of the total number of ice creams sold in a day and the numbers of the sold ice creams. Create a program to output the number of sales for each type of ice cream using asterisks (*), and a hyphen (-) for types with zero sales. Ice cream types are represented by integers from 0 to 9.\n\nInput:\nMultiple datasets are provided as input until a single zero is encountered at the end. Each dataset is in the following format:\nn\nc1\nc2\n...\ncn\nWhere n (1 \u2264 n \u2264 10000) represents the total number of ice creams sold in a day, and the following n lines represent the type ci (0 \u2264 ci \u2264 9) of the ice creams sold.\n\nThe number of datasets does not exceed 20.\n\nOutput:\nFor each input dataset, output the sales count for each type of ice cream in ascending order of their numbers.\n\nSample Input:\n15\n2\n6\n7\n0\n1\n9\n8\n7\n3\n8\n9\n4\n8\n2\n2\n3\n9\n1\n5\n0\n\nOutput for the Sample Input:\n*\n*\n***\n*\n*\n-\n*\n**\n***\n**\n-\n*\n-\n-\n-\n*\n-\n-\n-\n*", "before_after_length": [105, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00221", "p_user": "u766477342", "n_user": "u766477342", "pos": "def fizz_buzz():\n c = 1\n while True:\n res = ''\n if c % 3 == 0:\n res = res + 'Fizz'\n if c % 5 == 0:\n res = res + 'Buzz'\n if res == '':\n yield str(c)\n else:\n yield res\n c += 1\n\nwhile True:\n m,n = map(int,input().split())\n if m == 0: break\n\n player = list(range(m))\n\n p = 0\n fb = fizz_buzz()\n for i in range(n):\n inp = input()\n if len(player) > 1:\n if inp != next(fb):\n del player[p] \n p = p % len(player)\n else:\n p = (p+1) % len(player)\n\n result = str(player[0]+1)\n if len(player) > 1:\n for pi in player[1:]:\n result += ' ' + str(pi+1)\n\n print(result)", "neg": "def fizz_buzz():\n c = 1\n while True:\n res = ''\n if c % 3 == 0:\n res = res + 'Fizz'\n if c % 5 == 0:\n res = res + 'Buzz'\n if res == '':\n yield str(c)\n else:\n yield res\n c += 1\n\nwhile True:\n m,n = map(int,input().split())\n if m == 0: break\n\n player = list(range(m))\n\n p = 0\n fb = fizz_buzz()\n for i in range(n):\n inp = input()\n if len(player) > 1:\n if inp != next(fb):\n del player[p] \n else:\n p = (p+1) % len(player)\n\n print(result)", "jacc_sim": 0.9803921568627451, "nl": "Title: FizzBuzz\n\nThere is a game using numbers called \"Fizz Buzz\". In this game, multiple players count up numbers one by one from 1, and each player says only the next number spoken by the previous player. If the number is divisible by 3, the player says \"Fizz\", if it's divisible by 5, the player says \"Buzz\", and if it's divisible by both, the player says \"FizzBuzz\" instead of the number. For example, the first 16 statements are as follows:\n\n1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, ...\n\nTaro and his friends decided to play \"Fizz Buzz\" with the following rule: \"The person who makes a mistake is eliminated. The next person starts from the number after the mistaken one. For example, if 1, 2, 3 are spoken, the next number should be 4 since 3 was a mistake.\"\n\nYou are tasked to create a program that outputs the remaining player at the end of the specified number of statements, so that Taro and his friends can enjoy the game. The program should take the number of players, the number of statements made during the game, and the input statements, and output the numbers of the remaining players in ascending order. The players are numbered from 1, and the statements are made in order, starting from the first player. If it's the turn of a player who has already been eliminated, the next player speaks. The program should stop considering further statements once only one player remains.\n\nInput:\nMultiple datasets are given as input, and the end of the input is indicated by two consecutive zeros. Each dataset is in the following format:\n\nm n\ns1\ns2\n...\nsn\n\nThe first line contains the number of players m (2 \u2264 m \u2264 1000) and the number of statements n (1 \u2264 n \u2264 10000). The following n lines contain the i-th statement si. si is an integer, \"Fizz\", \"Buzz\", or \"FizzBuzz\" (up to 8 characters).\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each input dataset, output the numbers of the remaining players in ascending order at the specified number of statements.\n\nSample Input:\n5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0\n\nOutput for the Sample Input:\n2 3 4 5\n1", "before_after_length": [264, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00221", "p_user": "u567380442", "n_user": "u567380442", "pos": "def fizzbuzz(i):\n if i % 15 == 0:\n return 'FizzBuzz'\n elif i % 5 == 0:\n return 'Buzz'\n elif i % 3 == 0:\n return 'Fizz'\n else:\n return str(i)\n\nimport sys\nf = sys.stdin\n\n\nwhile True:\n m, n = map(int, f.readline().split())\n if m == n == 0:\n break\n member = list(range(1, m + 1))\n s = [f.readline().strip() for _ in range(n)]\n\n pos = 0\n for i in range(n):\n if s[i] != fizzbuzz(i + 1):\n del member[pos]\n m = len(member)\n if m == 1:\n break\n else:\n pos += 1\n pos %= m\n \n print(*member)", "neg": "def fizzbuzz(i):\n if i % 15 == 0:\n return 'FizzBuzz'\n elif i % 5 == 0:\n return 'Buzz'\n elif i % 3 == 0:\n return 'Fizz'\n else:\n return str(i)\n\nimport sys\nf = sys.stdin\n\nwhile True:\n m, n = map(int, f.readline().split())\n if m == n == 0:\n break\n member = list(range(1, m + 1))\n s = [f.readline().strip() for _ in range(n)]\n offset = 0\n for i in range(n):\n print(s[i]==fizzbuzz(i+1),offset,m)\n if s[i] != fizzbuzz(i + 1):\n pos = (i - offset) % m\n member.remove(member[pos])\n offset = i - pos + 1\n m -= 1\n if len(member) == 1:\n break\n \n print(*member)", "jacc_sim": 0.9285714285714286, "nl": "Title: FizzBuzz\n\nThere is a game using numbers called \"Fizz Buzz\". In this game, multiple players count up numbers one by one from 1, and each player says only the next number spoken by the previous player. If the number is divisible by 3, the player says \"Fizz\", if it's divisible by 5, the player says \"Buzz\", and if it's divisible by both, the player says \"FizzBuzz\" instead of the number. For example, the first 16 statements are as follows:\n\n1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, ...\n\nTaro and his friends decided to play \"Fizz Buzz\" with the following rule: \"The person who makes a mistake is eliminated. The next person starts from the number after the mistaken one. For example, if 1, 2, 3 are spoken, the next number should be 4 since 3 was a mistake.\"\n\nYou are tasked to create a program that outputs the remaining player at the end of the specified number of statements, so that Taro and his friends can enjoy the game. The program should take the number of players, the number of statements made during the game, and the input statements, and output the numbers of the remaining players in ascending order. The players are numbered from 1, and the statements are made in order, starting from the first player. If it's the turn of a player who has already been eliminated, the next player speaks. The program should stop considering further statements once only one player remains.\n\nInput:\nMultiple datasets are given as input, and the end of the input is indicated by two consecutive zeros. Each dataset is in the following format:\n\nm n\ns1\ns2\n...\nsn\n\nThe first line contains the number of players m (2 \u2264 m \u2264 1000) and the number of statements n (1 \u2264 n \u2264 10000). The following n lines contain the i-th statement si. si is an integer, \"Fizz\", \"Buzz\", or \"FizzBuzz\" (up to 8 characters).\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each input dataset, output the numbers of the remaining players in ascending order at the specified number of statements.\n\nSample Input:\n5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0\n\nOutput for the Sample Input:\n2 3 4 5\n1", "before_after_length": [226, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00221", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221\n\n\"\"\"\nimport sys\nfrom sys import stdin\nfrom collections import deque\ninput = stdin.readline\n\n\ndef fb_gen(count=1):\n while True:\n if count % 15 == 0:\n ans = 'FizzBuzz'\n elif count % 5 == 0:\n ans = 'Buzz'\n elif count % 3 == 0:\n ans = 'Fizz'\n else:\n ans = str(count)\n yield ans\n count += 1\n\n\ndef main(args):\n while True:\n m, n = map(int, input().split())\n if m == 0 and n == 0:\n break\n players = deque(range(1, m+1))\n fb = fb_gen()\n ok_count = 0\n for _ in range(n):\n p = input().strip()\n if p != fb.__next__():\n if len(players) > 1:\n players.rotate(ok_count)\n players.popleft()\n ok_count = 0\n else:\n ok_count -= 1\n\n result = list(players)\n result.sort()\n print(*result)\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0221\n\n\"\"\"\nimport sys\nfrom sys import stdin\nfrom collections import deque\ninput = stdin.readline\n\n\ndef fb_gen(count=1):\n while True:\n if count % 15 == 0:\n ans = 'FizzBuzz'\n elif count % 5 == 0:\n ans = 'Buzz'\n elif count % 3 == 0:\n ans = 'Fizz'\n else:\n ans = str(count)\n yield ans\n count += 1\n\n\ndef main(args):\n while True:\n m, n = map(int, input().split())\n if m == 0 and n == 0:\n break\n players = deque(range(1, m+1))\n fb = fb_gen()\n for _ in range(n):\n p = input().strip()\n # print('player {}: {}'.format(players[0], p))\n if p != fb.__next__():\n # drop = players.popleft()\n pass\n # print('player {} dropped'.format(drop))\n if len(players) == 1:\n break\n else:\n players.rotate(-1)\n\n result = list(players)\n result.sort()\n print(*result)\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "jacc_sim": 0.9042553191489362, "nl": "Title: FizzBuzz\n\nThere is a game using numbers called \"Fizz Buzz\". In this game, multiple players count up numbers one by one from 1, and each player says only the next number spoken by the previous player. If the number is divisible by 3, the player says \"Fizz\", if it's divisible by 5, the player says \"Buzz\", and if it's divisible by both, the player says \"FizzBuzz\" instead of the number. For example, the first 16 statements are as follows:\n\n1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz, 16, ...\n\nTaro and his friends decided to play \"Fizz Buzz\" with the following rule: \"The person who makes a mistake is eliminated. The next person starts from the number after the mistaken one. For example, if 1, 2, 3 are spoken, the next number should be 4 since 3 was a mistake.\"\n\nYou are tasked to create a program that outputs the remaining player at the end of the specified number of statements, so that Taro and his friends can enjoy the game. The program should take the number of players, the number of statements made during the game, and the input statements, and output the numbers of the remaining players in ascending order. The players are numbered from 1, and the statements are made in order, starting from the first player. If it's the turn of a player who has already been eliminated, the next player speaks. The program should stop considering further statements once only one player remains.\n\nInput:\nMultiple datasets are given as input, and the end of the input is indicated by two consecutive zeros. Each dataset is in the following format:\n\nm n\ns1\ns2\n...\nsn\n\nThe first line contains the number of players m (2 \u2264 m \u2264 1000) and the number of statements n (1 \u2264 n \u2264 10000). The following n lines contain the i-th statement si. si is an integer, \"Fizz\", \"Buzz\", or \"FizzBuzz\" (up to 8 characters).\n\nThe number of datasets does not exceed 50.\n\nOutput:\nFor each input dataset, output the numbers of the remaining players in ascending order at the specified number of statements.\n\nSample Input:\n5 7\n1\n2\nFizz\n4\nBuzz\n6\n7\n3 5\n1\n2\n3\n4\n5\n0 0\n\nOutput for the Sample Input:\n2 3 4 5\n1", "before_after_length": [344, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u021548497", "n_user": "u021548497", "pos": "import sys\ninput = sys.stdin.readline\n\ndef main():\n n, m = map(int, input().split())\n road = [[100000]*n for _ in range(n)]\n count = [[-1]*n for i in range(n)]\n for _ in range(m):\n a, b, c = map(int, input().split())\n road[a-1][b-1] = c\n road[b-1][a-1] = c\n count[a-1][b-1] = 0\n count[b-1][a-1] = 0\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if road[i][k]+road[k][j] < road[i][j]:\n if count[i][j] == 0:\n count[i][j] = 1\n road[i][j] = road[i][k]+road[k][j]\n ans = 0\n for i in range(n):\n ans += count[i].count(1)\n print(ans//2)\nif __name__ == \"__main__\":\n main()", "neg": "import sys\ninput = sys.stdin.readline\n\ndef main():\n n, m = map(int, input().split())\n road = [[100000]*n for _ in range(n)]\n count = [[-1]*n for i in range(n)]\n for _ in range(m):\n a, b, c = map(int, input().split())\n road[a-1][b-1] = c\n road[b-1][a-1] = c\n count[a-1][b-1] = 0\n count[b-1][a-1] = 0\n for k in range(n):\n for i in range(n):\n for j in range(n):\n if road[i][k]+road[k][j] < road[i][j]:\n if count[i][j] == 0:\n count[i][j] = 1\n road[i][j] = road[i][k]+road[k][j]\n print(count)\n ans = 0\n for i in range(n):\n ans += count[i].count(1)\n print(ans//2)\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [290, 296], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u677121387", "n_user": "u677121387", "pos": "n,m = map(int,input().split())\nINF = 10**18\nd = [[INF]*n for _ in range(n)]\nfor i in range(n): d[i][i] = 0\nA = [0]*m\nB = [0]*m\nC = [0]*m\nfor i in range(m):\n a,b,c = map(int,input().split())\n a -= 1\n b -= 1\n A[i] = a\n B[i] = b\n C[i] = c\n d[a][b] = c\n d[b][a] = c\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k]+d[k][j])\n\nans = 0\nfor i in range(m):\n if d[A[i]][B[i]] < C[i]: ans += 1\nprint(ans)", "neg": "n,m = map(int,input().split())\nINF = 10**18\nd = [[INF]*n for _ in range(n)]\nfor i in range(n): d[i][i] = 0\na = [0]*m\nb = [0]*m\nc = [0]*m\nfor i in range(m):\n a,b,c = map(int,input().split())\n a -= 1\n b -= 1\n a[i] = a\n b[i] = b\n c[i] = c\n d[a][b] = c\n d[b][a] = c\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j] = min(d[i][j], d[i][k]+d[k][j])\n\nans = 0\nfor i in range(m):\n if d[a[i]][b[i]] < c[i]: ans += 1\nprint(ans)", "jacc_sim": 0.926829268292683, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [243, 243], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u808806124", "n_user": "u808806124", "pos": "import numpy as np\n\nn, m = map(int, input().split())\n\nd = np.ones((n, n)) * 1001\n\nes = []\nfor i in range(m):\n es.append(list(map(int, input().split())))\n\nfor (i, j, w) in es:\n d[i - 1][j - 1] = w\n d[j - 1][i - 1] = w\n\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n l = d[i][k] + d[k][j]\n if d[i][j] > l:\n d[i][j] = l\n\nc = 0\nfor (i, j, w) in es:\n if d[i - 1][j - 1] < w:\n c += 1\n\nprint(c)\n", "neg": "n, m = map(int, input().split())\n\nd = np.ones((n, n)) * 1001\n\nes = []\nfor i in range(m):\n es.append(list(map(int, input().split())))\n\nfor (i, j, w) in es:\n d[i - 1][j - 1] = w\n d[j - 1][i - 1] = w\n\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n l = d[i][k] + d[k][j]\n if d[i][j] > l:\n d[i][j] = l\n\nc = 0\nfor (i, j, w) in es:\n if d[i - 1][j - 1] < w:\n c += 1\n\nprint(c)\n", "jacc_sim": 0.9285714285714286, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [216, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u593590006", "n_user": "u594956556", "pos": "import sys\nfrom copy import deepcopy\ninput = sys.stdin.readline\nn,m=map(int,input().split())\nd=[[100000]*n for _ in range(n)]\na=[0]*m\nb=[0]*m\nc=[0]*m\nfor i in range(m):\n a0,b0,c0=map(int,input().split())\n a[i]=a0-1\n b[i]=b0-1\n c[i]=c0\n d[a0-1][b0-1]=c0\n d[b0-1][a0-1]=c0\nfor i in range(n):\n d[i][i]=0\nd2=deepcopy(d)\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j]=min(d[i][j],d[i][k]+d[k][j])\ncount=0\nfor i in range(n):\n for j in range(i):\n if d2[i][j] != 100000 and d[i][j]!=d2[i][j]:\n count+=1\nprint(count)\n", "neg": "import sys\nfrom copy import deepcopy\ninput = sys.stdin.readline\nn,m=map(int,input().split())\nd=[[100000]*n for _ in range(n)]\na=[0]*m\nb=[0]*m\nc=[0]*m\nfor i in range(m):\n a0,b0,c0=map(int,input().split())\n a[i]=a0-1\n b[i]=b0-1\n c[i]=c0\n d[a0-1][b0-1]=c0\n d[b0-1][a0-1]=c0\nfor i in range(n):\n d[i][i]=0\nd2=deepcopy(d)\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n d[i][j]=min(d[i][j],d[i][k]+d[k][j])\ncount=0\nfor i in range(n):\n for j in range(i):\n if d[i][j]!=d[i][j]:\n count+=1\nprint(count)\n", "jacc_sim": 0.9791666666666666, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [297, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u118642796", "n_user": "u118642796", "pos": "N,M=map(int,input().split())\nINF = 10**5\nD=[[INF]*N for _ in range(N)]\nfor i in range(N):\n D[i][i]=0\npath=[]\nfor i in range(M):\n a,b,c = map(int,input().split())\n D[a-1][b-1]=c\n D[b-1][a-1]=c\n path.append([a-1,b-1,c])\nfor k in range(N):\n for i in range(N-1):\n for j in range(i+1,N):\n D[i][j]=min(D[i][j],D[i][k]+D[j][k])\n D[j][i]=D[i][j]\nans=0\nfor a,b,c in path:\n if D[a][b]c:\n ans+=1\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [236, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u437727817", "n_user": "u437727817", "pos": "n,m = map(int,input().split())\n\ndist = [[10**10 for i in range(n)]for j in range(n)]\nfor i in range(n):\n\tdist[i][i] == 0\n\na = [0]*m\nb = [0]*m\nc = [0]*m\n\nfor i in range(m):\n\ta[i], b[i], c[i] = map(int,input().split())\n\tdist[a[i]-1][b[i]-1] = c[i]\n\tdist[b[i]-1][a[i]-1] = c[i]\n\n\n#n\u306f\u9802\u70b9\u3001m\u306f\u8fba\u3001a\u3001b\u306f\u9802\u70b9\u3001c\u306fa\u3068b\u306e\u8ddd\u96e2\n\n\nfor k in range(n):\n\tfor i in range(n):\n\t\tfor j in range(n):\n\t\t\tdist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\n\nres = 0\nfor i in range(m):\n\tif c[i] > dist[a[i]-1][b[i]-1]:\n\t\tres += 1\n\nprint(res)\n", "neg": "n,m = map(int,input().split())\ndist = []\na = []\nb = []\nc = []\n\nfor i in range(m):\n\ta[i], b[i], c[i] = map(int,input().split())\n\tdist[a[i]-1][b[i]-1] = c[i]\n\tdist[b[i]-1][a[i]-1] = c[i]\n\n\n\n#n\u306f\u9802\u70b9\u3001m\u306f\u8fba\u3001a\u3001b\u306f\u9802\u70b9\u3001c\u306fa\u3068b\u306e\u8ddd\u96e2\n\n\nfor i in range(n):\n\tfor j in range(n):\n\t\tfor k in range(n):\n\t\t\tdist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])\n\nres = 0\nfor i in range(m):\n\tif c[i] > dist[a[i]-1][b[i]-1]:\n\t\tres += 1\n\nprint (res)\n", "jacc_sim": 0.9555555555555556, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [325, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u952022797", "n_user": "u952022797", "pos": "# -*- coding: utf-8 -*-\nimport sys\nimport copy\n\ndef main():\n\tN, M = map(int, input().split(\" \"))\n\t\n\tgraph = []\n\tmaps = [[9999999 for _ in range(N)] for _ in range(N)]\n\tfor i in range(N):\n\t\tmaps[i][i] = 0\n\t\n\tfor _ in range(M):\n\t\ta, b, c = map(int, input().split(\" \"))\n\t\ta, b = a-1, b-1\n\t\tmaps[a][b] = c\n\t\tmaps[b][a] = c\n\t\n\tans = 0\n\torg = copy.deepcopy(maps)\n\tfor k in range(N):\n\t\tfor i in range(N):\n\t\t\tfor j in range(N):\n\t\t\t\t#if maps[i][j] == 9999999:\n\t\t\t\t\t#continue\n\t\t\t\tif i <= j:\n\t\t\t\t\tcontinue\n\t\t\t\tmaps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\tmaps[j][i] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\n\tfor i in range(N):\n\t\tfor j in range(N):\n\t\t\tif i <= j:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] == 9999999:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] != maps[i][j]:\n\t\t\t\tans += 1\n\t\t\n\tprint(ans)\n\t\nif __name__ == \"__main__\":\n\tmain()\n\t", "neg": "# -*- coding: utf-8 -*-\nimport sys\nimport copy\n\ndef main():\n\tN, M = map(int, input().split(\" \"))\n\t\n\tgraph = []\n\tmaps = [[9999999 for _ in range(N)] for _ in range(N)]\n\tfor i in range(N):\n\t\tmaps[i][i] = 0\n\t\n\tfor _ in range(M):\n\t\ta, b, c = map(int, input().split(\" \"))\n\t\ta, b = a-1, b-1\n\t\tmaps[a][b] = c\n\t\tmaps[b][a] = c\n\t\n\tans = 0\n\torg = copy.deepcopy(maps)\n\tfor k in range(N):\n\t\tfor i in range(N):\n\t\t\tfor j in range(N):\n\t\t\t\tif maps[i][j] == 9999999:\n\t\t\t\t\tcontinue\n\t\t\t\tif i <= j:\n\t\t\t\t\tcontinue\n\t\t\t\tmaps[i][j] = min(maps[i][j], maps[i][k] + maps[k][j])\n\t\t\t\n\tfor i in range(N):\n\t\tfor j in range(N):\n\t\t\tif i <= j:\n\t\t\t\tcontinue\n\t\t\tif org[i][j] != maps[i][j]:\n\t\t\t\tans += 1\n\t\t\n\tprint(ans // 2)\n\t\nif __name__ == \"__main__\":\n\tmain()\n\t", "jacc_sim": 0.9636363636363636, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [394, 345], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u411858517", "n_user": "u411858517", "pos": "def warshall_floyd(d, V, M): #d[i][j]\u306f2\u9802\u70b9\u9593i, j\u9593\u306e\u79fb\u52d5\u30b3\u30b9\u30c8\u3092\u683c\u7d0d, V\u306f\u9802\u70b9\u6570\n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \n return d\n \nN, M = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(M)]\ndist = [[10 ** 5 for i in range(N)] for i in range(N)]\n\nfor l in L:\n l[0] -= 1\n l[1] -= 1\n \nfor i in range(M):\n dist[L[i][0]][L[i][1]] = L[i][2]\n dist[L[i][1]][L[i][0]] = L[i][2]\n\ndist = warshall_floyd(dist, N, M)\n\nres = 0\n\nfor i in range(M):\n if dist[L[i][0]][L[i][1]] != L[i][2]:\n res += 1\n \nprint(res)", "neg": "def warshall_floyd(d, V, M): #d[i][j]\u306f2\u9802\u70b9\u9593i, j\u9593\u306e\u79fb\u52d5\u30b3\u30b9\u30c8\u3092\u683c\u7d0d, V\u306f\u9802\u70b9\u6570\n for k in range(V):\n for i in range(V):\n for j in range(V):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n \n return d\n \nN, M = map(int, input().split())\nL = [list(map(int, input().split())) for _ in range(M)]\ndist = [[10 ** 5 for i in range(N)] for i in range(N)]\n\nfor l in L:\n l[0] -= 1\n l[1] -= 1\n \nfor i in range(M):\n dist[L[i][0]][L[i][1]] = L[i][2]\n dist[L[i][1]][L[i][0]] = L[i][2]\n\ndist = warshall_floyd(dist, N, M)\n\nres = M\nfor i in range(M):\n if dist[L[i][0]][L[i][1]] != L[i][2]:\n res -= 1\n \nprint(res)", "jacc_sim": 1.0, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [351, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u923279197", "n_user": "u923279197", "pos": "ans = 0\nn,m = map(int,input().split())\ndis = [[float('inf') for i in range(n)] for j in range(n)] #\u5404\u70b9\u8ddd\u96e2\u3092\u6700\u521d\u221e\u306b\u8a2d\u5b9a\nabt = []\nfor i in range(m):\n abt.append(list(map(int,input().split()))) #\u5165\u529b\nfor a,b,t in abt:\n dis[a-1][b-1] = t #\u9802\u70b9a\u304b\u3089b\u3078\u306e\u8ddd\u96e2\u304ct\n dis[b-1][a-1] = t # \u9006\u3082\u540c\u69d8\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n dis[k][j] = min(dis[k][j], dis[k][i] + dis[i][j])\nfor a,b,t in abt:\n if t > dis[a-1][b-1]:\n ans +=1\nprint(ans)", "neg": "ans = 0\nn,m = map(int,input().split())\ndis = [[float('inf') for i in range(n)] for j in range(n)] #\u5404\u70b9\u8ddd\u96e2\u3092\u6700\u521d\u221e\u306b\u8a2d\u5b9a\nabt = []\nfor i in range(m):\n abt.append(list(map(int,input().split()))) #\u5165\u529b\nfor a,b,t in abt:\n dis[a-1][b-1] = t #\u9802\u70b9a\u304b\u3089b\u3078\u306e\u8ddd\u96e2\u304ct\n dis[b-1][a-1] = t # \u9006\u3082\u540c\u69d8\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n dis[i][j] = min(dis[k][j], dis[k][i] + dis[i][j])\nfor a,b,t in abt:\n if t > dis[a-1][b-1]:\n ans +=1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [286, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03837", "p_user": "u190405389", "n_user": "u190405389", "pos": "n,m = map(int,input().split())\nabc = [list(map(int, input().split())) for i in range(m)]\n\nd = [[0]*n for i in range(n)]\ne = [[0]*n for i in range(n)]\n\nfor i in range(n):\n for j in range(n):\n if i!=j:\n d[i][j]=float('inf')\n e[i][j]=float('inf')\n\nfor i in range(m):\n d[abc[i][0]-1][abc[i][1]-1]=abc[i][2]\n d[abc[i][1]-1][abc[i][0]-1]=abc[i][2]\n e[abc[i][0]-1][abc[i][1]-1]=abc[i][2]\n e[abc[i][1]-1][abc[i][0]-1]=abc[i][2]\n\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n if d[j][k]>d[j][i]+d[i][k]:\n d[j][k] = d[j][i]+d[i][k]\n\nf = 0\n\nfor i in range(n):\n for j in range(n):\n if d[i][j]!=e[i][j] and e[i][j]!=float('inf'):\n f+=1\n\nprint(f//2)", "neg": "n,m = map(int,input().split())\nabc = [list(map(int, input().split())) for i in range(m)]\n\nd = [[0]*n for i in range(n)]\ne = [[0]*n for i in range(n)]\n\nfor i in range(n):\n for j in range(n):\n if i!=j:\n d[i][j]=float('inf')\n e[i][j]=float('inf')\n\nfor i in range(m):\n d[abc[i][0]-1][abc[i][1]-1]=abc[i][2]\n d[abc[i][1]-1][abc[i][0]-1]=abc[i][2]\n e[abc[i][0]-1][abc[i][1]-1]=abc[i][2]\n e[abc[i][1]-1][abc[i][0]-1]=abc[i][2]\n\nfor i in range(n):\n for j in range(n):\n for k in range(n):\n if d[j][k]>d[j][i]+d[i][k]:\n d[j][k] = d[j][i]+d[i][k]\n\nf = 0\n\nfor i in range(n):\n for j in range(n):\n if d[i][j]!=e[i][j]:\n f+=1\n\nprint(f//2)", "jacc_sim": 0.975, "nl": "You are given an undirected connected weighted graph with N vertices and M edges that contains neither self-loops nor double edges. Find the number of edges that are not contained in any shortest path between any pair of different vertices. Constraints: 2\u2264N\u2264100, N-1\u2264M\u2264min(N(N-1)/2,1000), 1\u2264a_i,b_i\u2264N, 1\u2264c_i\u22641000, c_i is an integer. The input is given in the format: N M a_1 b_1 c_1 a_2 b_2 c_2 ... a_M b_M c_M. Output the number of edges not contained in any shortest path.", "before_after_length": [378, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u923270446", "n_user": "u923270446", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\ncum = [0]\nfor i in range(n):\n cum.append(min(a[i], 0) + cum[-1])\ncum2 = [0]\nfor i in range(n):\n cum2.append(max(a[i], 0) + cum2[-1])\nSUM = sum(max(a[i], 0) for i in range(n))\nl = []\nfor i in range(n - k + 1):\n l.append(SUM + cum[i + k] - cum[i])\n l.append(SUM - cum2[i + k] + cum2[i])\nprint(max(l))", "neg": "n, k = map(int, input().split())\na = list(map(int, input().split()))\ncum = [0]\nfor i in range(n):\n cum.append(min(a[i], 0) + cum[-1])\ncum2 = [0]\nfor i in range(n):\n cum2.append(max(a[i], 0) + cum2[-1])\nSUM = sum(max(a[i], 0) for i in range(n))\nl = []\nfor i in range(n - k + 1):\n l.append(SUM + cum[i + k] - cum[i])\n l.append(SUM - cum2[i + k] + cum[i])\nprint(max(l))", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [178, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u102445737", "n_user": "u102445737", "pos": "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\nn,k = inm()\na = inl()\nif n<-4 and k==2:\n 3/0\nmx = sum(a)\nlacc = [0]*(n+1)\nracc = [0]*(n+1)\nfor i in range(n):\n lacc[i+1] = lacc[i]+max(a[i],0)\nfor i in range(n-1,-1,-1):\n racc[i] = racc[i+1]+max(a[i],0)\nsk = sum(a[:k])\nfor i in range(n-k+1):\n mx = max(mx,lacc[i]+max(sk,0)+racc[i+k])\n if i 0:\n t += a[i]\nans = max(t, s + t)\n# print(s, t)\nfor i in range(n - k):\n s -= a[i]\n s += a[k + i]\n if a[k + i] > 0:\n t -= a[k + i]\n if a[i] > 0:\n t += a[i]\n ans = max(ans, s + t, t)\n # print(s, t)\nprint(ans)\n \n \n\n", "neg": "import sys\ninput = sys.stdin.readline\n\nn, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\ns = sum(a[:k])\nt = 0\nfor i in range(k, n):\n if a[i] > 0:\n t += a[i]\nans = max(0, s + t)\n# print(s + t)\nfor i in range(n - k):\n s -= a[i]\n s += a[k + i]\n t -= a[k + i]\n if a[i] > 0:\n t += a[i]\n ans = max(ans, s + t)\n # print(s + t)\nprint(ans)\n \n \n\n", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [209, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u499381410", "n_user": "u499381410", "pos": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nfrom pprint import pprint\nfrom copy import deepcopy\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\nfrom operator import mul\nfrom functools import reduce\nfrom pprint import pprint\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 15\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 1000000007\n\n\nn, k = LI()\nA = LI()\nacc = [0] + list(accumulate(A))\nplus_acc = [0] + list(accumulate([i if i > 0 else 0 for i in A]))\nans = -INF\nfor l in range(n - k + 1):\n r = l + k\n ans = max(ans, max(acc[r] - acc[l], 0) + plus_acc[l] + plus_acc[n] - plus_acc[r])\n\nprint(ans)", "neg": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nfrom pprint import pprint\nfrom copy import deepcopy\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\nfrom operator import mul\nfrom functools import reduce\nfrom pprint import pprint\n\n\nsys.setrecursionlimit(2147483647)\nINF = 10 ** 15\ndef LI(): return list(map(int, sys.stdin.buffer.readline().split()))\ndef I(): return int(sys.stdin.buffer.readline())\ndef LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()\ndef S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 1000000007\n\n\nn, k = LI()\nA = LI()\nacc = [0] + list(accumulate(A))\nplus_acc = [0] + list(accumulate([i if i > 0 else 0 for i in A]))\nans = -INF\nfor l in range(n - k + 1):\n r = l + k\n ans = max(ans, acc[r] - acc[l] + plus_acc[l] + plus_acc[n] - plus_acc[r])\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [453, 449], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u476604182", "n_user": "u476604182", "pos": "from itertools import accumulate as acc\nN, K, *A = map(int, open(0).read().split())\nB = [0]+list(acc(A))\nM = list(acc(a if a>0 else 0 for a in A))\nans = -10**30\ns = sum(A)\nfor i in range(N-K+1):\n mi = B[i+K]-B[i]\n c = M[N-1] - M[i+K-1]\n if i>0:\n c += M[i-1]\n ans = max(ans,mi+c,c)\nprint(ans)", "neg": "from itertools import accumulate as acc\nN, K, *A = map(int, open('0').read().split())\nB = [0]+list(acc(A))\nM = list(acc(a if a>0 else 0 for a in A))\nans = -10**30\ns = sum(A)\nfor i in range(N-K+1):\n mi = B[i+K]-B[i]\n c = M[N-1] - M[i+K-1]\n if i>0:\n c += M[i-1]\n ans = max(ans,mi+c,c)\nprint(ans)", "jacc_sim": 0.9791666666666666, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [153, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u623819879", "n_user": "u623819879", "pos": "n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nacc=[0]*(n+1)\npos=[0]*(n+1)\nfor i in range(n):\n acc[i+1]+=a[i]+acc[i]\n pos[i+1]+=max(a[i],0)+pos[i]\n\nans=-10**18\n\nfor i in range(n-k+1):\n ans=max(ans,acc[i+k]-acc[i]+pos[i]+pos[-1]-pos[i+k])\n ans=max(ans,pos[i]+pos[-1]-pos[i+k])\nprint(ans)", "neg": "n,k=map(int,input().split())\na=[int(i) for i in input().split()]\nacc=[0]*(n+1)\npos=[0]*(n+1)\nfor i in range(n):\n acc[i+1]+=a[i]\n pos[i+1]+=max(a[i],0)\n\nans=-10**18\n\nfor i in range(n-k):\n ans=max(ans,acc[i+k]-acc[i]+pos[i]+pos[-1]-pos[i+k])\n ans=max(ans,pos[i]+pos[-1]-pos[i+k])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [175, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u619819312", "n_user": "u619819312", "pos": "from itertools import accumulate as ac\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nb=[0]+list(ac(a))\nc=[0]+list(ac([(0 if i<0 else i)for i in a]))\nd=0\nfor i in range(n-k+1):\n d=max(d,max(b[i+k]-b[i],0)+c[i]+c[-1]-c[i+k])\nprint(d)", "neg": "from itertools import accumulate as ac\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(ac(a))\nc=list(ac([(0 if i<0 else i)for i in a]))\nd=0\nfor i in range(n-k):\n d=max(d,max(b[i+k-1]-b[i],0)+c[i]+c[-1]-c[i+k])\nprint(d)", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [126, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom itertools import accumulate\n\ndef main():\n N, K = LI()\n A = LI()\n negs = [min(0, a) for a in A]\n poss = [max(0, a) for a in A]\n nacc = [0] + list(accumulate(negs))\n pacc = [0] + list(accumulate(poss))\n neg = max(q - p for p, q in zip(nacc, nacc[K:]))\n pos = min(q - p for p, q in zip(pacc, pacc[K:]))\n ans = sum(a for a in A if a > 0) + max(neg, -pos)\n\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom itertools import accumulate\n\ndef main():\n N, K = LI()\n A = LI()\n negs = [min(0, a) for a in A]\n acc = [0] + list(accumulate(negs))\n neg = max(q - p for p, q in zip(acc, acc[K:]))\n ans = sum(a for a in A if a > 0) + neg\n\n return ans\n\nprint(main())", "jacc_sim": 0.9230769230769231, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [312, 244], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u785578220", "n_user": "u785578220", "pos": "N, K = map(int, input().split())\na = list(map(int, input().split()))\n\nsa = [0]\nsb = [0]\nfor i in range(N):\n sa.append(sa[-1] + a[i])\n sb.append(sb[-1] + max(0, a[i]))\n\nans = 0\nfor i in range(N - K + 1):\n a = sa[i + K] - sa[i]\n b = sb[i + K] - sb[i]\n ans = max(ans, sb[N] - b + max(a, 0))\nprint(ans)\n", "neg": "N, K = map(int, input().split())\na = list(map(int, input().split()))\n\nsa = [0]\nsb = [0]\nfor i in range(N):\n sa.append(sa[-1] + a[i])\n sb.append(sb[-1] + max(0, a[i]))\n\nans = 0\nfor i in range(N - K + 1):\n\ta = sa[i + K] - sa[i]\n\tb = sb[i + K] - sb[i]\n ans = max(ans, sb[N] - b + max(a, 0))\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [155, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u064408584", "n_user": "u064408584", "pos": "import numpy as np\nn,k=map(int, input().split())\na=np.array(list(map(int, input().split())))\nb=np.maximum(a,0)\nsm=sum(a[:k])\nat=sum(b[k:])\nans=max(sm,0)+at\nfor i in range(k,n):\n sm+=a[i]-a[i-k]\n at+=b[i-k]-b[i]\n ans=max(max(0,sm)+at,ans)\nprint(ans)", "neg": "import numpy as np\nn,k=map(int, input().split())\na=np.array(list(map(int, input().split())))\nb=np.maximum(a,0)\nsm=sum(a[:k])\nat=sum(b[k:])\nans=max(sm,0)+at\nfor i in range(k,n):\n sm+=a[i]-a[i-k]\n at+=b[i-k]-b[i]\n ans=max(max(0,sm)+at,ans)\n print(sm,at)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [138, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u270681687", "n_user": "u270681687", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncum = []\nabscum = []\n\ncu = 0\nacu = 0\nfor i in range(n):\n cu += a[i]\n acu += max(0, a[i])\n cum.append(cu)\n abscum.append(acu)\n\nans = 0\nfor i in range(n-k+1):\n if i == 0:\n ans = max(ans, abscum[n-1] - abscum[i+k-1] + max(0, cum[i+k-1]))\n else:\n ans = max(ans, abscum[n - 1] - (abscum[i + k - 1] - abscum[i-1]) + max(0, cum[i + k - 1] - cum[i-1]))\n\nprint(ans)", "neg": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncum = []\nabscum = []\n\ncu = 0\nacu = 0\nfor i in range(n):\n cu += a[i]\n acu += abs(a[i])\n cu.append(cum)\n acu.append(abscum)\n\nans = 0\nfor i in range(n-k):\n if i == 0:\n ans = max(ans, abscum[n-1] - abscum[i+k-1] + abs(cum[i+k-1]))\n else:\n ans = max(ans, abscum[n - 1] - (abscum[i + k - 1] - abscum[i-1]) + abs(cum[i + k - 1] - cum[i-1]))\n \nprint(ans)", "jacc_sim": 0.9714285714285714, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [226, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u667024514", "n_user": "u667024514", "pos": "n,k = map(int,input().split())\nlis = list(map(int,input().split()))\nnum = 0\nans = 0\ncou = 0\nco = 0\nfor i in range(n):num += max(0,lis[i])\nli = [0 for i in range(n-k+1)]\nfor i in range(k-1):\n cou += max(0,lis[i])\n co += max(0,-lis[i])\nfor i in range(n-k+1):\n cou += max(0,lis[i+k-1])\n co += max(0,-lis[i+k-1])\n if cou >= co:ans = max(ans,num-co)\n else:ans = max(ans,num-cou)\n cou -= max(0,lis[i])\n co -= max(0,-lis[i])\nprint(ans)", "neg": "n,k = map(int,input().split())\nlis = list(map(int,input().split()))\nnum = 0\nans = 0\nfor i in range(n):\n num += max(0,lis[i])\nli = [0 for i in range(n-k+1)]\nfor i in range(n-k+1):\n cou = 0\n co = 0\n for nu in lis[i:i+k+1]:\n if nu >= 0:\n cou += nu\n else:\n co -= nu\n if cou >= co:ans = max(ans,num-co)\n else:ans = max(ans,num-cou)\n \nprint(ans)", "jacc_sim": 0.9714285714285714, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [231, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,k=map(int,input().split())\na=[0]+list(map(int,input().split()))\ns=[0]\np=[0]\nfor i in range(1,n+1):\n s.append(s[i-1]+a[i])\n p.append(p[i-1]+max(0,a[i]))\nans=0\nfor i in range(1,n-k+2):\n t=max(0,s[i+k-1]-s[i-1])\n t+=p[i-1]+p[n]-p[i+k-1]\n ans=max(ans,t)\nprint(ans)", "neg": "n,k=map(int,input().split())\na=[0]+list(map(int,input().split()))\ns=[0]\np=[0]\nfor i in range(1,n+1):\n s[i].append(s[i-1]+a[i])\n p[i].append(p[i-1]+max(0,a[i]))\nans=0\nfor i in range(1,n-k+1):\n t=max(0,s[i+k]-s[i-1])\n t+=p[i-1]+p[n]-p[i+k]\n ans=max(ans,t)\nprint(ans)", "jacc_sim": 0.96875, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [166, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u098968285", "n_user": "u098968285", "pos": "N, K = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\n\nif N == K:\n\tprint(max(0, sum(a)))\nelse:\n\timosW = [0]*(N+2)\n\timosB = [0]*(N+2)\n\tfor i in range(1, N+1):\n\t\timosW[i] = max(0, a[i]) + imosW[i-1]\n\t\timosB[i] = min(0, a[i]) + imosB[i-1]\n\n\tsepW = -1\n\tmini = int(1e18)\n\tfor i in range(K, N + 1):\n\t\tif mini > imosW[i] - imosW[i-K]:\n\t\t\tmini = imosW[i] - imosW[i-K]\n\t\t\tsepW = (i-K, i)\n\n\tansW = 0\n\tfor i in range(1, N+1):\n\t\tif a[i] > 0 and not(i > sepW[0] and i <= sepW[1]):\n\t\t\tansW += a[i]\n\n\t##\n\tsepB = -1\n\tmaxm = int(-1e18)\n\tfor i in range(K, N+1):\n\t\tif maxm < imosB[i] - imosB[i-K]:\n\t\t\tmaxm = imosB[i] - imosB[i-K]\n\t\t\tsepB = (i-K, i)\n\tansB = (imosB[sepB[1]] - imosB[sepB[0]]) + (imosW[sepB[1]] - imosW[sepB[0]])\n\tfor i in range(1, N+1):\n\t\tif a[i] > 0 and not(i > sepB[0] and i <= sepB[1]):\n\t\t\tansB += a[i]\n\n\tprint(max(max(ansW, ansB), sum(a)))\n", "neg": "N, K = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\n\nif N == K:\n\tprint(max(0, sum(a)))\nelse:\n\timosW = [0]*(N+2)\n\timosB = [0]*(N+2)\n\tfor i in range(1, N+1):\n\t\timosW[i] = max(0, a[i]) + imosW[i-1]\n\t\timosB[i] = min(0, a[i]) + imosB[i-1]\n\n\tsepW = -1\n\tmini = int(1e18)\n\tfor i in range(K, N + 1):\n\t\tif mini > imosW[i] - imosW[i-K]:\n\t\t\tmini = imosW[i] - imosW[i-K]\n\t\t\tsepW = (i-K, i)\n\n\tansW = 0\n\tfor i in range(1, N+1):\n\t\tif a[i] > 0 and not(i > sepW[0] and i <= sepW[1]):\n\t\t\tansW += a[i]\n\n\t##\n\tsepB = -1\n\tmaxm = int(-1e18)\n\tfor i in range(K, N+1):\n\t\tif maxm < imosB[i] - imosB[i-K]:\n\t\t\tmaxm = imosB[i] - imosB[i-K]\n\t\t\tsepB = (i-K, i)\n\tansB = imosB[sepB[1]] - imosB[sepB[0]]\n\tfor i in range(1, N+1):\n\t\tif a[i] > 0 and not(i > sepB[0] and i <= sepB[1]):\n\t\t\tansB += a[i]\n\n\tprint(max(max(ansW, ansB), sum(a)))\n", "jacc_sim": 1.0, "nl": "You are given a row of N squares, each containing an integer. Initially, all squares are white. You can repeatedly choose K consecutive squares and paint them all white or all black. After each operation, the score is the sum of integers in the black squares. Find the maximum possible score. Constraints: 1\u2264N\u226410^5, 1\u2264K\u2264N, |a_i|\u226410^9. Input format: N K a_1 a_2 ... a_N. Output the maximum score. Example: Input: 5 3 -10 10 -10 10 -10, Output: 10.", "before_after_length": [505, 481], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03839", "p_user": "u778736942", "n_user": "u778736942", "pos": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\nk = 0\nfor i in range(N-K+1):\n\tif i>0:\n\t\tK_sum = K_sum-A[i-1]+A[i+K-1]\n\t\tK_sum0 = max(0, K_sum)\n\t\tK_pos = K_pos-max(0, A[i-1])+max(0, A[i+K-1])\n\telse:\n\t\tK_sum = sum(A[i:i+K])\n\t\tK_sum0 = max(0, K_sum)\n\t\tK_pos = sum(map(lambda x:max(0, x), A[i:i+K]))\n\tloss = K_pos-K_sum0\n\tif i==0:\n\t\tloss_min = loss\n\tif loss0:\n\t\tK_sum = K_sum-A[i-1]+A[i+K-1]\n\t\tK_sum0 = max(0, K_sum)\n\t\tK_pos = K_pos-max(0, A[i-1])+max(0, A[i+K-1])\n\telse:\n\t\tK_sum = sum(A[i:i+K])\n\t\tK_sum0 = max(0, K_sum)\n\t\tK_pos = sum(map(lambda x:max(0, x), A[i:i+K]))\n\tloss = K_pos-K_sum\n\tif i==0:\n\t\tloss_min = loss\n\tif loss0)&(aj>0)&(al>0):\n ai -= 1\n aj -= 1\n al -= 1\n tmp = 6 + (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4\n ans = max(ans,tmp)\nprint(ans//2)", "neg": "ai,ao,at,aj,al,As,az = map(int,input().split())\n\nans = (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4\nif(ai>0)&(aj>0)&(al>0):\n ai -= 1\n aj -= 1\n al -= 1\n tmp = 6 + (ai//2)*4 + ao*2 + (aj//2)*4 + (al//2)*4\n ans = max(ans,tmp)\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [131, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u707124227", "n_user": "u707124227", "pos": "ni,no,nt,nj,nl,ns,nz=map(int,input().split())\nans=0\nans+=no\nc=0\nc+=ni%2\nc+=nl%2\nc+=nj%2\n# c:\u5947\u6570\u306e\u500b\u6570\nif c==3 or c==0:\n ans+=ni+nj+nl\nelif c==1:\n ans+=ni+nj+nl-1\nelif ni>0 and nj>0 and nl>0:\n ans+=ni+nj+nl-1\nelse:\n ans+=ni+nj+nl-2\nprint(ans)\n", "neg": "ni,no,nt,nj,nl,ns,nz=map(int,input().split())\nans=0\nans+=no\nc=0\nc+=ni%2\nc+=nl%2\nc+=nj%2\n# c:\u5947\u6570\u306e\u500b\u6570\nif c==3 or c==0:\n ans+=ni+nj+nl\nelif c==1:\n ans+=ni+nj+nl-1\nelif ni>0 and nj>0 and nl>0:\n ans+=ni+nj+nl-1\nelse:\n ans+=ni+nj+nl-2\nprint(ans if ans else -1)", "jacc_sim": 1.0, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [170, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u367701763", "n_user": "u984276646", "pos": "A = list(map(int, input().split()))\nres = 0\nif A[0]%2 + A[3]%2 + A[4]%2 >=2 and A[0]*A[3]*A[4]>0:\n A[0] -= 1\n A[3] -= 1\n A[4] -= 1\n res += 3\nres += A[0]//2*2\nres += A[1]\nres += A[4]//2*2\nres += A[3]//2*2\nprint(res)\n", "neg": "A = list(map(int, input().split()))\nS = A[1] * 2\nS += (A[0] // 2) * 4\nif A[4] > 0 and A[5] > 0 and A[0] % 2 == 1:\n A[4] -= 1\n A[5] -= 1\n S += 3\nS += (A[4] // 2) * 4 + (A[5] // 2) * 4\nprint(S)", "jacc_sim": 0.9032258064516129, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [132, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u366886346", "n_user": "u366886346", "pos": "i,o,t,j,l,s,z=map(int,input().split())\nans=0\nans+=o\nif j==1 and l==1 and i==1:\n ans+=3\nelif j<2 and l<2 and i<2:\n ans+=0\nelif j%2==1 and l%2==1 and i%2==1:\n ans+=j+i+l\nelif j%2==1 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==0:\n ans+=j+i+l\nprint(ans)\n", "neg": "i,o,t,j,l,s,z=map(int,input().split())\nans=0\nans+=o\nif j==1 and l==1 and i==1:\n ans+=3\nelif j<2 or l<2 or i<2:\n ans+=0\nelif j%2==1 and l%2==1 and i%2==1:\n ans+=j+i+l\nelif j%2==1 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==1 and l%2==0 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==1 and i%2==0:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==1:\n ans+=j+i+l-1\nelif j%2==0 and l%2==0 and i%2==0:\n ans+=j+i+l\nprint(ans)\n", "jacc_sim": 0.967741935483871, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [338, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u543954314", "n_user": "u543954314", "pos": "i,o,t,j,l,s,z = map(int, input().split())\nk = o\np = (i//2 + j//2 + l//2)*2\nq = 0\nif i*j*l:\n q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*2 + 3\nprint(k + max(p, q)) \n", "neg": "i,o,t,j,l,s,z = map(int, input().split())\nk = o*2\np = (i//2 + j//2 + l//2)*4\nq = 0\nif i*j*k:\n q = ((i-1)//2 + (j-1)//2 + (l-1)//2)*4 + 6\nprint(k + max(p, q)) ", "jacc_sim": 0.9090909090909091, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [98, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u813174766", "n_user": "u813174766", "pos": "a=list(map(int,input().split()))\nans=min(a[0],a[3],a[4])\na[0]-=ans\na[3]-=ans\na[4]-=ans\nans*=3\nif(ans>0 and (a[0]%2+a[3]%2+a[4]%2==2)):\n ans+=1\nans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]\nprint(ans)\n", "neg": "a=list(map(int,input().split()))\nans=min(a[0],a[3],a[4])\na[0]-=ans\na[3]-=ans\na[4]-=ans\nans*=3\nif(ans>0&&(a[0]%2+a[3]%2+a[4]%2==2)):\n ans+=1\nans+=(a[0]//2*2)+(a[3]//2*2)+(a[4]//2*2)+a[1]\nprint(ans)\n", "jacc_sim": 0.9354838709677419, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [140, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u227082700", "n_user": "u227082700", "pos": "I,O,R,J,L,S,Z=map(int,input().split())\na=(I//2+J//2+L//2)*2\nb=0\nif I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)\nprint(max(a,b)+O)", "neg": "I,O,R,J,L,S,Z=map(int,input().split())\na=(I//2+J//2+L//2)*2\nb=0\nif I*J*L!=0:b=(2*((I-1)//2+(J-1)//2+(L-1)//2)+3)\nprint(max(a,b))", "jacc_sim": 1.0, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [94, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u969190727", "n_user": "u969190727", "pos": "i,o,t,j,l,s,z=map(int,input().split())\nans=0\nif i==0 or j==0 or l==0:\n ans+=o+(i//2)*2+(j//2)*2+(l//2)*2\nelse:\n ans+=o+(i//2)*2+(j//2)*2+(l//2)*2\n ans1=o+((i-1)//2)*2+((j-1)//2)*2+((l-1)//2)*2+3\n ans=max(ans,ans1)\nprint(ans)", "neg": "i,o,t,j,l,s,z=map(int,input().split())\nans=0\nif i==0 or j==0 or l==0:\n ans+=o+(i//2)*2+min(j,l)*2\nelse:\n ans+=o+(i//2)*2+min(j,l)*2\n ans1=o+((i-1)//2)*2+max(0,min(j-1.l-1))*2\nprint(ans)", "jacc_sim": 0.9393939393939394, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [151, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u391731808", "n_user": "u391731808", "pos": "A = {k:a for k,a in zip(list(\"IOTJLSZ\"),map(int,input().split()))}\nm = min(A[\"I\"],A[\"J\"],A[\"L\"])\nans = 0\nfor i in range(min(2,m+1)):\n ans = max(ans, 3*i + A[\"O\"] + (A[\"I\"]-i)//2*2 + (A[\"J\"]-i)//2*2 + (A[\"L\"]-i)//2*2)\nprint(ans)", "neg": "A = {k:a for k,a in zip(list(\"IOTJLSZ\"),map(int,input().split()))}\nm = min(A[\"I\"],A[\"J\"],A[\"L\"])\nans = 0\nfor i in (0,1,m-1,m):\n ans = max(ans, 3*i + A[\"O\"] + (A[\"I\"]-i)//2 + (A[\"J\"]-i)//2 + (A[\"L\"]-i)//2)\nprint(ans)", "jacc_sim": 0.9761904761904762, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [132, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u619819312", "n_user": "u619819312", "pos": "a=list(map(int,input().split()))\nk,h=a[1],a[1]\nk+=a[0]-a[0]%2\nk+=a[3]-a[3]%2\nk+=a[4]-a[4]%2\nif min(a[0],a[3],a[4])>0:\n h+=3\n a[0],a[3],a[4]=a[0]-1,a[3]-1,a[4]-1\n h+=a[0]-a[0]%2\n h+=a[3]-a[3]%2\n h+=a[4]-a[4]%2\nprint(max(k,h))", "neg": "a=list(map(int,input().split()))\nk,h=b,b\nk+=a[0]-a[0]%2\nk+=a[3]-a[3]%2\nk+=a[4]-a[4]%2\nif min(a[0],a[3],a[4])>0:\n h+=3\n a[0],a[3],a[4]=a[0]-1,a[3]-1,a[4]-1\n h+=a[0]-a[0]%2\n h+=a[3]-a[3]%2\n h+=a[4]-a[4]%2\nprint(max(k,h))", "jacc_sim": 0.9666666666666667, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [188, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u118642796", "n_user": "u118642796", "pos": "I,O,T,J,L,S,Z = map(int,input().split())\nprint(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0)*(L>0)*(J>0),(I//2+J//2+L//2)*2+O))\n", "neg": "I,O,T,J,L,S,Z = map(int,input().split())\nprint(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3*(I>0*\u2768L>0\u2769*\u2768J>0\u2769,(I//2+J//2+L//2)*2+O))\n", "jacc_sim": 0.9310344827586207, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [89, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u729707098", "n_user": "u729707098", "pos": "a = [int(i) for i in input().split()]\nf = lambda x: x-x%2\nans = a[1]+f(a[0])+f(a[3])+f(a[4])\nif a[0] and a[3] and a[4]: ans = max(ans, a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3)\nprint(ans)", "neg": "a = [int(i) for i in input().split()]\nf = lambda x: max(0,x-x%2)\nprint(max(a[1]+f(a[0])+f(a[3])+f(a[4]),a[1]+f(a[0]-1)+f(a[3]-1)+f(a[4]-1)+3))", "jacc_sim": 0.9032258064516129, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [113, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u467736898", "n_user": "u118642796", "pos": "I, O, T, J, L, S, Z = map(int, input().split())\nif I>0 and J>0 and L>0:\n print(O + max(2*(I//2+J//2+L//2), 3+2*((I-1)//2+(J-1)//2+(L-1)//2)))\nelse:\n print(O+2*(I//2+J//2+L//2))\n", "neg": "I,O,T,J,L,S,Z = map(int,input().split())\nif I==1 and J==1 and L==1: \n print(3) \nelif ((I-1)//2+(J-1)//2+(L-1)//2)*2+O==0 and (I//2+J//2+L//2)*2+O)==0:\n print(0)\nelse:\n print(max(((I-1)//2+(J-1)//2+(L-1)//2)*2+O+3,(I//2+J//2+L//2)*2+O))\n", "jacc_sim": 0.9375, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [110, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03840", "p_user": "u107077660", "n_user": "u107077660", "pos": "A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nans = 0\nans += B[0]\nif min(B[1:]) == 0:\n\tfor b in B[1:]:\n\t\tans += b//2*2\nelif not sum([i%2 for i in B[1:]])%3:\n\tans += sum(B[1:])\nelse:\n\tans += sum(B[1:])-1\nprint(ans)\n", "neg": "A = [int(i) for i in input().split()]\nB = [A[1],A[0],A[3],A[4]]\nans = 0\nans += B[0]\nif min(B[1:]) == 0:\n\tfor b in B[1:]:\n\t\tif b%2 == 0:\n\t\t\tans += 2\nelif not sum([i%2 for i in B[1:]])%3:\n\tans += sum(B[1:])\nelse:\n\tans += sum(B[1:])-1\nprint(ans)\n", "jacc_sim": 0.9428571428571428, "nl": "Score: 600 points\nProblem Statement:\nA tetromino is a figure formed by joining four squares edge to edge. There are seven kinds of tetromino: I-, O-, T-, J-, L-, S-, and Z-tetrominos. Snuke has a certain number of each type of tetromino. He wants to join K of his tetrominos to form a rectangle that is two squares tall and 2K squares wide. Each tetromino can be rotated but not reflected. The goal is to find the maximum possible value of K. Constraints: 0 \u2264 a_I, a_O, a_T, a_J, a_L, a_S, a_Z \u2264 10^9, and a_I + a_O + a_T + a_J + a_L + a_S + a_Z \u2265 1. Input: a_I a_O a_T a_J a_L a_S a_Z. Output: Print the maximum possible value of K. If no rectangle can be formed, print 0. Sample Input 1: 2 1 1 0 0 0 0. Sample Output 1: 3. Sample Input 2: 0 0 10 0 0 0 0. Sample Output 2: 0.", "before_after_length": [131, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03849", "p_user": "u054106284", "n_user": "u054106284", "pos": "N= int(input())\nbit = bin(N)[2:]\nk = len(bit)\ndp = [[0] * 2 for i in range(len(bit) + 1)]\ndp[0][0] = 1\ndp[0][1] = 1\nfor i in range(k):\n\tj = int(bit[k-i-1])\n\ta,b,c = [(1,0,0),(1,1,0)][j]\n\td,e,f = [(1, 1, 1),(0, 1, 2)][j]\n\tdp[i+1][0] = (a * dp[i][0] + b * dp[i][1] + c * 3**i) % 1000000007\n\tdp[i+1][1] = d * dp[i][0] + e * dp[i][1] + f * 3**i % 1000000007\n\nprint(dp[k][0])\n \n ", "neg": "N= int(input())\n\nbit = bin(N)[2:]\nk = len(bit)\ndp = [[0] * 2 for i in range(len(bit) + 1)]\nfor i in range(k):\n\tj = int(bit[k-i+1])\n\ta,b,c = [(1,0,0),(1,1,0)][j]\n\td,e,f = [(2, 1, 1),(1, 2, 2)][j]\n\tdp[i+1][0] = a * dp[i][0] + b * dp[i][1] + c * 3**i\n\tdp[i+1][1] = d * dp[i][0] + e * dp[i][1] + f * 3**i\n\nprint(dp[k][0])\n \n \n", "jacc_sim": 0.9444444444444444, "nl": "You are given a positive integer N. Find the number of pairs of integers u and v (0\u2266u,v\u2266N) such that there exist two non-negative integers a and b satisfying a xor b=u and a+b=v. Compute the answer modulo 10^9+7. The input is given as N, and the output should be the number of possible pairs of integers u and v, modulo 10^9+7.", "before_after_length": [226, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03857", "p_user": "u205166254", "n_user": "u205166254", "pos": "\ndef f(m, r):\n connmap = [[] for _ in range(m + 1)]\n for _ in range(r):\n a, b = map(int, input().split())\n connmap[a].append(b)\n connmap[b].append(a)\n group = [0] * (m + 1)\n num = 0\n for i in range(1, m + 1):\n if group[i] > 0:\n continue\n num += 1\n group[i] = num\n for j in connmap[i]:\n group[j] = num\n bfs = connmap[i]\n while len(bfs) > 0:\n tmp = []\n for j in bfs:\n for k in connmap[j]:\n if group[k] > 0:\n continue\n group[k] = num\n tmp.append(k)\n bfs = tmp\n return group\n\nn, k, l = map(int, input().split())\n\nroad = f(n, k)\nrail = f(n, l)\n\ncount = {}\n\nfor i in range(1, n + 1):\n key = '{0} {1}'.format(road[i], rail[i])\n if key in count:\n count[key] += 1\n else:\n count[key] = 1\n \nfor i in range(1, n + 1):\n key = '{0} {1}'.format(road[i], rail[i])\n print(count[key], end=' ' if i < n else '')\nprint()\n\n", "neg": "\ndef f(m, r):\n connmap = [[] for _ in range(m + 1)]\n for _ in range(r):\n a, b = map(int, input().split())\n connmap[a].append(b)\n connmap[b].append(a)\n group = [0] * (m + 1)\n num = 0\n for i in range(1, m + 1):\n if group[i] > 0:\n continue\n if len(connmap[i]) == 0:\n continue\n num += 1\n group[i] = num\n for j in connmap[i]:\n group[j] = num\n bfs = connmap[i]\n while len(bfs) > 0:\n tmp = []\n for j in bfs:\n for k in connmap[j]:\n if group[k] > 0:\n continue\n group[k] = num\n tmp.append(k)\n bfs = tmp\n return group\n\nn, k, l = map(int, input().split())\n\nroad = f(n, k)\nrail = f(n, l)\n\ncount = {}\n\nfor i in range(1, n + 1):\n key = '{0} {1}'.format(road[i], rail[i])\n if key in count:\n count[key] += 1\n else:\n count[key] = 1\n \nfor i in range(1, n + 1):\n key = '{0} {1}'.format(road[i], rail[i])\n print(count[key], end=' ' if i < n else '')\nprint()\n\n", "jacc_sim": 1.0, "nl": "You are given N cities, K roads, and L railways connecting the cities. Each road connects two cities bidirectionally, as do the railways. For each city, find the number of cities connected to it by both roads and railways. Constraints: 2 \u2264 N \u2264 2*10^5, 1 \u2264 K, L \u2264 10^5, 1 \u2264 p_i, q_i, r_i, s_i \u2264 N, p_i < q_i, r_i < s_i, and no two roads or railways connect the same pair of cities. Input format: N, K, L, followed by K lines of road connections and L lines of railway connections. Output N integers representing the number of cities connected to each city by both roads and railways. Example inputs and outputs are provided.", "before_after_length": [388, 404], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u589969467", "n_user": "u667024514", "pos": "s = str(input())\na = len(s)%2==0\nb = s[0]==s[-1]\n\nif a ^ b:\n print('Second')\nelse:\n print('First')", "neg": "s = str(input())\nif ((len(s)%2) ^ (s[0] == s[-1])):\n print(\"Second\")\nelse:\n print(\"First\")", "jacc_sim": 0.9166666666666666, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [51, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u102445737", "n_user": "u102445737", "pos": "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ns = ins()\nif s=='ab':\n 3/0\nn = len(s)\nif s[0]==s[-1]:\n n += 1\nprint('Second' if n%2==0 else 'First')\n", "neg": "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ns = ins()\nif s=='aba':\n 3/0\nn = len(s)\nif s[0]==s[-1]:\n n += 1\nprint('Second' if n%2==0 else 'First')\n", "jacc_sim": 0.9672131147540983, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [183, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u242757684", "n_user": "u242757684", "pos": "a = input()\nn = len(a)\nif a[0] != a[-1]:\n n += 1\nif n % 2 == 0:\n print(\"First\")\nelse:\n print(\"Second\")", "neg": "a = input()\nn = len(a)\nif a[0] != a[-1]:\n n += 1\nif n % 2 == 0:\n print(\"Second\")\nelse:\n print(\"First\")", "jacc_sim": 1.0, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [50, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u047816928", "n_user": "u047816928", "pos": "# \u6587\u5b57\u304c2\u7a2e\u985e\u306b\u306a\u308b\u307e\u3067\u6e1b\u308b\n# 2\u7a2e\u985e\u306b\u306a\u3063\u305f\u3089\u7d42\u4e86\n# \u4e21\u7aef\u306e\u6587\u5b57\u304c\u9055\u3046\u306a\u3089\u305d\u306e2\u7a2e\u985e\u304c\u6b8b\u308b\u2192\u5076\u6570\u500b\u6b8b\u308b\n# \u4e21\u7aef\u306e\u6587\u5b57\u304c\u540c\u3058\u306a\u3089\u305d\u306e\u6587\u5b57+1\u7a2e\u2192\u5947\u6570\u500b\u6b8b\u308b\n\ns = input()\niseven = len(s)&1==0\nissame = s[0]==s[-1]\nprint('Second' if iseven^issame else 'First')", "neg": "# \u6587\u5b57\u304c2\u7a2e\u985e\u306b\u306a\u308b\u307e\u3067\u6e1b\u308b\n# 2\u7a2e\u985e\u306b\u306a\u3063\u305f\u3089\u7d42\u4e86\n# \u4e21\u7aef\u306e\u6587\u5b57\u304c\u9055\u3046\u306a\u3089\u305d\u306e2\u7a2e\u985e\u304c\u6b8b\u308b\u2192\u5076\u6570\u500b\u6b8b\u308b\n# \u4e21\u7aef\u306e\u6587\u5b57\u304c\u540c\u3058\u306a\u3089\u305d\u306e\u6587\u5b57+1\u7a2e\u2192\u5947\u6570\u500b\u6b8b\u308b\n\ns = input()\niseven = len(S)&1==0\nissame = S[0]==S[-1]\nprint('First' if iseven^issame else 'Second')", "jacc_sim": 0.9818181818181818, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [256, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u469254913", "n_user": "u469254913", "pos": "# import numpy as np\n# import math\nimport sys\ninput = sys.stdin.readline().rstrip\n\n\ndef main():\n s = list(input())\n N = len(s)\n\n if (N % 2 == 0) ^ (s[0] == s[-1]):\n print('Second')\n else:\n print('First')\n\n\nmain()\n", "neg": "# import numpy as np\n# import math\nimport sys\ninput = sys.stdin.readline\n\n\ndef main():\n s = list(input())\n N = len(s)\n\n if (N % 2 == 0) ^ (s[0] == s[-1]):\n print('Second')\n else:\n print('First')\n\n\nmain()\n", "jacc_sim": 0.9722222222222222, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [91, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u263933075", "n_user": "u476418095", "pos": "a = list(input())\nif a[0] == a[-1]:\n if len(a) % 2 == 1:\n print('Second')\n else:\n print('First')\nelse:\n if len(a) % 2 == 1: \n print('First')\n else:\n print('Second')", "neg": "a = list(input())\nif a[0] == a[-1]:\n if len(a) % 2 == 1:\n print('Second')\n else:\n print('First')\nelse:\n if len(s) % 2 == 1: \n print('First')\n else:\n print('Second')", "jacc_sim": 0.9545454545454546, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [76, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u623819879", "n_user": "u594956556", "pos": "s=input()\nn=len(s)%2==0\na=s[0]==s[-1]\nprint('Second' if a^n else 'First')", "neg": "s=input()\nn=len(s)\nif s[0]==s[-1] ^ n%2==0:\n print('Second')\nelse:\n print('First')", "jacc_sim": 0.9130434782608695, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [40, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u733321071", "n_user": "u733321071", "pos": "# -*- coding: utf-8\n\ns = input()\n\nif (s[0] == s[-1]) ^ (len(s) % 2 == 0):\n print('Second')\nelse:\n print('First')", "neg": "# -*- coding: utf-8\n\ns = input()\n\nif (s[0] == s[-1]) ^ (len(s) % 2 == 0):\n print('First')\nelse:\n print('Second')", "jacc_sim": 1.0, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [54, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u207056619", "n_user": "u657913472", "pos": "s=input()\nprint('First'if(s[0]==s[-1])!=bool(len(s)%2)else'Second')", "neg": "s=input()\nprint('Second'if(len(s)%2==0)!=(s[1]==s[-1])else'First')", "jacc_sim": 0.9523809523809523, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [35, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u268793453", "n_user": "u392319141", "pos": "S = input()\nprint('First' if (len(S) % 2 == \n0) == (S[0] == S[-1]) else 'Second')", "neg": "S = input()\nN = len(S)\n\nprint('First' if (N % 2 == 0) != (S[0] == S[-1]) else 'Second')\n", "jacc_sim": 0.9047619047619048, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [37, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u557171945", "n_user": "u690536347", "pos": "s = input()\nprint('First' if not (len(s)%2==0)^(s[0]==s[-1]) else 'Second')", "neg": "s=input()\nif len(s)%2==0^s[0]==s[-1]:\n print(\"Second\")\nelse:\n print(\"First\")", "jacc_sim": 0.9090909090909091, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [35, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u075012704", "n_user": "u075012704", "pos": "S = input()\nN = len(S)\n\nx = S[0]\ny = S[1]\nfor i in range(2, N):\n if i % 2 == 0:\n if S[i] != x:\n break\n else:\n if S[i] != y:\n break\nelse:\n print(\"Second\")\n exit()\n\nif S[0]==S[-1]:\n if N % 2 == 0:\n print(\"First\")\n else:\n print(\"Second\")\nelse:\n if N % 2 == 0:\n print(\"Second\")\n else:\n print(\"First\")\n", "neg": "S = input()\nN = len(S)\n\nx = S[0]\ny = S[1]\nfor i in range(2, N):\n if i % 2 == 0:\n if S[i] != x:\n break\n else:\n if S[i] != y:\n break\nelse:\n print(\"Second\")\n exit()\n\nif N % 2 == 0 and S[0]==S[-1]:\n print(\"First\")\nelif N % 2 == 1 and S[0]==S[-1]:\n print(\"Second\")\nelif N % 2 == 0:\n print(\"First\")\nelse:\n print(\"Second\")\n", "jacc_sim": 0.9393939393939394, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [154, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u257974487", "n_user": "u798316285", "pos": "s = input()\nl = len(s)\na = s[0]\nb = s[l-1]\n\nif l % 2 == 0:\n if a == b:\n print(\"First\")\n else:\n print(\"Second\")\nelse:\n if a == b:\n print(\"Second\")\n else:\n print(\"First\")\n", "neg": "s=input()\nl=len(s)\nif s[0]==s[-1]:\n if l%2=1:\n print(\"First\")\n else:\n print(\"Second\")\nelse:\n if l%2=0:\n print(\"First\")\n else:\n print(\"Second\")", "jacc_sim": 0.9130434782608695, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [86, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u425351967", "n_user": "u425351967", "pos": "s = input()\n\nb1 = bool(len(s)%2)\nb2 = ( s[0] == s[len(s)-1] )\n\nif b1 ^ b2:\n print(\"First\")\nelse:\n print(\"Second\")\n", "neg": "s = input()\n\nb1 = bool(len(s)%2)\nb2 = ( s[0] == s[len(s)-1] )\n\nif b1 ^ b2:\n print(\"Second\")\nelse:\n print(\"First\")\n", "jacc_sim": 1.0, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [62, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u455505352", "n_user": "u103178403", "pos": "s = input()\n\ns_len = len(s)\nif (s[0]==s[-1] and s_len%2==0) or (s[0]!=s[-1] and s_len%2==1):\n\tprint(\"First\")\nelse:\n\tprint(\"Second\")\n", "neg": "s=input()\nprint(\"Second\" if len(s)%2==0 and s[0]==s[-1] or len(s)%2!=0 and s[0]!=s[-1] else \"First\")", "jacc_sim": 0.9166666666666666, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [72, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u422104747", "n_user": "u623516423", "pos": "s=input()\nif (s[0]==s[-1] and len(s)%2==0) or (s[0]!=s[-1] and len(s)%2==1):\n print(\"First\")\nelse:\n print(\"Second\")", "neg": "s=input()\n\nif len(s)%2==0 and s[0]==s[-1]:\n print('Second')\nelse: \n print('First')", "jacc_sim": 0.9130434782608695, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [61, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u333917945", "n_user": "u258647915", "pos": "s = input()\n\nif s[0:1] == s[len(s)-1:len(s)]:\n if len(s) % 2 == 1:\n print(\"Second\")\n else:\n print(\"First\")\nelse:\n if len(s) % 2 == 1:\n print(\"First\")\n else:\n print(\"Second\")", "neg": "s = input()\nn = len(s)\nn -= 1\n\nprint(n)\nif s[0] == s[n-1]:\n print(\"First\" if (n % 2 == 0) else \"Second\")\nelse:\n print(\"First\" if (n % 2 == 1) else \"Second\")\n", "jacc_sim": 0.9523809523809523, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [86, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03863", "p_user": "u425448230", "n_user": "u218843509", "pos": "#D\ns = input()\nif s[0] == s[-1]:\n if len(s)%2==0:\n print(\"First\")\n else:\n print(\"Second\")\nelse:\n if len(s)%2==0:\n print(\"Second\")\n else:\n print(\"First\")", "neg": "s = input()\nif s[0] == s[-1]:\n if len(s) % 2 == 1:\n print(\"Second\")\n else:\n print(\"First\")\nelse:\n if len(s) % 2 == 0:\n print(\"First\")\n else:\n print(\"Second\")", "jacc_sim": 0.9090909090909091, "nl": "You are given a string \"s\" of length 3 or greater, with no neighboring characters being equal. Takahashi and Aoki play a game where they alternately remove characters from \"s\" (excluding both ends) without creating neighboring equal characters. The player unable to make a move loses. Determine the winner when both play optimally. Constraints: 3 \u2264 |s| \u2264 10^5, s consists of lowercase English letters, and no neighboring characters in s are equal. Input is given as \"s\" and the output should be \"First\" if Takahashi wins, \"Second\" if Aoki wins. Examples: Input: aba, Output: Second; Input: abc, Output: First; Input: abcab, Output: First.", "before_after_length": [77, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03878", "p_user": "u606045429", "n_user": "u606045429", "pos": "N,*E=map(int,open(0).read().split())\nE=sorted((e,2*(i=1:\n ans*=cnt\n ans%=mod\n cnt-=1\n else:\n cntb+=1\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "Score: 500 points\nProblem Statement:\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to only one computer. In how many ways can he minimize the total length of the cables? Compute the answer modulo 10^9+7.\nConstraints:\n1 \u2264 N \u2264 10^5\n0 \u2264 a_i, b_i \u2264 10^9\nThe coordinates are integers.\nThe coordinates are pairwise distinct.\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1\n:\na_N\nb_1\n:\nb_N\nOutput:\nPrint the number of ways to minimize the total length of the cables, modulo 10^9+7.\nSample Input 1:\n2\n0\n10\n20\n30\nSample Output 1:\n2\nThere are two optimal connections: 0-20, 10-30 and 0-30, 10-20. In both connections, the total length of the cables is 40.\nSample Input 2:\n3\n3\n10\n8\n7\n12\n5\nSample Output 2:\n1", "before_after_length": [168, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03878", "p_user": "u619819312", "n_user": "u619819312", "pos": "p=1\nm=10**9+7\ns=[0]*2\nn=int(input())\nq=sorted([[int(input()),i//n]for i in range(2*n)])\nfor i in q:\n if s[1-i[1]]==0:\n s[i[1]]+=1\n else:\n p=(p*s[1-i[1]])%m\n s[1-i[1]]-=1\nprint(p)", "neg": "p=1\ns=[0]*2\nn=int(input())\nq=sorted([[int(input()),i//n]for i in range(2*n)])\nfor i in q:\n if s[1-i[1]]==0:\n s[i[1]]+=1\n else:\n p*=s[1-i[1]]\n s[1-[i[1]]-=1\nprint(p%(10**9+7))", "jacc_sim": 0.9696969696969697, "nl": "Score: 500 points\nProblem Statement:\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to only one computer. In how many ways can he minimize the total length of the cables? Compute the answer modulo 10^9+7.\nConstraints:\n1 \u2264 N \u2264 10^5\n0 \u2264 a_i, b_i \u2264 10^9\nThe coordinates are integers.\nThe coordinates are pairwise distinct.\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1\n:\na_N\nb_1\n:\nb_N\nOutput:\nPrint the number of ways to minimize the total length of the cables, modulo 10^9+7.\nSample Input 1:\n2\n0\n10\n20\n30\nSample Output 1:\n2\nThere are two optimal connections: 0-20, 10-30 and 0-30, 10-20. In both connections, the total length of the cables is 40.\nSample Input 2:\n3\n3\n10\n8\n7\n12\n5\nSample Output 2:\n1", "before_after_length": [119, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03878", "p_user": "u054106284", "n_user": "u054106284", "pos": "N = int(input())\nL = []\nfor i in range(N):\n L.append((int(input()),'a'))\nfor i in range(N):\n L.append((int(input()),'b'))\nL.sort()\nres = 1\ncc = 0\nnowcol = None\nmo = 1000000007\nfor i in range(2*N):\n if cc == 0:\n nowcol=L[i][1]\n if nowcol == L[i][1]:\n cc += 1\n else:\n res *= cc\n res %= mo\n cc -= 1\nprint(res)\n", "neg": "N = int(input())\nL = []\nfor i in range(N):\n L.append((int(input),'a'))\nfor i in range(N):\n L.append((int(input),'b'))\nL.sort()\nres = 1\ncc = 0\nnowcol = None\nmo = 1000000007\nfor i in range(2*N):\n if cc == 0:\n nowcol=L[i][1]\n if nowcol == L[i][1]:\n cc += 1\n else:\n res *= cc\n res %= mo\n cc -= 1\nprint(res)", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to only one computer. In how many ways can he minimize the total length of the cables? Compute the answer modulo 10^9+7.\nConstraints:\n1 \u2264 N \u2264 10^5\n0 \u2264 a_i, b_i \u2264 10^9\nThe coordinates are integers.\nThe coordinates are pairwise distinct.\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1\n:\na_N\nb_1\n:\nb_N\nOutput:\nPrint the number of ways to minimize the total length of the cables, modulo 10^9+7.\nSample Input 1:\n2\n0\n10\n20\n30\nSample Output 1:\n2\nThere are two optimal connections: 0-20, 10-30 and 0-30, 10-20. In both connections, the total length of the cables is 40.\nSample Input 2:\n3\n3\n10\n8\n7\n12\n5\nSample Output 2:\n1", "before_after_length": [148, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03878", "p_user": "u236127431", "n_user": "u236127431", "pos": "N=int(input())\nC=[]\nfor i in range(N):\n C.append((int(input()),\"a\")) \nfor i in range(N):\n C.append((int(input()),\"b\")) \nC.sort()\nmod=10**9+7\na,b=0,0\nans=1\nfor c in C:\n if c[1]==\"a\":\n if b>0:\n ans=(ans*b)%mod\n b-=1\n else:\n a+=1\n if c[1]==\"b\":\n if a>0:\n ans=(ans*a)%mod\n a-=1\n else:\n b+=1\nprint(ans) \n ", "neg": "N=int(input())\nC=[]\nfor i in range(N):\n C.append((int(input()),\"a\")) \nfor i in range(N):\n C.append((int(input()),\"b\")) \nC.sort()\nmod=10**9+7\na,b=0,0\nans=1\nfor c in C:\n if c[1]==\"a\":\n if b>0:\n ans=(ans*b)%mod\n b-=1\n else:\n a+=1\n if c[1]==\"b\":\n if a>0:\n ans=(ans*a)%mod\n a-=1\n else:\n b+=1\n print(a,b,ans)\nprint(ans) \n ", "jacc_sim": 1.0, "nl": "Score: 500 points\nProblem Statement:\nThere are N computers and N sockets in a one-dimensional world. The coordinate of the i-th computer is a_i, and the coordinate of the i-th socket is b_i. It is guaranteed that these 2N coordinates are pairwise distinct. Snuke wants to connect each computer to a socket using a cable. Each socket can be connected to only one computer. In how many ways can he minimize the total length of the cables? Compute the answer modulo 10^9+7.\nConstraints:\n1 \u2264 N \u2264 10^5\n0 \u2264 a_i, b_i \u2264 10^9\nThe coordinates are integers.\nThe coordinates are pairwise distinct.\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1\n:\na_N\nb_1\n:\nb_N\nOutput:\nPrint the number of ways to minimize the total length of the cables, modulo 10^9+7.\nSample Input 1:\n2\n0\n10\n20\n30\nSample Output 1:\n2\nThere are two optimal connections: 0-20, 10-30 and 0-30, 10-20. In both connections, the total length of the cables is 40.\nSample Input 2:\n3\n3\n10\n8\n7\n12\n5\nSample Output 2:\n1", "before_after_length": [183, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03880", "p_user": "u754022296", "n_user": "u754022296", "pos": "n = int(input())\nA = [int(input()) for _ in range(n)]\nm = 30\nC = [False]*m\nx = 0\nfor a in A:\n x ^= a\n for i in range(m):\n if a>>i & 1:\n C[i] = True\n break\ntotal = 0\nans = 0\nfor i in range(m-1, -1, -1):\n if (x>>i & 1) ^ total:\n if C[i]:\n ans += 1\n total ^= 1\n else:\n print(-1)\n break\nelse:\n print(ans)", "neg": "n = int(input())\nA = [int(input()) for _ in range(n)]\nm = 30\nC = [False]*m\nx = 0\nfor a in A:\n x ^= a\n for i in range(m):\n if a>>i & 1:\n C[i] = True\ntotal = 0\nans = 0\nfor i in range(m):\n if (x>>i & 1) ^ total:\n if C[i]:\n ans += 1\n total ^= 1\n else:\n print(-1)\n break\nelse:\n print(ans)", "jacc_sim": 0.972972972972973, "nl": "In the game of Nim, a cheetah and a cheater take turns removing stones from piles. The cheater can eat zero or one stone from each pile before the game starts to ensure a win. Find the minimum number of stones the cheater must eat to guarantee a win, or print -1 if winning is impossible. The input consists of the number of piles and the number of stones in each pile. Output the minimum number of stones the cheater will eat.", "before_after_length": [152, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03880", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n n = int(input())\n a = [int(input()) for _ in [0]*n]\n xor = 0\n for i in a:\n xor ^= i\n i = 1\n cnt = 0\n while True:\n if xor >= i:\n i *= 2\n cnt += 1\n else:\n break\n ans = 0\n for i in range(cnt-1, -1, -1):\n j = (xor & 2**i) // (2**i)\n if j == 1:\n for k in a:\n if (k & 2**i) // (2**i) == 1 and k % (2**i) == 0:\n xor ^= k\n xor ^= k-1\n ans += 1\n a.remove(k)\n break\n else:\n print(-1)\n return 0\n print(ans)\n\n\nmain()", "neg": "def main():\n n = int(input())\n a = [int(input()) for _ in [0]*n]\n m = max(a)\n xor = 0\n for i in a:\n xor ^= i\n i = 1\n cnt = 0\n while True:\n if xor >= i:\n i *= 2\n cnt += 1\n else:\n break\n ans = 0\n for i in range(cnt-1, -1, -1):\n j = (xor & 2**i) // (2**i)\n if j == 1:\n for k in a:\n if k % (2**i) == 0:\n xor ^= k\n xor ^= k-1\n ans += 1\n a.remove(k)\n break\n else:\n print(-1/0)\n return 0\n print(ans)\n\n\nmain()", "jacc_sim": 0.9347826086956522, "nl": "In the game of Nim, a cheetah and a cheater take turns removing stones from piles. The cheater can eat zero or one stone from each pile before the game starts to ensure a win. Find the minimum number of stones the cheater must eat to guarantee a win, or print -1 if winning is impossible. The input consists of the number of piles and the number of stones in each pile. Output the minimum number of stones the cheater will eat.", "before_after_length": [219, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03880", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,*a=map(int,open(0))\nx=0\nc=[0]*30\nfor i in a:\n x^=i\n c[bin(i^i-1)[::-1].rfind('1')]=1\na=0\nfor i in range(29,-1,-1):\n if x&2**i:\n if c[i]:\n a+=1\n x^=2**i-1\n else:\n print(-1)\n break\nelse:\n print(a)", "neg": "n,*a=map(int,open(0))\nx=0\nc=[0]*30\nfor i in a:\n x^=i\n c[bin(i^i-1)[::-1].rfind('1')]=1\na=0\nfor i in range(29,-1,-1):\n if x&2**i:\n if c[i]:\n a+=1\n x^=2**i-1\n else:\n print(-1)\n break\nelse:\n print(a)", "jacc_sim": 1.0, "nl": "In the game of Nim, a cheetah and a cheater take turns removing stones from piles. The cheater can eat zero or one stone from each pile before the game starts to ensure a win. Find the minimum number of stones the cheater must eat to guarantee a win, or print -1 if winning is impossible. The input consists of the number of piles and the number of stones in each pile. Output the minimum number of stones the cheater will eat.", "before_after_length": [131, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u357751375", "n_user": "u357751375", "pos": "s = list(input())\nt = list(s[::-1])\nfor i in range(len(s)):\n if t[i] == 'b':\n t[i] = 'd'\n elif t[i] == 'd':\n t[i] = 'b'\n elif t[i] == 'p':\n t[i] = 'q'\n else:\n t[i] = 'p'\nif s == t:\n print('Yes')\nelse:\n print('No')", "neg": "s = list(input())\nt = list(s[::-1])\nfor i in range(len(s)):\n if t[i] == 'b':\n t[i] = 'd'\n if t[i] == 'd':\n t[i] = 'b'\n if t[i] == 'p':\n t[i] = 'q'\n else:\n t[i] = 'p'\nif s == t:\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9642857142857143, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [126, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u052499405", "n_user": "u052499405", "pos": "s = input().rstrip()\nn = len(s)\nif n % 2 == 1:\n print(\"No\")\n exit()\nfor a, b in zip(s[:n//2], s[::-1]):\n if a == \"p\" and b == \"q\":\n continue\n elif a == \"q\" and b == \"p\":\n continue\n elif a == \"b\" and b == \"d\":\n continue\n elif a == \"d\" and b == \"b\":\n continue\n else:\n print(\"No\")\n exit()\nprint(\"Yes\")", "neg": "s = input().rstrip()\nn = len(s)\nif n % 2 == 1:\n print(\"No\")\n exit()\nfor a, b in zip(s[n//2], s[::-1]):\n if a == \"p\" and b == \"q\":\n continue\n elif a == \"q\" and b == \"p\":\n continue\n elif a == \"b\" and b == \"d\":\n continue\n elif a == \"d\" and b == \"b\":\n continue\n else:\n print(\"No\")\n exit()\nprint(\"Yes\")", "jacc_sim": 1.0, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [140, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u399721252", "n_user": "u399721252", "pos": "s = list(input())\nt = s[::-1]\nfor i in range(len(t)):\n if t[i] == \"p\":\n t[i] = \"q\"\n elif t[i] == \"q\":\n t[i] = \"p\"\n if t[i] == \"b\":\n t[i] = \"d\"\n elif t[i] == \"d\":\n t[i] = \"b\" \nif s == t:\n ans = \"Yes\"\nelse:\n ans = \"No\"\nprint(ans)\n ", "neg": "s = list(input())\nt = s[::-1]\nfor i in t:\n if i == \"p\":\n i = \"q\"\n elif i == \"q\":\n i = \"p\"\n if i == \"b\":\n i = \"d\"\n elif i == \"d\":\n i = \"b\" \nif s == t:\n ans = \"Yes\"\nelse:\n ans = \"No\"\nprint(ans)\n ", "jacc_sim": 0.9310344827586207, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [141, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u623819879", "n_user": "u623819879", "pos": "b='b'\nd='d'\np='p'\nq='q'\nm=[(b,d),(p,q),(d,b),(q,p)]\nans='Yes'\ns=input()\nif len(s)%2==1:\n ans='No'\nelse:\n A=s[:len(s)//2]\n B=s[len(s)//2:]\n B=B[::-1]\n for i in range(len(s)//2):\n if (A[i],B[i]) in m:\n continue\n else:\n ans='No'\nprint(ans)", "neg": "\nb='b'\nd='d'\np='p'\nq='q'\nm=[(b,d),(p,q),(d,b),(q,p)]\nans='Yes'\ns=input()\nif len(s)%2==1:\n ans='No'\nelse:\n A=s[:len(s)//2]\n B=s[len(s)//2:]\n B=B[::-1]\n for i in range(len(s)//2):\n if (A[i],B[i]) in m:\n continue\n else:\n ans='NO'\nprint(ans)", "jacc_sim": 0.9714285714285714, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [155, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u807772568", "n_user": "u807772568", "pos": "n = list(input())\n\nif len(n) % 2 == 0:\n\tfor i in range(len(n)//2):\n\t\tif n[i] ==\"b\":\n\t\t\tif n[-(i+1)] != \"d\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"p\":\n\t\t\tif n[-(i+1)] != \"q\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"d\":\n\t\t\tif n[-(i+1)] != \"b\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"q\":\n\t\t\tif n[-(i+1)] != \"p\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "neg": "n = list(input())\n\nif n % 2 == 0:\n\tfor i in range(len(n)//2):\n\t\tif n[i] ==\"b\":\n\t\t\tif n[-(i+1)] != \"d\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"p\":\n\t\t\tif n[-(i+1)] != \"q\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"d\":\n\t\t\tif n[-(i+1)] != \"b\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telif n[i] == \"q\":\n\t\t\tif n[-(i+1)] != \"p\":\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "jacc_sim": 1.0, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [206, 203], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u596421790", "n_user": "u596421790", "pos": "s = input()\nif s[::-1].translate(str.maketrans(\"bdpq\",\"dbqp\")) == s:\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\nis s[::-1].translate(str.maketrans(\"bdpq\",\"dbqp\")) == s:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9166666666666666, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [47, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u128914900", "n_user": "u128914900", "pos": "s = input()\nss = s[::-1]\ns3 = \"\"\nfor i,j in enumerate(ss):\n if j == \"p\":\n s3 += \"q\"\n elif j == \"q\":\n s3 += \"p\"\n elif j == \"b\":\n s3 += \"d\"\n else:\n s3 += \"b\"\nif s == s3:\n print(\"Yes\")\nelse:\n print(\"No\")", "neg": "s = input()\nss = s[::-1]\nfor i,j in enumerate(ss):\n if j == \"p\":\n ss[i] = \"q\"\n elif j == \"q\":\n ss[i] = \"p\"\n elif j == \"b\":\n ss[i] = \"d\"\n else:\n ss[i] = \"b\"\nif ss == s:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 0.9333333333333333, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [110, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03889", "p_user": "u488497128", "n_user": "u488497128", "pos": "import sys\n\ndct = {\"b\": \"d\", \"d\": \"b\", \"p\": \"q\", \"q\": \"p\"}\nS = sys.stdin.readline().strip()\nrev = \"\"\nfor s in S[::-1]:\n rev += dct[s]\n\nif rev == S:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "neg": "import sys\n\ndct = {\"b\": \"d\", \"d\", \"b\", \"p\": \"q\", \"q\": \"p\"}\nS = sys.stdin.readline().strip()\nrev = \"\"\nfor s in S[::-1]:\n rev += dct[s]\n\nif rev == S:\n print(\"Yes\")\nelse:\n print(\"No\")", "jacc_sim": 1.0, "nl": "You are given a string S consisting of letters b, d, p, and q. Determine whether S is a mirror string. A mirror string is a string S such that reversing the order of the characters and simultaneously replacing each occurrence of b by d, d by b, p by q, and q by p results in the same string S. The input is given from Standard Input in the format of the string S. If S is a mirror string, print \"Yes\". Otherwise, print \"No\".", "before_after_length": [89, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03890", "p_user": "u491550356", "n_user": "u491550356", "pos": "N = int(input())\nA = [int(input()) for _ in range(2**N)]\n\nwhile len(A) > 1:\n B = []\n i = 0\n while i+1 < len(A):\n if A[i] == A[i+1]:\n B.append(A[i])\n else:\n B.append(abs(A[i] - A[i+1])) \n i += 2\n A = B\nprint(A[0])", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nwhile len(A) > 1:\n B = []\n i = 0\n while i < len(A):\n if A[i] == A[i+1]:\n B.append(A[i])\n else:\n B.append(abs(A[i] - A[i+1])) \n i += 2\n A = B\n\nprint(A[0])", "jacc_sim": 0.96875, "nl": "You are tasked with determining the eventual hardness of the last stone remaining in the annual Kode Festival contest. In this contest, 2^N stones with varying hardness levels participate in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the stone with the lower hardness is destroyed, and the hardness of the surviving stone is adjusted accordingly. This process continues until only one stone remains. Your task is to find the eventual hardness of the last remaining stone. The input consists of N and the hardness values of the participating stones, and the output should be the eventual hardness of the last stone. The constraints are 1 \u2264 N \u2264 18 and 1 \u2264 A_i \u2264 10^9, where A_i is an integer.", "before_after_length": [119, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03890", "p_user": "u064246852", "n_user": "u064246852", "pos": "N = int(input())\nA = []\nfor i in range(2**N):\n A.append(int(input()))\ni = 2**N\nwhile i > 1:\n i //= 2\n for j in range(i):\n l = 2*j\n r = 2*j+1\n if A[l] < A[r]:\n A[j] = A[r]-A[l]\n elif A[l] > A[r]:\n A[j] = A[l]-A[r]\n else:\n A[j] = A[r]\nprint(A[0])", "neg": "N = int(input())\nA = []\nfor i in range(2**N):\n A.append(int(input()))\ni = 2**N\nwhile i > 1:\n i //= 2\n for j in range(i):\n l = 2*j\n r = 2*j+1\n print(A[l], A[r])\n if A[l] < A[r]:\n A[j] = A[r]-A[l]\n elif A[l] > A[r]:\n A[j] = A[l]-A[r]\n else:\n A[j] = A[r]\nprint(A[0])", "jacc_sim": 0.9705882352941176, "nl": "You are tasked with determining the eventual hardness of the last stone remaining in the annual Kode Festival contest. In this contest, 2^N stones with varying hardness levels participate in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the stone with the lower hardness is destroyed, and the hardness of the surviving stone is adjusted accordingly. This process continues until only one stone remains. Your task is to find the eventual hardness of the last remaining stone. The input consists of N and the hardness values of the participating stones, and the output should be the eventual hardness of the last stone. The constraints are 1 \u2264 N \u2264 18 and 1 \u2264 A_i \u2264 10^9, where A_i is an integer.", "before_after_length": [152, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03890", "p_user": "u128914900", "n_user": "u128914900", "pos": "def setGroup(a):\n l = len(a)\n i = 0\n b = []\n while i < l:\n if a[i] < a[i+1]:\n b.append(a[i + 1] - a[i])\n elif a[i] > a[i+1]:\n b.append(a[i] - a[i+1])\n else:\n b.append(a[i])\n i += 2\n return b\n \nn = int(input())\ni = 0\na =[]\nwhile i < 2**n:\n a.append(int(input()))\n i += 1\nwhile len(a) > 1:\n a = setGroup(a)\nprint(a[0])", "neg": "def setGroup(a):\n l = len(a)\n i = 0\n b = []\n while i < l:\n if a[i] < a[i+1]:\n b.append(a[i + 1] - a[i])\n elif a[i] > a[i+1]:\n b.append(a[i] - a[i+1])\n else:\n b.append(a[i])\n i += 2\n return b\n \nn = int(input())\ni = 0\na =[]\nwhile i < 2**n:\n a.append(int(input()))\n i += 1\nwhile len(a) > 1:\n a = setGroup(a)\nprint(a)", "jacc_sim": 1.0, "nl": "You are tasked with determining the eventual hardness of the last stone remaining in the annual Kode Festival contest. In this contest, 2^N stones with varying hardness levels participate in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the stone with the lower hardness is destroyed, and the hardness of the surviving stone is adjusted accordingly. This process continues until only one stone remains. Your task is to find the eventual hardness of the last remaining stone. The input consists of N and the hardness values of the participating stones, and the output should be the eventual hardness of the last stone. The constraints are 1 \u2264 N \u2264 18 and 1 \u2264 A_i \u2264 10^9, where A_i is an integer.", "before_after_length": [183, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03890", "p_user": "u488497128", "n_user": "u488497128", "pos": "import sys\n\nN = int(sys.stdin.readline().strip())\n\narray = [None for _ in range(2**N)]\nfor i in range(int(2**N)):\n array[i] = int(sys.stdin.readline().strip())\n\nfor stage in range(N):\n for i in range(int(2**(N-stage-1))):\n tmp = abs(array[i*2] - array[i*2+1])\n array[i] = tmp if tmp != 0 else array[i*2]\n #print(array)\n\nprint(array[0])", "neg": "import sys\n\nN = int(sys.stdin.readline().strip())\n\narray = [None for _ in range(2**N)]\nfor i in range(int(2**N)):\n array[i] = int(sys.stdin.readline().strip())\n\nfor stage in range(N):\n for i in range(int(2**(N-stage-1))):\n tmp = abs(array[i*2] - array[i*2+1])\n array[i*2] = tmp if tmp != 0 else array[i*2]\n #print(array)\n\nprint(array[0])", "jacc_sim": 1.0, "nl": "You are tasked with determining the eventual hardness of the last stone remaining in the annual Kode Festival contest. In this contest, 2^N stones with varying hardness levels participate in a knockout tournament. When two stones with hardness X and Y are thrown at each other, the stone with the lower hardness is destroyed, and the hardness of the surviving stone is adjusted accordingly. This process continues until only one stone remains. Your task is to find the eventual hardness of the last remaining stone. The input consists of N and the hardness values of the participating stones, and the output should be the eventual hardness of the last stone. The constraints are 1 \u2264 N \u2264 18 and 1 \u2264 A_i \u2264 10^9, where A_i is an integer.", "before_after_length": [146, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03891", "p_user": "u461727381", "n_user": "u461727381", "pos": "a=int(input())\nb=int(input())\nc=int(input())\n\nli1=[a,b,3*c-a-b]\nli2=[4*c-2*a-b,c,2*a+b-2*c]\nli3=[a+b-c,2*c-b,2*c-a]\nprint(*li1)\nprint(*li2)\nprint(*li3)", "neg": "a=int(input())\nb=int(input())\nc=int(input())\n\nli1=[a,b,3*c-a-b]\nli2=[4*c-2*a-b,2*c-b,2*a+b-2*c]\nli3=[a+b-c,2*c-b,2*c-a]\nprint(*li1)\nprint(*li2)\nprint(*li3)", "jacc_sim": 1.0, "nl": "You are given a 3x3 grid with integers in each square. A magic square has the property that the sum of integers in each row, column, and diagonal is the same. Given integers A, B, and C at specific positions in the magic square, determine the remaining integers. Constraints: 0 \u2264 A, B, C \u2264 100. Input format: A, B, C. Output format: The integers in the magic square. Example input/output provided.", "before_after_length": [103, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03891", "p_user": "u143509139", "n_user": "u143509139", "pos": "a,b,c=[int(input()) for _ in range(3)]\ns=3*c\nprint(a,b,s-a-b)\nprint(2*s-2*a-b-2*c,c,2*a+b+c-s)\nprint(a+b+2*c-s,s-b-c,s-a-c)\n", "neg": "a,b,c=[input() for _ in range(3)]\ns=3*c\nprint(a,b,s-a-b)\nprint(2*s-2*a-b-2*c,c,2*a+b+c-s)\nprint(a+b+2*c-s,s-b-c,s-a-c)", "jacc_sim": 0.9545454545454546, "nl": "You are given a 3x3 grid with integers in each square. A magic square has the property that the sum of integers in each row, column, and diagonal is the same. Given integers A, B, and C at specific positions in the magic square, determine the remaining integers. Constraints: 0 \u2264 A, B, C \u2264 100. Input format: A, B, C. Output format: The integers in the magic square. Example input/output provided.", "before_after_length": [91, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03891", "p_user": "u796731633", "n_user": "u796731633", "pos": "a = int(input())\nb = int(input())\nc = int(input())\ns = 3 * c\n\nl = [\n [a, b, s-a-b],\n [2*s-2*a-b-2*c, c, 2*a+b+c-s],\n [a+b+2*c-s, s-b-c, s-a-c]\n]\n\nfor i in l:\n print(*i)", "neg": "a = int(input())\nb = int(input())\nc = int(input())\n\nl = [\n [a, b, -a-b],\n [-2*a-b-2*c, c, 2*a+b+c],\n [a+b+2*c, -b-c, -a-c]\n]\n\nfor i in l:\n print(*i)\n", "jacc_sim": 0.9130434782608695, "nl": "You are given a 3x3 grid with integers in each square. A magic square has the property that the sum of integers in each row, column, and diagonal is the same. Given integers A, B, and C at specific positions in the magic square, determine the remaining integers. Constraints: 0 \u2264 A, B, C \u2264 100. Input format: A, B, C. Output format: The integers in the magic square. Example input/output provided.", "before_after_length": [113, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03891", "p_user": "u969190727", "n_user": "u743614777", "pos": "a=int(input())\nb=int(input())\nc=int(input())\nprint(a,b,3*c-a-b)\nprint(4*c-2*a-b,c,-2*c+2*a+b)\nprint(a+b-c,2*c-b,2*c-a)", "neg": "a=int(input())\nb=int(input())\nc=int(input())\nprint(a,b,c)\nprint(a,b,-a-b+3*c)\nprint(-2*a-b+4*c,c,2*a+b-2*c)\nprint(a+b-c,-b+2*c,-a+2*c)", "jacc_sim": 1.0, "nl": "You are given a 3x3 grid with integers in each square. A magic square has the property that the sum of integers in each row, column, and diagonal is the same. Given integers A, B, and C at specific positions in the magic square, determine the remaining integers. Constraints: 0 \u2264 A, B, C \u2264 100. Input format: A, B, C. Output format: The integers in the magic square. Example input/output provided.", "before_after_length": [82, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03892", "p_user": "u883621917", "n_user": "u883621917", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\na, b, c, d = map(int, input().split())\n\nif a == c or b == d:\n print(0)\n sys.exit(0)\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nx = abs(a - c)\ny = abs(b - d)\n\n_gcd = gcd(x, y)\nx2 = x // _gcd\ny2 = y // _gcd\n\nimport math\n\nprint((x2 + y2 - 1) * _gcd)\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10 ** 7)\n\na, b, c, d = map(int, input().split())\n\nif a == c or b == d:\n print(0)\n sys.exit(0)\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nx = abs(a - c)\ny = abs(b - d)\n\n_gcd = gcd(x, y)\nx2 = x // _gcd\ny2 = y // _gcd\n\nimport math\n\nprint(x2, y2)\nprint((math.ceil(y2 / x2) * x2) * _gcd)\n", "jacc_sim": 0.9318181818181818, "nl": "Takahashi is drawing a segment on grid paper. Given two squares on the grid, find the number of squares crossed by the segment connecting the lower left corners of the two squares. The segment is said to cross a square if it has a non-empty intersection with the region within the square, excluding the boundary. The input consists of four integers A, B, C, and D, and the output should be the number of squares crossed by the segment. The constraints are 1 \u2264 A, B, C, D \u2264 10^9, and at least one of A \u2260 C and B \u2260 D holds.", "before_after_length": [171, 187], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03893", "p_user": "u754022296", "n_user": "u754022296", "pos": "print((4<= 1:\n t = s.index(\"snuke\")\n u = i\n break\n\nprint(chr(ord('A') + t) + str(u+1))", "neg": "h, w = map(int, input().split())\n\nA = []\nt = 0\nu = 0\nfor i in range(h):\n s = list(input().split())\n # t = s.index(\"snuke\")\n if s.count(\"snuke\") >= 1:\n t = s.index(\"snuke\")\n print(t)\n u = i\n break\n\nprint(chr(ord('A') + t) + str(u+1))", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [111, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u984276646", "n_user": "u984276646", "pos": "H, W = map(int, input().split())\nalpha = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nS = [list(map(str, input().split())) for _ in range(H)]\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"snuke\":\n print(\"{}{}\".format(alpha[j], i+1))\n", "neg": "H, W = map(int, input().split())\nalpha = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nS = [input() for _ in range(H)]\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"snuke\":\n print(\"{}{}\".format(i+1, alpha[j]))", "jacc_sim": 0.9411764705882353, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [101, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u386089355", "n_user": "u386089355", "pos": "h, w = map(int, input().split())\nls = [input().split() for _ in range(h)]\n\nfor i in range(h):\n\tfor j in range(w):\n\t\tif ls[i][j] == 'snuke':\n\t\t\tprint(chr(65 + j) + str(i + 1))\n\t\t\tbreak", "neg": "h, w = map(int, input().split())\nls = [input().split() for _ in range(h)]\n\nfor i in range(h):\n\tfor j in range(w):\n\t\tif ls[i][j] == 'snuke':\n\t\t\tprint(chr(65 + i) + str(j + 1))\n\t\t\tbreak", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [83, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u539517139", "n_user": "u539517139", "pos": "h,w=map(int,input().split())\ns=[list(input().split()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j]=='snuke':\n print(chr(ord('A')+j)+str(i+1))\n break", "neg": "h,w=map(int,input().split())\ns=[list(input().split()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j]=='snuke':\n print(chr(ord('A')+j) +str(i))\n break", "jacc_sim": 0.9696969696969697, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [81, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u277177960", "n_user": "u277177960", "pos": "H, W = map(int, input().split())\nM = [input().split() for _ in range(H)]\nfor i, r in enumerate(M):\n for j, c in enumerate(r):\n if c == 'snuke':\n print(\"%s%d\" %(chr(ord('A')+j), i+1))\n", "neg": "H, W = map(int, intput().split())\nM = [input().split() for _ in range(H)]\nfor i, r in enumerate(M):\n for j, c in enumerate(r):\n if c == 'snuke':\n print(\"%s%d\" %(chr(ord('A')+j), i))", "jacc_sim": 0.9459459459459459, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [81, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u268792407", "n_user": "u163320134", "pos": "h,w=map(int,input().split())\nalphabet = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"]\nfor i in range(h):\n s=list(map(str,input().split()))\n for j in range(w):\n if s[j]==\"snuke\":\n print(alphabet[j]+str(i+1))", "neg": "h,w=map(int,input().split())\ndisp=['A','B','C','D','E','F','G','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(1,h+1):\n arr=list(map(str,input().split()))\n for j in range(w):\n if arr[j]=='snuke':\n print(disp[j]+str(i))", "jacc_sim": 0.9122807017543859, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [128, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u878326845", "n_user": "u878326845", "pos": "a,b=map(int,input().split())\nls = list(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")\nx = [list(input().split()) for i in range(a)]\nfor i in range(a):\n for j in range(b):\n if x[i][j] == \"snuke\":\n print(ls[j]+str(i+1))\n break", "neg": "a,b=map(int,input().split())\nls = [\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"]\nx = [list(input().split()) for i in range(a)]\nfor i in range(a):\n for j in range(b):\n if x[a][b] == \"snuke\":\n print(ls[a]+str(b+1))\n break", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [96, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u503111914", "n_user": "u503111914", "pos": "import sys\nH,W = map(int,input().split())\nfor i in range(H):\n S = list(map(str,input().split()))\n for j in range(W):\n if S[j] == \"snuke\":\n print(chr(65+j)+str(i+1))\n sys.exit()\n ", "neg": "import sys\nH,W = map(int,input().split())\nfor i in range(H):\n S = list(map(str,input().split()))\n for j in range(W):\n if S[j] == \"snuke\":\n print(chr(65+i)+str(i+1))\n sys.exit()\n ", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [84, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u677523557", "n_user": "u677523557", "pos": "H, W = map(int, input().split())\nstate = [list(map(str, input().split())) for _ in range(H)]\n\nA = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor h in range(H):\n for w in range(W):\n if state[h][w] == 'snuke':\n ans = A[w] + str(h+1)\nprint(ans)\n", "neg": "H, W = map(int, input().split())\nstate = [list(map(str, input().split())) for _ in range(h)]\n\nA = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nfor h in range(H):\n for w in range(W):\n if state[h][w] == 'snuke':\n ans = A[w] + str(h+1)\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [105, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u727787724", "n_user": "u727787724", "pos": "h,w=map(int,input().split())\nS=[]\nans=0\nans1=0\nW=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(h):\n S.append(input().split())\nfor k in range(h):\n for j in range(w):\n if S[k][j]=='snuke':\n ans=j\n ans1=str(k+1)\nprint(W[ans]+ans1) ", "neg": "h,w=map(int,input().split())\nS=[]\nans=0\nans1=0\nW=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(h):\n S.append(input().split())\nfor k in range(h):\n for j in range(w):\n if S[k][j]=='snuke':\n ans=j\n ans1=str(k)\nprint(W[ans]+ans1) ", "jacc_sim": 0.9824561403508771, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [157, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u623349537", "n_user": "u623349537", "pos": "abc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nH, W = map(int, input().split())\nS = [[] for i in range(H)]\nfor i in range(H):\n S[i] = list(input().split())\n \nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"snuke\":\n print(abc[j] + str(i + 1))\n break", "neg": "abc = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\nH, W = map(int, input().split())\nS = [[] for i in range(H)]\nfor i in range(H):\n S[i] = list(input().split())\n \nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"Snuke\":\n print(abc[j] + str(i))\n break", "jacc_sim": 0.90625, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [114, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u787456042", "n_user": "u787456042", "pos": "from numpy import*;H,_=input().split();i,j=where(array([input().split()for _ in range(int(H))])==\"snuke\");print(chr(*j+65)+str(*i+1))", "neg": "from numpy import*;H,_=input().split();i,j=where(array([input().split()for _ in range(int(H))])==\"snuke\");print(chr(*j+65)+str(i*+1))", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [54, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u303059352", "n_user": "u303059352", "pos": "alph = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\na, b = map(int, input().split())\nfor i in range(a):\n c= input().split()\n for j in range(b):\n if c[j] == \"snuke\":\n print(alph[j] + str(i + 1))\n exit()\n", "neg": "alph = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\na, b = ap(int, input().split())\nfor i in range(a):\n for j in range(b):\n if input() == \"snuke\":\n print(alph[j] + str(i + 1))\n exit()", "jacc_sim": 0.9032258064516129, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [89, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u163320134", "n_user": "u163320134", "pos": "h,w=map(int,input().split())\ndisp=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(h):\n arr=list(map(str,input().split()))\n for j in range(w):\n if arr[j]=='snuke':\n print(disp[j]+str(i+1))", "neg": "h,w=map(int,input().split())\ndisp=['A','B','C','D','E','F','G','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(h):\n arr=list(map(str,input.split()))\n for j in range(w):\n if arr[j]=='snuke':\n print(disp[j]+str(i))", "jacc_sim": 0.9636363636363636, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [126, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u616522759", "n_user": "u864197622", "pos": "H, W = map(int, input().split())\nretsulist = [chr(i) for i in range(65, 65+26)]\nfor i in range(H):\n S = input().split()\n for j in range(W):\n if S[j] == 'snuke':\n print(retsulist[j] + str(i + 1))", "neg": "H, W = map(int, input().split())\nfor i in range(H):\n S = input(split())\n for j in range(W):\n if S[j] == \"snuke\":\n print(chr(65+j) + str(i+1))", "jacc_sim": 0.9354838709677419, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [88, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u580697892", "n_user": "u580697892", "pos": "#coding: utf-8\nH, W = map(int, input().split())\ntable = []\nfor _ in range(H):\n table.append(list(input().split()))\nalp = [chr(i) for i in range(65, 65+26)]\nfor i in range(H):\n for j in range(W):\n if table[i][j] == \"snuke\":\n print(alp[j] + str(i+1))\n break", "neg": "#coding: utf-8\nH, W = map(int, input().split())\ntable = []\nfor _ in range(H):\n table.append(list(input().split()))\nalp = [chr(i) for i in range(65, 65+26)]\nfor i in range(H):\n for j in range(W):\n if table[i][j] == \"snuke\":\n print(alp[j] + str(i))\n break", "jacc_sim": 0.975, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [115, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u932465688", "n_user": "u932465688", "pos": "H,W = map(int,input().split())\nL = []\nA = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nfor i in range(H):\n L.append(input().split())\nfor i in range(H):\n for j in range(W):\n if L[i][j] == 'snuke':\n k = i+1\n l = A[j]\n break\nprint(l+str(k))\n", "neg": "H,W = map(int,input().split())\nA = [list(input().split()) for i in range(H)]\nfor j in range(H):\n for k in range(W):\n if (A[j][k] == 'snuke'):\n break\nL = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']\nprint(L[k-1]+str(j))", "jacc_sim": 0.9285714285714286, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [150, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u785989355", "n_user": "u785989355", "pos": "\ndef itoa(i):\n if i==0:\n return \"a\"\n elif i==1:\n return \"b\"\n elif i==2:\n return \"c\"\n elif i==3:\n return \"d\"\n elif i==4:\n return \"e\"\n elif i==5:\n return \"f\"\n elif i==6:\n return \"g\"\n elif i==7:\n return \"h\"\n elif i==8:\n return \"i\"\n elif i==9:\n return \"j\"\n elif i==10:\n return \"k\"\n elif i==11:\n return \"l\"\n elif i==12:\n return \"m\"\n elif i==13:\n return \"n\"\n elif i==14:\n return \"o\"\n elif i==15:\n return \"p\"\n elif i==16:\n return \"q\"\n elif i==17:\n return \"r\"\n elif i==18:\n return \"s\"\n elif i==19:\n return \"t\"\n elif i==20:\n return \"u\"\n elif i==21:\n return \"v\"\n elif i==22:\n return \"w\"\n elif i==23:\n return \"x\"\n elif i==24:\n return \"y\"\n elif i==25:\n return \"z\"\n\n\nH,W = list(map(int,input().split()))\nS = []\nfor i in range(H):\n S.append(input().split())\n\nfor i in range(H):\n for j in range(W):\n if S[i][j]==\"snuke\":\n print(itoa(j).upper()+str(i+1))\n ", "neg": "\ndef itoa(i):\n if i==0:\n return \"a\"\n elif i==1:\n return \"b\"\n elif i==2:\n return \"c\"\n elif i==3:\n return \"d\"\n elif i==4:\n return \"e\"\n elif i==5:\n return \"f\"\n elif i==6:\n return \"g\"\n elif i==7:\n return \"h\"\n elif i==8:\n return \"i\"\n elif i==9:\n return \"j\"\n elif i==10:\n return \"k\"\n elif i==11:\n return \"l\"\n elif i==12:\n return \"m\"\n elif i==13:\n return \"n\"\n elif i==14:\n return \"o\"\n elif i==15:\n return \"p\"\n elif i==16:\n return \"q\"\n elif i==17:\n return \"r\"\n elif i==18:\n return \"s\"\n elif i==19:\n return \"t\"\n elif i==20:\n return \"u\"\n elif i==21:\n return \"v\"\n elif i==22:\n return \"w\"\n elif i==23:\n return \"x\"\n elif i==24:\n return \"y\"\n elif i==25:\n return \"z\"\n\n\n\nH,W = list(map(int,input().split()))\nS = []\nfor i in range(H):\n S.append(list(map(int,input().split())))\n\nfor i in range(H):\n for j in range(W):\n if S[i][j]==\"snuke\":\n print(itoa(j).upper()+str(i))\n break", "jacc_sim": 0.9880952380952381, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [437, 444], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u782441844", "n_user": "u782441844", "pos": "H,W = map(int,input().split())\nL = [list(map(str,input().split())) for i in range(H)]\nA = [chr(i) for i in range(ord(\"A\"),ord(\"Z\")+1)]\nfor y in range(H) :\n for x in range(W) :\n if L[y][x] == \"snuke\" :\n ans = A[x]+str(y+1)\n print(ans)\n ", "neg": "H,W = map(int,input().split())\nL = [list(map(str,input().split())) for i in range(H)]\nA = [chr(i) for i in range(ord(\"A\"),ord(\"Z\")+1)]\nfor y in range(H) :\n for x in range(W) :\n if L[y][x] == \"snuke\" :\n ans = A[y]+str(x+1)\n print(ans)\n exit()\n ", "jacc_sim": 0.9714285714285714, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [116, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03909", "p_user": "u506127000", "n_user": "u506127000", "pos": "from string import ascii_uppercase\nH, W = [int(i) for i in input().split()]\nS = [input().split() for _ in range(H)]\nfor h in range(H):\n for w in range(W):\n if S[h][w] == \"snuke\":\n print(\"{}{}\".format(ascii_uppercase[w], h+1))\n", "neg": "from string import ascii_uppercase\nH, W = [int(i) for i in input().split()]\nS = [input().split() for _ in range(H)]\nfor h in range(H):\n for w in range(W):\n if S[h][w] == \"snuke\":\n print(\"{}{}\".format(ascii_uppercase[w], h))\n", "jacc_sim": 0.9411764705882353, "nl": "Score: 100 points\nProblem Statement:\nThere is a grid with H rows and W columns. Each square at the i-th row and j-th column contains a string S_{i,j} of length 5. Rows are labeled 1 to H, and columns are labeled A to the W-th letter of the alphabet. Find the square containing the string \"snuke\" and report its location (e.g., 6th row and 8th column as H6).\n\nConstraints:\n1\u2266H, W\u226626\nThe length of S_{i,j} is 5.\nS_{i,j} consists of lowercase English letters (a-z).\nExactly one of the given strings is equal to \"snuke\".\n\nInput:\nThe input is given from Standard Input in the format:\nH W\nS_{1,1} S_{1,2} ... S_{1,W}\nS_{2,1} S_{2,2} ... S_{2,W}\n:\nS_{H,1} S_{H,2} ... S_{H,W}\n\nOutput:\nPrint the labels of the row and the column of the square containing the string \"snuke\", with no space in between.\n\nSample Input 1:\n15 10\nsnake snake snake snake snake snake snake snake snake snake\nsnake snake snake snake snake snake snake snake snake snake\n... (repeated)\nsnake snake snake snake snake snake snake snake snake snake\n\nSample Output 1:\nH6\n\nSample Input 2:\n1 1\nsnuke\n\nSample Output 2:\nA1", "before_after_length": [93, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u348293370", "n_user": "u348293370", "pos": "n = int(input())\nscore = 0\ni = 0\nans_list = []\n\nwhile score < n:\n i += 1\n score += i\n ans_list.append(i)\n\nif score == n:\n for k in range(len(ans_list)):\n print(ans_list[k])\nelse:\n ans_list.remove(score - n)\n for k in range(len(ans_list)):\n print(ans_list[k])", "neg": "n = int(input())\nscore = 0\ni = 0\nans_list = []\n\nwhile score < n:\n i += 1\n score += i\n ans_list.append(i)\n\n\nans_list.remove(score - n)\nfor k in range(len(ans_list)):\n print(ans_list[k])", "jacc_sim": 0.9310344827586207, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [117, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u368796742", "n_user": "u368796742", "pos": "n = int(input())\nnow = 0\nfor i in range(1,n+2):\n now += i\n if now >= n:\n x = now-n\n for j in range(1,i+1):\n if j != x:\n print(j)\n exit()", "neg": "n = int(input())\nnow = 0\nfor i in range(1,n):\n now += i\n if now >= n:\n x = now-n\n for j in range(1,i+1):\n if j != x:\n print(j)\n exit()", "jacc_sim": 0.96, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [71, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u054514819", "n_user": "u054514819", "pos": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\ncnt = 0\ns = set()\nfor i in range(1, N+1):\n cnt += i\n s.add(i)\n if cnt>=N:\n break\nif N!=cnt:\n s.remove(cnt-N)\n\nfor i in s:\n print(i)", "neg": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\ncnt = 0\ns = set()\nfor i in range(1, N):\n cnt += i\n s.add(i)\n if cnt>=N:\n break\nif N!=cnt:\n s.remove(cnt-N)\n\nfor i in s:\n print(i)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [124, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u781262926", "n_user": "u781262926", "pos": "class BisectSearch:\n def __init__(self, f, l=0, r=10**9):\n self.f = f\n self.l = l\n self.r = r\n def __call__(self, dist):\n f = self.f\n l = self.l\n r = self.r\n if dist <= f(l):\n return l\n if f(r) <= dist:\n return r\n while r-l > 1:\n n = (r+l) // 2\n if f(n) <= dist:\n l = n\n else:\n r = n\n return l\n\nn = int(input())\ndef f(n):\n return (n+1)*n // 2\nm = BisectSearch(f, l=1, r=10**7)(n)\nm += f(m) != n\nA = set(range(1, m+1))\nA.discard(f(m) - n)\nprint(*A, sep='\\n')", "neg": "class BisectSearch:\n def __init__(self, f, l=0, r=10**9):\n self.f = f\n self.l = l\n self.r = r\n def __call__(self, dist):\n f = self.f\n l = self.l\n r = self.r\n if dist <= f(l):\n return l\n if f(r) <= dist:\n return r\n while r-l > 1:\n n = (r+l) // 2\n if f(n) <= dist:\n l = n\n else:\n r = n\n return l\n\nn = int(input())\ndef f(n):\n return (n+1)*n // 2\nm = BisectSearch(f, l=1, r=10**7)(n)\nm += f(m) != n\nA = set(range(1, m+1))\nA.remove(f(m) - n)\nprint(*A, sep='\\n')", "jacc_sim": 0.9574468085106383, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [246, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u506910932", "n_user": "u506910932", "pos": "n = int(input())\nif n == 1 or n == 2:\n print(n)\n exit()\n\nnow = 0\nans = []\nfor i in range(1, n):\n now += i\n ans.append(i)\n if now >= n:\n break\n\namari = now - n\n\nfor i in ans:\n if i == amari:\n continue\n else:\n print(i)\n", "neg": "n = int(input())\nnow = 0\nans = []\nfor i in range(1, n):\n now += i\n ans.append(i)\n if now >= n:\n break\n\namari = now - n\n\nfor i in ans:\n if i == amari:\n continue\n else:\n print(i)\n", "jacc_sim": 0.90625, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [105, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u597455618", "n_user": "u597455618", "pos": "n = int(input())\nans = []\ncnt = 0\nfor i in range(1, int(n**0.7)+3):\n if n > cnt:\n ans.append(i)\n cnt += i\n else:\n if cnt - n in ans:\n ans.remove(cnt - n)\n break\nfor i in ans:\n print(i)", "neg": "n = int(input())\nans = []\ncnt = 0\nfor i in range(1, int(n**(2/3))):\n if n > cnt:\n ans.append(i)\n cnt += i\n else:\n if cnt - n in ans:\n ans.remove(cnt - n)\n break\nfor i in ans:\n print(i)", "jacc_sim": 0.9090909090909091, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [90, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u453642820", "n_user": "u453642820", "pos": "N=int(input())\nans=0\nreject=0\nA=[]\nfor i in range(1,N+1):\n ans+=i\n if ans>=N:\n reject=ans-N\n for j in range(1,i+1):\n if j!=reject:\n print(j)\n break", "neg": "N=int(input())\nans=0\nreject=0\nA=[]\nfor i in range(1,N+1):\n ans+=i\n if ans>N:\n reject=ans-N\n for j in range(1,i+1):\n if j!=reject:\n print(j)\n break", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [81, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u485319545", "n_user": "u485319545", "pos": "n=int(input())\n\nans=[1]\ni=1\ns=1\nwhile True:\n if s>=n:\n break\n i+=1\n s+=i\n ans.append(i)\n\ndif = s-n\nif dif==0:\n for i in range(len(ans)):\n print(ans[i])\n exit(0)\n\nfor i in range(len(ans)):\n if ans[i]==dif:\n continue\n print(ans[i])\n\n\n", "neg": "n=int(input())\n\nans=[1]\ni=1\ns=1\nwhile True:\n if s>=n:\n break\n i+=1\n s+=i\n ans.append(i)\n\ndif = s-n\nif dif==0:\n for i in range(len(ans)):\n print(ans[i])\n exit(0)\n \nfor i in range(len(ans)):\n if a[i]==dif:\n continue\n print(ans[i])\n\n\n", "jacc_sim": 0.96875, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [130, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u830054172", "n_user": "u830054172", "pos": "N = int(input())\n\nif N <= 2:\n print(N)\nelse:\n s = 0\n l = []\n for i in range(1, N):\n s += i\n l.append(i)\n if s > N:\n break\n # print(l)\n\n for i in range(len(l)):\n if s-l[i] == N:\n l.pop(i)\n break\n\n for i in l:\n print(i)\n", "neg": "N = int(input())\n\ns = 0\nl = []\nfor i in range(1, N):\n s += i\n l.append(i)\n if s > N:\n break\n# print(l)\n\nfor i in range(len(l)):\n if s-l[i] == N:\n l.pop(i)\n break\n\nfor i in l:\n print(i)\n", "jacc_sim": 0.90625, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [124, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u153094838", "n_user": "u153094838", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jun 12 20:20:11 2020\n\n@author: NEC-PCuser\n\"\"\"\n\n\nN = int(input())\n\ni = 1\nli = []\nwhile (N >= (i * (i + 1)) // 2):\n li.append(i)\n i += 1\n \n\nvalue = (i - 1) * i // 2\n\nindex = len(li) - 1\nfor i in range(value, N):\n li[index] += 1\n index -= 1\n\nfor i in li:\n print(i)", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Jun 12 20:20:11 2020\n\n@author: NEC-PCuser\n\"\"\"\n\n\nN = int(input())\n\ni = 1\nli = []\nwhile (N >= (i * (i + 1)) // 2):\n li.append(i)\n i += 1\n \n\nvalue = (i - 1) * i // 2\nprint(value)\n\nindex = len(li) - 1\nfor i in range(value, N):\n li[index] += 1\n index -= 1\n\nfor i in li:\n print(i)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [149, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u616252029", "n_user": "u616252029", "pos": "n=int(input())\ns=0\nl=[]\nfor i in range(1,n+1):\n s+=i\n l.append(i)\n if s>=n:\n for j in l:\n if j!=s-n:\n print(j)\n break", "neg": "n=int(input())\ns=0\nl=[]\nfor i in\u3000range(1,n+1):\n s+=i\n l.append(i)\n if s>=n:\n for j in l:\n if j!=s-n:\n print(j)\n break", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [71, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u489124637", "n_user": "u489124637", "pos": "#import itertools\n#import bisect\nimport math\n\nN = int(input())\nL = [i for i in range((N+2)//2+2)]\nnum = math.floor(pow(2*(N-1),0.5))\n \nfor i in range(num,len(L)):\n if N == i*(i+1)//2:\n index = i\n Max = i*(i+1)//2\n break\n elif N < i*(i+1)//2:\n index = i\n Max = i*(i+1)//2\n break\nLeft = Max - N \n#print(num,Left,Max,index,L)\n#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))\n#print(acu) \n#index = bisect.bisect_left(acu,N)\n#print(index)\n \n#if acu[index] == N:\n# Max = acu[index-1]\n#else:\n# Max = acu[index]\n#Left = Max - N\n\nfor i in range(1,index+1):\n if i == Left:\n continue\n print(i)", "neg": "#import itertools\n#import bisect\nimport math\n\nN = int(input())\nL = [i for i in range((N+1)//2+1)]\nnum = math.ceil(pow(2*(N-1),0.5))\n \nfor i in range(num,len(L)):\n if N == i*(i+1)//2:\n index = i\n Max = i*(i+1)//2\n break\n elif N < i*(i+1)//2:\n index = i\n Max = i*(i+1)//2\n break\nLeft = Max - N \n \n#acu = list(itertools.accumulate([i for i in range((N+1)//2+2)]))\n#print(acu) \n#index = bisect.bisect_left(acu,N)\n#print(index)\n\nLeft = Max - N \n#if acu[index] == N:\n# Max = acu[index-1]\n#else:\n# Max = acu[index]\n#Left = Max - N\n\nfor i in range(1,index+1):\n if i == Left:\n continue\n print(i)", "jacc_sim": 0.9583333333333334, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [296, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u801049006", "n_user": "u801049006", "pos": "n = int(input())\n\ns = 0\ni = 0\nwhile s < n:\n s += i\n i += 1\n\nif i == 1:\n print(1)\nelse:\n ans = list(range(1,i))\n if s - n != 0: ans.remove(s-n)\n print('\\n'.join(map(str,ans)))\n", "neg": "n = int(input())\n\ns = 0\ni = 0\nwhile s < n:\n s += i\n i += 1\n\nif i == 1:\n print(1)\n exit()\nans = list(range(1,i))\nans.remove(s-n)\nprint('\\n'.join(map(str,ans)))\n", "jacc_sim": 0.9032258064516129, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [92, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u183840468", "n_user": "u183840468", "pos": "n = int(input())\ndef main(n):\n if n == 1:\n return 2,0\n \n if n == 3:\n return 3,0\n m = n //2 \n for i in range(1,m+1):\n if i * (i + 1) <= 2*n < (i+1)*(i+2):\n right = i + 1\n break\n \n diff = right * (right+1) //2 - n\n \n return right+1,diff\n\n\nright,diff = main(n)\n\nfor i in range(1,right):\n if i != diff:\n print(i)\n \n ", "neg": "n = int(input())\ndef main(n):\n if n == 1:\n return 1,0\n m = n //2 \n for i in range(1,m+1):\n if i * (i + 1) <= 2*n <= (i+1)*(i+2):\n right = i + 1\n break\n \n diff = right * (right+1) //2 - n\n \n return right+1,diff\n\n\nright,diff = main(n)\n\nfor i in range(1,right):\n if i != diff:\n print(i)\n", "jacc_sim": 0.967741935483871, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [162, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u408375121", "n_user": "u408375121", "pos": "n = int(input())\nk = 1\nwhile True:\n if k*(k+1)//2 >= n:\n ans = k\n break\n k += 1\nif n == ans*(ans+1)//2:\n i = 1\n while i <= ans:\n print(i)\n i += 1\nelse:\n i = 1\n l = []\n cnt = 1\n while i < ans:\n if cnt <= (ans-1)*(ans+2)//2 - n:\n print(i)\n cnt += 1\n else:\n print(i+1)\n i += 1\n \n\n", "neg": "n = int(input())\nk = 1\nwhile True:\n if k*(k+1)//2 >= n:\n ans = k\n break\n k += 1\nif n == k*(k+1)//2:\n i = 1\n while i <= ans:\n print(i)\n i += 1\nelse:\n i = 1\n l = []\n cnt = 0\n while i < ans:\n if cnt <= (ans-1)*(ans+2)//2 - n:\n print(i)\n cnt += 1\n else:\n print(i+1)\n i += 1\n \n\n", "jacc_sim": 0.9655172413793104, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [154, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u103902792", "n_user": "u103902792", "pos": "n = int(input())\nr = 10**7+1\nl = 1\n\ndef f(n):\n return (n**2+n)//2\n\nwhile r-l> 1:\n if f((l+r)//2)>n:\n r = (l+r)//2\n else:\n l = (l+r)//2\n\nl = l+1\nrm = (l+1)*l//2-n\nans = list(range(1, l+1))\nans.remove(rm)\nfor a in ans:\n print(a)\n\n", "neg": "n = int(input())\nr = 10**7+1\nl = 1\n\ndef f(n):\n return n**2+n\n\nwhile r-l>1:\n if f((l+r)//2)>n:\n r = (l+r)//2\n else:\n l = (l+r)//2\nl = l+1\nrm = (l+1)*l//2-n\nans = list(range(1, l+1))\nans.remove(rm)\nfor a in ans:\n print(a)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [141, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u430247423", "n_user": "u430247423", "pos": "# CODE FESTIVAL 2016 Final\n# B - Exactly N points\n# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b\nN = int(input())\nfor i in range(1, N+1):\n if i*(i+1)//2 >= N:\n k = i\n break\n\n\nS = k*(k+1)//2\nsub = S-N\nfor i in range(1, k+1):\n if i == sub:\n continue\n print(i)\n1\n", "neg": "# CODE FESTIVAL 2016 Final\n# B - Exactly N points\n# https://atcoder.jp/contests/cf16-final/tasks/codefestival_2016_final_b\nN = int(input())\nfor i in range(1, N):\n if i*(i+1)//2 >= N:\n k = i\n break\n\nS = k*(k+1)//2\nsub = S-N\nfor i in range(1, k+1):\n if i == sub:\n continue\n print(i)\n", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [136, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u813174766", "n_user": "u813174766", "pos": "n=int(input())\ni=0\nwhile i*(i+1)//2= N:\n end = i\n break\nres = ans - N\nfor i in range(1, end+1):\n if i != res:\n print(i)", "neg": "# coding: utf-8\nN = int(input())\nif N == 1:\n print(1)\n exit()\nans = 0\nfor i in range(1, N+1):\n ans += i\n if ans >= N:\n end = i\n break\nres = ans - N\nfor i in range(1, end):\n if i != res:\n print(i)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [96, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u857428111", "n_user": "u857428111", "pos": "import math\nN=int(input())\np=math.sqrt(N*2-0.25)-0.5\nq=int(p)+1\nM=q*(q+1)//2\nL=M-N#must0or+\nfor i in range(1,q+1):\n if i != L:\n print(i)", "neg": "import math\nN=int(input())\np=math.sqrt(N*2-0.25)-0.5\nq=int(p)+1\nM=q*(q+1)//2\nL=M-N#must0or+\nfor i in range(q+1):\n if i != L:\n print(i)", "jacc_sim": 0.9705882352941176, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [82, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u089142196", "n_user": "u089142196", "pos": "N=int(input())\nk=1\n\nfor i in range(1,N+1):\n if i*(i+1)//2 >= N:\n k=i\n break\n \nc = int(k*(k+1)//2 - N)\n\nfor j in range(1,k+1):\n if j!=c:\n print(j)", "neg": "N=int(input())\n\nfor i in range(1,N):\n if i*(i+1)//2 >= N:\n break\n \nc = i*(i+1)//2 - N\n\nfor j in range(1,i+1):\n if j!=c:\n print(j)", "jacc_sim": 0.9615384615384616, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [90, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u878326845", "n_user": "u878326845", "pos": "n = int(input())\nfor i in range(1,n+2):\n if i*(i+1)//2 > n:\n x = i\n y = i*(i+1)//2 - n\n break\nfor i in range(1,x+1):\n if i != y:\n print(i)", "neg": "n = int(input())\nfor i in range(1,n):\n if i*(i+1)//2 > n:\n x = i\n y = i*(i+1)//2 - n\n break\nfor i in range(1,x+1):\n if i != y:\n print(i)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [79, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u879309973", "n_user": "u276204978", "pos": "def solve(n):\n score = 0\n for p in range(1, n+1):\n score += p\n if score >= n:\n break\n x = score - n\n res = list(range(1,x)) + list(range(x+1,p+1))\n return \"\\n\".join(map(str, res))\n\nn = int(input())\nprint(solve(n))", "neg": "def solve():\n N = int(input())\n score = 0\n for i in range(1, n+1):\n score += i\n if score >= n:\n break\n x = score - n\n res = list(range(1, x)) + list(range(x+1, i+1))\n return '\\n'.join(map(str, res))\n \nprint(solve())", "jacc_sim": 0.9142857142857143, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [99, 97], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u945181840", "n_user": "u945181840", "pos": "from itertools import accumulate\nfrom math import sqrt\nfrom bisect import bisect_left\n\nN = int(input())\nn = list(accumulate(range(int(sqrt(2 * N)) + 2)))\n\nr = bisect_left(n, N)\n\nif n[r] == N:\n print('\\n'.join(map(str, range(1, r + 1))))\n exit()\n\nd = n[r] - N\nfor i in range(1, r + 1):\n if i != d:\n print(i)", "neg": "from itertools import accumulate\nfrom math import sqrt, floor\nfrom bisect import bisect_left\n\nN = int(input())\nn = list(accumulate(range(floor(sqrt(2 * N)) + 1)))\n\nr = bisect_left(n, N)\n\nif n[r] == N:\n print('\\n'.join(map(str, range(1, r + 1))))\n exit()\n\nd = n[r] - N\nfor i in range(1, r + 1):\n if i != d:\n print(i)", "jacc_sim": 0.9761904761904762, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [128, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u141574039", "n_user": "u141574039", "pos": "N=int(input())\nS=[1]\nfor i in range(1,N):\n S.append(S[i-1]+i+1)\np=0\nj=0\nif N==1:\n print(1)\nelse:\n while N>=S[j]:\n j += 1\n p=S[j]-N\n for i in range(1,j+2):\n if i!=p:\n print(i)", "neg": "N=int(input())\nS=[1]\nfor i in range(1,N):\n S.append(S[i-1]+i+1)\np=0\nj=0\nwhile N>=S[j]:\n j += 1\np=S[j]-N\nfor i in range(1,j+2):\n if i!=p:\n print(i)", "jacc_sim": 0.9666666666666667, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [112, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u779455925", "n_user": "u779455925", "pos": "N=int(input())\nlst=set()\nnum=0\nfor i in range(1,N+1):\n lst.add(i)\n num+=i\n if num>=N:\n if num==N:\n break\n else:\n lst.remove(num-N)\n break\nfor s in lst:\n print(s)\n", "neg": "N=int(input())\nN=10**7\nlst=set()\nnum=0\nfor i in range(1,N+1):\n lst.add(i)\n num+=i\n if num>=N:\n if num==N:\n break\n else:\n lst.remove(num-N)\n break\nfor s in lst:\n print(s)\n", "jacc_sim": 0.9032258064516129, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [89, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u296150111", "n_user": "u296150111", "pos": "n=int(input())\nfor i in range(n+1):\n\tif i**2+i>=2*n:\n\t\tp=i\n\t\tbreak\ntotal=(p*(p+1))//2\nfor i in range(1,p+1):\n\tif total-n!=i:\n\t\tprint(i)", "neg": "n=int(input())\nfor i in range(n):\n\tif i**2+i>=2*n:\n\t\tp=i\n\t\tbreak\ntotal=(p*(p+1))//2\nfor i in range(1,p+1):\n\tif total-n!=i:\n\t\tprint(i)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [80, 78], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u598229387", "n_user": "u598229387", "pos": "n=int(input())\n\n\nif n==1:\n print(1)\n exit()\n \nif n==2:\n print(2)\n exit()\n \nfor i in range(n):\n if i+i**2>=2*n:\n check=i\n\n break\n\ntotal=(1+check)*check//2\nout=total-n\n\nfor i in range(1,check+1):\n if i!=out:\n print(i)\n", "neg": "n=int(input())\n\nfor i in range(n):\n if i+i**2>=2*n:\n check=i\n break\n\ntotal=(1+check)*check//2\nout=total-n\n\nfor i in range(1,check+1):\n if i!=out:\n print(i)\n", "jacc_sim": 0.9629629629629629, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [120, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u156743806", "n_user": "u156743806", "pos": "import math\nN=int(input())\nM=int(math.sqrt(N*2-0.25)+0.5)\nleft = M*(M-1) // 2\nsum_=0\nfor i in range(1,M-(N-left)):\n print(i)\n sum_ += i\nfor i in range(M-(N-left),M):\n print(i+1)\n sum_ += i+1", "neg": "import math\nN=int(input())\nM=int(math.sqrt(N*2-0.25)+0.5)\nleft = M*(M-1) // 2\nsum_=0\nfor i in range(1,M-(N-left)):\n print(i)\n sum_ += i\nfor i in range(M-(N-left),M):\n print(i+1)\n sum_ += i+1\nprint(sum_)", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [105, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u335540120", "n_user": "u335540120", "pos": "N = int(input())\n\nans_max = 0\nwhile ans_max * (ans_max + 1) / 2 < N:\n ans_max += 1\n\nnum_remove = ans_max * (ans_max + 1) // 2 - N\nfor i in range(1, ans_max + 1):\n if i != num_remove:\n print(i)\n", "neg": "N = int(input())\n\nans_max = 0\nwhile ans_max * (ans_max + 1) / 2 < N:\n ans_max += 1\n\nnum_remove = ans_max - N\nfor i in range(1, ans_max + 1):\n if i != num_remove:\n print(i)\n", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [89, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u077291787", "n_user": "u077291787", "pos": "# cf16-finalB - Exactly N points\ndef main():\n # N <= cnt (1 + 2 + ... + ma) -> 1 ~ ma except ex\n N = int(input())\n cnt, ma = 0, 0\n for i in range(1, N + 1):\n cnt += i\n if cnt >= N:\n ma = i\n break\n ex = cnt - N # exclusion\n ans = [i for i in range(1, ma + 1) if i != ex]\n print(*ans, sep=\"\\n\")\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# cf16-finalB - Exactly N points\ndef main():\n # N <= cnt (1 + 2 + ... + ma) -> 1 ~ ma except ex\n N = int(input())\n cnt, ma = 0, 0\n for i in range(1, N):\n cnt += i\n if cnt >= N:\n ma = i\n break\n ex = cnt - N # exclusion\n ans = [i for i in range(1, ma + 1) if i != ex]\n print(*ans, sep=\"\\n\")\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [145, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u438160204", "n_user": "u438160204", "pos": "import math\nN=int(input())\nfor i in range(int(math.sqrt(N)) , int(math.sqrt(2*N+1))+100):\n if (i*(i+1))//2 >= N:\n ansmax=i\n dif=(i*(i+1))//2 - N\n break\n\nfor j in range(1,ansmax+1):\n if j!=dif:\n print(j)", "neg": "import math\nN=int(input())\nfor i in range(int(math.sqrt(N)) , int(math.sqrt(2*N))+1):\n if (i*(i+1))//2 >= N:\n ansmax=i\n dif=(i*(i+1))//2 - N\n\nfor j in range(1,ansmax+1):\n if j!=dif:\n print(j)", "jacc_sim": 0.9354838709677419, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [105, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u941753895", "n_user": "u941753895", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n N=II()\n\n i=1\n l=[i]\n sm=i\n while True:\n if sm==N:\n break\n elif sm>N:\n l.remove(sm-N)\n break\n else:\n i+=1\n l.append(i)\n sm+=i\n\n for x in l:\n print(x)\n\nmain()\n# print(main())\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf=10**20\nmod=10**9+7\n\ndef LI(): return list(map(int,input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\ndef main():\n N=II()\n if N==1:\n exit()\n\n i=1\n l=[i]\n sm=i\n while True:\n if sm==N:\n break\n elif sm>N:\n l.remove(sm-N)\n break\n else:\n i+=1\n l.append(i)\n sm+=i\n\n for x in l:\n print(x)\n\nmain()\n# print(main())\n", "jacc_sim": 0.9841269841269841, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [209, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03910", "p_user": "u623819879", "n_user": "u623819879", "pos": "n=int(input())\nfor i in range(int((2*n)**0.5-3),n+2):\n if i*(i+1)//2==n:\n for j in range(1,i+1):\n print(j)\n break\n elif i*(i+1)//2>n:\n k=i*(i+1)//2-n\n for j in range(1,i+1):\n if j!=k:\n print(j)\n break", "neg": "n=int(input())\nfor i in range((2*n)**0.5-3,n**0.5+2):\n if i*(i+1)//2=n:\n for j in range(1,i+1):\n print(j)\n break\n elif i*(i+1)//2>n:\n k=i*(i+1)//2-n\n for j in range(1,i+1):\n ifr j!=k:\n print(j)\n break", "jacc_sim": 0.967741935483871, "nl": "Takahashi is participating in a contest with N problems, each worth i points. He aims to score exactly N points by choosing problems to solve. To minimize the highest score of a problem solved, he needs to determine the set of problems to solve. Constraints: 1 \u2264 N \u2264 10^7. For a partial score, 200 points are awarded for N \u2264 1000, and an additional 100 points for passing without constraints. Given N, find a set of problems with a total score of N, where the highest score of a problem is minimum, and print the indices of the problems in the set. If multiple sets exist, any will be accepted.", "before_after_length": [123, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03921", "p_user": "u619819312", "n_user": "u619819312", "pos": "import sys\nsys.setrecursionlimit(10**9)\nn,m=map(int,input().split())\na=[[]for i in range(n+m)]\nfor i in range(n):\n s=list(map(int,input().split()))\n for j in s[1:]:\n a[i].append(j+n-1)\n a[n+j-1].append(i)\nt=[False]*(n+m)\ndef g(x):\n t[x]=True\n for i in a[x]:\n if not t[i]:\n g(i)\ng(0)\nif all(t[:n]):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "neg": "import sys\nsys.setrecursionlimit(10**6)\nn,m=map(int,input().split())\na=[[]for i in range(n+m)]\nfor i in range(n):\n s=list(map(int,input().split()))\n for j in s[1:]:\n a[i].append(j)\n a[n+j].append(i)\nt=[False]*n\ndef g(x):\n if not t[x]:\n t[x]=False:\n for i in a[x]:\n for j in a[i+n]:\n g(j)\ng(0)\nif all(t):\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 0.9166666666666666, "nl": "You are given a scenario on a distant planet where there are M languages and N participants for a CODE FESTIVAL. Each participant can speak a certain number of languages. Participants can communicate if they share a language or if they can communicate through a third participant. The task is to determine if all participants can communicate with each other. Constraints are provided for N, M, and the number of languages spoken by each participant. The input consists of N lines, each containing the number of languages a participant speaks and the corresponding language numbers. The output should be \"YES\" if all participants can communicate with each other, and \"NO\" otherwise. Sample inputs and outputs are provided for illustration.", "before_after_length": [177, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03921", "p_user": "u297574184", "n_user": "u297574184", "pos": "# Union-Find\u30c7\u30fc\u30bf\u69cb\u9020\nclass UnionFind:\n def __init__(self, numV):\n self.pars = list(range(numV))\n self.ranks = [0] * numV\n def find(self, x):\n if self.pars[x] == x: return x\n else:\n self.pars[x] = self.find(self.pars[x])\n return self.pars[x]\n def union(self, x, y):\n x, y = self.find(x), self.find(y)\n if x == y: return\n if self.ranks[x] < self.ranks[y]:\n self.pars[x] = y\n else:\n self.pars[y] = x\n if self.ranks[x] == self.ranks[y]:\n self.ranks[x] += 1\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\nN, M = map(int, input().split())\nUF = UnionFind(N+M)\nfor i in range(N):\n K, *Ls = map(int, input().split())\n for L in Ls:\n UF.union(i, L+N-1)\n\npars = [UF.find(i) for i in range(N)]\nprint('YES' if len(set(pars)) == 1 else 'NO')\n", "neg": "# Union-Find\u30c7\u30fc\u30bf\u69cb\u9020\nclass UnionFind:\n def __init__(self, numV):\n self.pars = list(range(numV))\n self.ranks = [0] * numV\n def find(self, x):\n if self.pars[x] == x: return x\n else:\n self.pars[x] = self.find(self.pars[x])\n return self.pars[x]\n def union(self, x, y):\n x, y = self.find(x), self.find(y)\n if x == y: return\n if self.ranks[x] < self.ranks[y]:\n self.pars[x] = y\n else:\n self.pars[y] = x\n if self.ranks[x] == self.ranks[y]:\n self.ranks[x] += 1\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\nN, M = map(int, input().split())\nUF = UnionFind(N+M)\nfor i in range(N):\n K, *Ls = map(int, input().split())\n for L in Ls:\n UF.union(i, L+N-1)\n\npars = [UF.find(i) for i in range(N)]\nprint('YES' if len(set(pars)) else 'NO')\n", "jacc_sim": 1.0, "nl": "You are given a scenario on a distant planet where there are M languages and N participants for a CODE FESTIVAL. Each participant can speak a certain number of languages. Participants can communicate if they share a language or if they can communicate through a third participant. The task is to determine if all participants can communicate with each other. Constraints are provided for N, M, and the number of languages spoken by each participant. The input consists of N lines, each containing the number of languages a participant speaks and the corresponding language numbers. The output should be \"YES\" if all participants can communicate with each other, and \"NO\" otherwise. Sample inputs and outputs are provided for illustration.", "before_after_length": [362, 360], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03921", "p_user": "u785205215", "n_user": "u785205215", "pos": "from sys import stdin, stdout\ndef readLine_int_list():return list(map(int, stdin.readline().split()))\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n \ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x==y: return\n if rank[x]=2:\n ans*=d[a[i]-1]-1\n else:\n ch+=1\n break\n elif d[a[i]]==2:\n d[a[i]]=3\n if a[i]-1 not in d:\n ch+=1\n break\n else:\n if d[a[i]-1]>=3:\n ans*=1\n else:\n ch+=1\n break\n else:\n ch+=1\n break\n \n ans=(ans%mod)\n \nif ch==0:\n print(ans)\nelse:\n print(0)\n\n\n", "neg": "n=int(input())\na=list(map(int,input().split()))\n\nans=1\n\nd={}\n\nch=0\n\nmod=10**9+7\n\nfor i in range(n):\n if a[i]==0:\n if 0 not in d:\n d[0]=1\n ans*=3\n else:\n if d[0]==1:\n d[0]=2\n ans*=2\n elif:\n d[0]=3\n else:\n ch+=1\n break\n \n else:\n if a[i] not in d:\n d[a[i]]=1\n if a[i]-1 not in d:\n ch+=1\n break\n else:\n ans*=d[a[i]-1]\n else:\n if d[a[i]]==1:\n d[a[i]]=2\n if a[i]-1 not in d:\n ch+=1\n break\n else:\n if d[a[i]-1]>=2:\n ans*=d[a[i]-1]-1\n else:\n ch+=1\n break\n elif:\n d[a[i]]=3\n if a[i]-1 not in d:\n ch+=1\n break\n else:\n if d[a[i]-1]>=3:\n ans*=1\n else:\n ch+=1\n break\n else:\n ch+=1\n break\n \n ans=(ans%mod)\n \nif ch==0:\n print(ans)\nelse:\n print(0)\n\n", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [439, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u617515020", "n_user": "u617515020", "pos": "P=10**9+7\nN=int(input())\nA=list(map(int, input().split()))\nans=1\nc=[0,0,0]\nfor i in range(N):\n a,f,k=A[i],-1,0\n for j in range(3):\n if c[j]==a:\n k+=1\n if f==-1:\n c[j]+=1\n f=j\n ans=(ans*k)%P\nprint(ans)", "neg": "N=int(input())\nA=list(map(int, input().split()))\nans=1\nc=[0,0,0]\nfor i in range(N):\n a,f,k=A[i],-1,0\n for j in range(3):\n if c[j]==a:\n k+=1\n if f==-1:\n c[j]+=1\n f=j\n ans*=k%(10**9+7)\nprint(ans)", "jacc_sim": 0.9736842105263158, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [126, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u267718666", "n_user": "u267718666", "pos": "N = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\nG = [0]*3\nans = 1\nfor i in range(N):\n x = 0\n cnt = 0\n for j, g in enumerate(G):\n if g == A[i]:\n x = j if cnt == 0 else x\n cnt += 1\n \n G[x] += 1\n ans *= cnt\n ans = ans % mod\n\nprint(ans)", "neg": "N = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\nG = [0]*3\nans = 1\nfor i in range(N):\n x = 0\n cnt = 0\n for j, g in enumerate(G):\n if g == A[i]:\n x = j if cnt == 0 else x\n cnt += 1\n \n G[x] += 1\n ans *= cnt\n ans = ans % mod\n print(i, G)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [121, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u428199834", "n_user": "u428199834", "pos": "n=int(input())\na=list(map(int,input().split()))\na_=max(a)\ncon=[0]*(a_+1)\ntou=[0]*(a_+1)\nans=[]\nfor i in range(len(a)):\n u=a[i]\n if u==0:\n con[0]+=1\n tou[0]+=1\n ans.append(4-con[0])\n\n else:\n con[u]+=1 \n tou[u]+=1 \n ans.append(min(tou[u-1]-con[u]+1,4-con[u]))\nc=1\nfor i in range(len(ans)):\n c*=ans[i]\n c=c%(10**9+7)\nprint(c%(10**9+7)) \n\n", "neg": "n=int(input())\na=list(map(int,input().split()))\na_=max(a)\ncon=[0]*(a_+1)\ntou=[0]*(a_+1)\nans=[]\nfor i in range(len(a)):\n u=a[i]\n if u==0:\n con[0]+=1\n tou[0]+=1\n ans.append(4-con[0])\n\n else:\n con[u]+=1 \n tou[u]+=1 \n ans.append(min(tou[u-1],4-con[u]))\nc=1\nfor i in range(len(ans)):\n c*=ans[i]\nprint(c%(10**9+7)) \nprint(ans) ", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [209, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u285891772", "n_user": "u285891772", "pos": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nN = INT()\nA = LIST()\n\nans = 1\ncnt = [0, 0, 0]\nfor i in range(N):\n\tans = ans * cnt.count(A[i]) % mod\n\tif A[i] in cnt:\n\t\tcnt[cnt.index(A[i])] += 1\n\telse:\n\t\tprint(0)\n\t\texit()\n\nprint(ans)", "neg": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nN = INT()\nA = LIST()\n\ncnt = [0]*(max(A)+2)\ncnt[0] = 3\nans = 1\nfor a in A:\n\tprint(cnt)\n\tans *= cnt[a] - cnt[a+1]\n\tcnt[a+1] += 1\n\tans %= mod\n\nprint(ans)", "jacc_sim": 0.9035087719298246, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [347, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u665873062", "n_user": "u665873062", "pos": "N = int(input())\nA = list(map(int,input().split()))\nC = [0,0,0]\nAns = 1\nMOD = 1000000007\nfor a in A:\n ask = C.count(a)\n if ask==0:\n Ans=0\n break\n ind = C.index(a)\n C[ind] += 1\n Ans = (Ans*ask)%MOD\nprint(Ans)\n", "neg": "N = int(input())\nA = list(map(int,input().split()))\nC = [0,0,0]\nAns = 1\nMOD = 1000000007\nfor a in A:\n ask = C.count(a)\n if ask==0:\n Ans=0\n break\n ind = C.index(a)\n C[ind] += 1\n Ans = (Ans*ask)%MOD\n print(C)\nprint(Ans)\n", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [111, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u896741788", "n_user": "u896741788", "pos": "def f():\n n=int(input())\n l=[0,0,0]\n ans=1\n mod=10**9+7\n for i in list(map(int,input().split())):\n if i not in l:print(0);exit()\n ans=ans*l.count(i)%mod\n l[l.index(i)]+=1\n print(ans)\nif __name__ == \"__main__\":f()", "neg": "def f():\n\tn=int(input())\n l=[0,0,0]\n ans=1\n mod=10**9+7\n for i in list(map(int,input().split())):\n if i not in l:print(0);exit()\n ans=ans*l.count(i)%mod\n l[l.index(i)]+=1\n print(ans)\nif _name__==\"__main__\":f()", "jacc_sim": 0.9512195121951219, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [111, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u089142196", "n_user": "u089142196", "pos": "N=int(input())\nA=list(map(int,input().split()))\np=1000000007\n\n\nR=[0]\nG=[0]\nB=[0]\n\n#print(A)\nans=1\nfor i in range(N):\n tmp=0\n if A[i]==R[-1]:\n tmp+=1\n if A[i]==G[-1]:\n tmp+=1\n if A[i]==B[-1]:\n tmp+=1\n ans = (ans*tmp)%p\n\n if A[i]==R[-1]:\n R.append(R[-1]+1)\n G.append(G[-1])\n B.append(B[-1])\n elif A[i]==G[-1]:\n R.append(R[-1])\n G.append(G[-1]+1)\n B.append(B[-1])\n else:\n R.append(R[-1])\n G.append(G[-1])\n B.append(B[-1]+1)\n \n#print(R)\n#print(G)\n#print(B)\nprint(ans)", "neg": "N=int(input())\nA=list(map(int,input().split()))\np=1000000007\n\n\nR=[0]\nG=[0]\nB=[0]\n\n#print(A)\nans=1\nfor i in range(N):\n if A[i]==R[-1]:\n tmp+=1\n if A[i]==G[-1]:\n tmp+=1\n if A[i]==B[-1]:\n tmp+=1\n ans = (ans*tmp)%p\n\n if A[i]==R[-1]:\n R.append(R[-1]+1)\n G.append(G[-1])\n B.append(B[-1])\n elif A[i]==G[-1]:\n R.append(R[-1])\n G.append(G[-1]+1)\n B.append(B[-1])\n else:\n R.append(R[-1])\n G.append(G[-1])\n B.append(B[-1]+1)\n tmp=0\n \n#print(R)\n#print(G)\n#print(B)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [282, 282], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u995004106", "n_user": "u995004106", "pos": "N=int(input())\nA=list(map(int,input().split()))\nl=[[] for _ in range(3)]\nans=1\np=10**9+7\nflag=1\nfor i in range(N):\n cnt=0\n piv=A[i]\n ind=[]\n for j in range(3):\n if len(l[j])==piv:\n cnt=cnt+1\n ind.append(j)\n if len(ind)==0:\n flag=0\n break\n l[ind[0]].append(piv)\n ans=(ans*cnt)%p\n #print(l,ans)\n #input()\nif flag==1:\n print(ans%p)\nelse:\n print(flag)\n\n", "neg": "N=int(input())\nA=list(map(int,input().split()))\nl=[[] for _ in range(3)]\nans=1\np=10**9+7\nflag=1\nfor i in range(N):\n cnt=0\n piv=A[i]\n ind=[]\n for j in range(3):\n if l[j]==piv:\n cnt=cnt+1\n ind.append(j)\n if len(ind)==0:\n flag=0\n break\n l[ind[0]].append(piv)\n ans=(ans*cnt)%p\n #print(l,ans)\n #input()\nif flag==1:\n print(ans%p)\nelse:\n print(flag)\n\n", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [192, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u784022244", "n_user": "u784022244", "pos": "N=int(input())\nA=list(map(int, input().split()))\nmod=10**9+7\nif A[0]!=0:\n print(0)\n exit()\nL=[1,0,0]\nans=3\nfor i in range(1,N):\n a=A[i]\n count=0\n add=True\n for j,l in enumerate(L):\n if a==l:\n count+=1\n if add:\n L[j]+=1\n add=False\n\n ans*=count\n ans%=mod\nprint(ans)\n#print(L)\n", "neg": "N=int(input())\nA=list(map(int, input().split()))\nmod=10**9+7\nif A[0]!=0:\n print(0)\n break\nL=[1,0,0]\nans=3\nfor i in range(1,N):\n a=A[i]\n count=0\n add=True\n for j,l in enumerate(L):\n if a==l:\n count+=1\n if add:\n L[j]+=1\n add=False\n\n ans*=count\n ans%=mod\nprint(ans)\n#print(L)\n", "jacc_sim": 0.9555555555555556, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [156, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u373047809", "n_user": "u373047809", "pos": "_, a = open(0)\nmod = 10**9+7\nc = 1\nl = [3] + [0]*10**6\n\nfor a in a.split():\n a = int(a)\n c = c * l[a] % mod\n l[a] -= 1\n l[a+1] += 1\nprint(c)", "neg": "_, *a = open(0)\nmod = 10**9+7\nc = 1\nl = [3] + [0]*10**6\n\nfor a in a.split():\n a = int(a)\n c = c * l[a] % mod\n d[a] -= 1\n d[a] += 1\nprint(c)", "jacc_sim": 0.967741935483871, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [85, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u010090035", "n_user": "u010090035", "pos": "n=int(input())\na=list(map(int,input().split()))\nMOD=1000000007\nhats=[0,0,0]\nans=1\nfor i in range(n):\n ai=a[i]\n ans=((ans%MOD)*hats.count(ai))%MOD\n if(ans==0):\n break\n hats[hats.index(ai)]+=1\n# print(ai,ans,hats)\nprint(ans%MOD)\n", "neg": "n=int(input())\na=list(map(int,input().split()))\nMOD=1000000007\nhats=[0,0,0]\nans=1\nfor i in range(n):\n ai=a[i]\n ans=((ans%MOD)*hats.count(ai))%MOD\n if(ans==0):\n break\n hats[hats.index(ai)]+=1\n print(ai,ans,hats)\nprint(ans%MOD)\n", "jacc_sim": 0.9714285714285714, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [120, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u977193988", "n_user": "u977193988", "pos": "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(10 ** 9)\n\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n RGB = [1, 0, 0]\n ans = 1\n if A[0] !=0:\n print(0)\n return\n for i in range(1, N):\n a = A[i]\n if a == 0:\n if 0 in RGB:\n j = RGB.index(a)\n RGB[j] += 1\n else:\n print(0)\n return\n elif a not in RGB:\n print(0)\n return\n else:\n k = RGB.count(a)\n ans *= k\n ans %= MOD\n j = RGB.index(a)\n RGB[j] += 1\n z = RGB.count(0)\n if z == 0:\n ans *= 6\n ans %= MOD\n elif z == 1:\n ans *= 6\n ans %= MOD\n else:\n ans *= 3\n ans %= MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(10 ** 9)\n\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n RGB = [1, 0, 0]\n ans = 1\n for i in range(1, N):\n a = A[i]\n if a == 0:\n j = RGB.index(a)\n RGB[j] += 1\n\n elif a in RGB:\n print(0)\n return\n else:\n k = RGB.count(a)\n ans *= k\n ans %= MOD\n j = RGB.index(a)\n RGB[j] += 1\n z = RGB.count(0)\n if z == 0:\n ans *= 6\n ans %= MOD\n elif z == 1:\n ans *= 6\n ans %= MOD\n else:\n ans *= 3\n ans %= MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9642857142857143, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [310, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u345966487", "n_user": "u345966487", "pos": "import itertools\nimport sys\nfrom collections import Counter\n\nsys.setrecursionlimit(10 ** 9)\nM = 1000000007\nN = int(sys.stdin.readline())\nleft = list(map(int, sys.stdin.read().split()))\ncounter = Counter(left)\n\n\ndef dp(t, ns):\n cached = t.get(ns)\n if cached is not None:\n return cached\n remaining = sum(ns)\n assert remaining > 0\n last_cnt = left[remaining - 1] + 1\n n1, n2, n3 = ns\n res = 0\n if last_cnt == n1:\n res += dp(t, tuple(sorted([n1 - 1, n2, n3])))\n res %= M\n if last_cnt == n2:\n res += dp(t, tuple(sorted([n1, n2 - 1, n3])))\n res %= M\n if last_cnt == n3:\n res += dp(t, tuple(sorted([n1, n2, n3 - 1])))\n res %= M\n # print(f\"{remaining}: ({n1},{n2},{n3}) => {res}\")\n t[ns] = res\n return res\n\n\ndef solve():\n h = [0, 0, 0]\n for i in range(N):\n k = counter[i]\n if k == 3:\n h[0] = h[1] = h[2] = i + 1\n elif k == 2:\n h[0] = h[1] = i + 1\n elif k == 1:\n h[0] = i + 1\n else:\n break\n if sum(h) != N:\n return 0\n t = dict()\n t[0, 0, 0] = 1\n res = dp(t, tuple(sorted(h)))\n return (res * len(set(itertools.permutations(h)))) % M\n\n\nprint(solve())\n", "neg": "import itertools\nimport sys\nfrom collections import Counter\n\nsys.setrecursionlimit(10 ** 9)\ninput = sys.stdin.readline\nM = 1000000007\nN = int(input())\nleft = list(map(int, input().split()))\n#assert len(left) == N\n#assert left[0] == 0\n\ncounter = Counter(left)\n\n\ndef dp(t, ns):\n cached = t.get(ns)\n if cached is not None:\n return cached\n remaining = sum(ns)\n #assert remaining > 0\n last_cnt = left[remaining - 1] + 1\n n1, n2, n3 = ns\n res = 0\n if last_cnt == n1:\n res += dp(t, tuple(sorted([n1 - 1, n2, n3])))\n res %= M\n if last_cnt == n2:\n res += dp(t, tuple(sorted([n1, n2 - 1, n3])))\n res %= M\n if last_cnt == n3:\n res += dp(t, tuple(sorted([n1, n2, n3 - 1])))\n res %= M\n print(f\"{remaining}: ({n1},{n2},{n3}) => {res}\")\n t[ns] = res\n return res\n\n\ndef solve():\n h = [0, 0, 0]\n for i in range(N):\n k = counter[i]\n if k == 3:\n h[0] = h[1] = h[2] = i + 1\n elif k == 2:\n h[0] = h[1] = i + 1\n elif k == 1:\n h[0] = i + 1\n else:\n break\n #assert sum(h) == N\n t = dict()\n t[0, 0, 0] = 1\n res = dp(t, tuple(sorted(h)))\n return res * len(set(itertools.permutations(h))) % M\n\n\nprint(solve())\n", "jacc_sim": 0.9629629629629629, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [479, 492], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u969190727", "n_user": "u969190727", "pos": "import sys\ninput=lambda: sys.stdin.readline().rstrip()\n\nn=int(input())\nA=[int(i) for i in input().split()]\nans=1\nmod=10**9+7\nC=[0,0,0]\nfor i in range(n):\n cur=A[i]\n ct=0\n Chk=True\n for i,c in enumerate(C):\n if cur==c:\n ct+=1\n if Chk:\n C[i]+=1\n Chk=False\n ans=(ans*ct)%mod\n \nprint(ans)\n", "neg": "import sys\ninput=lambda: sys.stdin.readline().rstrip()\n\nn=int(input())\nA=[int(i) for i in input().split()]\nans=1\nmod=10**9+7\nC=[0,0,0]\nfor i in range(1,n):\n cur=A[i]\n ct=0\n Chk=True\n for i,c in enumerate(C):\n if cur==c:\n ct+=1\n if Chk:\n C[i]+=1\n Chk=False\n ans=(ans*ct)%mod\n \nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [150, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u644516473", "n_user": "u644516473", "pos": "import sys\n\nreadline = sys.stdin.buffer.readline\nn = int(readline())\nA = map(int, readline().split())\nmod = 1000000007\n\ncaps = [0] * 3\nans = 1\nfor a in A:\n ans *= caps.count(a)\n # caps[caps.index(a)] += 1\n for i in range(3):\n if caps[i] == a:\n caps[i] += 1\n break\n ans %= mod\nprint(ans)\n", "neg": "import sys\n\nreadline = sys.stdin.buffer.readline\nn = int(readline())\nA = map(int, readline().split())\nmod = 1000000007\n\ncaps = [0] * 3\nans = 1\nfor a in A:\n ans *= caps.count(a)\n ans %= mod\n for i in range(3):\n if caps[i] == a:\n caps[i] += 1\nprint(ans)\n", "jacc_sim": 0.9230769230769231, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [123, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u358254559", "n_user": "u358254559", "pos": "n = int(input())\na = list(map(int, input().split()))\nfrom collections import defaultdict\nd = defaultdict(int)\n\nans=1\nfor num in a:\n if num==0:\n ans*= (3 - d[0])\n else:\n ans*= (d[num-1] - d[num])\n\n ans%=1000000007\n d[num]+=1\n\nprint(ans)", "neg": "n = int(input())\na = list(map(int, input().split()))\nfrom collections import defaultdict\nd = defaultdict(int)\n\nans=1\nfor num in a:\n if num==0:\n ans*= (3 - d[0])\n else:\n ans*= (d[num-1] - d[num])\n\n ans*=tmp\n ans%=1000000007\n d[num]+=1\n\nprint(ans)", "jacc_sim": 0.9722222222222222, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [106, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u852690916", "n_user": "u852690916", "pos": "N = int(input())\nA = list(map(int,input().split()))\n\nMOD = 1000000007\n\n#\u8272\u3054\u3068\u306e\u4eba\u6570\nC=[0,0,0]\nans=1\nfor a in A:\n #\u4eba\u6570\u304c\u4e00\u81f4\u3059\u308b\u8272\u304c\u306a\u3051\u308c\u3070OUT\n found=False\n count=C.count(a)\n if count==0:\n print(0)\n exit()\n #\u9069\u5f53\u306b1\u4eba\u8db3\u3059\n C[C.index(a)]+=1\n #\u4eca\u898b\u3066\u3044\u308b\u4eba\u306e\u8272\u306e\u53ef\u80fd\u6027\u306fcount\u7a2e\u985e\n ans=ans*count%MOD\n\nprint(ans)", "neg": "N = int(input())\nA = list(map(int,input().split()))\n\nMOD = 1000000007\n\n#\u8272\u3054\u3068\u306e\u4eba\u6570\nC=[0,0,0]\nans=1\nfor a in A:\n #\u4eba\u6570\u304c\u4e00\u81f4\u3059\u308b\u8272\u304c\u306a\u3051\u308c\u3070OUT\n found=False\n count=C.count(a)\n if count==0:\n print(0)\n exit()\n #\u9069\u5f53\u306b1\u4eba\u8db3\u3059\n C[C.index(a)]+=1\n #\u4eca\u898b\u3066\u3044\u308b\u4eba\u306e\u8272\u306e\u53ef\u80fd\u6027\u306fcount\u7a2e\u985e\n ans=ans*count%MOD\n print(count)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [241, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u947883560", "n_user": "u947883560", "pos": "#!/usr/bin/env python3\nimport sys\nINF = float(\"inf\")\n\nMOD = 1000000007 # type: int\n\n\ndef solve(N: int, A: \"List[int]\"):\n RGB = [-1, -1, -1]\n ans = 1\n for a in A:\n count = 0\n for i in range(3):\n if RGB[i] == a-1:\n if count == 0:\n RGB[i] = a\n count += 1\n if count > 1:\n ans *= count\n ans %= MOD\n elif count == 0:\n ans = 0\n print(ans)\n return\n print(ans)\n\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n A = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, A)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\nINF = float(\"inf\")\n\nMOD = 1000000007 # type: int\n\n\ndef solve(N: int, A: \"List[int]\"):\n RGB = [-1, -1, -1]\n ans = 1\n for a in A:\n mi = None\n count = 0\n for i in range(3):\n if RGB[i] == a-1:\n if mi == None:\n RGB[mi] = a\n mi = i\n count += 1\n if count > 1:\n ans *= count\n ans %= MOD\n print(ans)\n\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n A = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, A)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.953125, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [280, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u405534002", "n_user": "u405534002", "pos": "n=int(input())\nA=list(map(int,input().split()))\nx=0\ny=0\nz=0\nans=1\nfor a in A:\n c=0\n X,Y,Z=x,y,z\n if a==x:\n x+=1\n c+=1\n if a==y:\n c+=1\n if a!=X:\n y+=1\n if a==z:\n c+=1\n if a!=X and a!=Y:\n z+=1\n ans=ans*c%1000000007\nprint(ans)", "neg": "=int(input())\nA=list(map(int,input().split()))\nx=0\ny=0\nz=0\nans=1\nfor a in A:\n c=0\n X,Y,Z=x,y,z\n if a==x:\n x+=1\n c+=1\n if a==y:\n c+=1\n if a!=X:\n y+=1\n if a==z:\n c+=1\n if a!=X and a!=Y:\n z+=1\n ans=ans*c%1000000007\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [154, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u602740328", "n_user": "u602740328", "pos": "N = int(input())\nA = map(int, input().split())\nxyz,T = [0,0,0],1\nfor Ai in A:\n n_Ai = xyz.count(Ai)\n T = (T*n_Ai)%1000000007\n if n_Ai>0: xyz[xyz.index(Ai)] += 1\nprint(T)", "neg": "N = int(input())\nA = map(int, input().split())\nxyz,T = [0,0,0],1\nfor Ai in A:\n n_Ai = xyz.count(Ai)\n T = (T*n_Ai))%1000000007\n if n_Ai>0: xyz.count(Ai)xyz[xyz.index(Ai)] += 1\nprint(T)", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [93, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u989345508", "n_user": "u989345508", "pos": "import collections\n\nn=int(input())\nb=[[0,0,0]]\na=[int(i) for i in input().split()]\n\ndef my_index(l, x):\n if x in l:\n return l.index(x)\n else:\n return -1\n\nfor i in range(n):\n k=my_index(b[-1],a[i])\n if k==-1:\n print(0)\n break\n c=[]\n for j in range(3):\n if j==k:\n c.append(b[-1][j]+1)\n else:\n c.append(b[-1][j])\n b.append(c)\nelse:\n x=1\n for i in range(n):\n x=x*b[i].count(a[i])%1000000007\n print(x)\n", "neg": "import collections\n\nn=int(input())\nb=[[0,0,0]]\na=[int(i) for i in input().split()]\n\ndef my_index(l, x):\n if x in l:\n return l.index(x)\n else:\n return -1\n\nfor i in range(n):\n k=b[-1].my_index(a[i])\n if k==-1:\n print(0)\n break\n c=[]\n for j in range(3):\n if j==k:\n c.append(b[-1][j]+1)\n else:\n c.append(b[-1][j])\n b.append(c)\nelse:\n x=1\n for i in range(n):\n x=x*b[i].count(a[i])%1000000007\n print(x)\n", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [216, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u729133443", "n_user": "u729133443", "pos": "_,a=open(0)\nc=1\nd=[3]+[0]*10**6\nfor a in map(int,a.split()):\n c=c*d[a]%(10**9+7)\n d[a]-=1\n d[a+1]+=1\nprint(c)", "neg": "_,a=open(0)\nc=1\nd=[3]+[0]*10**6\nfor a in map(int,a.split()):\n c=c*dp[a]%(10**9+7)\n d[a]-=1\n d[a]+=1\nprint(c)", "jacc_sim": 0.967741935483871, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [77, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u729008627", "n_user": "u729008627", "pos": "N = int(input())\nA = list(map(int, input().split()))\nL = [0 for i in range(max(A)+2)]\nans = 1\nL[0] = 3\np = 10 ** 9 + 7\nfor i in range(N):\n ai = A[i]\n ans *= (L[ai] - L[ai + 1])\n ans = ans % p\n L[ai + 1] += 1\nprint(ans)\n", "neg": "N = int(input)\nA = list(map(int, input().split()))\nL = [0 for i in range(max(A)+2)]\nans = 1\nL[0] = 3\np = 10 ** 9 + 7\nfor i in range(N):\n ai = A[i]\n ans *= (L[ai] - L[ai + 1])\n ans = ans % p\n L[ai + 1] += 1\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [110, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u268554510", "n_user": "u268554510", "pos": "N=int(input())\nA = list(map(int,input().split()))\nlis = [0]*200000\nans=1\nnum_zero=0\nmod = 1000000007\nfor i in A:\n lis[i]+=1\n if i!=0:\n ans*=lis[i-1]\n lis[i-1]-=1\n ans%=mod\n if lis[i-1]<0:\n ans=0\n break\n \n else:\n num_zero+=1\n\nif (num_zero==2)or(num_zero==3):\n mul = 6\n \nelif num_zero==1:\n mul = 3\n\nelse:\n mul = 0\n \nprint((ans*mul)%mod)", "neg": "N=int(input())\nA = list(map(int,input().split()))\nlis = [0]*200000\nans=1\nnum_zero=0\nmod = 1000000007\nfor i in A:\n lis[i]+=1\n if i!=0:\n ans*lis[i-1]\n lis[i-1]-=1\n ans%=mod\n if lis[i-1]<0:\n ans=0\n break\n \n else:\n num_zero+=1\n\nif num_zero>=2:\n mul = 6\n \nelse:\n mul = 3\n \nprint((ans*mul)%mod)", "jacc_sim": 0.9302325581395349, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [193, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u759938562", "n_user": "u759938562", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\nc = [-1, -1 ,-1]\n\nsum = 1\ntmp = 0\nfor i in range(N):\n sum = sum * c.count(A[i]-1) % 1000000007\n if (A[i]-1) == c[0]:\n c[0] += 1\n tmp = c.count(c[0] - 1) + 1\n elif (A[i]-1) == c[1]:\n c[1] += 1\n tmp = c.count(c[1]-1) + 1\n elif (A[i]-1) == c[2]:\n c[2] += 1\n tmp = c.count(c[2] - 1) + 1\nprint(sum)\n", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\nc = [-1, -1 ,-1]\n\nsum = 1\ntmp = 0\nfor a in A:\n sum = sum * c.count(A-1) % 1000000007\n if A-1 == c[0]:\n c[0] += 1\n tmp = c.count(c[0] - 1) + 1\n elif A-1 == c[1]:\n c[1] += 1\n tmp = c.count(c[1]-1) + 1\n elif A-1 == c[2]:\n c[2] += 1\n tmp = c.count(c[2] - 1) + 1\nprint(sum)\n", "jacc_sim": 0.9142857142857143, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [200, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u845536647", "n_user": "u845536647", "pos": "N = int(input()) \na = list(map(int, input().split()))\nb = [-1, -1, -1]\nx=1\nfor i in range(N):\n x = x*b.count(a[i]-1) % 1000000007\n if b[0]==(a[i]-1):\n b[0]+=1\n elif b[1]==(a[i]-1):\n b[1]+=1\n else:\n b[2]+=1\nprint(x)", "neg": "N = int(input()) \na = list(map(int, input().split()))\na[0:0] = [-1, -1, -1]\nx=1\nfor i in range(3,N+2):\n b=a[0:i-1]\n x = x*((b.count(a[i]-1)-b.count(a[i])))\n if x=0:x=1\nx = x % 1000000007\nprint(x)", "jacc_sim": 0.9142857142857143, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [131, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u117348081", "n_user": "u117348081", "pos": "INF = int(1e9) + 7\n\nn = int(input())\na = list(map(int, input().split()))\ncol = [0, 0, 0]\nans = 1\nfor i in range(n):\n m = 0\n for j in range(3):\n if a[i] ==col[j]:\n m = col.count(a[i])\n ans *= m\n \n for j in range(3):\n if a[i]==col[j]:\n col[j] +=1\n break\n else:\n continue\n ans = ans%INF\n\nprint(ans)\n", "neg": "INF = int(1e9) + 7\n\nn = int(input())\na = list(map(int, input().split()))\ncol = [0,0,0]\nans = 1\nfor i in range(n):\n col[i] +=1\n continue\n c = set(col)\n m = 0\n for j in range(3):\n if c==col[j]:\n m +=1\n ans *= m\n \n for j in range(3):\n if i==col[j]:\n col[j] +=1\n break\n else:\n continue\n ans = ans%INF\n\nprint(ans)", "jacc_sim": 0.925, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [152, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u408620326", "n_user": "u408620326", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\nrbg = [0, 0, 0]\nans = 1\nA = [int(a) for a in input().strip().split()]\nfor a in A:\n if rbg.count(a) == 0:\n print(0)\n exit()\n ans = (ans * rbg.count(a)) % (10 ** 9 + 7)\n rbg[rbg.index(a)] += 1\n\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\nA = \n\nrbg = [1, 0, 0]\nans = 1\nfor a in [int(a) for a in input().strip().split()]:\n ans = (ans * rbg.count(a)) % (10 ** 9 + 7)\n rbg[rbg.index(a)] += 1\n\nprint(ans * 3 % (10 ** 9 + 7))", "jacc_sim": 0.918918918918919, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [122, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u094191970", "n_user": "u094191970", "pos": "n=int(input())\na=list(map(int,input().split()))\n\nmod=1000000007\nans=1\nr,b,g=0,0,0\nr2,b2,g2=-1,-1,-1\nfor i in a:\n if r2==r and b2==b and g2==g:\n print(0)\n exit()\n r2=r\n b2=b\n g2=g\n if i==r and i==b and i==g:\n ans*=3\n ans%=mod\n r+=1\n elif (i==r and i==b) or (i==g and i==r):\n ans*=2\n ans%=mod\n r+=1\n elif i==b and i==g:\n ans*=2\n ans%=mod\n g+=1\n elif i==r:\n r+=1\n elif i==b:\n b+=1\n elif i==g:\n g+=1\n\n else:\n print(0)\n exit()\n\nprint(ans)", "neg": "n=int(input())\na=list(map(int,input().split()))\n\nmod=1000000007\nans=1\nr,b,g=0,0,0\nfor i in a:\n if r2==r and b2==b and g2==g:\n print(0)\n exit()\n if i==r and i==b and i==g:\n ans*=3\n ans%=mod\n r+=1\n elif (i==r and i==b) or (i==g and i==r):\n ans*=2\n ans%=mod\n r+=1\n elif i==b and i==g:\n ans*=2\n ans%=mod\n g+=1\n elif i==r:\n r+=1\n elif i==b:\n b+=1\n elif i==g:\n g+=1\n\n else:\n print(0)\n exit()\nprint(ans)", "jacc_sim": 0.975, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [274, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u620084012", "n_user": "u620084012", "pos": "N = int(input())\nA = list(map(int,input().split()))\n\nc = [0 for k in range(max(A)+2)]\nans = 1\nMOD = 1000000007\n\nc[0] = 3\nfor k in range(N):\n ans *= c[A[k]] - c[A[k]+1]\n c[A[k]+1] += 1\n ans %= MOD\n\nprint(ans)\n", "neg": "N = int(input())\nA = list(map(int,input().split()))\nnow = 0\n\nc = [0 for k in range(max(A)+2)]\nans = 1\nMOD = 1000000007\n\nfor k in range(N):\n c[A[k]] += 1\n ans *= c[A[k]]-c[A[k]+1]\n ans %= MOD\nprint(ans)\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [106, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u270681687", "n_user": "u730769327", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nmod = 10**9 + 7\n\n\nans = 1\ncnt = [0 for i in range(3)]\nfor i in range(n):\n count = 0\n for j in range(3):\n if cnt[j] == a[i]:\n count += 1\n ans *= count\n ans %= mod\n for j in range(3):\n if cnt[j] == a[i]:\n cnt[j] += 1\n break\n\n\nprint(ans)", "neg": "mod=10**9+7\nn=int(input())\na=list(map(int,input().split()))\nb=[0,0,0]\nans=1\nfor i in a:\n ans*=b.count(i)\n for j in range(3):\n if b[j]==i:\n b[j]+=1\n break\n else:print(1)\nprint(ans%mod)", "jacc_sim": 0.9210526315789473, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [135, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02845", "p_user": "u223904637", "n_user": "u223904637", "pos": "n=int(input())\nl=list(map(int,input().split()))\nmod=10**9+7\nans=1\nrgb=[0]*3\nfor i in range(n):\n f=0\n for j in range(3):\n if l[i]==rgb[j]:\n if f==0:\n rgb[j]+=1\n f+=1\n ans*=f\n ans%=mod\nprint(ans)", "neg": "n=int(input())\nl=list(map(int,input().split()))\nmod=10**9+7\nans=1\nrgb=[0]*3\nfor i in range(n):\n f=0\n for i in range(3):\n if l[i]==rgb[i]:\n if f==0:\n rgb[i]+=1\n f+=1\n ans*=f\n ans%=mod\nprint(ans)\n \n", "jacc_sim": 0.9714285714285714, "nl": "You are given a queue of N people, each wearing a red, blue, or green hat. Person i states the number of people in front of them wearing the same color hat. Find the number of possible hat color combinations, considering all statements to be true. Output the result modulo 1000000007. Constraints: 1 \u2264 N \u2264 100000, 0 \u2264 A_i \u2264 N-1. Input format: N followed by A_1 to A_N. Output the number of possible combinations. Example: Input 1: 6 0 1 2 3 4 5, Output 1: 3. Example: Input 2: 3 0 0 0, Output 2: 6. Example: Input 3: 54 0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17, Output 3: 115295190.", "before_after_length": [110, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u036104576", "n_user": "u036104576", "pos": "import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom collections import Counter\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\n\nimport sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nacc = [0] * (N + 1)\nfor i in range(1, N + 1):\n acc[i] = acc[i - 1] + A[i - 1] - 1\n acc[i] %= K\n\nmp = defaultdict(int)\nans = 0\nq = deque([])\nfor j in range(N + 1):\n ans += mp[acc[j]]\n mp[acc[j]] += 1\n q.append(acc[j])\n if len(q) == K:\n mp[q[0]] -= 1\n q.popleft()\nprint(ans)", "neg": "import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom collections import Counter\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\n\nimport sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nacc = [0] * (N + 1)\nfor i in range(1, N + 1):\n acc[i] = acc[i - 1] + A[i - 1] - 1\n acc[i] %= K\n\nmp = defaultdict(int)\nans = 0\nfor j in range(N + 1):\n ans += mp[acc[j]]\n mp[acc[j]] += 1\n if j >= K:\n mp[acc[j - K]] -= 1\nprint(ans)", "jacc_sim": 0.9242424242424242, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [393, 369], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u873915460", "n_user": "u873915460", "pos": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\nDP=dict()\nif K==1:\n print(0)\n exit()\nDP[0]=1\nP=0\nY=[0]*(N+1)\nfor i in range(N):\n Y[i+1]=(Y[i]+A[i]-1)%K\n P+=DP.get(Y[i+1],0)\n DP[Y[i+1]]=DP.get(Y[i+1],0)+1\n if i>=K-2:\n DP[Y[i-K+2]]-=1\nprint(P)", "neg": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\nDP=dict()\nif K==1:\n print(0)\n exit()\nDP[0]=1\nP=0\nY=[0]*(N+1)\nfor i in range(N):\n Y[i+1]=(Y[i]+A[i]-1)%K\n P+=DP.get(Y[i+1],0)\n DP[Y[i+1]]=DP.get(Y[i+1],0)+1\n if i>=K-2:\n DP[Y[i-K+2]]-=1", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [171, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u368796742", "n_user": "u368796742", "pos": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nmo = [0]\nmod = [0]\nfor i in range(n):\n a = l[i]%k\n mo.append((a+mo[-1])%k)\n mod.append((mo[-1]-(i+1))%k)\ndic = {0:1}\nle = 1\nans = 0\nfor i in range(1,n+1):\n if le < k:\n if mod[i] in dic:\n ans += dic[mod[i]]\n dic[mod[i]] += 1\n else:\n dic[mod[i]] = 1\n le += 1\n else:\n dic[mod[i-k]] -= 1\n if mod[i] in dic:\n ans += dic[mod[i]]\n dic[mod[i]] += 1\n else:\n dic[mod[i]] = 1\n \nprint(ans)\n", "neg": "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nmo = [0]\nmod = [0]\nfor i in range(n):\n a = l[i]%k\n mo.append((a+mo[-1])%k)\n mod.append((mo[-1]-(i+1))%k)\ndic = {0:1}\nle = 1\nans = 0\nfor i in range(1,n+1):\n if le < k:\n if mod[i] in dic:\n ans += dic[mod[i]]\n dic[mod[i]] += 1\n else:\n dic[mod[i]] = 1\n le += 1\n else:\n dic[mod[i-k]] -= 1\n if mod[i] in dic:\n ans += dic[mod[i]]\n dic[mod[i]] += 1\n else:\n dic[mod[i]] = 1\n print(dic)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [242, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u498487134", "n_user": "u498487134", "pos": "N, K = map(int,input().split())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\nS2 = [0]*(N+1)\ndict = {}#\u6700\u65b0K\u4ef6\u306e\u5ea6\u6570\u5206\u5e03\u306e\u7ba1\u7406\n\nfor i in range(N):\n S[i+1]=S[i]+A[i]\n S2[i+1] =(S[i+1]-i-1)%K\n\nans =0\nfor i in range(N+1):\n if dict.get(S2[i],0):\n ans += dict[S2[i]]\n dict[S2[i]]=dict.get(S2[i],0)+1\n if i >=K-1:\n dict[S2[i-(K-1)]]-=1\n\nprint(ans)", "neg": "N, K = map(int,input().split())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\ndict = {}#\u6700\u65b0K\u4ef6\u306e\u5ea6\u6570\u5206\u5e03\u306e\u7ba1\u7406\n\nfor i in range(N):\n S[i+1]=S[i]+A[i]\n S[i+1]-=i+1\n S[i+1]%=K\n\nans =0\nfor i in range(N+1):\n if dict.get(S[i],0):\n ans += dict[S[i]]\n print(i,ans)\n dict[S[i]]=dict.get(S[i],0)+1\n if i >=K:\n dict[S[i-K]]-=1\n\nprint(ans)", "jacc_sim": 0.9787234042553191, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [233, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u619819312", "n_user": "u619819312", "pos": "from collections import defaultdict as d\nfrom itertools import accumulate as ac\nn,k=map(int,input().split())\na=[0]+list(ac(list(map(int,input().split()))))\nb=d(int)\nc=0\nfor i in range(n+1):\n p=(a[i]-i)%k\n c+=b[p]\n b[p]+=1\n if i-k+1>=0:\n b[(a[i-k+1]-i+k-1)%k]-=1\nprint(c)", "neg": "from collections import defaultdict as d\nfrom itertools import accumulate as ac\nn,k=map(int,input().split())\na=[0]+list(ac(list(map(int,input().split()))))\nb=d(int)\nc=0\nfor i in range(n+1):\n p=(a[i]-i)%k\n c+=b[p]\n b[p]+=1\n if i-k>=0:\n b[(a[i-k]-i+k)%k]-=1\nprint(c)", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [141, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u824237520", "n_user": "u824237520", "pos": "n, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\nn += 1\nans = 0\nm = dict()\ntemp = 0\nb = []\nfor i in range(min(n, k)):\n temp = (temp + a[i]) % k\n c = (temp - (i % k) + k) % k\n b.append(c)\n if c in m.keys():\n ans += m[c]\n m[c] += 1\n else:\n m[c] = 1\n\nfor i in range(k, n):\n x = i % k\n m[b[x]] -= 1\n temp = (temp + a[i]) % k\n c = (temp - (i % k) + k) % k\n b[x] = c\n if c in m.keys():\n ans += m[c]\n m[c] += 1\n else:\n m[c] = 1\n\nprint(ans)\n", "neg": "n, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\nn += 1\nans = 0\nm = dict()\nfor x in a:\n m[x] = 0\ntemp = 0\nb = []\nfor i in range(min(n, k)):\n temp = (temp + a[i]) % k\n c = (temp - (i % k) + k) % k\n b.append(c)\n m[c] += 1\n\nfor i in range(k, n):\n x = i % k\n m[b[x]] -= 1\n temp = (temp + a[i]) % k\n c = (temp - (i % k) + k) % k\n b[x] = c\n m[c] += 1\n\nprint(ans)", "jacc_sim": 0.9210526315789473, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [250, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u813102292", "n_user": "u813102292", "pos": "from collections import defaultdict as dd\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nS = [0]*(N+1)\n# \u7d2f\u7a4d\u548c\nfor i in range(1, N + 1):\n S[i] = S[i - 1] + A[i - 1] - 1\n S[i] %= K\n \nB = dd(int) # \u3053\u3053\u3067\u7bc4\u56f2\u5185\u306eS[i]-i\u306e\u500b\u6570\u3092\u6570\u3048\u3066\u3044\u304f\u3002\ncnt = 0\nfor j in range(1, N + 1):\n B[S[j - 1]] += 1\n if j - K >= 0:\n B[S[j - K]] -= 1\n cnt += B[S[j]]\n\nprint(cnt)", "neg": "from collections import defaultdict as dd\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nS = [0]\n# \u7d2f\u7a4d\u548c\nfor i in range(N):\n S.append(S[-1] + A[i] - (i+1))\n S[-1] %= K\n \nB = dd(int) # \u3053\u3053\u3067\u7bc4\u56f2\u5185\u306eS[i]-i\u306e\u500b\u6570\u3092\u6570\u3048\u3066\u3044\u304f\u3002\ncnt = 0\nfor j in range(1,N):\n if j > K:\n B[S[j - 1 - K]] -= 1\n B[S[j]] += 1\n cnt += B[(-S[j]) % K]\nprint(cnt)", "jacc_sim": 0.9655172413793104, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [232, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u353919145", "n_user": "u089230684", "pos": "from collections import defaultdict \ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n \n ans = 0\n ruiseki = [0]\n d = defaultdict(int)\n d[0]=1\n for i in range(n):\n if i - k + 1>= 0:\n d[ruiseki[i - k+1]]-=1\n ruiseki.append((ruiseki[i] + a[i] - 1)%k)\n ans += d[ruiseki[i+1]]\n d[ruiseki[i + 1]] += 1\n print(ans)\n \n \nif __name__ == '__main__':\n main()", "neg": "def main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n \n ans = 0\n ruiseki = [0]\n d = defaultdict(int)\n d[0]=1\n for i in range(n):\n if i - k + 1>= 0:\n d[ruiseki[i - k+1]]-=1\n ruiseki.append((ruiseki[i] + a[i] - 1)%k)\n ans += d[ruiseki[i+1]]\n d[ruiseki[i + 1]] += 1\n print(ans)\n \n \nif __name__ == '__main__':\n main()", "jacc_sim": 0.926829268292683, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [184, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u121921603", "n_user": "u121921603", "pos": "from collections import defaultdict\nN,K=map(int, input().split())\nA=list(map(int,input().split()))\n\"\"\"count=0\nfor l in range(N):\n if A[l]%K==1:\n count+=1\nfor l in range(N-1):\n sum=A[l]\n for r in range(l+1,N):\n sum+=A[r]\n if sum%K==r-l+1:\n count+=1\nprint(count)\"\"\"\ncum=[0]*(N+1)\nfor i in range(N):\n cum[i+1]=(cum[i]+A[i]-1)%K\ndic=defaultdict(int)\nans=0\nfor i in range(N+1):\n ans+=dic[cum[i]]\n dic[cum[i]]+=1\n if i-(K-1)>=0:\n dic[cum[i-(K-1)]]-=1\nprint(ans)\n", "neg": "from collections import defaultdict\nN,K=map(int, input().split())\nA=list(map(int,input().split()))\n\"\"\"count=0\nfor l in range(N):\n if A[l]%K==1:\n count+=1\nfor l in range(N-1):\n sum=A[l]\n for r in range(l+1,N):\n sum+=A[r]\n if sum%K==r-l+1:\n count+=1\nprint(count)\"\"\"\ncum=[0]*(N+1)\nfor i in range(N):\n cum[i+1]=(cum[i]+A[i]-1)%K\ndic=defaultdict(int)\nans=0\nfor i in range(N+1):\n print(dic)\n ans+=dic[cum[i]]\n dic[cum[i]]+=1\n if i>K:\n dic[cum[i-(K-1)]]-=1\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [247, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u227082700", "n_user": "u911575040", "pos": "n,k=map(int,input().split())\na=[0]+list(map(int,input().split()))\nfor i in range(n):a[i+1]=(a[i+1]+a[i]-1)%k\nfrom collections import defaultdict\nd=defaultdict(int)\nx=0\nd[0]=1\nfor i in range(1,n+1):\n if i-k>=0:d[a[i-k]]-=1\n x+=d[a[i]]\n d[a[i]]+=1\nprint(x)", "neg": "\nn,k = map(int, input().split())\na = [0] + list(map(int, input().split()))\nfor i in range(n):\n a[i+1] = (a[i] + a[i+1]-1)%k\nfrom collections import defaultdict\n\nd=defaultdict(int)\nd[0]=1\nans=0\nfor i in range(1,n+1):\n ans+=d[a[i]]\n d[a[i]]+=1\n if i>=k:\n d[a[i-k]]-=1\nprint(ans)", "jacc_sim": 0.9428571428571428, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [142, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u193182854", "n_user": "u843175622", "pos": "from collections import defaultdict\n\nn, k = map(int, input().split())\na = list(map(lambda x: int(x)-1, input().split()))\ns = [0] * (n+1)\nfor i in range(n):\n s[i+1] = s[i] + a[i]\ns = [x % k for x in s]\nd = defaultdict(int)\nans = 0\n\nfor i in range(n+1):\n j = i - k\n if j >= 0: d[s[j]] -= 1\n ans += d[s[i]]\n d[s[i]] += 1\n\nprint(ans)", "neg": "from collections import defaultdict\nn, k = map(int, input().split())\n\n\na = list(map(lambda x: int(x) - 1, input().split()))\ns = [0] * (n + 1)\nfor i in range(n):\n\ts[i + 1] = (s[i] + a[i]) % k\n\nmp = defaultdict(int)\n\nprint(s)\nans = 0\nfor i in range(n + 1):\n\tans += mp[s[i]]\n\tmp[s[i]] += 1\n\tif i >= k - 1:\n\t\tmp[s[i - k + 1]] -= 1\nprint(ans)\n", "jacc_sim": 0.925, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [159, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u223904637", "n_user": "u223904637", "pos": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nif k==1:\n print(0)\n exit()\nnl=[]\nfor i in range(n):\n nl.append((l[i]-1)%k)\nr=[0]*(n+1)\nfor i in range(n):\n r[i+1]=(r[i]+nl[i])%k\np=[]\nfor i in range(n+1):\n p.append([r[i],i])\np.sort()\ns=0\ne=0\nans=0\nf=0\nwhile e=p[e][1]:\n f+=1\n e+=1\n else:\n ans+=f-1\n f-=1\n s+=1\nprint(ans+f*(f-1)//2)\n", "neg": "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nif k==1:\n print(n)\n exit()\nnl=[]\nfor i in range(n):\n nl.append((l[i]-1)%k)\nr=[0]*(n+1)\nfor i in range(n):\n r[i+1]=(r[i]+nl[i])%k\np=[]\nfor i in range(n+1):\n p.append([r[i],i])\np.sort()\ns=0\ne=0\nans=0\nf=0\nwhile e=p[e][1]:\n f+=1\n e+=1\n else:\n ans+=f\n f-=1\n s+=1\nprint(ans)\n", "jacc_sim": 0.9777777777777777, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [277, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u638795007", "n_user": "u638795007", "pos": "def examE():\n N, K = LI()\n A = LI()\n sumA = [0]*(N+1)\n for i in range(1,N+1):\n sumA[i] = sumA[i-1]+A[i-1]\n d = defaultdict(int)\n ans = 0\n #\u9023\u60f3\u914d\u5217 \u5148\u982d\u304b\u3089\u306e\u756a\u53f7\u3000\u4f59\u5206\u306a\u91cf\n que = deque()\n for i,a in enumerate(sumA):\n #K\u756a\u76ee\u4ee5\u964d\u306f\u4e00\u756a\u5de6\u306e\u3084\u3064\u6d88\u3057\u3066\u3044\u304f\n if que and que[0][0] <= (i-K):\n d[que.popleft()[1]] -= 1\n cur = (a-i)%K\n ans +=d[cur]\n d[cur] +=1\n que.append((i,cur))\n# print(ans,que,d,a-i)\n print(ans)\n return\n\ndef examF():\n return\n\nimport sys,copy,bisect,itertools,math\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float('inf')\n\nexamE()\n", "neg": "def examE():\n N, K = LI()\n A = LI()\n sumA = [0]*(N+1)\n for i in range(1,N):\n sumA[i] = sumA[i-1]+A[i-1]\n d = defaultdict(int)\n ans = 0\n #\u9023\u60f3\u914d\u5217 \u5148\u982d\u304b\u3089\u306e\u756a\u53f7\u3000\u4f59\u5206\u306a\u91cf\n que = deque()\n for i,a in enumerate(sumA):\n #K\u756a\u76ee\u4ee5\u964d\u306f\u4e00\u756a\u5de6\u306e\u3084\u3064\u6d88\u3057\u3066\u3044\u304f\n if que and que[0][0] <= (i-K):\n d[que.popleft()[1]] -= 1\n cur = (a-i)%K\n ans +=d[cur]\n d[cur] +=1\n que.append((i,cur))\n print(que,d)\n print(ans)\n return\n\ndef examF():\n return\n\nimport sys,copy,bisect,itertools,math\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float('inf')\n\nexamE()", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [427, 417], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u375616706", "n_user": "u375616706", "pos": "from collections import defaultdict\nfrom itertools import accumulate\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA_acc = [0]+list(accumulate(A))\n\n\nans = 0\nD = defaultdict(int)\nfor l in range(N+1):\n t = (A_acc[l]-l) % K\n if l>=K:\n r = (A_acc[l-K]-(l-K))\n D[r%K]-=1\n ans += D[t]\n D[t] += 1\n\n\nprint(ans)\n", "neg": "from collections import defaultdict\nfrom itertools import accumulate\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA_acc = [0]+list(accumulate(A))\n\n\nans = 0\nD = defaultdict(int)\nfor l in range(N+1):\n t = (A_acc[l]-l) % K\n ans += D[t]\n D[t] += 1\n\n\nprint(ans)\n", "jacc_sim": 0.9347826086956522, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [177, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u623819879", "n_user": "u623819879", "pos": "from heapq import heappush,heappop,heapify\nfrom collections import deque,defaultdict,Counter\nimport itertools\nfrom itertools import permutations,combinations\nimport sys\nimport bisect\nimport string\nimport math\nimport time\n#import random\ndef I():\n return int(input())\ndef MI():\n return map(int,input().split())\ndef LI():\n return [int(i) for i in input().split()]\ndef LI_():\n return [int(i)-1 for i in input().split()]\ndef StoI():\n return [ord(i)-97 for i in input()]\ndef ItoS(nn):\n return chr(nn+97)\ndef show(*inp,end='\\n'):\n if show_flg:\n print(*inp,end=end)\nYN=['Yes','No']\nmo=10**9+7\ninf=float('inf')\nl_alp=string.ascii_lowercase\nu_alp=string.ascii_uppercase\nts=time.time()\n#sys.setrecursionlimit(10**6)\ninput=lambda: sys.stdin.readline().rstrip()\n\nshow_flg=False\n#show_flg=True\n\nn,k=LI()\na=LI()\nb=[k-1]\nfor i in range(n):\n b.append((b[-1]+a[i])%k)\nb=[(b[i]-i)%k for i in range(n+1)]\nans=0\ndc=defaultdict(int)\nshow(a)\nshow(b)\nfor i in range(n+1):\n if i>=k:\n dc[b[i-k]]-=1\n ans+=dc[b[i]]\n #if dc[b[i]]>0:show(i,a[i],dc[b[i]],ans)\n #show(i,b[i],dc)\n dc[b[i]]+=1\n\nprint(ans)\n", "neg": "from heapq import heappush,heappop,heapify\nfrom collections import deque,defaultdict,Counter\nimport itertools\nfrom itertools import permutations,combinations\nimport sys\nimport bisect\nimport string\nimport math\nimport time\n#import random\ndef I():\n return int(input())\ndef MI():\n return map(int,input().split())\ndef LI():\n return [int(i) for i in input().split()]\ndef LI_():\n return [int(i)-1 for i in input().split()]\ndef StoI():\n return [ord(i)-97 for i in input()]\ndef ItoS(nn):\n return chr(nn+97)\ndef show(*inp,end='\\n'):\n if show_flg:\n print(*inp,end=end)\nYN=['Yes','No']\nmo=10**9+7\ninf=float('inf')\nl_alp=string.ascii_lowercase\nu_alp=string.ascii_uppercase\nts=time.time()\n#sys.setrecursionlimit(10**6)\ninput=lambda: sys.stdin.readline().rstrip()\n\nshow_flg=False\nshow_flg=True\n\nn,k=LI()\na=LI()\nb=[k-1]\nfor i in range(n):\n b.append((b[-1]+a[i])%k)\nb=[(b[i]-i)%k for i in range(n+1)]\nans=0\ndc=defaultdict(int)\nshow(a)\nshow(b)\nfor i in range(n+1):\n if i>=k:\n dc[b[i-k]]-=1\n ans+=dc[b[i]]\n #if dc[b[i]]>0:show(i,a[i],dc[b[i]],ans)\n #show(i,b[i],dc)\n dc[b[i]]+=1\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [479, 478], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u366959492", "n_user": "u911575040", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\na=list(map(lambda x:x-1 ,a))\n\nif k==1:\n print(0)\n exit()\ns=[0]\nfor i in range(n):\n s.append(s[-1]+a[i])\ns=list(map(lambda x:x%k,s))\nfrom collections import defaultdict\nd=defaultdict(int)\nd[0]=1\nans=0\n\nfor i in range(1,n+1):\n ans+=d[s[i]]\n d[s[i]]+=1\n if i>=k-1:\n d[s[i-k+1]]-=1\nprint(ans)\n", "neg": "n,k=map(int,input().split())\nif k==1:\n print(0)\n exit()\na=list(map(int,input().split()))\nfrom itertools import accumulate\na=list(accumulate(a))\nfrom collections import defaultdict\n\na=list(map(lambda x:x%k,a))\na=list(map(lambda x:x-1,a))\na=[0]+a\nd=defaultdict(int)\nd[0]=1\nans=0\nfor i in range(1,n+1):\n ans+=d[a[i]]\n d[a[i]]+=1\n if i>=k:\n d[a[i-k]]-=1\nprint(ans)", "jacc_sim": 0.9024390243902439, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [192, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u579885123", "n_user": "u579885123", "pos": "import numpy\nN,K=map(int,input().split())\n\nif K==1:\n print(0)\n exit(0)\n\nA=list(map(int,input().split()))\nS=[0]+list(numpy.cumsum(A)) #\u7d2f\u7a4d\u548c\nS2=[(S[i]-i)%K for i in range(N+1)]\n\nd = {}\nans = 0\nfor j in range(1,N+1):\n if j>K-1:\n if S2[j-K] in d:\n d[S2[j-K]] -= 1\n \n if S2[j-1] in d:\n d[S2[j-1]] += 1\n else:\n d[S2[j-1]] = 1\n \n if S2[j] in d:\n ans += d[S2[j]]\nprint(ans)", "neg": "import numpy\nN,K=map(int,input().split())\n\nif K==1:\n print(0)\n exit(0)\n\nA=list(map(int,input().split()))\nS=[0]+list(numpy.cumsum(A)) #\u7d2f\u7a4d\u548c\nS2=[(S[i]-i)%K for i in range(N+1)]\nprint(A,S,S2)\n\nd = {}\nans = 0\nfor j in range(1,N+1):\n if j>K-1:\n if S2[j-K] in d:\n d[S2[j-K]] -= 1\n \n if S2[j-1] in d:\n d[S2[j-1]] += 1\n else:\n d[S2[j-1]] = 1\n \n if S2[j] in d:\n ans += d[S2[j]]\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [226, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u945181840", "n_user": "u945181840", "pos": "import sys\nfrom collections import Counter\nfrom itertools import accumulate\nread = sys.stdin.read\n\nN, K, *A = map(int, read().split())\na = list(accumulate([0] + A))\na = [(a[i] - i) % K for i in range(N + 1)]\n\nanswer = 0\nif N < K:\n for i in Counter(a).values():\n answer += i * (i - 1) // 2\nelse:\n dic = Counter(a[:K])\n for i in dic.values():\n answer += i * (i - 1) // 2\n here = K\n for i, x in enumerate(a[K:]):\n dic[a[i]] -= 1\n answer += dic[x]\n dic[x] += 1\n\nprint(answer)", "neg": "import sys\nfrom collections import Counter\nfrom itertools import accumulate\nread = sys.stdin.read\n\nN, K, *A = map(int, read().split())\na = list(accumulate([0] + A))\na = [(a[i] - i) % K for i in range(N + 1)]\n\n\ndef cmb(x):\n return x * (x - 1) // 2\n\n\nanswer = 0\nif N < K:\n for i in Counter(a).values():\n answer += cmb(i)\nelse:\n dic = Counter(a[:K])\n for i in dic.values():\n answer += cmb(i)\n print([0] + A)\n print(a)\n print(dic)\n here = K\n for i, x in enumerate(a[K:]):\n dic[a[i]] -= 1\n answer += dic[x]\n dic[x] += 1\n\nprint(answer)", "jacc_sim": 0.94, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [194, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u945181840", "n_user": "u945181840", "pos": "import sys\nfrom collections import Counter\nfrom itertools import accumulate\nread = sys.stdin.read\n\nN, K, *A = map(int, read().split())\na = list(accumulate([0] + A))\na = [(a[i] - i) % K for i in range(N + 1)]\n\n\ndef cmb(x):\n return x * (x - 1) // 2\n\n\nanswer = 0\nif N < K:\n for i in Counter(a).values():\n answer += cmb(i)\nelse:\n dic = Counter(a[:K])\n for i in dic.values():\n answer += cmb(i)\n here = K\n for i, x in enumerate(a[K:]):\n dic[a[i]] -= 1\n answer += dic[x]\n dic[x] += 1\n\nprint(answer)", "neg": "import sys\nfrom collections import Counter\nfrom itertools import accumulate\nread = sys.stdin.read\n\nN, K, *A = map(int, read().split())\na = list(accumulate([0] + A))\na = [(a[i] - i) % K for i in range(N + 1)]\n\n\ndef cmb(x):\n return x * (x - 1) // 2\n\n\nanswer = 0\nif N <= K:\n for i in Counter(a).values():\n answer += cmb(i)\nelse:\n dic = Counter(a[:K])\n for i in dic.values():\n answer += cmb(i)\n\n here = K\n while here <= N:\n if here >= K - 1:\n dic[a[here - K - 1]] -= 1\n if a[here] in dic:\n answer += dic[a[here]]\n dic[a[here]] += 1\n else:\n dic[a[here]] = 1\n here += 1\n print(answer)\n", "jacc_sim": 0.9423076923076923, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [208, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u969190727", "n_user": "u969190727", "pos": "n,k=map(int,input().split())\nA=[int(i) for i in input().split()]\nans=0\nAA=[(A[0]-1)%k]\nfor i in range(1,n):\n AA.append((AA[-1]+A[i]-1)%k)\nimport collections\nd=collections.defaultdict(int)\nd[0]+=1\nfor i in range(n):\n if i+1==k:\n d[0]-=1\n elif i+1>=k:\n d[AA[i-k]]=max(0,d[AA[i-k]]-1)\n ans+=d[AA[i]]\n d[AA[i]]+=1\nprint(ans)\n", "neg": "n,k=map(int,input().split())\nA=[int(i) for i in input().split()]\nans=0\nAA=[A[0]-1]\nfor i in range(1,n):\n AA.append((AA[-1]+A[i]-1)%k)\nimport collections\nd=collections.defaultdict(int)\nd[0]+=1\nfor i in range(n):\n \n if i+1>=k:\n d[AA[i-k]]-=1\n ans+=d[AA[i]]\n d[AA[i]]+=1\nprint(ans)\n", "jacc_sim": 0.9444444444444444, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [185, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u671455949", "n_user": "u671455949", "pos": "import bisect\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nfor i in range(n - 1):\n a[i] -= 1\n a[i + 1] += a[i]\na[n - 1] -= 1\n\nmemo = {0 : []}\nfor i in range(n):\n if a[i] % k not in memo.keys():\n memo[a[i] % k] = [i]\n else:\n memo[a[i] % k].append(i)\n\nans = bisect.bisect_left(memo[0], k - 1)\n\nfor i in memo.keys():\n for j in range(len(memo[i]) - 1):\n ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j\n\nprint(ans)", "neg": "import bisect\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nfor i in range(n - 1):\n a[i] -= 1\n a[i + 1] += a[i]\na[n - 1] -= 1\n\nmemo = {0 : []}\nfor i in range(n):\n if a[i] % k not in memo.keys():\n memo[a[i] % k] = [i]\n else:\n memo[a[i] % k].append(i)\n\nans = bisect.bisect_left(memo[0], k - 1)\n\nfor i in memo.keys():\n for j in range(len(memo[i]) - 1):\n ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j\n\nprint(memo)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [216, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02851", "p_user": "u299869545", "n_user": "u299869545", "pos": "n, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\ncnt = {0:1}\n\nans = 0\n\nfor i in range(1, n+1):\n left = i - k\n if left >= 0:\n ldif = (a[left] - left) % k\n if ldif < 0: ldif += k\n cnt[ldif] -= 1\n \n a[i] += a[i-1]\n dif = (a[i] - i) % k\n if dif < 0: dif += k\n if dif not in cnt:\n cnt[dif] = 0\n \n ans += cnt[dif]\n cnt[dif] += 1\n\nprint(ans)", "neg": "n, k = map(int, input().split())\na = [0] + list(map(int, input().split()))\n\ncnt = {0:1}\n\nans = 0\n\nfor i in range(1, n+1):\n left = i - k + 1\n if left >= 0:\n ldif = (a[left] - left) % k\n if ldif < 0: ldif += k\n cnt[ldif] -= 1\n \n a[i] += a[i-1]\n dif = (a[i] - i) % k\n if dif < 0: dif += k\n if dif not in cnt:\n cnt[dif] = 0\n \n ans += cnt[dif]\n cnt[dif] += 1\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of N positive integers A_1, A_2, ..., A_N, and a positive integer K. Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. Two subsequences are considered different if they are taken from different positions, even if they are equal sequences.\n\nConstraints:\n- All values in input are integers.\n- 1 <= N <= 2*10^5\n- 1 <= K <= 10^9\n- 1 <= A_i <= 10^9\n\nInput:\nThe input is given in the format: N K\nFollowed by the sequence A_1, A_2, ..., A_N\n\nOutput:\nPrint the number of subsequences that satisfy the condition.\n\nSample Input 1:\n5 4\n1 4 2 3 5\n\nSample Output 1:\n4\nFour sequences satisfy the condition: (1), (4,2), (1,4,2), and (5).\n\nSample Input 2:\n8 4\n4 2 4 2 4 2 4 2\n\nSample Output 2:\n7\n(4,2) is counted four times, and (2,4) is counted three times.\n\nSample Input 3:\n10 7\n14 15 92 65 35 89 79 32 38 46\n\nSample Output 3:\n8", "before_after_length": [186, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u276588887", "n_user": "u276588887", "pos": "n=int(input())\n\ndnum =0\ndsum =0\n\nfor i in range(n):\n d,c=map(int,input().split())\n dnum += c\n dsum += d*c\n \nans = dnum-1 + (dsum-1)//9\n\nprint(ans)", "neg": "n=int(input())\n\ndnum =0\ndsum =0\n\nfor i in range(n):\n d,c=map(int,input().split())\n dnum += c\n dsum += d*c\n \nans = c-1 + dsum//9\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [78, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u375616706", "n_user": "u375616706", "pos": "M = int(input())\nKeta=0\nSum=0\n\nfor _ in range(M):\n d,c = map(int,input().split())\n Keta+=c\n Sum+=d*c\nprint(Keta-1 + (Sum-1)//9)\n", "neg": "M = int(input())\nKeta=0\nSum=0\n\nfor _ in range(M):\n d,c = map(int,input().split())\n Keta+=c\n Sum=d*c\nprint(Keta-1 + (Sum-1)//9)\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [70, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u847923740", "n_user": "u847923740", "pos": "# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d\n\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n M=int(input())\n dc=[tuple(map(int,input().split())) for i in range(M)]\n ans=0\n n=0\n for i in range(M):\n n+=dc[i][0]*dc[i][1]\n ans+=dc[i][1]\n ans-=1\n def aint(x):\n ret=0\n cnt=0\n while(x>0):\n cnt+=1\n ret+=x//10\n x//=10\n cnt-=1\n return int(ret)-cnt\n \n if n>=10:\n ans+=aint(n)\n \n\n while(n>=10):\n ns=str(n)\n n=0\n for i in range(10):\n c=ns.count(chr(i+ord(\"0\")))\n n+=i*c\n ans+=len(ns)-1\n if n>=10:\n ans+=aint(n)\n print(ans)\n \n \n \n \nif __name__==\"__main__\":\n main()\n", "neg": "# https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_d\n\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n M=int(input())\n dc=[tuple(map(int,input().split())) for i in range(M)]\n ans=0\n n=0\n for i in range(M):\n n+=dc[i][0]*dc[i][1]\n ans+=dc[i][1]\n ans-=1\n def aint(x):\n ret=0\n cnt=0\n while(x>0):\n cnt+=1\n ret+=x//10\n x//=10\n cnt-=1\n return int(ret)-cnt\n \n if n>=10:\n ans+=aint(n)\n \n print(ans,n)\n while(n>=10):\n ns=str(n)\n n=0\n for i in range(10):\n c=ns.count(chr(i+ord(\"0\")))\n n+=i*c\n ans+=len(ns)-1\n if n>=10:\n ans+=aint(n)-1\n print(ans,n)\n print(ans)\n \n \n \n \nif __name__==\"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [323, 339], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u262597910", "n_user": "u262597910", "pos": "import sys\nsys.stdin.readline\n\ndef main():\n m = int(input())\n a = [list(map(int, input().split())) for _ in range(m)]\n wa = 0\n length = 0\n for i,j in a:\n wa += i*j\n length += j\n #print(wa,length)\n print(length-1+(wa-1)//9)\n \n \nif __name__==\"__main__\":\n main()\n", "neg": "import sys\nsys.stdin.readline\n\ndef main():\n m = int(input())\n a = [list(map(int, input().split())) for _ in range(m)]\n wa = 0\n length = 0\n for i,j in a:\n wa += i*j\n length += j\n print(wa,length)\n print(length-1+(wa-1)//9)\n \n \nif __name__==\"__main__\":\n main()\n", "jacc_sim": 0.9761904761904762, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [122, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u498487134", "n_user": "u498487134", "pos": "\n\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\ndef main():\n mod=10**9+7\n M=I()\n dig=0\n S=0\n for i in range(M):\n d,c=MI()\n dig+=c\n S+=d*c\n\n print(dig-1+(S-1)//9)\n\nmain()\n\n", "neg": "\n\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\ndef main():\n mod=10**9+7\n M=I()\n dig=0\n S=0\n for i in range(M):\n d,c=MI()\n dig+=d\n S+=d*c\n\n print(dig-1+(S)//10)\n\nmain()\n\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [123, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u691896522", "n_user": "u691896522", "pos": "import sys\ninput = sys.stdin.readline\nm = int(input())\nans = 0\nsum_num = 0\nc_sum = 0\nfor i in range(m):\n d,c = map(int, input().split())\n sum_num += d*c\n c_sum += c\n#\u5408\u8a08\u306b\u5bfe\u3057\u3066\u30019\u6e1b\u3089\u3059\u884c\u70ba\u304c\u4f55\u56de\u51fa\u6765\u308b\u304b\nprint(c_sum-1 + ((sum_num-1)//9))", "neg": "import sys\ninput = sys.stdin.readline\nm = int(input())\nans = 0\nsum_num = 0\nc_sum = 0\nfor i in range(m):\n d,c = map(int, input().split())\n sum_num += d*c\n c_sum += c\n#\u5408\u8a08\u306b\u5bfe\u3057\u3066\u30019\u6e1b\u3089\u3059\u884c\u70ba\u304c\u4f55\u56de\u51fa\u6765\u308b\u304b\nprint(d-1 + (c_sum//9))", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [151, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u163320134", "n_user": "u163320134", "pos": "n=int(input())\nsums=0\ndigits=0\nfor _ in range(n):\n a,b=map(int,input().split())\n sums+=a*b\n digits+=b\nans=(digits-1)+(sums-1)//9\nprint(ans)", "neg": "n=int(input())\nsums=0\ndigits=0\nfor _ in range(n):\n a,b=map(int,input().split())\n sums+=a*b\n digits+=b\nans=(digits-1)+(sums+9-1)//9\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [71, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u170183831", "n_user": "u170183831", "pos": "m = int(input())\nCD = [list(map(int, input().split())) for _ in range(m)]\ncount = 0\ntmp = -1\ntotal = 0\nfor c, d in CD:\n q, m = divmod(tmp + c * d, 9)\n count += q\n tmp = m\n total += d\nprint(total - 1 + count)\n", "neg": "m = int(input())\nCD = [list(map(input().split())) for _ in range(m)]\ncount = 0\ntmp = -1\ntotal = 0\nfor c, d in CD:\n q, m = divmod(c * d, 9)\n count += q\n tmp += m\n if tmp >= 9:\n count += 1\n tmp %= 9\n total += d\nprint(total - 1 + count)", "jacc_sim": 0.9166666666666666, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [90, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u899645116", "n_user": "u899645116", "pos": "m = int(input())\ncsum = 0\ndsum = 0\nfor i in range(m):\n d,c = (int(x) for x in input().split())\n csum += c\n dsum += d*c\nprint(csum-1 + (dsum-1) // 9)\n", "neg": "m = int(input())\ncsum = 0\ndsum = 0\nfor i in range(m):\n d,c = (int(x) for x in input().split())\n csum += c\n dsum += d*c\nprint(c-1 + dsum // 9)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [74, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef LS(): return list(map(list, input().split()))\ndef S(): return list(input().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n m = II()\n Digit = 0\n Sum = 0\n for _ in range(m):\n d, c = LI()\n Digit += c\n Sum += d * c\n print(Digit + (Sum - 1) // 9 - 1)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef LS(): return list(map(list, input().split()))\ndef S(): return list(input().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n m = II()\n Digit = 0\n Sum = 0\n for _ in range(m):\n d, c = LI()\n Digit += c\n Sum += d * c\n print(Digit + Sum // 9)\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [409, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u075739430", "n_user": "u075739430", "pos": "m = int(input())\ntot = 0\nans = 0\nfor i in range(m):\n x, y = map(int, input().split())\n tot += x * y\n ans += y\nwhile tot >= 10:\n ans += tot // 10\n tot = tot // 10 + tot % 10\nprint(ans - 1)", "neg": "m = int(input())\ntot = 0\nans = 0\nfor i in range(m):\n x, y = map(int, input().split())\n tot += x * y\n ans += y\nwhile tot >= 10:\n tot = tot // 10 + tot % 10\n ans += tot\nprint(ans - 1)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [79, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u223904637", "n_user": "u223904637", "pos": "m=int(input())\nd=[]\nc=[]\nz=0\nfor i in range(m):\n a,b=map(int,input().split())\n d.append(a)\n c.append(b)\n z+=a*b\nans=0\nprint(sum(c)-1+(z-1)//9)\nexit()\ndef ika(x,y):\n ret=0\n z=x*y\n ret+=y-1\n while z>9:\n s=list(str(z))\n ret+=len(s)-1\n i5=0\n for i in range(len(s)):\n s[i]=int(s[i])\n g=0\n while g=10:\n #ret+=1\n g+=2\n else:\n g+=1\n z=sum(s)\n ret+=(z-10)//10\n return [ret,z]\nka=[]\nfor i in range(m):\n f=ika(d[i],c[i])\n ans+=f[0]\n ka.append(f[1])\nprint(ans+ika(sum(ka),1)[0]+len(ka)-1)\n", "neg": "m=int(input())\nd=[]\nc=[]\nfor i in range(m):\n a,b=map(int,input().split())\n d.append(a)\n c.append(b)\nans=0\ndef ika(x,y):\n ret=0\n z=x*y\n ret+=y-1\n while z>9:\n s=list(str(z))\n ret+=len(s)-1\n i5=0\n for i in range(len(s)):\n s[i]=int(s[i])\n g=0\n while g=10:\n #ret+=1\n g+=2\n else:\n g+=1\n z=sum(s)\n ret+=z//10-1\n return [ret,z]\nka=[]\nfor i in range(m):\n f=ika(d[i],c[i])\n ans+=f[0]\n ka.append(f[1])\nprint(ans+ika(sum(ka),1)[0]+len(ka)-1)\n", "jacc_sim": 0.9821428571428571, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [325, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u539517139", "n_user": "u539517139", "pos": "x=0;y=0\nfor _ in range(int(input())):\n d,c=map(int,input().split())\n x+=d*c\n y+=c\nprint(y-1+(x-1)//9)", "neg": "x=0;y=0\nfor _ in range(int(input())):\n d,c=map(int,input().split())\n x+=d*c\n y+=c\nprint(y-2+x//9)", "jacc_sim": 0.9285714285714286, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [62, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u511379665", "n_user": "u511379665", "pos": "m=int(input())\nans=0\ntmp=0\ndig=0\nfor i in range(m):\n q,r=map(int,input().split())\n tmp+=q*r\n dig+=r\n\nans+=(tmp-1)//9\nprint(ans+dig-1)\n\n", "neg": "m=int(input())\nans=m-1\ntmp=0\nfor i in range(m):\n q,r=map(int,input().split())\n tmp+=q*r\n\nans+=(tmp-1)//9\nprint(ans)\n \n", "jacc_sim": 0.9642857142857143, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [76, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u021548497", "n_user": "u021548497", "pos": "n = int(input())\nd, c = 0, 0\n\nfor i in range(n):\n p, q = map(int, input().split())\n d = d + q\n c = c + p*q\n\nprint((d-1)+(c-1)//9)", "neg": "n = int(input())\nd, c = 0, 0\n\nfor i in range(n):\n p, q = map(int, input().split())\n d = d + p\n c = c + p*q\n\nprint((d-1)+(c-1)//9)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [69, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u764956288", "n_user": "u764956288", "pos": "import sys\n\ndef answer():\n input = sys.stdin.readline\n M = int(input())\n\n Ds = [0] * M\n Cs = [0] * M\n total = 0\n\n for i in range(M):\n c, d = map(int, input().split())\n Cs[i] = c\n Ds[i] = d\n total += d * c\n\n digits = sum(Ds)\n\n ans = (digits-1) + (total-1) // 9\n\n print(ans)\n\n\nif __name__ == '__main__':\n answer()\n", "neg": "import sys\n\ndef answer():\n input = sys.stdin.readline\n M = int(input())\n\n Ds = [0] * M\n Cs = [0] * M\n total = 0\n\n for i in range(M):\n d, c = map(int, input().split())\n Ds[i] = d\n Cs[i] = c\n total += d * c\n\n digits = sum(Ds)\n\n ans = (digits-1) + (total-1) // 9\n\n print(ans)\n\n\nif __name__ == '__main__':\n answer()\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [151, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u170201762", "n_user": "u970308980", "pos": "M = int(input())\nD = 0\nS = 0\nfor i in range(M):\n c,d = map(int,input().split())\n D += d\n S += c*d\nprint(D-1+(S-1)//9)", "neg": "M = int(input())\nd = [0] * M\nc = [0] * M\nfor i in range(M):\n\td[i], c[i] = map(int, input().split())\nD = 0\nS = 0\nfor i in range(M):\n\tD += c[i]\n\tS += d[i] * c[i]\nprint((D - 1) + (S // 9)\n", "jacc_sim": 0.9310344827586207, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [63, 100], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u945181840", "n_user": "u945181840", "pos": "import sys\nread = sys.stdin.read\n\nM = int(input())\ndc = map(int, read().split())\ndig = [0] * 10\ncnt = 0\nanswer = 0\nfor d, c in zip(*[iter(dc)] * 2):\n dig[d] += c\n\ntrans = dict()\nfor i in range(10):\n if i < 5:\n trans[i] = i + i\n elif i == 5:\n trans[i] = 1\n else:\n trans[i] = trans[i - 1] + 2\n\nwhile True:\n tmp = [0] * 10\n for i, x in enumerate(dig):\n q, r = divmod(x, 2)\n if x >= 2:\n if i < 5:\n answer += q\n tmp[trans[i]] += q\n tmp[i] += r\n else:\n answer += q * 2\n tmp[trans[i]] += q\n tmp[i] += r\n else:\n tmp[i] += x\n\n dig = tmp.copy()\n for i in dig:\n if i > 1:\n break\n else:\n break\n\nlast = [i for i in range(10) if dig[i] == 1]\nwhile len(last) > 1:\n a = last.pop()\n b = last.pop()\n c = a + b\n if c >= 10:\n answer += 2\n last.append(c // 10 + c % 10)\n else:\n answer += 1\n last.append(c)\n\nprint(answer)", "neg": "import sys\nread = sys.stdin.read\n\nM = int(input())\ndc = map(int, read().split())\ndig = [0] * 10\ncnt = 0\nanswer = 0\nfor d, c in zip(*[iter(dc)] * 2):\n dig[d] += c\n\ntrans = dict()\nfor i in range(10):\n if i < 5:\n trans[i] = i + i\n elif i == 5:\n trans[i] = 1\n else:\n trans[i] = trans[i - 1] + 2\n\nprint(trans)\n\nwhile True:\n tmp = [0] * 10\n for i, x in enumerate(dig):\n q, r = divmod(x, 2)\n if x >= 2:\n if i < 5:\n answer += q\n tmp[trans[i]] += q\n tmp[i] += r\n else:\n answer += x\n tmp[trans[i]] += q\n tmp[i] += r\n else:\n tmp[i] += x\n\n dig = tmp.copy()\n for i in dig:\n if i > 1:\n break\n else:\n break\n\nlast = [i for i in range(10) if dig[i] == 1]\nwhile len(last) > 1:\n a = last.pop()\n b = last.pop()\n if a + b >= 10:\n answer += 2\n last.append((a + b) // 10 + (a + b) % 10)\n else:\n answer += 1\n last.append(a + b)\n\nprint(answer)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [384, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u813102292", "n_user": "u813102292", "pos": "M = int(input())\nS = -1\nres = -1\nfor _ in range(M):\n d, c = map(int, input().split())\n res += c\n S += d*c\n\nres += S // 9\nprint(res)", "neg": "M = int(input())\nS = 0\nres = -1\nfor _ in range(M):\n d, c = map(int, input().split())\n res += d\n S += c\n\nres += S // 9\nprint(res)", "jacc_sim": 0.9259259259259259, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [62, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u892687772", "n_user": "u892687772", "pos": "m = int(input())\ncount = 0\nsum1 = 0\nfor i in range(m):\n d,c = map(int,input().split())\n sum1 += d*c\n count += c\nif (sum1%9 == 0):\n print(sum1//9 - 1 + count - 1)\nelse:\n print(sum1//9 + count - 1)\n", "neg": "m = int(input())\ncount = 0\nsum1 = 0\nfor i in range(m):\n d,c = map(int,input().split())\n sum1 += d*c\n count += c\nif (sum1%9 == 0) print(sum1//9 - 1 + count - 1)\nelse print(sum1//9 + count -1)\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [92, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u268554510", "n_user": "u268554510", "pos": "M = int(input())\ndc = [list(map(int,input().split())) for _ in range(M)]\nans = 0\ns = 0\nfor i in dc:\n d = i[0]\n c = i[1]\n ans += c\n s+=d*c\n if s>=10:\n t = (s-1)//9\n ans+=t\n s-= t*9\n\nans -= 1\nprint(ans)", "neg": "M = int(input())\ndc = [list(map(int,input().split())) for _ in range(M)]\nans = 0\ns = 0\nfor i in dc:\n d = i[0]\n c = i[1]\n ans += c\n s+=d*c\n if s>=10:\n t = s//10\n ans+=t\n s-= t*10\n\nprint(ans)", "jacc_sim": 0.9722222222222222, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [114, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u968846084", "n_user": "u372550522", "pos": "m=int(input())\nd=[0]*m\nc=[0]*m\nfor i in range(m):\n d[i],c[i]=map(int,input().split())\na=0\nfor i in range(m):\n a=a+d[i]*c[i]\nprint(sum(c)-1+(a-1)//9)", "neg": "m = int(input())\nd = [0] * m\nc = [0] * m\nfor i in range(m):\n d[i], c[i] = map(int, input().split())\n\nprint((sum(c)-1+sum([c[i]*d[i] for i in range(m)]-1)//9) % 1000000007)", "jacc_sim": 0.9032258064516129, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [88, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u828766688", "n_user": "u828766688", "pos": "M = int(input())\n\nlis = [0] * 10\nable =0\n\nfor i in range(M):\n\n d,c = map(int,input().split())\n\n lis[d] += c\n\n able += d * c\n \nprint ( sum(lis)-1 + (able-1) // 9 )\n", "neg": "M = int(input())\n\nlis = [0] * 10\nable =0\n\nfor i in range(M):\n\n d,c = map(int,input().split())\n\n lis[d] = c\n\n able += d * c\n \nprint ( sum(lis) + (able-1) // 9 )\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [83, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u480300350", "n_user": "u480300350", "pos": "m = int(input())\nL = []\nfor _ in range(m):\n L.append(list(map(int, input().split())))\n\nshort = []\nadditional = 0\nfor elm in L:\n additional += (elm[1] - 1)\n total = elm[0] * elm[1]\n if total > 9:\n if total % 9 == 0:\n additional += (total // 9) - 1\n else:\n additional += total // 9\n # additional += (total - 1) // 9\n if total > 9:\n if total % 9 == 0:\n res = 9\n else:\n res = total % 9\n else:\n res = total\n short.append(res)\n\nprev = 0\nadditional += len(short) - 1\nfor elm in short:\n prev = prev + elm\n if prev > 9:\n prev -= 9\n additional += 1\n\nprint(additional)\n\n", "neg": "m = int(input())\nL = []\nfor _ in range(m):\n L.append(list(map(int, input().split())))\n\nshort = []\nadditional = 0\nfor elm in L:\n additional += (elm[1] - 1)\n total = elm[0] * elm[1]\n additional += (total - 1) // 9\n if total > 9:\n res = total % 9\n else:\n res = total\n short.append(res)\n\nprev = 0\nadditional += len(short) - 1\nfor elm in short:\n prev = prev + elm\n if prev > 9:\n prev -= 9\n additional += 1\n\nprint(additional)\n ", "jacc_sim": 0.975, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [226, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u934868410", "n_user": "u623819879", "pos": "m = int(input())\ns = 0\nans = -1\nfor i in range(m):\n d,c = map(int,input().split())\n s += d*c\n ans += c\n\nprint(ans + (s-1)//9)", "neg": "m=int(input())\ns,c=0,0\nfor i in range(m):\n d,c=map(int,input().split())\n s+=d*c\n k+=c\nprint(k-1+(s-1)//9)", "jacc_sim": 0.9285714285714286, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [63, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u017810624", "n_user": "u017810624", "pos": "m=int(input())\nl=[list(map(int,input().split())) for i in range(m)]\nct=0;sum=0\nfor i in range(m):\n ct+=l[i][0]*l[i][1]\n sum+=l[i][1]\nprint(sum-1+((ct-1)//9))", "neg": "m=int(input())\nl=[list(map(int,input().split())) for i in range(m)]\nct=0;sum=0\nfor i in range(m):\n ct+=l[i][0]*l[i][1]\n sum+=l[i][1]\nprint(sum-1+(ct//9)-1)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [86, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u042802884", "n_user": "u042802884", "pos": "N=int(input())\nd=[];c=[]\nfor i in range(N):\n di,ci=map(int,input().split())\n d.append(di);c.append(ci)\n# print(d) #DB\n# print(c) #DB\ns=sum([d[i]*c[i] for i in range(N)])\n# print(s) #DB\nt=0\nwhile s>=10:\n t+=s//10\n s=s//10+s%10\n\nans=sum(c)-1+t\nprint(ans)", "neg": "N=int(input())\nd=[];c=[]\nfor i in range(N):\n di,ci=map(int,input().split())\n d.append(di);c.append(ci)\n# print(d) #DB\n# print(c) #DB\ns=sum([d[i]*c[i] for i in range(N)])\n# print(s) #DB\nt=0\nwhile s>10:\n s=s//10+s%10\n t+=s\n\nans=sum(c)-1+t\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [141, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u415154163", "n_user": "u415154163", "pos": "M = int(input())\nketa = 0\ncount_sum = 0\nfor _ in range(M):\n d,c= map(int,input().split(' '))\n keta += c\n count_sum += d*c\nadditional = count_sum//10\nif 9 < count_sum:\n print(keta-1 + (count_sum-1)//9)\nelse:\n print(keta-1)", "neg": "keta = 0\ncount_sum = 0\nfor _ in range(M):\n d,c= map(int,input().split(' '))\n keta += c\n count_sum += d*c\nadditional = count_sum//10\nif 9 < count_sum:\n print(keta-1 + (count_sum-1)//9)\nelse:\n print(keta-1)\n'''", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [103, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u095426154", "n_user": "u095426154", "pos": "# coding: utf-8\n# Your code here!\n\nm= int(input())\ndc=[]\ns=0\nfor i in range(m):\n dc.append(list(map(int,input().split())))\n s+=dc[i][0]*dc[i][1]\n\n\nans=s//9\n\nfor i in range(m):\n ans+=dc[i][1]\n\nif s%9==0:\n ans-=1\n\nprint(ans-1)\n", "neg": "# coding: utf-8\n# Your code here!\n\nm= int(input())\ndc=[]\ns=0\nfor i in range(m):\n dc.append(list(map(int,input().split())))\n s+=dc[i][0]*dc[i][1]\n\nprint(s)\n\nans=s//9\n\nfor i in range(m):\n ans+=dc[i][1]\n\nif s%9==0:\n ans-=1\n\nprint(ans-1)\n", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [122, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02856", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = int(input())\nans = -1\nnum = 0\nfor i in range(n):\n a,b = map(int,input().split())\n ans += b\n num += a * b\n if num > 9:\n ans += num // 9\n num %= 9\n if num == 0:\n ans -= 1\n num = 9\nprint(ans)", "neg": "n = int(input())\nans = -1\nnum = 0\nfor i in range(n):\n a,b = map(int,input().split())\n ans += b\n num += a * b\n if num > 9:\n ans += (num-9) // 9\n num %= 9\n if num == 0:\n num = 9\nprint(ans,num)", "jacc_sim": 1.0, "nl": "You are given the number of programmers, N, participating in the preliminary stage of DDCC 20XX. At most 9 contestants can advance to the finals due to venue constraints. The preliminary stage consists of multiple rounds. The number of contestants advancing to the next round is determined by choosing two consecutive digits in the decimal notation of the current number of contestants and replacing them with their sum. The preliminary stage ends when 9 or fewer contestants remain. The goal is to find the maximum possible number of rounds in the preliminary stage. The input consists of M, followed by sequences of digits and their counts. The output should be the maximum possible number of rounds. The constraints are given for M, the digits, and their counts. Sample inputs and outputs are provided for illustration.", "before_after_length": [90, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02858", "p_user": "u819048695", "n_user": "u819048695", "pos": "def gcd(x,y):\n if x, and v stand for Type-H, Type-R, and Type-D, respectively:\n>> .. vv\n.. .. vv\nSample Input 2\n869 120 1001\nSample Output 2\n672919729", "before_after_length": [152, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u490642448", "n_user": "u490642448", "pos": "n = int(input())\na = [ [int(s),i] for i,s in enumerate(input().split())]\nb = [ [int(s),i] for i,s in enumerate(input().split())]\na.sort(reverse=True)\nb.sort(reverse=True)\n\ngo = [-1] * n\n\nb_ind = 0\nans = 'No'\nfor a_ind, (j,j_ind) in enumerate(a):\n while(b[b_ind][0] >= j ):\n b_ind += 1\n\n if(b_ind == n)&(a_ind < n-1):\n print('Yes')\n exit()\n\n if(b_ind == n):\n break\n\n if(b_ind == a_ind):\n print('No')\n exit()\n\n if(b_ind > a_ind+1):\n ans = 'Yes'\n\n go[j_ind] = b[a_ind][1]\n\n\nnow = 0\ncnt = 0\nfor _ in range(n-1):\n now = go[now]\n cnt += 1\n if(now==0):\n print('Yes')\n exit()\n\nprint(ans)", "neg": "n = int(input())\na = [ [int(s),i] for i,s in enumerate(input().split())]\nb = [ [int(s),i] for i,s in enumerate(input().split())]\na.sort(reverse=True)\nb.sort(reverse=True)\n\ngo = [-1] * n\n\nb_ind = 0\nans = 'No'\nfor a_ind, (j,j_ind) in enumerate(a):\n while(b[b_ind][0] >= j ):\n b_ind += 1\n\n if(b_ind == n)&(a_ind < n-1):\n print('Yes')\n exit()\n\n if(b_ind == n):\n break\n\n if(b_ind == a_ind):\n print('No')\n exit()\n\n if(b_ind > a_ind+1):\n ans = 'Yes'\n\nnow = 0\ncnt = 0\nfor _ in range(n-1):\n now = go[now]\n cnt += 1\n if(now==0):\n print('Yes')\n exit()\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [300, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nab = [(x,y) for x,y in zip(a,b)]\nab.sort(key = lambda x:x[1])\na = list(list(zip(*ab))[0])\nai = [[a[i],i] for i in range(n)]\nflg = 0\nif len(set(b)) == n:\n ai.sort()\n for i in range(n):\n ai[i][0] = i\n ai.sort(key = lambda x:x[1])\n idc = list(zip(*ai))[0]\n cnt = 0\n plc = 0\n while True:\n plc = idc[plc]\n cnt += 1\n if plc == 0:\n break\n if cnt == n:\n flg = 1\na.sort()\nb.sort()\nfor x,y in zip(a,b):\n if x > y:\n print(\"No\")\n exit()\nif not flg:\n print(\"Yes\")\nelse:\n for i in range(1,n):\n if a[i] <= b[i-1]:\n print(\"Yes\")\n exit()\n print(\"No\")", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nbi = [[b[i],i] for i in range(n)]\nbi.sort()\nflg = 0\nif len(set(b)) == n:\n for i in range(n):\n bi[i][0] = i\n bi.sort(key = lambda x:x[1])\n idc = list(zip(*bi))[0]\n cnt = 0\n plc = 0\n while True:\n plc = idc[plc]\n cnt += 1\n if plc == 0:\n break\n if cnt == n:\n flg = 1\na.sort()\nb.sort()\nfor x,y in zip(a,b):\n if x > y:\n print(\"No\")\n exit()\nif not flg:\n print(2/0)\n print(\"Yes\")\nelse:\n for i in range(1,n):\n if a[i] <= b[i-1]:\n print(\"Yes\")\n exit()\n print(\"No\")", "jacc_sim": 0.9152542372881356, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [332, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])\na = [(x[0], i) for i, x in enumerate(c)]\nb = [x[1] for x in c]\na.sort()\nfor i in range(n):\n\tif a[i][0] > b[i]:\n\t\tprint(\"No\")\n\t\tsys.exit()\ncur, cnt = 0, 0\nwhile a[cur][1] != 0:\n\tcnt += 1\n\tcur = a[cur][1]\nif cnt < n-1:\n\tprint(\"Yes\")\nelse:\n\tfor i in range(n-1):\n\t\tif a[i+1][0] <= b[i]:\n\t\t\tprint(\"Yes\")\n\t\t\tbreak\n\telse:\n\t\tprint(\"No\")", "neg": "import sys\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = sorted([[a[i], b[i]] for i in range(n)], key=lambda x: x[1])\na = [(x[0], i) for i, x in enumerate(c)]\nb = [x[1] for x in c]\na.sort()\nprint(a)\nfor i in range(n):\n\tif a[i][0] > b[i]:\n\t\tprint(\"No\")\n\t\tsys.exit()\ncur, cnt = 0, 0\nwhile a[cur][1] != 0:\n\tcnt += 1\n\tcur = a[cur][1]\nif cnt < n-1:\n\tprint(\"Yes\")\nelse:\n\tfor i in range(n-1):\n\t\tif a[i][0] <= b[i+1]:\n\t\t\tprint(\"Yes\")\n\t\t\tbreak\n\telse:\n\t\tprint(\"No\")", "jacc_sim": 1.0, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [243, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u970449052", "n_user": "u970449052", "pos": "n=int(input())\nal=list(map(int,input().split()))\nbl=list(map(int,input().split()))\nail=[(i,a) for i,a in enumerate(al)]\nbil=[(i,b) for i,b in enumerate(bl)]\nail=sorted(ail,key=lambda x:x[1])\nbil=sorted(bil,key=lambda x:x[1])\nif not all([ail[i][1]<=bil[i][1] for i in range(n)]):\n print('No')\n exit()\nif any([ail[i+1][1]<=bil[i][1] for i in range(n-1)]):\n print('Yes')\n exit()\nc=[(ail[i][0],bil[i][0]) for i in range(n)]\nc=sorted(c)\nidx=0\nfor _ in range(n-1):\n idx=c[idx][1]\n if idx==0:\n print('Yes')\n break\nelse:\n print('No')", "neg": "n=int(input())\nal=list(map(int,input().split()))\nbl=list(map(int,input().split()))\nail=[(i,a) for i,a in enumerate(al)]\nbil=[(i,b) for i,b in enumerate(bl)]\nail=sorted(ail,key=lambda x:x[1])\nbil=sorted(bil,key=lambda x:x[1])\nif not all([ail[i][1]<=bil[i][1] for i in range(n)]):\n print('No')\n exit()\nif any([ail[i][0]==bil[i][0] for i in range(n)]):\n print('Yes')\n exit()\nc=[(ail[i][0],bil[i][0]) for i in range(n)]\nc=sorted(c)\nprint(c)\nidx=0\nfor _ in range(n-1):\n idx=c[idx][1]\n if idx==0:\n print('Yes')\n break\nelse:\n print('No')", "jacc_sim": 0.9791666666666666, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [262, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u778113870", "n_user": "u778113870", "pos": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nba = sorted((y, x) for x, y in zip(a, b))\na = [x for y, x in ba]\nb = [y for y, x in ba]\n\n# print(a)\n# print(b) \n\nap = sorted((x, i) for i, x in enumerate(a))\n\n# print(ap) \nif any(ap[i][0] > b[i] for i in range(n)):\n print('No')\n exit()\nif any(ap[i + 1][0] <= b[i] for i in range(n - 1)):\n print('Yes')\n exit()\n\nrep = [ap[i][1] for i in range(n)]\np = 0\nc = 0\nwhile True:\n c += 1\n p = rep[p]\n if p == 0:\n break\nprint(['No', 'Yes'][c != n])", "neg": "n = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nba = sorted((y, x) for x, y in zip(a, b))\na = [x for y, x in ba]\nb = [y for y, x in ba]\n\n\nap = sorted((x, i) for i, x in enumerate(a))\n\nprint(ap) \nif any(ap[i][0] > b[i] for i in range(n)):\n print('No')\n exit()\nif any(ap[i + 1][0] <= b[i] for i in range(n - 1)):\n print('Yes')\n exit()\n\nrep = [ap[i][1] for i in range(n)]\np = 0\nc = 0\nprint(['No', 'Yes'][rep[n-1] != 0])\n", "jacc_sim": 0.9166666666666666, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [255, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u164727245", "n_user": "u164727245", "pos": "# coding: utf-8\nimport numpy as np\n\n\ndef solve(*args: str) -> str:\n n = int(args[0])\n A = np.array(list(map(int, args[1].split())))\n B = np.array(list(map(int, args[2].split())))\n\n ret = False\n\n sA = np.sort(A)\n sB = np.sort(B)\n\n if all(sA <= sB):\n if any(sA[1:] <= sB[:-1]):\n ret = True\n else:\n nA = np.argsort(A)\n nB = np.argsort(B)\n P = dict(zip(nA, nB))\n\n count = 0\n x = P[0]\n while x != 0:\n x = P[x]\n count += 1\n\n ret = count < n-1\n\n return 'Yes' if ret else 'No'\n\n\nif __name__ == \"__main__\":\n print(solve(*(open(0).read().splitlines())))\n", "neg": "# coding: utf-8\nimport numpy as np\n\n\ndef solve(*args: str) -> str:\n n = int(args[0])\n A = np.array(list(map(int, args[1].split())))\n B = np.array(list(map(int, args[2].split())))\n\n ret = False\n\n sA = np.sort(A)\n sB = np.sort(B)\n\n if any(sA[1:] <= sB[:-1]):\n ret = True\n\n elif all(sA <= sB):\n nA = np.argsort(A)\n nB = np.argsort(B)\n P = dict(zip(nA, nB))\n\n count = 0\n x = P[0]\n while x != 0:\n x = P[x]\n count += 1\n\n ret = count < n-1\n\n return 'Yes' if ret else 'No'\n\n\nif __name__ == \"__main__\":\n print(solve(*(open(0).read().splitlines())))\n", "jacc_sim": 0.984375, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [269, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline \n\nn = int(input())\na = [int(i) for i in readline().split()]\nb = [int(i) for i in readline().split()]\npb = [(bi,i) for i,bi in enumerate(b)]\n\nsa = sorted(a)\nsb = sorted(b)\npb.sort()\n\nna = [a[i] for bi,i in pb]\n\n\nok = 1\nfor i,j in zip(sa,sb):\n if i > j: ok = 0\n\nfor i,j in zip(sa[1:],sb):\n if i <= j: break\nelse:\n #sa => na \u304c\u5de1\u56de\u7f6e\u63db\u304b\uff1f\n d = {ai:i for i,ai in enumerate(sa)}\n ra = [d[ai] for ai in na]\n \n #print(ra,ok) \n now = 0\n for i in range(n-1):\n now = ra[now]\n #print(now)\n if now == 0:\n break\n else: ok = 0 \n\n\n \n\n#print(a,b,sa,sb,na)\n\nif ok: print(\"Yes\") \nelse: print(\"No\")\n \n \n \n \n \n ", "neg": "# coding: utf-8\n# Your code here!\n\nimport sys\nsys.setrecursionlimit(10**6)\nreadline = sys.stdin.readline \n\nn = int(input())\na = [int(i) for i in readline().split()]\nb = [int(i) for i in readline().split()]\npb = [(bi,i) for i,bi in enumerate(b)]\n\nsa = sorted(a)\nsb = sorted(b)\npb.sort()\n\nna = [a[i] for bi,i in pb]\n\n\nok = 1\nfor i,j in zip(sa,sb):\n if i > j: ok = 0\n\nfor i,j in zip(sa[1:],sb):\n if i <= j: break\nelse:\n #sa => na \u304c\u5de1\u56de\u7f6e\u63db\u304b\uff1f\n d = {ai:i for i,ai in enumerate(sa)}\n ra = [d[ai] for ai in na]\n \n print(ra) \n now = 0\n for i in range(n-1):\n now = ra[now]\n #print(now)\n if now == 0:\n break\n else: ok = 0 \n\n \n \n \n\n \n\n#print(a,b,sa,sb,na)\n\nif ok: print(\"Yes\") \nelse: print(\"No\")\n \n \n \n \n \n ", "jacc_sim": 1.0, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [354, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u864197622", "n_user": "u864197622", "pos": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nA = [(A[i]<<18) + i for i in range(N)]\nB = [(B[i]<<18) + i + (1<<17) for i in range(N)]\nAA = sorted(A)\nBB = sorted(B)\n\nIA = {}\nIB = {}\nfor i in range(N):\n IA[AA[i]] = i\n IB[BB[i]] = i\n\nfor i in range(N):\n if AA[i] > BB[i]:\n print(\"No\")\n break\nelse:\n for i in range(1, N):\n if AA[i] <= BB[i-1]:\n print(\"Yes\")\n break\n else:\n for i in range(N):\n if IA[A[i]] == IB[B[i]]:\n print(\"Yes\")\n break\n else:\n c = 1\n i = 0\n P = [-1] * N\n for i in range(N):\n P[IA[A[i]]] = IB[B[i]]\n i = P[0]\n while i != 0:\n i = P[i]\n c += 1\n if c < N:\n print(\"Yes\")\n else:\n print(\"No\")", "neg": "N = int(input())\nA = [int(a) for a in input().split()]\nB = [int(a) for a in input().split()]\nA = [(A[i]<<18) + i for i in range(N)]\nB = [(B[i]<<18) + i + (1<<17) for i in range(N)]\nAA = sorted(A)\nBB = sorted(B)\n\nIA = {}\nIB = {}\nfor i in range(N):\n IA[AA[i]] = i\n IB[BB[i]] = i\n\nfor i in range(N):\n if AA[i] > BB[i]:\n print(\"No\")\n break\nelse:\n for i in range(1, N):\n if AA[i] <= BB[i-1]:\n print(\"No\")\n break\n else:\n for i in range(N):\n if IA[A[i]] == IB[B[i]]:\n print(\"Yes\")\n break\n else:\n c = 1\n i = IA[A[0]]\n i = IA[A[IB[B[i]]]]\n while i != IA[A[0]]:\n i = IA[A[IB[B[i]]]]\n c += 1\n if c < N:\n print(\"Yes\")\n else:\n print(\"No\")", "jacc_sim": 0.9565217391304348, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [346, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02867", "p_user": "u918601425", "n_user": "u918601425", "pos": "N=int(input())\nA1=[int(s) for s in input().split()]\nB1=[int(s) for s in input().split()]\nA2=[(A1[i],i) for i in range(N)]\nB2=[(B1[i],i) for i in range(N)]\nA=sorted(A2)\nB=sorted(B2)\n#print(A)\n#print(B)\nfor i in range(N):\n if B[i][0]=A[i+1][0]:\n print(\"Yes\")\n break\n else:\n C=[(A[i][1],B[i][1]) for i in range(N)]\n C.sort()\n# print(C)\n k=0\n for i in range(N-1):\n k=C[k][1]\n if k==0:\n print(\"Yes\")\n break\n else:\n print(\"No\")\n \n", "neg": "N=int(input())\nA1=[int(s) for s in input().split()]\nB1=[int(s) for s in input().split()]\nA2=[(A1[i],i) for i in range(N)]\nB2=[(B1[i],i) for i in range(N)]\nA=sorted(A2)\nB=sorted(B2)\nprint(A)\nprint(B)\nfor i in range(N):\n if B[i][0]=A[i+1][0]:\n print(\"Yes\")\n break\n else:\n k=0\n for i in range(N-1):\n k=B[k][1]\n if k==0:\n print(\"Yes\")\n break\n else:\n print(\"No\")\n \n", "jacc_sim": 0.926829268292683, "nl": "You are given two sequences of N integers, A1,...,AN and B1,...,BN. Determine if it's possible to perform the following operation at most N-2 times (possibly zero) so that for every integer i from 1 to N, Ai \u2264 Bi holds: Choose two distinct integers x and y between 1 and N (inclusive), and swap the values of Ax and Ay. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai, Bi \u2264 10^9. Input is given as N followed by the sequences A and B. Output \"Yes\" if the objective is achievable, and \"No\" if it is not. Example: Input: 3, 1 3 2, 1 2 3. Output: Yes (swap A2 and A3).", "before_after_length": [275, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02868", "p_user": "u969190727", "n_user": "u969190727", "pos": "import sys\ninput=sys.stdin.readline\nimport heapq\nn,m=map(int,input().split())\n\nD=[0]\nP=[]\nans=float(\"inf\")\n\nfor i in range(m):\n l,r,c=map(int,input().split())\n P.append((l,r,c))\nP.sort(key=lambda x:x[0])\nheapq.heappush(D,0*10**15+1)\nfor l,r,c in P:\n while D:\n ld=heapq.heappop(D)\n dd=ld//(10**15)\n ll=ld%(10**15)\n if ll=l:\n heapq.heappush(D,r+(dd+c)*10**15)\n heapq.heappush(D,ll+dd*10**15)\nwhile D:\n ld=heapq.heappop(D)\n dd=ld//(10**15)\n ll=ld%(10**15)\n if ll==n:\n ans=min(ans,dd)\nprint(-1 if ans==float(\"inf\") else ans)\n\n\n ", "neg": "import sys\ninput=sys.stdin.readline\nimport heapq\nn,m=map(int,input().split())\n\nD=[0]\nP=[]\nans=float(\"inf\")\n\nfor i in range(m):\n l,r,c=map(int,input().split())\n P.append((l,r,c))\nP.sort(key=lambda x:x[0])\nheapq.heappush(D,1*10**15+0)\nfor l,r,c in P:\n while D:\n ld=heapq.heappop(D)\n ll=ld//(10**15)\n dd=ld%(10**15)\n if ll=l:\n heapq.heappush(D,r*10**15+dd+c)\n heapq.heappush(D,ll*10**15+dd)\nprint(D)\nwhile D:\n ld=heapq.heappop(D)\n ll=ld//(10**15)\n dd=ld%(10**15)\n if ll==n:\n ans=min(ans,dd)\nprint(-1 if ans==float(\"inf\") else ans)\n\n\n ", "jacc_sim": 1.0, "nl": "You are given N points arranged in a line. Takahashi adds edges between these points using M operations. Each operation connects points within a given range with a specific length. Find the shortest path from point 1 to point N in the final graph. If no path exists, output -1. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 Li < Ri \u2264 N, 1 \u2264 Ci \u2264 10^9. Input format: N M, followed by M lines of Li, Ri, and Ci. Output the length of the shortest path or -1.", "before_after_length": [302, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02868", "p_user": "u777923818", "n_user": "u777923818", "pos": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import defaultdict\nfrom operator import itemgetter\nfrom heapq import heappop, heappush\n#input = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\n\nN, M = inpl()\nD = [0] + [10**18]*(N-1)\ng0 = itemgetter(0)\nQ = sorted([inpl() for _ in range(M)], key=g0, reverse=True)\n#print(*Q, sep=\"\\n\")\n\nHQ = [(0, 0), (10**18, N)]\n\nfor i in range(N):\n while HQ[0][1] < i:\n heappop(HQ)\n v = HQ[0][0]\n while len(Q) and (i == (Q[-1][0]-1)):\n l, r, c = Q.pop()\n heappush(HQ, (v+c, r-1))\n\n\nif v == 10**18:\n print(-1)\nelse:\n print(v)", "neg": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import defaultdict\nfrom operator import itemgetter\nfrom heapq import heappop, heappush\ninput = sys.stdin.readline\ndef inpl(): return list(map(int, input().split()))\n\nN, M = inpl()\nD = [0] + [10**18]*(N-1)\ng0 = itemgetter(0)\nQ = sorted([inpl() for _ in range(M)], key=g0, reverse=True)\n#print(*Q, sep=\"\\n\")\n\nHQ = [(0, 0)]\n\nfor i in range(N):\n while HQ[0][1] < i:\n heappop(HQ)\n v = HQ[0][0]\n while len(Q) and (i == (Q[-1][0]-1)):\n l, r, c = Q.pop()\n heappush(HQ, (v+c, r-1))\n\n\nif v == 10**18:\n print(-1)\nelse:\n print(v)", "jacc_sim": 1.0, "nl": "You are given N points arranged in a line. Takahashi adds edges between these points using M operations. Each operation connects points within a given range with a specific length. Find the shortest path from point 1 to point N in the final graph. If no path exists, output -1. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 M \u2264 10^5, 1 \u2264 Li < Ri \u2264 N, 1 \u2264 Ci \u2264 10^9. Input format: N M, followed by M lines of Li, Ri, and Ci. Output the length of the shortest path or -1.", "before_after_length": [271, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02869", "p_user": "u923270446", "n_user": "u923270446", "pos": "n, k = map(int, input().split())\nif 2 * k > n + 1:\n exit(print(-1))\nelse:\n if n % 2 == 0:\n for i in range(n):\n if i % 2 == 0:\n print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)\n else:\n print(k + i // 2 + n // 2, k + i // 2 + n, k + i + n * 2)\n else:\n for i in range(n):\n if i % 2 == 0:\n print(k + i // 2, k + (i + n * 3) // 2, k + i + n * 2)\n else:\n print(k + i // 2 + n // 2 + 1, k + i // 2 + n, k + i + n * 2)", "neg": "n, k = map(int, input().split())\nif 2 * k > n + 1:\n exit(print(-1))\nelse:\n if n % 2 == 0:\n for i in range(n):\n if i % 2 == 0:\n print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=\" \")\n else:\n print(i // 2 + n // 2 + k, i // 2 + n + k, i + n * 2 + k, end=\" \")\n else:\n for i in range(n):\n if i % 2 == 0:\n print(i // 2 + k, (i + n * 3) // 2, i + n * 2 + k, end=\" \")\n else:\n print(i // 2 + n // 2 + k + 1, i // 2 + n + k, i + n * 2 + k, end=\" \")", "jacc_sim": 0.9375, "nl": "You are given two positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be divided into N triples (a1, b1, c1), ..., (aN, bN, cN) such that for each i from 1 to N, ai + bi \u2264 ci holds. If possible, construct one such partition. If it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the format a1 b1 c1 : aN bN cN.", "before_after_length": [212, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02869", "p_user": "u218843509", "n_user": "u787456042", "pos": "n, k = map(int, input().split())\nif 2*k > n+1:\n\tprint(-1)\nelse:\n\tfor i in range(n//2):\n\t\tprint((2*k+n-2)//2 - i, k+n+1+2*i, k+2*n+i)\n\tfor i in range(n-n//2):\n\t\tprint(k+n-1-i, k+n+2*i, k+2*n+n//2+i)", "neg": "n, k = map(int, input().split())\nif n>1+2*k: print(-1)\nelse:\n for i in range(k): print(i+1, 2*k-i, 2*k+i+1)\n", "jacc_sim": 0.9615384615384616, "nl": "You are given two positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be divided into N triples (a1, b1, c1), ..., (aN, bN, cN) such that for each i from 1 to N, ai + bi \u2264 ci holds. If possible, construct one such partition. If it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the format a1 b1 c1 : aN bN cN.", "before_after_length": [124, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02869", "p_user": "u111365362", "n_user": "u923270446", "pos": "n,k = map(int,input().split())\nif n % 2 == 0:\n if 2*k > n:\n print(-1)\n else:\n for i in range(n//2):\n print(k+2*i, k+(3*n)//2-1-i, k+2*n+i)\n for i in range(n//2):\n print(k+1+2*i, k+2*n-1-i, k+(5*n)//2+i)\nelse:\n if 2*k-1 > n:\n print(-1)\n else:\n for i in range((n+1)//2):\n print(k+2*i, k+(3*n-1)//2-i, k+2*n+i)\n for i in range((n-1)//2):\n print(k+1+2*i, k+2*n-1-i, k+(5*n+1)//2+i)", "neg": "n, k = map(int, input().split())\nif 2 * k > n + 1:\n exit(print(-1))\nelse:\n if n % 2 == 0:\n for i in range(n):\n if i % 2 == 0:\n print(k + i // 2, (i + n * 3) // 2, k + i + n * 2)\n else:\n print(k + i // 2 + n // 2, k + i // 2 + n, k + i + n * 2)\n print()\n else:\n for i in range(n):\n if i % 2 == 0:\n print(k + i // 2, (i + n * 3) // 2, k + i + n * 2)\n else:\n print(k + i // 2 + n // 2 + 1, i // 2 + n + k, k + i + n * 2)", "jacc_sim": 0.9354838709677419, "nl": "You are given two positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be divided into N triples (a1, b1, c1), ..., (aN, bN, cN) such that for each i from 1 to N, ai + bi \u2264 ci holds. If possible, construct one such partition. If it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the format a1 b1 c1 : aN bN cN.", "before_after_length": [247, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02869", "p_user": "u627417051", "n_user": "u627417051", "pos": "#\u8a2d\u5b9a\nimport sys\ninput = sys.stdin.buffer.readline\n\n#\u30e9\u30a4\u30d6\u30e9\u30ea\u30a4\u30f3\u30dd\u30fc\u30c8\nfrom collections import defaultdict\n\n#\u5165\u529b\u53d7\u3051\u53d6\u308a\ndef getlist():\n\treturn list(map(int, input().split()))\n\n#\u51e6\u7406\u5185\u5bb9\ndef main():\n\tN, K = getlist()\n\tif 2 * K - 1 > N:\n\t\tprint(-1)\n\telse:\n\t\tif N % 2 == 1:\n\t\t\tans = [[0, 0, 0] for i in range(N)]\n\t\t\tfor i in range(N):\n\t\t\t\tans[i][2] = K + 2 * N + i\n\t\t\tfor i in range(N):\n\t\t\t\tans[(2 * i) % N][(2 * i) // N] = K + i\n\t\t\t\tans[(2 * i + 1) % N][(2 * i + 1) // N] = K + N + i\n\t\telse:\n\t\t\tans = [[0, 0, 0] for i in range(N)]\n\t\t\tfor i in range(N):\n\t\t\t\tans[i][2] = K + 2 * N + i\n\t\t\tn = N // 2\n\t\t\tfor i in range(n):\n\t\t\t\tans[2 * i][0] = K + i\n\t\t\t\tans[2 * i + 1][0] = K + N + i\n\t\t\tfor i in range(n, N):\n\t\t\t\tans[2 * i - N][1] = K + N + i\n\t\t\t\tans[2 * i + 1 - N][1] = K + i\n\t\tfor i in range(N):\n\t\t\tprint(\" \".join(list(map(str, ans[i]))))\n\nif __name__ == '__main__':\n\tmain()", "neg": "#\u8a2d\u5b9a\nimport sys\ninput = sys.stdin.buffer.readline\n\n#\u30e9\u30a4\u30d6\u30e9\u30ea\u30a4\u30f3\u30dd\u30fc\u30c8\nfrom collections import defaultdict\n\n#\u5165\u529b\u53d7\u3051\u53d6\u308a\ndef getlist():\n\treturn list(map(int, input().split()))\n\n#\u51e6\u7406\u5185\u5bb9\ndef main():\n\tN, K = getlist()\n\tif 2 * K - 1 > N:\n\t\tprint(-1)\n\telse:\n\t\tif N % 2 == 1:\n\t\t\tans = [[0, 0, 0] for i in range(N)]\n\t\t\tprint(ans)\n\t\t\tfor i in range(N):\n\t\t\t\tans[i][2] = K + 2 * N + i\n\t\t\tfor i in range(N):\n\t\t\t\tans[(2 * i) % N][(2 * i) // N] = K + i\n\t\t\t\tans[(2 * i + 1) % N][(2 * i + 1) // N] = K + N + i\n\t\telse:\n\t\t\tans = [[0, 0, 0] for i in range(N)]\n\t\t\tfor i in range(N):\n\t\t\t\tans[i][2] = K + 2 * N + i\n\t\t\tn = N // 2\n\t\t\tfor i in range(n):\n\t\t\t\tans[2 * i][0] = K + i\n\t\t\t\tans[2 * i + 1][0] = K + N + i\n\t\t\tfor i in range(n, N):\n\t\t\t\tans[2 * i - N][1] = K + N + i\n\t\t\t\tans[2 * i + 1 - N][1] = K + i\n\t\tfor i in range(N):\n\t\t\tprint(\" \".join(list(map(str, ans[i]))))\n\nif __name__ == '__main__':\n\tmain()", "jacc_sim": 1.0, "nl": "You are given two positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be divided into N triples (a1, b1, c1), ..., (aN, bN, cN) such that for each i from 1 to N, ai + bi \u2264 ci holds. If possible, construct one such partition. If it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the format a1 b1 c1 : aN bN cN.", "before_after_length": [468, 475], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02869", "p_user": "u327466606", "n_user": "u327466606", "pos": "\n\n\ndef solve(N,K):\n if 2*K > N+1:\n print(-1)\n return\n\n def it():\n\n for i in range((N+1)//2):\n yield (K+i, K+N+i+N//2, K+N*2+i*2)\n for i in range(N//2):\n yield (K+(N+1)//2 + i, K+N+i, K+N*2+i*2+1)\n\n for a,b,c in it():\n print(a,b,c)\n\nN,K = map(int,input().split())\nsolve(N,K)", "neg": "\n\n\ndef solve(N,K):\n if 2*K < N-1:\n print(-1)\n return\n\n def it():\n\n for i in range((N+1)//2):\n yield (K+i, K+N+i+N//2, K+N*2+i*2)\n for i in range(N//2):\n yield (K+(N+1)//2 + i, K+N+i, K+N*2+i*2+1)\n\n for a,b,c in it():\n print(a,b,c)\n\nN,K = map(int,input().split())\nsolve(N,K)", "jacc_sim": 0.9411764705882353, "nl": "You are given two positive integers N and K. Determine if the 3N integers K, K+1, ..., K+3N-1 can be divided into N triples (a1, b1, c1), ..., (aN, bN, cN) such that for each i from 1 to N, ai + bi \u2264 ci holds. If possible, construct one such partition. If it is impossible to partition the integers satisfying the condition, print -1. If it is possible, print N triples in the format a1 b1 c1 : aN bN cN.", "before_after_length": [167, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u572142121", "n_user": "u572142121", "pos": "N=int(input())\nA=[]\ndd=0\nLL,RR=[],[]\n\nfor i in range(N):\n L,R=map(int, input().split())\n LL.append(L)\n RR.append(R)\n A.append((L,-R))\nLL=sorted(LL)\nRR=sorted(RR)\nA=sorted(A)\ndl,dr=0,10**9+1\nel,er=0,10**9+1\nD=[0 for i in range(N-1)]\nE=[0 for i in range(N-1)]\n\nfor i in range(N-1):\n dl=max(dl,A[i][0])\n dr=min(dr,-A[i][1])\n D[i]=dr-dl+1\n el=max(el,A[-1-i][0])\n er=min(er,-A[-1-i][1])\n E[-i-1]=er-el+1\nans=dd\nfor i in range(len(D)):\n d=max(0,D[i])+max(0,E[i])\n ans=max(d,ans)\nfor L,R in A:\n l=LL[-1]\n r=RR[0]\n if l==L:\n l=LL[-2]\n if r==-R:\n r=RR[1]\n d=(-R-L+1)+max(0,r-l+1)\n ans=max(ans,d)\nprint(ans) ", "neg": "N=int(input())\nA=[]\ndd=0\nLL,RR=[],[]\n\nfor i in range(N):\n L,R=map(int, input().split())\n LL.append(L)\n RR.append(R)\n A.append((L,-R))\nLL=sorted(LL)\nRR=sorted(RR)\nA=sorted(A)\ndl,dr=0,10**9+1\nel,er=0,10**9+1\nD=[0 for i in range(N-1)]\nE=[0 for i in range(N-1)]\n\nfor i in range(N-1):\n dl=max(dl,A[i][0])\n dr=min(dr,-A[i][1])\n D[i]=dr-dl+1\n el=max(el,A[-1-i][0])\n er=min(er,-A[-1-i][1])\n E[-i-1]=er-el+1\nans=dd\nfor i in range(len(D)):\n d=max(0,D[i])+max(0,E[i])\n ans=max(d,ans)\nfor L,R in A:\n l=LL[-1]\n r=RR[0]\n if LL[0]==L:\n l=LL[-2]\n if RR[0]==R:\n r=RR[1]\n d=(-R-L+1)+max(0,r-l+1)\n ans=max(ans,d)\nprint(ans) ", "jacc_sim": 1.0, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [379, 384], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [list(map(int, input().split())) for i in range(n)]\nlmx = 0\nlmxi = -1\nrmn = 10**18\nrmni = -1\nansls = []\nanstmp = 0\na.sort(reverse=True)\nfor i in range(n):\n if a[i][0] >= lmx:\n lmx = a[i][0]\n lmxi = i\n if rmn >= a[i][1]:\n rmn = a[i][1]\n rmni = i\nfor i in range(n):\n if i not in (lmxi,rmni):\n anstmp = max(anstmp,a[i][1]-a[i][0]+1)\nansls.append(anstmp+max(0,rmn-lmx+1))\nrmnt = a[0][1]\nrmnls = [0 for i in range(n)]\nrmnls[-1] = a[-1][1]\nfor i in range(n-1)[::-1]:\n rmnls[i] = min(rmnls[i+1],a[i][1])\nfor i in range(n-1):\n rmnt = min(rmnt,a[i][1])\n anstmp = 0\n anstmp += max(0,rmn-a[i+1][0]+1)\n anstmp += max(0,rmnt-lmx+1)\n ansls.append(anstmp)\nprint(max(ansls))", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [list(map(int, input().split())) for i in range(n)]\nlmx = 0\nlmxi = -1\nrmn = 10**18\nrmni = -1\nansls = []\nanstmp = 0\na.sort(reverse=True)\nfor i in range(n):\n if a[i][0] >= lmx:\n lmx = a[i][0]\n lmxi = i\n if rmn >= a[i][1]:\n rmn = a[i][1]\n rmni = i\nfor i in range(n):\n if i not in (lmxi,rmni):\n anstmp = max(anstmp,a[i][1]-a[i][0]+1)\nansls.append(anstmp+max(0,rmn-lmx+1))\nrmnt = a[0][1]\nrmnls = [0 for i in range(n)]\nrmnls[-1] = a[-1][1]\nfor i in range(n-1)[::-1]:\n rmnls[i] = min(rmnls[i+1],a[i][1])\nfor i in range(n-1):\n if i in (lmxi,rmni):\n continue\n rmnt = min(rmnt,a[i][1])\n anstmp = 0\n anstmp += max(0,rmn-a[i+1][0]+1)\n anstmp += max(0,rmnt-lmx+1)\n ansls.append(anstmp)\nprint(max(ansls))", "jacc_sim": 0.9795918367346939, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [395, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u145600939", "n_user": "u145600939", "pos": "n = int(input())\nL,R = [0]*n,[0]*n\nfor i in range(n):\n L[i],R[i] = map(int,input().split())\n R[i] += 1\n\nM = L.index(max(L))\nm = R.index(min(R))\n\nd = [R[i] - L[i] if M != i != m else 0 for i in range(n)]\nans = max(d) + max(R[m] - L[M], 0)\nd[m] = R[m] - L[m]\nd[M] = R[M] - L[M]\nif m == M:\n print(ans)\n exit()\nif n == 2:\n print(d[m] + d[M])\n exit()\na,b = [0]*(n-2),[0]*(n-2)\nj = 0\nfor i in range(n):\n if m != i != M:\n a[j],b[j] = max(R[i]-L[M],0) , max(R[m]-L[i],0)\n j += 1\nab = sorted(list(zip(a,b)),reverse = True)\nmb = [0]*len(a)\nfor i in range(len(a))[::-1]:\n if i == len(a)-1:\n mb[i] = ab[i][1]\n else:\n mb[i] = min(ab[i][1], mb[i+1])\nfor i in range(len(a) - 1):\n ans = max(ans,min(ab[i][0],d[M]) + min(mb[i + 1],d[m]))\nans = max(ans , d[M] + min(mb[0], d[m]), min(ab[len(a)-1][0],d[M]) + d[m])\n\nprint(ans)\n", "neg": "n = int(input())\nL,R = [0]*n,[0]*n\nfor i in range(n):\n L[i],R[i] = map(int,input().split())\n R[i] += 1\n\nM = L.index(max(L))\nm = R.index(min(R))\n\nd = [R[i] - L[i] for i in range(n)]\nans = max(d) + max(R[m] - L[M], 0)\nif m == M:\n print(ans)\n exit()\nif n == 2:\n print(d[m] + d[M])\n exit()\na,b = [0]*n,[0]*n\nfor i in range(n):\n a[i],b[i] = max(R[i]-L[M],0) , -max(R[m]-L[i],0)\nab = sorted(list(zip(a,b)),reverse = True)\nmb = [0]*n\nfor i in range(n)[::-1]:\n if i == n-1:\n mb[i] = -ab[i][1]\n else:\n mb[i] = min(-ab[i][1], mb[i+1])\nfor i in range(n-1):\n ans = max(ans,min(a[i],d[M]) + min(mb[i + 1],d[m]))\nans = max(ans , d[M] + min(mb[0], d[m]), min(a[len(a)-1],d[M]) + d[m])\n\nprint(ans)\n", "jacc_sim": 0.9583333333333334, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [471, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u824237520", "n_user": "u824237520", "pos": "import sys\nsys.setrecursionlimit(10 ** 9)\n\nn = int(input())\nLR = [tuple(map(int, input().split())) for _ in range(n)]\n\ndef quicksort(x):\n if x==[]: return []\n\n smallerSorted = quicksort([a for a in x[1:] if a[0] < x[0][0] or (a[0] == x[0][0] and a[1] >= x[0][1])])\n biggerSorted = quicksort([a for a in x[1:] if a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1])])\n\n return(smallerSorted+[x[0]]+biggerSorted)\n\nLR = quicksort(LR)\n\ne = [[] for _ in range(n+2)]\n\nans = [0] * (n+1)\ntemp = 10 ** 9\ni = 1\nfor L, R in LR:\n temp = min(temp, R)\n if L > temp:\n break\n ans[i] = temp - L + 1\n i += 1\n\ntemp = 10 ** 9\ni = n - 1\nL = LR[-1][0]\nfor x, R in reversed(LR):\n temp = min(temp, R)\n if L > temp:\n break\n ans[i] += temp - L + 1\n i -= 1\n\nres = max(ans)\nfor L, R in LR:\n res = max(res, R - L + 1 + ans[0])\n\n#print(LR)\n#print(ans)\nprint(res)\n", "neg": "import sys\nsys.setrecursionlimit(10 ** 9)\n\nn = int(input())\nLR = [tuple(map(int, input().split())) for _ in range(n)]\n\ndef quicksort(x):\n if x==[]: return []\n\n smallerSorted = quicksort([a for a in x[1:] if (a[0] < x[0][0] or (a[0] == x[0][0] and a[1] >= x[0][1])])\n biggerSorted = quicksort([a for a in x[1:] if (a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1]))])\n\n return(smallerSorted+[x[0]]+biggerSorted)\n\nLR = quicksort(LR)\n\nans = [0] * (n+1)\ntemp = 10 ** 9\ni = 1\nfor L, R in LR:\n temp = min(temp, R)\n if L > temp:\n break\n ans[i] = temp - L + 1\n i += 1\n#print(ans)\ntemp = 10 ** 9\ni = n - 1\nL = LR[-1][0]\nfor x, R in reversed(LR):\n temp = min(temp, R)\n if L > temp:\n break\n ans[i] += temp - L + 1\n i -= 1\n\nprint(max(ans))", "jacc_sim": 0.9464285714285714, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [405, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u170201762", "n_user": "u170201762", "pos": "N = int(input())\nLR = [list(map(int,input().split())) for _ in range(N)]\n\nLR.sort(key=lambda x:[-x[0],x[1]])\nML = LR[0][0]\nMR = LR[0][1]\nLR.sort(key=lambda x:[x[1],-x[0]])\nmR = LR[0][1]\nmL = LR[0][0]\n\nans = max(mR-ML+1,0)\nfor i in range(N):\n if LR[i] not in [[ML,MR],[mL,mR]]:\n ans = max(ans,max(mR-ML+1,0)+max(LR[i][1]-LR[i][0]+1,0))\n\nLR.sort(key=lambda x:[x[1],x[0]])\n\nL_ = [0]*N\nfor i in range(N):\n L_[i] = max(LR[i][0],L_[i-1])\n\nfor i in range(1,N):\n ans = max(ans,max(LR[i][1]-ML+1,0)+max(mR-L_[i-1]+1,0))\n\nprint(ans)", "neg": "N = int(input())\nLR = [list(map(int,input().split())) for _ in range(N)]\n\n\nML = max(LR)[0]\nmR = min(LR,key=lambda x:x[1])[1]\n\nans = max(ML-mR+1,0)+max([LR[i][1]-LR[i][0]+1 for i in range(N)])\nLR.sort(key=lambda x:[x[1],x[0]])\n\nL_ = [0]*N\nfor i in range(N):\n L_[i] = min(L[i],L_[i-1])\n\nfor i in range(1,N):\n ans = max(ans,max(LR[i]-ML+1,0)+max(mR-L_[i-1]+1,0))\n\nprint(ans)", "jacc_sim": 0.9024390243902439, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [313, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02874", "p_user": "u340781749", "n_user": "u340781749", "pos": "import sys\nfrom itertools import accumulate\n\n\ndef calc(tasks):\n tasks_l, tasks_r = zip(*tasks)\n tasks_l_acc_fwd = list(accumulate(tasks_l, func=max))\n tasks_l_acc_bwd = list(reversed(list(accumulate(reversed(tasks_l), func=max))))\n tasks_r_acc_fwd = list(accumulate(tasks_r, func=min))\n tasks_r_acc_bwd = list(reversed(list(accumulate(reversed(tasks_r), func=min))))\n # print(tasks)\n # print(tasks_r_acc_fwd)\n # print(tasks_r_acc_bwd)\n\n score = 0\n for i in range(1, n):\n left_max_l = tasks_l_acc_fwd[i - 1]\n left_min_r = tasks_r_acc_fwd[i - 1]\n right_max_l = tasks_l_acc_bwd[i]\n right_min_r = tasks_r_acc_bwd[i]\n tmp_score = max(0, left_min_r - left_max_l + 1) + max(0, right_min_r - right_max_l + 1)\n score = max(score, tmp_score)\n return score\n\n\nn = int(input())\nappeared_lr = set()\ntasks = []\nfor line in sys.stdin:\n l, r = list(map(int, line.split()))\n appeared_lr.add(l)\n appeared_lr.add(r)\n tasks.append((l, r))\n\ntasks.sort()\nans1 = calc(tasks)\n\ntasks.sort(key=lambda lr: (lr[0], -lr[1]))\nans2 = calc(tasks)\n\ntasks.sort(key=lambda lr: (lr[1] - lr[0], lr[0], lr[1]))\nans3 = calc(tasks)\n\nprint(max(ans1, ans2, ans3))\n", "neg": "import sys\nfrom itertools import accumulate\n\n\ndef calc(tasks):\n tasks_l, tasks_r = zip(*tasks)\n tasks_r_acc_fwd = list(accumulate(tasks_r, func=min))\n tasks_r_acc_bwd = list(reversed(list(accumulate(reversed(tasks_r), func=min))))\n # print(tasks)\n # print(tasks_r_acc_fwd)\n # print(tasks_r_acc_bwd)\n\n right_max_l = tasks_l[-1]\n score = 0\n for i in range(1, n):\n left_max_l = tasks_l[i - 1]\n left_min_r = tasks_r_acc_fwd[i - 1]\n right_min_r = tasks_r_acc_bwd[i]\n tmp_score = max(0, left_min_r - left_max_l + 1) + max(0, right_min_r - right_max_l + 1)\n score = max(score, tmp_score)\n return score\n\n\nn = int(input())\nappeared_lr = set()\ntasks = []\nfor line in sys.stdin:\n l, r = list(map(int, line.split()))\n appeared_lr.add(l)\n appeared_lr.add(r)\n tasks.append((l, r))\n\ntasks.sort()\nans1 = calc(tasks)\n\ntasks.sort(key=lambda lr: (lr[0], -lr[1]))\nans2 = calc(tasks)\n\ntasks.sort(key=lambda lr: (lr[1] - lr[0], lr[0], lr[1]))\nans3 = calc(tasks)\n\nprint(max(ans1, ans2, ans3))\n", "jacc_sim": 0.9696969696969697, "nl": "You are given N problems and a range for each problem. Contestants will solve problems within the given range. Each problem must be used in exactly one of two contests. The joyfulness of a contest is the number of contestants solving all problems in that contest. Find the maximum possible total joyfulness of the two contests. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Li \u2264 Ri \u2264 10^9. Input format: N, followed by N lines of Li and Ri. Output the maximum possible total joyfulness of the two contests.", "before_after_length": [504, 439], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02875", "p_user": "u180645294", "n_user": "u180645294", "pos": "\nn=int(input())\npre=[1]*(n//2+200)\npp=[1]*(n+1)\nmod=998244353\nfor i in range(1,n//2+100):\n pre[i]=((pre[i-1]*2)%mod)\n \np=[1]*(n+1)\nfor i in range(n):\n p[i+1]=((p[i]*(i+1))%mod)\npp[-1] = pow(p[-1], mod - 2, mod)\n \nfor i in range(2, n + 1):\n\tpp[-i] = int((pp[-i + 1] * (n + 2 - i)) % mod)\ntot=1\nfor i in range(n):\n tot*=3\n tot%=mod\n#print(1)\n#print(tot)\ncc=0\nfor i in range(n//2+1,n+1):\n c=(((((p[n]*pp[i])%mod)*pp[n-i])%mod)*pre[n-i])%mod\n c%=mod\n cc+=c\ntot-=cc\ntot-=cc\ntot%=mod\nprint(tot)\n", "neg": "\nn=int(input())\npre=[1]*(n//2+200)\npp=[1]*(n+1)\nmod=998244353\nfor i in range(1,n//2+100):\n pre[i]=((pre[i-1]*2)%mod)\n \np=[1]*(n+1)\nfor i in range(n):\n p[i+1]=((p[i]*(i+1))%mod)\n pp[i+1]=pow(p[i+1],mod-2,mod)\ntot=1\nfor i in range(n):\n tot*=3\n tot%=mod\n#print(1)\n#print(tot)\ncc=0\nfor i in range(n//2+1,n+1):\n c=(((((p[n]*pp[i])%mod)*pp[n-i])%mod)*pre[n-i])%mod\n c%=mod\n cc+=c\ntot-=cc\ntot-=cc\ntot%=mod\nprint(tot)\n", "jacc_sim": 1.0, "nl": "You are given a positive even number N. Find the number of strings 's' of length N consisting of 'A', 'B', and 'C' that satisfy the condition: 's' can be converted to the empty string by erasing two consecutive characters, but 'AB' or 'BA' cannot be erased. Compute the count modulo 998244353. Constraints: 2 \u2264 N \u2264 10^7. Input is given as N, and the output should be the number of strings that satisfy the conditions, modulo 998244353.", "before_after_length": [295, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u141610915", "n_user": "u141610915", "pos": "import sys\nfrom collections import Counter\ninput = sys.stdin.readline\nN = int(input())\na = list(map(int, input().split()))\nc = Counter()\nfor x in a: c[x] += 1\ncv = Counter()\nfor v in c.values(): cv[v] += 1\n#print(cv)\n\ndef check(x, K):\n t = 0\n for k, v in cv.items(): t += min(k, x) * v\n return t >= K * x\n\nres = [N] * (N + 1)\nfor K in range(1, N):\n ok = 0\n ng = res[K] + 1\n while ng - ok > 1:\n m = (ok + ng) // 2\n if check(m, K + 1): ok = m\n else: ng = m\n res[K + 1] = ok\n\nfor r in res[1: ]: print(r)", "neg": "import sys\nfrom collections import Counter\ninput = sys.stdin.readline\nN = int(input())\na = list(map(int, input().split()))\nc = Counter()\nfor x in a: c[x] += 1\ncv = Counter()\nfor v in c.values(): cv[v] += 1\nprint(cv)\n\ndef check(x, K):\n t = 0\n for k, v in cv.items(): t += min(k, x) * v\n return t >= K * x\n\nres = [N] * (N + 1)\nfor K in range(1, N):\n ok = 0\n ng = res[K] + 1\n while ng - ok > 1:\n m = (ok + ng) // 2\n if check(m, K + 1): ok = m\n else: ng = m\n res[K + 1] = ok\n\nfor r in res[1: ]: print(r)", "jacc_sim": 0.9821428571428571, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [226, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n from sys import stdin\n input = stdin.readline\n from collections import Counter as ct\n from bisect import bisect_left as bl\n\n n = int(input())\n max_a = sorted(ct(list(map(int, input().split()))).values())\n now_a = [i for i in max_a]\n m = len(max_a)\n cnt = m\n ans = 0\n ans_list = [0]*(n-m)\n\n for use in range(m, 1, -1):\n rest = ans\n nex = now_a[0]\n while rest:\n val = nex\n start = bl(now_a, val+1)\n nex += 1\n q = max(-1, start-1-rest, bl(max_a, now_a[start-1]+1)-1)\n for i in range(start-1, q, -1):\n now_a[i] += 1\n if now_a[start-1] == 1:\n cnt += start-1-q\n rest -= start-1-q\n if start != m:\n nex = now_a[start]\n while cnt >= use:\n ans += 1\n rest = use\n nex = now_a[-1]\n end = m\n while rest:\n val = nex\n start = bl(now_a, val)\n if start != 0:\n nex = now_a[start-1]\n end = min(end, bl(now_a, val+1), start+rest)\n for i in range(start, end):\n now_a[i] -= 1\n if now_a[start] == 0:\n cnt -= end-start\n rest -= end-start\n end = start\n ans_list.append(ans)\n print(n)\n for i in ans_list[::-1]:\n print(i)\n\n\nmain()", "neg": "def main():\n from sys import stdin\n input = stdin.readline\n from collections import Counter as ct\n from bisect import bisect_left as bl\n\n n = int(input())\n max_a = sorted(ct(list(map(int, input().split()))).values())\n now_a = [i for i in max_a]\n m = len(max_a)\n cnt = m\n ans = 0\n ans_list = [0]*(n-m)\n\n for use in range(m, 1, -1):\n rest = ans\n nex = now_a[0]\n while rest:\n val = nex\n start = bl(now_a, val+1)\n nex += 1\n q = bl(max_a, now_a[start-1]+1)-1\n for i in range(start-1, max(-1, start-1-rest, q), -1):\n now_a[i] += 1\n rest -= start-1-max(-1, start-1-rest, q)\n if now_a[start-1] == 0:\n cnt += start-1-max(-1, start-1-rest, q)\n if start != m:\n nex = now_a[start]\n while cnt >= use:\n ans += 1\n rest = use\n nex = now_a[-1]\n end = m\n while rest:\n val = nex\n start = bl(now_a, val)\n if start != 0:\n nex = now_a[start-1]\n end = min(end, bl(now_a, val+1), start+rest)\n for i in range(start, end):\n now_a[i] -= 1\n if now_a[start] == 0:\n cnt -= end-start\n rest -= end-start\n end = start\n ans_list.append(ans)\n print(n)\n for i in ans_list[::-1]:\n print(i)\n\n\nmain()", "jacc_sim": 1.0, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [477, 498], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u843135954", "n_user": "u843135954", "pos": "import sys\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nimport bisect\nfrom collections import Counter\n\nn = ni()\na = na()\n\nc = sorted(Counter(a).values())\ncc = [0]\nm = len(c)\nfor i in c:\n cc.append(cc[-1]+i)\n\ndef is_ok(k,arg):\n b = bisect.bisect_right(c,arg)\n p = cc[b] + (m-b)*arg\n return True if p >= arg*k else False\n\nfor k in range(1,n+1):\n if k > m:\n print(0)\n continue\n #\u306b\u3076\u305f\u3093\n ok,ng = -1,n//k+1\n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(k,mid):\n ok = mid\n else:\n ng = mid\n \n print(ok)\n ", "neg": "import sys\nstdin = sys.stdin\n\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nimport bisect\nfrom collections import Counter\n\nn = ni()\na = na()\naa = [a[0]]\nfor i in range(1,n):\n aa.append(aa[-1]+a[i])\n\nc = sorted(Counter(a).values())\ncc = [c[0]]\nm = len(c)\nfor i in range(1,m):\n cc.append(cc[-1]+c[i])\n\nfor k in range(1,n+1):\n def is_ok(arg):\n b = bisect.bisect_right(c,arg)\n p = cc[b-1] + (m-b)*arg\n return True if p >= arg*k else False\n\n #\u306b\u3076\u305f\u3093\n ok,ng = -1,n\n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n \n print(ok)\n ", "jacc_sim": 0.9722222222222222, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [298, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u864197622", "n_user": "u864197622", "pos": "from collections import Counter as C\nN = int(input())\nA = sorted(list(C([int(a) for a in input().split()]).values()))\nX = [0] * 303030\nfor a in A:\n X[a] += 1\n\ns = 0\nc = 0\nB = [0] * 303030\nfor i in range(300030)[::-1]:\n s += c\n B[i] += s\n c += X[i]\n\ndef chk(k, a):\n if N - B[a] >= k * a: return 1\n return 0\n\nfor i in range(1, N+1):\n l, r = 0, N + 1\n while r-l > 1:\n m = (l+r) // 2\n if chk(i, m):\n l = m\n else:\n r = m\n print(l)", "neg": "from collections import Counter as C\nN = int(input())\nA = sorted(list(C([int(a) for a in input().split()]).values()))\nX = [0] * 303030\nfor a in A:\n X[a] += 1\n\ns = 0\nB = [0] * 303030\nfor i in range(300030)[::-1]:\n B[i] += s\n s += X[i]\n\ndef chk(k, a):\n if N - B[a] >= k * a: return 1\n return 0\n\nfor i in range(1, N+1):\n l, r = 0, N + 1\n while r-l > 1:\n m = (l+r) // 2\n if chk(i, m):\n l = m\n else:\n r = m\n print(l)", "jacc_sim": 0.9807692307692307, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [220, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u327179339", "n_user": "u327179339", "pos": "import bisect\nN = int(input())\ncount = {}\nfor x in map(int, input().split()):\n count[x] = count.get(x, 0) + 1\n\na = sorted(count.values())\nsums = a[:]\nn = len(a)\nfor i in range(1, n):\n sums[i] += sums[i-1]\n \ndef check(k, x):\n pos = bisect.bisect_right(a, x)\n if pos == 0:\n return x * n >= k * x\n return sums[pos-1]+ x * (n - pos) >= k * x\n\nx = 0\nres = []\nfor k in range(N, 0, -1):\n while check(k, x+1):\n x += 1\n res.append(x)\n \nfor x in res[::-1]:\n print(x)", "neg": "N = int(input())\ncount = {}\nfor x in map(int, input().split()):\n count[x] = count.get(x, 0) + 1\n\na = sorted(count.values())\nsums = a[:]\nn = len(a)\nfor i in range(1, n):\n sums[i] += sums[i-1]\n \ndef check(k, x):\n pos = bisect.bisect_right(a, x)\n return (sums[pos-1] if pos-1 >= 0 else 0) + x * (n - pos) >= k * x\n\nx = 0\nres = []\nfor k in range(N, 0, -1):\n while check(k, x+1):\n x += 1\n res.append(x)\n \nfor x in res[::-1]:\n print(x)", "jacc_sim": 0.9583333333333334, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [217, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u148425972", "n_user": "u148425972", "pos": "N = int(input())\nA = list(map(int, input().split()))\ntypes = {}\nfor i in A: types[i] = types.get(i, 0) + 1\nA = sorted([types[k] for k in types], reverse=True)\nL = len(A)\ncumsum = [0 for i in range(L+1)]\nfor i in range(L-1, -1, -1):\n cumsum[i] = A[i] + cumsum[i+1]\n\n\n\ndef getMidPoint(lo, hi, O):\n if lo >= hi: return lo\n mid = lo + (hi - lo+1) // 2\n if A[mid] > O:\n return getMidPoint(mid, hi, O)\n else:\n return getMidPoint(lo, mid-1, O)\n\ngetMid = [getMidPoint(0, L - 1, o) for o in range(N+1)]\n\n# Highest K for given O\ndef calc(O):\n \n\n mid = getMid[O]\n if A[mid] < O: mid = - 1\n return (mid+1) + cumsum[mid+1] // O\n\nfor K in range(1, N+1):\n def getO(lo, hi):\n if lo >= hi: return lo\n mid = lo + (hi - lo+1) // 2\n if calc(mid) < K:\n return getO(lo, mid - 1)\n else:\n return getO(mid, hi)\n \n print(getO(0, N))\n \n", "neg": "N = int(input())\nA = list(map(int, input().split()))\ntypes = {}\nfor i in A: types[i] = types.get(i, 0) + 1\nA = sorted([types[k] for k in types], reverse=True)\nL = len(A)\ncumsum = [0 for i in range(L+1)]\nfor i in range(L-1, -1, -1):\n cumsum[i] = A[i] + cumsum[i+1]\n\n# Highest K for given O\ndef calc(O):\n def getMidPoint(lo, hi):\n if lo >= hi: return lo\n mid = lo + (hi - lo+1) // 2\n if A[mid] > O:\n return getMidPoint(mid, hi)\n else:\n return getMidPoint(lo, mid-1)\n\n mid = getMidPoint(0, L-1)\n return (mid+1) + cumsum[mid+1] // O\n\nfor K in range(1, N+1):\n def getO(lo, hi):\n if lo >= hi: return lo\n mid = lo + (hi - lo+1) // 2\n if calc(mid) < K:\n return getO(lo, mid - 1)\n else:\n return getO(mid, hi)\n \n print(getO(0, N))\n \n", "jacc_sim": 0.9818181818181818, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [381, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u461454424", "n_user": "u461454424", "pos": "import sys\ninput = sys.stdin.readline\n\n#input\nN = int(input())\nA = list(map(int, input().split()))\n\n#output\nfrom collections import Counter\nimport bisect\n\nl = Counter(A).most_common()\nl = [b for a, b in l]\nM = len(l)\nl.sort()\np = sum(l)\n\nmaximum_operation = [0] * N\n\nll = []\nfor x in reversed(range(1, N+1)):\n a = bisect.bisect_left(l, x)\n if a == 0:\n b = M*x\n c = 0\n elif a >= M:\n b = 0\n c = p\n else:\n b = (M-a)*x\n c = sum(l[0:a]) \n ll.append((b + c)/x)\n\nfor K in range(M):\n maximum_operation[K] = N - bisect.bisect_left(ll, K+1)\n\nfor m in maximum_operation:\n print(m)\n", "neg": "import sys\ninput = sys.stdin.readline\n\n#input\nN = int(input())\nA = list(map(int, input().split()))\n\n#output\nfrom collections import Counter\nimport bisect\nimport numpy as np\n\nl = Counter(A).most_common()\nl = [b for a, b in l]\nM = len(l)\nnp.sort(l)\nm = np.cumsum(l)\np = m[-1]\n\nmaximum_operation = [0] * N\n\nll = []\nfor x in range(1, N+1):\n a = bisect.bisect_left(l, x)\n if a == 0:\n b = M*x\n c = 0\n elif a >= M:\n b = 0\n c = p\n else:\n b = (M-a)*x\n c = m[a-1] \n ll.append((b + c)/x)\nnp.sort(ll)\n\nfor K in range(M):\n maximum_operation[K] = N - bisect.bisect_left(ll, K+1)\n\nfor m in maximum_operation:\n print(m)\n", "jacc_sim": 0.9016393442622951, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [262, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u947883560", "n_user": "u947883560", "pos": "#!/usr/bin/env python3\nimport sys\nfrom collections import Counter\nfrom itertools import accumulate\nfrom collections import defaultdict\nINF = float(\"inf\")\n\n\ndef solve(N: int, A: \"List[int]\"):\n c = Counter(A)\n d = Counter(c.values())\n d = tuple(accumulate([d[i] for i in range(N, -1, -1)]))[::-1]\n S = [0]*(N+1)\n for i in range(1, N+1):\n S[i] = S[i-1] + d[i]\n\n def isOK(y):\n return S[y] < K*y\n\n def binary_search(x):\n ng = -1\n ok = len(x)+1\n\n while abs(ok - ng) > 1:\n mid = (ok + ng)//2\n if isOK(mid):\n ok = mid\n else:\n ng = mid\n return ng, ok\n\n for K in range(1, N+1):\n ng, ok = binary_search(range(N))\n print(ng)\n\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n A = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, A)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\nfrom collections import Counter\nfrom itertools import accumulate\nfrom collections import defaultdict\nINF = float(\"inf\")\n\n\ndef solve(N: int, A: \"List[int]\"):\n c = Counter(A)\n d = Counter(c.values())\n d = tuple(accumulate([d[i] for i in range(N, -1, -1)])[::-1])\n S = [0]*(N+1)\n for i in range(1, N+1):\n S[i] = S[i-1] + d[i]\n\n def isOK(y):\n return S[y] < K*y\n\n def binary_search(x):\n ng = -1\n ok = len(x)+1\n\n while abs(ok - ng) > 1:\n mid = (ok + ng)//2\n if isOK(mid):\n ok = mid\n else:\n ng = mid\n return ng, ok\n\n for K in range(1, N+1):\n ng, ok = binary_search(range(N))\n print(ng)\n\n return\n\n\ndef main():\n\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n A = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, A)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [392, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u849660048", "n_user": "u849660048", "pos": "from collections import *\nMAX = 3*pow(10,5) + 2\nn = int(input())\na = list(map(int,input().split()))\nb = [0 for i in range(MAX)]\nc = [0 for i in range(MAX)]\nfor i in a:\n b[i] += 1\nfor i in b:\n c[i] += 1\ns = n\nlast = n\nprint(last)\nfor k in range(2,n+1):\n while(s//k < last):\n best = min(last,s//k)\n for i in range(last,best,-1):\n s -= c[i]\n c[i-1] += c[i]\n c[i] = 0\n last = best\n print(last)", "neg": "from collections import *\nMAX = 3*pow(10,5) + 2\nn = int(input())\na = list(map(int,input().split()))\nb = [0 for i in range(MAX)]\nc = [0 for i in range(MAX)]\nfor i in a:\n b[i] += 1\nfor i in b:\n c[i] += 1\ns = n\nlast = n\nprint(last)\nfor k in range(2,n+1):\n while(s//k < last):\n for i in range(last,s//k,-1):\n s -= c[i]\n c[i-1] += c[i]\n c[i] = 0\n last = s//k\n print(last)", "jacc_sim": 0.9545454545454546, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [191, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u844789719", "n_user": "u844789719", "pos": "import itertools\nimport collections\nN = int(input())\nA = [int(_) for _ in input().split()]\nc = sorted(collections.Counter(A).values())\nacc = list(itertools.accumulate([0] + c))\nn = len(acc) - 1\nj = 0\nfor i in range(1, n + 1):\n r = 0\n while i - j > 0:\n if (i - j) * c[-1 - j] <= acc[-1 - j]:\n r = acc[-1 - j] // (i - j)\n break\n else:\n j += 1\n print(r)\nfor _ in range(N - n):\n print(0)\n", "neg": "import itertools\nimport collections\nN = int(input())\nA = [int(_) for _ in input().split()]\nc = sorted(collections.Counter(A).values())\nacc = list(itertools.accumulate([0] + c))\nn = len(acc) - 1\nj = 0\nfor i in range(1, N + 1):\n r = 0\n while i - j > 0:\n if (i - j) * c[-1 - j] <= acc[-1 - j]:\n r = acc[-1 - j] // (i - j)\n break\n else:\n j += 1\n print(r)\n", "jacc_sim": 1.0, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [168, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u520276780", "n_user": "u520276780", "pos": "#x\u500b\u306e\u5217\u3092\u53d6\u308a\u51fa\u305b\u308b\u6700\u5927\u306e\u9577\u3055f(x)\u3092\u8003\u3048\u308b\n#d\u306e\u5c0e\u5165\n\nimport bisect\nn = int(input())\na = list(map(int, input().split()))\n\nc = [0]*(n+1)\n\nfor i in range(n):\n c[a[i]] += 1\n\nd = [0]*(n+1)\nfor i in range(n+1):###\n d[c[i]] += 1\n\nsum1 = 0\nsum2 =sum(d)-d[0]\nfx = []\nfor x in range(1,n+1):\n sum1 += x*d[x]\n sum2 -= d[x]\n fx.append((sum1+x*sum2)//x)\nfx.sort()\nfor i in range(1,n+1):\n j = bisect.bisect_left(fx,i)###\n print(n-j)", "neg": "#x\u500b\u306e\u5217\u3092\u53d6\u308a\u51fa\u305b\u308b\u6700\u5927\u306e\u9577\u3055f(x)\u3092\u8003\u3048\u308b\n#d\u306e\u5c0e\u5165\n\nimport bisect\nn = int(input())\na = list(map(int, input().split()))\n\nc = [0]*(n+1)\n\nfor i in range(n):\n c[a[i]] += 1\n\nd = [0]*(n+1)\nfor i in range(n):\n d[c[i]] += 1\n\nsum1 = 0\nsum2 =sum(d)-d[0]\nans = []\nfor x in range(1,n+1):\n sum1 += x*d[x]\n sum2 -= d[x]\n ans.append((sum1+x*sum2)//x)\nans.sort()\nfor i in range(1,n+1):\n j = bisect.bisect_left(ans,i)\n print(n-j)", "jacc_sim": 0.9661016949152542, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [274, 270], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02890", "p_user": "u792078574", "n_user": "u792078574", "pos": "from collections import Counter\nfrom itertools import accumulate\nfrom bisect import bisect_right\nN = int(input())\nAs = list(map(int, input().split()))\nct = Counter(As)\nctm = [c[1] for c in ct.most_common()]\nctm.reverse()\nL = len(ctm)\nacc = [0] + list(accumulate(ctm))\n\narr = [0]\nfor n in range(1, N+1):\n idx = bisect_right(ctm, n)\n arr.append(acc[idx] + n*(L-idx))\n\nfor n in range(1, N+1):\n f = 0\n t = N // n + 1\n while f + 1 < t:\n m = f + (t-f) // 2\n if arr[m] >= m*n:\n f = m\n else:\n t = m\n print(f)", "neg": "from collections import Counter\nfrom itertools import accumulate\nfrom bisect import bisect_right\nN = int(input())\nAs = list(map(int, input().split()))\nct = Counter(As)\nctm = [c[1] for c in ct.most_common()]\nctm.reverse()\nL = len(ctm)\nacc = [0] + list(accumulate(ctm))\n\narr = [0]\nfor n in range(1, N+1):\n idx = bisect_right(ctm, n)\n arr.append(acc[idx] + n*(L-idx))\n\nfor i in range(1, N+1):\n f = 1\n t = N // i + 1\n if f +1 >= t:\n print(0)\n continue\n while f + 1 < t:\n m = f + (t-f) // 2\n if arr[m] >= m*i:\n f = m\n else:\n t = m\n print(f)", "jacc_sim": 0.9642857142857143, "nl": "Takahashi has N cards, each with an integer Ai written on it. He chooses an integer K and repeats the following operation: select K cards with different integers and eat them. Find the maximum number of times Takahashi can perform this operation for each K (1 to N). Constraints: 1 \u2264 N \u2264 3 \u00d7 10^5, 1 \u2264 Ai \u2264 N. Input format: N followed by A1 to AN. Output: N integers representing the maximum operations for each K. Example: For K=1, K=2, K=3, etc., output the maximum operations possible.", "before_after_length": [223, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u189479417", "n_user": "u189479417", "pos": "import sys\n\nINF = 10 ** 8\nN = int(input())\nS = []\nfor _ in range(N):\n S.append(list(map(int,list(input()))))\n\ncolor = [0] * N\n\ndef dfs(x, c):\n color[x] = c\n for i in range(N):\n if S[x][i] and color[i] == c:\n return False\n if S[x][i] and color[i] == 0 and not dfs(i, -c):\n return False\n return True\n\nfor i in range(N):\n if color[i] == 0 and not dfs(i, 1):\n print(-1)\n sys.exit()\n\nd = [[INF if S[i][j] == 0 else S[i][j] for i in range(N)] for j in range(N)]\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n if i != j:\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n\nans = 0\n\nfor i in range(N):\n for j in range(N):\n if d[i][j] != INF:\n ans = max(ans, d[i][j]+1)\nprint(ans)", "neg": "import sys\n\nINF = 10 ** 8\nN = int(input())\nS = []\nfor _ in range(N):\n S.append(list(map(int,list(input()))))\n\ncolor = [0] * N\n\ndef dfs(x, c):\n color[x] = c\n for i in range(N):\n if S[x][i] and color[i] == c:\n return False\n if S[x][i] and color[i] == 0 and not dfs(i, -c):\n return False\n return True\n\nfor i in range(N):\n if color[i] == 0 and not dfs(i, 1):\n print(-1)\n sys.exit()\n\nd = [[INF if S[i][j] == 0 else S[i][j] for i in range(N)] for j in range(N)]\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n d[i][j] = min(d[i][j], d[i][k] + d[k][j])\n\nans = 0\n\nfor i in range(N):\n for j in range(N):\n if d[i][j] != INF:\n ans = max(ans, d[i][j])\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [329, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u531436689", "n_user": "u531436689", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\nfrom collections import deque\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nDR = [1, -1, 0, 0]\nDC = [0, 0, 1, -1]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n \ndef main():\n N = I()\n adj = []\n for i in range(N):\n adj.append(S())\n\n def bfs(v):\n group = [-1] * N\n q = deque([(v, 0)])\n group[v] = 0\n while q:\n cur_v, gid = q.popleft()\n for next_v in range(N):\n if adj[cur_v][next_v] == '0':\n continue\n if group[next_v] != -1:\n if abs(group[cur_v] - group[next_v]) > 1:\n return -1\n if group[cur_v] == group[next_v]:\n return -1\n else:\n continue\n group[next_v] = gid + 1\n q.append((next_v, gid+1))\n return max(group) + 1\n\n ans = -1\n for i in range(N):\n ans = max(ans, bfs(i))\n\n print(ans)\n\nmain()\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\nfrom collections import deque\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nDR = [1, -1, 0, 0]\nDC = [0, 0, 1, -1]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n \ndef main():\n N = I()\n adj = []\n for i in range(N):\n adj.append(S())\n\n def bfs(v):\n group = [-1] * N\n q = deque([(v, 0)])\n group[v] = 0\n while q:\n cur_v, gid = q.popleft()\n for next_v in range(N):\n if adj[cur_v][next_v] == '0':\n continue\n if group[next_v] != -1:\n if abs(group[cur_v] - group[next_v]) > 1:\n return -1\n else:\n continue\n group[next_v] = gid + 1\n q.append((next_v, gid+1))\n return max(group) + 1\n\n ans = -1\n for i in range(N):\n ans = max(ans, bfs(i))\n\n print(ans)\n\nmain()\n\n", "jacc_sim": 1.0, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [479, 458], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u703950586", "n_user": "u703950586", "pos": "import sys,queue,math,copy,itertools,bisect,collections,heapq\n\ndef main():\n NI = lambda : int(sys.stdin.readline())\n\n N = NI()\n S = [[int(x) for x in sys.stdin.readline().rstrip()] for _ in range(N)]\n\n max_k = 0\n\n for i in range(N):\n node = [-1] * N\n q = collections.deque()\n q.append((i,1))\n node[i] = 1\n f = True\n while q:\n v,d = q.popleft()\n for j in range(N):\n if S[v][j] == 0: continue\n if node[j] == d+1 or node[j] == d-1: continue\n if node[j] < 0:\n node[j] = d+1\n q.append((j,d+1))\n else:\n f = False\n break\n else:\n continue\n break\n if f: max_k = max(max_k,max(node))\n if max_k == 0:\n print(-1)\n else:\n print(max_k)\n\nif __name__ == '__main__':\n main()", "neg": "import sys,queue,math,copy,itertools,bisect,collections,heapq\n\ndef main():\n NI = lambda : int(sys.stdin.readline())\n\n N = NI()\n S = [[int(x) for x in sys.stdin.readline().rstrip()] for _ in range(N)]\n\n max_k = 0\n\n for i in range(N):\n node = [-1] * N\n q = collections.deque()\n q.append((i,1))\n node[i] = 1\n s = copy.deepcopy(S)\n f = True\n while q:\n v,d = q.popleft()\n for j in range(N):\n if s[i][j] == 0: continue\n if node[j] == d+1 or node[j] == d-1: continue\n if node[j] < 0:\n node[j] = d+1\n q.append((j,d+1))\n else:\n f = False\n break\n else:\n continue\n break\n if f: max_k = max(max_k,max(node))\n if max_k == 0:\n print(-1)\n else:\n print(max_k)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.96875, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [313, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u210440747", "n_user": "u210440747", "pos": "#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\nfrom collections import defaultdict\nfrom queue import deque\n\ndef main():\n n = int(input())\n graph = defaultdict(list)\n \n def is_bt():\n def bfs():\n colors = [-1] * len(graph)\n dq = deque()\n dq.append(0)\n colors[0] = 0\n while dq:\n inode = dq.popleft()\n for ichild in graph[inode]:\n if colors[ichild] == -1:\n colors[ichild] = abs(colors[inode]-1)\n dq.append(ichild)\n else:\n if colors[ichild] == colors[inode]:\n return False\n return True\n return bfs()\n \n def wf(edges):\n dp = edges\n for k in range(len(graph)):\n for i in range(len(graph)):\n for j in range(len(graph)):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])\n return dp\n \n edges = [[n+1] * n for _ in range(n)] \n for i in range(n):\n for j, c in enumerate(input().strip()):\n if c == '1':\n graph[i].append(j)\n edges[i][j] = 1\n edges[i][i] = 0\n graph = dict(graph)\n \n if not is_bt():\n print(-1)\n return\n print(max([max(x) for x in wf(edges)]) + 1)\n \nif __name__=='__main__':\n main()\n\n", "neg": "#!/usr/bin/python3\n# -*- coding:utf-8 -*-\n\nfrom collections import defaultdict\nfrom queue import deque\n\ndef main():\n n = int(input())\n graph = defaultdict(list)\n \n def is_bt():\n def bfs():\n colors = [-1] * len(graph)\n dq = deque()\n dq.append(0)\n colors[0] = 0\n while dq:\n inode = dq.popleft()\n for ichild in graph[inode]:\n if colors[ichild] == -1:\n colors[ichild] = abs(colors[inode]-1)\n dq.append(ichild)\n else:\n if colors[ichild] == colors[inode]:\n return False\n return True\n return bfs()\n \n def wf(edges):\n dp = edges\n for k in range(len(graph)):\n for i in range(len(graph)):\n for j in range(len(graph)):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])\n return dp\n \n edges = [[n+1] * n for _ in range(n)] \n for i in range(n):\n for j, c in enumerate(input().strip()):\n if c == '1':\n graph[i].append(j)\n edges[i][j] = 1\n edges[i][i] = 0\n graph = dict(graph)\n \n# if not is_bt():\n# print(-1)\n# return\n print(max([max(x) for x in wf(edges)]) + 1)\n \nif __name__=='__main__':\n main()\n\n", "jacc_sim": 1.0, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [427, 430], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u932465688", "n_user": "u932465688", "pos": "n = int(input())\nS = []\nfor i in range(n):\n S.append(input())\ncolor = [-1]*n #0:\u9ed2, 1:\u767d\ncolor[0] = 0\nstack = [0]\ncolored = [0]*n\ncolored[0] = 1\nwhile len(stack) != 0:\n temp = stack.pop()\n col = color[temp]\n cur = S[temp]\n for j in range(n):\n if cur[j] == '1':\n if colored[j] != 0:\n if color[j] == col:\n print(-1)\n exit()\n else:\n if col == 1:\n color[j] = 0\n else:\n color[j] = 1\n colored[j] = 1\n stack.append(j)\nmaxdist = 0\ndist = []\nfor i in range(n):\n d = [10**10]*n\n d[i] = 0\n dist.append(d)\nfor i in range(n):\n for j in range(n):\n if S[i][j] == '1':\n dist[i][j] = 1\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])\nfor i in range(n):\n for j in range(n):\n maxdist = max(maxdist, dist[i][j])\nprint(maxdist+1)\n", "neg": "n = int(input())\nS = []\nfor i in range(n):\n S.append(input())\ncolor = [-1]*n #0:\u9ed2, 1:\u767d\ncolor[0] = 0\nstack = [0]\ncolored = [0]*n\ncolored[0] = 1\nwhile len(stack) != 0:\n temp = stack.pop()\n col = color[temp]\n cur = S[temp]\n for j in range(n):\n if cur[j] == '1':\n if colored[j] != 0:\n if color[j] == col:\n print(-1)\n exit()\n else:\n if col == 1:\n color[j] = 0\n else:\n color[j] = 1\n colored[j] = 1\n stack.append(j)\nmaxdist = 0\ndist = []\nfor i in range(n):\n d = [10**7]*n\n d[i] = 0\n dist.append(d)\nfor i in range(n):\n for j in range(n):\n if S[i][j] == '1':\n dist[i][j] = 1\nfor i in range(n):\n for k in range(n):\n for j in range(n):\n dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])\n if dist[i][j] != 10**7:\n maxdist = max(maxdist, dist[i][j])\nprint(maxdist)\n", "jacc_sim": 0.9795918367346939, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [384, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u223904637", "n_user": "u223904637", "pos": "from collections import deque\nn=int(input())\ng=[[] for i in range(n)]\nfor i in range(n):\n p=list(str(input()))\n for j in range(n):\n if p[j]=='1':\n g[i].append(j)\nq=deque([0])\nv=[-1]*n\nv[0]=0\nwhile q:\n p=q.popleft()\n for i in g[p]:\n if v[i]==-1:\n v[i]=1-v[p]\n q.append(i)\n else:\n if v[i]!=1-v[p]:\n print(-1)\n exit()\nans=0\nfor s in range(n):\n q=deque([s])\n v=[0]*n\n v[s]=1\n while q:\n p=q.popleft()\n for i in g[p]:\n if v[i]==0:\n v[i]=1+v[p]\n q.append(i)\n ans=max(ans,max(v))\nprint(ans)\n", "neg": "from collections import deque\nn=int(input())\ng=[[] for i in range(n)]\nfor i in range(n):\n p=list(str(input()))\n for j in range(n):\n if p[j]=='1':\n g[i].append(j)\nq=deque([0])\nv=[-1]*n\nv[0]=0\nwhile q:\n p=q.popleft()\n for i in g[p]:\n if v[i]==-1:\n v[i]=1-v[p]\n q.append(i)\n else:\n if v[i]!=1-v[p]:\n print(-1)\n exit()\nq=deque([0])\nv=[0]*n\nv[0]=1\nwhile q:\n p=q.popleft()\n for i in g[p]:\n if v[i]==0:\n v[i]=1+v[p]\n q.append(i)\ns=v.index(max(v))\nq=deque([s])\nv=[0]*n\nv[0]=1\nwhile q:\n p=q.popleft()\n for i in g[p]:\n if v[i]==0:\n v[i]=1+v[p]\n q.append(i)\nprint(max(v))", "jacc_sim": 0.9318181818181818, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [283, 341], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u077291787", "n_user": "u077291787", "pos": "# AGC039B - Graph Partition (153ms)\nfrom collections import deque\n\n\ndef is_bipartite() -> bool:\n stack, color = [(1, 1)], [0] * (N + 1)\n color[1] = 1\n while stack:\n v, cur_color = stack.pop()\n next_color = -cur_color\n for u in E[v]:\n if color[u] == cur_color:\n return False\n if not color[u]:\n color[u] = next_color\n stack.append((u, next_color))\n return True\n\n\ndef bfs(source: int) -> int:\n queue = deque([source])\n dist = [0] * (N + 1) # dist[i] := distance from V_source to V_i\n dist[source] = 1\n while queue:\n v = queue.popleft()\n cur = dist[v]\n for u in E[v]:\n if not dist[u]:\n dist[u] = cur + 1\n queue.append(u)\n return max(dist)\n\n\ndef main():\n # if bipartite graph -> diameter of the graph + 1\n global N, E\n N, *S = open(0)\n N = int(N)\n E = [0] + [[i for i, flg in enumerate(s, 1) if flg == \"1\"] for s in S]\n if is_bipartite():\n ans = max(bfs(i) for i in range(1, N + 1))\n print(ans)\n else:\n print(-1)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# AGC039B - Graph Partition (153ms)\nfrom collections import deque\n\n\ndef is_bipartite() -> bool:\n stack, color = [(1, 1)], [0] * (N + 1)\n color[1] = 1\n while stack:\n v, cur_color = stack.pop()\n next_color = -cur_color\n for u in E[v]:\n if color[u] == cur_color:\n return False\n if not color[u]:\n color[u] = next_color\n stack.append((u, next_color))\n return True\n\n\ndef bfs(source: int) -> int:\n queue = deque([source])\n dist = [0] * (N + 1) # dist[i] := distance from V_source to V_i\n dist[start] = 1\n while queue:\n v = queue.popleft()\n cur = dist[v]\n for u in E[v]:\n if not dist[u]:\n dist[u] = cur + 1\n queue.append(u)\n return max(dist)\n\n\ndef main():\n # if bipartite graph -> diameter of the graph + 1\n global N, E\n N, *S = open(0).read().split()\n N = int(N)\n E = [0] + [[i for i, flg in enumerate(s, 1) if flg == \"1\"] for s in S]\n if is_bipartite():\n ans = max(bfs(i) for i in range(1, N + 1))\n print(ans)\n else:\n print(-1)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9620253164556962, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [413, 417], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u077291787", "n_user": "u077291787", "pos": "# AGC039B - Graph Partition\nfrom collections import deque\n\n\ndef is_bipartite() -> bool:\n stack = [(1, 1)]\n color = [-1] * (N + 1)\n color[1] = 1\n while stack:\n v, cur_color = stack.pop()\n next_color = cur_color ^ 1\n for u in E[v]:\n if color[u] == cur_color:\n return False\n if color[u] == -1:\n color[u] = next_color\n stack.append((u, next_color))\n return True\n\n\ndef bfs(start) -> int:\n que = deque([start])\n dist = [-1] * (N + 1) # dist[i] := distance from V_start to V_i\n dist[start] = 0\n while que:\n v = que.popleft()\n cur = dist[v]\n for u in E[v]:\n if dist[u] == -1:\n dist[u] = cur + 1\n que.append(u)\n return max(dist)\n\n\ndef main():\n # if bipartite graph -> diameter of the graph + 1\n global N, E\n N, *S = open(0).read().split()\n N = int(N)\n E = [0] + [[i for i, flg in enumerate(s, 1) if flg == \"1\"] for s in S]\n if is_bipartite():\n ans = max(bfs(i) for i in range(1, N + 1)) + 1\n print(ans)\n else:\n print(-1)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# AGC039B - Graph Partition\ndef is_bipartite() -> bool:\n stack = deque([(1, 1)])\n color = [-1] * (N + 1)\n color[1] = 1\n while stack:\n v, cur_color = stack.pop()\n next_color = cur_color ^ 1\n for u in E[v]:\n if color[u] == cur_color:\n return False\n if color[u] == -1:\n color[u] = next_color\n stack.append((u, next_color))\n return True\n\n\ndef bfs(start) -> int:\n que = deque([start])\n dist = [-1] * (N + 1) # dist[i] := distance from V_start to V_i\n dist[start] = 0\n while que:\n v = que.popleft()\n cur = dist[v]\n for u in E[v]:\n if dist[u] == -1:\n dist[u] = cur + 1\n que.append(u)\n return max(dist)\n\n\ndef main():\n # if bipartite graph -> diameter of the graph + 1\n global N, E\n N, *S = open(0).read().split()\n N = int(N)\n E = [0] + [[i for i, flg in enumerate(s, 1) if flg == \"1\"] for s in S]\n if is_bipartite():\n ans = max(bfs(i) for i in range(1, N + 1)) + 1\n print(ans)\n else:\n print(-1)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.974025974025974, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [421, 416], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u864197622", "n_user": "u864197622", "pos": "from collections import deque\nN = int(input())\nX = [[] for _ in range(N)]\nfor i in range(N):\n s = input()\n for j in range(N):\n if s[j] == \"1\":\n X[i].append(j)\n\ndef bipartite(n, E):\n col = [-1] * n\n f = 0\n for i in range(n):\n if col[i] >= 0: continue\n que = deque([[i, 0]])\n while que:\n v, c = que.popleft()\n if col[v] == -1:\n col[v] = c\n elif col[v] == c:\n continue\n else:\n f = 1\n break\n for ne in E[v]:\n if col[ne] == c:\n f = 1\n break\n if col[ne] < 0:\n que.append([ne, 1-c])\n\n if f:\n break\n if f:\n break\n return 1-f\n\ndef BFS(n, E, i0=0):\n Q = deque([i0])\n D = [-1] * n\n D[i0] = 0\n while Q:\n x = Q.popleft()\n for c in E[x]:\n if D[c] == -1:\n D[c] = D[x] + 1\n Q.append(c)\n return D\n\nif bipartite(N, X):\n print(max([max(BFS(N, X, i)) for i in range(N)])+1)\nelse:\n print(-1)\n", "neg": "from collections import deque\nN = int(input())\nX = [[] for _ in range(N)]\nfor i in range(N):\n s = input()\n for j in range(N):\n if s[j] == \"1\":\n X[i].append(j)\n\ndef bipartite(n, E):\n col = [-1] * n\n for i in range(n):\n if col[i] >= 0: continue\n que = deque([[i, 0]])\n f = 0\n while que:\n v, c = que.popleft()\n col[v] = c\n for ne in E[v]:\n if col[ne] == c:\n f = 1\n break\n if col[ne] < 0:\n que.append([ne, 1-c])\n\n if f:\n break\n return 1-f\n\ndef BFS(n, E, i0=0):\n Q = deque([i0])\n D = [-1] * n\n D[i0] = 0\n while Q:\n x = Q.popleft()\n for c in E[x]:\n if D[c] == -1:\n D[c] = D[x] + 1\n Q.append(c)\n return D\n\nif bipartite(N, X):\n print(max([max(BFS(N, X, i)) for i in range(N)])+1)\nelse:\n print(-1)\nprint(\"X =\", X)\nfor i in range(N):\n print(i, BFS(N, X, i))", "jacc_sim": 0.9824561403508771, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [406, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u270681687", "n_user": "u270681687", "pos": "from collections import deque\n\nn = int(input())\ns = [input() for _ in range(n)]\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u5224\u5b9a\nmemo = [-1] * n\nmemo[0] = 0\nq = deque([(0, -1)])\nwhile q:\n v, p = q.popleft()\n for nv in range(n):\n if s[v][nv] == '1':\n if nv == p:\n continue\n if memo[nv] == -1:\n memo[nv] = (memo[v] + 1) % 2\n q.append((nv, v))\n else:\n if memo[nv] == memo[v]:\n print(-1)\n exit()\n\n# \u30ef\u30fc\u30b7\u30e3\u30eb\u30d5\u30ed\u30a4\u30c9\u3067\u30b0\u30e9\u30d5\u306e\u76f4\u5f84\u3092\u6c42\u3081\u3066\u3082\u3088\u3057\nINF = float('inf')\ndp = [[1 if c == '1' else INF for c in row] for row in s]\n\nfor i in range(n):\n dp[i][i] = 0\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])\n\ndist = 0\nfor i in range(n):\n d = 0\n for j in range(n):\n d = max(d, dp[i][j])\n dist = max(d, dist)\n\nprint(dist+1)", "neg": "from collections import deque\n\nn = int(input())\ns = [input() for _ in range(n)]\n\n# \u4e8c\u90e8\u30b0\u30e9\u30d5\u5224\u5b9a\nmemo = [-1] * n\nmemo[0] = 0\nq = deque((0, -1))\nwhile q:\n v, p = q.popleft()\n for nv in range(n):\n if s[v][nv] == '1':\n if nv == p:\n continue\n if memo[nv] == -1:\n memo[nv] = (memo[v] + 1) % 2\n q.append((nv, v))\n else:\n if memo[nv] == memo[v]:\n print(-1)\n exit()\n\n# \u30ef\u30fc\u30b7\u30e3\u30eb\u30d5\u30ed\u30a4\u30c9\u3067\u30b0\u30e9\u30d5\u306e\u76f4\u5f84\u3092\u6c42\u3081\u3066\u3082\u3088\u3057\nINF = float('inf')\ndp = [[1 if c == '1' else INF for c in row] for row in s]\n\nfor i in range(n):\n dp[i][i] = 0\n\nfor k in range(n):\n for i in range(n):\n for j in range(n):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])\n\ndist = 0\nfor i in range(n):\n d = 0\n for j in range(n):\n d = max(d, dp[i][j])\n dist = max(d, dist)\n\nprint(dist+1)", "jacc_sim": 1.0, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [426, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u123648284", "n_user": "u123648284", "pos": "from collections import deque\n\ndef solve(init):\n groups = [-1 for i in range(N)]\n groups[init] = 1\n q = deque()\n q.append(init)\n while len(q) > 0:\n u = q.popleft()\n for v in range(N):\n if M[u][v] == 0:\n continue\n if groups[v] != -1:\n if groups[v] == groups[u]-1 or groups[v] == groups[u]+1:\n continue\n else:\n return -1\n groups[v] = groups[u] + 1\n q.append(v)\n return max(groups)\n\n\nN = int(input())\nM = [list(map(int, list(input()))) for i in range(N)]\n\nres = -1\nfor u in range(N):\n res = max(res, solve(u))\n\nprint(res)\n", "neg": "from collections import deque\n\ndef solve(init):\n depth = 0\n groups = [INF for i in range(N)]\n q = deque()\n q.append(init)\n while len(q) > 0:\n u = q.popleft()\n groups[u] = depth\n for v in range(N):\n if M[u][v] == 0:\n continue\n if groups[v] != INF:\n if groups[v] == depth-1:\n continue\n else:\n return -1\n q.append(v)\n depth += 1\n return depth\n\nN = int(input())\nM = [list(map(int, list(input()))) for i in range(N)]\nINF = 201\n\nres = -1\nfor u in range(N):\n res = max(res, solve(u))\n\nprint(res)\n", "jacc_sim": 0.92, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [230, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u017810624", "n_user": "u017810624", "pos": "import sys\nfrom collections import deque\nsys.setrecursionlimit(10**7)\nn=int(input())\nl=[list(input()) for i in range(n)]\ncolors = [0 for i in range(n)]\nes=[[] for i in range(n)]\nEdges=es\nfor i in range(n):\n for j in range(n):\n if l[i][j]=='1':\n es[i].append(j)\ndef dfs(v,color):\n colors[v] = color\n for to in es[v]:\n if colors[to] == color:\n return False\n if colors[to] == 0 and not dfs(to, -color):\n return False\n return True\n \ndef is_bipartite():\n return dfs(0,1)\nif is_bipartite()==0:\n print(-1)\n sys.exit()\n\n\ndef bfs(v):\n Visited=[False]*n\n q=deque()\n q.append((v,0))\n Visited[v]=True\n ret=(v,0)\n while q:\n fr,dist=q.popleft()\n if ret[1] 0):\n Q2 = set()\n cnt += 1\n idx += 1\n \n for i in Q:\n for j, s in enumerate(S[i]):\n if s == '1':\n if R[j] == idx - 1:\n return -1\n elif R[j] == 0:\n R[j] = idx\n Q2.add(j)\n \n Q = Q2\n \n return cnt\n \n\n\ndef g(N, S):\n m = 0\n\n for i in range(N):\n k = f(N, S, i)\n if k == -1:\n return -1\n\n m = max(m, k)\n\n return m\n\n\n\ndef main():\n N = int(input())\n S = list(input() for _ in range(N))\n\n print(g(N, S))\n\n\n\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# --*-coding:utf-8-*--\n\n\ndef f(N, S, st):\n R = [0]*(N)\n\n Q = set([st])\n R[st] = 1\n idx = 1\n cnt = 0\n\n while(len(Q) > 0):\n Q2 = set()\n cnt += 1\n idx += 1\n \n for i in Q:\n for j, s in enumerate(S[i]):\n if s == '1':\n if R[j] == idx - 1:\n return -1\n elif R[j] == 0:\n R[j] = idx\n Q2.add(j)\n \n Q = Q2\n \n return cnt\n \n\n\ndef g(N, S):\n m = 0\n\n for i in range(N):\n k = f(N, S, i)\n if k == -1:\n return -1\n\n m = max(m, k)\n\n return m\n\n\n\ndef main():\n N = int(input())\n S = list(input() for _ in range(N))\n\n print(g(N, S))\n\n\n\n", "jacc_sim": 0.9636363636363636, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [309, 293], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02892", "p_user": "u263534486", "n_user": "u263534486", "pos": "from collections import deque\n\nN = int(input())\n\nminDist = [[1 if s == '1' else float('inf') for s in input()] for _ in range(N)]\n\nfor i in range(N):\n minDist[i][i] = 0\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n if minDist[i][j] > minDist[i][k] + minDist[k][j]:\n minDist[i][j] = minDist[i][k] + minDist[k][j]\n\nbase = [d % 2 for d in minDist[0]]\n\nfor i in range(N):\n A = [0] * N\n for j, d in enumerate(minDist[i]):\n A[j] = (d + base[i]) % 2\n if A != base:\n print(-1)\n exit()\n\nans = max([max(D) for D in minDist]) + 1\nprint(ans)", "neg": "from collections import deque\n\nN = int(input())\n\nminDist = [[1 if s == '1' else float('inf') for s in input()] for _ in range(N)]\n\nfor i in range(N):\n minDist[i][i] = 0\n\nfor k in range(N):\n for i in range(N):\n for j in range(N):\n if minDist[i][j] > minDist[i][k] + minDist[k][j]:\n minDist[i][j] = minDist[i][k] + minDist[k][j]\n\nans = 0\nbase = [d % 2 for d in minDist[0]]\n\nfor i in range(N):\n A = [0] * N\n for j, d in enumerate(minDist[i]):\n A[j] = (d + base[i]) % 2\n ans = max(ans, d)\n if A != base:\n print(-1)\n exit()\n\nif ans % 2 == 1:\n print(0)\nprint(ans + 1)", "jacc_sim": 0.9787234042553191, "nl": "You are given a connected undirected graph with N vertices and M edges. The vertices are numbered 1 to N, and the edges are described by a grid of characters S. If S_{i,j} is 1, there is an edge connecting Vertex i and j; otherwise, there is no such edge. Determine if it's possible to divide the vertices into non-empty sets V_1, ..., V_k such that every edge connects two vertices belonging to adjacent sets. If yes, find the maximum possible number of sets, k, in such a division. Constraints: 2 \u2264 N \u2264 200, S_{i,j} is 0 or 1, S_{i,i} is 0, S_{i,j}=S_{j,i}, the given graph is connected, and N is an integer. Input is given in the format: N, followed by the grid S. Output -1 if it's impossible to divide the vertices into sets satisfying the condition; otherwise, print the maximum possible number of sets, k. Examples of input and output are provided.", "before_after_length": [246, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02893", "p_user": "u170201762", "n_user": "u170201762", "pos": "mod = 998244353\nN = int(input())\nX = input()\nX_ = []\nfor i in range(N):\n if X[i]=='0':\n X_.append('1')\n else:\n X_.append('0')\nX_ = ''.join(X_)\n\nd = []\nfor n in range(1,N+1):\n if N%n==0 and (N//n)%2==1:\n d.append(n)\n\np_d = {}\n\nfor n in d:\n p_d[n] = 0\n S = (X[:n]+X_[:n])*(N//n//2)+X[:n]\n p_d[n] += int(X[:n],2)%mod\n if S<=X:\n p_d[n] += 1\n\nans = 0\nfor i in range(len(d)):\n n = d[i]\n for j in range(i):\n m = d[j]\n if n%m==0:\n p_d[n] -= p_d[m]\n ans += p_d[n]*2*n\nans %= mod\nprint(ans)", "neg": "mod = 998244353\nN = int(input())\nX = input()\n\nd = []\nfor n in range(1,N+1):\n if N%n==0 and (N//n)%2==1:\n d.append(n)\n\np_d = {}\n\nfor n in d:\n p_d[n] = 0\n S = []\n for i in range(N):\n j = i//n\n if X[i%n]=='0':\n if j%2==0:\n S.append('0')\n else:\n S.append('1')\n else:\n if j%2==0:\n S.append('1')\n else:\n S.append('0')\n\n S = ''.join(S)\n s = X[:n][::-1]\n print(S)\n print(X)\n for i in range(n):\n if s[i]=='1':\n p_d[n] += pow(2,i,mod)\n if S<=X:\n p_d[n] += 1\n\n\nans = 0\nfor i in range(len(d)):\n n = d[i]\n for j in range(i):\n m = d[j]\n if n%m==0:\n p_d[n] -= p_d[m]\n ans += p_d[n]*2*n\nans %= mod\nprint(ans)\n", "jacc_sim": 0.9361702127659575, "nl": "You are given integers N and X. For each integer k between 0 and X (inclusive), find the number of operations needed until k returns to its original value. Then, compute the sum of all these answers modulo 998244353. The operation is as follows: if k is odd, subtract 1 and divide by 2; otherwise, divide by 2 and add 2^(N-1). The input is given as N and X, and the output should be the sum of the answers for integers between 0 and X (inclusive), modulo 998244353.", "before_after_length": [291, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02893", "p_user": "u170201762", "n_user": "u170201762", "pos": "mod = 998244353\nN = int(input())\nX = input()\n\nd = []\nfor n in range(1,N+1):\n if N%n==0 and (N//n)%2==1:\n d.append(n)\n\np_d = {}\n\nfor n in d:\n p_d[n] = 0\n S = []\n for i in range(N):\n j = i//n\n if X[i%n]=='0':\n if j%2==0:\n S.append('0')\n else:\n S.append('1')\n else:\n if j%2==0:\n S.append('1')\n else:\n S.append('0')\n\n S = ''.join(S)\n s = X[:n][::-1]\n for i in range(n):\n if s[i]=='1':\n p_d[n] += pow(2,i,mod)\n if S<=X:\n p_d[n] += 1\n\nans = 0\nfor i in range(len(d)):\n n = d[i]\n for j in range(i):\n m = d[j]\n if n%m==0:\n p_d[n] -= p_d[m]\n ans += p_d[n]*2*n\nans %= mod\nprint(ans)\n", "neg": "mod = 998244353\nN = int(input())\nX = input()\n\nd = []\nfor n in range(1,N+1):\n if N%n==0 and n%2==1:\n d.append(n)\n\np_d = {}\n\nfor n in d:\n p_d[n] = 0\n l = N//n\n s = X[:l]\n s_ = ''\n for i in range(l):\n if s[i]=='0':\n s_ = s_+'1'\n else:\n s_ = s_+'0'\n S = ''\n for i in range(n):\n if i%2==0:\n S = S+s\n else:\n S = S+s_\n s = s[::-1]\n for i in range(l):\n if s[i]=='1':\n p_d[n] += pow(2,i,mod)\n if S<=X:\n p_d[n] += 1\n\nd = d[::-1]\nans = 0\nfor i in range(len(d)):\n n = d[i]\n ans += p_d[n]*2*N//n\n for j in range(i):\n m = d[j]\n if m%n==0:\n ans -= p_d[m]*2*N//n\nans %= mod\nprint(ans)", "jacc_sim": 0.9375, "nl": "You are given integers N and X. For each integer k between 0 and X (inclusive), find the number of operations needed until k returns to its original value. Then, compute the sum of all these answers modulo 998244353. The operation is as follows: if k is odd, subtract 1 and divide by 2; otherwise, divide by 2 and add 2^(N-1). The input is given as N and X, and the output should be the sum of the answers for integers between 0 and X (inclusive), modulo 998244353.", "before_after_length": [348, 352], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02893", "p_user": "u695811449", "n_user": "u695811449", "pos": "import sys\ninput = sys.stdin.readline\n\nmod=998244353\n\nN=int(input())\nX=input()\n\nimport math\nxr=math.ceil(math.sqrt(N))\n\nLIST=[]\nfor i in range(1,xr+1):\n if N%i==0:\n LIST.append(i)\n LIST.append(N//i)\n\nREP=[l for l in set(LIST) if (N//l)%2==1 and l!=N]\n\nREP.sort(reverse=True)\n\n\nANS=2*N*(int(X,2)+1)%mod\n\ndef invstr(X,r):\n return bin(int(X,2)^((1<r and j%r==0:\n score+=2*N-2*j\n break\n\n #print(r,score)\n\n XSTR=X[:r]\n\n kosuu=int(XSTR,2)\n\n if (XSTR+invstr(XSTR,r))*(N//(r*2))+XSTR<=X:\n kosuu+=1\n\n ANS+=kosuu*score\n\nprint(ANS%mod)", "jacc_sim": 0.9090909090909091, "nl": "You are given integers N and X. For each integer k between 0 and X (inclusive), find the number of operations needed until k returns to its original value. Then, compute the sum of all these answers modulo 998244353. The operation is as follows: if k is odd, subtract 1 and divide by 2; otherwise, divide by 2 and add 2^(N-1). The input is given as N and X, and the output should be the sum of the answers for integers between 0 and X (inclusive), modulo 998244353.", "before_after_length": [373, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02893", "p_user": "u511268447", "n_user": "u511268447", "pos": "if __name__ == '__main__':\n import sys\n input = sys.stdin.readline\n\n\n nn = int(input())\n x = input()\n\n ans = 0\n def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n if i % 2 != 0:\n divisors.append(i)\n if i != n // i and (n//i)%2 != 0:\n divisors.append(n//i)\n\n divisors.sort(reverse = True)\n return divisors\n\n fact_n = make_divisors(nn)\n\n used = {}\n\n ans = 0\n\n for i in fact_n:\n num_len = int(nn/i)\n base = x[:num_len]\n can_divide = int(base, 2)+1\n for key, value in used.items():\n if num_len%key == 0:\n can_divide -= value\n if x < (base + format(2**num_len-1-int(base,2), 'b').zfill(num_len))*int((i-1)/2)+base:\n can_divide -= 1\n used[num_len] = can_divide\n ans += can_divide*num_len*2\n ans = ans%998244353\n\n\n print(ans%998244353)\n", "neg": "if __name__ == '__main__':\n import sys\n input = sys.stdin.readline\n\n\n nn = int(input())\n x = input()\n\n ans = 0\n def make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n if i % 2 != 0:\n divisors.append(i)\n if i != n // i and (n//i)%2 != 0:\n divisors.append(n//i)\n\n divisors.sort(reverse = True)\n return divisors\n\n fact_n = make_divisors(nn)\n\n used = {}\n\n ans = 0\n\n for i in fact_n:\n num_len = int(nn/i)\n base = x[:num_len]\n can_divide = int(base, 2)+1\n for key, value in used.items():\n if num_len%key == 0:\n can_divide -= value\n if x < (base + format(2**num_len-1-int(base,2), 'b'))*int((i-1)/2)+base:\n can_divide -= 1\n used[num_len] = can_divide\n ans += can_divide*num_len*2\n ans = ans%998244353\n\n\n print(ans%998244353)\n", "jacc_sim": 0.9836065573770492, "nl": "You are given integers N and X. For each integer k between 0 and X (inclusive), find the number of operations needed until k returns to its original value. Then, compute the sum of all these answers modulo 998244353. The operation is as follows: if k is odd, subtract 1 and divide by 2; otherwise, divide by 2 and add 2^(N-1). The input is given as N and X, and the output should be the sum of the answers for integers between 0 and X (inclusive), modulo 998244353.", "before_after_length": [371, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02914", "p_user": "u475503988", "n_user": "u102461423", "pos": "from numpy import *\nf=bitwise_xor.reduce\nN=int(input())\nA=array(input().split(),int64)\nX=f(A)\nA=hstack((A,array([1<>i],A))\nfor k in range(60)[::-1]:\n b=1<> i & 1:\n if not p[i]:\n p[i] = x\n break\n x ^= p[i]\n\nall = 0 \nfor x in a:\n all ^= x\n\nfor i in range(61):\n if all >> i & 1:\n for j in range(n):\n if a[j] >> i & 1:\n a[j] -= (1< ans:\n ans = p[i] ^ ans\nprint(ans + (ans ^ all))\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\np = [0] * 62\n\ndef insert(x):\n for i in range(60, -1, -1):\n if x >> i & 1:\n if not p[i]:\n p[i] = x\n break\n x ^= p[i]\n\nall = 0 \nfor x in a:\n all ^= x\n\nfor i in range(61):\n if all >> i & 1:\n for j in range(n):\n if a[j] >> i & 1:\n a[j] -= (1< 0] ^= a\n if ans & b == 0:\n ans ^= a\n\n\nprint (ans*2 + all_x)", "neg": "'''\nCreated on 2019/09/23\n\n@author: oiwaiman\n'''\n\n\nimport numpy as np\n\nn = int(input())\naaa = np.fromiter(list(map(int, input().split())), np.int64)\n\nall_x = np.bitwise_xor.reduce(aaa)\n\nmask = ~all_x\nbbb = aaa & mask\n\nans = 0\nwhile True:\n a = bbb.max()\n if a == 0:\n break\n b = 1<<(int(a).bit_length() -1)\n bbb[bbb & b > 0] ^= a\n if ans & b == 0:\n ans ^= b\n\nprint (ans*2 + all_x)", "jacc_sim": 1.0, "nl": "You are given N non-negative integers: A_1, A_2, ..., A_N. You need to paint at least one and at most N-1 integers in red and the rest in blue. The beauty of the painting is the XOR of the integers painted in red, plus the XOR of the integers painted in blue. Find the maximum possible beauty of the painting. The bitwise XOR of n non-negative integers x_1, x_2, ..., x_n is defined such that when x_1 XOR x_2 XOR ... XOR x_n is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if the number of integers among x_1, x_2, ..., x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 XOR 5 = 6. All input values are integers, 2 \u2264 N \u2264 10^5, and 0 \u2264 A_i < 2^60 (1 \u2264 i \u2264 N). The input is given in the format: N A_1 A_2 ... A_N. Print the maximum possible beauty of the painting.", "before_after_length": [179, 178], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02914", "p_user": "u695811449", "n_user": "u695811449", "pos": "import sys\ninput = sys.stdin.readline\n\nN=int(input())\nA=list(map(int,input().split()))\n\nXOR=0\nfor a in A:\n XOR^=a\n\nfor i in range(N):\n A[i] &=~XOR\n \nUSED=[0]*N\n\nfor bi in range(60,-1,-1):\n for i in range(N):\n if USED[i]==0 and A[i] & (1<= 0 and (a >> i) & 1 == 0:\n i -= 1\n x = 0\n if i < 0: break\n if x:\n heappush(h, -(a^x))\n else:\n x = a\n s = max(s, s^x)\nprint(s+(t^s))", "neg": "from heapq import *\nN = int(input())\nA = [int(a) for a in input().split()]\nx, t, s, i, h = 0, 0, 0, 59, []\nfor a in A:\n t ^= a\nfor a in A:\n heappush(h, -(a&~t))\nwhile h:\n a = -heappop(h)\n while (a >> i) & 1 == 0 and i >= 0:\n i -= 1\n x = 0\n if i < 0: break\n if x:\n heappush(h, -(a^x))\n else:\n x = a\n s = max(s, s^x)\nprint(s+(t^s))", "jacc_sim": 1.0, "nl": "You are given N non-negative integers: A_1, A_2, ..., A_N. You need to paint at least one and at most N-1 integers in red and the rest in blue. The beauty of the painting is the XOR of the integers painted in red, plus the XOR of the integers painted in blue. Find the maximum possible beauty of the painting. The bitwise XOR of n non-negative integers x_1, x_2, ..., x_n is defined such that when x_1 XOR x_2 XOR ... XOR x_n is written in base two, the digit in the 2^k's place (k \u2265 0) is 1 if the number of integers among x_1, x_2, ..., x_n whose binary representations have 1 in the 2^k's place is odd, and 0 if that count is even. For example, 3 XOR 5 = 6. All input values are integers, 2 \u2264 N \u2264 10^5, and 0 \u2264 A_i < 2^60 (1 \u2264 i \u2264 N). The input is given in the format: N A_1 A_2 ... A_N. Print the maximum possible beauty of the painting.", "before_after_length": [180, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01059", "p_user": "u829695570", "n_user": "u724548524", "pos": "n,m = map(int,input().split())\na = list(map(int,input().split()))\nc = [a[0]-1, n-a[m-1]]\nfor i in range(m-1):\n c.append((a[i+1]-a[i])//2)\nprint(max(c))\n\n", "neg": "n, m = map(int, input().split())\na =[0] + list(map(int, input().split())) + [n]\nt = max(a[0] - 1, n - a[-1])\nfor i in range(1, m):t = max(t, -((a[i - 1] - a[i]) // 2))\nprint(t)\n", "jacc_sim": 0.9032258064516129, "nl": "Title: Gossip\n\nProblem:\nThere are n idols numbered from 1 to n lined up in a row. Each idol can pass information to the idol on their left or right in one unit of time. Idol 1 can only pass information to idol 2, and idol n can only pass information to idol n-1. At time 0, m idols hold secret information with numbers a1, a2, ..., am. Find the minimum time for all idols to receive the secret information.\n\nInput:\nThe input consists of:\n- Two integers n and m on the first line separated by a space.\n- m integers a1, a2, ..., am on the second line separated by spaces.\n\nConstraints:\n- 2 \u2264 n \u2264 10^5\n- 1 \u2264 m \u2264 n\n- 1 \u2264 ai \u2264 n\n- All ai values are distinct and given in ascending order.\n\nOutput:\nOutput the minimum time for all idols to receive the information in a single line.\n\nSample Input 1:\n3 2\n1 3\n\nSample Output 1:\n1\n\nSample Input 2:\n10 3\n2 5 7\n\nSample Output 2:\n3\n\nSample Input 3:\n10 5\n2 5 6 8 10\n\nSample Output 3:\n1\n\nSample Input 4:\n100000 1\n1\n\nSample Output 4:\n99999", "before_after_length": [84, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01085", "p_user": "u546285759", "n_user": "u546285759", "pos": "while 1:\n m,nn,nx= map(int,input().split())\n if m==0: break\n s=[int(input()) for _ in range(m)]\n v=k=0\n for i in range(nn-1,nx):\n t=s[i]-s[i+1]\n if v<=t:\n k,v=i+1,t\n print(k)", "neg": "while 1:\n m,nn,nx= map(int,input().split())\n if m==0: break\n s=[int(input()) for _ in range(m)]\n v=k=0\n for i in range(nn-1,nx):\n t=s[i]-s[i+1]\n if v A[k]) :\n break\n if(ans != 0) :\n break\n print(ans)\n", "neg": "while True :\n n = int(input())\n if(n == 0) :\n break\n else :\n A = [5, 7, 5, 7, 7]\n ans = 0\n w = [len(input()) for i in range(n)]\n for i in range(n) :\n k = 0\n s = 0\n for j in range(i, n) :\n s += w[j]\n if(s == A[k]) :\n s = 0\n k += 1\n if(k == 5) :\n ans = i + 1\n break\n elif(s > A[k]) :\n break\n if(ans != 0) :\n break\n print(ans)\n", "jacc_sim": 1.0, "nl": "A Short Phrase (aka. Tanku) is a fixed verse inspired by Japanese poetry Tanka and Haiku. It consists of a sequence of words, each made up of lowercase letters 'a' to 'z'. The sequence must be divided into five sections, with the first section having a total of five letters, the second section having seven, and the remaining sections having five, seven, and seven letters, respectively. The task is to write a program that identifies the Short Phrase from a sequence of words, which may contain irrelevant text at the beginning and end. The input consists of multiple datasets, each containing the number of words and the words themselves. The output should indicate the position of the first word of the Short Phrase for each dataset. The end of the input is marked by a line with a single zero.", "before_after_length": [176, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01086", "p_user": "u572046143", "n_user": "u572046143", "pos": "def main():\n while True:\n n = int(input().strip())\n\n if n == 0:\n break\n\n phrases = []\n for _ in range(n):\n word = input().strip()\n phrases.append(word)\n\n PHRASE_LEN = [5,7,5,7,7]\n found_flag = False\n\n for i in range(n):\n acc_len = 0\n phrase_idx = 0\n for j in range(i, n):\n acc_len += len(phrases[j])\n\n if acc_len == PHRASE_LEN[phrase_idx]:\n if phrase_idx == (len(PHRASE_LEN)-1):\n found_flag = True\n break\n\n acc_len = 0\n phrase_idx += 1\n elif acc_len > PHRASE_LEN[phrase_idx]:\n break\n\n if found_flag:\n print(i+1)\n break\n\nif __name__ == \"__main__\":\n main()\n\n", "neg": "def main():\n while True:\n n = int(input().strip())\n\n if n == 0:\n break\n\n phrases = []\n for _ in range(n):\n word = input().strip()\n phrases.append(word)\n\n PHRASE_LEN = [5,7,5,7,7]\n found_flag = False\n\n for i in range(n):\n acc_len = 0\n phrase_idx = 0\n for j in range(i, n):\n acc_len += len(phrases[j])\n\n if acc_len == PHRASE_LEN[phrase_idx]:\n if phrase_idx == (len(PHRASE_LEN)-1):\n found_flag = True\n break\n\n acc_len = 0\n phrase_idx += 1\n elif acc_len > PHRASE_LEN[phrase_idx]:\n break\n\n if found_flag:\n print(i+1)\n break\n\nif __name__ == \"__main__\":\n main()\n~ \n~ \n~ \n", "jacc_sim": 0.9782608695652174, "nl": "A Short Phrase (aka. Tanku) is a fixed verse inspired by Japanese poetry Tanka and Haiku. It consists of a sequence of words, each made up of lowercase letters 'a' to 'z'. The sequence must be divided into five sections, with the first section having a total of five letters, the second section having seven, and the remaining sections having five, seven, and seven letters, respectively. The task is to write a program that identifies the Short Phrase from a sequence of words, which may contain irrelevant text at the beginning and end. The input consists of multiple datasets, each containing the number of words and the words themselves. The output should indicate the position of the first word of the Short Phrase for each dataset. The end of the input is marked by a line with a single zero.", "before_after_length": [252, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01086", "p_user": "u284260266", "n_user": "u284260266", "pos": "while True:\n n = int(input())#\u6587\u5b57\u5217\u306e\u91cf\n if n == 0:\n break\n w = list()#\u6587\u5b57\u7528\n for i in range(0, n):#\u5165\u529b\n w.append(input())\n\n for j in range(1, n+1):#\u59cb\u3081\u306e\u6587\u5b57\u306e\u5834\u6240\n ck = 0\n co = 0\n p = 0\n t = \"\"\n for k in range(j-1,50):#\uff15\uff17\uff15\uff17\uff17\u30c1\u30a7\u30c3\u30af\u7528\n #print(k)\n if co == 0 or co == 2:#\uff15\u306e\u5834\u6240\n if ck < 5:#\u4e94\u4ee5\u4e0b\n #print(\"<\")\n ck = ck + len(w[k+p])#\u6587\u5b57\u5897\u3084\u3059\n elif ck == 5:#\u30d4\u30c3\u30bf\u30ea\u306b\u306a\u3063\u305f\u3089\n #print(\"==\")\n co = co + 1#\u6b21\u306b\u79fb\u308b\n ck = 0\n p = p-1\n else:#\u30aa\u30fc\u30d0\u30fc\u3057\u305f\u3089\n #print(\">\")\n break\n else:\n if ck < 7:\n #print(\"<7\")\n ck = ck+len(w[k+p])\n #print(\" \" ,ck)\n elif ck == 7:\n #print(\"==7\")\n co = co+1\n ck = 0\n p = p-1\n if co == 5:\n t = \"fin\"\n break\n else:\n #print(\">7\")\n break\n\n if t == \"fin\":\n print(j)\n break\n #print(\"over\")\n\n", "neg": "while True:\n n = int(input())#\u6587\u5b57\u5217\u306e\u91cf\n if n == 0:\n break\n w = list()#\u6587\u5b57\u7528\n for i in range(0, n):#\u5165\u529b\n w.append(input())\n\n for j in range(1, n+1):#\u59cb\u3081\u306e\u6587\u5b57\u306e\u5834\u6240\n ck = 0\n co = 0\n p = 0\n t = \"\"\n for k in range(j-1,50):#\uff15\uff17\uff15\uff17\uff17\u30c1\u30a7\u30c3\u30af\u7528\n #print(k)\n if co == 0 or co == 2:#\uff15\u306e\u5834\u6240\n if ck < 5:#\u4e94\u4ee5\u4e0b\n #print(\"<\")\n ck = ck + len(w[k+p])#\u6587\u5b57\u5897\u3084\u3059\n elif ck == 5:#\u30d4\u30c3\u30bf\u30ea\u306b\u306a\u3063\u305f\u3089\n #print(\"==\")\n co = co + 1#\u6b21\u306b\u79fb\u308b\n ck = 0\n p = p-1\n else:#\u30aa\u30fc\u30d0\u30fc\u3057\u305f\u3089\n #print(\">\")\n break\n else:\n if ck < 7:\n #print(\"<7\")\n ck = ck+len(w[k+p])\n #print(\" \" ,ck)\n elif ck == 7:\n #print(\"==7\")\n co = co+1\n ck = 0\n p = p-1\n if co == 5:\n t = \"fin\"\n break\n else:\n #print(\">7\")\n break\n\n print(j)\n if t == \"fin\":\n break\n #print(\"over\")\n\n", "jacc_sim": 1.0, "nl": "A Short Phrase (aka. Tanku) is a fixed verse inspired by Japanese poetry Tanka and Haiku. It consists of a sequence of words, each made up of lowercase letters 'a' to 'z'. The sequence must be divided into five sections, with the first section having a total of five letters, the second section having seven, and the remaining sections having five, seven, and seven letters, respectively. The task is to write a program that identifies the Short Phrase from a sequence of words, which may contain irrelevant text at the beginning and end. The input consists of multiple datasets, each containing the number of words and the words themselves. The output should indicate the position of the first word of the Short Phrase for each dataset. The end of the input is marked by a line with a single zero.", "before_after_length": [509, 509], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01087", "p_user": "u731941832", "n_user": "u731941832", "pos": "while True:\n n = int(input())\n if n == 0:break\n a = [input() for _ in range(n)]\n while True:\n if len(a) == 1:break\n c = 0\n s = 0\n for i in range(len(a)):\n if a[i].count('.') > c:\n c = a[i].count('.')\n s = i\n e = s\n while e < len(a) and a[e].count('.') == a[s].count('.'):\n e += 1\n k = a[s - 1].replace('.', '')\n b = [a[i] for i in range(s, e)]\n for i in range(len(b)):\n b[i] = int(b[i].replace('.', ''))\n if k == '+':\n a[s - 1] = '.'*a[s - 1].count('.')+str(sum(b))\n del a[s:e]\n else:\n m = 1\n for i in b:\n m *= i\n a[s - 1] = '.'*a[s - 1].count('.')+str(m)\n del a[s:e]\n print(a[0])\n \n", "neg": "while True:\n n = int(input())\n if n == 0:break\n a = [input() for _ in range(n)]\n while True:\n if len(a) == 1:break\n c = 0\n s = 0\n for i in range(len(a)):\n if a[i].count('.') > c:\n c = a[i].count('.')\n s = i\n e = s\n while e < len(a) and a[e].count('.') == a[s].count('.'):\n e += 1\n k = a[s - 1].replace('.', '')\n b = [a[i] for i in range(s, e)]\n for i in range(len(b)):\n b[i] = int(b[i].replace('.', ''))\n if k == '+':\n a[s] = '.'*a[s].count('.')+str(sum(b))\n del a[s + 1:e]\n else:\n m = 1\n for i in b:\n m *= i\n a[s] = '.'*a[s].count('.')+str(m)\n del a[s + 1:e]\n print(a[0])\n \n", "jacc_sim": 1.0, "nl": "ICPC Calculator\n\nIn mathematics, the order of operations is usually specified using parentheses. However, the International Counter of Parentheses Council (ICPC) aims to establish a notation without parentheses as the world standard. Dr. Tsukuba, a member of ICPC, has invented a new parenthesis-free notation. In this notation, a single expression is represented by multiple lines, each containing an addition operator (+), a multiplication operator (*), or an integer. Expressions may be arbitrarily nested, and each expression is given a nesting level. The top-level expression has a nesting level of 0. The task is to write a program that computes the value of expressions written in Dr. Tsukuba's notation. The input consists of multiple datasets, each starting with a line containing a positive integer n, followed by n lines denoting a single expression in Dr. Tsukuba's notation. The output should contain a single line for each dataset, with an integer representing the value of the given expression.", "before_after_length": [312, 308], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01093", "p_user": "u660912567", "n_user": "u284260266", "pos": "while True:\n n = int(input())\n if n==0: break\n l = list(map(int,input().split()))\n r = []\n for i in range(n):\n for j in range(i+1,n):\n r += [abs(l[i]-l[j])]\n print(min(r))", "neg": "while True:\n n = int(input())\n a = list(map(int, input().split()))\n l = list()\n\n for i in range(1, n-1):\n for j in range(i+1,n):\n l.append(abs(a[i]-a[j]))\n if l = []:\n break\n if n == 0:\n break\n print(min(l))\n\n", "jacc_sim": 0.9117647058823529, "nl": "Dr. Tsukuba wants to compare the effectiveness of his new programming training method with the conventional one. He plans to conduct an experiment with two students, each trained under a different method. To ensure a fair comparison, he needs two students with the closest scores from a list of student scores. The task is to write a program that selects two students with the smallest score difference. The input consists of multiple datasets, each containing the number of students and their respective scores. The program should output the absolute difference in scores for each dataset.", "before_after_length": [86, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01094", "p_user": "u284260266", "n_user": "u284260266", "pos": "def secMax(a):\n mx = 0\n smx = 0\n for i in range(0,len(a)):\n if a[i] > mx:\n smx = mx\n mx = a[i]\n elif a[i] > smx:\n smx = a[i]\n else:\n return smx\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n c = list(map(str,input().split()))\n ##alphabet = char('a')##char\u578b\u306d\u3047\u3088\u3063\u3066\u8a00\u308f\u308c\u305f(\u00b4\u30fb\u03c9\u30fb`)\n alph = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\n \"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\n \"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"]\n abcCount = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n for i in range(0, n):\n for j in range(0, 26):\n if c[i] == alph[j]:\n abcCount[j] = abcCount[j] + 1\n break\n #print(abcCount)\n if max(abcCount) > n-1-i+secMax(abcCount):\n print(alph[abcCount.index(max(abcCount))], sum(abcCount))\n break\n else:\n print(\"TIE\")\n\n", "neg": "def secMax(a):\n mx = 0\n smx = 0\n for i in range(0,len(a)):\n if a[i] > mx:\n smx = mx\n mx = a[i]\n elif a[i] > smx:\n smx = a[i]\n else:\n return smx\n\nwhile True:\n n = int(input())\n if n == 0:\n break\n c = list(map(str,input().split()))\n ##alphabet = char('a')##char\u578b\u306d\u3047\u3088\u3063\u3066\u8a00\u308f\u308c\u305f(\u00b4\u30fb\u03c9\u30fb`)\n alph = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\n \"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\n \"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\"]\n abcCount = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]\n for i in range(0, n):\n for j in range(0, 26):\n if c[i] == alph[j]:\n abcCount[j] = abcCount[j] + 1\n break\n print(abcCount)\n if max(abcCount) > n-1-i+secMax(abcCount):\n print(alph[abcCount.index(max(abcCount))], sum(abcCount))\n break\n else:\n print(\"TIE\")\n\n", "jacc_sim": 1.0, "nl": "In TKB City, citizens are eager to know the winner of an election as soon as possible. The task is to create a program that, as votes are counted one by one, identifies the winner and determines when the winner is guaranteed. The input consists of datasets, each containing the number of votes and the votes themselves. The output should indicate the winner and the number of votes at which the winner is identified, unless there is a tie, in which case \"TIE\" should be output.", "before_after_length": [419, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01101", "p_user": "u617401892", "n_user": "u617401892", "pos": "#!/usr/bin/env python3\n\nn_list = []\nm_list = []\na_list = []\n\nwhile True:\n n, m = list(map(int, input().split(' ')))\n\n if n == 0 and m == 0:\n break\n\n a = list(map(int, input().split(' ')))\n\n n_list.append(n)\n m_list.append(m)\n a_list.append(a)\n\n\nfor n, m, a in zip(n_list, m_list, a_list):\n m_sum = 0\n for i in range(0, n):\n for j in range(i + 1, n):\n tmp = a[i] + a[j]\n if m_sum < tmp and tmp <= m:\n m_sum = tmp\n\n if m_sum > 0:\n print(m_sum)\n else:\n print('NONE')\n\n", "neg": "#!/usr/bin/env python3\n\nn_list = []\nm_list = []\na_list = []\n\nwhile True:\n n, m = list(map(int, input().split(' ')))\n\n if n == 0 and m == 0:\n break\n\n a = list(map(int, input().split(' ')))\n\n n_list.append(n)\n m_list.append(m)\n a_list.append(a)\n\n\nfor n, m, a in zip(n_list, m_list, a_list):\n m_sum = 0\n for i in range(0, n):\n for j in range(i + 1, n):\n tmp = a[i] + a[j]\n if m_sum < tmp and tmp <= m:\n m_sum = tmp\n\n if m_sum > 0:\n print(m_sum)\n else:\n print('None')\n\n", "jacc_sim": 0.96, "nl": "Title: Taro's Shopping\n\nMammy wants to give Taro his first shopping experience. Taro needs to choose two items from a shopping catalogue. He wants to buy two different items with the highest price sum, not exceeding the allowed amount. Your task is to help Taro select the two items and report the sum. The input consists of multiple datasets, each containing the number of items, the maximum payment allowed, and the prices of the items. The output should indicate the pair with the highest price sum not exceeding the allowed amount, or \"NONE\" if no pair meets the criteria.", "before_after_length": [233, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01101", "p_user": "u064320529", "n_user": "u064320529", "pos": "maxes=[]\ncnt=0\nwhile True:\n s=input()\n d=s.split()\n n=int(d[0])\n m=int(d[1])\n if n==0 and m==0:\n break\n\n s=input()\n d=s.split()\n a=[]\n \n for i in range(n):\n a.append(int(d[i]))\n\n p=[[0 for i in range(n)] for j in range(n)]\n for i in range(n):\n for j in range(i+1,n):\n p[i][j]=(a[i]+a[j])\n\n\n max=0\n for i in range(n):\n for j in range(i+1,n):\n if p[i][j]>m:\n continue\n if maxm:\n continue\n if max=v:\n if max=v:\n if max=l[i]+l[j]:\n max=l[i]+l[j]\n\n if max==0:\n s+=[\"NONE\"]\n else:\n s+=[max]\n\n\nfor x in s:\n print(x)\n\n", "neg": "s=[]\n\ncnt=0\n\nwhile 1:\n max=0\n n,m =map(int,input().split())\n l=list(map(int,input().split()))\n if n==0 and m==0:\n break\n\n for i in range(len(l)):\n for j in range(len(l)):\n if max=l[i]+l[j]:\n max=l[i]+l[j]\n\n if max==0:\n s+=[\"NONE\"]\n else:\n s+=[max]\n\n\nfor x in s:\n print(x)\n\n", "jacc_sim": 1.0, "nl": "Title: Taro's Shopping\n\nMammy wants to give Taro his first shopping experience. Taro needs to choose two items from a shopping catalogue. He wants to buy two different items with the highest price sum, not exceeding the allowed amount. Your task is to help Taro select the two items and report the sum. The input consists of multiple datasets, each containing the number of items, the maximum payment allowed, and the prices of the items. The output should indicate the pair with the highest price sum not exceeding the allowed amount, or \"NONE\" if no pair meets the criteria.", "before_after_length": [173, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01101", "p_user": "u196653484", "n_user": "u196653484", "pos": "maxs=[]\nwhile(True):\n max=-1\n \n b=list(map(int,input().split()))\n n=b[0]\n m=b[1]\n if(n == 0 and m == 0):\n break\n a=list(map(int,input().split()))\n for i in range(n):\n for j in range(i+1,n):\n sum=a[i]+a[j]\n if(sum>max and sum<=m):\n max=sum\n maxs.append(max)\n\nfor i in maxs:\n if i==-1:\n print(\"NONE\")\n else:\n print(i)\n\n\n", "neg": "maxs=[]\nwhile(True):\n max=-1\n \n b=list(map(int,input().split()))\n n=b[0]\n m=b[1]\n if(n == 0 and m == 0):\n break\n a=list(map(int,input().split()))\n for i in range(n):\n for j in range(i+1,n):\n sum=a[i]+a[j]\n if(sum>max and sum=mm and ans1<=m:\n mm=ans1\n ans1=0\n A.append(mm)\n z=z+1\n\nfor i in range(z):\n if A[i]==0:\n A[i]=\"NONE\"\n print(A[i])\n\n", "neg": "n=5\nm=5\nz=0\nsum=0\nA=[]\n\nwhile n!=0:\n n,m=[int(i) for i in input().split()]\n if n==0 and m==0:\n break\n val=[int(i) for i in input().split()]\n ans1=[int(0) for i in range(n)]\n ans2=[int(0) for i in range(n)]\n mm=0\n for i in range(0,n-1):\n for j in range(i+1,n):\n if i==j:\n break\n ans1[i]=val[i]+val[j]\n if ans1[i]>mm and ans1[i] max):\n max = sum\n if (max == 0):\n print(\"NONE\")\n else:\n print(max)\n\n", "neg": "import sys\nwhile(True):\n items=[]\n max=0\n n, m = map(int, input().split())\n if (n == 0 & m == 0):exit()\n items = list(map(int, input().split()))\n for i in range(n):\n for j in range(n):\n sum = items[i] + items[j]\n if (i != j and sum < m and sum > max):\n max = sum\n if (max == 0):\n print(\"NONE\")\n else:\n print(max)\n\n", "jacc_sim": 1.0, "nl": "Title: Taro's Shopping\n\nMammy wants to give Taro his first shopping experience. Taro needs to choose two items from a shopping catalogue. He wants to buy two different items with the highest price sum, not exceeding the allowed amount. Your task is to help Taro select the two items and report the sum. The input consists of multiple datasets, each containing the number of items, the maximum payment allowed, and the prices of the items. The output should indicate the pair with the highest price sum not exceeding the allowed amount, or \"NONE\" if no pair meets the criteria.", "before_after_length": [138, 138], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01101", "p_user": "u320921262", "n_user": "u196653484", "pos": "while True:\n n,m = map(int,input().split())\n if n == 0 and m == 0:\n break\n a = list(map(int,input().split()))\n \n b = 0\n for i in range(n):\n for j in range(i+1,n):\n if m < a[i] + a[j]:\n continue\n b = max(b,a[i] + a[j])\n if b == 0:\n print(\"NONE\")\n else:\n print(b)\n", "neg": "while(True):\n max=0\n b=list(map(int,input().split()))\n n=b[0]\n m=b[1]\n if(n == 0 and m == 0):\n break\n a=list(map(int,input().split()))\n for i in range(n):\n for j in range(i+1,n):\n sum=a[i]+a[j]\n if(sum>max and sum=0 and m=0:\n yield A[i]+A[j]\n print(max(f())or\"NONE\")\n", "neg": "while 1:\n n, m = map(int, input().split())\n if n == m == 0:\n break\n A=sorted(map(int, input().split()))\n def f():\n j = n-1\n yield 0\n for i in range(n):\n while j >= 0 and m < A[i]+A[j]:\n j -= 1\n if j >= 0:\n yield A[i] + A[j]\n print(max(f()) or\"NONE\")", "jacc_sim": 1.0, "nl": "Title: Taro's Shopping\n\nMammy wants to give Taro his first shopping experience. Taro needs to choose two items from a shopping catalogue. He wants to buy two different items with the highest price sum, not exceeding the allowed amount. Your task is to help Taro select the two items and report the sum. The input consists of multiple datasets, each containing the number of items, the maximum payment allowed, and the prices of the items. The output should indicate the pair with the highest price sum not exceeding the allowed amount, or \"NONE\" if no pair meets the criteria.", "before_after_length": [133, 122], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u848218390", "n_user": "u848218390", "pos": "while 1:\n s1 = input().split('\\\"')\n if s1[0] == '.': break\n s2 = input().split('\\\"')\n\n jdg = 1\n cnt_d = 0\n\n if len(s1) != len(s2): print(\"DIFFERENT\")\n else:\n l = len(s1)\n i = 0\n while i < l:\n if s1[i] != s2[i]:\n cnt_d += 1\n if cnt_d == 1 and i % 2 == 1:\n jdg = 1\n else:\n jdg = 0\n break\n i += 1\n\n if jdg == 1 and cnt_d == 1: print(\"CLOSE\")\n elif jdg == 0 or cnt_d > 1: print(\"DIFFERENT\")\n else: print(\"IDENTICAL\")\n", "neg": "while 1:\n s1 = input().split('\\\"')\n if s1[0] == '.': break\n s2 = input().split('\\\"')\n\n jdg = 1\n cnt_d = \n\n if len(s1) != len(s2): print(\"DIFFERENT\")\n else:\n l = len(s1)\n i = 0\n while i < l:\n if s1[i] != s2[i]:\n cnt_d += 1\n if cnt_d == 1 and i % 2 == 1:\n jdg = 1\n else:\n jdg = 0\n break\n i += 1\n\n if jdg == 1 and cnt_d == 1: print(\"CLOSE\")\n elif jdg == 0 or cnt_d > 1: print(\"DIFFERENT\")\n else: print(\"IDENTICAL\")\n\n", "jacc_sim": 1.0, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [206, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u196653484", "n_user": "u196653484", "pos": "results=[]\nwhile True:\n a=input().split(\"\\\"\")\n if a[0]==\".\":\n break\n b=input().split(\"\\\"\")\n count1=0\n count2=0\n if len(a) != len(b):\n results.append(2)\n else:\n for i in range(len(a)):\n if(i%2==1):\n if len(a[i]) != len(b[i]):\n count1+=1\n else:\n for k,l in zip(a[i],b[i]):\n if(k!=l):\n count1+=1\n else:\n if len(a[i]) != len(b[i]):\n count2+=1\n else:\n for k,l in zip(a[i],b[i]):\n if(k!=l):\n count2+=1 \n if count1==0 and count2==0:\n results.append(0)\n elif count1==1 and count2==0:\n results.append(1)\n else:\n results.append(2)\nfor i in results:\n if i==0:\n print(\"IDENTICAL\")\n if i==1:\n print(\"CLOSE\")\n if i==2:\n print(\"DIFFERENT\")\n", "neg": "results=[]\nwhile True:\n a=input().split(\"\\\"\")\n if a[0]==\".\":\n break\n b=input().split(\"\\\"\")\n count1=0\n count2=0\n if len(a) != len(b):\n results.append(2)\n else:\n for i in range(len(a)):\n if(i%2==1):\n if len(a[i]) == len(b[i]):\n count1+=1\n else:\n for k,l in zip(a[i],b[i]):\n if(k!=l):\n count1+=1\n else:\n if len(a[i]) == len(b[i]):\n count2+=1\n else:\n for k,l in zip(a[i],b[i]):\n if(k!=l):\n count2+=1 \n if count1==0 and count2==0:\n results.append(0)\n elif count1==1 and count2==0:\n results.append(1)\n else:\n results.append(2)\nfor i in results:\n if i==0:\n print(\"IDENTICAL\")\n if i==1:\n print(\"CLOSE\")\n if i==2:\n print(\"DIFFERENT\")\n \n\n", "jacc_sim": 1.0, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [330, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u684325232", "n_user": "u684325232", "pos": "s=[]\n\nwhile 1:\n l1=input()\n if l1==\".\":\n break\n l2=input()\n\n sp1=l1.split('\"')\n sp2=l2.split('\"')\n \n t=0\n if len(sp1)==len(sp2):\n for i in range(len(sp1)):\n if i%2==1 and sp1[i]!=sp2[i]:\n t+=1\n elif i%2!=1 and sp1[i]!=sp2[i]:\n t+=2\n\n\n if sp1==sp2:\n s+=[\"IDENTICAL\"]\n elif t==1:\n s+=[\"CLOSE\"]\n else:\n s+=[\"DIFFERENT\"]\n\nfor x in s:\n print(x)\n", "neg": "s=[]\n\nwhile 1:\n l1=input()\n if l1==\".\":\n break\n l2=input()\n\n sp1=l1.split('\"')\n sp2=l2.split('\"')\n \n t=0\n if len(sp1)==len(sp2):\n for i in range(len(sp1)):\n if i%2==1 and sp1[i]!=sp2[i]:\n t+=1\n elif i%2!=1 and sp1[i]!=sp2[i]:\n t+=2\n\n\n if sp1==sp2:\n s+=[\"IDENTCAL\"]\n elif t==1:\n s+=[\"CLOSE\"]\n else:\n s+=[\"DIFFERENT\"]\n\nfor x in s:\n print(x)\n\n\n", "jacc_sim": 0.9487179487179487, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [210, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u217703215", "n_user": "u217703215", "pos": "ans=[]\nwhile 1:\n s1=input().split('\"')\n if s1==[\".\"]: break\n s2=input().split('\"')\n if len(s1)!=len(s2):\n ans.append(\"DIFFERENT\")\n continue\n else:\n cnt=0\n flag=0\n for i in range(len(s1)):\n if s1[i]!=s2[i]:\n if i%2==0:\n ans.append(\"DIFFERENT\")\n flag=1\n break\n else:\n cnt+=1\n else: pass\n if flag==1:\n continue\n else: pass\n if cnt==0:\n ans.append(\"IDENTICAL\")\n elif cnt==1:\n ans.append(\"CLOSE\")\n else: \n ans.append(\"DIFFERENT\")\n\nfor i in range(len(ans)):\n print(ans[i])\n", "neg": "ans=[]\nwhile 1:\n s1=input().split('\"')\n if s1==[\".\"]: break\n s2=input().split('\"')\n if len(s1)!=len(s2):\n ans.append(\"DIFFERENT\")\n continue\n else:\n cnt=0\n for i in range(len(s1)):\n if s1[i]!=s2[i]:\n cnt+=1\n else: pass\n if cnt==0:\n ans.append(\"IDENTICAL\")\n elif cnt==1:\n ans.append(\"CLOSE\")\n else: \n ans.append(\"DIFFERENT\")\nfor i in range(len(ans)):\n print(ans[i])\n\n", "jacc_sim": 0.9210526315789473, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [232, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u408444038", "n_user": "u408444038", "pos": "st = []\nwhile(1):\n a1 = input()\n if a1 =='.':\n break\n a2 = input()\n b1 = a1.split('\"')\n b2 = a2.split('\"')\n cnt = 0\n if len(b1)==len(b2):\n for i in range(0,len(b1)):\n if i%2==0:\n if b1[i]!=b2[i]:\n cnt+=10000\n break\n if i%2!=0:\n if b1[i]!=b2[i]:\n cnt+=1\n else:\n cnt+=10000\n \n if cnt>1:\n st.append(\"DIFFERENT\")\n if cnt==1:\n st.append(\"CLOSE\")\n if cnt==0:\n st.append(\"IDENTICAL\")\n\nfor i in range(len(st)):\n print(st[i])\n", "neg": "a1 = input()\na2 = input()\nb1 = a1.split('\"')\nb2 = a2.split('\"')\ncnt = 0\nif len(b1)==len(b2):\n for i in range(0,len(b1)):\n if i%2==0:\n if b1[i]!=b2[i]:\n cnt+=10000\n break\n if i%2!=0:\n if b1[i]!=b2[i]:\n cnt+=1\nelse:\n cnt+=10000\n\nif cnt>1:\n print(\"DIFFERENT\")\nif cnt==1:\n print(\"CLOSE\")\nif cnt==0:\n print(\"IDENTICAL\")\n", "jacc_sim": 0.9230769230769231, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [237, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u063056051", "n_user": "u063056051", "pos": "while 1:\n s1=input().split('\"')\n if s1[0]==\".\":\n break\n s2=input().split('\"')\n \n cnt1=0\n cnt2=0\n flag=0\n \n if len(s1)!=len(s2):\n print(\"DIFFERENT\")\n else:\n i=0\n while i1:\n print(\"DIFFERENT\")\n break\n i+=1\n \n if flag==0 and cnt2==1:\n print(\"CLOSE\")\n if cnt1==len(s1):\n print(\"IDENTICAL\")\n", "neg": "while 1:\n s1=input().split('\"')\n if s1[0]==\".\":\n break\n s2=input().split('\"')\n \n flag2=0\n cnt2=0\n flag=0\n \n if len(s1)!=len(s2):\n print(\"DIFFERENT\")\n else:\n i=0\n while i1:\n print(\"DIFFERENT\")\n break\n i+=1\n \n if flag==0 and cnt2==1:\n print(\"CLOSE\")\n if flag2==1:\n print(\"IDENTICAL\")\n", "jacc_sim": 0.9444444444444444, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [223, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u826549974", "n_user": "u826549974", "pos": "while(1):\n a = input()\n if(a == '.'):\n break\n b = input()\n n = len(a)\n m = len(b)\n l = 0\n flag = 0\n idx_dif = 0\n error_cou = 0\n \n while(1):\n if(flag == 0):\n for i in range(l,n):\n if(a[i] == '\\\"'):\n if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):\n l = i+1\n flag = 1\n else:\n flag = 2\n break\n \n elif(i == n-1):\n if(a[l:i] != b[l+idx_dif:m-1]):\n flag = 2\n else:\n l = n-1\n \n elif(flag == 1):\n for i in range(l,n):\n if(a[i] == '\\\"'):\n for j in range(l+idx_dif,m):\n if(b[j] == '\\\"'):\n if(a[l:i+1] != b[l+idx_dif:j+1]):\n error_cou += 1\n idx_dif = j-i\n l = i+1\n flag = 0\n break\n if(j == m-1):\n flag = 2\n break\n if(flag != 1):\n break\n \n if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):\n break\n \n if(error_cou >= 2 or flag == 2):\n print(\"DIFFERENT\")\n elif(error_cou == 1):\n print(\"CLOSE\")\n elif(error_cou == 0):\n print(\"IDENTICAL\")\n", "neg": "while(1):\n a = input()\n if(a == '.'):\n break\n b = input()\n n = len(a)\n m = len(b)\n l = 0\n flag = 0\n idx_dif = 0\n error_cou = 0\n\n while(1):\n if(flag == 0):\n for i in range(l,n):\n if(a[i] == '\\\"'):\n if(i+idx_dif < m and a[l:i+1] == b[l+idx_dif:i+idx_dif+1]):\n l = i+1\n flag = 1\n else:\n flag = 2\n break\n\n elif(i == n-1):\n if(a[l:i] != b[l+idx_dif:m-1]):\n flag = 2\n else:\n l = n-1\n\n elif(flag == 1):\n for i in range(l,n):\n if(a[i] == '\\\"'):\n for j in range(l+idx_dif,m):\n if(b[j] == '\\\"'):\n if(a[l:i+1] != b[l+idx_dif:j+1]):\n error_cou += 1\n idx_dif = j-i\n l = i+1\n flag = 0\n break\n if(j == m-1):\n flag = 2\n break\n\n if(flag == 2 or l >= n-1 or l+idx_dif >= m-1):\n break\n\n if(error_cou >= 2 or flag == 2):\n print(\"DIFFERENT\")\n elif(error_cou == 1):\n print(\"CLOSE\")\n elif(error_cou == 0):\n print(\"IDENTICAL\")\n", "jacc_sim": 1.0, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [453, 442], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u481571686", "n_user": "u481571686", "pos": "A=[]\nwhile True:\t\n\ta=input().split('\"')\n\tif a[0]==\".\":\n\t\tbreak\n\tb=input().split('\"')\n\t\n\tcnt=0\n\n\tif len(a)!=len(b):\n\t\tA.append(-1)\n\telse:\n\t\tfor i in range(len(a)):\n\t\t\tif(a[i]==b[i]):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tif i%2==1:\n\t\t\t\t\tcnt+=1\n\t\t\t\telse:\n\t\t\t\t\tcnt+=2\n\t\tif cnt>=2:\n\t\t\tA.append(-1)\n\t\tif cnt==1:\n\t\t\tA.append(0)\n\t\tif cnt==0:\n\t\t\tA.append(1)\n\nA.reverse()\n#print(A)\nfor i in range(len(A)):\n\ttmp=A.pop()\n\tif tmp==-1:\n\t\tprint(\"DIFFERENT\")\n\telif tmp==0:\n\t\tprint(\"CLOSE\")\n\telse:\n\t\tprint(\"IDENTICAL\")\n", "neg": "A=[]\nwhile True:\t\n\ta=input().split('\"')\n\tif a[0]==\".\":\n\t\tbreak\n\tb=input().split('\"')\n\t\n\tcnt=0\n\n\tif len(a)!=len(b):\n\t\tA.append(-1)\n\telse:\n\t\tfor i in range(len(a)):\n\t\t\tif(a[i]==b[i]):\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tcnt+=1\n\t\tif cnt>=2:\n\t\t\tA.append(-1)\n\t\tif cnt==1:\n\t\t\tA.append(0)\n\t\tif cnt==0:\n\t\t\tA.append(1)\n\nA.reverse()\n#print(A)\nfor i in range(len(A)):\n\ttmp=A.pop()\n\tif tmp==-1:\n\t\tprint(\"DIFFERENT\")\n\telif tmp==0:\n\t\tprint(\"CLOSE\")\n\telse:\n\t\tprint(\"IDENTICAL\")\n", "jacc_sim": 0.9767441860465116, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [270, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u055885332", "n_user": "u055885332", "pos": "#16D8101014F \u4e45\u7559\u7c73 \u7adc\u4e4b\u4ecb Python3\n#a=[]\nwhile(True):\n\ti=0\n\ttmp=0\n\ta=input().split('\"') \n\taL=len(a)\n\tif a[0] ==\".\":\n\t\tbreak\n\tb=input().split('\"')\n\tbL=len(b)\n\t\t\n\tif aL != bL:\n\t\tprint(\"DIFFERENT\")\n\telse:\n\t\twhile(True):\n\t\t\tif a[i] != b[i]:\n\t\t\t\tprint(\"DIFFERENT\")\n\t\t\t\tbreak\n\t\t\telif i > aL-2:\n\t\t\t\tif tmp==1:\n\t\t\t\t\tprint(\"CLOSE\")\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tprint(\"IDENTICAL\")\n\t\t\t\t\tbreak\n\t\t\telif a[i+1] != b[i+1]:\n\t\t\t\tif tmp==1:\n\t\t\t\t\tprint(\"DIFFERENT\")\n\t\t\t\t\tbreak\n\t\t\t\telse: tmp=1\n\t\t\ti +=2\n\t\n", "neg": "#16D8101014F \u4e45\u7559\u7c73 \u7adc\u4e4b\u4ecb Python3\n#a=[]\nwhile(True):\n\ti=0\n\ttmp=0\n\ta=input().split('\"') \n\taL=len(a)\n\tif a[0] ==\".\":\n\t\tbreak\n\tb=input().split('\"')\n\tbL=len(b)\n\t\t\n\tif aL != bL:\n\t\tprint(\"DIFFELENT\")\n\telse:\n\t\twhile(True):\n\t\t\tif a[i] != b[i]:\n\t\t\t\tprint(\"DIFFERENT\")\n\t\t\t\tbreak\n\t\t\telif i > aL-2:\n\t\t\t\tif tmp==1:\n\t\t\t\t\tprint(\"CLOSE\")\n\t\t\t\t\tbreak\n\t\t\t\telse:\n\t\t\t\t\tprint(\"IDENTICAL\")\n\t\t\t\t\tbreak\n\t\t\telif a[i+1] != b[i+1]:\n\t\t\t\tif tmp==1:\n\t\t\t\t\tprint(\"DIFFERENT\")\n\t\t\t\t\tbreak\n\t\t\t\telse: tmp=1\n\t\t\ti +=2\n\t\n", "jacc_sim": 0.9767441860465116, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [264, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01102", "p_user": "u531592024", "n_user": "u531592024", "pos": "def vals(arr):\n even = True\n res = [[], []]\n tmp = []\n for e in arr:\n if e == \"\\\"\":\n even = not even\n res[even].append(tmp)\n tmp = []\n continue\n tmp.append(e)\n even = not even\n res[even].append(tmp)\n return res\n\n\nwhile True:\n str1 = input()\n if str1 == \".\":\n break\n a = vals(str1)\n b = vals(input())\n res = 0\n if len(a[0]) != len(b[0]) or len(a[1]) != len(b[1]) :\n res = 2\n else:\n for (x, y) in zip(a[0], b[0]):\n if x != y:\n res = 2\n break\n if res == 0:\n for (a, b) in zip(a[1], b[1]):\n if a != b:\n res += 1\n if res == 2:\n break\n if res == 0:\n print(\"IDENTICAL\")\n elif res == 1:\n print(\"CLOSE\")\n else:\n print(\"DIFFERENT\")\n\n", "neg": "def vals(arr):\n even = True\n res = [[], []]\n tmp = []\n for e in arr:\n if e == \"\\\"\":\n even = not even\n res[even].append(tmp)\n tmp = []\n continue\n tmp.append(e)\n even = not even\n res[even].append(tmp)\n return res\n\n\nwhile True:\n str1 = input()\n if str1 == \".\":\n break\n a = vals(str1)\n b = vals(input())\n print(a)\n print(b)\n res = 0\n if len(a[0]) != len(b[0]) or len(a[1]) != len(b[1]) :\n res = 2\n else:\n for (x, y) in zip(a[0], b[0]):\n if x != y:\n res = 2\n break\n if res == 0:\n for (a, b) in zip(a[1], b[1]):\n if a != b:\n res += 1\n if res == 2:\n break\n if res == 0:\n print(\"IDENTICAL\")\n elif res == 1:\n print(\"CLOSE\")\n else:\n print(\"DIFFERENT\")\n\n", "jacc_sim": 1.0, "nl": "The problem \"Almost Identical Programs\" is part of a programming contest called \"Concours de Programmation Comtemporaine Interuniversitaire\" (CPCI), which has a judging system similar to ICPC. Contestants must submit correct outputs for two different inputs to be accepted as a correct solution. Each submission should include the program that generated the output. A pair of submissions is considered correct when, in addition to the correctness of the outputs, they include an identical program.\n\nHowever, many contestants submit a different version of their programs in their second submissions, after modifying a single string literal representing the input file name, attempting to process different input. The organizers of CPCI want to show a special error message for such \"close\" submissions, indicating what's wrong with them.\n\nThe task is to detect such close submissions. The input consists of at most 100 datasets, each containing two strings representing the first and second submitted programs. The length of each string is between 1 and 200, inclusive. The end of the input is indicated by a line containing a period.\n\nFor each dataset, the judge result should be printed. If the given two programs are identical, print \"IDENTICAL\". If two programs differ with only one corresponding string literal, print \"CLOSE\". Otherwise, print \"DIFFERENT\". A string literal is a possibly empty sequence of characters between an odd-numbered occurrence of a double quote and the next occurrence of a double quote.", "before_after_length": [300, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p01103", "p_user": "u260980560", "n_user": "u148477094", "pos": "while 1:\n d, w = map(int, input().split())\n if d == w == 0:\n break\n E = [list(map(int, input().split())) for i in range(d)]\n ans = 0\n for x2 in range(d):\n for y2 in range(w):\n for x1 in range(x2-1):\n for y1 in range(y2-1):\n co = 10**18\n for x in range(x1, x2+1):\n co = min(co, E[x][y1], E[x][y2])\n for y in range(y1, y2+1):\n co = min(co, E[x1][y], E[x2][y])\n ci = cnt = 0\n for x in range(x1+1, x2):\n for y in range(y1+1, y2):\n ci = max(ci, E[x][y])\n cnt += E[x][y]\n if ci < co:\n ans = max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt)\n print(ans)", "neg": "while True:\n d, w = map(int, input().split())\n if d==w==0:\n break\n E=[list(map(int, input().split())) for i in range(d)]\n a=0\n for x2 in range(d):\n for y2 in range(w):\n for x1 in range(x2-1):\n for y1 in range(y2-1):\n co=10**18\n for x in range(x1, x2+1):\n co=min(co, E[x][y1], E[x][y2])\n for y in range(y1, y2+1):\n co=min(co, E[x1][y], E[x2][y])\n ci=cnt=0\n for x in range(x1+1, x2):\n for y in range(y1+1, y2):\n ci=max(ci, E[x][y])\n cnt+=E[x][y]\n if ci < co:\n a=max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt)\n print(a)\n\n", "jacc_sim": 0.9565217391304348, "nl": "Mr. Gardiner, a modern garden designer, plans ponds by first deciding their locations and then designing them with the terrain features intact. His ponds are rectangular with simple aspect ratios. He divides the land into cells of unit square and annotates each cell with its elevation. A pond occupies a rectangular area where the outermost cells are higher than the inner cells. The width and depth of the pond are at least three. The capacity of a pond is the maximum amount of water it can keep. Given a grid map describing the elevation of each unit square cell, the task is to calculate the largest possible capacity of a pond built in the site. The input consists of datasets, each containing the depth and width of the garden site, followed by the elevation values. The output should provide the largest possible capacity of a pond for each dataset, or zero if no ponds can be built.", "before_after_length": [288, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02262", "p_user": "u264972437", "n_user": "u264972437", "pos": "def insertionSort(A,n,g,cnt):\n\tfor i in range(g,n):\n\t\tv = A[i]\n\t\tj = i - g\n\t\twhile j >= 0 and A[j] > v:\n\t\t\tA[j+g] = A[j]\n\t\t\tj = j - g\n\t\t\tcnt += 1\n\t\tA[j+g] = v\n\treturn A,cnt\n\ndef shellSort(A,n):\n\tcnt = 0\n\tG = [1]\n\twhile G[-1]*3+1 <= n:\n\t\tG.append(G[-1]*3 + 1)\n\tG = G[::-1]\n\tm = len(G)\n\tfor g in G:\n\t\tA,cnt = insertionSort(A,n,g,cnt)\n\treturn A,m,G,cnt\n\nif __name__ == '__main__':\n\t\n\tn = int(input())\n\tA = []\n\t[A.append(int(input())) for i in range(n)]\n\t\n\t'''\n\tdata = [int(d) for d in data.split('\\n')]\n\tn = data.pop(0)\n\tA = data[:]\n\t'''\n\t\n\tA,m,G,cnt = shellSort(A,n)\n\tprint(m)\n\tprint(' '.join([str(i) for i in G]))\n\tprint(cnt)\n\t[print(a) for a in A]", "neg": "def insertionSort(A,n,g,cnt):\n\tfor i in range(g,n):\n\t\tv = A[i]\n\t\tj = i - g\n\t\twhile j >= 0 and A[j] > v:\n\t\t\tA[j+g] = A[j]\n\t\t\tj = j - g\n\t\t\tcnt += 1\n\t\tA[j+g] = v\n\treturn A,cnt\n\ndef shellSort(A,n):\n\tcnt = 0\n\tG = [1]\n\twhile G[-1] <= n:\n\t\tG.append(G[-1]*3 + 1)\n\tG = G[::-1]\n\tm = len(G)\n\tfor g in G:\n\t\tA,cnt = insertionSort(A,n,g,cnt)\n\treturn A,m,G,cnt\n\nif __name__ == '__main__':\n\t\n\tn = int(input())\n\tA = []\n\t[A.append(int(input())) for i in range(n)]\n\t\n\t'''\n\tdata = [int(d) for d in data.split('\\n')]\n\tn = data.pop(0)\n\tA = data[:]\n\t'''\n\t\n\tA,m,G,cnt = shellSort(A,n)\n\tprint(m)\n\tprint(' '.join([str(i) for i in G]))\n\tprint(cnt)\n\t[print(a) for a in A]", "jacc_sim": 1.0, "nl": "Shell Sort is a variation of Insertion Sort used to arrange a list of n elements A. The algorithm involves two functions: insertionSort(A, n, g) and shellSort(A, n). The latter calls the former, considering every g-th element. The task is to complete the program by filling in the missing values. The program should read an integer n and a sequence A, then print m, G_i (i = 0, 1, ..., m \u2212 1), and the sorted sequence A. Constraints include 1 \u2264 m \u2264 100, 0 \u2264 G_i \u2264 n, and cnt not exceeding \u2308n^1.5\u2309. The input consists of an integer n followed by n lines of A_i values. The output includes m, G_i values, cnt, and the sorted A_i values. Constraints are 1 \u2264 n \u2264 1,000,000 and 0 \u2264 A_i \u2264 10^9.", "before_after_length": [352, 349], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02272", "p_user": "u150984829", "n_user": "u150984829", "pos": "def g(A,l,m,r):\n global c\n L,R=A[l:m]+[1e10],A[m:r]+[1e10]\n i=j=0\n for k in range(l,r):\n if L[i] aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [237, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u130834228", "n_user": "u130834228", "pos": "def merge(A, left, mid, right):\n\n n1 = mid-left\n n2 = right-mid\n #L = [0 for i in range(n1+1)]\n #R = [0 for i in range(n2+1)]\n #for i in range(n1):\n # L[i] = A[left+i]\n #for i in range(n2):\n # R[i] = A[mid+i]\n L = A[left:mid]\n l = len(L)\n R = A[mid:right]\n L.append(float('inf'))\n R.append(float('inf'))\n i = 0\n j = 0\n global cnt\n\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i = i+1\n \n else:\n A[k] = R[j]\n j = j+1\n cnt += l-i\n\ndef mergeSort(A, left, right):\n if left+1 < right:\n mid = (left+right) // 2\n mergeSort(A, left, mid)\n mergeSort(A, mid, right)\n merge(A, left, mid, right)\n else:\n return 0\n\nn = input()\nA = list(map(int, input().split()))\ncnt = 0\nmergeSort(A, 0, len(A))\n#print(*A)\nprint(str(cnt))", "neg": "def merge(A, left, mid, right):\n\n n1 = mid-left\n n2 = right-mid\n #L = [0 for i in range(n1+1)]\n #R = [0 for i in range(n2+1)]\n #for i in range(n1):\n # L[i] = A[left+i]\n #for i in range(n2):\n # R[i] = A[mid+i]\n L = A[left:mid]\n R = A[mid:right]\n L.append(float('inf'))\n R.append(float('inf'))\n i = 0\n j = 0\n global cnt\n\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i = i+1\n \n else:\n A[k] = R[j]\n j = j+1\n cnt += l-i\n\ndef mergeSort(A, left, right):\n if left+1 < right:\n mid = (left+right) // 2\n mergeSort(A, left, mid)\n mergeSort(A, mid, right)\n merge(A, left, mid, right)\n else:\n return 0\n\nn = input()\nA = list(map(int, input().split()))\ncnt = 0\nmergeSort(A, 0, len(A))\n#print(*A)\nprint(str(cnt))", "jacc_sim": 1.0, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [372, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u918276501", "n_user": "u918276501", "pos": "def merge(A, left, mid, right):\n global count\n # count += (right - left)\n L = A[left:mid] + [int(1e9)]\n R = A[mid:right] + [int(1e9)]\n i = j = 0\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i += 1\n else:\n A[k] = R[j]\n j += 1\n count += (mid-left-i)\n\ndef merge_sort(A, left, right):\n if left+1 < right:\n mid = (left + right) // 2\n merge_sort(A, left, mid)\n merge_sort(A, mid, right)\n merge(A, left, mid, right)\n\nif __name__ == \"__main__\":\n n = int(input())\n A = list(map(int, input().strip().split()))\n count = 0\n merge_sort(A, 0, n)\n print(count)", "neg": "def merge(A, left, mid, right):\n global count\n # count += (right - left)\n L = A[left:mid] + [int(1e9)]\n R = A[mid:right] + [int(1e9)]\n i = j = 0\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i += 1\n else:\n A[k] = R[j]\n j += 1\n count += j\n\ndef merge_sort(A, left, right):\n if left+1 < right:\n mid = (left + right) // 2\n merge_sort(A, left, mid)\n merge_sort(A, mid, right)\n merge(A, left, mid, right)\n\nif __name__ == \"__main__\":\n n = int(input())\n A = list(map(int, input().strip().split()))\n count = 0\n merge_sort(A, 0, n)\n print(count)", "jacc_sim": 1.0, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [266, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u269488240", "n_user": "u269488240", "pos": "input()\na = list(map(int, input().split()))\n\ndef merge_and_count(a, b):\n i, j = 0, 0\n count = 0\n m = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n m.append(a[i])\n i += 1\n else:\n count += len(a)-i\n m.append(b[j])\n j += 1\n\n if i < len(a):\n m += a[i:]\n else:\n m += b[j:]\n\n return (count, m)\n\n\n\ndef sort_and_count(l):\n if len(l) == 1:\n return 0, l\n else:\n a = l[0:len(l)//2]\n b = l[len(l)//2:]\n rA, a_ = sort_and_count(a)\n rB, b_ = sort_and_count(b)\n r, l_ = merge_and_count(a_, b_)\n return (rA+rB+r, l_)\n\nprint(sort_and_count(a)[0])", "neg": "a = list(map(int, input().split()))\n\ndef merge_and_count(a, b):\n i, j = 0, 0\n count = 0\n m = []\n while i < len(a) and j < len(b):\n if a[i] <= b[j]:\n m.append(a[i])\n i += 1\n else:\n count += len(a)-i\n m.append(b[j])\n j += 1\n\n if i < len(a):\n m += a[i:]\n else:\n m += b[j:]\n\n return (count, m)\n\n\n\ndef sort_and_count(l):\n if len(l) == 1:\n return 0, []\n else:\n a = l[0:len(l)//2]\n b = l[len(l)//2:]\n rA, a_ = sort_and_count(a)\n rB, b_ = sort_and_count(b)\n r, l_ = merge_and_count(a, b)\n# print(a, b)\n# print(rA, rB, a_, b_, r, l_)\n return (rA+rB+r, l_)\n\nprint(sort_and_count(a)[0])", "jacc_sim": 0.9777777777777777, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [299, 325], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u196653484", "n_user": "u196653484", "pos": "# 16D8101012J ItoJun dj Python3\ncount=0\ndef merge(A, left, mid, right):\n global count\n h=[]\n L=A[left:mid]+[2**32]\n R=A[mid:right]+[2**32]\n i=0\n j=0\n for k in range(left,right):\n if L[i] <= R[j]:\n A[k] = L[i]\n h.append(L[i])\n i += 1\n else:\n A[k] = R[j]\n h.append(R[j])\n j += 1\n if i < len(L)-1:\n count += len(L) - 1 - i\n \ndef merge_sort(A, left, right):\n if left+1 < right:\n mid=(left+right)//2\n merge_sort(A, left, mid)\n merge_sort(A, mid, right)\n merge(A, left, mid, right)\n\nif __name__ == \"__main__\":\n n=int(input())\n A=list(map(int,input().split()))\n merge_sort(A,0,n)\n print(count)\n", "neg": "# 16D8101012J ItoJun dj Python3\ncount=0\ndef merge(A, left, mid, right):\n global count\n h=[]\n L=A[left:mid]+[2**32]\n R=A[mid:right]+[2**32]\n i=0\n j=0\n for k in range(left,right):\n if L[i] <= R[j]:\n print(\"{}<={}\".format(L[i],R[j]))\n A[k] = L[i]\n h.append(L[i])\n i += 1\n else:\n print(\"{}>{}\".format(L[i],R[j]))\n A[k] = R[j]\n h.append(R[j])\n j += 1\n if i < len(L)-1:\n count += len(L) - 1 - i\n \ndef merge_sort(A, left, right):\n if left+1 < right:\n mid=(left+right)//2\n merge_sort(A, left, mid)\n merge_sort(A, mid, right)\n merge(A, left, mid, right)\n\nif __name__ == \"__main__\":\n n=int(input())\n A=list(map(int,input().split()))\n merge_sort(A,0,n)\n print(count)\n", "jacc_sim": 0.9322033898305084, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [304, 340], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u564105430", "n_user": "u564105430", "pos": "#16D8103010K Ko Okasaki\n#ALDS_5_D\n\nglobal cnt\ncnt=0\n\ndef merge(A,left,mid,right):\n L=A[left:mid]\n R=A[mid:right]\n L.append(float(\"inf\"))\n R.append(float(\"inf\"))\n \n i=0\n j=0\n for k in range(left,right):\n global cnt\n if L[i]<=R[j]:\n A[k]=L[i]\n i=i+1\n else:\n A[k]=R[j]\n j=j+1\n cnt+=mid-left-i\n\ndef mergeSort(A,left,right):\n if left+1 aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [281, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u564105430", "n_user": "u564105430", "pos": "global cnt\ncnt=0\n\ndef merge(A,left,mid,right):\n L=A[left:mid]\n R=A[mid:right]\n L.append(float(\"inf\"))\n R.append(float(\"inf\"))\n \n i=0\n j=0\n for k in range(left,right):\n global cnt\n if L[i]<=R[j]:\n A[k]=L[i]\n i=i+1\n else:\n A[k]=R[j]\n j=j+1\n cnt+=mid-left-i\n\ndef mergeSort(A,left,right):\n if left+1 aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [258, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u782850499", "n_user": "u782850499", "pos": "cnt = 0\ndef merge(A,left,mid,right):\n global cnt\n n1 = mid - left\n n2 = right - mid\n\n L = [A[i] for i in range(left, mid)]\n R = [A[i] for i in range(mid, right)]\n L.append(float(\"inf\"))\n R.append(float(\"inf\"))\n i = 0\n j = 0\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i += 1\n else:\n cnt += n1 - i\n A[k] = R[j]\n j += 1\n\ndef mergeSort(A,left,right):\n if left + 1 < right:\n mid = (left+right) // 2\n mergeSort(A,left,mid)\n mergeSort(A,mid,right)\n merge(A,left,mid,right)\n\ninput()\na = list(map(int, input().split()))\nmergeSort(a, 0, len(a))\nprint(cnt)\n\n", "neg": "cnt = 0\ndef merge(A,left,mid,right):\n global cnt\n n1 = mid - left\n n2 = right - mid\n\n L = [A[i] for i in range(left, mid)]\n R = [A[i] for i in range(mid, right)]\n L.append(float(\"inf\"))\n R.append(float(\"inf\"))\n i = 0\n j = 0\n for k in range(left, right):\n if L[i] <= R[j]:\n A[k] = L[i]\n i += 1\n else:\n cnt += n1 - i\n A[k] = R[j]\n j += 1\n\ndef mergeSort(A,left,right):\n if left + 1 < right:\n mid = (left+right) // 2\n mergeSort(A,left,mid)\n mergeSort(A,mid,right)\n merge(A,left,mid,right)\n\ninput()\na = list(map(int, input().split()))\nmergeSort(a, 0, len(a))\nreturn cnt\n\n", "jacc_sim": 0.9591836734693877, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [274, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u318430977", "n_user": "u318430977", "pos": "def merge(a, left, mid, right):\n INF = int(1e+11)\n l = a[left:mid]\n r = a[mid:right]\n l.append(INF)\n r.append(INF)\n i = 0\n j = 0\n\n ans = 0\n\n for k in range(left, right):\n if l[i] <= r[j]:\n a[k] = l[i]\n i += 1\n else:\n a[k] = r[j]\n j += 1\n if l[i] != INF:\n ans += mid - left - i\n\n return ans\n\n\ndef merge_sort(a, left, right):\n ans = 0\n if left + 1 < right:\n mid = (left + right) // 2\n ans += merge_sort(a, left, mid)\n ans += merge_sort(a, mid, right)\n ans += merge(a, left, mid, right)\n # print(left, right, ans)\n return ans\n\nn = int(input())\na = [int(x) for x in input().split()]\n\nprint(merge_sort(a, 0, len(a)))\n", "neg": "def merge(a, left, mid, right):\n INF = int(1e+11)\n l = a[left:mid]\n r = a[mid:right]\n l.append(INF)\n r.append(INF)\n i = 0\n j = 0\n\n ans = 0\n\n for k in range(left, right):\n if l[i] <= r[j]:\n a[k] = l[i]\n i += 1\n else:\n a[k] = r[j]\n j += 1\n if l[i] != INF:\n ans += 1\n\n return ans\n\n\ndef merge_sort(a, left, right):\n ans = 0\n if left + 1 < right:\n mid = (left + right) // 2\n ans += merge_sort(a, left, mid)\n ans += merge_sort(a, mid, right)\n ans += merge(a, left, mid, right)\n return ans\n\nn = int(input())\na = [int(x) for x in input().split()]\n\nprint(merge_sort(a, 0, len(a)))\n", "jacc_sim": 0.9574468085106383, "nl": "Title: The Number of Inversions\n\nFor a given sequence A = {a0, a1, ... an-1}, the number of pairs (i, j) where ai > aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [295, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02274", "p_user": "u439083584", "n_user": "u426534722", "pos": "def merge(A,left,mid,right):\n L=A[left:mid]+[float(\"INF\")]\n R=A[mid:right+1]+[float(\"INF\")]\n i=0\n j=0\n global cnt\n for k in range(left,right+1):\n if L[i]<=R[j]:\n A[k]=L[i]\n i+=1\n else:\n A[k]=R[j]\n j+=1\n cnt+=len(L)-i-1\ndef mergeSort(A,left,right):\n if left aj and i < j, is called the number of inversions. The number of inversions is equal to the number of swaps of Bubble Sort defined in the following program:\n\nbubbleSort(A)\n cnt = 0 // the number of inversions\n for i = 0 to A.length-1\n for j = A.length-1 downto i+1\n if A[j] < A[j-1]\n swap(A[j], A[j-1])\n cnt++\n\n return cnt\n\nFor the given sequence A, print the number of inversions of A. Note that you should not use the above program, which brings Time Limit Exceeded.\n\nInput:\nIn the first line, an integer n, the number of elements in A, is given. In the second line, the elements ai (i = 0, 1, .. n-1) are given separated by space characters.\n\nOutput:\nPrint the number of inversions in a line.\n\nConstraints:\n- 1 \u2264 n \u2264 200,000\n- 0 \u2264 ai \u2264 10^9\n- ai are all different\n\nSample Input 1:\n5\n3 5 2 1 4\n\nSample Output 1:\n6\n\nSample Input 2:\n3\n3 1 2\n\nSample Output 2:\n2", "before_after_length": [244, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u269568674", "n_user": "u269568674", "pos": "flg = 0\nn = int(input())\nl = list(map(int,input().split()))\nbucket = [0]*10000\nfor i in range(n):\n bucket[l[i]] += 1\n if flg < l[i]:\n flg = l[i]\nfor i in range(flg):\n for j in range(bucket[i]):\n print(i,end = ' ')\nfor i in range(bucket[flg]-1):\n print(flg,end=' ')\nprint(flg)\n", "neg": "n = int(input())\nl = list(map(int,input().split()))\nbucket = [0]*(n+1)\nfor i in range(n+1):\n for j in range(n):\n if i == l[j]:\n bucket[i] += 1\n flg = i\nprint(bucket)\nfor i in range(flg):\n for j in range(bucket[i]):\n print(i,end = ' ')\nfor i in range(bucket[flg]-1):\n print(flg,end=' ')\nprint(flg)\n\n", "jacc_sim": 0.9393939393939394, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [131, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u153665391", "n_user": "u153665391", "pos": "def counting_sort(MAX):\n C = [0 for _ in range(MAX+1)]\n\n for i in range(N):\n C[A[i]] += 1\n\n for i in range(1, MAX+1):\n C[i] = C[i] + C[i-1]\n\n for i in range(N-1, -1, -1):\n C[A[i]] -= 1\n B[C[A[i]]] = A[i]\n\nN = int(input())\nA = list(map(int, input().split()))\n\nMAX = 0\nfor n in A:\n if MAX < n:\n MAX = n\n\nB = [0 for _ in range(N)]\ncounting_sort(MAX)\nprint(\" \".join(map(str, B)))\n", "neg": "def counting_sort(MAX):\n C = [0 for _ in range(MAX+1)]\n\n for i in range(N):\n C[A[i]] += 1\n\n for i in range(1, MAX+1):\n C[i] = C[i] + C[i-1]\n\n for i in range(N-1, -1, -1):\n C[A[i]] -= 1\n B[C[A[i]]] = A[i]\n\nN = int(input())\nA = list(map(int, input().split()))\n\nMAX = 0\nfor n in A:\n if MAX < n:\n MAX = n\n\nB = [0 for _ in range(N)]\ncounting_sort(MAX)\nprint(\" \".join(B))\n", "jacc_sim": 0.9722222222222222, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [197, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u487861672", "n_user": "u487861672", "pos": "def counting_sort(A, k):\n B = [0] * len(A)\n C = [0] * k\n\n for a in A:\n C[a] += 1\n\n for i in range(1, k):\n C[i] += C[i - 1]\n\n for a in A:\n B[C[a] - 1] = a\n C[a] -= 1\n\n return B\n\n\ndef main():\n n = int(input())\n A = [int(x) for x in input().split()]\n print(*counting_sort(A, 10001))\n\n\nmain()\n", "neg": "def counting_sort(A, k):\n B = [0] * len(A)\n C = [0] * k\n\n for a in A:\n C[a] += 1\n\n for i in range(1, k):\n C[i] += C[i - 1]\n\n for a in reversed(A):\n print(a, C[a])\n B[C[a] - 1] = a\n C[a] -= 1\n\n return B\n\n\ndef main():\n n = int(input())\n A = [int(x) for x in input().split()]\n print(*counting_sort(A, 11))\n\n\nmain()\n", "jacc_sim": 0.9166666666666666, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [156, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u254642509", "n_user": "u254642509", "pos": "def InputData():\n \n sequence_len = int(input())\n sequence = [None] + [int(a) for a in input().split(\" \")]\n\n return sequence_len, sequence\n\ndef countingSort(sequence, k, sequence_len):\n \n B = [None]*(sequence_len+1)\n C = [0]*k\n \n for j in range(1, sequence_len+1):\n C[sequence[j]] += 1\n \n for i in range(1, k):\n C[i] = C[i] + C[i-1]\n \n for j in range(sequence_len, 0, -1):\n B[C[sequence[j]]] = sequence[j]\n C[sequence[j]] -= 1\n\n return B\n\ndef PrintOut(sequence):\n print(' '.join( map(str, sequence)))\n\ndef main():\n [sequence_len, sequence] = InputData()\n sequence_out = countingSort(sequence, 10000, sequence_len)\n PrintOut(sequence_out[1:])\n\nif __name__==\"__main__\":\n main()\n", "neg": "def InputData():\n \n sequence_len = int(input())\n sequence = [None] + [int(a) for a in input().split(\" \")]\n\n return sequence_len, sequence\n\ndef countingSort(sequence, k, sequence_len):\n \n B = [None]*(sequence_len+1)\n C = [0]*k\n \n for j in range(1, sequence_len+1):\n C[sequence[j]] += 1\n \n for i in range(1, k):\n C[i] = C[i] + C[i-1]\n \n for j in range(sequence_len, 0, -1):\n B[C[sequence[j]]] = sequence[j]\n C[sequence[j]] -= 1\n\n return B\n\ndef PrintOut(sequence):\n print(' '.join( map(str, sequence)))\n\ndef main():\n [sequence_len, sequence] = InputData()\n sequence_out = countingSort(sequence, 10000, sequence_len)\n PrintOut(sequence[1:])\n\nif __name__==\"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [276, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u554503378", "n_user": "u554503378", "pos": "def counting_sort(lst,ans,max):\n cnt_lst = [0] * (max+1)\n for i in range(0,len(lst)):\n cnt_lst[lst[i]] += 1\n for j in range(1,max+1):\n cnt_lst[j] = cnt_lst[j] + cnt_lst[j-1]\n\n for k in range(len(lst)-1,-1,-1):\n ans[cnt_lst[lst[k]]-1] = lst[k]\n cnt_lst[lst[k]] -= 1\n return ans\n\nn = int(input())\nn_lst = list(map(int,input().split()))\nans = [0] * len(n_lst)\nans = map(str,counting_sort(n_lst,ans,max(n_lst)))\nprint(' '.join(ans))\n\n", "neg": "def counting_sort(lst,ans,max):\n cnt_lst = [0] * (max+1)\n for i in range(1,len(lst)):\n cnt_lst[lst[i]] += 1\n for j in range(1,max+1):\n cnt_lst[j] = cnt_lst[j] + cnt_lst[j-1]\n\n for k in range(len(lst)-1,0,-1):\n ans[cnt_lst[lst[k]]] = lst[k]\n cnt_lst[lst[k]] -= 1\n return ans\n\nn = int(input())\nn_lst = list(map(int,input().split()))\nans = [0] * len(n_lst)\nans = map(str,counting_sort(n_lst,ans,max(n_lst)))\nprint(' '.join(ans))\n", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [216, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u363774867", "n_user": "u363774867", "pos": "def countingsort(a,k):\n c=[0]*(k+1)\n n=len(a)\n for i in a:\n c[i]+=1\n for i in range(1,k+1):\n c[i]=c[i]+c[i-1]\n b=[0]*n\n for i in range(n-1,-1,-1):\n b[c[a[i]]-1]=a[i]\n c[a[i]]-=1\n return b\no=int(input())\na=list(map(int,input().split()))\nq=max(a)\nret=countingsort(a,q)\nfor i in range(o):\n if i!=o-1:\n print(ret[i],end=\" \")\n else:\n print(ret[i])\n", "neg": "def countingsort(a,k):\n c=[0]*(k+1)\n n=len(a)\n for i in a:\n c[i]+=1\n for i in range(1,k+1):\n c[i]=c[i]+c[i-1]\n b=[0]*n\n for i in range(n-1,-1,-1):\n b[c[a[i]]-1]=a[i]\n c[a[i]]-=1\n return b\no=int(input())\na=list(map(int,input().split()))\nq=max(a)\nret=countingsort(a,q)\nfor i in range(n):\n if i!=n-1:\n print(ret[i],end=\" \")\n else:\n print(ret[i])\n", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [211, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u805716376", "n_user": "u805716376", "pos": "#\u8a08\u6570\u30bd\u30fc\u30c8\nn = int(input())\na = list(map(int, input().split()))\n\ndef countSort(a):\n N = max(a)\n c = [0]*(N+2)\n b = [0]*len(a)\n for i in a:\n c[i] += 1\n for i in range(1,len(c)):\n c[i] += c[i-1]\n \n for i in a:\n b[c[i]-1] = i\n c[i] -= 1\n print(*b)\n\ncountSort(a)\n", "neg": "#\u8a08\u6570\u30bd\u30fc\u30c8\nn = int(input())\na = list(map(int, input().split()))\n\ndef countSort(a):\n N = max(a)\n c = [0]*(N+2)\n b = [0]*len(a)\n for i in a:\n c[i] += 1\n for i in range(1,len(c)):\n c[i] += c[i-1]\n \n for i in a:\n b[c[i]-1] = i\n c[i] -= 1\n print(b)\n\ncountSort(*a)\n", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [162, 162], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u963402991", "n_user": "u963402991", "pos": "\n\ndef counting_sort(A, k):\n n = len(A)\n B = ['0' for i in range(n + 1)]\n C = [0 for i in range(0, k + 1)]\n\n # C[i]???i???????????\u00b0????\u00a8??????????\n for j in range(0, n):\n C[A[j]] += 1\n\n # C[i]???i??\\????????\u00b0???????????\u00b0????\u00a8??????????\n for i in range(0, k):\n C[i + 1] += C[i]\n\n for j in reversed(range(0, n)):\n B[C[A[j]]] = str(A[j])\n C[A[j]] -= 1\n return ' '.join(B[1:])\n\nn = int(input())\nA = list(map(int, input().split()))\nk = max(A)\nprint(counting_sort(A, k))", "neg": "\n\ndef counting_sort(A, k):\n B = [0 for i in range(len(A))]\n C = [0 for i in range(0, k + 1)]\n\n # C[i]???i???????????\u00b0????\u00a8??????????\n for j in range(1, n):\n C[A[j]] += 1\n\n # C[i]???i??\\????????\u00b0???????????\u00b0????\u00a8??????????\n for i in range(1, k + 1):\n C[i] += C[i - 1]\n\n for j in reversed(range(1, n)):\n B[C[A[j]]] = A[j]\n C[A[j]] -= 1\n return B\nn = int(input())\nA = list(map(int, input().split()))\nk = max(A)\n\nprint(counting_sort(A, B, k))", "jacc_sim": 0.9285714285714286, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [258, 244], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u022407960", "n_user": "u022407960", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n\ndef counting_sort(A, max_occurance):\n result = [0] * array_length\n count_list = [0] * max_occurance\n\n for j in range(array_length):\n count_list[A[j]] += 1\n # print('1', C[:array_length])\n\n for i in range(1, max_occurance):\n count_list[i] += count_list[i - 1]\n # print('2', C[:array_length])\n\n for m in array[::-1]:\n result[count_list[m] - 1] = m\n count_list[m] -= 1\n\n return result\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n array_length = int(_input[0])\n array = list(map(int, _input[1].split()))\n # assert len(array) == array_length\n max_elem = int(1e4)\n result = counting_sort(A=array, max_occurance=max_elem)\n print(*result)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\nimport sys\n\n\ndef counting_sort(A, k):\n B = [0] * k\n C = [0] * k\n for j in range(array_length):\n C[A[j]] += 1\n print('1', C[:array_length])\n\n for i in range(1, k):\n C[i] += C[i - 1]\n print('2', C[:array_length])\n\n for m in range(array_length - 1, -1, -1):\n B[C[A[m]]] = A[m]\n C[A[m]] -= 1\n\n return B[1:array_length + 1]\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n array_length = int(_input[0])\n array = list(map(int, _input[1].split()))\n assert len(array) == array_length\n MAX_ELEM = int(1e4 + 1)\n result = counting_sort(A=array, k=MAX_ELEM)\n print(*result)", "jacc_sim": 0.9016393442622951, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [296, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u564398841", "n_user": "u564398841", "pos": "def CountingSort(A, k):\n C = [0] * k\n B = C[:]\n for a in A:\n C[a] += 1\n for i in range(1, len(C)):\n C[i] += C[i - 1]\n for i in range(len(A) - 1, -1, -1):\n B[C[A[i]]] = A[i]\n C[A[i]] -= 1\n return B\n\n\n\nif __name__ == '__main__':\n N = int(input())\n A = [int(i) for i in input().strip().split()]\n sorted_A = CountingSort(A, int(3E6))\n print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))", "neg": "def CountingSort(A, k):\n C = [0] * k\n B = C[:]\n for a in A:\n C[a] += 1\n for i in range(1, len(C)):\n C[i] += C[i - 1]\n for i in range(len(A) - 1, -1, -1):\n B[C[A[i]]] = A[i]\n C[A[i]] -= 1\n return B\n\n\n\n\nif __name__ == '__main__':\n N = int(input())\n A = [int(i) for i in input().strip().split()]\n sorted_A = CountingSort(A, int(3E10))\n print(' '.join([str(a) for a in sorted_A[1:len(A) + 1]]))", "jacc_sim": 0.9523809523809523, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [203, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u130834228", "n_user": "u130834228", "pos": "def CountingSort(A, B, k):\n C = [0 for i in range(k+1)]\n n = len(A)\n #C[i]???i???????????\u00b0????\u00a8??????????\n for j in range(n):\n C[A[j]] += 1\n\n #C[i]???i??\\????????\u00b0???????????\u00b0????\u00a8??????????\n for i in range(1, k+1):\n C[i] = C[i] + C[i-1]\n\n for j in range(n)[::-1]:\n B[C[A[j]]-1] = A[j]\n #print(C[A[j]])\n C[A[j]] -= 1\n\n\nn = int(input())\nA = list(map(int, input().split()))\nB = [0 for i in range(n)]\nCountingSort(A, B, max(A))\nprint(*B)", "neg": "def CountingSort(A, B, k):\n C = [0 for i in range(k+1)]\n n = len(A)\n #C[i]???i???????????\u00b0????\u00a8??????????\n for j in range(n):\n C[A[j]] += 1\n\n #C[i]???i??\\????????\u00b0???????????\u00b0????\u00a8??????????\n for i in range(1, k+1):\n C[i] = C[i] + C[i-1]\n\n for j in range(n)[::-1]:\n B[C[A[j]]-1] = A[j]\n print(C[A[j]])\n C[A[j]] -= 1\n\n\nn = int(input())\nA = list(map(int, input().split()))\nB = [0 for i in range(n)]\nCountingSort(A, B, max(A))\nprint(*B)", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [254, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u091533407", "n_user": "u091533407", "pos": "def CountingSort(A, B, k):\n C = [0 for i in range(k+2)]\n \n for j in range(n):\n C[A[j]] += 1\n \n for i in range(k+1):\n C[i] += C[i-1]\n \n for j in range(n-1, -1, -1):\n B[C[A[j]]-1] = A[j]\n C[A[j]] -= 1\n\nif __name__==\"__main__\":\n n = int(input())\n D = list(map(int, input().split()))\n l = max(D)\n E = D[:]\n CountingSort(D, E, l)\n print(\" \".join(map(str, E)))", "neg": "def CountingSort(A, B, k):\n C = [0 for i in range(k+2)]\n \n for j in range(n):\n C[A[j]] += 1\n \n for i in range(k+1):\n C[i] += C[i-1]\n \n for j in range(n-1, -1, -1):\n B[C[A[j]]-1] = A[j]\n C[A[j]] -= 1\n\nif __name__==\"__main__\":\n n = int(input())\n D = list(map(int, input().split()))\n l = max(D)\n E = D[:]\n CountingSort(D, E, l)\n print(\" \".join(map, str(E))))", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [194, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u193453446", "n_user": "u193453446", "pos": "def CountingSort(A, B, k, n):\n C = [0 for i in range(k)] # for i = 0 to k { C[i] = 0 }\n\n # /* C[i] ??? i ???????????\u00b0????\u00a8?????????? */\n for j in range(n):\n C[A[j]] += 1\n# print(\"j:{} Aj:{} C[Aj]:{}\".format(j,A[j], C[A[j]]))\n\n # /* C[i] ??? i ??\\????????\u00b0???????????\u00b0????\u00a8??????????*/\n for i in range(k):\n# print(\"\\ti:{} Ci:{} Ci-1:{}\".format(i,C[i], C[i-1]))\n C[i] = C[i] + C[i-1]\n\n for j in reversed(range(n)):\n# print(\"j:{} Aj:{} C[Aj]:{} k:{}\".format(j,A[j], C[A[j]],k))\n B[C[A[j]]] = A[j]\n C[A[j]] -= 1\n\ndef main():\n \"\"\" ????????? \"\"\"\n num = int(input().strip())\n A = list(map(int,input().split()))\n max = 0\n for i in range(num):\n if max < A[i]:\n max = A[i]\n if max < num:\n max = num\n max += 2\n B = [0 for i in range(num + 2)]\n CountingSort(A, B, max, num)\n print(\" \".join(map(str,B[1:num+1])))\n\nif __name__ == '__main__':\n main()", "neg": "def CountingSort(A, B, k, n):\n C = [0 for i in range(k)] # for i = 0 to k { C[i] = 0 }\n\n # /* C[i] ??? i ???????????\u00b0????\u00a8?????????? */\n for j in range(n):\n C[A[j]] += 1\n print(\"j:{} Aj:{} C[Aj]:{}\".format(j,A[j], C[A[j]]))\n\n # /* C[i] ??? i ??\\????????\u00b0???????????\u00b0????\u00a8??????????*/\n for i in range(k):\n print(\"\\ti:{} Ci:{} Ci-1:{}\".format(i,C[i], C[i-1]))\n C[i] = C[i] + C[i-1]\n\n for j in reversed(range(n)):\n print(\"j:{} Aj:{} C[Aj]:{} k:{}\".format(j,A[j], C[A[j]],k))\n B[C[A[j]]] = A[j]\n C[A[j]] -= 1\n\ndef main():\n \"\"\" ????????? \"\"\"\n num = int(input().strip())\n A = list(map(int,input().split()))\n max = 0\n for i in range(num):\n if max < A[i]:\n max = A[i]\n if max < num:\n max = num\n max += 2\n B = [0 for i in range(num + 2)]\n CountingSort(A, B, max, num)\n print(\" \".join(map(str,B[1:num+1])))\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [447, 444], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u949517845", "n_user": "u949517845", "pos": "# -*- coding:utf-8 -*-\n\n\ndef countingSort(A, B, k, n):\n C = [0] * (k+1)\n\n for i in range(1, n + 1):\n C[A[i]] += 1\n\n for j in range(1, k + 1):\n C[j] = C[j] + C[j - 1]\n\n for j in range(n, 0, -1):\n B[C[A[j]]] = A[j]\n C[A[j]] -= 1\n\n\nif __name__ == \"__main__\":\n n = int(input())\n lst = [int(val) for val in input().split()]\n lst.insert(0, 0)\n result = [0] * (n + 1)\n k = max(lst)\n countingSort(lst, result, k, n)\n result.pop(0)\n print(\" \".join([str(val) for val in result]))", "neg": "# -*- coding:utf-8 -*-\n\n\ndef countingSort(A, B, k, n):\n C = [0] * (k+1)\n\n for i in range(1, n + 1):\n C[A[i]] += 1\n\n for j in range(1, k + 1):\n C[j] = C[j] + C[j - 1]\n\n print(C)\n for j in range(n, 0, -1):\n B[C[A[j]]] = A[j]\n C[A[j]] -= 1\n\n\nif __name__ == \"__main__\":\n n = int(input())\n lst = [int(val) for val in input().split()]\n lst.insert(0, 0)\n result = [0] * (n + 1)\n k = max(lst)\n countingSort(lst, result, k, n)\n result.pop(0)\n print(\" \".join([str(val) for val in result]))", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [242, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u912143677", "n_user": "u912143677", "pos": "n = int(input())\na = list(map(int, input().split()))\n\n\ndef countingsort(a, k):\n c = [0 for i in range(k+1)]\n b = [0 for i in range(n)]\n\n for j in range(n):\n c[a[j]] += 1\n\n for i in range(k):\n c[i+1] += c[i]\n\n for j in reversed(range(n)):\n b[c[a[j]]-1] = a[j]\n c[a[j]] -= 1\n\n return b\n\nb = countingsort(a, 10000)\nprint(*b)\n\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\n\ndef countingsort(a, k):\n c = [0 for i in range(k)]\n b = [0 for i in range(n)]\n\n for j in range(n):\n c[a[j]] += 1\n\n for i in range(k):\n c[i+1] += c[i]\n\n for j in reversed(range(n)):\n b[c[a[j]]] = a[j]\n c[a[j]] -= 1\n \n return b\n\nb = countingsort(a, 10001)\nprint(*b)\n", "jacc_sim": 0.9428571428571428, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [168, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u599130514", "n_user": "u599130514", "pos": "def counting_sort(A, B, k):\n len_A = len(A)\n\n C = [0 for _ in range(k + 1)]\n\n for j in range(len_A):\n C[A[j]] += 1\n\n for i in range(1, k + 1):\n C[i] = C[i] + C[i - 1]\n\n for j in range(len_A - 1, -1, -1):\n B[C[A[j]] - 1] = A[j]\n C[A[j]] -= 1\n\n\nn = int(input())\ninput_list = list(map(int, input().split(' ')))\n\nB = [0 for _ in range(n)]\n\ncounting_sort(input_list, B, max(input_list) + 1)\n\nprint(*B)\n", "neg": "def counting_sort(A, B, k):\n len_A = len(A)\n\n C = [0 for _ in range(k + 1)]\n\n for j in range(len_A):\n C[A[j]] += 1\n\n for i in range(1, k + 1):\n C[i] = C[i] + C[i - 1]\n\n for j in range(len_A - 1, -1, -1):\n B[C[A[j]] - 1] = A[j]\n C[A[j]] -= 1\n\n\nn = int(input())\ninput_list = list(map(int, input().split(' ')))\n\nB = [0 for _ in range(n)]\n\ncounting_sort(input_list, B, max(input_list) + 1)\n\nprint(B)\n", "jacc_sim": 0.972972972972973, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [207, 207], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u404682284", "n_user": "u404682284", "pos": "def CountingSort(n, input_line, max_num):\n max_num += 1\n count_list = [0 for i in range(max_num)]\n output_line = [0 for i in range(n)]\n for i in range(n):\n count_list[input_line[i]] += 1\n for i in range(1,max_num):\n count_list[i] = count_list[i] + count_list[i-1]\n for i in range(n-1,-1, -1):\n output_line[count_list[input_line[i]]-1] = str(input_line[i])\n count_list[input_line[i]] -= 1\n return output_line\n\nn = int(input())\ninput_line = [int(i) for i in input().split()]\nmax_num = max(input_line)\noutput_line = CountingSort(n, input_line, max_num)\nprint(' '.join(output_line))\n", "neg": "def CountingSort(n, input_line, max_num):\n max_num += 1\n count_list = [0 for i in range(max_num)]\n output_line = [0 for i in range(n)]\n for i in range(n):\n count_list[input_line[i]] += 1\n for i in range(1,max_num):\n count_list[i] = count_list[i] + count_list[i-1]\n print(count_list)\n for i in range(n-1,-1, -1):\n output_line[count_list[input_line[i]]-1] = str(input_line[i])\n count_list[input_line[i]] -= 1\n return output_line\n\nn = int(input())\ninput_line = [int(i) for i in input().split()]\nmax_num = max(input_line)\noutput_line = CountingSort(n, input_line, max_num)\nprint(' '.join(output_line))\n", "jacc_sim": 1.0, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [246, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u135880652", "n_user": "u300095814", "pos": "n = int(input())\nA = list(map(int, input().split()))\n\ndef CountingSort(A, B, k):\n C = [0] * k\n\n for j in range(n):\n C[A[j]] += 1\n\n for i in range(1, k):\n C[i] = C[i] + C[i-1]\n\n for j in range(n-1, -1, -1):\n B[C[A[j]] - 1] = A[j]\n C[A[j]] -= 1\n\nB = [0] * n\nCountingSort(A, B, 10000)\n\nprint(' '.join(map(str, B)))\n\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\n\ndef countingSort(A, B, k):\n C = [0] * k\n for j in range(1, n):\n C[A[j]]+=1\n\n for i in range(1, k):\n C[i] = C[i] + C[i - 1]\n\n for j in range(1, n)[::-1]:\n B[C[A[j]]] = A[j]\n C[A[j]]-=1\n return B\n \nprint(' '.join(map(str, countingSort(A, [0] * n, 10000))))\n", "jacc_sim": 0.9210526315789473, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [173, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02275", "p_user": "u629780968", "n_user": "u777299405", "pos": "def counting_sort(a,b,k):\n c = [0 for _ in range(k+1)]\n for i in range(len(a)):\n c[a[i]] += 1\n for i in range(1, len(c)):\n c[i] += c[i-1]\n for i in range(len(a) - 1, -1, -1):\n b[c[a[i]]- 1] = a[i]\n c[a[i]] -= 1\n\nn = int(input())\na = list(map(int, input().split()))\nb = [0 for _ in range(len(a))]\ncounting_sort(a, b, max(a))\nprint(*b)\n\n", "neg": "def countingsort(a, b, k):\n c = [0 for i in range(k + 1)]\n for i in range(len(a)):\n c[a[i]] += 1\n for i in range(1, len(c)):\n c[i] += c[i - 1]\n for i in range(len(a) - 1, -1, -1):\n b[c[a[i]] - 1] = a[i]\n c[a[i]] -= 1\n\nn = int(input())\na = list(map(int, input().split()))\nb = [0] * (n + 1)\ncountingsort(a, b, max(a))\nprint(*b)", "jacc_sim": 0.9117647058823529, "nl": "Counting Sort is a method used to sort elements in an array where each input element is an integer within the range of 0 to k. The algorithm works by counting the number of elements less than each input element x and then placing x directly into its position in the output array B. The algorithm needs to be adjusted to handle situations where multiple elements have the same value. The pseudocode provided outlines the steps for implementing Counting Sort. The task is to write a program that sorts the elements of a given array in ascending order using Counting Sort.\n\n**Input:**\nThe first line of the input contains an integer n, representing the number of elements in the sequence. The second line contains n elements of the sequence separated by spaces.\n\n**Output:**\nPrint the sorted sequence, with each pair of contiguous elements separated by a space.\n\n**Constraints:**\n- 1 \u2264 n \u2264 2,000,000\n- 0 \u2264 A[i] \u2264 10,000\n\n**Sample Input 1:**\n7\n2 5 1 3 2 3 0\n\n**Sample Output 1:**\n0 1 2 2 3 3 5", "before_after_length": [181, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u798796508", "n_user": "u798796508", "pos": "n = int(input())\na = list(map(int, input().split()))\n\ns = 0\nlast = a[-1]\n\nfor i in range(n-1):\n if a[i] <= last:\n tmp = a[i]\n a[i] = a[s]\n a[s] = tmp\n s += 1\ntmp = a[-1]\na[-1] = a[s]\na[s] = tmp\n\nfor i in range(0, s):\n print(a[i], end=' ')\nprint('[' + str(a[s]) + '] ', end='')\nfor i in range(s+1, n-1):\n print(a[i], end=' ')\nprint(a[n-1])\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\ns = 0\nlast = a[-1]\n\nfor i in range(n-1):\n if a[i] <= last:\n tmp = a[i]\n a[i] = a[s]\n a[s] = tmp\n s += 1\ntmp = a[-1]\na[-1] = a[s]\na[s] = tmp\n\nfor i in range(1, s):\n print(a[i], end=' ')\nprint('[' + str(a[s]) + '] ', end='')\nfor i in range(s+1, n-1):\n print(a[i], end=' ')\nprint(a[n-1])\n", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [183, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u253463900", "n_user": "u253463900", "pos": "def Partition(A,p,r):\n x = A[r]\n i = p-1\n for j in range(p,r):\n if (A[j] <= x):\n i += 1\n A[i],A[j] = A[j],A[i]\n A[i+1],A[r] = A[r],A[i+1]\n return i+1\n\nn = int(input())\nst = input()\ndata = list(map(int,st.split()))\n\nmid = Partition(data,0,len(data)-1)\nfor i in range(0,mid):\n print(data[i],end=\" \")\nprint(\"[{0}] \".format(data[mid]),end=\"\")\nfor i in range(mid+1,len(data)-1):\n print(data[i],end=\" \")\nprint(data[len(data)-1])", "neg": "def Partition(A,p,r):\n x = A[r]\n i = p-1\n for j in range(p,r):\n if (A[j] <= x):\n i += 1\n A[i],A[j] = A[j],A[i]\n print(\"swap:\",i,j)\n A[i+1],A[r] = A[r],A[i+1]\n print('swap:',i+1,r)\n return i+1\n\nn = int(input())\nst = input()\ndata = list(map(int,st.split()))\n\nmid = Partition(data,0,len(data)-1)\nfor i in data:\n print(i)\nfor i in range(0,mid):\n print(data[i],end=\" \")\nprint(\"[{0}] \".format(data[mid]),end=\"\")\nfor i in range(mid+1,len(data)-1):\n print(data[i],end=\" \")\nprint(data[len(data)-1])", "jacc_sim": 0.9767441860465116, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [219, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u488601719", "n_user": "u488601719", "pos": "def partition(a, p, r):\n x = a[r]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i = i + 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i+1\n\nn = int(input())\na = list(map(int, input().split()))\nm = partition(a, 0, n-1)\na = list(map(str, a))\na[m] = \"[%s]\"%(a[m])\nprint(\" \".join(a))", "neg": "def partition(a, p, r):\n x = a[r]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i = i + 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i+1\n\nn = int(input())\na = list(map(int, input().split()))\nm = partition(a, 0, n-1)\na[m] = \"[%s]\"%(a[m])\nprint(\" \".join(a))", "jacc_sim": 0.9743589743589743, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [168, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u247976584", "n_user": "u247976584", "pos": "class Partition:\n def partion(self, a, p, r): \n x = a[-1]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n # a[i + 1], a[-1] = a[-1], a[i + 1]\n return((a, i))\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n a = [int(x) for x in input().rstrip().split(\" \")]\n x = Partition()\n a, i = x.partion(a, 0, n)\n res = []\n for j in range(len(a)):\n if j == i:\n res.append(\"[{}]\".format(a[j]))\n else:\n res.append(str(a[j]))\n print(\" \".join(res))", "neg": "class Partition:\n def partion(self, a, p, r): \n x = a[-1]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n print(a) \n # a[i + 1], a[-1] = a[-1], a[i + 1]\n print(a)\n return((a, i))\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n a = [int(x) for x in input().rstrip().split(\" \")]\n x = Partition()\n a, i = x.partion(a, 0, n)\n res = []\n for j in range(len(a)):\n if j == i:\n res.append(\"[{}]\".format(a[j]))\n else:\n res.append(str(a[j]))\n print(\" \".join(res))", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [240, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u247976584", "n_user": "u247976584", "pos": "class Partition:\n def partion(self, a, p, r): \n x = a[r]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i + 1], a[r] = a[r], a[i + 1]\n return(i+1)\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n a = [int(x) for x in input().rstrip().split(\" \")]\n x = Partition()\n i = x.partion(a, 0, n-1)\n a = [str(i) for i in a]\n a[i] = \"[{}]\".format(a[i])\n print(\" \".join(a))", "neg": "class Partition:\n def partion(self, a, p, r): \n x = a[-1]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i] \n a[i + 1], a[-1] = a[-1], a[i + 1]\n return((a, i))\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n a = [int(x) for x in input().rstrip().split(\" \")]\n x = Partition()\n a, i = x.partion(a, 0, n)\n res = []\n for j in range(len(a)):\n if j == i:\n res.append(\"[{}]\".format(a[j]))\n else:\n res.append(str(a[j]))\n print(\" \".join(res))", "jacc_sim": 0.9148936170212766, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [214, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u918457647", "n_user": "u488601719", "pos": "def partition(p, r):\n x = a[r]\n i = p-1\n\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n\n a[i+1], a[r] = a[r], a[i+1]\n return i+1\n\n\nn = int(input())\na = list(map(int, input().split()))\nidx = partition(0, n-1)\na[idx] = [a[idx]]\nprint(*a)", "neg": "def partition(a, p, r):\n x = a[r]\n i = p - 1\n for j in range(p, r):\n if a[j] <= x:\n i = i + 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n print(*a)\n return i+1\n\nn = int(input())\na = list(map(int, input().split()))\npartition(a, 0, n)", "jacc_sim": 0.9714285714285714, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [148, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u742013327", "n_user": "u742013327", "pos": "#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp\n#partition\n\ndef partition(target_list):\n x = target_list[-1]\n i = -1\n\n for j in range(len(target_list))[:-1]:\n if target_list[j] <= x:\n i = i+1\n tmp = target_list[i]\n target_list[i] = target_list[j]\n target_list[j] = tmp\n tmp = target_list[-1]\n target_list[-1] = target_list[i + 1]\n target_list[i + 1] = tmp\n \n return i + 1\n\ndef convert(l):\n return \" \".join([str(n) for n in l])\n\nif __name__ == \"__main__\":\n n_list = int(input())\n target_list = [int(n) for n in input().split()]\n\n center_index = partition(target_list)\n print(convert(target_list[:center_index]) + \" [\"+ str(target_list[center_index]) + \"] \" + convert(target_list[center_index + 1:]))", "neg": "#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_B&lang=jp\n#partition\n\ndef partition(target_list):\n x = target_list[-1]\n i = -1\n\n for j in range(len(target_list))[:-1]:\n if target_list[j] <= x:\n i = i+1\n tmp = target_list[i]\n target_list[i] = target_list[j]\n target_list[j] = tmp\n tmp = target_list[-1]\n target_list[-1] = target_list[i + 1]\n target_list[i + 1] = tmp\n \n return i + 1\n\ndef convert(l):\n return \" \".join([str(n) for n in l])\n\nif __name__ == \"__main__\":\n n_list = int(input())\n target_list = [int(n) for n in input().split()]\n\n center_index = partition(target_list)\n print(convert(target_list[:center_index]) + \" [\"+ str(target_list[center_index]) + \"] \" + convert(target_list[center_index:]))", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [306, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u811733736", "n_user": "u811733736", "pos": "def partition(A, p, r):\n \"\"\"\n ???????????????????????????????????????A[r]?????\u00b0?????????????????????????????????????????????A[r-1]??\u00a8?\u00b4??????????????????\u00a7??\u00a8???\n \"\"\"\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n temp = A[i]\n A[i] = A[j]\n A[j] = temp\n temp = A[i+1]\n A[i+1] = A[r]\n A[r] = temp\n return i+1\n\n\nif __name__ == '__main__':\n # ??????????????\\???\n # A = [13, 19, 9, 5, 12, 8, 7, 4, 21, 2, 6, 11]\n num_of_data = int(input())\n A = [int(x) for x in input().split(' ')]\n\n # ???????????????\n p = partition(A, 0, len(A)-1) # ????????????????????????????????????len(A)??\u00a7?????????-1???????????????????????????\n\n # ???????????\u00a8???\n left = A[:p]\n partition = A[p]\n right = A[p+1:]\n print('{0} [{1}] {2}'.format(' '.join(map(str, left)), partition, ' '.join(map(str, right))))", "neg": "def partition(A, p, r):\n \"\"\"\n ???????????????????????????????????????A[r]?????\u00b0?????????????????????????????????????????????A[r-1]??\u00a8?\u00b4??????????????????\u00a7??\u00a8???\n \"\"\"\n x = A[r]p\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n temp = A[i]\n A[i] = A[j]\n A[j] = temp\n temp = A[i+1]\n A[i+1] = A[r]\n A[r] = temp\n return i+1\n\n\nif __name__ == '__main__':\n # ??????????????\\???\n # A = [13, 19, 9, 5, 12, 8, 7, 4, 21, 2, 6, 11]\n num_of_data = int(input())\n A = [int(x) for x in input().split(' ')]\n\n # ???????????????\n p = partition(A, 0, len(A)-1) # ????????????????????????????????????len(A)??\u00a7?????????-1???????????????????????????\n\n # ???????????\u00a8???\n left = A[:p]\n partition = A[p]\n right = A[p+1:]\n print('{0} [{1}] {2}'.format(' '.join(map(str, left)), partition, ' '.join(map(str, right))))", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [442, 443], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u300946041", "n_user": "u300946041", "pos": "# -*- coding: utf-8 -*-\n\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\n\ndef main():\n n = int(input())\n A = [int(e) for e in input().split()]\n p = 0\n idx = partition(A, p, n - 1)\n A = [str(e) for e in A]\n A[idx] = \"[{}]\".format(A[idx])\n return \" \".join(A)\n\n\nprint(main())", "neg": "# -*- coding: utf-8 -*-\n\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i]\n return i + 1\n\n\ndef main():\n n = int(input())\n A = [int(e) for e in input().split()]\n p = 0\n idx = partition(A, p, n - 1)\n A = [str(e) for e in A]\n A[idx] = \"[{}]\".format(A[idx])\n return \" \".join(A)\n\n\nprint(main())", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [210, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u918276501", "n_user": "u918276501", "pos": "def swap(A,i,j):\n A[i],A[j] = A[j],A[i]\n return A\n\ndef partition(A,p=0, r=None):\n if r is None:\n r = len(A)-1\n x = A[r]\n i = p-1\n for j in range(p,r):\n if A[j] <= x:\n i += 1\n swap(A,i,j)\n swap(A,i+1,r)\n return i+1\n\nif __name__ == \"__main__\":\n input()\n A = list(map(int, input().strip().split()))\n k = partition(A)\n B = list(map(str, A))\n B[k] = \"[{}]\".format(B[k])\n print(\" \".join(B))", "neg": "def partition(A,p=0, r=None):\n if r is None:\n r = len(A)-1\n x = A[r]\n i = p-1\n for j in range(p,r):\n while A[j] <= x:\n i += 1\n swap(A,i,j)\n swap(A,i+1,r)\n return i+1\n\nif __name__ == \"__main__:\n input()\n A = list(map(int, input().strip().split()))\n k = partition(A)\n B = list(map(str, A))\n B[k] = \"[{}]\".format(B[k])\n print(\" \".join(B))", "jacc_sim": 0.9791666666666666, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [210, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u024715419", "n_user": "u024715419", "pos": "n = int(input())\na = list(map(int,input().split()))\n\nx = a[-1]\ni = -1\n\nfor j in range(len(a)-1):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n\na[i + 1], a[n - 1] = \"[\" + str(a[n - 1]) + \"]\", a[i + 1]\n\nprint(*a)", "neg": "n = int(input())\na = list(map(int,input().split()))\n\nx = a[-1]\ni = -1\n\nfor j in range(len(a)-1):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n\na[i + 1], a[n] = \"[\" + str(a[n]) + \"]\", a[i + 1]\n\nprint(*a)", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [120, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u917432951", "n_user": "u091533407", "pos": "\ndef partition(A,p,r):\n x = A[r]\n i = p-1\n for j in range(p,r):\n if A[j] <= x:\n i = i+1\n (A[i],A[j]) = (A[j],A[i])\n (A[i+1],A[r]) = (A[r],A[i+1])\n return i+1\n\n\n\nif __name__ == '__main__':\n n = (int)(input())\n A = list(map(int,input().split()))\n\n i = partition(A,0,n-1)\n A[i] = \"[\"+str(A[i])+\"]\"\n print(*A)", "neg": "def partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i = i + 1\n temp = A[i]\n A[i] = A[j]\n A[j] = temp\n temp = A[i+1]\n A[i+1] = A[r]\n A[r] = temp\n return i+1\n\n\nif __name__ == \"__main__\":\n n = int(input())\n B = list(map(int, input().split()))\n p = partition(B, 0, n-1)\n print(B)\n print(\" \".join(map(str, B[:p])) + \" [\" + str(B[p]) + \"] \" + \" \".join(map(str, B[p+1:])))", "jacc_sim": 0.9024390243902439, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [180, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u150984829", "n_user": "u150984829", "pos": "n=int(input())-1\nA=list(map(int,input().split()))\ni=0\nfor j in range(n):\n if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1\nA[i],A[n]=A[n],A[i]\nprint(\" \".join(map(str,A[:i]))+\" [\"+str(A[i])+\"] \"+\" \".join(map(str,A[i+1:])))\n", "neg": "n=int(input())-1\nA=list(map(int,input().split()))\ni=0\nfor j in range(n):\n if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1\nA[i],A[n]=A[n],A[i]\nprint(\" \".join(map(str,A[:k]))+\" [\"+str(A[i])+\"] \"+\" \".join(map(str,A[k+1:])))\n", "jacc_sim": 0.96875, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [126, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u150984829", "n_user": "u150984829", "pos": "def s():\n n=int(input())-1\n A=list(map(int,input().split()))\n i=0\n for j in range(n):\n if A[j]<=A[-1]:A[i],A[j]=A[j],A[i];i+=1\n A[i],A[n]=A[n],A[i]\n print(\" \".join(map(str,A[:i]))+\" [\"+str(A[i])+\"] \"+\" \".join(map(str,A[i+1:])))\nif'__main__'==__name__:s()\n", "neg": "def s():\n n=int(input())-1\n A=list(map(int,input().split()))\n i=0\n for j in range(n):A[j]<=A[-1]and A[i],A[j]=A[j],A[i];i+=1\n A[i],A[n]=A[n],A[i]\n print(\" \".join(map(str,A[:i]))+\" [\"+str(A[i])+\"] \"+\" \".join(map(str,A[i+1:])))\nif'__main__'==__name__:s()\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [144, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u605879293", "n_user": "u605879293", "pos": "def partition(array, p, r):\n x = array[r]\n i = p-1\n for j in range(p, r):\n if array[j] <= x:\n i += 1\n array[i], array[j] = array[j], array[i]\n array[i+1], array[r] = array[r], array[i+1]\n a1 = array[:i+1]\n a2 = \"[\" + str(array[i+1]) + \"]\"\n a3 = array[i+2:]\n array = a1[:]\n array.append(a2)\n array += a3\n print(*array)\n return i+1\n\nn = int(input())\narray = [int(a) for a in input().split()]\np = partition(array, 0, n-1)\n", "neg": "def partition(array, p, r):\n x = array[r]\n i = p-1\n for j in range(p, r):\n if array[j] <= x:\n i += 1\n array[i], array[j] = array[j], array[i]\n array[i+1], array[r] = array[r], array[i+1]\n a1 = array[:i+1]\n a2 = \"[\" + str(array[i+1]) + \"]\"\n a3 = array[i+1:]\n array = a1[:]\n array.append(a2)\n array += a3\n print(*array)\n return i+1\n\nn = int(input())\narray = [int(a) for a in input().split()]\np = partition(array, 0, n-1)\n", "jacc_sim": 0.975, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [205, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u782850731", "n_user": "u782850731", "pos": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\ndef patition(a, p, r):\n x = a[r]\n i = p-1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i+1\n\n\nn = int(stdin.readline())\ndata = [int(s) for s in stdin.readline().split()]\npat = patition(data, 0, len(data)-1)\nprint(*data[:pat], end=' ')\nprint('[{}]'.format(data[pat]), *data[pat+1:])", "neg": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\ndef patition(a, p, r):\n x = a[r]\n i = p-1\n for j in range(p, r):\n if a[j] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i+1\n\n\nn = int(stdin.readline())\ndata = [int(s) for s in stdin.readline().split()]\nprint(data[-1])\npat = patition(data, 0, len(data)-1)\nprint(*data[:pat], end=' ')\nprint('[{}]'.format(data[pat]), *data[pat+1:])", "jacc_sim": 1.0, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [206, 213], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u655267413", "n_user": "u963402991", "pos": "def partition(A, p, r):\n x = A[r-1]\n i = p-1\n for j in range(p,r):\n if A[j] <= x:\n i = i+1\n A[i], A[j] = A[j], A[i]\n return i+1\n\nn = int(input())\nA = list(map(int,input().split()))\nnum = partition(A, 0, n)\nA[num-1] = f\"[{A[num-1]}]\"\nprint(*A)\n", "neg": "\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\n\nn = int(input())\nA = list(map(int, input().split()))\n\nq =partition(A, 1, len(A) - 1)\n\nprint(*A[:q] + \" [{0}] \" + *A[q + 1:])", "jacc_sim": 0.9024390243902439, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [137, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u882810648", "n_user": "u356729014", "pos": "def partition(A, p, r):\n x = A[r]\n i = p - 1\n \n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n \n A[i + 1], A[r] = A[r], A[i + 1]\n \n return i + 1\n_ = input()\nA = [int(num) for num in input().split()]\np = 0\nr = len(A)-1\nq = partition(A, p, r)\nA_str = [str(a) for a in A]\nA_str[q] = \"[\" + A_str[q] + \"]\"\nprint(\" \".join(A_str))\n", "neg": "def partition(A, p, r):\n x = A[r]\n i = p - 1\n \n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n \n A[i + 1], A[r] = A[r], A[i + 1]\n \n return i + 1\nA = [int(num) for num in input().split()][1:]\np = 0\nr = len(A)-1\nq = partition(A, p, r)\nA_str = [str(a) for a in A]\nA_str[q] = \"[\" + A_str[q] + \"]\"\nprint(\" \".join(A_str))\n", "jacc_sim": 0.9743589743589743, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [192, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u759934006", "n_user": "u300095814", "pos": "n = int(input())\nA = [int(x) for x in input().split()]\n\n\ndef partition(A, p, r):\n x = A[r]\n i = p\n for j in range(p, r):\n if A[j] <= x:\n A[i], A[j] = A[j], A[i]\n i += 1\n\n A[i], A[r] = A[r], A[i]\n\n return i\n\n\nr = partition(A, 0, n - 1)\n\nans = [str(x) for x in A]\nans[r] = '[{}]'.format(ans[r])\nprint(' '.join(ans))\n\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x :\n i += 1\n A[i], A[j] = A[j], A[i]\n\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\nb = partition(A, 0, n-1)\nA[b] = '[{0}]'.format(b)\nprint(' '.join(map(str, A)))\n", "jacc_sim": 0.9024390243902439, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [172, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u337252135", "n_user": "u546285759", "pos": "def partition(A, p, r):\n x = A[r]\n i = p-1\n for j in range(p, r):\n if A[j] <= x:\n i+=1\n A[i],A[j]=A[j],A[i]\n \n A[i+1],A[r]=A[r],A[i+1]\n return i+1\n\n#input\nn=int(input())\ndata=list(map(int, input().split()))\nq=partition(data,0,n-1)\ndata[q]=\"[\"+str(data[q])+\"]\"\nprint(*data)\n", "neg": "def partition(A, p, r):\n x = A[r]\n i = p-1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i+1], A[r] = A[r], A[i+1]\n return i+1\n\nn = int(input())\nA = list(map(int, input().split()))\ni = partition(A, 0, n)\nA[i] = \"[\"+str(A[i])+\"]\"\nprint(*A)", "jacc_sim": 0.9230769230769231, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [161, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u629780968", "n_user": "u519227872", "pos": "def partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range (p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i+1], A[r] = A[r],A[i + 1]\n return i + 1\n\nn = int(input())\na = list(map(int, input().split()))\ni = partition(a, 0, n-1)\na[i] = \"[\" + str(a[i]) + \"]\"\nprint(\" \".join(map(str, a)))\n\n", "neg": "n = int(input())\nA = list(map(int, input().split()))\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\ni = partition(A, 0, n-1)\nprint(' '.join(map(str, A[:i])) + ' [' + str(A[i]) + '] ' + ' '.join(map(str, A[i:])))", "jacc_sim": 0.972972972972973, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [164, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02276", "p_user": "u940395729", "n_user": "u963402991", "pos": "def partition(A, p, r):\n x = A[r]\n i = p-1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i+1], A[r] = A[r], A[i+1]\n A[i+1] = \"[{}]\".format(A[i+1])\n\n\nn = int(input())\nA = list(map(int, input().split()))\npartition(A, 0, n-1)\nprint(*A)\n\n", "neg": "\n\ndef partition(A, p, r):\n x = A[r]\n i = p - 1\n for j in range(p, r):\n if A[j] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\n\nn = int(input())\nA = list(map(int, input().split()))\n\nq =partition(A, 1, len(A) - 1)\n\nprint(*A[:q], end = ' ')\nprint('[{0}]'.format(A[q]), end = ' ')\nprint(*A[q + 1:])", "jacc_sim": 0.9024390243902439, "nl": "Title: Partition\n\nQuick sort is based on the Divide-and-conquer approach. In QuickSort(A, p, r), first, a procedure Partition(A, p, r) divides an array A[p..r] into two subarrays A[p..q-1] and A[q+1..r] such that each element of A[p..q-1] is less than or equal to A[q], which is, in turn, less than or equal to each element of A[q+1..r]. It also computes the index q.\n\nIn the conquer processes, the two subarrays A[p..q-1] and A[q+1..r] are sorted by recursive calls of QuickSort(A, p, q-1) and QuickSort(A, q+1, r).\n\nYour task is to read a sequence A and perform the Partition based on the following pseudocode:\n\nPartition(A, p, r)\n1 x = A[r]\n2 i = p-1\n3 for j = p to r-1\n4 do if A[j] <= x\n5 then i = i+1\n6 exchange A[i] and A[j] \n7 exchange A[i+1] and A[r]\n8 return i+1\n\nNote that, in this algorithm, Partition always selects an element A[r] as a pivot element around which to partition the array A[p..r].\n\nInput:\nThe first line of the input includes an integer n, the number of elements in the sequence A.\nIn the second line, Ai (i = 1,2,...,n), elements of the sequence are given separated by space characters.\n\nOutput:\nPrint the sorted sequence. Two contiguous elements of the sequence should be separated by a space character. The element which is selected as the pivot of the partition should be indicated by [ ].\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 0 \u2264 Ai \u2264 100,000\n\nSample Input 1:\n12\n13 19 9 5 12 8 7 4 21 2 6 11\n\nSample Output 1:\n9 5 8 7 4 2 6 [11] 21 13 19 12", "before_after_length": [154, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u805716376", "n_user": "u805716376", "pos": "a = []\nb = {}\nn = int(input())\nfor _ in range(n):\n s, i = input().split()\n a += [(s, int(i))]\n b.setdefault(int(i), []).append(s)\nb = {val: iter(s).__next__ for val, s in b.items()}\n\ndef partition(a, left, right):\n standard = a[right][1]\n cnt = left\n for i in range(left, right):\n if a[i][1] <= standard:\n a[cnt],a[i] = a[i], a[cnt]\n cnt += 1\n a[cnt],a[right] = a[right], a[cnt]\n return cnt\n\ndef quickSort(a, left = 0, right = len(a) - 1):\n if 1 <= right - left:\n cnt_ = partition(a, left, right)\n quickSort(a,left, cnt_ - 1)\n quickSort(a,cnt_ + 1, right)\n\nquickSort(a, 0 , len(a)-1)\n\nok = 1\nfor s, i in a:\n if b[i]() != s:\n ok = 0\nprint(['Not stable','Stable'][ok])\n\n\nfor i in range(n):\n print(*a[i])\n", "neg": "a = []\nb = {}\nn = int(input())\nfor _ in range(n):\n s, i = input().split()\n a += [(s, int(i))]\n b.setdefault(int(i), []).append(s)\nb = {val: iter(s).__next__ for val, s in D.items()}\n\ndef partition(a, left, right):\n standard = a[right][1]\n cnt = left\n for i in range(left, right):\n if a[i][1] <= standard:\n a[cnt],a[i] = a[i], a[cnt]\n cnt += 1\n a[cnt],a[i] = a[i], a[cnt]\n return cnt\n\ndef quickSort(a, left = 0, right = len(a) - 1):\n if 1 <= right - left:\n cnt_ = partition(a, left, right)\n quickSort(a,left, cnt_ - 1)\n quickSort(a,cnt_ + 1, right)\n\nquickSort(a, 0 , len(a)-1)\n\nok = 1\nfor v, d in A:\n if D[d]() != v:\n ok = 0\nprint(['Not stable','Stable'][ok])\n\n\nfor i in range(n):\n print(*a[i])\n", "jacc_sim": 0.9298245614035088, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [326, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u949338836", "n_user": "u949338836", "pos": "#coding:utf-8\n#1_6_C\ndef partition(A, p, r):\n x = int(A[r][1])\n i = p - 1\n for j in range(p, r):\n if int(A[j][1]) <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\ndef quick_sort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quick_sort(A, p, q - 1)\n quick_sort(A, q + 1, r)\n return A\n\nclass CheckStable:\n def __init__(self):\n self.d = dict() # Key is number. Value is array of suit.\n\n def store_cards(self, cards):\n for i in range(n):\n if cards[i][1] in self.d:\n self.d[cards[i][1]].append(cards[i][0])\n else:\n self.d[cards[i][1]] = [cards[i][0]]\n\n def is_stable(self, cards):\n for item in reversed(cards):\n if self.d[item[1]].pop() != item[0]:\n return \"Not stable\"\n return \"Stable\"\n\nn = int(input())\ncards = [tuple(input().split()) for i in range(n)]\nd = CheckStable()\nd.store_cards(cards)\n\nquick_sort(cards, 0, n - 1)\n\nprint(d.is_stable(cards))\nfor i in range(n):\n print(' '.join(cards[i]))", "neg": "#coding:utf-8\n#1_6_C\ndef partition(A, p, r):\n x = int(A[r][1])\n i = p - 1\n for j in range(p, r):\n if int(A[j][1]) <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n A[i + 1], A[r] = A[r], A[i + 1]\n return i + 1\n\ndef quick_sort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quick_sort(A, p, q - 1)\n quick_sort(A, q + 1, r)\n return A\n\nclass CheckStable:\n def __init__(self):\n self.d = dict() # Key is number. Value is array of suit.\n\n def store_cards(self, cards):\n for i in range(n):\n if cards[i][1] in self.d:\n self.d[cards[i][1]].append(cards[i][0])\n else:\n self.d[cards[i][1]] = [cards[i][0]]\n\n def is_stable(self, cards):\n for item in reversed(cards):\n if self.d[item[1]].pop() != item[0]:\n return \"Not Stable\"\n return \"Stable\"\n\nn = int(input())\ncards = [tuple(input().split()) for i in range(n)]\nd = CheckStable()\nd.store_cards(cards)\n\nquick_sort(cards, 0, n - 1)\n\nprint(d.is_stable(cards))\nfor i in range(n):\n print(' '.join(cards[i]))", "jacc_sim": 0.9848484848484849, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [449, 450], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u247976584", "n_user": "u247976584", "pos": "class Quicksort:\n def quicksort(self, a, p, r):\n if p < r:\n q = self.partion(a, p, r)\n self.quicksort(a, p, q - 1)\n self.quicksort(a, q + 1, r)\n return(a)\n\n def partion(self, a, p, r): \n x = a[r][1]\n i = p - 1\n for j in range(p, r):\n if a[j][1] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i + 1], a[r] = a[r], a[i + 1]\n return(i+1)\n\ndef bubbleSort(a, n):\n flag = 1\n while flag == 1:\n flag = 0\n for j in range(n-1, 0, -1):\n if a[j][1] < a[j - 1][1]:\n a[j], a[j-1] = a[j-1], a[j]\n flag = 1\n return(a)\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n cards = []\n for i in range(n):\n tmp = input().rstrip().split(\" \")\n tmp[1] = int(tmp[1])\n cards.append(tmp)\n a = cards[:]\n b = cards[:]\n x = Quicksort()\n a = x.quicksort(a, 0, n-1)\n b = sorted(b, key=lambda i: i[1])\n \n if a == b:\n print(\"Stable\")\n else:\n print(\"Not stable\")\n \n for i in a:\n i[1] = str(i[1])\n print(\" \".join(i))", "neg": "class Quicksort:\n def quicksort(self, a, p, r):\n if p < r:\n q = self.partion(a, p, r)\n self.quicksort(a, p, q - 1)\n self.quicksort(a, q + 1, r)\n return(a)\n\n def partion(self, a, p, r): \n x = a[r][1]\n i = p - 1\n for j in range(p, r):\n if a[j][1] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i + 1], a[r] = a[r], a[i + 1]\n return(i+1)\n\ndef bubbleSort(a, n):\n flag = 1\n while flag == 1:\n flag = 0\n for j in range(n-1, 0, -1):\n if a[j][1] < a[j - 1][1]:\n a[j], a[j-1] = a[j-1], a[j]\n flag = 1\n return(a)\n\nif __name__ == '__main__':\n n = int(input().rstrip())\n cards = []\n for i in range(n):\n tmp = input().rstrip().split(\" \")\n tmp[1] = int(tmp[1])\n cards.append(tmp)\n a = cards[:]\n b = cards[:]\n \n x = Quicksort()\n a = x.quicksort(a, 0, n-1)\n \n b = bubbleSort(b, n)\n\n if a == b:\n print(\"Stable\")\n else:\n print(\"Not Stable\")\n \n for i in a:\n i[1] = str(i[1])\n print(\" \".join(i))", "jacc_sim": 0.9298245614035088, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [462, 460], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u613534067", "n_user": "u613534067", "pos": "# Quick Sort #\ndef partition(A, p, r):\n x = A[r][1]\n i = p-1\n for k in range(p, r):\n if A[k][1] <= x:\n i += 1\n A[i], A[k] = A[k], A[i]\n A[i+1], A[r] = A[r], A[i+1]\n return i+1\n\ndef quick_sort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quick_sort(A, p, q-1)\n quick_sort(A, q+1, r)\n\ndef bubble_sort(c, n):\n x = c[:]\n for i in range(n):\n for k in range(n-1, i, -1):\n if x[k][1] < x[k-1][1]:\n x[k], x[k-1] = x[k-1], x[k]\n return x\n\ndef is_stable(_in, out):\n n = len(_in)\n for i in range(n):\n for k in range(i+1, n):\n for a in range(n):\n for b in range(a+1, n):\n if _in[i][1] == _in[k][1] and _in[i] == out[b] and _in[k] == out[a]:\n return False\n return True\n\nn = int(input())\na = []\nfor i in range(n):\n mrk, num = input().split()\n num = int(num)\n a.append((mrk, num))\nb = a[:]\nquick_sort(b, 0, n-1)\nif n > 10000:\n print(\"Not stable\")\nelse:\n c = bubble_sort(a[:], n)\n if b == c:\n print(\"Stable\")\n else:\n print(\"Not stable\")\nfor i in b:\n print(*i)\n", "neg": "# Quick Sort #\ndef partition(A, p, r):\n x = A[r][1]\n i = p-1\n for k in range(p, r):\n if A[k][1] <= x:\n i += 1\n A[i], A[k] = A[k], A[i]\n A[i+1], A[r] = A[r], A[i+1]\n return i+1\n\ndef quick_sort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quick_sort(A, p, q-1)\n quick_sort(A, q+1, r)\n\ndef bubble_sort(c, n):\n x = c[:]\n for i in range(n):\n for k in range(n-1, i, -1):\n if x[k][1] < x[k-1][1]:\n x[k], x[k-1] = x[k-1], x[k]\n return x\n\ndef is_stable(_in, out):\n n = len(_in)\n for i in range(n):\n for k in range(i+1, n):\n for a in range(n):\n for b in range(a+1, n):\n if _in[i][1] == _in[k][1] and _in[i] == out[b] and _in[k] == out[a]:\n return False\n return True\nn = int(input())\na = []\nfor i in range(n):\n mrk, num = input().split()\n num = int(num)\n a.append((mrk, num))\nb = a[:]\nquick_sort(b, 0, n-1)\nc = bubble_sort(a[:], n)\nif b == c:\n print(\"Stable\")\nelse:\n print(\"Not Stable\")\nfor i in b:\n print(*i)\n", "jacc_sim": 0.9482758620689655, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [501, 482], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u255317651", "n_user": "u255317651", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu May 3 21:24:25 2018\nALDS1_6_C\n@author: maezawa\n\"\"\"\na = []\nn = int(input())\nfor i in range(n):\n s = input().split()\n a.append([s[0], int(s[1])])\n \na_in = a.copy()\n\ndef is_stable(a, b):\n s = True\n for i in range(n-1):\n if b[i+1][1] == b[i][1]:\n j = a.index(b[i])\n k = a.index(b[i+1])\n if j > k:\n s = False\n return s\n return s\n \n\ndef partition(a, p, r):\n x = a[r][1]\n i = p - 1\n for j in range(p, r):\n if a[j][1] <= x:\n i += 1\n temp = a[i]\n a[i] = a[j]\n a[j] = temp\n temp = a[i+1]\n a[i+1] = a[r]\n a[r] = temp\n return i+1\n \ndef quick_sort(a, p, r):\n if p < r:\n q = partition(a, p, r)\n quick_sort(a, p, q-1)\n quick_sort(a, q+1, r)\n\nquick_sort(a, 0, len(a)-1)\nif is_stable(a_in, a):\n print('Stable')\nelse:\n print('Not stable')\nfor i in range(len(a)):\n print('{} {}'.format(a[i][0],a[i][1]))\n\n\n", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu May 3 21:24:25 2018\nALDS1_6_C\n@author: maezawa\n\"\"\"\na = []\nn = int(input())\nfor i in range(n):\n s = input().split()\n a.append([s[0], int(s[1])])\n \na_in = a.copy()\n\ndef is_stable(a, b):\n s = True\n for i, card in enumerate(b):\n if b[i+1][1] == b[i][1]:\n j = a.index(card)\n k = a.index(b[i+1])\n if j > k:\n s = False\n return s\n return s\n \n\ndef partition(a, p, r):\n x = a[r][1]\n i = p - 1\n for j in range(p, r):\n if a[j][1] <= x:\n i += 1\n temp = a[i]\n a[i] = a[j]\n a[j] = temp\n temp = a[i+1]\n a[i+1] = a[r]\n a[r] = temp\n return i+1\n \ndef quick_sort(a, p, r):\n if p < r:\n q = partition(a, p, r)\n quick_sort(a, p, q-1)\n quick_sort(a, q+1, r)\n\nquick_sort(a, 0, len(a)-1)\nif is_stable(a_in, a):\n print('Stable')\nelse:\n print('Not stable')\nfor i in range(len(a)):\n print('{} {}'.format(a[i][0],a[i][1]))\n\n\n", "jacc_sim": 0.972972972972973, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [454, 452], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u404682284", "n_user": "u404682284", "pos": "def partition(num_list, start, end):\n split = start -1\n x = int(num_list[end][1])\n for i in range(start, end):\n if int(num_list[i][1]) <= x:\n split += 1\n num_list[split], num_list[i] = num_list[i], num_list[split]\n num_list[split+1], num_list[end] = num_list[end], num_list[split+1]\n return split+1\n\ndef quickSort(num_list, start, end):\n if start < end:\n q = partition(num_list, start, end)\n quickSort(num_list, start, q-1)\n quickSort(num_list, q+1, end)\n\nimport sys, copy\nn = int(input())\ninput_list = [sys.stdin.readline().rstrip().split() for i in range(n)]\ncheck_list = copy.deepcopy(input_list)\nquickSort(input_list, 0, n-1)\nfor i in range(n-1):\n if input_list[i][1] == input_list[i+1][1]:\n if check_list.index(input_list[i]) > check_list.index(input_list[i+1]):\n print('Not stable')\n break\nelse:\n print('Stable')\nfor i in input_list:\n print('{} {}'.format(i[0], i[1]))\n", "neg": "def partition(num_list, start, end):\n split = start -1\n end -= 1\n x = num_list[end][1]\n for i in range(start, end):\n if num_list[i][1] <= x:\n split += 1\n num_list[split], num_list[i] = num_list[i], num_list[split]\n num_list[split+1], num_list[end] = num_list[end], num_list[split+1]\n num_list = [str(i) for i in num_list]\n return split+1\n\ndef quickSort(num_list, start, end):\n if start < end:\n q = partition(num_list, start, end)\n quickSort(num_list, start, q-1)\n quickSort(num_list, q+1, end)\n\nimport sys, copy\nn = int(input())\ninput_list = [sys.stdin.readline().rstrip().split() for i in range(n)]\ncheck_list = copy.deepcopy(input_list)\nquickSort(input_list, 0, n)\nfor i in range(n-1):\n if input_list[i][1] == input_list[i+1][1]:\n if check_list.index(input_list[i]) > check_list.index(input_list[i+1]):\n print('Not Stable')\n break\nelse:\n print('Stable')\nfor i in input_list:\n print('{} {}'.format(i[0], i[1]))\n\n", "jacc_sim": 0.9629629629629629, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [367, 386], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u007270338", "n_user": "u007270338", "pos": "#coding:utf-8\nfrom copy import deepcopy\nn = int(input())\nA = []\nfor i in range(n):\n ch, num = input().split()\n A.append([ch, int(num)])\n\nB = deepcopy(A)\n\n\n\ndef Merge(A, left, mid, right):\n L = A[left:mid]\n R = A[mid:right]\n L.append([\"S\",2000000000])\n R.append([\"S\",2000000000])\n i,j = 0,0\n for k in range(left,right):\n if L[i][1] <= R[j][1]:\n A[k] = L[i]\n i += 1\n else:\n A[k] = R[j]\n j += 1\n\ndef MergeSort(A, left, right):\n if left+1 < right:\n mid = (left + right)//2\n MergeSort(A, left, mid)\n MergeSort(A, mid, right)\n Merge(A, left, mid, right)\n\n \n\ndef partition(A, p, r):\n x = A[r-1][1]\n i = p-1\n for j in range(p, r):\n if A[j][1] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n return i\n\n\ndef quickSort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quickSort(A, p, q)\n quickSort(A, q+1, r)\n\n\n\n\n \nquickSort(A, 0, n)\nMergeSort(B, 0, n)\n\nif A == B:\n print(\"Stable\")\nelse:\n print(\"Not stable\")\n \nfor a in A:\n a = \" \".join([a[0],str(a[1])])\n print(a)\n\n\n\n", "neg": "#coding:utf-8\nfrom copy import deepcopy\nn = int(input())\nA = []\nfor i in range(n):\n ch, num = input().split()\n A.append([ch, int(num)])\n\nB = deepcopy(A)\n\n\n\ndef Merge(A, left, mid, right):\n L = A[left:mid]\n R = A[mid:right]\n L.append([\"S\",20000000])\n R.append([\"S\",20000000])\n i,j = 0,0\n for k in range(left,right):\n if L[i][1] <= R[j][1]:\n A[k] = L[i]\n i += 1\n else:\n A[k] = R[j]\n j += 1\n\ndef MergeSort(A, left, right):\n if left+1 < right:\n mid = (left + right)//2\n MergeSort(A, left, mid)\n MergeSort(A, mid, right)\n Merge(A, left, mid, right)\n\n \n\ndef partition(A, p, r):\n x = A[r-1][1]\n i = p-1\n for j in range(p, r):\n if A[j][1] <= x:\n i += 1\n A[i], A[j] = A[j], A[i]\n return i\n\n\ndef quickSort(A, p, r):\n if p < r:\n q = partition(A, p, r)\n quickSort(A, p, q)\n quickSort(A, q+1, r)\n\n\n\n\n \nquickSort(A, 0, n)\nMergeSort(B, 0, n)\n\nif A == B:\n print(\"stable\")\nelse:\n print(\"Not stable\")\n \nfor a in A:\n a = \" \".join([a[0],str(a[1])])\n print(a)\n\n", "jacc_sim": 0.9545454545454546, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [486, 482], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u424720817", "n_user": "u424720817", "pos": "def main() :\n n = int(input())\n cards = [Card(*input().split()) for i in range(n)]\n stableCards = sorted(cards[:], key=lambda c: c.number)\n quickSort(cards, 0, n - 1)\n print(isStable(cards, stableCards, n))\n list(map(lambda i : i.print_card(), cards))\n\ndef quickSort(cards, p, r) :\n if p < r:\n q = partion(cards, p, r)\n quickSort(cards, p, q - 1)\n quickSort(cards, q + 1, r)\n\ndef partion(cards, p, r) :\n x = cards[r]\n i = p\n for j in range(p, r + 1) :\n if int(cards[j].number) <= int(x.number) :\n cards[i], cards[j] = cards[j], cards[i]\n i += 1\n return i - 1\n\ndef isStable(a, b, n):\n for i in range(n):\n if a[i].prefix != b[i].prefix:\n return 'Not stable'\n\n return 'Stable'\n\nclass Card():\n def __init__(self, prefix, number):\n self.prefix = prefix\n self.number = number\n\n def print_card(self):\n print(self.prefix, self.number)\n\nif __name__ == '__main__':\n main()\n\n", "neg": "def main() :\n n = int(input())\n cards = [Card(*input().split()) for i in range(n)]\n stableCards = sorted(cards[:], key=lambda c: (c.number, c.prefix))\n quickSort(cards, 0, n - 1)\n print(isStable(cards, stableCards, n))\n list(map(lambda i : i.print_card(), cards))\n\ndef quickSort(cards, p, r) :\n if p < r:\n q = partion(cards, p, r)\n quickSort(cards, p, q - 1)\n quickSort(cards, q + 1, r)\n\ndef partion(cards, p, r) :\n x = cards[r]\n i = p\n for j in range(p, r + 1) :\n if cards[j].number <= x.number :\n cards[i], cards[j] = cards[j], cards[i]\n i += 1\n return i - 1\n\ndef isStable(a, b, n):\n for i in range(n):\n if a[i].prefix != b[i].prefix:\n return 'Not stable'\n\n return 'Stable'\n\nclass Card():\n def __init__(self, prefix, number):\n self.prefix = prefix\n self.number = number\n\n def print_card(self):\n print(self.prefix, self.number)\n\nif __name__ == '__main__':\n main()\n\n", "jacc_sim": 1.0, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [371, 369], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02277", "p_user": "u782850731", "n_user": "u782850731", "pos": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\ndef patition(a, p, r):\n x = a[r][0]\n i = p - 1\n for j in range(p, r):\n if a[j][0] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i + 1\n\n\ndef quick_sort(a, p, r):\n if p < r:\n q = patition(a, p, r)\n quick_sort(a, p, q-1)\n quick_sort(a, q+1, r)\n\n\nn = int(stdin.readline())\ndata = []\ns = set()\nfor i in range(n):\n c, num = stdin.readline().split()\n data.append((int(num), c))\n s.add(int(num))\noutput = data[:]\nquick_sort(output, 0, n-1)\nfor i in s:\n if [d for d in data if d[0] == i] != [d for d in output if d[0] == i]:\n print('Not stable')\n break\nelse:\n print('Stable')\nfor num, c in output:\n print(c, num)", "neg": "#!/usr/bin/env python\nfrom __future__ import division, print_function\nfrom sys import stdin\n\n\ndef patition(a, p, r):\n x = a[r][0]\n i = p - 1\n for j in range(p, r):\n if a[j][0] <= x:\n i += 1\n a[i], a[j] = a[j], a[i]\n a[i+1], a[r] = a[r], a[i+1]\n return i + 1\n\n\ndef quick_sort(a, p, r):\n if p < r:\n q = patition(a, p, r)\n quick_sort(a, p, q-1)\n quick_sort(a, q+1, r)\n\n\nn = int(stdin.readline())\ndata = []\ns = set()\nfor i in range(n):\n c, num = stdin.readline().split()\n data.append((int(num), c))\n s.add(int(num))\noutput = data[:]\nquick_sort(output, 0, n-1)\nfor i in s:\n if [d for d in data if d[0] == i] != [d for d in output if d[0] == i]:\n print('Not stable')\n break\nelse:\n print('Stable')\nfor num, c in data:\n print(c, num)", "jacc_sim": 1.0, "nl": "Title: Quick Sort\n\nLet's arrange a deck of cards. Your task is to sort a total of n cards. Each card consists of a suit (S, H, C, or D) and a number. Write a program to sort these cards using the following pseudocode:\n\nPartition(A, p, r)\n1. x = A[r]\n2. i = p-1\n3. for j = p to r-1\n4. if A[j] <= x\n5. then i = i+1\n6. exchange A[i] and A[j] \n7. exchange A[i+1] and A[r]\n8. return i+1\n\nQuicksort(A, p, r)\n1. if p < r\n2. then q = Partition(A, p, r)\n3. run Quicksort(A, p, q-1)\n4. run Quicksort(A, q+1, r)\n\nHere, A is an array representing a deck of cards, and comparisons are based on the numbers.\n\nYour program should also report the stability of the output for the given input. Stability means that cards with the same value appear in the output in the same order as they do in the input.\n\nInput\nThe first line contains an integer n, the number of cards.\nn cards are given in the following lines. Each card is represented by a pair of a character and an integer separated by a single space.\n\nOutput\nIn the first line, print the stability (\"Stable\" or \"Not stable\") of the output.\nIn the following lines, print the arranged cards in the same manner as the input.\n\nConstraints\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 the number of a card \u2264 10^9\n- There are no identical cards in the input\n\nSample Input 1\n6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 1\n\nSample Output 1\nNot stable\nD 1\nC 1\nD 2\nH 2\nD 3\nS 3\n\nSample Input 2\n2\nS 1\nH 1\n\nSample Output 2\nStable\nS 1\nH 1", "before_after_length": [349, 349], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u509309113", "n_user": "u509309113", "pos": "n = int(input())\n\npoints = []\n\nfor i in range(n) :\n point = list(map(int, input().split(\" \")))\n points.append(point)\n\nz = []\nw = []\n\nfor i in range(len(points)) :\n z.append(points[i][0] + points[i][1])\n\nfor i in range(len(points)) :\n w.append(points[i][0] - points[i][1])\n\nmax_z = max(z) - min(z)\nmax_w = max(w) - min(w)\n\nif max_z > max_w :\n print(max_z)\nelse :\n print(max_w)\n", "neg": "n = int(input())\n\npoints = []\n\nfor i in range(n) :\n point = list(map(int, input(\" \")))\n points.append(point)\n\nz = []\nw = []\n\nfor i in range(len(points)) :\n z.append(points[i][0] + points[i][1])\n\nfor i in range(len(points)) :\n w.append(points[i][0] - points[i][1])\n\nmax_z = max(z) - min(z)\nmax_w = max(w) - min(w)\n\nif max_z > max_w :\n print(max_z)\nelse :\n print(max_w)", "jacc_sim": 0.972972972972973, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [176, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u437215432", "n_user": "u437215432", "pos": "def manhattan(n, x, y):\n x2 = [0] * n\n y2 = [0] * n\n for i in range(n):\n x2[i] = x[i] - y[i]\n y2[i] = x[i] + y[i]\n print(max(max(x2) - min(x2), max(y2) - min(y2)))\n\nn = int(input())\nx = [0] * n\ny = [0] * n\nfor i in range(n):\n x[i] , y[i] = map(int, input().split())\nmanhattan(n, x, y)\n", "neg": "def manhattan(n, x, y):\n x2 = [0] * n\n y2 = [0] * n\n for i in range(n):\n x0, y0 = xy[i]\n x2[i] = x0 - y0\n y2[i] = x0 + y0\n print(max(max(x2) - min(x2), max(y2) - min(y2)))\n\nn = int(input())\nx = [0] * n\ny = [0] * n\nfor i in range(n):\n x[i] , y[i] = map(int, input().split())\nmanhattan(n, x, y)\n", "jacc_sim": 0.9090909090909091, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [168, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u539517139", "n_user": "u546853743", "pos": "n=int(input())\na=[]\nb=[]\nfor i in range(n):\n x,y=map(int,input().split())\n a.append(x+y)\n b.append(x-y)\nprint(max(max(a)-min(a),max(b)-min(b)))", "neg": "n=int(input())\na=[]\nb=[]\nfor i in range(n):\n x,y=list(map(int,input().split()))\n a.append(x+y)\n b.append(x-y)\nprint(abs(max(max(a),max(b)))-abs(min(min(a),min(b))))", "jacc_sim": 0.9310344827586207, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [77, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u033602950", "n_user": "u033602950", "pos": "import sys\n#import time\nfrom collections import deque, Counter, defaultdict\n#from fractions import gcd\nimport bisect\nimport heapq\n#import math\nimport itertools\nimport numpy as np\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\ninf = 10**18\nMOD = 1000000007\nri = lambda : int(input())\nrs = lambda : input().strip()\nrl = lambda : list(map(int, input().split()))\n\nn = ri()\na = []\nb = []\nfor i in range(n):\n x,y = rl()\n a.append(x+y)\n b.append(x-y)\na.sort()\nb.sort()\nprint(max(a[-1]-a[0], b[-1]-b[0]))", "neg": "import sys\n#import time\nfrom collections import deque, Counter, defaultdict\n#from fractions import gcd\nimport bisect\nimport heapq\n#import math\nimport itertools\nimport numpy as np\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\ninf = 10**18\nMOD = 1000000007\nri = lambda : int(input())\nrs = lambda : input().strip()\nrl = lambda : list(map(int, input().split()))\n\nn = ri()\na = []\nb = []\nfor i in range(n):\n x,y = rl()\n a.append(x+y)\n b.append(x-y)\na.sort()\nb.sort()\nprint(max(a[-1]-a[0], b[-1]-[0]))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [190, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u347203174", "n_user": "u347203174", "pos": "import math\nN = int(input())\n\ns1 = []\ns2 = []\n#visited\nfor i in range(N):\n x, y = map(int, input().split())\n d0 = x + y\n d1 = x - y\n #if d0 in s1 and d1 in s2 and s1.index(d0) == s2.index(d1):\n # continue\n s1.append(d0)\n s2.append(d1)\n\n\nans = 0\n\nif len(s1) > 1 and len(s2) > 1:\n s1s = sorted(s1)\n s2s = sorted(s2)\n\n ans = max(s1s[0] - s1s[-1], s2s[0] - s2s[-1]\n , s1s[-1] - s1s[0], s2s[-1] - s2s[0])\n\nprint(int(ans))\n\n\n", "neg": "import math\nN = int(input())\n\ns1 = []\ns2 = []\n#visited\nfor i in range(N):\n x, y = map(int, input().split())\n d0 = x + y\n d1 = x - y\n if d0 in s1 and d1 in s2 and s1.index(d0) == s2.index(d1):\n continue\n s1.append(d0)\n s2.append(d1)\n\n\nans = 0\n\nif len(s1) > 1 and len(s2) > 1:\n s1s = sorted(s1)\n s2s = sorted(s2)\n\n ans = max(s1s[0] - s1s[-1], (s2s[0] - s2s[-1])\n , (s1s[0] - s2s[0]), (s1s[-1] - s2s[-1]))\n\nprint(int(ans))\n\n\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [239, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u395313349", "n_user": "u395313349", "pos": "def main():\n n = int(input())\n a_li , b_li = [] , []\n for _ in range(n):\n x , y = map(int,input().split())\n a_li.append(x + y)\n b_li.append(x - y)\n print(max(max(a_li) - min(a_li), max(b_li) - min(b_li)))\n \nif __name__ == \"__main__\":\n main()", "neg": "def main():\n n = int(input())\n a_li , b_li = [] , []\n for _ in range(n):\n x , y = int(input())\n a_li.append(x + y)\n b_li.append(x - y)\n print(max(max(a_li) - min(a_li), max(b_li) - min(b_li)))\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9393939393939394, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [119, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u453623947", "n_user": "u453623947", "pos": "n = int(input())\nxy = [list(map(int,input().split())) for i in range(n)]\ncheby = []\nfor i in range(n):\n l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]\n cheby.append(l)\n\nxmax = -10**10\nxmin = 10**10\nymax = -10**10\nymin = 10**10\nfor i in range(n):\n if cheby[i][0] > xmax :\n xmax = cheby[i][0]\n xa = i\n if cheby[i][0] < xmin :\n xmin = cheby[i][0]\n xi = i\n if cheby[i][1] > ymax :\n ymax = cheby[i][1]\n ya = i\n if cheby[i][1] < ymin :\n ymin = cheby[i][1]\n yi = i\n\nif abs(xmax-xmin) > abs(ymax-ymin):\n print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))\nelse :\n print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))\n", "neg": "n = int(input())\nxy = [list(map(int,input().split())) for i in range(n)]\ncheby = []\nfor i in range(n):\n l = [xy[i][0]-xy[i][1],xy[i][0]+xy[i][1]]\n cheby.append(l)\n\nxmax = 0\nxmin = 10**10\nymax = 0\nymin = 10**10\nfor i in range(n):\n if cheby[i][0] > xmax :\n xmax = cheby[i][0]\n xa = i\n if cheby[i][0] < xmin :\n xmin = cheby[i][0]\n xi = i\n if cheby[i][1] > ymax :\n ymax = cheby[i][1]\n ya = i\n if cheby[i][1] < ymin :\n ymin = cheby[i][1]\n yi = i\n\nif abs(xmax-xmin) >= abs(ymax-ymin):\n print(abs(xy[xa][0]-xy[xi][0])+abs(xy[xa][1]-xy[xi][1]))\nelse :\n print(abs(xy[ya][0]-xy[yi][0])+abs(xy[ya][1]-xy[yi][1]))\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [333, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u262121009", "n_user": "u262121009", "pos": "n = int(input())\n\nz = []\nw = []\nfor i in range(n):\n x, y = map(int, input().split())\n z.append(x + y)\n w.append(x - y)\nz.sort()\nw.sort()\nprint(max(z[-1]-z[0], w[-1]-w[0]))", "neg": "n = int(input())\nw = []\nfor i in range(n):\n x, y = map(int, input().split())\n z.append(x + y)\n w.append(x - y)\nz.sort()\nw.sort()\nprint(max(z[-1]-z[0], w[-1]-w[0]))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [90, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u242757684", "n_user": "u242757684", "pos": "# Fast IO (be careful about bytestring, not on interactive)\n\nimport os,io\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nN = int(input())\n\nsumList = []\nsubList = []\n\nfor _ in range(N):\n x,y = map(int,input().split())\n sumList.append(x + y)\n subList.append(x - y)\n\nprint(max(max(sumList) - min(sumList),max(subList) - min(subList)))", "neg": "# Fast IO (be careful about bytestring, not on interactive)\n\nimport os,io\ninput=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nN = int(input())\n\nsumList = []\nsubList = []\n\nfor _ in range(N):\n x,y = map(int,input().split())\n sumList.append(x + y)\n subList.append(x - y)\n\nprint(max(max(sumList),max(subList)))", "jacc_sim": 0.9787234042553191, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [139, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u773081031", "n_user": "u773081031", "pos": "n = int(input())\nu = [list(map(int, input().split())) for i in range(n)]\nz = [u[i][0] + u[i][1] for i in range(n)]\nw = [u[i][0] - u[i][1] for i in range(n)]\nd = [max(z)-min(z), max(w)-min(w)]\n\nprint(max(d))\n\t\n", "neg": "n = int(input())\nu = [list(map(int, input().split())) for i in range(n)]\nz = [u[i][0] + u[i][1] for i in range(n)]\nw = [w[i][0] - w[i][1] for i in range(n)]\nd = [max(z)-min(z), max(w)-min(w)]\n\nprint(max(d))\n\t\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [107, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u329865314", "n_user": "u329865314", "pos": "n = int(input())\nl = []\nfor i in range(n):\n l.append(list(map(int,input().split())))\n\nk = []\nm = []\nfor i in l:\n a,b = i\n k.append(a+b)\n m.append(a-b)\nk.sort()\nm.sort()\nprint(max([k[-1]-k[0],m[-1] -m[0]]))", "neg": "n = int(input())\nl = []\nfor i in range(n):\n l.append(list(map(int,input().split())))\nm = []\nfor i in l:\n a,b = i\n k.append(a+b)\n m.append(a-b)\nk.sort()\nm.sort()\nprint(max([k[-1]-k[0],m[-1] -m[0]]))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [111, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u664907598", "n_user": "u664907598", "pos": "n=int(input())\nxbox=[]\nybox=[]\nfor i in range(n):\n x,y = map(int,input().split())\n xbox.append(x)\n ybox.append(y)\nxmax=max(xbox)\nxmin = min(xbox)\nymax=max(ybox)\nymin=min(ybox)\nbox1=[]\nbox2=[]\nbox3=[]\nbox4=[]\nfor i in range(n):\n box1.append(xmax+ymax-xbox[i]-ybox[i])\n box2.append(-xmin + ymax + xbox[i] - ybox[i])\n box3.append(xmax - ymax - xbox[i] + ybox[i])\n box4.append(-xmax - ymax + xbox[i] + ybox[i])\nprint(max([max(box1)-min(box1),max(box2)-min(box2),max(box3)-min(box3),max(box4)-min(box4)]))\n", "neg": "n=int(input())\nxbox=[]\nybox=[]\nfor i in range(n):\n x,y = map(int,input().split())\n xbox.append(x)\n ybox.append(y)\nxmax=max(xbox)\nxmin = min(xbox)\nymax=max(ybox)\nymin=min(ybox)\nbox1=[]\nbox2=[]\nbox3=[]\nbox4=[]\nfor i in range(n):\n box1.append(xmax+ymax-xbox[i]-ybox[i])\n box2.append(-xmin + ymax + xbox[i] - ybox[i])\n box2.append(xmax - ymax - xbox[i] + ybox[i])\n box2.append(-xmax - ymax + xbox[i] + ybox[i])\nprint(max([max(box1)-min(box1),max(box2)-min(box2),max(box3)-min(box3),max(box4)-min(box4)]))\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [260, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u688839540", "n_user": "u688839540", "pos": "n = int(input())\nxy = []\nfor _ in range(n):\n xy.append(list(map(int,input().split())))\na,b=xy[0]\nm1=a+b\np1=xy[0]\nm2=a-b\np2=xy[0]\np3=xy[0]\np4=xy[0]\nm3=-a-b\nm4=-a+b\n\nfor x,y in xy:\n if x+y > m1:\n m1=x+y\n p1 = [x,y]\n if x-y > m2:\n m2=x-y\n p2 = [x,y]\n if -x-y > m3:\n m3 = -x-y\n p3 = [x,y]\n if -x+y > m4:\n m4 = -x+y\n p4 = [x,y]\nm = 0\nfor x0,y0 in [p1,p2,p3,p4]:\n for x1,y1 in [p1,p2,p3,p4]:\n dis=abs(x0-x1) + abs(y0-y1)\n if dis > m:\n m = dis\nprint(m)", "neg": "n = int(input())\nxy = []\nfor _ in range(n):\n xy.append(list(map(int,input().split())))\na,b=xy[0]\nm1=a+b\np1=xy[0]\nm2=a-b\np2=xy[0]\np3=xy[0]\np4=xy[0]\nm3=-a-b\nm4=-a+b\n\nfor x,y in xy:\n if x+y > m1:\n p1 = [x,y]\nif x-y > m2:\n p2 = [x,y]\nif -x-y > m3:\n p3 = [x,y]\nif -x+y > m4:\n p4 = [x,y]\nm = 0\nfor x0,y0 in [p1,p2,p3,p4]:\n for x1,y1 in [p1,p2,p3,p4]:\n dis=abs(x0-x1) + abs(y0-y1)\n if dis > m:\n m = dis\nprint(m)", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [314, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u729133443", "n_user": "u729133443", "pos": "a,*b=[],\nfor z in[*open(0)][1:]:x,y=map(int,z.split());a+=x+y,;b+=x-y,\nprint(max(abs(max(a)-min(a)),abs(max(b)-min(b))))", "neg": "a,b=[],\nfor z in[*open(0)][1:]:x,y=map(int,z.split());a+=x+y,;b+=x-y,\nprint(max(abs(max(a)-min(a)),abs(max(b)-min(b))))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [74, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u495667483", "n_user": "u495667483", "pos": "import sys, math\nfrom functools import lru_cache\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\ndef main():\n N = ii()\n x, y = i2(N)\n\n Mw = max(x[i]+y[i] for i in range(N))\n mw = min(x[i]+y[i] for i in range(N))\n Mz = max(x[i]-y[i] for i in range(N))\n mz = min(x[i]-y[i] for i in range(N))\n\n print(max(Mz-mz, Mw-mw))\n \n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys, math\nfrom functools import lru_cache\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return map(int, input().split())\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\ndef main():\n N = ii()\n x, y = i2(N)\n\n Mw = max(x[i]+y[i] for i in range(N))\n mw = min(x[i]+y[i] for i in range(N))\n Mz = max(abs(a[i]-y[i]) for i in range(N))\n mz = min(abs(x[i]-y[i]) for i in range(N))\n\n print(max(Mz-mz, Mw-mw))\n \n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9661016949152542, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [265, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u119148115", "n_user": "u119148115", "pos": "import sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\n\n\nN = I()\nA,B = [],[] # x+y,x-y \u305f\u3061\u306e\u30ea\u30b9\u30c8\nfor i in range(N):\n x,y = MI()\n A.append(x+y)\n B.append(x-y)\n\nprint(max(max(A)-min(A),max(B)-min(B)))\n", "neg": "import sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef MI(): return map(int,sys.stdin.readline().rstrip().split())\n\n\nN = I()\nA,B = [],[] # x+y,x-y \u305f\u3061\u306e\u30ea\u30b9\u30c8\nfor i in range(N):\n x,y = MI()\n A.append(x+y)\n B.append(x-y)\n\nprint(max(A)-min(A),max(B)-min(B))\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [142, 140], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u594983000", "n_user": "u594983000", "pos": "import sys\ndef input(): return sys.stdin.readline().rstrip()\n\nN = int(input())\nX = []\nY = []\nfor i in range(N):\n x,y = map(int,input().split())\n X.append(x)\n Y.append(y)\n\nans1 = []\nans2 = []\nfor i in range(N):\n ans1.append(X[i] + Y[i])\n ans2.append(Y[i] - X[i])\nans1.sort()\nans2.sort()\n\na = ans1[-1] - ans1[0]\nb = ans2[-1] - ans2[0]\n\nprint(max(a,b))", "neg": "import sys\ndef input(): return sys.stdin.readline().rstrip()\n\nN = int(input())\nX = []\nY = []\nfor i in range(N):\n x,y = map(int,input().split())\n X.append(x)\n Y.append(y)\n\nans1 = []\nans2 = []\nfor i in range(N):\n ans1.append(X[i] + Y[i])\n ans2.append(Y[i] - X[i])\nans1.sort()\nans2.sort()\n\na = ans1[-1] - ans1[1]\nb = ans2[-1] - ans2[1]\n\nprint(max(a,b))", "jacc_sim": 0.975, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [173, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u588794534", "n_user": "u588794534", "pos": "n=int(input())\n\nx=[]\ny=[]\nfor _ in range(n):\n xx,yy=map(int,input().split())\n x.append(xx)\n y.append(yy)\n\ndef maxAbsValExpr(arr1, arr2):\n minX, maxX = min(arr1), max(arr1)\n minY, maxY = min(arr2), max(arr2)\n \n ans = 0\n # For all four corners, calculate the max distance differences\n for point in [(minX, minY), (maxX, minY), (minX, maxY), (maxX, maxY)]:\n minD = float('inf')\n maxD = float('-inf')\n for i in range(0, len(arr1)):\n distance = abs(arr1[i]-point[0]) + abs(arr2[i]-point[1]) \n minD = min(minD, distance)\n maxD = max(maxD, distance)\n ans = max(ans, maxD - minD)\n return ans\n\n\nprint(maxAbsValExpr(x, y))\n", "neg": "n=int(input())\n\nx=[]\ny=[]\nfor _ in range(n):\n xx,yy=map(int,input().split())\n x.append(xx)\n y.append(yy)\n\ndef maxAbsValExpr(arr1, arr2):\n minX, maxX = min(arr1), max(arr1)\n minY, maxY = min(arr2), max(arr2)\n \n ans = 0\n # For all four corners, calculate the max distance differences\n for point in [(minX, minY), (maxX, minY), (minX, maxY), (maxX, maxY)]:\n minD = float('inf')\n maxD = float('-inf')\n for i in range(0, len(arr1)):\n distance = abs(arr1[i]-point[0]) + abs(arr2[i]-point[1]) + i\n minD = min(minD, distance)\n maxD = max(maxD, distance)\n ans = max(ans, maxD - minD)\n return ans\n\n\nprint(maxAbsValExpr(x, y))\n\n", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [270, 273], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u377989038", "n_user": "u700805562", "pos": "n = int(input())\nxy = [list(map(int, input().split())) for _ in range(n)]\n\nf0 = [x - y for x, y in xy]\nf1 = [x + y for x, y in xy]\n\nf0.sort()\nf1.sort()\n\nans = max((f0[-1] - f0[0]), (f1[-1] - f1[0]))\nprint(ans)\n", "neg": "n = int(input())\nxy = [list(map(int, input().split())) for _ in range(n)]\nf0 = sorted([x+y for x, y in xy])\nf1 = sorted([x-y for x, y in xy])\nprint(max(f0[-1]+f1[0], f0[0]+f1[-1]))", "jacc_sim": 0.9032258064516129, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [108, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u509739538", "n_user": "u509739538", "pos": "from collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\nimport math\nimport itertools\n\ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\n\nn = readInt()\ndata = []\nfor i in range(n):\n\tx,y = readInts()\n\tdata.append([x+y,x,y,x-y])\nans = 0\ndata.sort(key=lambda x:x[0])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\ndata.sort(key=lambda x:x[1])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\ndata.sort(key=lambda x:x[2])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\ndata.sort(key=lambda x:x[3])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\nprint(ans)", "neg": "from collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\nimport math\nimport itertools\n\ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\n\nn = readInt()\ndata = []\nfor i in range(n):\n\tx,y = readInts()\n\tdata.append([x+y,x,y])\n\ndata.sort(key=lambda x:x[0])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\ndata.sort(key=lambda x:x[1])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\ndata.sort(key=lambda x:x[2])\nans = max(ans,abs(data[-1][1]-data[0][1])+abs(data[-1][2]-data[0][2]))\nprint(ans)", "jacc_sim": 0.98, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [335, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u239725287", "n_user": "u239725287", "pos": "import sys\n\ndef I(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef main():\n n = I()\n x, y = MI()\n x1 = x\n x2 = x\n x3 = x\n x4 = x\n y1 = y\n y2 = y\n y3 = y\n y4 = y\n for _ in range(n-1):\n x, y = MI()\n if x+y > x1+y1:\n x1 = x\n y1 = y\n if -x+y > -x2+y2:\n x2 = x\n y2 = y\n if -x-y > -x3-y3:\n x3 = x\n y3 = y\n if x-y > x4-y4:\n x4 = x\n y4 = y\n temp = [abs(x1-x2)+abs(y1-y2), abs(x1-x3)+abs(y1-y3), abs(x1-x4)+abs(y1-y4), abs(x2-x3)+abs(y2-y3), abs(x2-x4)+abs(y2-y4), abs(x3-x4)+abs(y3-y4)]\n ans = max(temp)\n print(ans)\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n\ndef I(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef main():\n n = I()\n x, y = MI()\n x1 = x\n x2 = x\n x3 = x\n x4 = x\n y1 = y\n y2 = y\n y3 = y\n y4 = y\n for _ in range(n-1):\n x, y = MI()\n if x+y > x1+y1:\n x1 = x\n y1 = y\n if -x+y > -x2+y2:\n x2 = x\n y2 = y\n if -x-y > -x3-y3:\n x3 = x\n y3 = y\n if x-y > x4-y4:\n x4 = x\n y4 = y\n temp = [abs(x1-x2)+abs(y1-y2), abs(x1-x3)+abs(y1-y3), abs(x1-x4)+abs(y1-y4), abs(x2-x3)+abs(y2-y3), abs(x2-x4)+abs(y2-y4), abs(x3-x4)+abs(y3-y4)]\n ans = max(temp)\n print(ans)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [375, 375], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u993808866", "n_user": "u993808866", "pos": "N = int(input())\nArray1 = []\nArray2 = []\n\nfor i in range(N):\n next_x, next_y = map(int, input().split())\n s = next_x + next_y\n t = next_x - next_y\n Array1.append(s)\n Array2.append(t)\n\nprint(max(max(Array1)-min(Array1),max(Array2)-min(Array2)))", "neg": "N = int(input())\nArray1 = []\nArray2 = []\n\nfor i in range(N):\n next_x, next_y = map(int, input().split())\n s = next_x + next_y\n t = next_x - next_y\n Array1.append(s)\n Array2.append(t)\n\nprint(max(max(Array1)-min(Array2),max(Array2)-min(Array1)))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u594803920", "n_user": "u594803920", "pos": "n = int(input())\nl = []\nll = []\nfor _ in range(n):\n x, y = map(int, input().split())\n l.append((x+y, x, y))\n ll.append((x-y, x, y))\nl.sort()\nll.sort()\nans1 = 0\nans2 = 0\n#print(l)\n#print(ll)\n\ncnt = 0\nwhile True:\n a = l[n-1-cnt]\n b = l[cnt]\n #print(a, b)\n if a[1] >= b[1] and a[2] >= b[2]:\n ans1 = abs(b[0]-a[0])\n #print(ans1, a, b)\n break\n if cnt >= n-1:\n break\n cnt += 1\n\ncnt = 0\nwhile True:\n a = ll[n-1-cnt]\n b = ll[cnt]\n if a[1] >= b[1] and b[2] >= a[2]:\n ans2 = abs(b[0]-a[0])\n #print(ans2, a, b)\n break\n if cnt >= n-1:\n break\n cnt += 1\n\nprint(max(ans1, ans2))\n", "neg": "n = int(input())\nl = []\nll = []\nfor _ in range(n):\n x, y = map(int, input().split())\n l.append((x+y, x, y))\n ll.append((x-y, x, y))\nl.sort()\nll.sort()\nans1 = 0\nans2 = 0\n\ncnt = 0\nwhile True:\n a = l[-cnt]\n b = l[cnt]\n if a[1] >= b[1] and a[2] >= b[2]:\n ans1 = b[0]-a[0]\n break\n if cnt >= n-1:\n break\n cnt += 1\n\ncnt = 0\nwhile True:\n a = l[-cnt]\n b = l[cnt]\n if a[1] >= a[2] and b[2] >= b[1]:\n ans2 = b[0]-a[0]\n break\n if cnt >= n-1:\n break\n cnt += 1\n\nprint(max(ans1, ans2))\n", "jacc_sim": 0.9534883720930233, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [316, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u367319568", "n_user": "u367319568", "pos": "N = int(input())\n\nXmax = -2*10**9\nYmax = -2*10**9\nXmin = 2*10**9\nYmin = 2*10**9\n\n\nfor i in range(N):\n x, y = map(int, input().split())\n if (x + y >= Xmax):\n Xmax = x + y\n if (x + y <= Xmin):\n Xmin = x + y\n if (x - y >= Ymax):\n Ymax = x - y\n if (x - y <= Ymin):\n Ymin = x - y\n\nprint(max(Xmax - Xmin, Ymax - Ymin))", "neg": "N = int(input())\n\nXmax = -2*10**9\nYmax = -2*10**9\nXmin = 2*10**9\nYmin = 2*10**9\n\n\nfor i in range(N):\n x, y = map(int, input().split())\n if (x + y >= Xmax):\n Xmax = x + y\n if (x + y =< Xmin):\n Xmin = x + y\n if (x - y >= Ymax):\n Ymax = x - y\n if (x - y =< Ymin):\n Ymin = x - y\n\nprint(max(Xmax - Xmin, Ymax - Ymin))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [163, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u091051505", "n_user": "u091051505", "pos": "n = int(input())\nx_list = []\ny_list = []\nfor _ in range(n):\n x, y = map(int, input().split())\n x_list.append(x - y)\n y_list.append(x + y)\nx_list.sort()\ny_list.sort()\nans = max(x_list[-1] - x_list[0], y_list[-1] - y_list[0])\nprint(ans)", "neg": "n = int(input())\nx_list = []\ny_list = []\nfor _ in range(n):\n x, y = map(int, input().split())\n x_list.append(x)\n y_list.append(y)\nx_list.sort()\ny_list.sort()\nans = x_list[-1] - x_list[0] + y_list[-1] - y_list[0]\nprint(ans)", "jacc_sim": 0.9666666666666667, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [114, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u822662438", "n_user": "u822662438", "pos": "import numpy as np\n\nn = int(input())\n\nx = []\ny = []\nfor i in range(n):\n l = list(map(int, input().split()))\n x.append(l[0])\n y.append(l[1])\n\nx = np.array(x)\ny = np.array(y)\n\nxy0 = x + y\nxy1 = x - y\n\nprint(max(max(xy0)-min(xy0),max(xy1)-min(xy1)))", "neg": "import numpy as np\n\nn = int(input())\n\nx = []\ny = []\nfor i in range(n):\n l = list(map(int, input().split()))\n x.append(l[0])\n y.append(l[1])\n\nx = np.array(x)\ny = np.array(y)\n\nxy0 = x + y\nxy1 = x - y\nprint(int(max(max(xy0)-min(xy1),max(xy1)-min(xy0))/2))", "jacc_sim": 0.9473684210526315, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [124, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u268554510", "n_user": "u268554510", "pos": "N = int(input())\nxy = [list(map(int,input().split())) for _ in range(N)]\nma = -float('inf')\nmi = float('inf')\nfor x,y in xy:\n ma = max(ma,x-y)\n mi = min(mi,x-y)\nans = ma - mi\n\nma = -float('inf')\nmi = float('inf')\nfor x,y in xy:\n ma = max(ma,x+y)\n mi = min(mi,x+y)\n \nans = max(ans, ma - mi)\nprint(ans)", "neg": "N = int(input())\nxy = [list(map(int,input().split())) for _ in range(N)]\nma = 0\nmi = float('inf')\nfor x,y in xy:\n ma = max(ma,abs(x-y))\n mi = min(mi,abs(x-y))\nans = ma - mi\n\nma = 0\nmi = float('inf')\nfor x,y in xy:\n ma = max(ma,x+y)\n mi = min(mi,x+y)\n\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [147, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u138083942", "n_user": "u138083942", "pos": "\ndef dist(a, b):\n return abs(a[0] - b[0]) + abs(a[1] - b[1])\n\ndef resolve():\n import sys\n input = sys.stdin.readline\n\n n = int(input().rstrip())\n ru = None\n rd = None\n lu = None\n ld = None\n\n for i in range(n):\n row = [int(x) for x in input().rstrip().split(\" \")]\n if i == 0:\n ru = row\n rd = row\n lu = row\n ld = row\n continue\n\n if ru[0] + ru[1] < row[0] + row[1]:\n ru = row\n if rd[0] - rd[1] < row[0] - row[1]:\n rd = row\n if -lu[0] + lu[1] < -row[0] + row[1]:\n lu = row\n if -ld[0] - ld[1] < -row[0] - row[1]:\n ld = row\n\n ans = 0\n points = [ru, rd, lu, ld]\n for i in range(4):\n for j in range(i+1, 4):\n tmp = dist(points[i], points[j])\n if ans < tmp:\n ans = tmp\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n resolve()\n", "neg": "def dist(a, b):\n return abs(a[0] - b[0]) + abs(a[1] - b[1])\n\ndef resolve():\n import sys\n input = sys.stdin.readline\n\n n = int(input().rstrip())\n ru = None\n rd = None\n lu = None\n ld = None\n\n for i in range(n):\n row = [int(x) for x in input().rstrip().split(\" \")]\n if i == 0:\n ru = row\n rd = row\n lu = row\n ld = row\n continue\n\n if ru[0] + ru[1] < row[0] + row[1]:\n ru = row\n if rd[0] - rd[1] < row[0] - row[1]:\n rd = row\n if -lu[0] + lu[1] < -row[0] + row[1]:\n lu = row\n if -ld[0] - ld[1] < -row[0] - row[1]:\n ld = row\n\n ans = 0\n points = [ru, rd, lu, ld]\n for i in range(4):\n for j in range(i+1, 4):\n tmp = dist(points[i], points[j])\n if ans < tmp:\n ans = tmp\n\n print(ans)", "jacc_sim": 0.9607843137254902, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [350, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u995004106", "n_user": "u995004106", "pos": "from math import *\nimport fractions\nimport sys\nimport collections\nimport itertools\nimport pprint\nfrom collections import deque\nfrom heapq import *\nimport copy\nN=int(input())\npoints=[list(map(int,input().split())) for _ in range(N)]\n\n\nchebmax0=-float(\"inf\")\nchebmin0=float(\"inf\")\nchebmax1=-float(\"inf\")\nchebmin1=float(\"inf\")\n\n#chebmax0\u2192x-y\u306emax\nfor l in points:\n chebmax0=max(chebmax0,l[0]-l[1])\nfor l in points:\n chebmin0=min(chebmin0,l[0]-l[1])\nfor l in points:\n chebmax1=max(chebmax1,l[0]+l[1])\nfor l in points:\n chebmin1=min(chebmin1,l[0]+l[1])\n#print(chebmin1,chebmax1,chebmin0,chebmax0)\nprint(max(chebmax0-chebmin0,chebmax1-chebmin1))", "neg": "from math import *\nimport fractions\nimport sys\nimport collections\nimport itertools\nimport pprint\nfrom collections import deque\nfrom heapq import *\nimport copy\nN=int(input())\npoints=[list(map(int,input().split())) for _ in range(N)]\n\n\nchebmax0=-float(\"inf\")\nchebmin0=float(\"inf\")\nchebmax1=-float(\"inf\")\nchebmin1=float(\"inf\")\n\n#chebmax0\u2192x-y\u306emax\nfor l in points:\n chebmax0=max(chebmax0,l[0]-l[1])\nfor l in points:\n chebmin0=min(chebmax0,l[0]-l[1])\nfor l in points:\n chebmax1=max(chebmax1,l[0]+l[1])\nfor l in points:\n chebmin1=min(chebmax1,l[0]+l[1])\n#print(chebmin1,chebmax1,chebmin0,chebmax0)\nprint(max(chebmax0-chebmin0,chebmax1-chebmin1))", "jacc_sim": 1.0, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [284, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u342869120", "n_user": "u921676506", "pos": "N = int(input())\nd = [[], []]\nfor i in range(N):\n x, y = map(int, input().split())\n d[0].append(x-y)\n d[1].append(x+y)\n\nans = 0\nfor i in range(2):\n ans = max(ans, max(d[i])-min(d[i]))\nprint(ans)\n", "neg": "N = int(input())\nx, y = map(int, input().split())\nd = [x - y, x - y, x + y, x + y]\nfor i in range(1,N):\n x, y = map(int, input().split())\n d[0] = max(d[0], x-y)\n d[1] = min(d[1], x-y)\n d[2] = max(d[2], x+y)\n d[3] = min(d[3], x+y)\nprint(d)\nprint(max(d[0]-d[1], d[2]-d[3]))", "jacc_sim": 0.9032258064516129, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [99, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u860829879", "n_user": "u716641520", "pos": "n=int(input())\n\nminx=10**10\nmaxx=-10**10\nminy=10**10\nmaxy=-10**10\n\nfor _ in range(n):\n x,y=map(int,input().split())\n\n maxx=max(maxx,x+y)\n minx=min(minx,x+y)\n maxy=max(maxy,x-y)\n miny=min(miny,x-y)\n\nprint(max(maxx-minx,maxy-miny))", "neg": "n = int(input())\nmaxx, minx, maxy, miny = -1**10, 1**10, -1**10, 1**10\nfor _ in range(n):\n\tx, y = map(int, input().split())\n\tx, y = x+y, x-y\n\tmaxx = max(maxx, x)\n\tminx = min(minx, x)\n\tmaxy = max(maxy, y)\n\tminy = min(miny, y)\nprint(max(maxx - minx, maxy - miny))\n", "jacc_sim": 0.9655172413793104, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [132, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02556", "p_user": "u331327289", "n_user": "u814271993", "pos": "import sys\n\n\ndef f(x, y):\n return x - y, x + y\n\n\ndef main():\n input = sys.stdin.buffer.readline\n n = int(input())\n x = [0] * n\n y = [0] * n\n for i in range(n):\n x[i], y[i] = map(int, input().split())\n f0 = [0] * n\n f1 = [0] * n\n for i in range(n):\n f0[i], f1[i] = f(x[i], y[i])\n print(max(max(f0) - min(f0), max(f1) - min(f1)))\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\ndef f(x,y):\n return x-y.x+y\n\ndef main():\n input = sys.stdin.buffer.readline\n n = int(input())\n x = [0]*n\n y = [0]*n\n for i in range(n):\n x[i],y[i] = map(int,input().split())\n f0 = [0]*n\n f1 = [0]*n\n for i in range(n):\n f0[i],fi[i] = f(x[i],y[i])\n print(max(max(f0)-minf(0),max(f1)-minf(1)))\n\nif __name__ = \"__main__\":\n main()", "jacc_sim": 0.9090909090909091, "nl": "You are given N points on a 2D plane, each located at (x_i, y_i). Find the maximum Manhattan distance between two distinct points. Manhattan distance is defined as |x_i-x_j| + |y_i-y_j|. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 x_i, y_i \u2264 10^9. Input format: N, followed by x and y coordinates for each point. Output the maximum distance. Example input: 3, 1 1, 2 4, 3 2. Example output: 4.", "before_after_length": [191, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u077291787", "n_user": "u077291787", "pos": "class UnionFind:\n __slots__ = [\"_data_size\", \"_roots\"]\n\n def __init__(self, data_size: int) -> None:\n self._data_size = data_size\n self._roots = [-1] * data_size\n\n def __getitem__(self, x: int) -> int:\n while self._roots[x] >= 0:\n x = self._roots[x]\n return x\n\n def is_connected(self, x: int, y: int) -> bool:\n return self[x] == self[y]\n\n def unite(self, x: int, y: int) -> None:\n x, y = self[x], self[y]\n if x == y:\n return\n if self._roots[x] > self._roots[y]:\n x, y = y, x\n self._roots[x] += self._roots[y]\n self._roots[y] = x\n\n\nimport sys\n\nread = sys.stdin.buffer.read\n\nN, Q, *TUV = map(int, read().split())\ntree = UnionFind(N)\nres = []\nfor t, u, v in zip(*[iter(TUV)] * 3):\n if t:\n res.append(int(tree.is_connected(u, v)))\n else:\n tree.unite(u, v)\nprint(\"\\n\".join(map(str, res)))\n", "neg": "class UnionFind:\n __slots__ = [\"_data_size\", \"_roots\"]\n\n def __init__(self, data_size: int) -> None:\n self._data_size = data_size\n self._roots = [-1] * data_size\n\n def __getitem__(self, x: int) -> int:\n while self._roots[x] >= 0:\n x = self._roots[x]\n return x\n\n def is_connected(self, x: int, y: int) -> bool:\n return self[x] == self[y]\n\n def unite(self, x: int, y: int) -> None:\n x, y = self[x], self[y]\n if x == y:\n return\n if self._roots[x] > self._roots[y]:\n x, y = y, x\n self._roots[x] += self._roots[y]\n self._roots[y] = x\n\n\nimport sys\n\nread = sys.stdin.read\n\nN, _, *X = map(int, readline().split())\ntree = UnionFind(N)\nres = []\nfor t, u, v in zip(*[iter(X)] * 3):\n if t:\n res.append(int(tree.is_connected(u, v)))\n else:\n tree.unite(u, v)\nprint(\"\\n\".join(map(str, res)))\n", "jacc_sim": 0.9090909090909091, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [349, 345], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u201234972", "n_user": "u201234972", "pos": "import sys\ninput = sys.stdin.readline\ndef find(A,x):\n p = A[x]\n if p == x:\n return x\n a = find(A,p)\n A[x] = a\n return a\n \ndef union(A, x, y):\n# bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)\u3060\u3068\u7121\u9650\u30eb\u30fc\u30d7\u3002\n if find(A,x) > find(A,y):\n bx, by = find(A,y), find(A,x)\n else:\n bx, by = find(A,x), find(A,y)\n A[y] = bx\n A[by] = bx\n\ndef main():\n N, Q = map( int, input().split())\n TUV = [ tuple( map( int, input().split())) for _ in range(Q)]\n G = [ i for i in range(N)]\n ANS = []\n for t, u, v in TUV:\n if t == 0:\n union(G,u,v)\n else:\n if find(G,u) == find(G,v):\n ANS.append(1)\n else:\n ANS.append(0)\n print(\"\\n\".join( map( str, ANS)))\n \nif __name__ == '__main__':\n main()\n", "neg": "import sys\ninput = sys.stdin.readline\ndef find(A,x):\n p = A[x]\n if p == x:\n return x\n a = find(A,p)\n A[x] = a\n return a\n \ndef union(A, x, y):\n# bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)\u3060\u3068\u7121\u9650\u30eb\u30fc\u30d7\u3002\n if find(A,x) > find(A,y):\n bx, by = find(A,y), find(A,x)\n else:\n bx, by = find(A,x), find(A,y)\n A[y] = bx\n A[by] = bx\n\ndef main():\n N, Q = map( int, input().split())\n TUV = [ tuple( map( int, input().split())) for _ in range(Q)]\n G = [ i for i in range(N)]\n ANS = []\n for t, u, v in TUV:\n if t == 0:\n union(T,u,v)\n else:\n if find(T,u) == find(T,v):\n ANS.append(1)\n else:\n ANS.append(0)\n print(\"\\n\".join( map( str, ANS)))\n \nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9850746268656716, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [372, 372], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u089230684", "n_user": "u970855438", "pos": "def find(u, find_root):\n find_root[u] = u if u == find_root[u] else find(find_root[u], find_root)\n return find_root[u]\n\ndef main():\n n, q = map(int, input().split())\n find_root = list(range(n))\n for i in range(q):\n t, u, v = map(int, input().split())\n u_root, v_root = find(u, find_root), find(v, find_root)\n if t:\n print(1 if u_root == v_root else 0)\n else:\n find_root[u_root] = v_root\n\nif __name__ == \"__main__\":\n main()", "neg": "def find(u, tree_root):\n tree_root[u] = u if u == tree_root[u] else find(tree_root[u], tree_root)\n return tree_root[u]\n\ndef main():\n n, q = map(int, input().split())\n tree_root = list(range(n))\n for i in range(q):\n t, u, v = map(int, input().split())\n u_root, v_root = find(u, tree_root), find(v, tree_root)\n if t:\n print(1 if u_root == v_root else 0)\n else:\n tree_root[u] = v_root\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9473684210526315, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [186, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u533039576", "n_user": "u533039576", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\n\n\nclass UnionFind():\n def __init__(self, n):\n self.par = [-1] * n\n\n def root(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.root(self.par[x]) # contraction\n return self.par[x]\n\n def unite(self, x, y):\n x, y = self.root(x), self.root(y)\n if x != y:\n if self.par[x] > self.par[y]: # merge technique\n x, y = y, x\n self.par[x] += self.par[y]\n self.par[y] = x\n\n def same(self, x, y):\n return self.root(x) == self.root(y)\n\n def size(self, x):\n return -self.par[self.root(x)]\n\n\nn, q = map(int, input().split())\nuf = UnionFind(n)\nfor _ in range(q):\n t, u, v = map(int, input().split())\n if t == 0:\n # add\n uf.unite(u, v)\n else:\n print(1 if uf.same(u, v) else 0)\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\n\n\nclass UnionFind():\n def __init__(self, n):\n self.par = [-1] * n\n\n def root(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.root(self.par[x]) # contraction\n return self.par[x]\n\n def unite(self, x, y):\n x, y = self.root(x), self.root(y)\n if x != y:\n if self.par[x] > self.par[y]: # merge technique\n x, y = y, x\n self.par[x] += self.par[y]\n self.par[y] = x\n\n def same(self, x, y):\n return self.root(x) == self.root(y)\n\n def size(self, x):\n return -self.par[self.root(x)]\n\n\nn, q = map(int, input().split())\nuf = UnionFind(n)\nfor _ in range(q):\n t, u, v = map(int, input().split())\n u -= 1\n v -= 1\n if t == 0:\n # add\n uf.unite(u, v)\n else:\n print(1 if uf.same(u, v) else 0)\n", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [351, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u102655885", "n_user": "u102655885", "pos": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n \n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n \n if x == y:\n return\n \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \n def size(self, x):\n return -self.parents[self.find(x)]\n \n def same(self, x, y):\n return self.find(x) == self.find(y)\n \n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n \n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n \n def group_count(self):\n return len(self.roots())\n \n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n \n \nn, q = list(map(lambda x: int(x), input().split()))\nuf = UnionFind(n)\nfor _ in range(q):\n t, u, v = list(map(lambda x: int(x), input().split()))\n# print(uf.parent_indexes)\n if t == 0:\n uf.union(u, v)\n continue\n print('1') if uf.same(u, v) else print('0')", "neg": "\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n \nn, q = list(map(lambda x: int(x), input().split()))\nuf = UnionFind(n)\nfor _ in range(q):\n t, u, v = list(map(lambda x: int(x), input().split()))\n# print(uf.parent_indexes)\n if t == 0:\n uf.union(u, v)\n continue\n print('1') if uf.are_in_the_same_group(u, v) else print('0')", "jacc_sim": 0.984375, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [478, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u279493135", "n_user": "u279493135", "pos": "import networkx as nx\ndef MAP(): return map(int, input().split())\nn,q=MAP()\ng=nx.utils.UnionFind(range(n))\nfor _ in range(q):\n t,u,v=MAP()\n if t==0:g.union(u,v)\n else:print(1 if g[u]==g[v] else 0)", "neg": "import networkx as nx\ndef MAP(): return map(int, input().split())\nn,q=MAP()\ng=nx.utils.UnionFind(range(n))\nfor _ in range(q):\n t,u,v=MAP()\n if t==0:g.union(u,v)\n else:print(1 if g[u]==g[v] else 0", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [92, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u729133443", "n_user": "u729133443", "pos": "p=[-1]*8**6\nfor q in[*open(0)][1:]:\n q,*x=map(int,q.split());a,b=sorted(map(f:=lambda x:f(p[x])if~p[x]<0else x,x))\n if q:print(+(a==b))\n elif a int:\n if root[x] < 0:\n return x\n else:\n while root[x] >= 0:\n x = root[x]\n return x\n\n def union(x: int, y: int):\n x = find(x)\n y = find(y)\n if x == y:\n return\n elif rank[x] > rank[y]:\n root[x] += root[y]\n root[y] = x\n else:\n root[y] += root[x]\n root[x] = y\n if rank[x] == rank[y]:\n rank[y] += 1\n\n for _ in range(q):\n t, u, v = map(int, input().split())\n if t:\n print(int(find(u) == find(v)))\n else:\n union(u, v)\n\n\nsolve()\n", "neg": "import sys\ninput = sys.stdin.readline\nN, q = map(int, input().split())\nroot = [-1] * N\nrank = [0] * N\n\n\ndef find(x: int) -> int:\n if root[x] < 0:\n return x\n else:\n while root[x] >= 0:\n x = root[x]\n return x\n\n\ndef union(x: int, y: int) -> int:\n y = find(y)\n if x == y:\n return\n elif rank[x] > rank[y]:\n root[x] += root[y]\n root[y] = x\n else:\n root[y] += root[x]\n root[x] = y\n if rank[x] == rank[y]:\n rank[y] += 1\n\n\n\nfor i in range(q):\n t, u, v = map(int, input().split())\n if t:\n print(int(find(u) == find(v)))\n else:\n union(u, v)\n", "jacc_sim": 0.9361702127659575, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [280, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u700805562", "n_user": "u700805562", "pos": "class UnionFind:\n def __init__(self, size):\n self.par = [-1] * size\n \n def find(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n def unite(self, x, y):\n x, y = self.find(x), self.find(y)\n if x == y: return False\n if self.par[x] > self.par[y]:\n x, y = y, x\n self.par[x] += self.par[y]\n self.par[y] = x\n return True\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n \n def size(self, x):\n return -self.par[self.find(x)]\n\nN, Q = map(int, input().split())\nuf = UnionFind(N)\nfor _ in range(Q):\n t, u, v = map(int, input().split())\n if t == 0:\n uf.unite(u, v)\n else:\n if uf.same(u, v):\n print(1)\n else:\n print(0)", "neg": "class UnionFind:\n def __init__(self, size):\n self.par = [-1] * size\n \n def find(self, x):\n if self.par[x] < 0:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n def unite(self, x, y):\n x, y = self.find(x), self.find(y)\n if x == y: return False\n if self.par[x] > self.par[y]:\n x, y = y, x\n self.par[x] += self.par[y]\n self.par[y] = x\n return True\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n \n def size(self, x):\n return -self.par[self.find(x)]\n\nN, Q = map(int, input().split())\nuf = Unionfind(N)\nfor _ in range(Q):\n t, u, v = map(int, input().split())\n if t == 0:\n uf.unite(u, v)\n else:\n if uf.same(u, v):\n print(1)\n else:\n print(0)", "jacc_sim": 0.9795918367346939, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [329, 329], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u284854859", "n_user": "u284854859", "pos": "#Union Find\n\n#x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n tank = []\n while par[x] >= 0:\n tank.append(x)\n x = par[x]\n for elt in tank:\n par[elt] = x\n return x\n#x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x == y:\n return False\n else:\n #size\u306e\u5927\u304d\u3044\u307b\u3046\u304cx\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\n#x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u306e\u5224\u5b9a\ndef same(x,y):\n return find(x) == find(y)\n\n#x\u304c\u5c5e\u3059\u308b\u96c6\u5408\u306e\u500b\u6570\ndef size(x):\n return -par[find(x)]\n\n\nimport sys\ninput = sys.stdin.readline\n\nn,q = map(int,input().split())\n\n#\u521d\u671f\u5316\n#\u6839\u306a\u3089-size,\u5b50\u306a\u3089\u89aa\u306e\u9802\u70b9\npar = [-1]*n\n\nfor i in range(q):\n t,u,v = map(int,input().split())\n if t == 0:\n unite(u,v)\n elif same(u,v):\n print(1)\n else:\n print(0)", "neg": "#Union Find\n\n#x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n tank = []\n while par[x] >= 0:\n tank.append(x)\n x = par[x]\n for elt in tank:\n par[elt] = x\n return x\n#x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x == y:\n return False\n else:\n #size\u306e\u5927\u304d\u3044\u307b\u3046\u304cx\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\n#x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u306e\u5224\u5b9a\ndef same(x,y):\n return find(x) == find(y)\n\n#x\u304c\u5c5e\u3059\u308b\u96c6\u5408\u306e\u500b\u6570\ndef size(x):\n return -par[find(x)]\n\n\nimport sys\ninput = sys.stdin.readline\n\nn,q = map(int,input().split())\n\n#\u521d\u671f\u5316\n#\u6839\u306a\u3089-size,\u5b50\u306a\u3089\u89aa\u306e\u9802\u70b9\npar = [-1]*n\n\nfor i in range(q):\n t,u,v = map(int,input().split())\n if t == 0:\n unite(u,v)\n elif same(x,y):\n print(1)\n else:\n print(0)", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [510, 510], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u751843916", "n_user": "u751843916", "pos": "from networkx.utils.union_find import UnionFind\nn,q=map(int,input().split())\na=[[int(i) for i in input().split()] for _ in range(q)]\n\nuf=UnionFind()\nfor i in range(n):\n uf.union(i,i)\nfor x in a:\n if x[0]==0:\n uf.union(x[1],x[2])\n else:\n f=x[1]\n while True:\n if f==uf.parents[f]:break\n f=uf.parents[f]\n b=x[2]\n while True:\n if b==uf.parents[b]:break\n b=uf.parents[b]\n print(1 if f==b else 0)", "neg": "from networkx.utils.union_find import UnionFind\nn,q=map(int,input().split())\na=[[int(i) for i in input().split()] for _ in range(q)]\n\nuf=UnionFind()\nfor i in range(n):\n uf.union(i,i)\nfor x in a:\n if x[0]==0:\n uf.union(x[1],x[2])\n else:\n f=x[1]\n while True:\n if f==uf.parents[f]:break\n f=uf.parents[f]\n b=x[2]\n while True:\n if b==uf.parents[b]:break\n b=uf.parents[b]\n print(0 if f==b else 1)", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [191, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02558", "p_user": "u785989355", "n_user": "u785989355", "pos": "class UnionFind():\n def __init__(self,size):\n self.table = [-1 for _ in range(size)]\n self.member_num = [1 for _ in range(size)]\n \n #representative\n def find(self,x):\n while self.table[x] >= 0:\n x = self.table[x]\n return x\n\n def union(self,x,y):\n s1 = self.find(x)\n s2 = self.find(y)\n m1=self.member_num[s1]\n m2=self.member_num[s2]\n if s1 != s2:\n if m1 != m2:\n if m1 < m2:\n self.table[s1] = s2\n self.member_num[s2]=m1+m2\n return [m1,m2]\n else:\n self.table[s2] = s1\n self.member_num[s1]=m1+m2\n return [m1,m2]\n else:\n self.table[s1] = -1\n self.table[s2] = s1\n self.member_num[s1] = m1+m2\n return [m1,m2]\n return [0,0]\n\nN,Q = list(map(int,input().split()))\n\nuf = UnionFind(N)\n\nfor i in range(Q):\n t,u,v = list(map(int,input().split()))\n \n if t==0:\n uf.union(u,v)\n else:\n if uf.find(u)==uf.find(v):\n print(1)\n else:\n print(0)", "neg": "class UnionFind():\n def __init__(self,size):\n self.table = [-1 for _ in range(size)]\n self.member_num = [1 for _ in range(size)]\n \n #representative\n def find(self,x):\n while self.table[x] >= 0:\n x = self.table[x]\n return x\n\n def union(self,x,y):\n s1 = self.find(x)\n s2 = self.find(y)\n m1=self.member_num[s1]\n m2=self.member_num[s2]\n if s1 != s2:\n if m1 != m2:\n if m1 < m2:\n self.table[s1] = s2\n self.member_num[s2]=m1+m2\n return [m1,m2]\n else:\n self.table[s2] = s1\n self.member_num[s1]=m1+m2\n return [m1,m2]\n else:\n self.table[s1] = -1\n self.table[s2] = s1\n self.member_num[s1] = m1+m2\n return [m1,m2]\n return [0,0]\n\nN,Q = list(map(int,input().split()))\n\nuf = UnionFind(N)\n\nfor i in range(Q):\n t,u,v = list(map(int,input().split()))\n if t==0:\n uf.union(u-1,v-1)\n else:\n if uf.find(u-1)==uf.find(v-1):\n print(1)\n else:\n print(0)", "jacc_sim": 1.0, "nl": "You are given an undirected graph with N vertices and 0 edges. Process Q queries of the following types:\n- \"0 u v\": Add an edge (u, v).\n- \"1 u v\": Print 1 if u and v are in the same connected component, 0 otherwise.\n\nConstraints:\n- 1 \u2264 N \u2264 200,000\n- 1 \u2264 Q \u2264 200,000\n- 0 \u2264 u_i, v_i < N\n\nInput:\nInput is given from Standard Input in the following format:\nN Q\nt_1 u_1 v_1\nt_2 u_2 v_2\n...\nt_Q u_Q v_Q\n\nOutput:\nFor each query of the latter type, print the answer.\n\nSample Input 1:\n4 7\n1 0 1\n0 0 1\n0 2 3\n1 0 1\n1 1 2\n0 0 2\n1 1 3\n\nSample Output 1:\n0\n1\n0\n1", "before_after_length": [434, 440], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u730769327", "n_user": "u730769327", "pos": "class binaryindexedtree():\n def __init__(self,n):\n self.n=n\n self.tree=[0]*n\n def add(self,a,w):\n x=a\n while x<=self.n:\n self.tree[x-1]+=w\n x+=x&(-x)\n def sums(self,a):\n x=a\n S=0\n while x!=0:\n S+=self.tree[x-1]\n x-=x&(-x)\n return S\nn,q=map(int,input().split())\na=list(map(int,input().split()))\nbit=binaryindexedtree(n)\nfor i,x in enumerate(a,1):\n bit.add(i,x)\nans=[]\nfor _ in range(q):\n x,y,z=map(int,input().split())\n if x:ans+=[bit.sums(z)-bit.sums(y)]\n else:bit.add(y+1,z)\nprint(*ans,sep='\\n')", "neg": "class binaryindexedtree():\n def __init__(self,n):\n self.n=n\n self.tree=[0]*n\n def add(self,a,w):\n x=a\n while x<=self.n:\n self.tree[x-1]+=w\n x+=x&(-x)\n def sums(self,a):\n x=a\n S=0\n while x!=0:\n S+=self.tree[x-1]\n x-=x&(-x)\n return S\nn,q=map(int,input().split())\na=list(map(int,input().split()))\nbit=binaryindexedtree(n)\nfor i,x in enumerate(a,1):\n bit.add(i,x)\nans=[]\nfor _ in range(q):\n x,y,z=map(int,input().split())\n if x:ans+=[bit.sums(z)-bit.sums(y)]\n else:bit.add(y,z)\nprint(*ans,sep='\\n')", "jacc_sim": 1.0, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [266, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u089230684", "n_user": "u350248178", "pos": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nsize=2*n+1\nbit=[0]*size\ndef bit_update(x,v):\n while x0:\n s+=bit[x]\n x-=(x&-x)\n return s\nfor i,j in enumerate(a,1):\n bit_update(i,j)\nfor i in range(q):\n a,b,c=map(int,input().split())\n if a==0:\n bit_update(b+1,c)\n else:\n print(bit_sum(c)-bit_sum(b))", "neg": "n,q=map(int,input().split())\na=list(map(int,input().split()))\nbit=[0]*(2*n+10)\ndef bit_update(x,v):\n while x0:\n s+=bit[x]\n x-=(x&-x)\n return s\nfor i,j in enumerate(a,1):\n bit_update(i,j)\nfor i in range(q):\n a,b,c=map(int,input().split())\n if a==0:\n bit_update(b+1,c)\n else:\n print(bit_sum(c)-bit_sum(b))", "jacc_sim": 0.9787234042553191, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [217, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u203843959", "n_user": "u203843959", "pos": "N,Q=map(int,input().split())\nalist=list(map(int,input().split()))\n\n#A1\uff5eAi\u307e\u3067\u306e\u548c O(logN)\ndef BIT_query(idx):\n res_sum = 0\n while idx > 0:\n res_sum += BIT[idx]\n idx -= idx&(-idx)\n return res_sum\n#Ai += x O(logN)\ndef BIT_update(idx,x):\n while idx <= N:\n BIT[idx] += x\n idx += idx&(-idx)\n return\n\nBIT=[0]*(N+1)\nfor i in range(N):\n BIT_update(i+1,alist[i])\n\nfor _ in range(Q):\n q1,q2,q3=map(int,input().split())\n if q1==0:\n BIT_update(q2+1,q3)\n else:\n print(BIT_query(q3)-BIT_query(q2))", "neg": "N,Q=map(int,input().split())\nalist=list(map(int,input().split()))\n\n#A1\uff5eAi\u307e\u3067\u306e\u548c O(logN)\ndef BIT_query(idx):\n res_sum = 0\n while idx > 0:\n res_sum += BIT[idx]\n idx -= idx&(-idx)\n return res_sum\n#Ai += x O(logN)\ndef BIT_update(idx,x):\n while idx <= N:\n BIT[idx] += x\n idx += idx&(-idx)\n return\n\nBIT=[0]*(N+1)\nfor i in range(N):\n BIT_update(i+1,alist[i])\n\nfor _ in range(Q):\n q1,q2,q3=map(int,input().split())\n if q1==0:\n BIT_update(q2,q3)\n else:\n print(BIT_query(q3)-BIT_query(q2))", "jacc_sim": 1.0, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [255, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u597455618", "n_user": "u597455618", "pos": "import sys\nimport numpy as np\n\n\nclass Bit:\n def __init__(self, n, arr):\n self.size = n\n self.tree = np.array([0] + arr)\n for i in range(1, n+1):\n if i + (i & -i) < n + 1:\n self.tree[i + (i & -i)] += self.tree[i]\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n def range_sum(self, l, r):\n return self.sum(r) - self.sum(l)\n\n\ndef main():\n n, q = map(int, sys.stdin.buffer.readline().split())\n bit = Bit(n, list(map(int, sys.stdin.buffer.readline().split())))\n for x in sys.stdin.buffer.readlines():\n q, p, x = map(int, x.split())\n if q:\n print(bit.range_sum(p, x))\n else:\n bit.add(p+1, x)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\n\nclass Bit:\n def __init__(self, n, arr):\n self.size = n\n self.tree = [0] + arr\n for i in range(1, n+1):\n if i + (i & -i) < n+1:\n self.tree[i + (i & -i)] += self.tree[i]\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n def range_sum(self, l, r):\n return self.sum(r) - self.sum(l)\n\n\ndef main():\n n, q = map(int, sys.stdin.buffer.readline().split())\n bit = Bit(n)\n bit.build(map(int, sys.stdin.buffer.readline().split()))\n for x in sys.stdin.buffer.readlines():\n q, p, x = map(int, x.split())\n if q:\n print(bit.range_sum(p, x))\n else:\n bit.add(p+1, x)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9032258064516129, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [346, 341], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u597455618", "n_user": "u597455618", "pos": "import sys\n\n\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i ^= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n\ndef main():\n n, q = map(int, sys.stdin.buffer.readline().split())\n bit = Bit(n)\n a = list(map(int, sys.stdin.buffer.readline().split()))\n for i in range(n):\n bit.add(i+1, a[i])\n for x in sys.stdin.buffer.readlines():\n q, p, x = map(int, x.split())\n if q:\n print(bit.sum(x) - bit.sum(p))\n else:\n bit.add(p+1, x)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\n\nclass Bit:\n def __init__(self, n):\n self.size = n\n self.tree = [0] * (n + 1)\n\n def sum(self, i):\n s = 0\n while i > 0:\n s += self.tree[i]\n i -= i & -i\n return s\n\n def add(self, i, x):\n while i <= self.size:\n self.tree[i] += x\n i += i & -i\n\n\ndef main():\n # \u4f7f\u7528\u4f8b\n n, q = map(int, sys.stdin.buffer.readline().split())\n bit = Bit(n+1)\n a = list(map(int, sys.stdin.buffer.readline().split()))\n for i in range(1, n+1):\n bit.add(i, a[i])\n print(bit.tree)\n for x in sys.stdin.buffer.readlines():\n q, p, x = map(int, x.split())\n if q:\n print(bit.sum(x) - bit.sum(p))\n else:\n bit.add(p, x)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9166666666666666, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [289, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u261103969", "n_user": "u261103969", "pos": "import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\nclass BinaryIndexTree:\n def __init__(self, n):\n self.size = n\n self._container = [0] * (n + 1)\n self.depth = n.bit_length()\n\n def sum(self, i):\n if i == 0:\n return 0\n s = 0\n while i > 0:\n s += self._container[i]\n i -= i & (-i)\n return s\n\n def add(self, i, x):\n if i == 0:\n return\n while i <= self.size:\n self._container[i] += x\n i += i & (-i)\n\n def lower_bound(self, x):\n if x == 0:\n return 0\n\n s = 0\n idx = 0\n for i in range(self.depth, -1, -1):\n k = idx + (1 << i)\n if k <= self.size and s + self._container[k] < x:\n s += self._container[k]\n idx += 1 << i\n return idx + 1\n\n def __repr__(self):\n return str(self._container)\n\n\ndef main():\n N, Q = map(int, readline().split())\n a = list(map(int, readline().split()))\n bit = BinaryIndexTree(N + 1)\n\n for i, x in enumerate(a, 1):\n bit.add(i, x)\n\n for _ in range(Q):\n a, b, c = map(int, readline().split())\n if a == 0:\n b += 1\n bit.add(b, c)\n else:\n b += 1\n c += 1\n print(bit.sum(c - 1) - bit.sum(b - 1))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\n\nreadline = sys.stdin.readline\nMOD = 10 ** 9 + 7\nINF = float('INF')\nsys.setrecursionlimit(10 ** 5)\n\n\nclass BinaryIndexTree:\n def __init__(self, n):\n self.size = n\n self._container = [0] * (n + 1)\n self.depth = n.bit_length()\n\n def sum(self, i):\n if i == 0:\n return 0\n s = 0\n while i > 0:\n s += self._container[i]\n i -= i & (-i)\n return s\n\n def add(self, i, x):\n if i == 0:\n return\n while i <= self.size:\n self._container[i] += x\n i += i & (-i)\n\n def lower_bound(self, x):\n if x == 0:\n return 0\n\n s = 0\n idx = 0\n for i in range(self.depth, -1, -1):\n k = idx + (1 << i)\n if k <= self.size and s + self._container[k] < x:\n s += self._container[k]\n idx += 1 << i\n return idx + 1\n\n def __repr__(self):\n return str(self._container)\n\n\ndef main():\n N, Q = map(int, readline().split())\n a = list(map(int, readline().split()))\n bit = BinaryIndexTree(N + 1)\n\n for i, x in enumerate(a, 1):\n bit.add(i, x)\n\n for _ in range(Q):\n a, b, c = map(int, readline().split())\n if a == 0:\n bit.add(b, c)\n else:\n b += 1\n c += 1\n print(bit.sum(c - 1) - bit.sum(b - 1))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [493, 488], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02559", "p_user": "u864197622", "n_user": "u864197622", "pos": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nNN = 19\nBIT = [0] * (2 ** NN + 1)\n\ndef addbit(i, x=1):\n i += 1\n while i <= 2**NN:\n BIT[i] += x\n i += i & (-i)\n\ndef getsum(i):\n ret = 0\n while i != 0:\n ret += BIT[i]\n i -= i&(-i)\n return ret\n\nN, Q = map(int, input().split())\nA = [int(a) for a in input().split()]\nfor i, a in enumerate(A):\n addbit(i, a)\n\nfor _ in range(Q):\n a, b, c = map(int, input().split())\n if a == 0:\n addbit(b, c)\n else:\n print(getsum(c) - getsum(b))\n\n", "neg": "import sys\ninput = lambda: sys.stdin.readline().rstrip()\nNN = 19\nBIT = [0] * (2 ** NN + 1)\n\ndef addbit(i, x=1):\n while i <= 2**NN:\n BIT[i] += x\n i += i & (-i)\n\ndef getsum(i):\n ret = 0\n while i != 0:\n ret += BIT[i]\n i -= i&(-i)\n return ret\n\nN, Q = map(int, input().split())\nA = [int(a) for a in input().split()]\nfor i, a in enumerate(A):\n addbit(i+1, a)\n\nfor _ in range(Q):\n a, b, c = map(int, input().split())\n if a == 0:\n addbit(b, c)\n else:\n print(getsum(c) - getsum(b))", "jacc_sim": 1.0, "nl": "You have an array of length N and need to process Q queries. The queries can either update a value in the array or calculate the sum of a range within the array. Constraints include the size of the array, the range of values, and the query indices. The input format includes N, Q, the array values, and the queries. The output should display the result of each query. For example, given an array [1, 2, 3, 4, 5] and the queries [1 0 5], [1 2 4], [0 3 10], [1 0 5], [1 0 3], the expected output is 15, 7, 25, 6.", "before_after_length": [230, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u327466606", "n_user": "u327466606", "pos": "def floor_linear_sum(n,m,a,b):\n \"\"\"\n returns sum((a*i+b)//m for i in range(n))\n \"\"\"\n res = 0\n while True:\n if a >= m:\n res += (n-1)*n*(a//m)//2\n a %= m\n if b >= m:\n res += n * (b//m)\n b %= m\n\n y_max = (a*n+b)//m\n if y_max == 0:\n return res\n nx_max = b - y_max*m\n res += (n + nx_max//a)*y_max\n n,m,a,b = y_max, a, m, nx_max%a\n\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nT = int(readline())\nm = map(int,read().split())\nfor t in zip(m,m,m,m):\n print(floor_linear_sum(*t))\n", "neg": "def floor_linear_sum(n,m,a,b):\n \"\"\"\n returns sum((a*i+b)//m for i in range(n))\n \"\"\"\n res = 0\n while True:\n if a >= m:\n res += (n-1)*n*(a//m)//2\n a %= m\n if b >= m:\n res += n * (b//m)\n b %= m\n\n y_max = (a*n+b)//m\n if y_max == 0:\n return res\n nx_max = b - y_max*m\n res += (n + nx_max//a)*y_max\n n,m,a,b = y_max, a, m, nx_max%a\n\nimport sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\n\nT = readline()\nm = map(int,read().split())\nfor t in zip(m,m,m,m):\n print(solve(*t))", "jacc_sim": 0.9795918367346939, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [258, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u367701763", "n_user": "u367701763", "pos": "# \u4e00\u756a\u65e9\u3044\u306e\u3092\u5199\u7d4c\u3057\u305f\u3082\u306e\u3092\u5f04\u3063\u3066\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u52c9\u5f37\u306e\u305f\u3081\u306e\u8a66\u3057\u6253\u3061\u4e2d\n\ndef floor_sum(n, m, a, b):\n res = 0\n if b >= m:\n res += n * (b // m)\n b %= m\n while True:\n if a >= m:\n res += (n - 1) * n * (a // m) // 2\n a %= m\n y_max = (a * n + b) // m\n if y_max == 0: break\n x_max = b - y_max * m\n res += (n + x_max // a) * y_max\n n, m, a, b = y_max, a, m, x_max % a\n return res\n\n\nimport sys\ninput = sys.stdin.buffer.readline\n\nT = int(input())\nres = [''] * T\n\nfor i in range(T):\n n, m, a, b = map(int, input().split())\n res[i] = str(floor_sum(n, m, a, b))\n\nprint('\\n'.join(res))\n", "neg": "# \u4e00\u756a\u65e9\u3044\u306e\u3092\u5199\u7d4c\u3057\u305f\u3082\u306e\u3092\u5f04\u3063\u3066\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u52c9\u5f37\u306e\u305f\u3081\u306e\u8a66\u3057\u6253\u3061\u4e2d\n\ndef floor_sum(n, m, a, b):\n res = 0\n if b >= m:\n res += n * (b // m)\n b %= m\n while True:\n if a >= m:\n res += (n - 1) * n * (a // m) // 2\n a %= m\n y_max = a*n//m\n if y_max == 0: break\n x_max = -y_max*m\n res += (n + x_max // a) * y_max\n n, m, a, b = y_max, a, m, x_max % a\n return res\n\n\nimport sys\ninput = sys.stdin.buffer.readline\n\nT = int(input())\nres = [''] * T\n\nfor i in range(T):\n n, m, a, b = map(int, input().split())\n res[i] = str(floor_sum(n, m, a, b))\n\nprint('\\n'.join(res))", "jacc_sim": 1.0, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [354, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\ndef floor_sum(n,m,a,b):\n res = 0\n while True:\n res += ((n-1)*n*(a//m)>>1) + (b//m)*n\n a %= m\n b %= m\n if a*n+b <= m:\n return res\n Y = (a*n+b)//m\n n,m,a,b = Y,a,m, a*n + b - m*Y\n\nimport sys\ninput = sys.stdin.buffer.readline\nT = int(input())\nfor _ in range(T):\n n,m,a,b = map(int,input().split())\n print(floor_sum(n,m,a,b))\n", "neg": "# coding: utf-8\n# Your code here!\n\ndef floor_sum(n,m,a,b):\n res = 0\n while True:\n res += ((n-1)*n*(a//m)>>1) + (b//m)*n\n a %= m\n b %= m\n if a*n+b <= m:\n return res\n n,m,a,b = (a*n+b)//m,a,m,(a*n+b)%m\n\nimport sys\ninput = sys.stdin.buffer.readline\nT = int(input())\nfor _ in range(T):\n n,m,a,b = map(int,input().split())\n print(floor_sum(n,m,a,b))\n\nif T==5: print(1)", "jacc_sim": 0.9607843137254902, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [191, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u034128150", "n_user": "u034128150", "pos": "# \u5199\u7d4c\u3057\u307e\u3057\u305f\u304c\u3001\u4f55\u3082\u308f\u304b\u3063\u3066\u3044\u307e\u305b\u3093\u3002\n\ndef floor_sum(n, m, a, b):\n \"Return sum( floor( (A * i + B) / M ) for i in range(N) )\"\n ret = 0\n while True:\n if a >= m:\n ret += ((n - 1) * n) // 2 * (a // m)\n a %= m\n if b >= m:\n ret += n * (b // m)\n b %= m\n y_max = (a * n + b) // m\n x_max = y_max * m - b\n if y_max == 0:\n return ret\n ret += (n - (x_max + a - 1) // a) * y_max\n n, m, a, b = y_max, a, m, -x_max % a\n \n return ret\n\ndef main():\n import sys\n input = sys.stdin.buffer.readline\n\n ans = []\n T = int(input())\n for _ in range(T):\n N, M, A, B = map(int, input().split())\n ans.append(floor_sum(N, M, A, B))\n\n print('\\n'.join(map(str, ans)))\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# \u5199\u7d4c\u3057\u307e\u3057\u305f\u304c\u3001\u4f55\u3082\u308f\u304b\u3063\u3066\u3044\u307e\u305b\u3093\u3002\n\ndef floor_sum(n, m, a, b):\n \"Return sum( floor( (A * i + B) / M ) for i in range(N) )\"\n ret = 0\n while True:\n if a >= m:\n ret += ((n - 1) * n * a) // (2 * m)\n a %= m\n if b >= m:\n ret += n * (b // m)\n b %= m\n y_max = (a * n + b) // m\n if y_max == 0:\n return ret\n x_max = y_max * m - b\n ret += (n - (x_max + a - 1) // a) * y_max\n n, m, a, b = y_max, a, m, -x_max % a\n\ndef main():\n import sys\n input = sys.stdin.buffer.readline\n\n ans = []\n T = int(input())\n for _ in range(T):\n N, M, A, B = map(int, input().split())\n ans.append(floor_sum(N, M, A, B))\n\n print('\\n'.join(map(str, ans)))\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [372, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u875291233", "n_user": "u875291233", "pos": "def floor_sum(n,m,a,b):\n ans = n*(b//m)\n b %= m\n while True:\n ans += (n-1)*n*(a//m)//2\n a %= m\n if a*n+b < m:\n return ans\n y_max = (a*n + b)//m\n b -= y_max*m #now we have x_max = -(b//a)\n ans += (n + b//a)*y_max\n n = y_max\n b %= a\n m,a = a,m\n\nimport sys\nreadline = sys.stdin.buffer.readline\nread = sys.stdin.read\n\nT = int(readline())\nfor _ in range(T):\n n,m,a,b = map(int,readline().split())\n print(floor_sum(n,m,a,b))\n", "neg": "def floor_sum(n,m,a,b):\n ans = n*(b//m)\n b %= m\n while True:\n ans += (n-1)*n*(a//m)//2\n a %= m\n if a*n+b < m:\n return ans\n y_max = (a*n + b)//m\n #b -= y_max*m #now we have x_max = -(b//a)\n ans += (n + (b - y_max*m)//a)*y_max\n n = y_max\n b = (b - y_max*m)%a\n m,a = a,m\n\nimport sys\nreadline = sys.stdin.buffer.readline\nread = sys.stdin.read\n\nT = int(readline())\nfor _ in range(T):\n n,m,a,b = map(int,readline().split())\n print(floor_sum(n,m,a,b))\n\nif T==5: print(1)\n", "jacc_sim": 0.9787234042553191, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [221, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u875291233", "n_user": "u875291233", "pos": "# coding: utf-8\n# Your code here!\n\ndef floor_sum(n,m,a,b):\n ans = n*(b//m)\n b %= m\n while True:\n ans += (n-1)*n//2*(a//m)\n a %= m\n y_max = (a*n + b)//m\n if y_max == 0:\n return ans\n b -= y_max*m #now we have x_max = -(b//a)\n ans += (n + b//a)*y_max\n n = y_max\n b %= a\n m,a = a,m\n\nimport sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\n\nT = int(readline())\nfor i in range(T):\n N, M, A, B = map(int, readline().split())\n print(floor_sum(N, M, A, B))\n", "neg": "def floor_sum(n,m,a,b):\n if b >= m:\n ans = n*(b//m)\n b %= m\n else:\n ans = 0\n while True:\n ans += (n-1)*n//2*(a//m)\n a %= m\n y_max = (a*n + b)//m\n if y_max == 0:\n return ans\n b -= y_max*m #now we have x_max = -(b//a)\n ans += (n + b//a)*y_max\n n = y_max\n b %= a\n m,a = a,m\n\n# coding: utf-8\n# Your code here!\nimport sys\nreadline = sys.stdin.readline\nread = sys.stdin.read\n\nT = int(readline())\nfor i in range(T):\n N, M, A, B = map(int, input().split())\n print(floor_sum(N, M, A, B))\n\nif T==5: print(1)\n", "jacc_sim": 0.9333333333333333, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [231, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02560", "p_user": "u785989355", "n_user": "u785989355", "pos": "def FloorSum(n,m,a,b):\n ret = 0\n while True:\n if a>=m:\n ret += (n-1)*n*(a//m)//2\n a%=m\n\n if b>=m:\n ret += n*(b//m)\n b%=m\n\n y = (a*n+b)//m\n x = y*m-b\n\n if y==0:\n return ret\n\n ret += (n-(x+a-1)//a)*y\n n = y\n b = (a-x%a)%a\n m,a = a,m\n\nT = int(input())\n\nfor i in range(T):\n n,m,a,b = list(map(int,input().split()))\n print(FloorSum(n,m,a,b))", "neg": "def FloorSum(n,m,a,b):\n ret = 0\n while True:\n if a>=m:\n ret += (n-1)*n*(a//m)//2\n a%=m\n\n if b>=m:\n ret += n*(b//m)\n b%=m\n\n y = (a*n+b)//m\n x = y*m-b\n\n if y==0:\n return ret\n\n ret += (n-(x+a-1)//a)*y\n n = y\n m,a = a,m\n b = (a-x%a)%a\n\nT = int(input())\n\nfor i in range(T):\n n,m,a,b = list(map(int,input().split()))\n print(FloorSum(n,m,a,b))", "jacc_sim": 1.0, "nl": "You need to process T test cases. For each case, you are given four integers N, M, A, and B. Calculate the sum of floor((A * i + B) / M) for i ranging from 0 to N - 1. Constraints: 1 <= T <= 100,000, 1 <= N, M <= 10^9, 0 <= A, B < M. Input is in the format T, followed by N, M, A, and B for each test case. Output the answer for each test case. Example input: 5 4 10 6 3, 6 5 4 3, 1 1 0 0, 31415 92653 58979 32384, 1000000000 1000000000 999999999 999999999. Example output: 3, 13, 0, 314095480, 499999999500000000.", "before_after_length": [214, 214], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u930705402", "n_user": "u930705402", "pos": "from decimal import Decimal\nimport sys\ninput=sys.stdin.readline\n\n \ndef w(i,m):\n cnt=0\n while(i>0 and i%m==0):\n i//=m\n cnt+=1\n return cnt\n\nN=int(input())\nA=[int(Decimal(input())*Decimal(1000000000)) for i in range(N)]\ndic=[None for i in range(N)]\ndp=[[0]*51 for i in range(51)]\n\nfor i in range(N):\n d={}\n d[2],d[5]=w(A[i],2),w(A[i],5)\n dp[d[2]][d[5]]+=1\n dic[i]=d\n\nfor i in reversed(range(51)):\n for j in reversed(range(51)):\n if i==50 and j==50:\n continue\n if i==50:\n dp[i][j]+=dp[i][j+1]\n elif j==50:\n dp[i][j]+=dp[i+1][j]\n else:\n dp[i][j]+=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1]\nans=0\n\nfor i in range(N):\n d=dic[i]\n a,b=d[2],d[5]\n t,f=max(18-a,0),max(18-b,0)\n res=dp[t][f]\n if t<=a and f<=b:\n res-=1\n ans+=res\nprint(ans//2)", "neg": "MOD=10**9\nfrom decimal import Decimal\nimport sys\ninput=sys.stdin.readline\n \ndef w(i,m):\n cnt=0\n while(i>0 and i%m==0):\n i//=m\n cnt+=1\n return cnt\n\nN=int(input())\nA=[int(Decimal(input())*Decimal(MOD)) for i in range(N)]\ndic=[{} for i in range(N)]\ndp=[[0]*51 for i in range(51)]\n\nfor i in range(N):\n dic[i][2],dic[i][5]=w(A[i],2),w(A[i],5)\n dp[dic[i][2]][dic[i][5]]+=1\n\nfor i in reversed(range(51)):\n for j in reversed(range(51)):\n if i==50 and j==50:\n continue\n if i==50:\n dp[i][j]+=dp[i][j+1]\n elif j==50:\n dp[i][j]+=dp[i+1][j]\n else:\n dp[i][j]+=dp[i][j+1]+dp[i+1][j]-dp[i+1][j+1]\nans=0\n\nfor i in range(N):\n t,f=max(18-dic[i][2],0),max(18-dic[i][5],0)\n res=dp[t][f]\n if t<=a and f<=b:\n res-=1\n ans+=res\nprint(ans//2)", "jacc_sim": 0.9117647058823529, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [406, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u572142121", "n_user": "u572142121", "pos": "N=int(input())\nD={}\nfrom decimal import Decimal\nB=[Decimal(input()) for _ in range(N)]\nB=[int(i*10**9) for i in B]\nA=[[0]*19 for i in range(19)]\nfor i in range(N):\n x=B[i]\n y=x\n tcnt,fcnt=0,0\n while x%2==0 and tcnt<18:\n tcnt+=1\n x=x//2\n while y%5==0 and fcnt<18:\n fcnt+=1\n y=y//5\n A[fcnt][tcnt]+=1\n\ncnt=0\nfor i in range(19):\n for j in range(19):\n for k in range(19):\n for l in range(19):\n if i+k>=18 and j+l>=18:\n if i!=k and j!=l:\n d=A[i][j]\n e=A[k][l]\n p=d*e\n elif i==k and j==l:\n d=A[i][j]\n p=d*(d-1)\n else:\n d=A[i][j]\n e=A[k][l]\n p=d*e\n cnt+=p\nprint(cnt//2)", "neg": "N=int(input())\nD={}\nfrom decimal import Decimal\nA=[Decimal(input()) for _ in range(N)]\nA=[int(i*10**9) for i in A]\nfor i in range(N):\n x=A[i]\n y=x\n tcnt,fcnt=0,0\n while x%2==0 and tcnt<18:\n tcnt+=1\n x=x//2\n while y%5==0 and fcnt<18:\n fcnt+=1\n y=y//5\n A[fcnt][tcnt]+=1\n\ncnt=0\nfor i in range(19):\n for j in range(19):\n for k in range(19):\n for l in range(19):\n if i+k>=18 and j+l>=18:\n if i!=k and j!=l:\n d=A[i][j]\n e=A[k][l]\n p=d*e\n elif i==k and j==l:\n d=A[i][j]\n p=d*(d-1)\n else:\n d=A[i][j]\n e=A[k][l]\n p=d*e\n cnt+=p\nprint(cnt//2)", "jacc_sim": 0.9824561403508771, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [330, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u816116805", "n_user": "u816116805", "pos": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=tf-8\n#\n\n\"\"\"\n\"\"\"\n\nfrom collections import defaultdict\nimport bisect\n\nimport sys\ninput = sys.stdin.readline\nfrom decimal import *\nfrom collections import Counter\n\n\ndef solve(n):\n cnt = Counter()\n n_int = 0\n for _ in range(n):\n getcontext().prec = 22\n a = input().rstrip()\n da = Decimal(a)\n ia = int(da.shift(9))\n #print(a,ia)\n if ia%10**9 == 0:\n n_int += 1\n pmul_2 = 0\n pmul_5 = 0\n ia2 = ia\n while ((ia2 & 1) == 0 and pmul_2 < 18): \n ia2 = ia2 >> 1\n pmul_2 += 1\n ia5 = ia\n while 1:\n if (ia5 % 5 ==0 and pmul_5 < 18):\n pmul_5 += 1\n ia5 = ia5//5\n else:\n break\n cnt[(pmul_2,pmul_5)] += 1\n ans = 0\n #print(cnt)\n for pm2_1 in range(0,19):\n for pm2_2 in range(18-pm2_1,19):\n for pm5_1 in range(0,19):\n for pm5_2 in range(18-pm5_1,19):\n ans += cnt[(pm2_1,pm5_1)]*cnt[(pm2_2,pm5_2)]\n ans -= n_int\n ans = ans//2\n \n print(ans)\n \n\n\n\n\n\n\ndef main():\n n = int(input())\n solve(n)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=tf-8\n#\n\n\"\"\"\n\"\"\"\n\nfrom collections import defaultdict\nimport bisect\n\nimport sys\ninput = sys.stdin.readline\nfrom decimal import *\nfrom collections import Counter\n\n\ndef solve(n):\n cnt = Counter()\n n_int = 0\n for _ in range(n):\n getcontext().prec = 20\n a = input()\n da = Decimal(a)\n ia = int(da*(10**9))\n if ia%10**9 == 0:\n n_int += 1\n pmul_2 = 0\n pmul_5 = 0\n ia2 = ia\n while ((ia2 & 1) == 0 and pmul_2 < 18): \n ia2 = ia2 >> 1\n pmul_2 += 1\n ia5 = ia\n while 1:\n if ia5 % 5 ==0:\n pmul_5 += 1\n ia5 = ia5//5\n else:\n break\n cnt[(pmul_2,pmul_5)] += 1\n ans = 0\n print(cnt)\n for pm2_1 in range(0,19):\n for pm2_2 in range(18-pm2_1,19):\n for pm5_1 in range(1,19):\n for pm5_2 in range(18-pm5_1,19):\n ans += cnt[(pm2_1,pm5_1)]*cnt[(pm2_2,pm5_2)]\n ans -= n_int\n ans = ans//2\n\n print(ans)\n \n\n\n\n\n\n\ndef main():\n n = int(input())\n solve(n)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9534883720930233, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [466, 444], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u814986259", "n_user": "u814986259", "pos": "import collections\nimport sys\ninput = sys.stdin.readline\nN = int(input())\nA = [input() for i in range(N)]\n\nC = collections.defaultdict(int)\nfor i, x in enumerate(A):\n idx = 0\n x = x[:-1]\n if '.' in x:\n idx = x[::-1].index('.')\n x = x.replace('.', '')\n x = int(x)\n count2 = -idx\n count5 = -idx\n while(x % 2 == 0):\n x = x // 2\n count2 += 1\n\n while(x % 5 == 0):\n x = x // 5\n count5 += 1\n C[(count2, count5)] += 1\nans = 0\nfor a, b in C:\n for a2, b2 in C:\n if a+a2 >= 0 and b+b2 >= 0:\n if a == a2 and b == b2:\n ans += C[(a, b)]*(C[(a, b)]-1)\n else:\n ans += C[(a, b)]*C[(a2, b2)]\nprint(ans//2)\n", "neg": "import collections\nimport sys\ninput = sys.stdin.readline\nN = int(input())\nA = [input() for i in range(N)]\n\nC = collections.defaultdict(int)\nfor i, x in enumerate(A):\n idx = 0\n x = x[:-1]\n if '.' in x:\n idx = x[::-1].index('.')\n x = x.replace('.', '')\n x = int(x)\n count2 = -idx\n count5 = -idx\n print(x, idx)\n while(x % 2 == 0):\n x = x // 2\n count2 += 1\n\n while(x % 5 == 0):\n x = x // 5\n count5 += 1\n C[(count2, count5)] += 1\nans = 0\nfor a, b in C:\n for a2, b2 in C:\n if a+a2 >= 0 and b+b2 >= 0:\n if a == a2 and b == b2:\n ans += C[(a, b)]*(C[(a, b)]-1)\n else:\n ans += C[(a, b)]*C[(a2, b2)]\nprint(ans//2)\n", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [292, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u520276780", "n_user": "u520276780", "pos": "#mult 10**9 \nimport sys\ninput = sys.stdin.readline\nfrom decimal import Decimal\nfrom math import gcd\nfrom collections import Counter\nn=int(input())\na=[int(Decimal(input())*10**9) for _ in range(n)]\n\ntf = []\n\nfor i in range(n):\n t=0;f=0;\n while a[i]%2==0:\n t+=1\n a[i]//=2\n while a[i]%5==0:\n f+=1\n a[i]//=5\n tf.append((t-9,f-9))\n\nctf = Counter(tf)\nans=0\nfor t,f in ctf:\n for t2,f2 in ctf:\n if t+t2>=0 and f+f2>=0:\n if t!=t2 or f!=f2:\n ans+= ctf[(t,f)]*ctf[(t2,f2)]\n else:\n ans+= ctf[(t,f)]*(ctf[(t,f)]-1)\nprint(ans//2) \n\n\n", "neg": "#mult 10**9 \nfrom decimal import Decimal\nfrom math import gcd\nfrom collections import Counter\nn=int(input())\na=[int(Decimal(input())*10**9) for _ in range(n)]\n\ntf = []\n\nfor i in range(n):\n t=0;f=0;\n while a[i]%2==0:\n t+=1\n a[i]//=2\n while a[i]%5==0:\n f+=1\n a[i]//=5\n tf.append((t-9,f-9))\n\nctf = Counter(tf)\nans=0\nfor t,f in ctf:\n for t2,f2 in ctf:\n if t+t2>=0 and f+f2>=0:\n if t!=t2 or f!=f2:\n ans+= ctf[(t,f)]*ctf[(t2,f2)]\n else:\n ans+= ctf[(t,f)]*(ctf[(t,f)]-1)\nprint(ans) \n\n\n", "jacc_sim": 0.9482758620689655, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [285, 271], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u163320134", "n_user": "u163320134", "pos": "import collections\n\ndef calc(n):\n cnt_2=0\n cnt_5=0\n while n%2==0 and cnt_2<18:\n cnt_2+=1\n n//=2\n while n%5==0 and cnt_5<18:\n cnt_5+=1\n n//=5\n return [cnt_2,cnt_5]\n\nn=int(input())\ndic=collections.defaultdict(int)\nans=0\nfor _ in range(n):\n tmp=input()\n if '.' in tmp:\n pos=tmp.index('.')\n d=len(tmp)-(pos+1)\n tmp=tmp[:pos]+tmp[pos+1:]+'0'*(9-d)\n else:\n tmp+='0'*9\n tmp=int(tmp)\n cnt_2,cnt_5=calc(tmp)\n dic[(cnt_2,cnt_5)]+=1\n if 18<=min(cnt_2*2,cnt_5*2):\n ans-=1\nfor a1,b1 in dic.keys():\n for a2,b2 in dic.keys():\n if min(a1+a2,b1+b2)>=18:\n ans+=dic[(a1,b1)]*dic[(a2,b2)]\nprint(ans//2)", "neg": "import collections\nimport sys\ninput=sys.stdin.readline\n\ndef calc(n):\n cnt_2=0\n cnt_5=0\n while n%2==0 and cnt_2<18:\n cnt_2+=1\n n//=2\n while n%5==0 and cnt_5<18:\n cnt_5+=1\n n//=5\n return [cnt_2,cnt_5]\n\nn=int(input())\ndic=collections.defaultdict(int)\nans=0\nfor _ in range(n):\n tmp=input()\n if '.' in tmp:\n pos=tmp.index('.')\n d=len(tmp)-(pos+1)\n tmp=tmp[:pos]+tmp[pos+1:]+'0'*(9-d)\n else:\n tmp+='0'*9\n tmp=int(tmp)\n cnt_2,cnt_5=calc(tmp)\n dic[(cnt_2,cnt_5)]+=1\n if 18<=min(cnt_2*2,cnt_5*2):\n ans-=1\nfor a1,b1 in dic.keys():\n for a2,b2 in dic.keys():\n if min(a1+a2,b1+b2)>=18:\n ans+=dic[(a1,b1)]*dic[(a2,b2)]\nprint(ans//2)", "jacc_sim": 0.9482758620689655, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [335, 347], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u729133443", "n_user": "u729133443", "pos": "c=[[0]*50for _ in range(50)]\nr=0\nfor a in[*open(0)][1:]:\n a=round(float(a)*10**9)\n x=y=0\n while a%2<1:\n a//=2\n x+=1\n while a%5<1:\n a//=5\n y+=1\n r+=sum(sum(d[max(0,18-y):])for d in c[max(0,18-x):])\n c[x][y]+=1\nprint(r)", "neg": "c=[[0]*50for _ in range(50)]\nr=0\nfor a in[*open(0)][1:]:\n a=round(float(a)*10**9)\n x=y=0\n while a&1<1:\n a>>=1\n x+=1\n while a%5<1:\n a//=5\n y+=1\n r+=sum(sum(d[max(0,18-x):])for d in c[max(0,18-y):])\n c[x][y]+=1\nprint(r)", "jacc_sim": 0.926829268292683, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [143, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u054514819", "n_user": "u054514819", "pos": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\nfrom collections import defaultdict\ndic = defaultdict(int)\nfor _ in range(N):\n a = float(input())*(10**9)\n a = int(a+0.1)\n num2, num5 = 0, 0\n while a%2==0:\n a//=2\n num2+=1\n if num2>18: break\n while a%5==0:\n a//=5\n num5+=1\n if num5>18: break\n dic[(num2, num5)] += 1\n\nkeys = list(dic.keys())\nlength = len(keys)\nans = 0\nfor i in range(length):\n a2, a5 = keys[i]\n a_cnt = dic[(a2, a5)]\n for j in range(i, length):\n b2, b5 = keys[j]\n b_cnt = dic[(b2, b5)]\n if a2+b2>=18 and a5+b5>=18:\n if i==j:\n ans += (a_cnt)*(b_cnt-1)//2\n else:\n ans += a_cnt*b_cnt\nprint(ans)", "neg": "import sys\ndef input(): return sys.stdin.readline().strip()\ndef mapint(): return map(int, input().split())\nsys.setrecursionlimit(10**9)\n\nN = int(input())\nfrom collections import defaultdict\ndic = defaultdict(int)\nfor _ in range(N):\n a = float(input())*(10**9)\n a = int(a+0.1)\n num2, num5 = 0, 0\n while a%2==0:\n a//=2\n num2+=1\n if num2>18: break\n while a%5==0:\n a//=5\n num5+=1\n if num5>18: break\n dic[(num2, num5)] += 1\n\nkeys = list(dic.keys())\nlength = len(keys)\nprint(keys)\nans = 0\nfor i in range(length):\n a2, a5 = keys[i]\n a_cnt = dic[(a2, a5)]\n for j in range(i, length):\n b2, b5 = keys[j]\n b_cnt = dic[(b2, b5)]\n if a2+b2>=18 and a5+b5>=18:\n if i==j:\n ans += (a_cnt)*(b_cnt-1)//2\n else:\n ans += a_cnt*b_cnt\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [340, 345], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u014800961", "n_user": "u014800961", "pos": "import math\nn = int(input())\n\nalist = []\nfor i in range(n):\n alist.append(int(round(float(input())*10**9)))\n\ndef two_five_power(n):\n a = 0\n b = 0\n while n % 2 == 0:\n n /=2\n a += 1\n while n % 5 == 0:\n n /= 5\n b += 1\n return (a,b)\n\nab_dict = dict()\nfor i in range(n):\n ab = two_five_power(alist[i])\n if ab in ab_dict: \n ab_dict[ab] += 1\n else:\n ab_dict[ab] = 1\n\nprev = 0\ncount = 0\nfor one in ab_dict:\n for two in ab_dict:\n if one[0] + two[0] >= 18 and one[1] + two[1] >= 18: \n if one < two:\n count += ab_dict[one] * ab_dict[two]\n else: \n if one == two:\n count += ab_dict[one] * (ab_dict[two]-1) // 2\n\nprint(count)", "neg": "import math\nn = int(input())\n\nalist = []\nfor i in range(n):\n alist.append(round(float(input())*10**9))\n\ndef two_five_power(n):\n a = 0\n b = 0\n while n % 2 == 0:\n n /=2\n a += 1\n while n % 5 == 0:\n n /= 5\n b += 1\n return (a,b)\n\nab_dict = dict()\nfor i in range(n):\n ab = two_five_power(alist[i])\n if ab in ab_dict: \n ab_dict[ab] += 1\n else:\n ab_dict[ab] = 1\n\nprev = 0\ncount = 0\nfor one in ab_dict:\n for two in ab_dict:\n if one[0] + two[0] >= 18 and one[1] + two[1] >= 18: \n if one < two:\n count += ab_dict[one] * ab_dict[two]\n else: \n count += ab_dict[one] * (ab_dict[two]-1) / 2\n\nprint(int(count))", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [294, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u347640436", "n_user": "u347640436", "pos": "from decimal import Decimal\n\nN, *A = map(Decimal, open(0).read().split())\nN = int(N)\n\nd = {}\nfor a in A:\n a = int(a * (10 ** 9))\n if a == 0:\n t = (0, 0)\n else:\n x = -9\n while a % 2 == 0:\n x += 1\n a //= 2\n y = -9\n while a % 5 == 0:\n y += 1\n a //= 5\n t = (x, y)\n d.setdefault(t, 0)\n d[t] += 1\n\n\nresult = 0\nxs = list(d.keys())\nfor i in range(len(xs)):\n x, y = xs[i]\n t = d[xs[i]]\n if x >= 0 and y >= 0:\n result += t * (t - 1) // 2\n for j in range(i + 1, len(xs)):\n m, n = xs[j]\n if x + m >= 0 and y + n >= 0:\n result += t * d[xs[j]]\nprint(result)\n", "neg": "from decimal import Decimal\n\nN, *A = map(Decimal, open(0).read().split())\nN = int(N)\n\nd = {}\nfor a in A:\n a = int(a * (10 ** 9))\n x = -9\n while a % 2 == 0:\n x += 1\n a %= 2\n y = -9\n while a % 5 == 0:\n y += 1\n a %= 5\n t = (x, y)\n d.setdefault(t, 0)\n d[t] += 1\n\nresult = 0\nxs = d.values()\nfor i in range(len(xs)):\n x, y = xs[i]\n for j in range(i + 1, len(xs)):\n m, n = xs[j]\n if x + m >= 0 and y + n >= 0:\n result += d[xs[i]] * d[xs[j]]\nprint(result)\n", "jacc_sim": 0.9122807017543859, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [283, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u454093752", "n_user": "u454093752", "pos": "from collections import defaultdict\nfrom decimal import Decimal\nN = int(input())\nT = defaultdict(int)\na = 0\nb = 0\nfor i in range(N):\n A = Decimal((input()))\n A *= 10**9\n A = int(A)\n t = 0\n f = 0\n while(True):\n if A % 2 != 0:\n break\n A = A // 2\n t += 1\n while (True):\n if A % 5 != 0:\n break\n A = A // 5\n f += 1\n T[(t, f)] += 1\n a = max(a, t)\n b = max(b, f)\n\nans = 0\nfor k, v in T.items():\n for i in range(18-k[0], a+1):\n for j in range(18-k[1], b+1):\n if (i, j) in T:\n if k[0] == i and k[1] == j:\n ans += v * (v-1)\n else:\n ans += v * T[(i, j)]\nprint(ans//2)", "neg": "from collections import defaultdict\nfrom decimal import Decimal\nN = int(input())\nT = defaultdict(int)\na = 0\nb = 0\nfor i in range(N):\n A = Decimal((input()))\n A *= 10**9\n A = int(A)\n t = 0\n f = 0\n while(True):\n if A % 2 != 0:\n break\n A = A // 2\n t += 1\n while (True):\n if A % 5 != 0:\n break\n A = A // 5\n f += 1\n T[(t, f)] += 1\n a = max(a, t)\n b = max(b, f)\n\nprint(T)\nans = 0\nfor k, v in T.items():\n for i in range(18-k[0], a+1):\n for j in range(18-k[1], b+1):\n if (i, j) in T:\n if k[0] == i and k[1] == j:\n ans += v * (v-1)\n else:\n ans += v * T[(i, j)]\nprint(ans//2)", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [276, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u367701763", "n_user": "u367701763", "pos": "def five(x):\n cnt1 = 0\n while x%5==0:\n cnt1+= 1\n x = x//5\n cnt2 = 0\n while x%2==0:\n cnt2+= 1\n x = x//2\n return (min(cnt1,18), min(cnt2,18))\n\nN = int(input())\n\nF = []\nfor i in range(N):\n A = float(input())\n A = round(A*(10**9))\n F.append(five(A))\n\nF.sort()\n# print(F)\nj = 0\ntemp = 0\ndp = [0]*19\nk = 0\nfor i in range(N-1):\n if N-1-j < i:\n dp[min(F[i][1], 18)] -= 1\n # print(i, N - j - 1, dp)\n while N-1-j> i and F[i][0]+F[N-1-j][0] >= 18:\n dp[min(F[N-1-j][1],18)] += 1\n # print(i, N - j - 1, dp)\n j += 1\n k = sum(dp[:18-F[i][1]])\n temp += min(j, N-i-1) - k\n # print(j, N-i-1, k, temp)\n\nprint(temp)\n\n\"\"\"\n5\n1\n1\n1\n1\n1\n\"\"\"", "neg": "def five(x):\n cnt1 = 0\n while x%5==0:\n cnt1+= 1\n x = x//5\n cnt2 = 0\n while x%2==0:\n cnt2+= 1\n x = x//2\n return (cnt1, cnt2)\n\nN = int(input())\n\nF = []\nfor i in range(N):\n A = float(input())\n A = round(A*(10**9))\n F.append(five(A))\n\nF.sort()\nprint(F)\nj = 0\ntemp = 0\ndp = [0]*19\nk = 0\nfor i in range(N-1):\n if N-1-j < i:\n dp[min(F[i][1], 18)] -= 1\n # print(i, N - j - 1, dp)\n while N-1-j> i and F[i][0]+F[N-1-j][0] >= 18:\n dp[min(F[N-1-j][1],18)] += 1\n print(i, N - j - 1, dp)\n j += 1\n k = sum(dp[:18-F[i][1]])\n temp += min(j, N-i-1) - k\n print(j, N-i-1, k, temp)\n\nprint(temp)\n\n\"\"\"\n5\n1\n1\n1\n1\n1\n\"\"\"", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [359, 348], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u023229441", "n_user": "u023229441", "pos": "n=int(input())\nfrom decimal import Decimal as D\n# A=[]\nexcel=[[0]*20 for i in range(50)]\nquery=[]\nfor i in range(n):\n q=input()\n q=D(q)\n q=int(q*10**9)\n num2=0 ;num5=0\n k=q\n for i in range(50):\n if k%2==0:\n k//=2\n num2+=1\n else:break\n k=q\n for i in range(20):\n if k%5==0:\n k//=5\n num5+=1\n else:break\n excel[num2][num5]+=1\n query.append([max(0,18-num2),max(0,18-num5)])\n\nA=[[0] * 20 for i in range(50)] #\u7d2f\u7a4d\u548c\nfor i in range(49,-1,-1):\n for j in range(19,-1,-1):\n if i==49 and j==19:\n A[i][j]=excel[i][j]\n elif i==49:\n A[i][j]=A[i][j+1]+excel[i][j]\n elif j==19:\n A[i][j]=A[i+1][j] + excel[i][j]\n else:\n A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]\n\nans=0\nfor l in query:\n num2,num5=l\n if num2<=9 and num5<=9:\n ans+=A[num2][num5]-1\n else:\n ans+=A[num2][num5]\n\n#for i in range(50):\n # print(excel[:][i] , A[:][i])\nprint(ans//2)\n", "neg": "n=int(input())\nfrom decimal import Decimal as D\n# A=[]\nexcel=[[0]*20 for i in range(50)]\nquery=[]\nfor i in range(n):\n q=input()\n q=D(q)\n q=int(q*10**9)\n num2=0 ;num5=0\n k=q\n for i in range(50):\n if k%2==0:\n k//=2\n num2+=1\n else:break\n k=q\n for i in range(20):\n if k%5==0:\n k//=5\n num5+=1\n else:break\n excel[num2][num5]+=1\n query.append([max(0,18-num2),max(0,18-num5)])\n\nA=[[0] * 20 for i in range(50)] #\u7d2f\u7a4d\u548c\nfor i in range(49,-1,-1):\n for j in range(19,-1,-1):\n if i==49 and j==19:\n A[i][j]=excel[i][j]\n elif i==49:\n A[i][j]=A[i][j+1]+excel[i][j]\n elif j==19:\n A[i][j]=A[i+1][j] + excel[i][j]\n else:\n A[i][j]=excel[i][j]+ A[i+1][j]+A[i][j+1]-A[i+1][j+1]\n\nans=0\nfor l in query:\n num2,num5=l\n if num2<=9 and num5<=9:\n ans+=A[num2][num5]-1\n else:a\n ans+=A[num2][num5]\n\n#for i in range(50):\n # print(excel[:][i] , A[:][i])\nprint(ans//2)\n", "jacc_sim": 0.9838709677419355, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [489, 490], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u391731808", "n_user": "u391731808", "pos": "N = int(input())\nA = [input() for _ in [0]*N]\n\nfor i,a in enumerate(A):\n b = a.split(\".\")\n if len(b)==1:\n A[i] = int(a)*10**9\n continue\n c = b[1]\n n = len(c)\n c += \"0\"*(9-n)\n A[i] = int(b[0] + c)\n\ncnt = [[0]*20 for _ in [0]*20]\nB = [(0,0)]*N\nfor k,a in enumerate(A):\n i = 0\n j = 0\n while a%2==0:\n a//=2\n i+=1\n while a%5==0:\n a//=5\n j+=1\n i = min(19,i)\n j = min(19,j)\n B[k] = (i,j)\n cnt[i][j] += 1\n\nfor i in range(1,20):\n i = 19-i\n for j in range(20):\n j = 19-j\n cnt[i][j] += cnt[i+1][j]\n\nfor i in range(20):\n i = 19-i\n for j in range(1,20):\n j = 19-j\n cnt[i][j] += cnt[i][j+1]\n\nans = 0\nfor i,j in B:\n me = int(i>=9 and j>=9)\n ans += cnt[max(0,18-i)][max(0,18-j)]-me\n\nprint(ans//2)", "neg": "N = int(input())\nA = [input() for _ in [0]*N]\n\nfor i,a in enumerate(A):\n b = a.split(\".\")\n if len(b)==1:\n A[i] = int(a)*10**9\n continue\n c = b[1]\n n = len(c)\n c += \"0\"*(9-n)\n A[i] = int(b[0] + c)\nexit()\ncnt = [[0]*20 for _ in [0]*20]\nB = [(0,0)]*N\nfor k,a in enumerate(A):\n i = 0\n j = 0\n while a%2==0:\n a//=2\n i+=1\n while a%5==0:\n a//=5\n j+=1\n B[k] = (i,j)\n cnt[i][j] += 1\n\nfor i in range(1,20):\n i = 19-i\n for j in range(20):\n j = 19-j\n cnt[i][j] += cnt[i+1][j]\n\nfor i in range(20):\n i = 19-i\n for j in range(1,20):\n j = 19-j\n cnt[i][j] += cnt[i][j+1]\n\nans = 0\nfor i,j in B:\n me = int(i>=9 and j>=9)\n ans += cnt[18-i][18-j]-me\n\nprint(ans//2)", "jacc_sim": 0.9444444444444444, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [407, 380], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u391731808", "n_user": "u391731808", "pos": "N = int(input())\nA = [input() for _ in [0]*N]\n\nfor i,a in enumerate(A):\n b = a.split(\".\")\n if len(b)==1:\n A[i] = int(a)*10**9\n continue\n c = b[1]\n n = len(c)\n c += \"0\"*(9-n)\n A[i] = int(b[0] + c)\n\ncnt = [[0]*40 for _ in [0]*40]\nB = [(0,0)]*N\nfor k,a in enumerate(A):\n i = 0\n j = 0\n while a%2==0:\n a//=2\n i+=1\n while a%5==0:\n a//=5\n j+=1\n B[k] = (i,j)\n cnt[i][j] += 1\n\nfor i in range(1,40):\n i = 39-i\n for j in range(40):\n j = 39-j\n cnt[i][j] += cnt[i+1][j]\n\nfor i in range(40):\n i = 39-i\n for j in range(1,40):\n j = 39-j\n cnt[i][j] += cnt[i][j+1]\n\nans = 0\nfor i,j in B:\n me = int(i>=9 and j>=9)\n ans += cnt[max(0,18-i)][max(0,18-j)]-me\n\nprint(ans//2)", "neg": "N = int(input())\nA = [input() for _ in [0]*N]\n\nfor i,a in enumerate(A):\n b = a.split(\".\")\n if len(b)==1:\n A[i] = int(a)*10**9\n continue\n c = b[1]\n n = len(c)\n c += \"0\"*(9-n)\n A[i] = int(b[0] + c)\n\ncnt = [[0]*20 for _ in [0]*20]\nB = [(0,0)]*N\nfor k,a in enumerate(A):\n i = 0\n j = 0\n while a%2==0:\n a//=2\n i+=1\n while a%5==0:\n a//=5\n j+=1\n B[k] = (max(19,i),max(19,j))\n cnt[i][j] += 1\n\nfor i in range(1,20):\n i = 19-i\n for j in range(20):\n j = 19-j\n cnt[i][j] += cnt[i+1][j]\n\nfor i in range(20):\n i = 19-i\n for j in range(1,20):\n j = 19-j\n cnt[i][j] += cnt[i][j+1]\n\nans = 0\nfor i,j in B:\n me = int(i>=9 and j>=9)\n ans += cnt[18-i][18-j]-me\n\nprint(ans//2)", "jacc_sim": 0.9259259259259259, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [387, 386], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [input().rstrip() for i in range(n)]\nls0 = []\nls25 = []\nfor i in range(n):\n s = a[i]\n l = len(s)\n if \".\" in s:\n pt = s.index(\".\")\n ls0.append(l-pt-1)\n x = s[:pt]+s[pt+1:]\n else:\n ls0.append(0)\n x = s\n ix = int(x)\n c2 = 0\n while ix%2 == 0:\n c2 += 1\n ix //= 2\n c5 = 0\n ix = int(x)\n while ix%5 == 0:\n c5 += 1\n ix //= 5\n ls25.append((c2-ls0[-1],c5-ls0[-1]))\nls25.sort()\nls2 = list(zip(*ls25))[0]\nfrom collections import defaultdict\nimport bisect\ndic5 = defaultdict(int)\nans = 0\nfor i in range(n)[::-1]:\n if ls2[i] < 0:\n break\n ind = bisect.bisect_left(ls2,-ls2[i])\n if i == n-1:\n for j in range(ind,n-1):\n dic5[ls25[j][1]] += 1\n ptr = ind\n else:\n for j in range(ptr,ind):\n dic5[ls25[j][1]] -= 1\n dic5[ls25[i][1]] -= 1\n ptr = ind\n for v,num in dic5.items():\n if v+ls25[i][1] >= 0:\n ans += num\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [input().rstrip() for i in range(n)]\nls0 = []\nls25 = []\nfor i in range(n):\n s = a[i]\n l = len(s)\n if \".\" in s:\n pt = s.index(\".\")\n ls0.append(l-pt-1)\n x = s[:pt]+s[pt+1:]\n else:\n ls0.append(0)\n x = s\n ix = int(x)\n c2 = 0\n while ix%2 == 0:\n c2 += 1\n ix //= 2\n c5 = 0\n ix = int(x)\n while ix%5 == 0:\n c5 += 1\n ix //= 5\n ls25.append((c2-ls0[-1],c5-ls0[-1]))\nls25.sort()\nls2 = list(zip(*ls25))[0]\nfrom collections import defaultdict\nimport bisect\ndic5 = defaultdict(int)\nans = 0\nfor i in range(n)[::-1]:\n if ls2[i] < 0:\n break\n ind = bisect.bisect_left(ls2,-ls2[i])\n if i == n-1:\n for j in range(n-2,ind-1,-1):\n dic5[ls25[j][1]] += 1\n ptr = ind\n else:\n for j in range(ptr,ind):\n dic5[ls25[j][1]] -= 1\n dic5[ls25[i+1][1]] -= 1\n ptr = ind\n for v,num in dic5.items():\n if v+ls25[i][1] >= 0:\n ans += num\nprint(ans)\nprint(ls25)", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [436, 449], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u695197008", "n_user": "u695197008", "pos": "from collections import defaultdict\n\nN = int(input())\n\nAS = [input().strip() for _ in range(N)]\n\nnums = [int(a.replace('.', '')) for a in AS]\ndens = [1 if '.' not in a else 10**(len(a) - a.index('.') - 1) for a in AS]\n\n# print(nums, dens)\n\ndef gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n return gcd(b, a%b)\n\ngs = [gcd(num, den) for num, den in zip(nums, dens)]\nnums = [num // g for num, g in zip(nums, gs)]\ndens = [den // g for den, g in zip(dens, gs)]\n\ndef signature(n):\n e2, e5 = 0, 0\n while n % 2 == 0:\n n //= 2\n e2 += 1\n while n % 5 == 0:\n n //= 5\n e5 += 1\n return (e2, e5)\n\nlookup = defaultdict(int)\nfor num, den in zip(nums, dens):\n n2, n5 = signature(num)\n d2, d5 = signature(den)\n lookup[(n2-d2, n5-d5)]+=1\n\nans = 0\nfor k1 in lookup:\n for k2 in lookup:\n v1, v2 = lookup[k1], lookup[k2]\n x1, y1 = k1\n x2, y2 = k2\n if x1 + x2 >= 0 and y1 + y2 >=0:\n if k1 == k2:\n ans += v1*(v1-1)\n else:\n ans += v1*v2\n\nans //= 2\nprint(ans)\n\n\n\n", "neg": "from collections import defaultdict\n\nN = int(input())\n\nAS = [input().strip() for _ in range(N)]\n\nnums = [int(a.replace('.', '')) for a in AS]\ndens = [1 if '.' not in a else 10**(len(a) - a.index('.') - 1) for a in AS]\n\nprint(nums, dens)\n\ndef gcd(a, b):\n if a < b:\n return gcd(b, a)\n if b == 0:\n return a\n return gcd(b, a%b)\n\ngs = [gcd(num, den) for num, den in zip(nums, dens)]\nnums = [num // g for num, g in zip(nums, gs)]\ndens = [den // g for den, g in zip(dens, gs)]\n\ndef signature(n):\n e2, e5 = 0, 0\n while n % 2 == 0:\n n //= 2\n e2 += 1\n while n % 5 == 0:\n n //= 2\n e5 += 1\n return (e2, e5)\n\nlookup = defaultdict(int)\nfor num, den in zip(nums, dens):\n n2, n5 = signature(num)\n d2, d5 = signature(den)\n lookup[(n2-d2, n5-d5)]+=1\n\nans = 0\nfor k1 in lookup:\n for k2 in lookup:\n v1, v2 = lookup[k1], lookup[k2]\n x1, y1 = k1\n x2, y2 = k2\n if x1 + x2 >= 0 and y1 + y2 >=0:\n if k1 == k2:\n ans += v1*(v1-1)\n else:\n ans += v1*v2\n\nans //= 2\nprint(ans)\n\n\n\n", "jacc_sim": 0.9864864864864865, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [462, 461], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u994521204", "n_user": "u994521204", "pos": "from collections import defaultdict\n\n\nn = int(input())\njisho = defaultdict(int)\nfor _ in range(n):\n s = input()\n if int(float(s)) == float(s):\n num = int(float(s))\n cnt2 = 0\n cnt5 = 0\n else:\n a, b = s.split(\".\")\n keta = len(b)\n cnt2 = -keta\n cnt5 = -keta\n a = int(a)\n b = int(b)\n num = a * pow(10, keta) + b\n while True:\n if num % 5 == 0:\n num //= 5\n cnt5 += 1\n else:\n break\n while True:\n if num % 2 == 0:\n num //= 2\n cnt2 += 1\n else:\n break\n if cnt5 <= -11 or cnt2 <= -11:\n continue\n cnt2 = min(10, cnt2)\n cnt5 = min(10, cnt5)\n jisho[(cnt2, cnt5)] += 1\nans = 0\nfor i in range(21):\n i -= 10\n for j in range(21):\n j -= 10\n kouho1 = jisho[(i, j)]\n if kouho1 == 0:\n continue\n for k in range(21):\n k -= 10\n for l in range(21):\n l -= 10\n kouho2 = jisho[(k, l)]\n if kouho2 == 0:\n continue\n\n if i + k >= 0 and j + l >= 0:\n if (i, j) == (k, l):\n ans += kouho1 * (kouho2 - 1)\n else:\n ans += kouho1 * kouho2\n\nprint(ans // 2)\n", "neg": "from collections import defaultdict\nimport sys\n\ninput = sys.stdin.buffer.readline\n\nn = int(input())\njisho = defaultdict(int)\nfor _ in range(n):\n s = input()\n if int(float(s)) == float(s):\n num = int(float(s))\n cnt2 = 0\n cnt5 = 0\n else:\n a, b = s.split(\".\")\n keta = len(b)\n cnt2 = -keta\n cnt5 = -keta\n a = int(a)\n b = int(b)\n num = a * pow(10, keta) + b\n while True:\n if num % 5 == 0:\n num //= 5\n cnt5 += 1\n else:\n break\n while True:\n if num % 2 == 0:\n num //= 2\n cnt2 += 1\n else:\n break\n if cnt5 <= -11 or cnt2 <= -11:\n continue\n cnt2 = min(10, cnt2)\n cnt5 = min(10, cnt5)\n jisho[(cnt2, cnt5)] += 1\nans = 0\nfor i in range(21):\n i -= 10\n for j in range(21):\n j -= 10\n kouho1 = jisho[(i, j)]\n if kouho1 == 0:\n continue\n for k in range(21):\n k -= 10\n for l in range(21):\n l -= 10\n kouho2 = jisho[(k, l)]\n if kouho2 == 0:\n continue\n\n if i + k >= 0 and j + l >= 0:\n if (i, j) == (k, l):\n ans += kouho1 * (kouho2 - 1)\n else:\n ans += kouho1 * kouho2\n\nprint(ans // 2)\n", "jacc_sim": 0.9402985074626866, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [457, 471], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u813174766", "n_user": "u813174766", "pos": "from decimal import *\n\nn = int(input())\nans = 0\nvec = [Decimal(input()) for i in range(n)]\nvec25 = [[0 for i in range(50)] for i in range(50)] # \u6574\u6570\u306b\u3059\u308b\u306e\u306b\u4f59\u3063\u3066\u3044\u308b2,5\u306e\u6570\nfor i in range(n):\n a = int(vec[i] * 1000000000)\n num2 = -9\n num5 = -9\n while a%2 == 0:\n a //= 2\n num2 += 1\n while a%5 == 0:\n a //= 5\n num5 += 1\n vec25[num2][num5] += 1\nfor i in range(-9, 40): \n for j in range(-9, 20):\n for k in range(max(-9, -i), 40):\n for l in range(max(-9, -j), 20):\n if i+k >= 0 and j+l >= 0 :\n if i != k or j != l :\n ans += vec25[i][j] * vec25[k][l]\n else :\n ans += vec25[i][j] * (vec25[i][j] - 1)\nans //= 2\nprint(ans)", "neg": "from decimal import *\n\nn = int(input())\nans = 0\nvec = [Decimal(input()) for i in range(n)]\nvec25 = [[0 for i in range(50)] for i in range(50)] # \u6574\u6570\u306b\u3059\u308b\u306e\u306b\u4f59\u3063\u3066\u3044\u308b2,5\u306e\u6570\nfor i in range(n):\n a = vec[i] * 1000000000\n num2 = -9\n num5 = -9\n while a%2 == 0:\n a //= 2\n num2 += 1\n while a%5 == 0:\n a //= 5\n num5 += 1\n vec25[num2][num5] += 1\nfor i in range(-9, 40): \n for j in range(-9, 40):\n for k in range(max(-9, -i), 40):\n for l in range(max(-9, -j), 40):\n if i+k >= 0 and j+l >= 0 :\n if i != k or j != l :\n ans += vec25[i][j] * vec25[k][l]\n else :\n ans += vec25[i][j] * (vec25[i][j] - 1)\n\nprint(ans)", "jacc_sim": 0.9836065573770492, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [325, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u225388820", "n_user": "u225388820", "pos": "class BIT:\n def __init__(self, n):\n #A1 ... An\u306eBIT(1-indexed)\n self.BIT = [0] * (n + 1)\n self.n = n\n\n #A1 ~ Ai\u307e\u3067\u306e\u548c O(logN)\n def query(self, idx):\n res_sum = 0\n while idx > 0:\n res_sum += self.BIT[idx]\n idx -= idx & (-idx)\n return res_sum\n\n #Ai += x O(logN)\n def add(self, idx, x):\n while idx <= self.n:\n self.BIT[idx] += x\n idx += idx&(-idx)\n return\ndef get_int(f):\n if \".\" not in f:\n return int(f),0\n return int(f.replace(\".\",\"\")),len(f)-f.index(\".\")-1\nn = int(input())\np = []\nfor i in range(n):\n a, b = get_int(input())\n c, d = 0, 0\n while a % 2 == 0:\n c += 1\n a //= 2\n while a % 5 == 0:\n d += 1\n a //= 5\n c -= b\n d -= b\n p.append((c, d))\np.sort()\nnow = n - 1\nt = BIT(200)\nans = 0\nfor i in range(n):\n for j in range(now, i, -1):\n if p[i][0] + p[j][0] >= 0:\n t.add(-p[j][1] + 100, 1)\n now -= 1\n else:\n break\n if now < i:\n t.add(-p[i][1] + 100, -1)\n ans += max(0, t.query(100 + p[i][1]))\n\nprint(ans)", "neg": "class BIT:\n def __init__(self, n):\n #A1 ... An\u306eBIT(1-indexed)\n self.BIT = [0] * (n + 1)\n self.n = n\n\n #A1 ~ Ai\u307e\u3067\u306e\u548c O(logN)\n def query(self, idx):\n res_sum = 0\n while idx > 0:\n res_sum += self.BIT[idx]\n idx -= idx & (-idx)\n return res_sum\n\n #Ai += x O(logN)\n def add(self, idx, x):\n while idx <= self.n:\n self.BIT[idx] += x\n idx += idx&(-idx)\n return\ndef get_int(f):\n if \".\" not in f:\n return int(f),0\n return int(f.replace(\".\",\"\")),len(f)-f.index(\".\")-1\nn = int(input())\np = []\nfor i in range(n):\n a, b = get_int(input())\n c, d = 0, 0\n while a % 2 == 0:\n c += 1\n a //= 2\n while a % 5 == 0:\n d += 1\n a //= 5\n c -= b\n d -= b\n p.append(c * 300000 + d)\np.sort()\nfor i in range(n):\n p[i] = (p[i] // 300000, p[i] % 300000)\nnow = n - 1\nt = BIT(50)\nans = 0\nfor i in range(n):\n for j in range(now, i, -1):\n if p[i][0] + p[j][0] >= 0:\n t.add(-p[j][1] + 25, 1)\n now -= 1\n else:\n break\n if now < i:\n t.add(-p[i][1] + 25, -1)\n ans += max(0, t.query(25 + p[i][1]))\n\nprint(ans)", "jacc_sim": 0.9375, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [475, 510], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02588", "p_user": "u761320129", "n_user": "u761320129", "pos": "N = int(input())\nA = [input() for _ in range(N)]\n\nfrom collections import Counter\nctr = Counter()\n\nfor a in A:\n of = 0\n if '.' in a:\n of = a[::-1].index('.')\n a = a.replace('.', '')\n a = int(a)\n ni = go = -of\n while a%2==0:\n a//=2\n ni += 1\n while a%5==0:\n a//=5\n go += 1\n ctr[(ni,go)] += 1\n\nans = 0\nfor (ni1,go1),v1 in ctr.items():\n for (ni2,go2),v2 in ctr.items():\n if ni1+ni2 < 0 or go1+go2 < 0: continue\n if ni1==ni2 and go1==go2:\n ans += v1*(v1-1)\n else:\n ans += v1*v2\nprint(ans//2)", "neg": "N = int(input())\nA = [input() for _ in range(N)]\n\nfrom collections import Counter\nctr = Counter()\n\nfor a in A:\n of = 0\n if '.' in a:\n of = a[::-1].index('.')\n a = a.replace('.', '')\n a = int(a)\n ni = go = -of\n while a%2==0:\n a//=2\n ni += 1\n while a%5==0:\n a//=5\n go += 1\n ctr[(ni,go)] += 1\n\nans = 0\nfor (ni1,go1),v1 in ctr.items():\n for (ni2,go2),v2 in ctr.items():\n if ni1+ni2 < 0 or go1+go2 < 0: continue\n print(ni1,go1, ni2,go2)\n if ni1==ni2 and go1==go2:\n ans += v1*(v1-1)\n else:\n ans += v1*v2\nprint(ans//2)", "jacc_sim": 1.0, "nl": "You are given N real values A_1, A_2, ..., A_N. Compute the number of pairs of indices (i, j) such that i < j and the product A_i * A_j is an integer. Constraints: 2 <= N <= 200,000, 0 < A_i < 10^4, A_i is given with at most 9 digits after the decimal. Input is given in the format: N, A_1, A_2, ..., A_N. Output the number of pairs with integer product A_i * A_j (and i < j).", "before_after_length": [246, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02599", "p_user": "u874644572", "n_user": "u874644572", "pos": "I=lambda:map(int,input().split())\nN=0xfffff\nn,q=I()\nc=list(I())\nQ=[]\nR=range\nfor i in R(q):l,r=I();Q.append(l<<40|r<<20|i)\nQ.sort()\nA=[[]for i in R(N)]\nfor i in R(n):A[c[i]].append(i)\nB=[0]*N\ndef P(i,x):\n\ti+=1\n\twhile i<=n:B[i]+=x;i+=i&-i\nfor i in A:\n\tif i:P(i[0],1);i.reverse()\nt=0\no=[0]*q\nfor x in Q:\n\tl=(x>>40)-1\n\tr=x>>20&N\n\ti=x&N\n\twhile t>40-1\n\tr=x>>20&N\n\ti=x&N\n\twhile t+1=10**9 else r)", "neg": "N=int(input())\nXYU=[tuple(input().split()) for _ in range(N)]\nU=[]\nR=[]\nD=[]\nL=[]\nfor x,y,u in XYU:\n x,y = int(x),int(y)\n if u==\"U\":\n U.append((x,y))\n elif u==\"D\":\n D.append((x,y))\n elif u==\"L\":\n L.append((x,y))\n else:\n R.append((x,y))\nr=10**9\ndef z(A):\n global r\n A.sort()\n n=p=-10**9\n for k,c,a in A:\n if k!=n:\n if a==1:\n n=k\n p=c\n continue\n if a==1:\n p=c\n continue\n if (c-p)*5=10**9 else r)", "jacc_sim": 0.9464285714285714, "nl": "M-kun is an air traffic controller. There are N airplanes flying at the same altitude, each with a constant speed and direction. The task is to determine if there are any pairs of airplanes that will collide and, if so, find the number of seconds until the first collision. The input includes the number of airplanes, their current coordinates, and their directions. If there is a collision, the output should be the number of seconds until the collision; otherwise, it should be \"SAFE.\" The constraints are provided for N, the coordinates, and the directions. Sample inputs and outputs are also given to illustrate the problem.", "before_after_length": [469, 471], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u203843959", "n_user": "u203843959", "pos": "import heapq\nT=int(input())\n\nfor _ in range(T):\n N=int(input())\n \n llist=[]\n rlist=[]\n base=0\n for _ in range(N):\n K,L,R=map(int,input().split())\n base+=min(L,R)\n if L>R:\n llist.append((K,L-R))\n elif Li:\n heapq.heappop(hq_left)\n hq_right=[]\n for i,r in rlist:\n heapq.heappush(hq_right,r)\n if len(hq_right)>i:\n heapq.heappop(hq_right)\n \n answer=base\n while hq_left:\n answer+=heapq.heappop(hq_left)\n while hq_right:\n answer+=heapq.heappop(hq_right)\n \n print(answer)", "neg": "import heapq\nT=int(input())\n\nfor _ in range(T):\n N=int(input())\n \n llist=[]\n rlist=[]\n base=0\n for _ in range(N):\n K,L,R=map(int,input().split()) \n if L>R:\n llist.append((K,L-R))\n base+=R\n elif Li:\n heapq.heappop(hq_left)\n hq_right=[]\n for i,r in rlist:\n heapq.heappush(hq_right,r)\n if len(hq_right)>i:\n heapq.heappop(hq_right)\n \n answer=base\n while hq_left:\n answer+=heapq.heappop(hq_left)\n while hq_right:\n answer+=heapq.heappop(hq_right)\n \n print(answer)", "jacc_sim": 0.9791666666666666, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [351, 353], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u520276780", "n_user": "u520276780", "pos": "t=int(input())\nimport heapq\nfor _ in range(t):\n n=int(input())\n L=[];R=[]\n ans=0\n for _ in range(n):\n ki,li,ri = map(int, input().split())\n dif=li-ri\n if dif>=0:\n L.append((ki-1,dif))\n ans+=ri\n else:\n R.append((n-ki-1,-dif))\n ans+=li\n L.sort();R.sort()\n hL=[]\n hR=[]\n for i in range(len(L)):\n if L[i][0]>=len(hL):\n heapq.heappush(hL,L[i][1])\n elif L[i][0]==len(hL)-1:\n heapq.heappushpop(hL,L[i][1])\n for i in range(len(R)):\n if R[i][0]>=len(hR):\n heapq.heappush(hR,R[i][1])\n elif R[i][0]==len(hR)-1:\n heapq.heappushpop(hR,R[i][1])\n print(ans+sum(hL)+sum(hR)) \n \n ", "neg": "t=int(input())\nimport heapq\nfor _ in range(t):\n n=int(input())\n L=[];R=[]\n ans=0\n for _ in range(n):\n ki,li,ri = map(int, input().split())\n dif=li-ri\n if dif>=0:\n L.append((ki-1,-dif))\n ans+=ri\n else:\n R.append((n-ki-1,dif))\n ans+=li\n L.sort();R.sort()\n hL=[]\n hR=[]\n for i in range(len(L)):\n if L[i][0]>len(hL):\n heapq.heappush(hL,L[i][1])\n elif L[i][0]==len(hL):\n heapq.heappushpop(hL,L[i][1])\n for i in range(len(R)):\n if R[i][0]>len(hR):\n heapq.heappush(hR,R[i][1])\n elif L[i][0]==len(hR):\n heapq.heappushpop(hR,R[i][1])\n print(ans-sum(hL)-sum(hR)) \n \n ", "jacc_sim": 1.0, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [330, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u348805958", "n_user": "u348805958", "pos": "#!python3\n\nimport sys\niim = lambda: map(int, sys.stdin.readline().rstrip().split())\nfrom heapq import heappush, heappushpop\n\ndef resolve():\n it = map(int, sys.stdin.read().split())\n\n T = next(it)\n ans = []\n for i in range(T):\n N = next(it)\n\n val = 0; a1 = []; a2 = []\n for i, v1, v2 in ((next(it), next(it), next(it)) for i in range(N)):\n diff = v1 - v2\n if diff == 0:\n val += v1\n elif diff > 0:\n a1.append((i, diff))\n val += v2\n else:\n a2.append((N-i, -diff))\n val += v1\n a1.sort(); a2.sort()\n\n for aa in (a1, a2):\n dq = []\n for i, diff in aa:\n ld = len(dq)\n if ld < i:\n heappush(dq, diff)\n else:\n diff = heappushpop(dq, diff)\n\n val += sum(dq)\n\n ans.append(val)\n\n\n print(*ans, sep=\"\\n\")\n\n\n\nif __name__ == \"__main__\":\n resolve()\n", "neg": "#!python3\n\nimport sys\niim = lambda: map(int, sys.stdin.readline().rstrip().split())\nfrom heapq import heappush, heappushpop\n\ndef resolve():\n it = map(int, sys.stdin.read().split())\n\n T = next(it)\n ans = []\n for i in range(T):\n N = next(it)\n\n val = 0\n a1 = [[] for i in range(N)];\n a2 = [[] for i in range(N)];\n for i, v1, v2 in ((next(it)-1, next(it), next(it)) for i in range(N)):\n diff = v1 - v2\n if diff == 0:\n val += v1\n elif diff > 0:\n a1[i].append(diff)\n val += v2\n else:\n i = N-1-i\n a2[i].append(-diff)\n val += v1\n\n for ax in (a1, a2):\n dq = []\n for i, aa in enumerate(ax):\n if not aa: continue\n for diff in aa:\n ld = len(dq)\n if ld <= i:\n heappush(dq, diff)\n else:\n diff = heappushpop(dq, diff)\n\n val += sum(dq)\n\n ans.append(val)\n\n\n print(*ans, sep=\"\\n\")\n\n\n\nif __name__ == \"__main__\":\n resolve()\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [347, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u729133443", "n_user": "u729133443", "pos": "from heapq import*\ni=input\nfor _ in'_'*int(i()):\n n,s,x,*y=int(i()),0,[]\n for _ in'_'*n:\n k,l,r=map(int,i().split())\n if l>r:x+=(k,l,r),\n else:y+=(n-k,r,l),\n for x in(x,y):\n x.sort();n,*h=len(x),\n while n:\n n-=1\n while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))\n if h:s+=heappop(h)[1]\n for*_,r in x+h:s+=r\n print(s)", "neg": "from heapq import*\ni=input\nfor _ in'_'*int(i()):\n n,s,x,*y=int(i()),0,[]\n for _ in'_'*n:k,l,r=t=[*map(int,i().split())];x+=[t]*(l>r);y+=[(n-k,r,l)]*(ln:k,l,r=x.pop();heappush(h,(r-l,l,r))\n if h:s+=heappop(h)[1]\n for*_,r in x+h:s+=r\n print(s)", "jacc_sim": 0.9361702127659575, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [206, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u490642448", "n_user": "u490642448", "pos": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom heapq import heappop,heappush\n\nt = int(readline())\nq = list(map(int,read().split()))\n\nnow = 0\nans = [0] * t\nfor cyc in range(t):\n n = q[now]\n klr = q[now+1: now+1+3*n]\n now = now+1+3*n\n\n it = iter(klr)\n lc = []\n rc = []\n min_p = 0\n for x,y,z in zip(it,it,it):\n if(y==z):\n min_p += y\n elif(y>z):\n min_p += z\n lc.append((x,y-z))\n else:\n min_p += y\n rc.append((n-x,z-y))\n\n res = min_p\n lc.sort()\n rc.sort()\n\n for cam in [lc,rc]:\n hq = []\n for i in range(n,0,-1):\n if(len(cam)>0):\n while(cam[-1][0] == i):\n x,p = cam.pop()\n heappush(hq,p*-1)\n if(len(cam)==0):\n break\n if(hq):\n res += heappop(hq)*-1\n\n ans[cyc] = res\n\nprint('\\n'.join(map(str,ans)))", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nfrom heapq import heappop,heappush\n\nt = int(readline())\nq = list(map(int,read().split()))\n\nnow = 0\nans = [0] * t\nfor cyc in range(t):\n n = q[now]\n klr = q[now+1: now+1+3*n]\n now = now+1+3*n\n\n it = iter(klr)\n lc = []\n rc = []\n min_p = 0\n for x,y,z in zip(it,it,it):\n if(y==z):\n min_p += y\n elif(y>z):\n min_p += z\n lc.append((x,y-z))\n else:\n min_p += y\n rc.append((n-x,z-y))\n\n res = min_p\n lc.sort()\n rc.sort()\n print(lc)\n\n for cam in [lc,rc]:\n hq = []\n for i in range(n,0,-1):\n if(len(cam)==0):\n continue\n while(cam[-1][0] == i):\n x,p = cam.pop()\n heappush(hq,p*-1)\n if(len(cam)==0):\n break\n if(hq):\n res += heappop(hq)*-1\n\n ans[cyc] = res\n\nprint('\\n'.join(map(str,ans)))", "jacc_sim": 0.9855072463768116, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [400, 409], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02610", "p_user": "u792078574", "n_user": "u792078574", "pos": "from heapq import heappush, heappop\nT = int(input())\n\nfor _ in range(T):\n N = int(input())\n arr1 = []\n arr2 = []\n for _ in range(N):\n K, L, R = list(map(int, input().split()))\n if L > R:\n arr1.append((K, L, R))\n else:\n arr2.append((N-K, R, L))\n\n arr1.sort()\n baseS = 0\n diffS = 0\n q = []\n length = 0\n for K, L, R in arr1:\n baseS += R\n diff = L - R\n heappush(q, diff)\n diffS += diff\n length += 1\n while length > K:\n d = heappop(q)\n diffS -= d\n length -= 1\n ans = baseS + diffS\n\n arr2.sort()\n baseS = 0\n diffS = 0\n q = []\n length = 0\n for K, L, R in arr2:\n baseS += R\n diff = L - R\n heappush(q, diff)\n diffS += diff\n length += 1\n while length > K:\n d = heappop(q)\n diffS -= d\n length -= 1\n ans += baseS + diffS\n print(ans)\n", "neg": "from heapq import heappush, heappop\nT = int(input())\n\ndef process(arr):\n arr.sort()\n baseS = 0\n diffS = 0\n q = []\n length = 0\n for K, L, R in arr1:\n baseS += R\n diff = L - R\n heappush(q, diff)\n diffS += diff\n length += 1\n while length > K:\n d = heappop(q)\n diffS -= d\n length -= 1\n return baseS + diffS\n\nfor _ in range(T):\n N = int(input())\n arr1 = []\n arr2 = []\n for _ in range(N):\n K, L, R = list(map(int, input().split()))\n if L > R:\n arr1.append((K, L, R))\n else:\n arr2.append((N-K, R, L))\n print(process(arr1) + process(arr2))\n", "jacc_sim": 0.9019607843137255, "nl": "You are given a group of camels numbered from 1 to N. Snuke wants to arrange them in a row to maximize their total happiness. Each camel's happiness is determined by its position in the row. For each test case, you need to find the maximum total happiness of the camels. The input consists of T test cases, and the output should contain the answer for each test case. The constraints are that all input values are integers, T is between 1 and 10^5, N is between 1 and 2*10^5, and the sum of N values in each input file is at most 2*10^5. The input format includes the number of test cases followed by the details of each case, and the output format requires printing the answer for each test case.", "before_after_length": [347, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02611", "p_user": "u348805958", "n_user": "u348805958", "pos": "#!python3\n\nimport sys\niim = lambda: map(int, sys.stdin.readline().rstrip().split())\nfrom functools import lru_cache\n\nmod = 10 **9 + 7\n\n\n@lru_cache(100)\ndef calc(n):\n ans = 0\n if n & 1:\n Y = [37033746750,-19102088250,-75258447165,+8922649446,+41082466425,+12030593120,-2592429840,-1880967088,-281252400,+27251510,+15690675,+2549638,+225225,+11620,+330,+4]\n else:\n Y = [0, -98703360000,-108248279040,+4240221696,+40869628800,+12030593120,-2592429840,-1880967088,-281252400,+27251510,+15690675,+2549638,+225225,+11620,+330,+4]\n\n x = 1\n for i, y in enumerate(Y):\n ans = (ans + x*(y%mod) % mod) % mod\n x = x*n%mod\n ans = ans * pow(167382319104000, mod-2, mod) % mod\n return ans\n\ndef resolve():\n it = map(int, sys.stdin.read().split())\n N = next(it)\n\n ans = [0] * N\n for i in range(N):\n n = next(it)\n ans[i] = calc(n)\n\n print(*ans, sep=\"\\n\")\n\nif __name__ == \"__main__\":\n resolve()\n", "neg": "#!python3\n\nimport sys\niim = lambda: map(int, sys.stdin.readline().rstrip().split())\nfrom functools import lru_cache\n\nmod = 10 **9 + 7\n\n\n@lru_cache(100)\ndef calc(n):\n ans = 0\n if n & 1:\n Y = [37033746750,-19102088250,-75258447165,+8922649446,+41082466425,+12030593120,-2592429840,-1880967088,-281252400,+27251510,+15690675,+2549638,+225225,+11620,+330,+4]\n else:\n Y = [0, -98703360000,-108248279040,+4240221696,+40869628800,+12030593120,-2592429840,-1880967088,-281252400,+27251510,+15690675,+2549638,+225225,+11620,+330,+4]\n\n x = 1\n for i, y in enumerate(Y):\n ans = (ans + x*(y%mod) % mod) % mod\n #print(i, y, x)\n x = x*n%mod\n #ans = ans + x * y\n ans = ans * pow(167382319104000, mod-2, mod) % mod\n #ans /= 167382319104000\n return ans\n\ndef resolve():\n it = map(int, sys.stdin.read().split())\n N = next(it)\n\n if N == 4: raise 1\n\n ans = [0] * N\n for i in range(N):\n n = next(it)\n ans[i] = calc(n)\n\n print(*ans, sep=\"\\n\")\n\nif __name__ == \"__main__\":\n resolve()\n", "jacc_sim": 0.9772727272727273, "nl": "You are given an integer N. Snuke selects integers s1, s2, n1, n2, u1, u2, k1, k2, e1, and e2 such that specific conditions are met. For each choice, compute (s2 \u2212 s1)(n2 \u2212 n1)(u2 \u2212 u1)(k2 - k1)(e2 - e1), and find the sum of all computed values modulo (10^9 +7). Solve this for each of the T test cases. Constraints: All input values are integers, 1 \u2264 T \u2264 100, 1 \u2264 N \u2264 10^9. Input format: T followed by T cases, each with N. Output format: T lines, each containing the answer for the corresponding test case.", "before_after_length": [452, 495], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02611", "p_user": "u034128150", "n_user": "u034128150", "pos": "import numpy as np\n\nMOD = 10 ** 9 + 7\n\nl_matrix = np.zeros((32, 32), np.uint64)\nfor i in range(16):\n l_matrix[i+16][i] = 1\n l_matrix[i][i+16] = 1\nfor i in range(15):\n l_matrix[i+1][i] = 1\nfor i in range(5, 15):\n l_matrix[i+1][i+16] = 1\n \ndoubling = [l_matrix] #doubling[i] = (l_matrix) ** (2 ** i) % MOD\nfor _ in range(30):\n doubling.append(doubling[-1] @ doubling[-1] % MOD)\n\nT = int(input())\nfor _ in range(T):\n N = int(input())\n N += 10\n dp = np.zeros(32, np.uint64)\n dp[0] = 1\n for i, c in enumerate(reversed(format(N, 'b'))):\n if c == '1':\n dp = doubling[i] @ dp\n dp %= MOD\n print(int((dp[15] + dp[31]) % MOD))\n #print(dp)\n", "neg": "import numpy as np\n\nMOD = 10 ** 9 + 7\n\nl_matrix = np.zeros((32, 32), np.uint64)\nfor i in range(16):\n l_matrix[i+16][i] = 1\n l_matrix[i][i+16] = 1\nfor i in range(15):\n l_matrix[i+1][i] = 1\nfor i in range(5, 15):\n l_matrix[i+1][i+16] = 1\n \ndoubling = [l_matrix] #doubling[i] = (l_matrix) ** (2 ** i) % MOD\nfor _ in range(30):\n doubling.append(doubling[-1] @ doubling[-1] % MOD)\n\nT = int(input())\nfor _ in range(T):\n N = int(input())\n N += 10\n dp = np.zeros(32, np.uint64)\n dp[0] = 1\n for i, c in enumerate(reversed(format(N, 'b'))):\n if c == '1':\n dp = doubling[i] @ dp\n dp %= MOD\n print((dp[15] + dp[31]) % MOD)\n #print(dp)\n", "jacc_sim": 1.0, "nl": "You are given an integer N. Snuke selects integers s1, s2, n1, n2, u1, u2, k1, k2, e1, and e2 such that specific conditions are met. For each choice, compute (s2 \u2212 s1)(n2 \u2212 n1)(u2 \u2212 u1)(k2 - k1)(e2 - e1), and find the sum of all computed values modulo (10^9 +7). Solve this for each of the T test cases. Constraints: All input values are integers, 1 \u2264 T \u2264 100, 1 \u2264 N \u2264 10^9. Input format: T followed by T cases, each with N. Output format: T lines, each containing the answer for the corresponding test case.", "before_after_length": [304, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u588794534", "n_user": "u588794534", "pos": "n=int(input())\ncc=[int(input()) for _ in range(n)]\n\n\nc=[cc[0]]\nfor i in range(1,n):\n if cc[i]!=cc[i-1]:\n c.append(cc[i])\n\nn=len(c)\n\nright_index=[-1]*n\ntmp_right_index=[-1]*(max(c)+1)\n\nfor i in range(n):\n if tmp_right_index[c[i]]==-1:\n tmp_right_index[c[i]]=i\n else:\n right_index[i]=tmp_right_index[c[i]]\n tmp_right_index[c[i]]=i\n\ndp=[0]*n\nmod=10**9+7\n#print(0,c)\nfor i in range(n):\n if i==0:\n dp[i]=1\n else:\n if right_index[i]==-1:\n dp[i]+=dp[i-1]%mod\n else:\n dp[i]+=dp[i-1]+dp[right_index[i]]%mod\n\nprint(dp[-1]%mod)\n\n\n\n\n\n\n\n \n\n", "neg": "n=int(input())\ncc=[int(input()) for _ in range(n)]\n\n\nc=[cc[0]]\nfor i in range(1,n):\n if cc[i]!=cc[i-1]:\n c.append(cc[i])\n\nn=len(c)\n\nright_index=[-1]*n\ntmp_right_index=[-1]*(max(c)+1)\n\nfor i in range(n):\n if tmp_right_index[c[i]]==-1:\n tmp_right_index[c[i]]=i\n else:\n right_index[i]=tmp_right_index[c[i]]\n tmp_right_index[c[i]]=i\n\ndp=[0]*n\nmod=10**9+7\nprint(0,c)\nfor i in range(n):\n if i==0:\n dp[i]=1\n else:\n if right_index[i]==-1:\n dp[i]+=dp[i-1]%mod\n else:\n dp[i]+=dp[i-1]+dp[right_index[i]]%mod\n\nprint(dp[-1]%mod)\n\n\n\n\n\n\n\n \n\n", "jacc_sim": 0.9743589743589743, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [303, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u706414019", "n_user": "u706414019", "pos": "import sys,math,collections,itertools\ninput = sys.stdin.readline\n\nN = int(input())\nans = 1\nm=10**9+7\nc=[]\nfor _ in range(N):\n c.append(int(input()))\ndp = [1]*(N+1)#dp[i] i\u756a\u76ee\u307e\u3067\u306e\u4e26\u3073\u66ff\u3048\u7dcf\u6570\nlast_color = [-1]*(max(c)+1)#\u6700\u5f8c\u306b\u305d\u306e\u8272\u304c\u51fa\u305findex\u306e\u4fdd\u5b58\nlast_color[c[0]] =0\nfor i in range(1,N):\n if c[i]==c[i-1]:#\u540c\u3058\u8272\u304c\u7d9a\u304f\u3068\u30ea\u30d0\u30fc\u30b7\u3067\u304d\u306a\u3044\n dp[i] = dp[i-1]\n else:\n if last_color[c[i]]==-1:#\u521d\u3081\u3066\u306e\u8272\u306f\u30ea\u30d0\u30fc\u30b7\u3067\u304d\u306a\u3044\n dp[i] = dp[i-1]\n last_color[c[i]]=i\n else:#\u631f\u3081\u308b\u77f3\u304c\u3042\u308b\u3057\u8272\u304c\u9023\u7d9a\u3057\u3066\u306a\u3044\n dp[i] = dp[i-1]+dp[last_color[c[i]]]#\u6700\u5f8c\u306b\u51fa\u305f\u77f3\u3068\u631f\u3080\u304b\u631f\u307e\u306a\u3044k\n last_color[c[i]]=i\nprint(dp[N-1]%m)\n", "neg": "import sys,math,collections,itertools\ninput = sys.stdin.readline\n\nN = int(input())\nans = 1\nm=10**9+7\nc=[]\nfor _ in range(N):\n c.append(int(input()))\ndp = [1]*(N+1)#dp[i] i\u756a\u76ee\u307e\u3067\u306e\u4e26\u3073\u66ff\u3048\u7dcf\u6570\nlast_color = [-1]*(max(c)+1)#\u6700\u5f8c\u306b\u305d\u306e\u8272\u304c\u51fa\u305findex\u306e\u4fdd\u5b58\nlast_color[c[0]] =1\nfor i in range(1,N):\n if c[i]==c[i-1]:#\u540c\u3058\u8272\u304c\u7d9a\u304f\u3068\u30ea\u30d0\u30fc\u30b7\u3067\u304d\u306a\u3044\n dp[i+1] = dp[i]\n else:\n if last_color[c[i]]==-1:#\u521d\u3081\u3066\u306e\u8272\u306f\u30ea\u30d0\u30fc\u30b7\u3067\u304d\u306a\u3044\n dp[i+1] = dp[i]\n last_color[c[i]]=i\n else:#\u631f\u3081\u308b\u77f3\u304c\u3042\u308b\u3057\u8272\u304c\u9023\u7d9a\u3057\u3066\u306a\u3044\n dp[i+1] = dp[i]+dp[last_color[c[i]]]#\u6700\u5f8c\u306b\u51fa\u305f\u77f3\u3068\u631f\u3080\u304b\u631f\u307e\u306a\u3044k\n last_color[c[i]]=i\nprint(dp[N])\n", "jacc_sim": 0.9888888888888889, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [489, 484], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u860002137", "n_user": "u860002137", "pos": "import numpy as np\n\nn = int(input())\ntmp = [int(input()) for _ in range(n)]\n\nc = [tmp[0]]\nfor x in tmp[1:]:\n if x != c[-1]:\n c.append(x)\n\nc = np.array(c)\n\nMOD = 10**9 + 7\n\n# dp\u30c6\u30fc\u30d6\u30eb\ndp = np.zeros(c.shape[0], dtype=np.int64)\ndp[0] = 1\n\nused = np.full(c.max() + 1, -1, dtype=np.int64)\nused[c[0]] = 1\n\nfor i in range(1, c.shape[0]):\n if used[c[i]] == -1:\n dp[i] = dp[i - 1]\n else:\n dp[i] = (dp[i - 1] + dp[used[c[i]]]) % MOD\n used[c[i]] = i\n\nprint(dp[-1])", "neg": "import numpy as np\n\nn = int(input())\nc = np.array([int(input()) for _ in range(n)])\n\nMOD = 10**9 + 7\n\n# dp\u30c6\u30fc\u30d6\u30eb\ndp = np.zeros(n, dtype=np.int64)\ndp[0] = 1\n\nused = np.full(c.max() + 1, -1, dtype=np.int64)\n\nfor i in range(1, n):\n if used[c[i]] == -1:\n dp[i] = dp[i - 1]\n else:\n dp[i] = (dp[i - 1] + dp[used[c[i]]]) % MOD\n used[c[i]] = i\n\nprint(dp[-1])", "jacc_sim": 0.9038461538461539, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [248, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u888337853", "n_user": "u888337853", "pos": "import sys\nimport math\nimport collections\nimport bisect\nimport copy\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n n = ni()\n last = [-1 for _ in range(2 * 10 ** 5 + 1)]\n d = []\n dp = [INF for _ in range(n + 1)]\n dp[0] = 1\n\n prev = -1\n for i in range(n):\n di = ni()\n di -= 1\n if i > 0:\n if prev == di:\n d.append(-1)\n prev = di\n continue\n d.append(di)\n prev = di\n\n for i, di in enumerate(d):\n dp[i + 1] = dp[i]\n if di == -1:\n last[di] = i\n continue\n if last[di] != -1:\n if i - last[di] != -1:\n dp[i + 1] += dp[last[di] + 1]\n dp[i + 1] %= MOD\n last[di] = i\n\n print(dp[n])\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nimport math\nimport collections\nimport bisect\nimport copy\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 9)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n n = ni()\n idxlist = [[] for _ in range(2 * 10 ** 5 + 1)]\n d = []\n dp = [INF for _ in range(n + 1)]\n dp[0] = 1\n\n for i in range(n):\n di = ni()\n di -= 1\n if i > 0:\n if d[-1] == di:\n d.append(-1)\n continue\n d.append(di)\n idxlist[di].append(i)\n\n for i, di in enumerate(d):\n print(i)\n dp[i + 1] = dp[i]\n if di == -1:\n continue\n bidx = bisect.bisect_left(idxlist[di], i)\n if bidx - 1 >= 0:\n dp[i + 1] += dp[idxlist[di][bidx - 1] + 1]\n dp[i + 1] %= MOD\n\n print(dp[n])\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9178082191780822, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [407, 408], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u091051505", "n_user": "u091051505", "pos": "mod = 10 ** 9 + 7\nn = int(input())\nc = [int(input()) for _ in range(n)]\nimport copy\ncc = copy.deepcopy(c)\ncolor_sum = {i: 0 for i in range(10 ** 6)}\ndp = [1 for _ in range(n + 1)]\ncolor_sum[cc[0]] = 1\nfor i in range(2, n + 1):\n dp[i] = dp[i - 1]\n if cc[i - 2] == cc[i - 1]:\n continue\n dp[i] += color_sum[cc[i - 1]]\n dp[i] %= mod\n color_sum[c[i - 1]] += dp[i - 1]\n color_sum[c[i - 1]] %= mod\nprint(dp[n])", "neg": "mod = 10 ** 9 + 7\n\nimport copy\ncc = copy.deepcopy(c)\ncolor_sum = {i: 0 for i in range(10 ** 6)}\ndp = [1 for _ in range(n + 1)]\ncolor_sum[cc[0]] = 1\nfor i in range(2, n + 1):\n dp[i] = dp[i - 1]\n if cc[i - 2] == cc[i - 1]:\n continue\n dp[i] += color_sum[cc[i - 1]]\n dp[i] %= mod\n color_sum[c[i - 1]] += dp[i - 1]\n color_sum[c[i - 1]] %= mod\nprint(dp[n])", "jacc_sim": 0.95, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [194, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u346812984", "n_user": "u346812984", "pos": "import sys\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N = int(input())\n C = [int(input()) for _ in range(N)] + [-1]\n C = [C[i] for i in range(N) if C[i] != C[i + 1]]\n\n N = len(C)\n # dp[i] := i\u500b\u307e\u3067\u306e\u8272\u306e\u5857\u308a\u65b9\u306e\u7dcf\u548c\n dp = [0] * N\n dp[0] = 1\n used = [-1] * (max(C) + 1)\n used[C[0]] = 0\n\n for i in range(1, N):\n if used[C[i]] == -1:\n dp[i] = dp[i - 1]\n else:\n dp[i] = dp[i - 1] + dp[used[C[i]]]\n\n dp[i] %= MOD\n used[C[i]] = i\n\n print(dp[-1])\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N = int(input())\n C = [int(input()) for _ in range(N)] + [None]\n C = [C[i] for i in range(N) if C[i] != C[i + 1]]\n\n N = len(C)\n # dp[i] := i\u500b\u307e\u3067\u306e\u8272\u306e\u5857\u308a\u65b9\u306e\u7dcf\u548c\n dp = [0] * (N + 1)\n dp[0] = 1\n used = [-1] * (max(C) + 1)\n\n for i in range(N):\n if used[C[i]] == -1:\n dp[i + 1] = dp[i]\n else:\n dp[i + 1] = dp[i] + dp[used[C[i]]]\n\n dp[i + 1] %= MOD\n used[C[i]] = i\n\n print(dp[-1])\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9682539682539683, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [316, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u667024514", "n_user": "u667024514", "pos": "MOD = 10**9 + 7\nN = int(input())\nC = [int(input()) for _ in range(N)]\ndp = [0]*(N+1)\nlis = [-1] * (2 * 10**5 + 1)\ndp[0] = 1\nlis[C[0]] = 0\nfor i,c in enumerate(C[1:],1):\n prev_i = lis[c]\n dp[i] = dp[i-1]\n if prev_i != i-1:\n dp[i] += dp[prev_i]\n dp[i] %= MOD\n lis[c] = i\nanswer = dp[N-1]\nprint(answer)", "neg": "MOD = 10**9 + 7\n\nN = int(input())\nC = [int(input()) for _ in range(N)]\n\ndp = [0]*(N+1)\nlis = [-1] * (2 * 10**5 + 1)\ndp[0] = 1\nlis[C[0]] = 0\nfor i,c in enumerate(C[1:],1):\n prev_i = c_to_i[c]\n dp[i] = dp[i-1]\n if prev_i != i-1:\n dp[i] += dp[prev_i]\n dp[i] %= MOD\n lis[c] = i\n\nanswer = dp[N-1]\nprint(answer)\n\n", "jacc_sim": 0.9736842105263158, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [168, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u413165887", "n_user": "u413165887", "pos": "n = int(input())\nc = [int(input()) for _i in range(n)]\nc.append(-1)\ndic = {}\ndp = [0 for _i in range(n+1)]\ndp[n] = 1\nmod = 10**9 +7\nfor i in range(n):\n if c[i-1] != c[i]:\n if c[i] in dic:\n dp[i] = (dp[i-1] + dic[c[i]])%mod\n else:\n dp[i] = dp[i-1]\n dic[c[i]] = dp[i]\n else:\n dp[i] = dp[i-1]\n \nprint(dp[n-1]%mod)", "neg": "n = int(input())\nc = [int(input()) for _i in range(n)]\nc.append(-1)\ndic = {}\ndp = [0 for _i in range(n+1)]\ndp[n] = 1\nmod = 10**9 +7\nfor i in range(n):\n if c[i-1] != c[i]:\n if c[i] in dic:\n dp[i] = (dp[i-1] + dic[c[i]])%mod\n else:\n dp[i] = dp[i-1]\n dic[c[i]] = dp[i-1]\n else:\n dp[i] = dp[i-1]\n \nprint(dp[n-1])", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [180, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u678167152", "n_user": "u678167152", "pos": "from collections import defaultdict\nfrom bisect import *\ndef solve():\n mod = 10**9+7\n d = defaultdict(lambda: [])\n N = int(input())\n for i in range(N):\n a = int(input())\n d[a].append(i)\n selist = []\n ends = [-1]\n for l in d.values():\n for i in range(len(l)-1):\n if l[i+1]-1>l[i]:\n selist.append([l[i],l[i+1]])\n ends.append(l[i+1])\n selist = [[-1,-1]]+sorted(selist,key=lambda x:x[1])\n # s_ind = {}\n # for i,(s,e) in enumerate(selist):\n # e_ind[e] = i\n # ends = list(e_ind.keys())\n ends.sort()\n dp = [0]*(len(selist))\n for i in range(1,len(selist)):\n dp[i] = dp[i-1]+1\n ind = bisect_right(ends,selist[i][0])\n dp[i] += dp[ind-1]\n ans = dp[-1]+1\n ans %= mod\n return ans\nprint(solve())", "neg": "from collections import defaultdict\nfrom bisect import *\ndef solve():\n d = defaultdict(lambda: [])\n N = int(input())\n for i in range(N):\n a = int(input())\n d[a].append(i)\n selist = []\n ends = [-1]\n for l in d.values():\n for i in range(len(l)-1):\n if l[i+1]-1>l[i]:\n selist.append([l[i],l[i+1]])\n ends.append(l[i+1])\n selist = [[-1,-1]]+sorted(selist,key=lambda x:x[1])\n # s_ind = {}\n # for i,(s,e) in enumerate(selist):\n # e_ind[e] = i\n # ends = list(e_ind.keys())\n ends.sort()\n dp = [0]*(len(selist))\n for i in range(1,len(selist)):\n dp[i] = dp[i-1]+1\n ind = bisect_right(ends,selist[i][0])\n dp[i] += dp[ind-1]\n ans = dp[-1]+1\n ans %= mod\n return ans\nprint(solve())", "jacc_sim": 0.9523809523809523, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [325, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u814986259", "n_user": "u814986259", "pos": "import sys\ninput=sys.stdin.readline\nN=int(input())\nC=[int(input())]\nfor i in range(N-1):\n tmp=int(input())\n if tmp != C[-1]:\n C.append(tmp)\n \nimport collections\ntable=collections.defaultdict(int)\nN=len(C)\ndp=[0]*(N+1)\ndp[N]=1\nmod=10**9 + 7\nfor i,x in enumerate(C[::-1]):\n dp[N-1-i]=dp[N-i] + table[x] \n dp[N-1-i]%=mod\n table[x]+=dp[N-i]\nprint(dp[0])", "neg": "import sys\ninput=sys.stdin.readline\nN=int(input())\nC=[int(input())]\nfor i in range(N-1)\n tmp=int(input())\n if tmp != C[-1]:\n C.append(tmp)\n \nimport collections\ntable=collections.defaultdict(list)\nN=len(C)\ndp=[0]*(N+1)\ndp[N]=1\nmod=10**9 + 7\nfor i,x in enumerate(C[::-1]):\n dp[N-1-i]=dp[N-i]\n for y in table[x]:\n dp[N-1-i]+=dp[y+1]\n dp[N-1-i]%=mod\n table[x].append(N-1-i)\n\nprint(dp[0])\n", "jacc_sim": 0.9545454545454546, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [178, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u263830634", "n_user": "u263830634", "pos": "import sys\ninput = sys.stdin.readline\n\nINF = 10 ** 9\nMOD = 10 **9 + 7\n\nN = int(input())\n\nC = [int(input()) for _ in range(N)]\nlst = [INF] * (2 * 10 ** 5 + 10) #\u5404\u756a\u53f7\u304c\u3069\u3053\u306b\u3042\u308b\u304b\u3092\u7ba1\u7406\u3059\u308b\u30ea\u30b9\u30c8\nans = [1] * N\n \nlst[C[-1]] = N - 1\n\nfor i in range(N - 2, -1, -1):\n c = C[i]\n if lst[c] == INF or lst[c] == i + 1:\n ans[i] = ans[i + 1]\n else:\n ans[i] = ans[i + 1] + ans[lst[c]]\n lst[c] = i\n\n# print (ans)\nprint (ans[0] % MOD)", "neg": "import sys\ninput = sys.stdin.readline\n\nINF = 10 ** 9\nMOD = 10 **9 + 7\n\nN = int(input())\n\nC = [int(input()) for _ in range(N)]\nlst = [INF] * (2 * 10 ** 5 + 10) #\u5404\u756a\u53f7\u304c\u3069\u3053\u306b\u3042\u308b\u304b\u3092\u7ba1\u7406\u3059\u308b\u30ea\u30b9\u30c8\nans = [1] * N\n \nlst[C[-1]] = N - 1\n\nfor i in range(N - 2, -1, -1):\n c = C[i]\n if lst[c] == INF or lst[c] == i + 1:\n ans[i] = ans[i + 1]\n else:\n ans[i] = ans[i + 1] + ans[lst[c]]\n lst[c] = i\n\nprint (ans)\nprint (ans[0] % MOD)", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [248, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u366959492", "n_user": "u366959492", "pos": "nn=int(input())\nimport sys\ninput=sys.stdin.readline\ncc=[int(input()) for _ in range(nn)]\nc=[cc[0]]\nfor i in range(1,nn):\n if cc[i]!=c[-1]:\n c.append(cc[i])\nn=len(c)\nmod=10**9+7\ndp=[0]*(n+1)\nsm=[0]*(max(c)+1)\ndp[0]=1\nfor i in range(n):\n x=c[i]\n dp[i+1]+=sm[x]+dp[i]\n sm[x]+=dp[i]\n dp[i]%=mod\n dp[i+1]%=mod\nprint(dp[n])\n", "neg": "nn=int(input())\nimport sys\ninput=sys.stdin.readline\ncc=[int(input()) for _ in range(n)]\nc=[cc[0]]\nfor i in range(1,nn):\n if cc[i]!=c[-1]:\n c.append(cc[i])\nn=len(c)\nmod=10**9+7\ndp=[0]*(n+1)\nsm=[0]*(max(c)+1)\ndp[0]=1\nfor i in range(n):\n x=c[i]\n dp[i+1]+=sm[x]+dp[i]\n sm[x]+=dp[i]\n dp[i]%=mod\n dp[i+1]%=mod\nprint(dp[n])\n", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [188, 188], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u315485238", "n_user": "u315485238", "pos": "N = int(input())\nC = [int(input()) for _ in range(N)]\nmod = int(1e9+7)\n\nfrom itertools import groupby\nx = [0] + [k for k, g in groupby(C)]\n\ndp = [0]*(len(x)) # i\u500b\u76ee\u307e\u3067\u3067\u4f55\u901a\u308a\u3042\u308b\u304b\ndp[0] = 1\nmemo = {}\n\nfor i in range(1, len(x)):\n c = x[i]\n memo[c] = (memo.get(c,0) + dp[i-1])%mod\n dp[i] = memo[c]\n\nprint(dp[-1])", "neg": "N = int(input())\nC = [int(input()) for _ in range(N)]\n\nfrom itertools import groupby\nx = [0] + [k for k, g in groupby(C)]\n\ndp = [0]*(len(x)) # i\u500b\u76ee\u307e\u3067\u3067\u4f55\u901a\u308a\u3042\u308b\u304b\ndp[0] = 1\nmemo = {}\n\nfor i in range(1, len(x)):\n c = x[i]\n dp[i] = dp[i-1] + memo.get(c, 0)\n memo[c] = dp[i-1]\n\nprint(dp[-1])\n", "jacc_sim": 0.9230769230769231, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [180, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u560889512", "n_user": "u560889512", "pos": "n=int(input())\narr=[int(input()) for _ in range(n)]\nmod=10**9+7\n\ndp=[0]*n\ndp[0]=1\n\nrecord={arr[0]:0}\n\nfor i,v in enumerate(arr):\n if i==0:\n continue\n dp[i]=dp[i-1]\n if v in record and record[v]= N:\n return\n else:\n raise Exception()\n if prev >= 0 and prev < i - 1:\n pairs.append((prev, i))\n last[c - 1] = i\n pairs.sort()\n count = [0] * N\n count[0] = 1\n idx = 0\n for i in range(N):\n if i > 0:\n count[i] += count[i - 1]\n count[i] %= MOD\n while idx < len(pairs) and pairs[idx][0] == i:\n count[pairs[idx][1]] += count[i]\n count[pairs[idx][1]] %= MOD\n idx += 1\n print(count[N - 1])\n return\n\n\n# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n C = [ int(next(tokens)) for _ in range(N) ] # type: \"List[int]\"\n solve(N, C)\n\nif __name__ == '__main__':\n main()\n", "neg": "#!/usr/bin/env python3\nimport sys\n\nMOD = 1000000007 # type: int\n\ndef solve(N, C):\n last = [-1] * N\n pairs = []\n for i, c in enumerate(C):\n prev = last[c - 1]\n if prev >= 0 and prev < i - 1:\n pairs.append((prev, i))\n last[c - 1] = i\n print(0)\n pairs.sort()\n count = [0] * N\n count[0] = 1\n idx = 0\n for i in range(N):\n if i > 0:\n count[i] += count[i - 1]\n count[i] %= MOD\n while idx < len(pairs) and pairs[idx][0] == i:\n count[pairs[idx][1]] += count[i]\n count[pairs[idx][1]] %= MOD\n idx += 1\n print(count[N - 1])\n return\n\n\n# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n C = [ int(next(tokens)) for _ in range(N) ] # type: \"List[int]\"\n solve(N, C)\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9263157894736842, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [426, 396], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u187205913", "n_user": "u187205913", "pos": "n = int(input())\nc = [0] + [int(input()) for _ in range(n)]\ndp = [0] * (200001)\nnum = 1\nfor i in range(n):\n if c[i]!=c[i+1]:\n num += dp[c[i+1]]\n dp[c[i+1]] = num\nprint(num%(10**9+7))", "neg": "n = int(input())\nc = [0] + [int(input()) for _ in range(200001)]\ndp = [0] * (n+1)\nnum = 1\nfor i in range(n):\n if c[i]!=c[i+1]:\n num += dp[c[i+1]]\n dp[c[i+1]] = num\nprint(num%(10**9+7))", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [99, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u013408661", "n_user": "u013408661", "pos": "import sys\nn=int(input())\nc=[int(i) for i in sys.stdin]\n#\u9023\u7d9a\u3057\u305f\u6570\u3092\u9664\u53bb\u3057\u305flist\nd=[]\n#\u524d\u306e\u6570\u3092\u4fdd\u5b58\u3059\u308b\u5909\u6570\nstack=0\nfor i in c:\n if i!=stack:\n d.append(i)\n stack=i\n#0\u3067\u521d\u671f\u5316\nx=[0]*200001\nsum=1\np=10**9+7\nfor i in range(0,len(d)):\n x[d[i]]= (x[d[i]]+sum)%p\n sum=x[d[i]]%p\nprint(sum)", "neg": "import sys\nn=int(input())\nc=[int(i) for i in sys.stdin]\n#\u9023\u7d9a\u3057\u305f\u6570\u3092\u9664\u53bb\u3057\u305flist\nd=[]\n#\u524d\u306e\u6570\u3092\u4fdd\u5b58\u3059\u308b\u5909\u6570\nstack=0\nfor i in c:\n if i!=stack:\n d.append(i)\n stack=i\n#0\u3067\u521d\u671f\u5316\nx=[0]*200001\nsum=1\nfor i in range(1,len(d)):\n x[d[i]]+= sum\n sum=x[d[i]]\nprint(sum)", "jacc_sim": 0.9152542372881356, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [209, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u013408661", "n_user": "u013408661", "pos": "import sys\nn=int(input())\nc=[int(i) for i in sys.stdin]\nx=[0]*(200001)\nc.append(0)\nx[c[0]]+= 1\nnum=1\np=10**9 +7\nfor i in range(1,n):\n if c[i]-c[i-1]:\n x[c[i]]+= num\n x[c[i]]= x[c[i]]%p\n if c[i]-c[i+1]:\n num=x[c[i]]%p\n else:\n num=0\nprint(num)", "neg": "import sys\nn=int(input())\nc=[int(i) for i in sys.stdin]\nx=[0]*(200001)\nc.append(0)\nx[c[0]]+= 1\nnum=1\np=10**9 +7\nfor i in c:\n if c[i]-c[i-1]:\n x[c[i]]+= num\n x[c[i]]= x[c[i]]%p\n if c[i]-c[i+1]:\n num=x[c[i]]\n else:\n num=0\nprint(num)", "jacc_sim": 0.9444444444444444, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [154, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u572144347", "n_user": "u572144347", "pos": "N=int(input()) \nclist=[-1]\nmod=10**9+7\n\nfor i in range(N):\n t=int(input())\n if t==clist[-1]:\n continue\n clist.append(t)\n\ndel clist[0]\nN = len(clist)\n\n# print(clist)\ncolorlast=[-1]*(3*10**5)\nposlp=[-1]*(N+1)\n\nfor e,c in enumerate(clist,1):\n if colorlast[c] != -1:\n poslp[e]=colorlast[c]\n colorlast[c]=e\n else:\n colorlast[c]=e\n\n\ndp=[0]*(N+100)\ndp[0]=1\n\nfor e,c in enumerate(clist,1):\n if poslp[e]==-1:\n dp[e]=(dp[e-1])%mod\n else:\n dp[e]=(dp[e-1]+dp[poslp[e]])%mod\n\n# print(dp[:len(clist)+1])\nprint(dp[len(clist)]%mod)\n \n\n", "neg": "N=int(input()) \nclist=[-1]\nmod=10**9+7\nfor i in range(N):\n t=int(input())\n if t==clist[-1]:\n continue\n clist.append(t)\n \ncolorlast=[-1]*(3*10**5)\nposlp=[-1]*(N+2)\n\nfor e,c in enumerate(clist,1):\n if colorlast[c]!=-1:\n poslp[e]=colorlast[c]\n colorlast[c]=e\n else:\n colorlast[c]=e\n\ndp=[0]*(N+1)\ndp[0]=1\nfor e,c in enumerate(clist,1):\n if poslp[e]!=-1:\n dp[e]=(dp[e-1])%mod\n else:\n dp[e]=(dp[e-1]+dp[poslp[e]])%mod\nprint(dp[len(clist)]%mod)\n \n", "jacc_sim": 0.9130434782608695, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [293, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u375616706", "n_user": "u375616706", "pos": "N = int(input())\nC = [-1]\n\nfor _ in range(N):\n c = int(input())\n if c == C[-1]:\n continue\n else:\n C.append(c)\n\nMOD = 10**9+7\ndp = 1\nprev = [0]*(max(C)+1)\n\nfor c in C[1:]:\n dp = (dp+prev[c]) % MOD\n prev[c] = dp\nprint(dp)\n", "neg": "N = int(input())\nC = [-1]\n\nfor _ in range(N):\n c = int(input())\n if c == C[-1]:\n continue\n else:\n C.append(c)\n\nMOD = 10**9+7\ndp = 1\nprev = [0]*(max(C)+1)\n\nfor c in enumerate(C[1:]):\n dp = (dp+prev[c]) % MOD\n prev[c] = dp\nprint(dp)\n", "jacc_sim": 0.9714285714285714, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [116, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u404459933", "n_user": "u404459933", "pos": "import sys\n\n\ndef tran(A):\n temp = []\n for i in range(len(A)):\n if i == 0:\n temp += [A[i]]\n elif A[i] != A[i - 1]:\n temp += [A[i]]\n return temp\n\n\ndef find(A):\n # assume consecutive elements\n dp = [1] * len(A) + [1]\n\n current_dic = {}\n\n MOD = 10**9 + 7\n\n for i in range(len(A)):\n\n if i == 0:\n current_dic[A[i]] = 1\n else:\n temp = dp[i - 1]\n if A[i] in current_dic:\n temp += current_dic[A[i]]\n temp %= MOD\n current_dic[A[i]] += dp[i - 1]\n current_dic[A[i]] %= MOD\n else:\n current_dic[A[i]] = dp[i - 1]\n\n dp[i] = temp\n # print(dp)\n return dp[-2] % MOD\n\n\nN = int(input())\nA = []\nfor i in range(N):\n A += [int(input())]\n\n\n\nprint(find(tran(A)))\n", "neg": "import sys\n\n\ndef tran(A):\n temp = []\n for i in range(len(A)):\n if i == 0:\n temp += [A[i]]\n elif A[i] != A[i - 1]:\n temp += [A[i]]\n return temp\n\n\ndef find(A):\n # assume consecutive elements\n dp = [1] * len(A) + [1]\n\n current_dic = {}\n\n MOD = 10**9 + 7\n\n for i in range(len(A)):\n\n if i == 0:\n current_dic[A[i]] = [i]\n else:\n temp = dp[i - 1]\n if A[i] in current_dic:\n for x in current_dic[A[i]]:\n temp += dp[x - 1]\n temp %= MOD\n current_dic[A[i]] += [i]\n else:\n current_dic[A[i]] = [i]\n\n dp[i] = temp\n print(dp)\n return dp[-2] % MOD\n\n\n\n\nN=int(input())\nA=[]\nfor i in range(N):\n A+=[int(input())]\n\nprint(find(tran(A)))", "jacc_sim": 0.9787234042553191, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [313, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u940990031", "n_user": "u940990031", "pos": "N = int(input())\nC = [int(input()) for _ in range(N)]\nC = [x for (x,y) in zip(C[:-1], C[1:]) if x!=y] + [C[-1]]\n\nSUM = 1\nDP_dict = {}\n\nfor c in C:\n if c in DP_dict.keys():\n SUM += DP_dict[c]\n DP_dict[c] = SUM\n\nprint(SUM % (10**9+7))", "neg": "N = int(input())\nC = [int(input()) for _ in range(N)]\nC = [x for (x,y) in zip(C[:-1], C[1:]) if x!=y] + [C[-1]]\n\nSUM = 1\nDP_dict = {}\n\nfor c in C:\n if c in DP_dict.keys():\n SUM += DP_dict[c] = SUM\n DP_dict[c] = SUM\n\nprint(SUM % (10**9+7))", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [122, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u326609687", "n_user": "u326609687", "pos": "import sys\n\nN = int(input())\nC = [0]\nfor line in sys.stdin:\n c = int(line)\n if C[-1] == c:\n continue\n else:\n C.append(c)\n\nans = 1\ndic = {}\nfor c in C:\n if c in dic.keys():\n a = dic[c]\n dic[c] += ans\n ans += a\n else:\n dic[c] = ans\n\nprint(ans % (10 ** 9 + 7))", "neg": "import sys\n\nN = int(input())\nC = [0]\nfor line in sys.stdin:\n c = int(line)\n if c[-1] == c:\n continue\n else:\n C.append(c)\n\nans = 1\ndic = {}\nfor c in C:\n if c in dic.keys():\n a = dic[c]\n dic[c] += ans\n ans += a\n else:\n dic[c] = ans\n\nprint(ans % (10 ** 9 + 7))", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [127, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u757446793", "n_user": "u757446793", "pos": "# coding: utf-8\n# Your code here!\n\nN = int(input())\nC = []\n\nprev = -1\n\nfor _ in range(N):\n tmp = int(input())\n if tmp != prev:\n C.append(tmp)\n prev = tmp\n\ndp = [0]*(len(C)+1)\nplace = {}\ndp[0] = 1\n\nfor i in range(len(C)):\n if place.get(C[i]) != None:\n dp[i+1] = dp[i] + dp[place.get(C[i])]\n else:\n dp[i+1] = dp[i]\n place[C[i]] = i+1\n \nprint(dp[-1]%(10**9+7))", "neg": "# coding: utf-8\n# Your code here!\n\nN = int(input())\nC = []\n\nprev = -1\n\nfor _ in range(N):\n tmp = int(input())\n if tmp != prev:\n C.append(tmp)\n prev = tmp\n\ndp = [0]*(len(C)+1)\nplace = {}\ndp[0] = 1\n\nfor i in range(len(C)):\n if place.get(C[i]) != None:\n dp[i+1] = dp[i] + dp[place.get(C[i])]\n else:\n dp[i+1] = dp[i]\n place[C[i]] = i+1\n print(dp)\n \nprint(dp[-1]%(10**9+7))", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [188, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\ndef main():\n N = II()\n C = []\n for _ in range(N):\n c = II()\n if len(C) == 0 or c != C[-1]:\n C.append(c)\n global ans\n ans = 0\n dp = [1] + [0] * N\n from collections import defaultdict\n cnt_clr = defaultdict(int)\n for i, c in enumerate(C):\n ret = dp[i]\n ret += cnt_clr[c]\n cnt_clr[c] = ret\n dp[i + 1] = ret % MOD\n\n ans = dp[len(C)]\n\n return ans % MOD\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\ndef main():\n N = II()\n C = []\n for _ in range(N):\n c = II()\n if len(C) == 0 or c != C[-1]:\n C.append(c)\n global ans\n ans = 0\n dp = [1] + [0] * N\n from collections import defaultdict\n idxs = defaultdict(list)\n for i, c in enumerate(C):\n ret = dp[i]\n if c in idxs.keys():\n for j in idxs[c]:\n ret += dp[j]\n dp[i + 1] = ret % MOD\n idxs[c].append(i)\n\n ans = dp[N]\n\n return ans % MOD\n\nprint(main())", "jacc_sim": 0.9242424242424242, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [305, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u925364229", "n_user": "u925364229", "pos": "N = int(input())\nC = [0] * N\nmod = 10 ** 9 + 7\ndic = [-1]*(2*(10**5)+1)\nprevIdx = [0] * N\nfor i in range(N):\n C[i] = int(input())\n if i > 0 and C[i] == C[i-1]:\n continue\n prevIdx[i] = dic[C[i]]\n dic[C[i]] = i\n\ndp = [0] * N\ndp[0] = 1\nacc = [0] * N\nacc[0] = 1\nfor i in range(1,N):\n dp[i] = dp[i-1] % mod\n if C[i] == C[i-1] or prevIdx[i] == -1:\n acc[i] = dp[i-1]\n continue\n \n dp[i] += acc[prevIdx[i]]\n acc[i] = acc[prevIdx[i]] + dp[i-1]\n acc[i] %= mod\n dp[i] %= mod\n\nprint(dp[N-1] % mod)", "neg": "N = int(input())\nC = [0] * N\nmod = 10 ** 9 + 7\ndic = [-1]*(2*(10**5)+1)\nprevIdx = [0] * N\nfor i in range(N):\n C[i] = int(input())\n if i > 0 and C[i] == C[i-1]:\n continue\n prevIdx[i] = dic[C[i]]\n dic[C[i]] = i\n\ndp = [0] * N\ndp[0] = 1\nacc = [0] * N\nacc[0] = 1\nfor i in range(1,N):\n dp[i] = dp[i-1] % mod\n if C[i] == C[i-1] or prevIdx[i] == -1:\n acc[i] = 1\n continue\n \n dp[i] += acc[prevIdx[i]]\n acc[i] = acc[prevIdx[i]] + dp[i-1]\n acc[i] %= mod\n dp[i] %= mod\n\nprint(dp[N-1] % mod)", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [272, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u955251526", "n_user": "u955251526", "pos": "n = int(input())\nz = []\npre = 0\nfor _ in range(n):\n i = int(input())\n if i != pre:\n z.append(i)\n pre = i\nn = len(z)\ndp = [1] * (n+1)\ndpp = [0] * 2 * 10 ** 5\nfor i in range(n):\n dp[i+1] = dp[i] + dpp[z[i]-1]\n dpp[z[i]-1] += dp[i]\n dp[i+1] %= 10 ** 9 + 7\nprint(dp[n])", "neg": "n = int(input())\nz = []\npre = 0\nfor _ in range(n):\n i = int(input())\n if i != pre:\n z.append(i)\n pre = i\nn = len(z)\ndp = [1] * (n+1)\ndpp = [0] * 2 * 10 ** 5\nfor i in range(n):\n dp[i+1] = dp[i] + dpp[z[i]-1]\n dpp[z[i]-1] += dp[i+1]\n dp[i+1] %= 10 ** 9 + 7\nprint(dp[n])", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [152, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u297109012", "n_user": "u297109012", "pos": "def solve(N, Cs):\n counts = [-1 for _ in Cs] + [1]\n latest_c = {}\n ans = 1\n d = 10 ** 9 + 7\n for i, c in enumerate(Cs):\n if c not in latest_c:\n latest_c[c] = i\n counts[i] = ans\n else:\n previous_i = latest_c[c]\n if previous_i != i - 1:\n ans += counts[previous_i]\n latest_c[c] = i\n counts[i] = ans\n return ans % d\n\nif __name__ == \"__main__\":\n N = int(input())\n Cs = [int(input()) for _ in range(N)]\n print(solve(N, Cs))\n", "neg": "def solve(N, Cs):\n counts = [-1 for _ in Cs] + [1]\n latest_c = {}\n ans = 1\n d = 10**9 + 7\n for i, c in enumerate(Cs):\n if c not in latest_c:\n latest_c[c] = i\n counts[i] = ans\n else:\n previous_i = latest_c[c]\n if previous_i != i - 1:\n ans += counts[previous_i - 1]\n ans %= d\n latest_c[c] = i\n counts[i] = ans\n return ans % d\n\nif __name__ == \"__main__\":\n N = int(input())\n Cs = [int(input()) for _ in range(N)]\n print(solve(N, Cs))\n", "jacc_sim": 1.0, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [193, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03096", "p_user": "u631277801", "n_user": "u631277801", "pos": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter, defaultdict\n\ndef compress(s):\n ret = []\n for i, si in enumerate(s):\n if i == 0:\n ret.append(si)\n else:\n if si == ret[-1]:\n continue\n else:\n ret.append(si)\n \n return ret\n\ndef removeonly1(s):\n cnt = Counter(s)\n ret = []\n \n for si in s:\n if cnt[si] == 1:\n continue\n else:\n ret.append(si)\n \n return ret\n\nn = ni()\nc = [ni() for _ in range(n)]\nMOD = 10**9+7\n\ncolors = removeonly1(compress(c))\n\n\ndp = [0 for _ in range(len(colors)+1)]\n\ndp[0] = 1\nidxs = defaultdict(list)\nkeys = set()\n\nfor i, ci in enumerate(colors):\n dp[i+1] = dp[i]\n \n if ci in keys:\n dp[i+1] += dp[idxs[ci][-1]+1]\n dp[i+1] %= MOD\n \n idxs[ci].append(i)\n keys.add(ci)\n \nprint(dp[len(colors)])\n ", "neg": "import sys\nstdin = sys.stdin\n \nsys.setrecursionlimit(10**5) \n \ndef li(): return map(int, stdin.readline().split())\ndef li_(): return map(lambda x: int(x)-1, stdin.readline().split())\ndef lf(): return map(float, stdin.readline().split())\ndef ls(): return stdin.readline().split()\ndef ns(): return stdin.readline().rstrip()\ndef lc(): return list(ns())\ndef ni(): return int(stdin.readline())\ndef nf(): return float(stdin.readline())\n\nfrom collections import Counter, defaultdict\n\ndef compress(s):\n ret = []\n for i, si in enumerate(s):\n if i == 0:\n ret.append(si)\n else:\n if si == ret[-1]:\n continue\n else:\n ret.append(si)\n \n return ret\n\ndef removeonly1(s):\n cnt = Counter(s)\n ret = []\n \n for si in s:\n if cnt[si] == 1:\n continue\n else:\n ret.append(si)\n \n return ret\n\nn = ni()\nc = [ni() for _ in range(n)]\nMOD = 10**9+7\n\ncolors = removeonly1(compress(c))\n\n\ndp = [0 for _ in range(len(colors)+1)]\n\ndp[0] = 1\nidxs = defaultdict(list)\n\nfor i, ci in enumerate(colors):\n dp[i+1] = dp[i]\n \n if ci in idxs.keys():\n dp[i+1] += dp[idxs[ci][-1]]\n dp[i+1] %= MOD\n \n idxs[ci].append(i)\n \nprint(dp[len(colors)])", "jacc_sim": 0.9726027397260274, "nl": "You are given a row of stones, each painted in a specific color. You can choose two stones of the same color and repaint all the stones between them with that color. Find the number of possible final sequences of colors of the stones, modulo 10^9+7. The input consists of the number of stones and their respective colors. Output the number of possible final sequences of colors of the stones.", "before_after_length": [453, 438], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03097", "p_user": "u415905784", "n_user": "u415905784", "pos": "N, A, B = map(int, input().split())\nAB = A ^ B\nD = bin(AB)[2:].count('1')\nif D % 2 == 0:\n print('NO')\nelse:\n print('YES')\n C = [0] * (2 ** N)\n C[0] = str(A)\n P = []\n for i in range(N):\n if AB % 2:\n P = P + [i]\n else:\n P = [i] + P\n AB >>= 1\n for i in range(1, 2 ** N):\n k = 0\n b = i\n while b % 2 == 0:\n k += 1\n b >>= 1\n A ^= 1 << P[k]\n C[i] = str(A)\n k = 0\n for i in range(D // 2):\n k += 1 / (4 ** (i + 1))\n K = int(2 ** N * (1 - k))\n C = C[:K-1] + C[K+1:] + C[K-1:K+1][::-1]\n print(' '.join(C))", "neg": "N, A, B = map(int, input().split())\nAB = A ^ B\nD = bin(AB)[2:].count('1')\nif D % 2 == 0:\n print('NO')\nelse:\n print('YES')\n C = [0] * (2 ** N)\n C[0] = str(A)\n P = []\n for i in range(N):\n if AB % 2:\n P = [i] + P\n else:\n P = P + [i]\n AB >>= 1\n for i in range(1, 2 ** N):\n k = 0\n b = i\n while b % 2 == 0:\n k += 1\n b >>= 1\n A ^= 1 << P[k]\n C[i] = str(A)\n k = 0\n for i in range(D // 2):\n k += 1 / (4 ** (i + 1))\n K = int(2 ** N * (1 - k))\n C = C[:K-1] + C[K+1:] + C[K-1:K+1][::-1]\n print(' '.join(C))", "jacc_sim": 1.0, "nl": "You are given integers N, A, and B. Determine if there exists a permutation (P_0, P_1, ..., P_{2^N-1}) of (0, 1, ..., 2^N-1) such that P_0 = A, P_{2^N-1} = B, and for all 0 \u2264 i < 2^N-1, the binary representations of P_i and P_{i+1} differ by exactly one bit. If such a permutation exists, provide one such permutation. Constraints: 1 \u2264 N \u2264 17, 0 \u2264 A, B \u2264 2^N-1, A \u2260 B, and all input values are integers. Input is given as N A B. If there is no permutation that satisfies the conditions, print \"NO\". If there is such a permutation, print \"YES\" in the first line, followed by the permutation (P_0, P_1, ..., P_{2^N-1}) in the second line, with spaces in between. If there are multiple solutions, any of them is accepted. Example: Input: 2 1 3, Output: YES 1 0 2 3.", "before_after_length": [278, 278], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03098", "p_user": "u562016607", "n_user": "u562016607", "pos": "N,K=map(int,input().split())\np=[int(i)-1 for i in input().split()]\nq=[int(i)-1 for i in input().split()]\ndef inv(seq):\n res=[0 for i in range(N)]\n for i in range(N):\n res[seq[i]]=i\n return res\ndef times(seq1,seq2):\n res=[0 for i in range(N)]\n for i in range(N):\n res[i]=seq1[seq2[i]]\n return res\nmd=[[0 for i in range(N)] for i in range(6)]\nfor i in range(N):\n md[0][i]=p[i]\n md[1][i]=q[i]\nfor i in range(2,6):\n md[i]=times(md[i-1],inv(md[i-2]))\nA=times(times(times(q,inv(p)),inv(q)),p)\nT=(K-1)//6\ndef expseq(seq,k):\n if k==0:\n return [i for i in range(N)]\n elif k==1:\n return seq\n elif k%2==0:\n return expseq(times(seq,seq),k//2)\n else:\n return times(expseq(times(seq,seq),k//2),seq)\ntmp=expseq(A,T)\nans=times(times(tmp,md[(K-1)%6]),inv(tmp))\nprint(\" \".join([str(i+1) for i in ans]))\n", "neg": "N,K=map(int,input().split())\np=[int(i)-1 for i in input().split()]\nq=[int(i)-1 for i in input().split()]\ndef inv(seq):\n res=[0 for i in range(N)]\n for i in range(N):\n res[seq[i]]=i\n return seq\ndef times(seq1,seq2):\n res=[0 for i in range(N)]\n for i in range(N):\n res[i]=seq1[seq2[i]]\n return res\nmd=[[0 for i in range(N)] for i in range(6)]\nfor i in range(N):\n md[0][i]=p[i]\n md[1][i]=q[i]\nfor i in range(2,6):\n md[i]=times(md[i-1],inv(md[i-2]))\nA=times(times(q,inv(p)),times(inv(q),p))\nT=(K-1)//6\ndef expseq(seq,k):\n if k==0:\n return [i for i in range(N)]\n elif k==1:\n return seq\n elif k%2==0:\n return expseq(times(seq,seq),k//2)\n else:\n return times(expseq(times(seq,seq),k//2),seq)\ntmp=expseq(A,T)\nans=times(times(tmp,md[(K-1)%6]),inv(tmp))\nprint(\" \".join([str(i+1) for i in ans]))\n", "jacc_sim": 1.0, "nl": "You are given two permutations p and q of integers from 1 to N. Define a sequence {a_n} of permutations of integers from 1 to N as follows: a_1=p, a_2=q, a_{n+2}=f(a_n,a_{n+1}) (n\u22651). Given a positive integer K, find a_K. Constraints: 1\u2264N\u226410^5, 1\u2264K\u226410^9, p and q are permutations of integers from 1 to N. Input: N K p_1 ... p_N q_1 ... q_N. Output: N integers, with spaces in between. The i-th integer (1\u2264i\u2264N) should be the i-th element in a_K.", "before_after_length": [393, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u780698286", "n_user": "u520276780", "pos": "from math import gcd\n\nn = int(input())\na = list(map(int, input().split()))\nans = a[0]\nfor i in range(n):\n ans = gcd(ans, a[i])\nprint(ans)", "neg": "import fractions\n\nn = int(input())\na = list(map(int, input().split( )))\nans = 0\nfor i in range(n):\n ans = math.gcd(ans,a[i])\nprint(ans)", "jacc_sim": 0.9259259259259259, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [58, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u888610038", "n_user": "u888610038", "pos": "N=int(input())\nA=list(map(int,input().split()))\nB=A[0]\ndef gcd(a,b):\n while b:\n a,b=b,a%b\n return a\nfor i in range(1,N):\n B=gcd(B,A[i])\nprint(B)", "neg": "N=int(input())\nA=list(map(int,input().split()))\nB=A[0]\ndef gcd(a,b):\n while b:\n a,b=b,a%b\n return a\nfor i in range(1,N):\n B=gcd(B,A[i])\nprnt(B)", "jacc_sim": 0.9354838709677419, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [83, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u732870425", "n_user": "u732870425", "pos": "N = int(input())\nA = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nans = A[0]\nfor i in range(N):\n ans = gcd(ans, A[i])\n\nprint(ans)", "neg": "N = int(input())\nA = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b == 0:\n return a\n else:\n return gcd(b, a % b)\n\nans = A[0]\nfor i in range(n):\n ans = gcd(ans, A[i])\n\n print(ans)", "jacc_sim": 0.967741935483871, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [89, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u922416423", "n_user": "u922416423", "pos": "N =int(input())\nA = list(map(int, input().split()))\n\n#\uff12\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u308b\n\ndef gcd2(x,y): \n while y != 0:\n x , y = y , x % y \n return x\n\n\n\n#N \u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u308b\n#A = [A[0],...,A[N]] \u3068\u3059\u308b\n\ndef gcd(A):\n ans = A[0]\n for i in range(1,N): #range(1,N)= 1,2,...,N-1\n ans = gcd2(ans, A[i])\n return ans\nprint(gcd(A))", "neg": "N =int(input())\nA = list(map(int, input().split()))\n\n#\uff12\u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u308b\n\ndef gcd(x,y): \n while y != 0:\n x , y = y , x % y \n return x\n\n\n\n#N \u6574\u6570\u306e\u6700\u5927\u516c\u7d04\u6570\u3092\u6c42\u3081\u308b\n#A = [A[0],...,A[N]] \u3068\u3059\u308b\n\ndef gcd(A):\n ans = A[0]\n for i in range(1,N) #range(1,N)= 1,2,...,N-1\n ans = gcd(ans, A[i])\n return ans\nprint(gcd(A))", "jacc_sim": 0.9795918367346939, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [230, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u197300773", "n_user": "u197300773", "pos": "def egcd(a, b):\n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n gcd=a\n return gcd\n\n \nN=int(input())\nHP=list(map(int,input().split()))\n\ntmp=egcd(HP[0],HP[1])\n\nfor i in range(1,N-1):\n tmp=egcd(tmp,HP[i+1])\n \nprint(tmp)", "neg": "N=int(input())\nHP=list(map(int,input().split()))\n\ntmp=egcd(HP[0],HP[1])\n\nfor i in range(1,N-1):\n a=tmp\n b=HP[i+1]\n \n (x, lastx) = (0, 1)\n (y, lasty) = (1, 0)\n while b != 0:\n q = a // b\n (a, b) = (b, a % b)\n (x, lastx) = (lastx - q * x, x)\n (y, lasty) = (lasty - q * y, y)\n \n tmp=a\n \nprint(tmp)", "jacc_sim": 0.926829268292683, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [186, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u762540523", "n_user": "u762540523", "pos": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\ndef gcdl(l):\n from functools import reduce\n return reduce(lambda x, y: gcd(x, y), l)\nn=input()\nprint(gcdl(list(map(int,input().split()))))", "neg": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\ndef gcdl(l):\n from functools import reduce\n reduce(lambda x, y: gcd(x, y), a)\nn=input()\nprint(gcdl(list(map(int,input().split()))))", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [82, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u957722693", "n_user": "u957722693", "pos": "n=int(input())\nl=list(map(int,input().split()))\nans=0\ndef gcd(a,b):\n if b==0:return a\n return gcd(b,a%b)\nif n==1:\n ans=l[0]\nelse:\n element = gcd(l[0], l[1])\n if n==2:\n ans=element\n else:\n for i in range(2,n):\n element=gcd(element,l[i])\n ans=element\nprint(ans)", "neg": "n=int(input())\nl=list(map(int,input().split()))\nans=0\ndef gcd(a,b):\n if b==0:return a\n return gcd(b,a%b)\nif n==1:\n ans=x[0]\nelse:\n element = gcd(x[0], x[1])\n if n==2:\n ans=element\n else:\n for i in range(2,n):\n element=gcd(element,x[i])\n ans=element\nprint(ans)", "jacc_sim": 0.9705882352941176, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [133, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u655048024", "n_user": "u655048024", "pos": "import math\nN = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor i in range(1,N):\n ans = math.gcd(ans,a[i])\nprint(ans)\n", "neg": "N = int(input())\na = list(map(int,input().split()))\nans = a[0]\nfor i in range(1,N):\n ans = gcd(ans,a[i])\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [61, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u823885866", "n_user": "u823885866", "pos": "import math\nimport functools\ninput()\nprint(functools.reduce(math.gcd,map(int,input().split())))", "neg": "import math\nprint(reduce(math.gcd,map(int,input().split())))", "jacc_sim": 0.9285714285714286, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [31, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u144980750", "n_user": "u144980750", "pos": "n=int(input())\na=[int(i) for i in input().split()]\nb=a[0]\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\nfor i in a:\n b=gcd(b,i)\nprint(b)", "neg": "n=int(input())\na=[map(int,input().split()) for i in range(n)]\nb=a[0]\ndef gcd(x,y):\n while y:\n x,y=y,x%y\n return x\n\nfor i in a:\n b=gcd(b,i)\nprint(b)", "jacc_sim": 0.9285714285714286, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [79, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u246820565", "n_user": "u246820565", "pos": "n = int(input())\nA = list(map(int,input().split()))\n\n#\u30e6\u30fc\u30b0\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd5\u3067\u3001a,b\u3092\u4e0e\u3048\u3066\u3001a\u3092b\u3067\u5272\u3063\u3066\u3042\u307e\u308a\u3092\u8a08\u7b97\u3059\u308b\n#\u3042\u307e\u308a\u304c\u306a\u3044\u3068\u304d\u306f\u3001\u6700\u5f8c\u306b\u5272\u3063\u305f\u6570\u3092\u8fd4\u3059\uff08\u6700\u5927\u516c\u7d04\u6570\uff09\n#\u3042\u307e\u308a\u304c\u3042\u308b\u3068\u304d\u306f\u3001b\u306b\u3042\u307e\u308a\u3092\u5165\u308c\u3066\u3001\u518d\u3073\u8a08\u7b97\u3059\u308b\ndef gcd(a,b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\n\nx = A[0]\nfor i in A[1:]:\n\tx = gcd(x,i)\nprint(x)", "neg": "n = int(input())\nA = list(map(int,input().split()))\n\n#\u30e6\u30fc\u30b0\u30ea\u30c3\u30c9\u306e\u4e92\u9664\u6cd5\u3067\u3001a,b\u3092\u4e0e\u3048\u3066\u3001a\u3092b\u3067\u5272\u3063\u3066\u3042\u307e\u308a\u3092\u8a08\u7b97\u3059\u308b\n#\u3042\u307e\u308a\u304c\u306a\u3044\u3068\u304d\u306f\u3001\u6700\u5f8c\u306b\u5272\u3063\u305f\u6570\u3092\u8fd4\u3059\uff08\u6700\u5927\u516c\u7d04\u6570\uff09\n#\u3042\u307e\u308a\u304c\u3042\u308b\u3068\u304d\u306f\u3001b\u306b\u3042\u307e\u308a\u3092\u5165\u308c\u3066\u3001\u518d\u3073\u8a08\u7b97\u3059\u308b\ndef gcd(a,b):\n\tif b == 0:\n\t\treturn a\n\treturn gcd(b,a%b)\n\n\nx = A[0]\nfor i in a[1:]:\n\tx = gcd(x,i)\nprint(x)", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [343, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u887207211", "n_user": "u887207211", "pos": "import sys \nstdin = sys.stdin\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : map(int, stdin.readline().split())\n\nn = ni()\na = list(na())\n\ndef gcd(n, m):\n while m:\n n, m = m, n%m\n return n\n\nans = a[0]\nfor e in a[1:]:\n ans = gcd(ans, e)\nprint(ans)\n", "neg": "import sys \nstdin = sys.stdin\nns = lambda : stdin.readline().rstrip()\nni = lambda : int(ns())\nna = lambda : map(int, stdin.readline().split())\n\nn = ni()\na = list(na())\n\ndef gcd(n, m):\n while m:\n n, m = m, n%m\n return n\n\nans = 1\nfor e in a:\n ans = gcd(ans, e)\nprint(ans)", "jacc_sim": 0.9166666666666666, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [122, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u119983020", "n_user": "u119983020", "pos": "N = int(input())\nA = [int(n) for n in input().split()]\n\ndef gcd(a,b):\n while b>0:\n a, b = b, a%b \n return a\n\ntemp_gcd = gcd(A[0],A[1])\nfor i in range(2,N):\n temp_gcd = gcd(A[i],temp_gcd)\nprint(temp_gcd)", "neg": "N = int(input())\nA = [int(n) for n in input().split()]\n\ndef gcd(a,b):\n while b>0:\n a, b = b, a%b \n return a\n\ntemp_gcm = gcm(A[0],A[1])\n for i in range(2,N):\n temp_gcm = gcm(A[i],temp_gcm)\nprint(temp_gcm)\n", "jacc_sim": 0.9090909090909091, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [106, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u652057333", "n_user": "u652057333", "pos": "from functools import reduce\n\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef gcd_list(numbers):\n return reduce(gcd, numbers)\n\n\ndef lcm_list(numbers):\n return reduce(lcm, numbers)\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nprint(gcd_list(a))", "neg": "from functools import reduce\n\n\ndef gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\n\ndef lcm(x, y):\n return (x * y) // gcd(x, y)\n\n\ndef gcd_list(*numbers):\n return reduce(gcd, numbers)\n\n\ndef lcm_list(*numbers):\n return reduce(lcm, numbers)\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nprint(gcd_list(a))", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [135, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u063052907", "n_user": "u063052907", "pos": "n = int(input())\nlst_a = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b==0:\n return a\n else:\n return gcd(b, a%b)\n\nans = lst_a[0]\nfor a in lst_a:\n # \u914d\u5217\u306e\u6700\u521d\u304b\u3089\u3072\u3068\u3064\u305a\u3064\u6700\u5927\u516c\u7d04\u6570\u3092\u53d6\u3063\u3066\u3044\u3051\u3070\u3088\u3044\u3002\n ans = gcd(ans, a)\n\nprint(ans)", "neg": "n = int(input())\nlst_a = list(map(int, input().split()))\n\ndef gcd(a, b):\n if b==0:\n return a\n else:\n gcd(b, a%b)\n\nans = lst_a[0]\nfor a in lst_a:\n # \u914d\u5217\u306e\u6700\u521d\u304b\u3089\u3072\u3068\u3064\u305a\u3064\u6700\u5927\u516c\u7d04\u6570\u3092\u53d6\u3063\u3066\u3044\u3051\u3070\u3088\u3044\u3002\n ans = gcd(ans, a)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [176, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u169350228", "n_user": "u169350228", "pos": "from math import gcd\nn = int(input())\na = list(map(int,input().split()))\n\ng = a[0]\nfor i in a:\n g = gcd(g,i)\n\nprint(g)\n", "neg": "from math import gcd\nn = int(input())\na = list(map(int,input().split()))\n\ng = a[0]\nfor i in a:\n g = gcd(g,i)\n\nprint(i)\n", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [56, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u729938879", "n_user": "u729938879", "pos": "n = int(input())\nmonsters = list(map(int, input().split()))\ndef gcd(a, b):\n if b == 0: \n return a\n else:\n return gcd(b, a%b)\ngcd(4,2)\n\ndef gcd_more(a):\n ans = a[0]\n for i in range(1,len(a)):\n ans = gcd(ans, a[i])\n return ans\nprint(gcd_more(monsters))", "neg": "n = int(input())\nmonsters = list(map(int, input().split()))\ndef gcd(a, b):\n if b == 0: \n return a\n else:\n return gcd(b, a%b)\ngcd(4,2)\n\ndef gcd_more(a):\n ans = a[0]\n for i in range(1,len(a)):\n ans = gcd(ans, a[i])\n return ans\ngcd_more(monsters)", "jacc_sim": 0.9714285714285714, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [123, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u207747871", "n_user": "u207747871", "pos": "def gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(b,a%b)\n\nn = int(input())\nline = list(map(int,input().split()))\n\nans = line[0]\n\nfor i in range(1,n):\n ans = gcd(ans,line[i])\n\nprint(ans)", "neg": "def gcd(a,b):\n if b == 0:\n return a\n else:\n return gcd(a,a%b)\n\nn = int(input())\nline = list(map(int,input().split()))\n\nans = line[0]\n\nfor i in range(1,n):\n ans = gcd(ans,line[i])\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [92, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u224554402", "n_user": "u224554402", "pos": "import math\nn= int(input())\na_list = list(map(int, input().split()))\ngcd = a_list[0]\nfor i in range(1,n):\n gcd = math.gcd(gcd,a_list[i])\n \n \nprint(gcd)", "neg": "n= int(input())\na_list = list(map(int, input().split()))\ngcd = a_list[0]\nfor i in range(1,n):\n gcd = math.gcd(gcd,a_list[i])\n \n \nprint(gcd)", "jacc_sim": 0.96, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [73, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u556589653", "n_user": "u556589653", "pos": "import math\nN = int(input())\nA = list(map(int,input().split()))\nnow = A[0]\nfor i in range(1,N):\n now = math.gcd(A[i],now)\nprint(now)\n", "neg": "N = int(input())\nA = list(map(int,input().split()))\nnow = A[0]\nfor i in range(1,N):\n now = math.gcd(A[i],now)\nprint(now)", "jacc_sim": 0.9615384615384616, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [61, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u828365778", "n_user": "u828365778", "pos": "input()\nA = list(map(int, input().split(\" \")))\nA.sort()\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\nrtn = 0\nfor i in range(0,len(A)-1):\n A[i+1] = gcd(A[i], A[i+1])\nprint(A[-1])", "neg": "input()\nA = list(map(int, input().split(\" \")))\nA.sort()\ndef gcd(a, b):\n while b:\n a, b = b, a%b\n return a\nrtn = 0\nfor i in range(0,len(A)-1):\n print(A[i], A[i+1], gcd(A[i], A[i+1]))\n A[i+1] = gcd(A[i], A[i+1])\nprint(A[-1])", "jacc_sim": 1.0, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [97, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u016182925", "n_user": "u016182925", "pos": "N = int(input())\nmonster = list(map(int, input().split()))\ndef gcd(a, b):\n\tif b > 0 :\n\t\treturn gcd(b, a % b)\n\telse:\n\t\treturn a\nif len(monster) == 1 :\n\tprint(monster[0])\nelse:\n\tmon = gcd(monster[0], monster[1])\n\tif len(monster) != 2 :\n\t\tfor i in range(2, N) :\n\t\t\tmon = gcd(mon, monster[i])\nprint(mon)", "neg": "N = int(input())\nmonsters = list(map(int, input().split()))\ndef gcd(a, b):\n\tif b > 0 :\n return gcd(b , a % b)\n else :\n return x\nif len(monster) == 1 :\n\tprint(monster[0])\nelse :\n mon = gcd(monster[0], monster[1])\n if len(monster) >= 2\n for i in range(2 , N) :\n mon = gcd(mon, monster[i])\nprint(mon)\n \n \n \n \n", "jacc_sim": 0.918918918918919, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [138, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03127", "p_user": "u521271655", "n_user": "u440129511", "pos": "import math\nfrom functools import reduce\n\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\n\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\n\nn = int(input())\nprint(gcd_list(list(map(int,input().split()))))", "neg": "from fractions import gcd\nfrom functools import reduce\nn=int(input())\na=list(map(int,input().split()))\ndef gcd(*numbers):\n return reduce(math.gcd, numbers)\ndef gcd_list(numbers):\n return reduce(math.gcd, numbers)\nprint(gcd_list(a))", "jacc_sim": 0.9230769230769231, "nl": "You are given N monsters, each with an initial health value. Monsters attack each other randomly until only one is left alive. During each attack, the health of the attacked monster decreases by the health of the attacking monster. Find the minimum possible final health of the last monster alive. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9. Input format: N followed by N health values. Output the minimum possible final health of the last monster alive.", "before_after_length": [75, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\nb = [0]*n\nfor i in range(n):\n if a[i]%2:\n b[i] = 1\n elif a[i]:\n b[i] = 2\nDP = [[10**18 for i in range(5)] for j in range(n+1)]\nfor i in range(5):\n DP[0][i] = 0\nfor i in range(1,n+1):\n for j in range(5):\n for k in range(j,5):\n if k == 0 or k == 4:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])\n elif k == 1 or k == 3:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))\n else:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))\nprint(min(DP[n]))", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\nb = [0]*n\nfor i in range(n):\n if a[i]%2:\n b[i] = 1\n elif a[i]:\n b[i] = 2\nn += 1\nDP = [[10**18 for i in range(5)] for j in range(n+1)]\nfor i in range(5):\n DP[0][i] = 0\nfor i in range(1,n+1):\n for j in range(5):\n for k in range(j,5):\n if k == 0 or k == 4:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])\n elif k == 1 or k == 3:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))\n else:\n DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))\nprint(min(DP[n]))", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [296, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u884982181", "n_user": "u884982181", "pos": "import sys\nsys.setrecursionlimit(200000)\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ndp = [[1<<60]*5 for i in range(n+1)]\ndp[0][0] = 0\nfor i in range(n):\n dp[i+1][0] = dp[i][0]+a[i]\n if a[i] != 0:\n dp[i+1][1] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2)\n else:\n dp[i+1][1] = min(dp[i][0]+2,dp[i][1]+2)\n a[i]+=1\n dp[i+1][2] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2,dp[i][2]+a[i]%2)\n a[i]-=1\n if a[i] != 0:\n dp[i+1][3] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2,dp[i][2]+a[i]%2,dp[i][3]+a[i]%2)\n else:\n dp[i+1][3] = min(dp[i][0]+2,dp[i][1]+2,dp[i][2]+2,dp[i][3]+2)\n dp[i+1][4] = min(dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4])+a[i]\nprint(min(dp[n]))", "neg": "import sys\nsys.setrecursionlimit(200000)\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ndp = [[1<<60]*5 for i in range(n+1)]\ndp[0][0] = 0\nfor i in range(n):\n dp[i+1][0] = dp[i][0]+a[i]\n dp[i+1][1] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2)\n if a[i] == 0:\n pass\n else:\n a[i]+=1\n dp[i+1][2] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2,dp[i][2]+a[i]%2)\n if a[i] == 0:\n pass\n else:\n a[i]-=1\n dp[i+1][3] = min(dp[i][0]+a[i]%2,dp[i][1]+a[i]%2,dp[i][2]+a[i]%2,dp[i][3]+a[i]%2)\n dp[i+1][4] = min(dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4])+a[i]\nprint(min(dp[n]))", "jacc_sim": 0.9512195121951219, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [431, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u807772568", "n_user": "u807772568", "pos": "a = int(input())\n\nb = []\n\nfor i in range(a):\n\tb.append(int(input()))\n\nc = [[0] * 5 for i in range(a+1)]\n\nfor i in range(a):\n\tc[i+1][0] = c[i][0] + b[i]\n\tc[i+1][1] = min(c[i][0],c[i][1]) + (b[i] % 2 if b[i] > 0 else 2)\n\tc[i+1][2] = min(c[i][0],c[i][1],c[i][2]) + ((b[i]+1) % 2)\n\tc[i+1][3] = min(c[i][0],c[i][1],c[i][2],c[i][3]) + (b[i] % 2 if b[i] > 0 else 2)\n\tc[i+1][4] = min(c[i][0],c[i][1],c[i][2],c[i][3],c[i][4]) + b[i]\n\nprint(min(c[-1]))", "neg": "a = int(input())\n\nb = []\n\nfor i in range(a):\n\tb.append(int(input()))\n\nc = [[0] * 5 for i in range(a+1)]\n\nfor i in range(a):\n\tc[i+1][0] = c[i][0] + b[i]\n\tc[i+1][1] = min(c[i][0],c[i][1]) + (b[i] % 2 if b[i] > 0 else 2)\n\tc[i+1][2] = min(c[i][0][,c[i][1],c[i][2]]) + ((b[i]+1) % 2)\n\tc[i+1][3] = min(c[i][0][,c[i][1],c[i][2]],c[i][3]) + (b[i] % 2 if b[i] > 0 else 2)\n\tc[i+1][4] = min(c[i][0][,c[i][1],c[i][2]],c[i][3],c[i][4]) + b[i]\n\nprint(min(c[-1]))", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [278, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u138486156", "n_user": "u138486156", "pos": "l = int(input())\na = [int(input()) for _ in range(l)]\n\ndp = [[0 for i in range(5)] for j in range(l+1)]\n\ndef cost(s, a):\n if s == 0 or s == 4:\n return a\n elif s == 1 or s == 3:\n if a > 0:\n return a%2\n else:\n return 2\n else:\n return (a+1)%2\n\nfor i in range(l):\n dp[i+1][0] = min(dp[i][:1]) + cost(0, a[i])\n dp[i+1][1] = min(dp[i][:2]) + cost(1, a[i])\n dp[i+1][2] = min(dp[i][:3]) + cost(2, a[i])\n dp[i+1][3] = min(dp[i][:4]) + cost(3, a[i])\n dp[i+1][4] = min(dp[i][:5]) + cost(4, a[i])\n\nprint(min(dp[l]))\n\n", "neg": "l = int(input())\na = [int(input()) for _ in range(l)]\n\ndp = [[0 for i in range(5)] for j in range(l+1)]\n\ndef cost(s, a):\n if s == 0 or s == 4:\n return a\n elif s == 1 or s == 3:\n if a > 0:\n return a%2\n else:\n return 0\n else:\n return (a+1)%2\n\nfor i in range(l):\n dp[i+1][0] = min(dp[i][:1]) + cost(0, a[i])\n dp[i+1][1] = min(dp[i][:2]) + cost(1, a[i])\n dp[i+1][2] = min(dp[i][:3]) + cost(2, a[i])\n dp[i+1][3] = min(dp[i][:4]) + cost(3, a[i])\n dp[i+1][4] = min(dp[i][:5]) + cost(4, a[i])\n\nprint(min(dp[l]))\n\n", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [279, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u062147869", "n_user": "u062147869", "pos": "N=int(input())\nA=[int(input()) for i in range(N)]\nB=[0]*N\nfor i in range(N):\n if A[i]>0:\n if A[i]%2==0:\n B[i]=2\n else:\n B[i]=1\nL=[0,2,1,2,0]\ndp=[[10**9]*5 for i in range(N+1)]\nfor k in range(5):\n dp[0][k]=0\nfor i in range(1,N+1):\n for k in range(5):\n for k1 in range(k+1):\n if 1<=k<=3:\n dp[i][k]=min(dp[i][k],dp[i-1][k1]+abs(L[k]-B[i-1]))\n else:\n dp[i][k]=min(dp[i][k],dp[i-1][k1]+A[i-1])\nans=10**9\n#print(B)\n#print(dp)\nfor a in range(5):\n ans=min(ans,dp[N][a])\nprint(ans)", "neg": "N=int(input())\nA=[int(input()) for i in range(N)]\nB=[0]*N\nfor i in range(N):\n if A[i]>0:\n if A[i]%2==0:\n B[i]=2\n else:\n B[i]=1\nL=[0,2,1,2,0]\ndp=[[10**9]*5 for i in range(N+1)]\nfor k in range(5):\n dp[0][k]=0\nfor i in range(1,N+1):\n for k in range(5):\n for k1 in range(k+1):\n if 1<=k<=3:\n dp[i][k]=min(dp[i][k],dp[i-1][k1]+abs(L[k]-B[i-1]))\n else:\n dp[i][k]=min(dp[i][k],dp[i-1][k1]+A[i-1])\nans=10**9\n#print(B)\n#print(dp)\nfor a in range(5):\n ans=min(ans,dp[N][a])\nprint(ans)v", "jacc_sim": 0.9761904761904762, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [289, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u667084803", "n_user": "u667084803", "pos": "#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d\n#2019-02-11\n\n#DP\n\nL = int(input())\n\nDP = [0 for i in range(5)]\n\ndef cost(a):\n if a:\n return [a, a%2, (a+1)%2, a%2, a]\n else:\n return [0, 2, 1, 2, 0]\n\nfor i in range(L):\n n = [min(DP[:i+1]) for i in range(5)]\n a = int(input())\n cos = cost(a)\n DP[0] = n[0] + cos[0]\n DP[1] = n[1] + cos[1]\n DP[2] = n[2] + cos[2]\n DP[3] = n[3] + cos[3]\n DP[4] = n[4] + cos[4]\n\n\n\nprint(min(DP))", "neg": "#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d\n#2019-02-11\n\n#DP\nL = int(input())\nDP = [0 for i in range(5)]\n\ndef cost(a):\n if a:\n return [a, a%2, (a+1)%2, a%2, a]\n else:\n return [0, 2, 1, 2, 0]\n\nfor i in range(L):\n n = [min(DP[:i+1]) for i in range(5)]\n cos = cost(a)\n DP[4] = n[4] + cos[4]\n DP[3] = n[3] + cos[3]\n DP[2] = n[2] + cos[2]\n DP[1] = n[1] + cos[1]\n DP[0] = n[0] + cos[0]\n\nprint(min(DP))", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [263, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u374103100", "n_user": "u374103100", "pos": "# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d\n\nL = int(input())\n\nA = [int(input()) for _ in range(L)]\n\nINF = int(1e15)\ndp = [[INF] * (L + 1) for _ in range(5)]\n\nfor i in range(4):\n dp[i][0] = 0\n\nfor i in range(L):\n dp[0][i + 1] = dp[0][i] + A[i] # \u5168\u90e8\u53d6\u308a\u9664\u304f\n dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)\n dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)\n dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)\n dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i] # \u5168\u90e8\u53d6\u308a\u9664\u304f\n\n\nprint(min(dp[i][L] for i in range(1, 5)))\n", "neg": "# https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d\n\nL = int(input())\n\nA = [int(input()) for _ in range(L)]\n\nINF = int(1e15)\ndp = [[INF] * (L + 1)] for _ in range(5)]\n\nfor i in range(4):\n dp[i][0] = 0\n\nfor i in range(n):\n dp[0][i + 1] = dp[0][i] + A[i] # \u5168\u90e8\u53d6\u308a\u9664\u304f\n dp[1][i + 1] = min(dp[j][i] for j in range(2)) + (A[i] % 2 if A[i] != 0 else 2)\n dp[2][i + 1] = min(dp[j][i] for j in range(3)) + (1 if A[i] % 2 == 0 else 0)\n dp[3][i + 1] = min(dp[j][i] for j in range(4)) + (A[i] % 2 if A[i] != 0 else 2)\n dp[4][i + 1] = min(dp[j][i] for j in range(5)) + A[i] # \u5168\u90e8\u53d6\u308a\u9664\u304f\n\n\nprint(min(dp[i][L] for i in range(1, 5)))\n", "jacc_sim": 0.9814814814814815, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [364, 364], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u667084803", "n_user": "u667084803", "pos": "#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d\n#2019-02-10\n\n#DP\n\nL = int(input())\nA = [int(input()) for i in range(L)]\n\nDP = [[float(\"inf\") for i in range(5)] for j in range(L+1)]\nfor i in range(5):\n DP[0][i] = 0\n\ndef cost(s, i, A):\n if s == 0 or s == 4:\n return A[i]\n elif s == 1 or s == 3:\n if A[i] > 0:\n if A[i]%2 == 0:\n return 0\n else:\n return 1\n else:\n return 2\n else:\n if A[i]%2 == 1:\n return 0\n else:\n return 1\n\nfor i in range(L):\n for j in range(5):\n for k in range(j,5):\n DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))\n\n\n\nprint(min(DP[L]))", "neg": "#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d\n#2019-02-10\n\n#DP\n\nL = int(input())\nA = [int(input()) for i in range(L)]\n\nDP = [[float(\"inf\") for i in range(5)] for j in range(L)]\nDP[0][0] = 0\n\ndef cost(s, i, A):\n if s == 0 or s == 4:\n return A[i]\n elif s == 1 or s == 3:\n if A[i] > 0:\n if A[i]%2 == 0:\n return 0\n else:\n return 1\n else:\n return 2\n else:\n if A[i]%2 == 1:\n return 1\n else:\n return 0\n\nfor i in range(L-1):\n for j in range(5):\n for k in range(j,5):\n DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))\n\n\n\nprint(min(DP[L-1]))", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [303, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u794173881", "n_user": "u794173881", "pos": "l = int(input())\na = []\nfor i in range(l):\n a.append(int(input()))\n \ndp=[[0]*5 for i in range(l+1)]\n\nfor i in range(0,l):\n if a[i]==0:\n even=2\n else:\n even=a[i]%2\n \n dp[i+1][0]=dp[i][0]+a[i]\n dp[i+1][1]=min(dp[i][0],dp[i][1]) + even\n dp[i+1][2]=min(dp[i][0],dp[i][1],dp[i][2]) + (a[i]+1)%2\n dp[i+1][3]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3]) + even\n dp[i+1][4]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4]) + a[i]\n \nprint(min(dp[l]))\n ", "neg": "l = int(input())\na = []\nfor i in range(l):\n a.append(int(input()))\n \ndp=[[0]*5 for i in range(l+1)]\n\nfor i in range(0,l):\n \n dp[i+1][0]=dp[i][0]+a[i]\n dp[i+1][1]=min(dp[i][0],dp[i][1]) + a[i]%2\n dp[i+1][2]=min(dp[i][0],dp[i][1],dp[i][2]) + (a[i]+1)%2\n dp[i+1][3]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3]) + a[i]%2\n dp[i+1][4]=min(dp[i][0],dp[i][1],dp[i][2],dp[i][3],dp[i][4]) + a[i]\n \nprint(min(dp[l]))", "jacc_sim": 0.90625, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [277, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u572144347", "n_user": "u572144347", "pos": "#!/mnt/c/Users/moiki/bash/env/bin/python\n# N,M = map(int, input().split())\nL = int(input())\nA = [int(input()) for _ in range(L)]\n\n\nDP = [0] * 5\nfor i in range(L):\n r0 = A[i]\n r1 = (A[i] + 1) % 2\n\n if A[i] == 0:\n r2 = 2\n else:\n r2 = A[i] % 2\n\n for i,r in zip(range(4,-1,-1), [r0,r2,r1,r2,r0]):\n DP[i] = min(DP[:i+1]) + r\n # print(DP)\n\nprint(min(DP))\n \n", "neg": "#!/mnt/c/Users/moiki/bash/env/bin/python\n# N,M = map(int, input().split())\nL = int(input())\nA = [int(input()) for _ in range(L)]\n\n\nDP = [0] * 5\nfor i in range(L):\n r0 = A[i]\n r1 = (A[i] + 1) % 2\n\n if A[i] == 0:\n r2 = 2\n else:\n r2 = A[i] % 2\n\n for i,r in zip(range(4,-1,-1), [r0,r2,r1,r2,r0]):\n DP[i] = min(DP[:i+1]) + r\n print(DP)\nprint(min(DP))\n \n", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [203, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u839188633", "n_user": "u839188633", "pos": "a = [int(input()) for _ in range(int(input()))]\n\ndp = [[0] * 5 for _ in range(len(a) + 1)]\n\nfor i, x in enumerate(a):\n y = x % 2 + (x == 0) * 2\n z = (x + 1) % 2\n \n dp[i+1][0] = min(dp[i][0:1]) + x\n dp[i+1][1] = min(dp[i][0:2]) + y\n dp[i+1][2] = min(dp[i][0:3]) + z\n dp[i+1][3] = min(dp[i][0:4]) + y\n dp[i+1][4] = min(dp[i][0:5]) + x\n\nprint(min(dp[-1]))", "neg": "a = [int(input()) for _ in range(int(input()))]\n\ndp = [[0] * 5 for _ in range(len(a) + 1)]\n\nfor i, x in enumerate(a):\n y = x % 2 + (x==0) * 2\n z = (x + 1) % 2\n \n dp[i+1][0] = dp[i][0] + x\n dp[i+1][1] = min(dp[i][0] + y, dp[i][1] + y)\n dp[i+1][2] = min(dp[i][1] + z, dp[i][0] + z, dp[i][2] + z)\n dp[i+1][3] = min(dp[i][2] + y, dp[i][1] + y, dp[i][0] + y, dp[i][3] + y)\n dp[i+1][4] = min(dp[i][3] + x, dp[i+1][3])\n\nprint(dp[-1][4])", "jacc_sim": 1.0, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [203, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u419686324", "n_user": "u419686324", "pos": "L = int(input())\n\ninf = float('inf')\ndp = [[inf] * 5 for _ in range(L+1)]\ndp[0][0] = 0\nfor i in range(1, L+1):\n a = int(input())\n\n b = a & 1\n c = b ^ 1\n p, n = dp[i-1], dp[i]\n n[0] = p[0] + a\n n[1] = min(p[:2]) + b\n n[2] = min(p[:3]) + c\n n[3] = min(p[:4]) + b\n n[4] = min(p[:5]) + a\n\n if a == 0:\n n[1] += 2\n n[3] += 2\n\nprint(min(dp[L]))", "neg": "L = int(input())\n\ninf = float('inf')\ndp = [[inf] * (L+1) for _ in range(5)]\ndp[0][0] = 0\nfor i in range(1, L+1):\n a = int(input())\n if a == 0:\n dp[0][i] = dp[0][i-1] + a\n dp[1][i] = min(dp[0][i-1], dp[1][i-1]) + 2\n dp[2][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1]) + 1\n dp[3][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1], dp[3][i-1]) + 2\n dp[4][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1], dp[3][i-1], dp[4][i-1])\n else:\n b = a & 1\n c = b ^ 1\n dp[0][i] = dp[0][i-1] + a\n dp[1][i] = min(dp[0][i-1], dp[1][i-1]) + b\n dp[2][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1]) + c\n dp[3][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1], dp[3][i-1]) + b\n dp[4][i] = min(dp[0][i-1], dp[1][i-1], dp[2][i-1], dp[3][i-1], dp[4][i-1]) + a\n\nprint(min(dp[3][L], dp[4][L]))", "jacc_sim": 0.9230769230769231, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [198, 469], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03132", "p_user": "u415905784", "n_user": "u415905784", "pos": "L = int(input())\nA = [0] * (L + 1)\nDP = [[0, 0, 0, 0, 0] for i in range(L + 1)]\nfor i in range(L):\n a = int(input())\n DP[i + 1][0] = DP[i][0] + a\n DP[i + 1][1] = min(min(DP[i][:2]), DP[i + 1][0]) + (a % 2 if a else 2)\n DP[i + 1][2] = min(min(DP[i][:3]), DP[i + 1][1]) + ((1 - a % 2) if a else 1)\n DP[i + 1][3] = min(min(DP[i][:4]), DP[i + 1][2]) + (a % 2 if a else 2)\n DP[i + 1][4] = min(min(DP[i]), DP[i + 1][3]) + a\nprint(min(DP[L]))", "neg": "L = int(input())\nA = [0] * (L + 1)\nDP = [[0, 0, 0, 0, 0] for i in range(L + 1)]\nfor i in range(L):\n a = int(input())\n DP[i + 1][0] = DP[i][0] + a\n DP[i + 1][1] = min(DP[i][1], DP[i + 1][0]) + a % 2\n DP[i + 1][2] = min(min(DP[i][:3]), DP[i + 1][1]) + (1 - a % 2)\n DP[i + 1][3] = min(min(DP[i][:4]), DP[i + 1][2]) + a % 2\n DP[i + 1][4] = min(min(DP[i]), DP[i + 1][3]) + a\nprint(min(DP[L]))", "jacc_sim": 0.9333333333333333, "nl": "Snuke stands on a number line with L ears and walks continuously under specific conditions. He puts a stone in his i-th ear each time he passes a point with coordinate i-0.5. After Snuke finishes walking, Ringo repeats operations to ensure each ear contains a specific number of stones. The task is to find the minimum number of operations required for Ringo to freely decide how Snuke walks. Constraints: 1 \u2264 L \u2264 2\u00d710^5, 0 \u2264 A_i \u2264 10^9 (1 \u2264 i \u2264 L). Input format: L followed by A_1 to A_L. Output the minimum number of operations required.", "before_after_length": [251, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03133", "p_user": "u325227960", "n_user": "u325227960", "pos": "import numpy as np\nimport random\n\nmod=998244353\n\n\nn,m=map(int,input().split())\nA=[list(map(int,input().split())) for i in range(n)]\n\n#n,m=300,300\n#A=[[int(random.randint(0,1)) for j in range(m)] for i in range(n)]\n\n\n#A=np.array(A)\n\n#print(\"A\")\ni=0\nj=0\nr=0 #rank\nwhile i0 :\n for kk in range(j,m):\n A[p][kk]=(A[p][kk]-A[i][kk])%2\n i+=1\n j+=1\n\n\n\n#r=0\n#j=0\n#for i in range(m):\n# if j0 :\n for kk in range(j,m):\n A[p][kk]=(A[p][kk]-A[i][kk])%2\n i+=1\n j+=1\n\n\n\n#r=0\n#j=0\n#for i in range(m):\n# if j dist[to]:\n parent[to] = temp\n dist[to] = temp_dist\n dfs(to)\n\nN, M = map(int, input().split())\n\ncount_from = [0] * N\ncount_to = [0] * N\ne = [[] for _ in range(N)]\n\nfor i in range(N + M - 1):\n a, b = map(int, input().split())\n e[a - 1].append(b - 1)\n count_from[b - 1] += 1\n count_to[a - 1] += 1\n\nstart = 0\nfor i in range(N):\n if count_from[i] == 0:\n start = i\n break\n\ndist = [0] * N\ncount = [0] * N\nparent = [-1] * N\n\ndfs(start)\n\nfor i in range(N):\n print(parent[i] + 1)", "neg": "import sys\n\nsys.setrecursionlimit(20000)\n\ndef dfs(temp):\n global dist, e, count_from, count_to\n global count, parent\n\n if count[temp] == count_from[temp]:\n for to in e[temp]:\n count[to] += 1\n temp_dist = dist[temp] + 1\n if temp_dist > dist[to]:\n parent[to] = temp\n dist[to] = temp_dist\n dfs(to)\n\nN, M = map(int, input().split())\n\ncount_from = [0] * N\ncount_to = [0] * N\ne = [[] for _ in range(N)]\n\nfor i in range(N + M - 1):\n a, b = map(int, input().split())\n e[a - 1].append(b - 1)\n count_from[b - 1] += 1\n count_to[a - 1] += 1\n\nstart = 0\nfor i in range(N):\n if count_from[i] == 0:\n start = i\n break\n\ndist = [0] * N\ncount = [0] * N\nparent = [-1] * N\n\n#dfs(start)\n\nfor i in range(N):\n print(parent[i] + 1)", "jacc_sim": 0.94, "nl": "You are given a rooted tree with N vertices, each numbered from 1 to N. Takahashi adds M new directed edges to the graph. You are given N-1+M pairs of integers representing the edges. Restore the original rooted tree. Constraints: 3 \u2264 N, 1 \u2264 M, N + M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, A_i \u2260 B_i, and (A_i, B_i) \u2260 (A_j, B_j) if i \u2260 j. The input is given in the format N M A_1 B_1 ... A_{N-1+M} B_{N-1+M}. Output N lines, where the i-th line prints 0 if Vertex i is the root, otherwise prints the integer representing the parent of Vertex i in the original tree.", "before_after_length": [309, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03142", "p_user": "u170201762", "n_user": "u170201762", "pos": "from collections import deque\n\ndef topological_sort(V, to):\n cnt = [0]*V\n for i in range(V):\n for j in to[i]:\n cnt[j] += 1\n Q = deque(i for i in range(V) if cnt[i]==0)\n res = []\n while Q:\n i = Q.popleft()\n res.append(i)\n for k in to[i]:\n cnt[k] -= 1\n if cnt[k] == 0:\n Q.append(k)\n return res\n\nN,M = map(int,input().split())\nto = [[] for i in range(N)]\nFrom = [[] for i in range(N)]\nfor i in range(N-1+M):\n x, y = list(map(int,input().split()))\n to[x-1].append(y-1)\n From[y-1].append(x-1)\ns = topological_sort(N, to)\ns = [(s[i],i) for i in range(N)]\ns.sort()\nfor i in range(N):\n k = -1\n I = -1\n for j in From[i]:\n if k < s[j][1]:\n k = s[j][1]\n I = j\n print(I+1)", "neg": "from collections import deque\n\ndef topological_sort(V, to):\n cnt = [0]*V\n for i in range(V):\n for j in to[i]:\n cnt[j] += 1\n Q = deque(i for i in range(V) if cnt[i]==0)\n res = []\n while len(Q) > 0:\n i = Q.popleft()\n res.append(i)\n for k in to[i]:\n cnt[k] -= 1\n if cnt[k] == 0:\n Q.append(k)\n return s\n\nN,M = map(int,input().split())\nto = [[] for i in range(N)]\nFrom = [[] for i in range(N)]\nfor i in range(N-1+M):\n x, y = list(map(int,input().split()))\n to[x-1].append(y-1)\n From[y-1].append(x-1)\ns = topological_sort(N, to)\ns = [(s[i],i) for i in range(N)]\ns.sort()\nfor i in range(N):\n k = -1\n I = -1\n for j in From[i]:\n if k < s[j][1]:\n k = s[j][1]\n I = j\n print(I+1)", "jacc_sim": 0.9615384615384616, "nl": "You are given a rooted tree with N vertices, each numbered from 1 to N. Takahashi adds M new directed edges to the graph. You are given N-1+M pairs of integers representing the edges. Restore the original rooted tree. Constraints: 3 \u2264 N, 1 \u2264 M, N + M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, A_i \u2260 B_i, and (A_i, B_i) \u2260 (A_j, B_j) if i \u2260 j. The input is given in the format N M A_1 B_1 ... A_{N-1+M} B_{N-1+M}. Output N lines, where the i-th line prints 0 if Vertex i is the root, otherwise prints the integer representing the parent of Vertex i in the original tree.", "before_after_length": [331, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03142", "p_user": "u145035045", "n_user": "u145035045", "pos": "import sys\nsys.setrecursionlimit(1000000)\n\nn, m = map(int, input().split())\nedges = [[] for _ in range(n)]\nrevEdges = [[] for _ in range(n)]\nfor _ in range(n - 1 + m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n revEdges[b].append(a)\n\nvisited = [False] * n\nlst = []\ndef search(x):\n if not visited[x]:\n visited[x] = True\n for to in edges[x]:\n search(to)\n lst.append(x)\n\nfor i in range(n):\n search(i)\nlst.reverse()\ndic = {}\nfor i in range(n):\n dic[lst[i]] = i\n\nparent = [-1] * n\nfor i in lst:\n if not revEdges[i]:\n continue\n maxScore = -1\n index = -1\n for fr in revEdges[i]:\n if maxScore <= dic[fr]:\n maxScore = dic[fr]\n index = fr\n parent[i] = index\n\nfor i in range(n):\n print(parent[i] + 1)", "neg": "n, m = map(int, input().split())\nedges = [[] for _ in range(n)]\nrevEdges = [[] for _ in range(n)]\nfor _ in range(n - 1 + m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n revEdges[b].append(a)\n\nvisited = [False] * n\nlst = []\ndef search(x):\n if not visited[x]:\n visited[x] = True\n for to in edges[x]:\n search(to)\n lst.append(x)\n\nfor i in range(n):\n search(i)\nlst.reverse()\ndic = {}\nfor i in range(n):\n dic[lst[i]] = i\n\nparent = [-1] * n\nfor i in lst:\n if not revEdges[i]:\n continue\n maxScore = n\n index = n\n for fr in revEdges[i]:\n if maxScore <= dic[fr]:\n maxScore = dic[fr]\n index = fr\n parent[i] = fr\n\nfor i in range(n):\n print(parent[i] + 1)", "jacc_sim": 0.9272727272727272, "nl": "You are given a rooted tree with N vertices, each numbered from 1 to N. Takahashi adds M new directed edges to the graph. You are given N-1+M pairs of integers representing the edges. Restore the original rooted tree. Constraints: 3 \u2264 N, 1 \u2264 M, N + M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, A_i \u2260 B_i, and (A_i, B_i) \u2260 (A_j, B_j) if i \u2260 j. The input is given in the format N M A_1 B_1 ... A_{N-1+M} B_{N-1+M}. Output N lines, where the i-th line prints 0 if Vertex i is the root, otherwise prints the integer representing the parent of Vertex i in the original tree.", "before_after_length": [310, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03142", "p_user": "u477320129", "n_user": "u477320129", "pos": "# from collections import namedtuple\n# Node = namedtuple(\"Node\", \"in, out\")\nN, M = list(map(int, input().split()))\nAB = [list(map(int, input().split())) for _ in range(N+M-1)]\nine = [[] * N for _ in range(N)]\noute = [[] * N for _ in range(N)]\nfor a, b in AB:\n ine[b-1].append(a-1)\n oute[a-1].append(b-1)\nroot = ine.index([])\nv = [len(e) for e in ine]\n#print(v)\nans = [0] * N\nq = [(root, n) for n in oute[root]]\nwhile q:\n nq = []\n for p, n in q:\n v[n] -= 1\n if v[n] == 0:\n ans[n] = p + 1\n nq += [(n, nn) for nn in oute[n]]\n q = nq\n\nprint(\"\\n\".join(map(str, ans)))\n\n\n", "neg": "# from collections import namedtuple\n# Node = namedtuple(\"Node\", \"in, out\")\nN, M = list(map(int, input().split()))\nAB = [list(map(int, input().split())) for _ in range(N+M-1)]\nine = [[] * N for _ in range(N)]\noute = [[] * N for _ in range(N)]\nfor a, b in AB:\n ine[b-1].append(a-1)\n oute[a-1].append(b-1)\nroot = ine.index([])\nv = [len(e) for e in ine]\nprint(v)\nans = [0] * N\nq = [(root, n) for n in oute[root]]\nwhile q:\n nq = []\n for p, n in q:\n v[n] -= 1\n if v[n] == 0:\n ans[n] = p + 1\n nq += [(n, nn) for nn in oute[n]]\n q = nq\n\nprint(\"\\n\".join(map(str, ans)))\n\n\n", "jacc_sim": 1.0, "nl": "You are given a rooted tree with N vertices, each numbered from 1 to N. Takahashi adds M new directed edges to the graph. You are given N-1+M pairs of integers representing the edges. Restore the original rooted tree. Constraints: 3 \u2264 N, 1 \u2264 M, N + M \u2264 10^5, 1 \u2264 A_i, B_i \u2264 N, A_i \u2260 B_i, and (A_i, B_i) \u2260 (A_j, B_j) if i \u2260 j. The input is given in the format N M A_1 B_1 ... A_{N-1+M} B_{N-1+M}. Output N lines, where the i-th line prints 0 if Vertex i is the root, otherwise prints the integer representing the parent of Vertex i in the original tree.", "before_after_length": [269, 268], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03143", "p_user": "u846150137", "n_user": "u846150137", "pos": "IN = lambda:list(map(int, input().split()))\nn, m = IN()\nn = n + 1\n\nW = [0] + IN()\nE = [IN() for i in range(m)]\nE.sort(key = lambda x:x[2])\n\nP = list(range(n))\nR = [0] * n\nC = [0] * n\n\ndef find(x):\n if P[x] != x:\n P[x] = find(P[x])\n return P[x]\n\ndef union(x, y, w):\n p, q = find(x), find(y)\n if R[p] < R[q]: p, q = q, p\n P[q] = p\n R[p] += R[p] == R[q]\n W[p] += W[q]\n C[p] = C[p] + C[q]+ 1 if W[p] < w else 0\n\nfor u, v, w in E:\n if find(u) == find(v):\n C[find(u)] += W[find(u)] < w\n else:\n union(u, v, w)\n\nprint(sum(C[i] for i in set(P) if i == P[i]))\n", "neg": "IN = lambda:list(map(int, input().split()))\nn, m = IN()\nn = n + 1\n\nW = [0] + IN()\nE = [IN() for i in range(m)]\nE.sort(key = lambda x:x[2])\n\nP = list(range(n))\nR = [0] * n\nC = [0] * n\n\ndef find(x):\n if P[x] != x:\n P[x] = find(P[x])\n return P[x]\n\ndef union(x, y, w):\n p, q = find(x), find(y)\n if R[p] < R[q]: \n p, q = q, p\n P[q] = p\n R[p] += R[p] == R[q]\n W[p] += W[q]\n C[p] = C[p] + C[q]+ 1 if W[p] < w else 0\n\nfor u, v, w in E:\n if find(u) == find(v):\n C[find(u)] += W[find(u)] < w\n else:\n union(u, v, w)\n\nprint(sum(C[i] for i in set(P)))", "jacc_sim": 1.0, "nl": "You are given a connected undirected graph with N vertices and M edges, each with a specified weight. You need to remove zero or more edges so that for each edge not removed, the sum of the weights of the vertices in the connected component containing that edge is greater than or equal to the weight of that edge. Find the minimum number of edges that need to be removed. The input is given in the format N M X1 X2 ... XN A1 B1 Y1 A2 B2 Y2 ... AM BM YM. The output should be the minimum number of edges that need to be removed.", "before_after_length": [312, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03152", "p_user": "u303037478", "n_user": "u303037478", "pos": "mod = 10**9+7\nn, m = map(int, input().split())\na = sorted(list(map(int, input().split())), reverse=True)\nb = sorted(list(map(int, input().split())), reverse=True)\n\nif len(a) != len(set(a)) or len(b) != len(set(b)):\n print(0)\n exit()\n\na = set(a)\nb = set(b)\n\nc = 1\nN = 0\nM = 0\nfor k in range(n*m, 0, -1):\n if k in a and k in b:\n N += 1\n M += 1\n elif k in a:\n c *= M\n N += 1\n elif k in b:\n c *= N\n M += 1\n else:\n c *= M*N - (m*n-k)\n c %= mod\n\nprint(c)\n", "neg": "mod = 10**9+7\nn, m = map(int, input().split())\na = sorted(list(map(int, input().split())), reverse=True)\nb = sorted(list(map(int, input().split())), reverse=True)\n\nif len(a) != len(set(a)) or len(b) != len(set(b)):\n print(0)\n exit()\n\na = set(a)\nb = set(b)\n\nc = 1\nN = 0\nM = 0\nfor k in range(n*m, 0, -1):\n if k in a and k in b:\n N += 1\n M += 1\n elif k in a:\n c *= M\n N += 1\n elif k in b:\n c *= N\n M += 1\n else:\n c *= M*N - (m*n-k)\n #c %= mod\n\nprint(c)\n", "jacc_sim": 0.9782608695652174, "nl": "Consider writing integers from 1 to N * M in an N x M grid without duplicates. Takahashi wants to write the numbers such that the largest value in the i-th row is A_i and the largest value in the j-th column is B_j. Find the number of ways to write the numbers under these conditions, modulo 10^9 + 7. Constraints: 1 <= N, M <= 1000, 1 <= A_i, B_j <= N * M. Input format: N M, followed by A_1 to A_N and B_1 to B_M. Output the number of ways to write the numbers under the given conditions, modulo 10^9 + 7.", "before_after_length": [226, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03152", "p_user": "u017810624", "n_user": "u017810624", "pos": "n,m=map(int,input().split())\na=list(map(int,input().split()));b=list(map(int,input().split()))\nA=set(a);B=set(b)\nc=1;N=0;M=0\nfor k in range(m*n,0,-1):\n if k in A and k in B:N+=1;M+=1\n elif k in A:c*=M;N+=1\n elif k in B:c*=N;M+=1\n else:c*=M*N-m*n+k\n c=c%(10**9+7)\nprint(c)", "neg": "n,m=map(int,input().split())\na=set(map(int,input().split()))\nb=set(map(int,input().split()))\nc=1;N=0;M=0\nfor k in range(n*m,0,-1):\n if k in A and k in B:\n N+=1;M+=1\n elif k in A:\n c*=M;N+=1\n elif k in B:\n c*=N;M+=1\n else:\n c*=N*M-n*m+k\n c%=10**9+7\nprint(c)", "jacc_sim": 0.975, "nl": "Consider writing integers from 1 to N * M in an N x M grid without duplicates. Takahashi wants to write the numbers such that the largest value in the i-th row is A_i and the largest value in the j-th column is B_j. Find the number of ways to write the numbers under these conditions, modulo 10^9 + 7. Constraints: 1 <= N, M <= 1000, 1 <= A_i, B_j <= N * M. Input format: N M, followed by A_1 to A_N and B_1 to B_M. Output the number of ways to write the numbers under the given conditions, modulo 10^9 + 7.", "before_after_length": [164, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u106181248", "n_user": "u106181248", "pos": "n = int(input())\na = int(input())\nb = int(input())\n\nans = (n-a+1)*(n-b+1)\n\nprint(ans)", "neg": "n = int(input())\na = int(input())\nb = int(input())\n\nans = (n-a+1)+(n-b+1)\n\nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [44, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u752898745", "n_user": "u619197965", "pos": "n,h,w=[int(input()) for _ in range(3)];print((n+1-h)*(n+1-w))", "neg": "n,h,w=[int(input()) for _ in range(3)]\nprint((n-h+1)+(n-w+1))", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [33, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u127499732", "n_user": "u127499732", "pos": "def main():\n import sys\n n,h,w=map(int,open(0).read().split())\n ans=(n-h+1)*(n-w+1)\n print(ans)\nif __name__==\"__main__\":\n main()\n", "neg": "def main():\n import sys\n n,h,w=map(int,open(0).read().split())\n ans=(n-h-1)*(n-w+1)\n print(ans)\nif __name__==\"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [65, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u597455618", "n_user": "u597455618", "pos": "n = [int(input()) for i in range(3)]\nprint((n[0] - n[1] + 1) * (n[0] - n[2] + 1) )", "neg": "n = list[int(input()) for i in range(3)]\nprint((n[0] - n[1] + 1) * (n[0] - n[2] + 1) )", "jacc_sim": 0.9523809523809523, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [44, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u787456042", "n_user": "u787456042", "pos": "n,h,w=map(int,open(0).read().split());print((n-h+1)*(n-w+1))", "neg": "n,h,w=map(int,open(0).read().split);print((n-h+1)*(n-w+1))", "jacc_sim": 1.0, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [33, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u430223993", "n_user": "u619197965", "pos": "n, h, w = [int(input()) for _ in range(3)]\nprint((n-w+1)*(n-h+1))", "neg": "n,h,w=[int(input()) for _ in range(3)]\nprint((n-h)*2+(n-w)*2)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [34, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u327466606", "n_user": "u096100666", "pos": "n,h,w = map(int,(input() for _ in range(3)))\n\nprint((n-h+1)*(n-w+1))", "neg": "n,h,w=map(int, input() for i in range(3))\n \nprint( (n - h + 1) * (n - w + 1))", "jacc_sim": 0.9047619047619048, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [37, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u582705534", "n_user": "u582705534", "pos": "N = int(input())\nH = int(input())\nW = int(input())\n \nANS = (N-(H-1))*(N-(W-1))\n \nprint(ANS)", "neg": "N = int(input())\nH = int(input())\nW = int(input())\n \nANS = (N-(H-1))(N-(W-1))\n \nprint(ANS)", "jacc_sim": 0.9230769230769231, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [48, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u844789719", "n_user": "u844789719", "pos": "N, H, W = [int(input()) for _ in range(3)]\nprint((N - H + 1) * (N - W + 1))\n", "neg": "N, H, W = [int(input()) for _ in range(3)]\nprint((N - H) * (N - W))\n", "jacc_sim": 0.9047619047619048, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [36, 32], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u412039195", "n_user": "u412039195", "pos": "N = int(input())\nH = int(input())\nW = int(input())\n\nNH = 1\nNW = 1\n\nif(N - H != 0):\n NH = N - H + 1\nif(N - W != 0):\n NW = N - W + 1\n\nprint(NH * NW)\n", "neg": "N = int(input())\nH = int(input())\nW = int(input())\n\nNH = 0\nNW = 0\n\nif(N - H != 0):\n NH = N - H + 1\n \nif(N - W != 0):\n NW = N - W + 1\n \nprint(NH + NW)", "jacc_sim": 0.9473684210526315, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [81, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u531055770", "n_user": "u531055770", "pos": "import sys\n\nlines = sys.stdin.readlines()\n\nN = int(lines[0])\nH = int(lines[1])\nW = int(lines[2])\n\np_row = N - H + 1\np_column = N - W + 1\n\nans = p_row * p_column\nprint(ans)\n\n", "neg": "import sys\n\nlines = sys.stdin.readlines()\n\nN = lines[0]\nH = lines[1]\nW = lines[2]\n\np_row = H - N + 1\np_column = W - N + 1\n\nans = p_row * p_column\nprint(ans)\n\n", "jacc_sim": 0.96, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [80, 74], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u390604812", "n_user": "u668726177", "pos": "N, H, W = int(input()), int(input()), int(input())\n\nprint((N - H + 1) * (N - W + 1))", "neg": "N, H, W = input(), input(), input()\nprint((N-H+1)*(N-W+1))", "jacc_sim": 0.9285714285714286, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [38, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u674885198", "n_user": "u674885198", "pos": "n1=int(input())\nn2=int(input())\nn3=int(input())\nout=(n1-n2+1)*(n1-n3+1)\nprint(out)", "neg": "n1=input()\nn2=input()\nn3=input()\nout=(n1-n2+1)*(n1-n3+1)\nprint(out)", "jacc_sim": 0.9285714285714286, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [48, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u971672726", "n_user": "u370608397", "pos": "N, H, W = [int(input()) for i in range(0, 3)]\n\nprint((N - H + 1) * (N - W + 1))", "neg": "N,H,W=[input() for i in range(3)]\nprint((N-H+1)*(N-W+1))", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [38, 31], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u496407619", "n_user": "u532966492", "pos": "N, H, W = [int(input()) for i in range(3)]\n\nprint((N - H + 1) * (N - W + 1))\n", "neg": "N,H,W=[int(input()) in _ for range(3)]\nprint((N-H+1)*(N-W+1))", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [37, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u620868411", "n_user": "u619670102", "pos": "# -*- coding: utf-8 -*-\nn = int(input())\nh = int(input())\nw = int(input())\n\nprint((n-w+1)*(n-h+1))\n", "neg": "#coding:utf-8\nn = input()\nh = input()\nw = input()\n\nprint((n-h+1)*(n-w+1))\n", "jacc_sim": 0.9444444444444444, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [51, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u284854859", "n_user": "u619819312", "pos": "n =int(input())\nh = int(input())\nw = int(input())\nprint((n-w+1)*(n-h+1))", "neg": "n=int(input())\nh=int(input())\nw=int(input())\nprint((n-h+1)*(w-h+1))", "jacc_sim": 1.0, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03155", "p_user": "u369402805", "n_user": "u978313283", "pos": "N = int(input())\nH = int(input())\nW = int(input())\nprint(str((N - H + 1) * (N - W + 1)))\n", "neg": "N=int(input())\nH=int(input())\nW==int(input())\nprint((N-H+1)*(N-W+1))", "jacc_sim": 0.9285714285714286, "nl": "You are tasked with finding the number of ways to place a notice on a bulletin board grid so that it completely covers a specified number of squares. The bulletin board is an N x N grid, and the notice occupies an H x W rectangular region. You need to determine the number of ways to position the notice to cover exactly H * W squares. The input consists of N, H, and W, and the output should be the number of ways to place the notice. The constraints are 1 \u2264 H, W \u2264 N \u2264 100, and all input values are integers.", "before_after_length": [40, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u520276780", "n_user": "u520276780", "pos": "n=int(input())\na,b=map(int, input().split())\n*p,=map(int, input().split())\nmn,md,mx=0,0,0\nfor pi in p:\n if pi<=a:\n mn+=1\n elif pi<=b:\n md+=1\n else:\n mx+=1\nprint(min(mn,md,mx))\n", "neg": "n,a,b=map(int, input().split())\n*p,=map(int, input().split())\nmn,md,mx=0,0,0\nfor pi in p:\n if pi<=a:\n mn+=1\n elif pi<=b:\n md+=1\n else:\n mx+=1\nprint(min(mn,md,mx))\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [100, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u428341537", "n_user": "u428341537", "pos": "pxcount=0\npycount=0\npzcount=0\n\nn=int(input())\na,b=map(int, input().split())\np=list(map(int, input().split()))\n\nfor i in p:\n if i<=a:\n pxcount=pxcount+1\nfor i in p:\n if a+1<=i and i<=b:\n pycount=pycount+1\nfor i in p:\n if b+1<=i:\n pzcount=pzcount+1\n \nprint(min(pxcount,pycount,pzcount))", "neg": "int pxcount,pycount,pzcount=0\n\nn=int(input())\na,b=map(int, input().split())\np=list(map(int, input().split()))\n\nfor i in p:\n if i<=a:\n pxcount=pxcount+1\nfor i in p:\n if a+1<=i and i<=b:\n pycount=pycount+1\nfor i in p:\n if b+1<=i:\n pzcount=pzcount+1\n \nprint(min(pxcount,pycount,pzcount))", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [148, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u266874640", "n_user": "u266874640", "pos": "N=int(input())\nA,B=map(int,input().split())\np = list(map(int,input().split()))\nc=[]\nd=[]\ne=[]\nfor i in range(N):\n if p[i]<=A:\n c.append(p[i])\n if A+1 <= p[i] <= B:\n d.append(p[i])\n if B+1 <= p[i]:\n e.append(p[i])\n\n \nprint(min(len(c),len(d),len(e)))\n", "neg": "N=int(input())\nA,B=map(int,input().split())\np = list(map(int,input().split()))\nc=[]\nd=[]\ne=[]\nfor i in range(N):\n if p[i]<=A:\n c.append(p[i])\n if A+1 <= p[i] <= B:\n d.append(p[i])\n if B+1 <= p[i]:\n e.append(p[i])\n\n \nprint(min(len(c),len(d),len(e))))\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [140, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u358254559", "n_user": "u358254559", "pos": "n = int(input())\na,b = map(int, input().split())\np = list(map(int, input().split()))\n\ncnt=[0,0,0]\nfor poi in p:\n if poi <= a:\n \tcnt[0]+=1\n elif poi <=b:\n cnt[1]+=1\n else:\n cnt[2]+=1\nprint(min(cnt))", "neg": "n = int(input())\na,b = map(int, input().split())\np = list(map(int, input().split()))\n\ncnt=[0,0,0]\nfor poi in p:\n if poi <= a:\n \tcnt[0]+=1\n elif poi <=b:\n cnt[1]+=1\n else:\n cnt[2]+=1\nprint(max(cnt))", "jacc_sim": 0.9375, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [99, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u970809473", "n_user": "u970809473", "pos": "n = int(input())\na,b = map(int, input().split())\nres = [0,0,0]\narr = list(map(int, input().split()))\nfor i in range(n):\n if arr[i] <= a:\n res[0] += 1\n elif arr[i] <= b:\n res[1] += 1\n else:\n res[2] += 1\nprint(min(res))\n", "neg": "n = int(input())\na,b = map(int, input().split())\nres = [0,0,0]\narr = list(map(int, input().split()))\nfor i in range(n):\n if arr[i] <= a:\n res[0] += 1\n elif arr[i] <= b:\n res[1] += 1\n else:\n res[2] += 1\nprint(min(arr))", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [107, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u843135954", "n_user": "u843135954", "pos": "import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn = ni()\na,b = na()\np = na()\nc = [0,0,0]\n\nfor i in p:\n if i <= a:\n c[0] += 1\n elif a+1 <= i <= b:\n c[1] += 1\n else:\n c[2] += 1\n\nprint(min(c))", "neg": "import sys\nstdin = sys.stdin\nsys.setrecursionlimit(10**6)\nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn = ni()\na,b = na()\np = na()\nc = [0,0,0]\n\nfor i in p:\n if i <= a:\n c[0] += 1\n elif a+1 < p <= b:\n c[1] += 1\n else:\n c[2] += 1\n\nprint(c)", "jacc_sim": 0.9772727272727273, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [163, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u239653493", "n_user": "u239653493", "pos": "n=int(input())\na,b=map(int,input().split())\nH=list(map(int,input().split()))\nd=[]\ne=[]\nf=[]\nfor i in range(n):\n k=H[i]\n if k<=a:\n d.append(k)\n elif a=i:\n ans1 = ans1 + 1\n if A+1 <= i <= B:\n ans2 = ans2 + 1\n if B+1 <= i:\n ans3 = ans3 + 1 \n\n\nprint(min(ans1,ans2,ans3))\n", "neg": "N = int(input())\nA, B = map(int, input().split())\nP = listans1 = 0\nans2 = 0\nans3 = 0 \nfor i in P:\n if A>=i:\n ans1 = ans1 + 1\n if A+1 <= i <= B+1:\n ans2 = ans2 + 1\n if B+1 <= i:\n ans3 = ans3 + 1 \n\n\nprint(min(ans1,ans2,ans3))", "jacc_sim": 0.9333333333333333, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [127, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u478266845", "n_user": "u478266845", "pos": "import numpy as np\n\nN = int(input())\n\nA, B = [int(i) for i in input().split()]\n\nP = [int(i) for i in input().split()]\n\n\n\ndef Three_Categorize(P,A,B):\n count_1 = 0\n count_2 = 0\n count_3 = 0\n for i in P:\n if i <= A:\n count_1 +=1\n elif (i > A) & (i <= B):\n count_2 +=1\n elif i > B:\n count_3 +=1\n \n return [count_1, count_2, count_3]\n \n \ncount = Three_Categorize(P,A,B)\nans=min(count)\nprint(ans)\n", "neg": "import numpy as np\n\nN = int(input())\n\nA, B = [int(i) for i in input().split()]\n\nP = [int(i) for i in input().split()]\n\n\n\ndef Three_Categorize(P,A,B):\n count_1 = 0\n count_2 = 0\n count_3 = 0\n for i in P:\n if i <= A:\n count_1 +=1\n elif (i > A) & (i < B):\n count_2 +=1\n elif i > B:\n count_3 +=1\n \n return [count_1, count_2, count_3]\n \n \ncount = Three_Categorize(P,A,B)\nans=1\nfor i in count:\n ans = ans*i\n \nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [194, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u167908302", "n_user": "u167908302", "pos": "#coding:utf-8\nn = int(input())\na, b = map(int, input().split())\np = list(map(int, input().split()))\n\np1 = 0\np2 = 0\np3 = 0\n\nfor i in p:\n if i <= a:\n p1 += 1\n elif i >= (a+1) and i <= b:\n p2 += 1\n elif i >= (b+1):\n p3 += 1\n\nprint(min(min(p1, p2), p3))\n", "neg": "#coding:utf-8\nn = int(input())\na, b = map(int, input().split())\np = list(map(int, input().split()))\n\np1 = 0\np2 = 0\np3 = 0\n\nfor i in p:\n if i <= a:\n p1 += 1\n elif i >= (a+1) and i <= b:\n p2 += 1\n elif i >= (b+1)\n p3 += 1\n\nprint(min(min(p1, p2), p3))", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [131, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u691896522", "n_user": "u691896522", "pos": "n = int(input())\na, b = map(int , input().split())\np = list(map(int, input().split()))\ngroup_a = len([i for i in p if i <= a])\ngroup_b = len([i for i in p if i > a and i <= b])\ngroup_c = len([i for i in p if i > b])\nprint(min(group_a, group_b, group_c))\n", "neg": "n = int(input())\na, b = map(int , input().split())\np = list(map(int, input().split()))\ngroup_a = len([i for i in p if i <= a])\ngroup_b = len([i for i in p if i < a and i <= b])\ngroup_c = len([i for i in p if i > b])\nprint(min( group_a, group_b, group_c))\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [106, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u174273188", "n_user": "u174273188", "pos": "def resolve():\n n = int(input())\n a, b = map(int, input().split())\n p = list(map(int, input().split()))\n low, mid, high = 0, 0, 0\n for pi in p:\n if pi <= a:\n low += 1\n elif a + 1 <= pi <= b:\n mid += 1\n else:\n high += 1\n print(min(low, mid, high))\n\n\nif __name__ == \"__main__\":\n resolve()\n", "neg": "def resolve():\n n = int(input())\n a, b = map(int, input().split())\n p = list(map(int, input().split()))\n low, mid, high = 0, 0, 0\n for pi in p:\n if pi <= a:\n low += 1\n elif a + 1 <= pi <= a:\n mid += 1\n else:\n high += 1\n print(min(low, mid, high))\n\n\nif __name__ == \"__main__\":\n resolve()\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [126, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u391731808", "n_user": "u391731808", "pos": "N = int(input())\nA,B = map(int,input().split())\n*P, = map(int,input().split())\n\na = len([p for p in P if p<=A])\na = min(a,\n len([p for p in P if A= b+1 and n<=c:\n s.append(n)\n li.remove(n)\n break\n else:judge = False\n\n for n in li:\n if n>=c+1:\n s.append(n)\n li.remove(n)\n break\n else:\n judge= False\n\n if len(s) == 3:\n d+=1\n judge = True\n else:judge=False\n\nprint(d)", "neg": "a = int(input())\nb,c = map(int,input().split())\nlis = input().split()\n\nli = [int(l) for l in lis]\n\njudge = True\n\nd = 0\n\nli.sort()\n\nwhile judge:\n \n s = []\n s.append(min(li))\n li.remove(min(li))\n\n for n in li:\n if n >= b+1 and n<=c:\n s.append(n)\n li.remove(n)\n break\n else:judge = False\n\n for n in li:\n if n>=c+1:\n s.append(n)\n li.remove(n)\n break\n else:\n judge= False\n\n if len(s) == 3:\n d+=1\n judge = True\n else:judge=False\n\nprint(d)", "jacc_sim": 0.9767441860465116, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [256, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u422104747", "n_user": "u422104747", "pos": "n=int(input())\na,b=map(int,input().split())\np=[int(i) for i in input().split()]\ncnta=0\ncntb=0\ncntc=0\nfor i in p:\n if i<=a:\n cnta+=1\n elif i<=b:\n cntb+=1\n else:\n cntc+=1\nprint(min(cnta,cntb,cntc))\n", "neg": "n=int(input())\na,b=map(int,input().split())\np=[int(i) for i in input().split()]\ncnta=0\ncntb=0\ncntc=0\nfor i in p:\n if i<=a:\n cnta+=1\n elif i<=b:\n cntb+=1\n else:\n cntc+=1\nprint(cnta*cntb*cntc)", "jacc_sim": 0.9375, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [111, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u197300260", "n_user": "u197300260", "pos": "# _*_ coding:utf-8 _*_\n# Atcoder_AISingProgramming_Contest-B\n# TODO https://aising2019.contest.atcoder.jp/tasks/aising2019_b\n\ndef solveProblem(problemSeed,FirstScore,SecondScore,ScoreList):\n\tfirstBarrier = 0\n\tsecondBarrier = 0\n\tlastBarrier = 0\n\tfor problemNo in range(0,len(ScoreList),+1):\n\t\tproblemScore = ScoreList[problemNo]\n\t\tif problemScore <= FirstScore:\n\t\t\tfirstBarrier = firstBarrier + 1\n\t\telif ( FirstScore+1 <= problemScore ) and ( problemScore <= SecondScore):\n\t\t\tsecondBarrier = secondBarrier + 1\n\t\telse : # secondScore + 1 <= problemScore\n\t\t\tlastBarrier = lastBarrier + 1\n\tproblemPattern = min(firstBarrier, secondBarrier,lastBarrier)\n\tanswer = problemPattern\n\treturn answer\n\n\nif __name__ == '__main__':\n\tN = int(input().strip())\n\tA,B = map(int,input().strip().split(' '))\n\tPs = list(map(int,input().strip().split(' ')))\n\tsolution = solveProblem(N,A,B,Ps)\n\tprint(\"{}\".format(solution))\n", "neg": "# _*_ coding:utf-8 _*_\n# Atcoder_AISingProgramming_Contest-B\n# TODO https://aising2019.contest.atcoder.jp/tasks/aising2019_b\n\ndef solveProblem(problemSeed,FirstScore,SecondScore,ScoreList):\n\tfirstBarrier = 0\n\tsecondBarrier = 0\n\tlastBarrier = 0\n\tfor problemNo in range(0,len(ScoreList),+1):\n\t\tproblemScore = ScoreList(problemNo)\n\t\tif problemScore <= FirstScore:\n\t\t\tfirstBarrier = firstBarrier + 1\n\t\telif ( FirstScore+1 <= problemScore ) and ( problemScore <= SecondScore):\n\t\t\tsecondBarrier = secondBarrier + 1\n\t\telse : # secondScore + 1 <= problemScore\n\t\t\tlastBarrier = lastBarrier + 1\n\tproblemPattern = firstBarrier * secondBarrier * lastBarrier\n\tanswer = problemPattern\n\treturn answer\n\n\nif __name__ == '__main__':\n\tN = int(input().strip())\n\tA,B = map(int,input().strip().split(' '))\n\tPs = list(map(int,input().strip().split(' ')))\n\tsolution = solveProblem(N,A,B,Ps)\n\tprint(\"{}\".format(solution))\n", "jacc_sim": 0.9594594594594594, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [318, 315], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u758933970", "n_user": "u758933970", "pos": "N = int(input())\nA, B = [int(_) for _ in input().split()]\nP = [int(_) for _ in input().split()]\nx = len([i for i in P if i <= A])\ny = len([i for i in P if i <= B and i >= A+1])\nz = len([i for i in P if i >= B + 1])\n \nif x != 0 and y != 0 and z != 0:\n print(min([x,y,z]))\nelse :\n print(0)", "neg": "N = int(input())\nA, B = [int(_) for i in input().split()]\nP = [int(_) for i in input().split()] \nx = len([i for i in P if i <= A])\ny = len([i for i in P if i <= B and i >= A+1])\nz = len([i for i in P if i <= B])\n\nif x != 0 and y != 0 and z != 0:\n print(min([x,y,z]))\nelse :\n print(0)", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [129, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u582705534", "n_user": "u828766688", "pos": "N = int(input())\n(A, B) = list(map(int, input().split()))\nP = list(map(int, input().split()))\nCOUNT = [0, 0, 0]\nfor i in sorted(P):\n if i <= A:\n COUNT[0] += 1\n elif i <= B:\n COUNT[1] += 1\n else:\n COUNT[2] += 1\nprint(min(COUNT))\n", "neg": "N = int(input())\nA,B = map(int,input().split())\n\nlis = []\n\nP = list(map(int,input().split()))\n\nfor i in P:\n if i <= A:\n lis[0] += 1\n elif i <= B:\n lis[1] += 1\n else:\n lis[2] += 1\n \nprint (min(lis))", "jacc_sim": 0.9090909090909091, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [106, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u576917804", "n_user": "u576917804", "pos": "n=int(input())\na,b = map(int,input().split())\np = map(int,input().split())\n\n\n\nlist1 = []\nlist2 = []\nlist3 = []\n\nfor i in p:\n if i<=a:\n list1.append(i)\n elif i<=b:\n list2.append(i)\n else:\n list3.append(i)\n\n\nif len(list1)>=len(list2):\n if len(list2)>=len(list3):\n print(len(list3))\n else:\n print(len(list2))\nelse:\n if len(list1)>=len(list3):\n print(len(list3))\n else:\n print(len(list1))\n", "neg": "n=int(input())\na,b = map(int,input().split())\np = map(int,input().split())\n\nprint(p)\n\nlist1 = []\nlist2 = []\nlist3 = []\n\nfor i in p:\n if i<=a:\n list1.append(i)\n elif i<=b:\n list2.append(i)\n else:\n list3.append(i)\n\n\nif len(list1)>=len(list2):\n if len(list2)>=len(list3):\n print(len(list3))\n else:\n print(len(list2))\nelse:\n if len(list1)>=len(list3):\n print(len(list3))\n else:\n print(len(list1))", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [196, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u297590902", "n_user": "u297590902", "pos": "N = int(input())\nA,B=(int(x) for x in input().split())\nscores = input().split()\nnum = [0,0,0]\nfor i in range(N):\n score = int(scores[i])\n if (score <= A):\n num[0] += 1\n elif(score <= B):\n num[1] += 1\n else:\n num[2] += 1\nmax_value = num[2]\nfor i in range(2):\n if max_value > num[i]:\n max_value = num[i]\nprint(max_value)", "neg": "N = int(input())\nA,B=(int(x) for x in input().split())\nscores = input().split()\nnum = [0,0,0]\nfor i in range(N):\n score = int(scores[i])\n if (score <= A):\n num[0] += 1\n elif(score <= B):\n num[1] += 1\n else:\n num[2] +=1\nmax_value = 0\nfor i in range(3):\n if max_value < num[i]:\n max_value = num[i]\nprint(max_value)", "jacc_sim": 0.9411764705882353, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [146, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u593063683", "n_user": "u593063683", "pos": "# B\nN = int(input())\nA, B = [int(x) for x in input().split()]\nP = [int(x) for x in input().split()]\n#print(N,A,B)#\nP.sort()\n#print(P)#\n\nfor i in range(N):\n if P[i]>A: break\na = i # A \u4ee5\u4e0b\u306e\u679a\u6570\nfor i in range(a,N):\n if P[i]>B: break\nelse:\n i = N\nb = i - a # A+1\u4ee5\u4e0aB\u4ee5\u4e0b\u306e\u679a\u6570\nc = N - i\n#print(a,b,c)#\n#count = min(a+1, b-a+1, N-b)\ncount = min(a, b, c)\nprint(count)\n\n", "neg": "# B\nN = int(input())\nA, B = [int(x) for x in input().split()]\nP = [int(x) for x in input().split()]\n#print(N,A,B)#\n#print(P)#\nP.sort()\nfor i in range(N):\n if P[i]>A: break\na = i # A \u4ee5\u4e0b\u306e\u679a\u6570\nfor i in range(A+1,N):\n if P[i]>B: break\nb = i - a # B\u4ee5\u4e0b\u306e\u679a\u6570\n#print(a,b)#\n#count = min(a+1, b-a+1, N-b)\ncount = min(a, b, N-(b+a))\nprint(count)\n\n", "jacc_sim": 0.926829268292683, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [224, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u179169725", "n_user": "u179169725", "pos": "N = int(input())\nA, B = list(map(int, input().split()))\nP = list(map(int, input().split()))\n\nP.sort()\n\nc1, c2, c3 = 0, 0, 0\nfor i, p in enumerate(P, 1):\n if p <= A:\n c1 = i\n if (p > A) and (p <= B):\n c2 = i\n if p > B:\n c3 = i\n\n\nif c1 <= c2 <= c3:\n print(min((c1), (c2 - c1), (c3 - c2)))\nelse:\n print(0)\n", "neg": "N = int(input())\nA, B = list(map(int, input().split()))\nP = list(map(int, input().split()))\n\nP.sort()\n\nc1, c2, c3 = 0, 0, 0\nfor i, p in enumerate(P, 1):\n if p <= A:\n c1 = i\n if (p > A) and (p <= B):\n c2 = i\n if p > B:\n c3 = i\n\nprint(c1, c2, c3)\nprint(min((c1), (c2 - c1), (c3 - c2)))\n", "jacc_sim": 0.9705882352941176, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [162, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u079482478", "n_user": "u079482478", "pos": "N = int(input())\nA,B = map(int,input().split())\np = list(map(int,input().split()))\ncntA = 0\ncntB = 0\ncntC = 0\n\nfor i in range(N):\n if int(p[i]) <= int(A):\n cntA += 1\n if int(p[i]) >= int(B)+1:\n cntB += 1\n if int(p[i]) >= int(A)+1 and int(p[i]) <= int(B):\n cntC += 1\n\nprint(min(cntA,cntB,cntC))\n", "neg": "N = int(input())\nA,B = map(int,input().split())\np = list(map(int,input().split()))\ncntA = 0\ncntB = 0\ncntC = 0\n\nfor i in range(N):\n if int(p[i]) <= int(A):\n cntA += 1\n if int(p[i]) >= int(B)+1:\n cntB += 1\n if int(p[i]) >= int(A)+1 and int(p[i]) < int(B):\n cntC += 1\n\nprint(min(cntA,cntB,cntC))\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [148, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u667469290", "n_user": "u667469290", "pos": "# -*- coding: utf-8 -*-\n\n\ndef solve():\n N = int(input())\n A,B = map(int,input().split())\n P = list(map(int,input().split()))\n P1 = list(p for p in P if p<=A)\n P2 = list(p for p in P if A= p >= A+1:\n countb += 1\n elif p >= B+1:\n countc +=1\nprint(min(min(counta,countb),countc))", "neg": "N = int(input())\nA, B = map(int,input().split())\nlist = [int(x) for x in input().split()]\ncounta = 0\ncountb = 0\ncountc = 0 \nfor p in list:\n if p < A:\n counta += 1\n elif B > p >= A+1:\n countb += 1\n elif p >= B+1:\n countc +=1\nprint(min(min(counta,countb),countc))", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [118, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u042644898", "n_user": "u042644898", "pos": "import math\ndef nCast(number):\n if type(number)==str:\n return int(number)\n for idx in range(0,len(number)):\n if type(number[idx])==str:\n\n number[idx]=int(number[idx])\n else:\n nCast(number[idx])\n return number\n \ndef inputArr(w):\n l=list()\n for idx in range(0,w):\n l.append(input().split())\n return l\ndef inputArr1(w):\n l=list()\n for idx in range(0,w):\n l.append(input())\n return l\nn=nCast(input())\nab=nCast(input().split())\np=nCast(input().split())\nx,y,z=0,0,0\nfor number in p:\n if number<=ab[0]:\n x+=1\n elif number>ab[1]:\n z+=1\n else:\n y+=1\nprint(min(x,y,z))\n", "neg": "import math\ndef nCast(number):\n if type(number)==str:\n return int(number)\n for idx in range(0,len(number)):\n if type(number[idx])==str:\n\n number[idx]=int(number[idx])\n else:\n nCast(number[idx])\n return number\n \ndef inputArr(w):\n l=list()\n for idx in range(0,w):\n l.append(input().split())\n return l\ndef inputArr1(w):\n l=list()\n for idx in range(0,w):\n l.append(input())\n return l\nn=nCast(input())\nab=nCast(input().split())\np=nCast(input().split())\nx,y,z=0,0,0\nfor number in p:\n if numberab[1]:\n z+=1\n else:\n y+=1\nprint(min(x,y,z))\n", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [259, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u674885198", "n_user": "u674885198", "pos": "N=int(input())\nA,B = list(map(int, input().split()))\nlis = list(map(int, input().split()))\nlis_1=[]\nlis_2=[]\nlis_3=[]\nfor i in lis:\n if i <= A:\n lis_1.append(i)\n elif i > A and i <=B:\n lis_2.append(i)\n else:\n lis_3.append(i)\n\nprint(min([len(lis_1),len(lis_2),len(lis_3)]))", "neg": "N=int(input())\nA,B = list(map(int, input().split()))\nlis = list(map(int, input().split())))\nlis_1=[]\nlis_2=[]\nlis_3=[]\nfor i in lis:\n if i <= A:\n lis_1.append(i)\n elif i > A and i <=B:\n lis_2.append(i)\n else:\n lis_3.append(i)\n\nprint(min[len(lis_1),len(lis_2),len(lis_3)])", "jacc_sim": 1.0, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [149, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u603234915", "n_user": "u603234915", "pos": "N = int(input())\nA, B = map(int, input().split())\nP = [i for i in map(int, input().split())]\n\nP.sort()\n\n\np_1 = list(filter(lambda x: x<=A, P))\np_2 = list(filter(lambda x: A < x <= B, P))\np_3 = list(filter(lambda x: B b:\n c[2] +=1\n else:\n c[1]+=1\nprint(min(c))", "jacc_sim": 0.9117647058823529, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [100, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u352623442", "n_user": "u496815777", "pos": "n = int(input())\na,b = map(int,input().split())\np = list(map(int,input().split()))\n\nx = 0\ny = 0\nz = 0\nfor i in range(n):\n if (p[i]<=a):\n x += 1\n elif (a+1 <= p[i]<= b):\n y += 1\n else:\n z += 1\n\nprint(min(x,y,z))\n", "neg": "n = int(input())\na, b = map(int, input().split())\np = list(map(int,input().split()))\nx = 0\ny = 0\nz = 0\n \nfor i in range(n):\n if p[i] < a:\n x = x + 1\n if a < p[i] < b:\n y = y + 1\n else:\n z = z+1\n\nprint(min(x, y, z))", "jacc_sim": 0.9696969696969697, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [114, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u923279197", "n_user": "u062621835", "pos": "n = int(input())\na,b = map(int,input().split())\np = list(map(int,input().split()))\nans = [0,0,0]\nfor i in p:\n if i<=a:\n ans[0] +=1\n elif i<= b:\n ans[1] += 1\n else:\n ans[2] += 1\nprint(min(ans))", "neg": "n=int(input())\na,b = list(map(int, input().split()))\np = list(map(int, input().split()))\n\nq = list([0,0,0])\nfor i in p:\n if i <= a:\n q[0] += 1\n elif i >= b:\n q[2] += 1\n else:\n q[1] +=1\n\nprint(min(q))\n", "jacc_sim": 0.9090909090909091, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [100, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03156", "p_user": "u743272507", "n_user": "u308914480", "pos": "n = int(input())\na,b = map(int,input().split())\np = list(map(int,input().split()))\n\nr = [0]*3\nfor i in p:\n if i <= a:\n r[0] += 1\n elif i <= b:\n r[1] += 1\n else:\n r[2] += 1\nprint(min(r)) ", "neg": "n=int(input())\na,b=map(int, input().split())\np=list(map(int, input().split())\nc=[0]*3\nfor i in p:\n if i <=a:\n c[0] +=1\n elif i>b:\n c[2] +=1\n else:\n c[1]+=1\nprint(min(c))", "jacc_sim": 0.9142857142857143, "nl": "You have created N problems for programming contests, each with a specific score. You want to hold as many contests as possible, with each contest having three problems. The first problem's score must be less than or equal to A, the second's score must be between A+1 and B (inclusive), and the third's score must be greater than or equal to B+1. The same problem cannot be used in multiple contests. Find the maximum number of contests that can be held. The constraints are: 3 \u2264 N \u2264 100, 1 \u2264 Pi \u2264 20, 1 \u2264 A < B < 20, and all input values are integers. The input format is N, A, B, followed by the scores of the N problems. Output the maximum number of contests that can be held.", "before_after_length": [97, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03158", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nfrom itertools import accumulate\nimport bisect\nn,q = map(int,input().split())\nif n%2:\n a = [0]+list(map(int,input().split()))\n n += 1\nelse:\n a = list(map(int,input().split()))\nfs = [a[i] if i%2 else 0 for i in range(n)]\naccss = [0]*n\naccff = list(accumulate(a))\naccfs = list(accumulate(fs))\nxls = []\nxpt = []\nfor i in range(n//2):\n xls.append((a[2*i+1]+a[i+n//2])/2)\n if i == 0:\n xpt.append(accff[n-1]-accff[n//2-1])\n else:\n xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])\nfor _ in range(q):\n x = bisect.bisect_left(xls,int(input()))\n if x >= n//2:\n print(xpt[-1])\n else:\n print(xpt[x])", "neg": "from itertools import accumulate\nimport bisect\nn,q = map(int,input().split())\nif n%2:\n a = [0]+list(map(int,input().split()))\n n += 1\nelse:\n a = list(map(int,input().split()))\nfs = [a[i] if i%2 else 0 for i in range(n)]\naccss = [0]*n\naccff = list(accumulate(a))\naccfs = list(accumulate(fs))\nxls = []\nxpt = []\nprint(accff)\nprint(accfs)\nfor i in range(n//2):\n xls.append((a[2*i+1]+a[i+n//2])/2)\n if i == 0:\n xpt.append(accff[n-1]-accff[n//2-1])\n else:\n xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])\nfor _ in range(q):\n x = bisect.bisect_left(xls,int(input()))\n if x >= n-1:\n print(xpt[-1])\n else:\n print(xpt[x])", "jacc_sim": 0.94, "nl": "You have N cards with different integers written on them. Takahashi and Aoki play a game where Aoki chooses an integer x, and starting from Takahashi, the players alternately take a card. Takahashi takes the card with the largest integer among the remaining cards, while Aoki takes the card with the integer closest to x among the remaining cards. For each given x, find the sum of the integers on the cards that Takahashi will take. Constraints: 2 \u2264 N \u2264 100,000, 1 \u2264 Q \u2264 100,000, 1 \u2264 A1 < A2 < ... < AN \u2264 10^9, 1 \u2264 Xi \u2264 10^9. Input format: N Q A1 AN X1 X2 ... XQ. Output format: Print Q lines, each containing the answer for x = Xi. Example: Input: 5 5 3 5 7 11 13 1 4 9 10 13. Output: 31 31 27 23 23.", "before_after_length": [305, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03158", "p_user": "u803848678", "n_user": "u803848678", "pos": "# http://kmjp.hatenablog.jp/entry/2019/01/13/0930\nimport sys\ninput = sys.stdin.readline\n\nfrom bisect import bisect_left\n\nn, q = map(int, input().split())\na = list(map(int, input().split()))\nxs = [int(input()) for i in range(q)]\n\ns = [0]*(n+1)\nse = [0]*(n+1)\nfor i in range(n):\n s[i+1] = s[i] + a[i]\n if i :\n se[i+1] = se[i-1]\n se[i+1] += a[i]\n\ndef check(x, k):\n if k > n:\n return False\n\n Tk = (k+1)//2\n i = bisect_left(a, x- (a[n-Tk]-x))\n return i+k <= n\n\nfor x in xs:\n left = 0\n right = n+1\n while right-left > 1:\n mid = (left+right)//2\n if check(x, mid):\n left = mid\n else:\n right = mid\n top = (left+1)//2\n ans = 0\n ans += s[n] - s[n-top]\n if left%2:\n left += 1\n ans += se[n-left] if n-left>=0 else 0\n print(ans)", "neg": "# http://kmjp.hatenablog.jp/entry/2019/01/13/0930\nimport sys\ninput = sys.stdin.readline\n\nfrom bisect import bisect_left\n\nn, q = map(int, input().split())\na = list(map(int, input().split()))\nxs = [int(input()) for i in range(q)]\n\n# \u7d2f\u7a4d\u548c\ns = [0]*(n+1)\nse = [0]*(n+1)\nfor i in range(n):\n s[i+1] = s[i] + a[i]\n if i :\n se[i+1] = se[i-1]\n se[i+1] += a[i]\n\ndef check(x, k):\n if k > n:\n return False\n\n Tk = (k+1)//2\n i = bisect_left(a, x- (a[n-Tk]-x))\n return i+k <= n\n\nfor x in xs:\n left = 0\n right = n+1\n while right-left > 1:\n mid = (left+right)//2\n if check(x, mid):\n left = mid\n else:\n right = mid\n top = (left+1)//2\n ans = 0\n ans += s[n] - s[n-top]\n if left%2:\n left += 1\n ans += se[n-left]\n print(ans)", "jacc_sim": 0.9565217391304348, "nl": "You have N cards with different integers written on them. Takahashi and Aoki play a game where Aoki chooses an integer x, and starting from Takahashi, the players alternately take a card. Takahashi takes the card with the largest integer among the remaining cards, while Aoki takes the card with the integer closest to x among the remaining cards. For each given x, find the sum of the integers on the cards that Takahashi will take. Constraints: 2 \u2264 N \u2264 100,000, 1 \u2264 Q \u2264 100,000, 1 \u2264 A1 < A2 < ... < AN \u2264 10^9, 1 \u2264 Xi \u2264 10^9. Input format: N Q A1 AN X1 X2 ... XQ. Output format: Print Q lines, each containing the answer for x = Xi. Example: Input: 5 5 3 5 7 11 13 1 4 9 10 13. Output: 31 31 27 23 23.", "before_after_length": [363, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u476604182", "n_user": "u476604182", "pos": "class BIT:\n \n def __init__(self, N):\n self.n = N\n self.tree = [0]*(self.n+1)\n \n def bsum(self, i):\n s = 0\n while i:\n s += self.tree[i]\n i -= i&(-i)\n return s\n \n def badd(self, i, x):\n while i<=self.n:\n self.tree[i] += x\n i += i&(-i)\n \n def bsearch(self, x):\n i = 0\n s = 0\n step = 1<<(self.n.bit_length()-1)\n while step:\n if i+step<=self.n and s+self.tree[i+step]>= 1\n return i+1\n\n \nN = int(input())\nP = [0]+[int(c) for c in input().split()]\n\nntoi = [0]*(N+1)\nfor i in range(N+1):\n ntoi[P[i]] = i\n\nbit = BIT(N)\n\nans = 0\nfor m in range(N, 0, -1):\n I = ntoi[m]\n L = bit.bsum(I)\n bit.badd(I,1)\n R = N-L-m\n a = bit.bsearch(L-1) if L>1 else 0\n b = bit.bsearch(L) if L>0 else 0\n c = bit.bsearch(L+2) if R>0 else N+1\n d = bit.bsearch(L+3) if R>1 else N+1\n coef = 0\n if b!=0:\n coef += (b-a)*(c-I)\n if c!=0:\n coef += (I-b)*(d-c)\n ans += m*coef\n\nprint(ans)", "neg": "class BIT:\n \n def __init__(self, N):\n self.n = N\n self.tree = [0]*(self.n+1)\n \n def bsum(self, i):\n s = 0\n while i:\n s += self.tree[i]\n i -= i&(-i)\n return s\n \n def badd(self, i, x):\n while i<=self.n:\n self.tree[i] += x\n i += i&(-i)\n \n def bsearch(self, x):\n i = 0\n step = 1<<(self.n.bit_length()-1)\n while step:\n if i+step<=self.n and self.tree[i+step]>= 1\n return i+1\n\n \nN = int(input())\nP = [0]+[int(c) for c in input().split()]\n\nntoi = [0]*(N+1)\nfor i in range(N+1):\n ntoi[P[i]] = i\n\nbit = BIT(N)\n\nans = 0\nfor m in range(N, 0, -1):\n I = ntoi[m]\n L = bit.bsum(I)\n bit.badd(I,1)\n R = N-L-m\n a = bit.bsearch(L-1) if L>1 else 0\n b = bit.bsearch(L) if L>0 else 0\n c = bit.bsearch(L+2) if R>0 else N+1\n d = bit.bsearch(L+3) if R>1 else N+1\n coef = 0\n if b!=0:\n coef += (b-a)*(c-I)\n if c!=0:\n coef += (I-b)*(d-c)\n ans += m*coef\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [489, 472], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u327179339", "n_user": "u327179339", "pos": "N = int(input())\nP = [None] + list(map(int, input().split()))\n\np_to_index = [None] * (N + 1)\nfor index, x in enumerate(P[1:], 1):\n p_to_index[x] = index\n\n\ndef BIT_add(i):\n while i <= N:\n tree[i] += 1\n i += i & (-i)\n\ndef BIT_sum(i):\n s = 0\n while i:\n s += tree[i]\n i -= i & (-i)\n return s\n\ndef BIT_search(x):\n i = 0\n s = 0\n step = 1 << (len(bin(N)[2:]) - 1)\n while step:\n if i + step <= N and s + tree[i + step] < x:\n i += step\n s += tree[i]\n step >>= 1\n return i + 1\n\ntree = [0] * (N + 1)\nans = 0\nfor x in range(N, 0, -1):\n c = p_to_index[x]\n L = BIT_sum(c)\n R = N - x - L\n a = BIT_search(L - 1) if L >= 2 else 0\n b = BIT_search(L) if L >= 1 else 0\n d = BIT_search(L + 1) if R >= 1 else N + 1\n e = BIT_search(L + 2) if R >= 2 else N + 1\n BIT_add(c)\n tmp = 0\n if b != 0:\n tmp += (b - a) * (d - c)\n if d != 0:\n tmp += (e - d) * (c - b)\n ans += tmp * x\n\nprint (ans)", "neg": "N = int(input())\nP = [None] + list(map(int, input().split()))\n\np_to_index = [None] * (N + 1)\nfor index, x in enumerate(P[1:], 1):\n p_to_index[x] = index\n\n\ndef BIT_add(i):\n while i <= N:\n tree[i] += 1\n i += i & (-i)\n\ndef BIT_sum(i):\n s = 0\n while i:\n s += tree[i]\n i -= i & (-i)\n return s\n\ndef BIT_search(x):\n i = 0\n s = 0\n step = 1 << (len(bin(N)[2:]) - 1)\n while step:\n if i + step <= N and s + tree[i + step] < x:\n i += step\n s += tree[i]\n step >>= 1\n return i + 1\n\ntree = [0] * (N + 1)\nans = 0\nfor x in range(N, 0, -1):\n c = p_to_index[x]\n L = BIT_sum(c) -1\n R = N - x - L\n a = BIT_search(L - 1) if L >= 2 else 0\n b = BIT_search(L) if L >= 1 else 0\n d = BIT_search(L + 1) if R >= 1 else N + 1\n e = BIT_search(L + 2) if R >= 2 else N + 1\n BIT_add(c)\n tmp = 0\n if b != 0:\n tmp += (b - a) * (d - c)\n if d != 0:\n tmp += (e - d) * (c - b)\n ans += tmp * x\n\nprint (ans)\n", "jacc_sim": 1.0, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [434, 437], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u414980766", "n_user": "u414980766", "pos": "import bisect\nimport array\nN = int(input())\nP = list(map(int, input().split()))\nP_id = [0]*(N + 1)\n\nfor i in range(N):\n P_id[P[i]] = i\n\nA = array.array('i', [- 1, P_id[N], N])\n\n\nres = 0\nfor i in range(N - 1, 0, - 1):\n j = bisect.bisect_left(A, P_id[i])\n A.insert(j, P_id[i])\n l1 = A[j - 1]\n r1 = A[j + 1]\n l2 = l1\n r2 = r1\n if l1 != - 1:\n l2 = A[j - 2]\n if r1 != N:\n r2 = A[j + 2]\n \n res += i*((A[j] - l1)*(r2 - r1) + (l1 - l2)*(r1 - A[j]))\n\nprint(res)", "neg": "import bisect\nN = int(input())\nP = map(int, input().split())\nP_id = [0]*(N + 1)\n\nfor i in range(N):\n P_id[P[i]] = i\n\nA = [- 1, P_id[N], N] \n\nres = 0\nfor i in range(N - 1, 0, - 1):\n j = bisect.bisect_left(A, P_id[i])\n A.insert(j, P_id[i])\n l1 = A[j - 1]\n r1 = A[j + 1]\n l2 = l1\n r2 = r1\n if l1 != - 1:\n l2 = A[j - 2]\n if r1 != N:\n r2 = A[j + 2]\n \n res += i*((A[j] - l1)*(r2 - r1) + (l1 - l2)*(r1 - A[j]))\n\nprint(res)", "jacc_sim": 0.9285714285714286, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [257, 244], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u263830634", "n_user": "u263830634", "pos": "N = int(input())\nP = list(map(int, input().split()))\n\nindex_lst = [0] * N\nfor index, i in enumerate(P):\n index_lst[i - 1] = index\n\nleft_next_Index = list(range(-1, N - 1)) + [-1, -1]\nright_next_Index = list(range(1, N + 1)) + [N, N]\n# print (left_next_Index)\n# print (right_next_Index)\nans = 0\nfor i in range(1, N):\n index = index_lst[i - 1]\n # print (i, index)\n l1 = left_next_Index[index]\n l2 = left_next_Index[l1]\n r1 = right_next_Index[index]\n r2 = right_next_Index[r1]\n # print ('l1 =', l1, ' l2 =', l2, ' r1 =', r1, ' r2 =', r2)\n ans += i * ((index - l1) * (r2 - r1) + (r1 - index) * (l1 -l2))\n\n left_next_Index[r1] = l1\n right_next_Index[l1] = r1\n\nprint (ans)", "neg": "N = int(input())\nP = list(map(int, input().split()))\n\nindex_lst = [0] * N\nfor index, i in enumerate(P):\n index_lst[i - 1] = index\n\nleft_next_Index = list(range(-1, N - 1)) + [-1]\nright_next_Index = list(range(1, N + 1)) + [N]\n# print (left_next_Index)\n# print (right_next_Index)\nans = 0\nfor i in range(1, N):\n index = index_lst[i - 1]\n # print (i, index)\n l1 = left_next_Index[index]\n l2 = left_next_Index[l1]\n r1 = right_next_Index[index]\n r2 = right_next_Index[r1]\n # print ('l1 =', l1, ' l2 =', l2, ' r1 =', r1, ' r2 =', r2)\n ans += i * ((index - l1) * (r2 - r1) + (r1 - index) * (l1 -l2))\n\n left_next_Index[r1] = l1\n right_next_Index[l1] = r1\n\nprint (ans)", "jacc_sim": 1.0, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [316, 311], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u716530146", "n_user": "u716530146", "pos": "#!/usr/bin/env python3\nans=0\nn=int(input())\np=list(map(int,input().split()))\nb=[0]*(n+1)\nfor i in range(n):\n b[p[i]]=i+1\nLL=[0]+[i for i in range(n+1)]\nRR=[i for i in range(1,n+2)]+[n+1]\nfor i in range(1,n+1):\n l1=LL[b[i]]\n l0=LL[l1]\n r0=RR[b[i]]\n r1=RR[r0]\n ans+=((l1-l0)*(r0-b[i])+(r1-r0)*(b[i]-l1))*i\n LL[r0]=l1\n RR[l1]=r0\n\nprint(ans)\n", "neg": "#!/usr/bin/env python3\nans=0\nn=int(input())\np=list(map(int,input().split()))\nb=[0]*(n+1)\nfor i in range(n):\n b[p[i]]=i+1\nLL=[0]+[i for i in range(n+1)]\nRR=[i for i in range(n+1)]+[n+1]\nfor i in range(1,n+1):\n l1=LL[b[i]]\n l0=LL[l1]\n r0=RR[b[i]]\n r1=RR[r0]\n ans+=((l1-l0)*(r1-b[i])+(r1-r0)*(b[i]-l1))*i\nprint(ans)\n", "jacc_sim": 0.975609756097561, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [222, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u734548018", "n_user": "u734548018", "pos": "#!/usr/bin/python3\n# -*- coding: utf-8 -*-\n\n\n\nN = int(input())\nPn = list(map(int, input().split()))\n\nIn = [0] * (N+1)\nfor i in range(N):\n In[Pn[i]] = i+1\n\ncnt = 0\nl = [0] + [i for i in range(N+1)]\nr = [i+1 for i in range((N+1))] + [N+1]\n\nfor v in range(1, N+1):\n i = In[v]\n \n l1 = l[i]\n l2 = l[l1]\n r1 = r[i]\n r2 = r[r1]\n cnt += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * v\n \n l[r1] = l1\n r[l1] = r1\n \nprint(cnt)\n", "neg": "#!/usr/bin/python3\n# -*- coding: utf-8 -*-\n\n\n\nN = int(input())\nPn = list(map(int, input().split()))\n\nIn = [0] * (N+1)\nfor i in range(N):\n In[Pn[i]] = i+1\nprint(Pn)\nprint(In)\n\ncnt = 0\nl = [0] + [i for i in range(N+1)]\nr = [i+1 for i in range((N+1))] + [N+1]\n\nfor v in range(1, N+1):\n i = In[v]\n \n l1 = l[i]\n l2 = l[l1]\n r1 = r[i]\n r2 = r[r1]\n cnt += ((l1-l2) * (r1-i) + (i-l1) * (r2-r1)) * v\n \n l[r1] = l1\n r[l1] = r1\n \nprint(cnt)\n", "jacc_sim": 1.0, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [251, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02919", "p_user": "u693716675", "n_user": "u231189826", "pos": "N = int(input())\nP = list(map(int, input().split()))\n \nleft_bigger = [0] + [i for i in range(N+1)]\nright_bigger = [i+1 for i in range(N+1)] + [N+1]\n \nE = [(v, i+1) for i, v in enumerate(P)]\nE.sort()\n\nans = 0\nfor v,i in E:\n l0=left_bigger[i]\n l1=left_bigger[l0]\n r0=right_bigger[i]\n r1=right_bigger[r0]\n \n ans += ((r1-r0)*(i-l0) + (r0-i)*(l0-l1))*v\n left_bigger[r0]=l0\n right_bigger[l0]=r0\nprint(ans)", "neg": "N = int(input())\nP = list(map(int, input().split()))\n \nleft_bigger = [0] + [i for i in range(N+1)]\nright_bigger = [i+1 for i in range(N+1)] + [N+1]\n \nE = [(v, i+1) for i, v in enumerate(P)]\nE.sort()\n\nans = 0\nfor v,i in E:\n l0=left_bigger[i]\n l1=left_bigger[l0]\n r0=right_bigger[i]\n r1=right_bigger[r0]\n print(left_bigger)\n ans += ((r1-r0)*(i-l0) + (r0-i)*(l0-l1))*v\n left_bigger[r0]=l0\n right_bigger[l0]=r0\nprint(ans)\n\n\n", "jacc_sim": 1.0, "nl": "You are given a permutation P of {1, 2, ..., N}. For a pair (L, R) (1 \u2264 L < R \u2264 N), find the sum of the second largest value among P_L, P_{L+1}, ..., P_R for all pairs (L, R). Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 P_i \u2264 N, P_i \u2260 P_j (i \u2260 j). Input is given as N followed by P_1, P_2, ..., P_N. Output the sum of the second largest values for all pairs (L, R).", "before_after_length": [225, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u047796752", "n_user": "u047796752", "pos": "import sys\ninput = sys.stdin.readline\nfrom collections import *\n\nN = int(input())\nS = input()[:-1]\n\nif S[0]=='W':\n print(0)\n exit()\n \nl = [0]\nans = 1\nMOD = 10**9+7\n\nfor i in range(1, 2*N):\n if S[i]==S[i-1]:\n l.append(1^l[-1])\n else:\n l.append(l[-1])\n\nif l.count(0)!=N:\n print(0)\n exit()\n \nzero = 0\n\nfor li in l:\n if li==0:\n zero += 1\n else:\n ans *= zero\n ans %= MOD\n zero -= 1\n \nfor i in range(1, N+1):\n ans *= i\n ans %= MOD\n\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nfrom collections import *\n\nN = int(input())\nS = input()[:-1]\n\nif S[0]=='W':\n print(0)\n exit()\n \nl = [0]\nans = 1\nMOD = 10**9+7\n\nfor i in range(1, 2*N):\n if S[i]==S[i-1]:\n l.append(1^l[-1])\n else:\n l.append(l[-1])\n\nif l.count(0)!=n:\n print(0)\n exit()\n \nzero = 0\n\nfor li in l:\n if li==0:\n zero += 1\n else:\n ans *= zero\n ans %= MOD\n zero -= 1\n \nfor i in range(1, N+1):\n ans *= i\n ans %= MOD\n\nprint(ans)", "jacc_sim": 0.9791666666666666, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [223, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u619819312", "n_user": "u619819312", "pos": "n=int(input())\ns=input()\nm=10**9+7\nl=1\nfor i in range(1,n+1):l=(l*i)%m\nt=[0]*(2*n)\nt[0]=1\nfor i in range(1,2*n):\n if s[i-1]==s[i]:\n t[i]=1-t[i-1]\n else:\n t[i]=t[i-1]\nif t.count(1)==n and s[0]==s[-1]==\"B\":\n p=1\n c=0\n for i in t:\n c+=i\n if i==0:\n p=(p*c)%m\n c-=1\n print((p*l)%m)\nelse:\n print(0)", "neg": "n=int(input())\ns=input()\nm=10**9+7\nl=1\nfor i in range(1,n+1):l=(l*i)%m\nt=[0]*(2*n)\nt[0]=1\nfor i in range(1,2*n):\n if s[i-1]==s[i]:\n t[i]=1-t[i-1]\n else:\n t[i]=t[i-1]\nif t.count(1)==n:\n p=1\n c=0\n for i in t:\n c+=i\n if i==0:\n p=(p*c)%m\n c-=1\n print((p*l)%m)\nelse:\n print(0)", "jacc_sim": 0.9210526315789473, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [207, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u861962192", "n_user": "u861962192", "pos": "def f_c():\n n = int(input())\n s = input()\n q = 10**9+7\n\n stack, c = 1, 1\n for si in s[1:]:\n if si==\"B\":\n if stack%2==0:\n stack += 1\n else:\n c *= stack\n stack -= 1\n else:\n if stack%2==0:\n c *= stack\n stack -= 1\n else:\n stack += 1\n c %= q\n if stack!=0 or c==0:\n print(0)\n else:\n for i in range(1, n+1):\n c *= i\n c %= q\n print(c)\n\nif __name__ == \"__main__\":\n f_c()\n", "neg": "def f_c():\n n = int(input())\n s = input()\n\n stack, c = 1, 1\n for si in s[1:]:\n if si==\"B\":\n if stack%2==0:\n stack += 1\n else:\n c *= stack\n stack -= 1\n else:\n if stack%2==0:\n c *= stack\n stack -= 1\n else:\n stack += 1\n if stack!=0 | c==0:\n print(0)\n else:\n for i in range(1, n+1):\n c*=i\n print(c%(10**9+7))\n\nif __name__ == \"__main__\":\n f_c()\n", "jacc_sim": 0.926829268292683, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [189, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u223904637", "n_user": "u223904637", "pos": "n=int(input())\ns=list(input())\nm=2*n\nmod=10**9+7\n\nif s[0]==\"W\" or s[m-1]==\"W\":\n print(0)\n exit()\n\nrl=[\"L\"]\nfor i in range(1,m):\n if s[i-1]==s[i]:\n if rl[i-1]==\"R\":\n rl.append(\"L\")\n else: \n rl.append(\"R\")\n else:\n if rl[i-1]==\"L\":\n rl.append(\"L\")\n else: \n rl.append(\"R\")\nif rl[m-1]==\"L\":\n print(0)\n exit()\nnl=0\nfor i in range(m):\n if rl[i]==\"L\":\n nl+=1\nif nl!=n:\n print(0)\n exit()\n \nans=1\nli=0\nri=0\nfor i in range(m):\n if rl[i]==\"L\":\n li+=1\n else:\n if li-ri<0:\n ans=0\n ans*=li-ri\n ans=ans%mod\n ri+=1\n if i>=1 and i<=n:\n ans*=i\n ans=ans%mod\nprint(ans)", "neg": "n=int(input())\ns=list(input())\nm=2*n\nmod=10**9+7\n\nif s[0]==\"W\" or s[m-1]==\"W\":\n print(0)\n exit()\n\nrl=[L]\nfor i in range(1,m):\n if s[i-1]==s[i]:\n if rl[i-1]==\"L\":\n rl.append(\"L\")\n else: \n rl.append(\"R\")\n else:\n if rl[i-1]==\"R\":\n rl.append(\"L\")\n else: \n rl.append(\"R\")\nif rl[m-1]==\"L\":\n print(0)\n exit()\nnl=0\nfor i in range(m):\n if rl[i]==\"L\":\n nl+=1\nif nl!=n:\n print(0)\n exit()\n \nans=1\nli=0\nri=0\nfor i in range(m):\n if rl[i]==\"L\":\n li+=1\n else:\n if li-ri<0:\n ans=0\n ans*=li-ri\n ans=ans%mod\n ri+=1\n if i>=1 and i<=n:\n ans*=i\n ans=ans%mod\nprint(ans)\n \n\n\n ", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [330, 335], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u716530146", "n_user": "u716530146", "pos": "import math\nmod=10**9+7\nn=int(input())*2\nS=list(input())\n# L\u30921\u3001R\u30920\u3068\u3057\u3066DP\ndp=[0]*(n)\ndp[0]=1\nif S[0]=='W' or S[-1]=='W':\n\tprint(0)\n\texit()\nfor i in range(1,n):\n\t# print(S,i)\n\tif S[i]==S[i-1]:\n\t\tdp[i]=0 if dp[i-1] else 1\n\telse:\n\t\tdp[i]=1 if dp[i-1] else 0\n\ncount=1\ncounter=[0]*2\nfor i in range(n):\n\tif dp[i]==0:\n\t\tcount*=counter[1]-counter[0]\n\t\tcount%=mod\n\tcounter[dp[i]]+=1\nif counter[0]!=counter[1]:\n\tprint(0)\n\texit()\n\nprint((count*math.factorial(n//2))%mod)\n# print(dp)\n\n\n", "neg": "import math\nn=int(input())*2\nS=list(input())\n# L\u30921\u3001R\u30920\u3068\u3057\u3066DP\ndp=[0]*(n)\ndp[0]=1\nif S[0]=='W' or S[-1]=='W':\n\tprint(0)\n\texit()\nfor i in range(1,n):\n\t# print(S,i)\n\tif S[i]==S[i-1]:\n\t\tdp[i]=0 if dp[i-1] else 1\n\telse:\n\t\tdp[i]=1 if dp[i-1] else 0\n\ncount=1\ncounter=[0]*2\nfor i in range(n):\n\tif dp[i]==0:\n\t\tcount*=counter[1]-counter[0]\n\t\tcount%=10**9+7\n\tcounter[dp[i]]+=1\nif counter[0]!=counter[1]:\n\tprint(0)\n\texit()\n\nprint((count*math.factorial(n//2))%10**9+7)\n# print(dp)\n\n\n", "jacc_sim": 0.9807692307692307, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [277, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u201234972", "n_user": "u201234972", "pos": "import sys\ninput = sys.stdin.readline\nQ = 10**9+7\ndef main():\n N = int( input())\n S = input()\n left = 0\n ans = 1\n for i in range(N*2):\n s = S[i]\n if s == \"B\":\n if left%2 == 0:\n left += 1\n else:\n ans *= left\n left -= 1\n else:\n if left%2 == 1:\n left += 1\n else:\n ans *= left\n left -= 1\n ans %= Q\n if left > 0 or ans == 0:\n print(0)\n return\n for i in range(1,N+1):\n ans *= i\n ans %= Q\n print(ans)\nif __name__ == '__main__':\n main()", "neg": "import sys\ninput = sys.stdin.readline\nQ = 10**9+7\ndef main():\n N = int( input())\n S = input()\n left = 0\n ans = 1\n for s in S:\n if s == \"B\":\n if left%2 == 0:\n left += 1\n else:\n if left == 0:\n print(0)\n return\n ans *= left\n left -= 1\n else:\n if left%2 == 1:\n left += 1\n else:\n if left == 0:\n print(0)\n return\n ans *= left\n left -= 1\n ans %= Q\n if left > 0:\n print(0)\n return\n for i in range(1,N+1):\n ans *= i\n ans %= Q\n print(ans)\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9347826086956522, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [202, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u492026192", "n_user": "u492026192", "pos": "import sys\ndef main():\n n=int(input())\n s=input()\n MOD=10**9+7\n perm=1\n for i in range(1,n+1):\n perm=perm*i%MOD\n ans=1\n dp=[-1]*(2*n)\n\n dp[0]=1#L\n for i in range(1,2*n):\n if s[i]==s[i-1]:\n dp[i]=1-dp[i-1]\n else:\n dp[i]=dp[i-1]\n if s[0]=='W' or s[-1]=='W' or sum(dp)!=n:\n print(0)\n sys.exit()\n #print(dp)\n count=0\n for i in range(2*n):\n if dp[i]==1:\n count+=1\n else:\n ans*=count\n ans%=MOD\n count-=1\n print(ans*perm%MOD)\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\ndef main():\n n=int(input())\n s=input()\n MOD=10**9+7\n perm=1\n for i in range(1,n+1):\n perm=perm*i%MOD\n ans=1\n dp=[-1]*(2*n)\n\n dp[0]=1#L\n count=0\n for i in range(1,2*n):\n if s[i]==s[i-1]:\n dp[i]=1-dp[i-1]\n else:\n dp[i]=dp[i-1]\n if dp[i]==1:\n count+=1\n else:\n ans*=count\n count-=1\n if s[0]=='W' or s[-1]=='W' or sum(dp)!=n:\n print(0)\n sys.exit()\n #print(dp)\n \n \n print(ans*perm%MOD)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [269, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u442030035", "n_user": "u442030035", "pos": "import sys\nfrom math import factorial\n\nN = int(input())\nS = input()\nmod = 10**9+7\n\nif S[0] == 'W' or S[-1] == 'W':\n print(0)\n sys.exit()\n\nop = \"L\"\nfor i in range(1, 2*N):\n if S[i] == S[i-1]:\n op += 'R' if op[i-1] == 'L' else 'L'\n else:\n op += 'R' if op[i-1] == 'R' else 'L'\n\nif op.count('L') != N:\n print(0)\n sys.exit()\n\nct_L, ans = 0, 1\n\nfor i in op:\n if i == 'L':\n ct_L += 1\n else:\n ans *= ct_L\n ct_L -= 1\n ans %= mod\n\n\nprint(factorial(N) * ans % mod)\n", "neg": "import sys\nfrom math import factorial\n\nN = int(input())\nS = input()\n\nif S[0] == 'W' or S[-1] == 'W':\n print(0)\n sys.exit()\n\nop = \"L\"\nfor i in range(1, 2*N):\n if S[i] == S[i-1]:\n op += 'R' if op[i-1] == 'L' else 'L'\n else:\n op += 'R' if op[i-1] == 'R' else 'L'\n\nif op.count('L') != N:\n print(0)\n sys.exit()\n\nct_L, ans = 0, 1\n\nfor i in op:\n if i == 'L':\n ct_L += 1\n else:\n ans *= ct_L\n ct_L -= 1\n ans %= mod\n\nmod = 10**9+7\nprint(factorial(N) * ans % mod)\n", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [238, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u390618988", "n_user": "u390618988", "pos": "from sys import stdin\n\nN = int(stdin.readline().rstrip())\nS = stdin.readline().rstrip()\n\nans = 1\ninf = 10 ** 9 + 7\nd = 'L'\nl_count = 1\nr_count = 0\n\nif S[0] == 'W' or S[2 * N - 1] == 'W':\n print(0)\n exit()\n\nfor i in range(1, 2 * N):\n if S[i] != S[i - 1]:\n if d == 'R':\n ans *= l_count - r_count\n ans %= inf\n r_count += 1\n else:\n l_count += 1\n else:\n if d == 'R':\n d = 'L'\n l_count += 1\n else:\n ans *= l_count - r_count\n ans %= inf\n d = 'R'\n r_count += 1\n\nif l_count != r_count:\n print(0)\n exit()\n\nfor j in range(1, N + 1):\n ans *= j\n ans %= inf\n\nprint(ans % inf)", "neg": "from sys import stdin\n\nN = int(stdin.readline().rstrip())\nS = stdin.readline().rstrip()\n\nans = 1\ninf = 10 ** 9 + 7\nd = 'L'\nl_count = 1\nr_count = 0\nfor i in range(1, 2 * N):\n if S[i] == 'R':\n ans *= l_count - r_count\n ans %= inf\n if S[i] != S[i - 1]:\n l_count += 1\n else:\n if d == 'R':\n d = 'L'\n else:\n d = 'R'\n r_count += 1\n\nfor j in range(1, N + 1):\n ans *= j\n ans %= inf\n\nprint(ans % inf)\n", "jacc_sim": 0.9361702127659575, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [275, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u820351940", "n_user": "u820351940", "pos": "import sys\nM = 10**9 + 7\nn = int(input()) * 2\ns = list(map(lambda x: int(x == \"W\"), input()))\n\nlr = [0] * n # L: 0, R: 1\n\nif s[0] or s[-1]:\n print(0)\n sys.exit()\n\nl = 1\nans = 1\nfor i, v in enumerate(s[1:], 1):\n if v:\n if l % 2:\n l += 1\n else:\n ans *= l\n l -= 1\n lr[i] = 1\n else:\n if l % 2 == 0:\n l += 1\n else:\n ans *= l\n l -= 1\n lr[i] = 1\n if ans > M:\n ans %= M\n if l < 0:\n print(0)\n sys.exit()\n\nif not lr[-1] or l:\n print(0)\n sys.exit()\n\ndef fact(n):\n result = 1\n for i in range(2, n + 1):\n result *= i\n if result > M:\n result %= M\n return result\nprint((ans * fact(n // 2)) % M)\n", "neg": "import sys\nM = 10**9 + 7\nn = int(input()) * 2\ns = list(map(lambda x: int(x == \"W\"), input()))\n\nlr = [0] * n # L: 0, R: 1\n\nif s[0] or s[-1]:\n print(0)\n sys.exit()\n\nl = 1\nans = 1\nfor i, v in enumerate(s[1:], 1):\n if v:\n if l % 2:\n l += 1\n else:\n ans *= l\n l -= 1\n lr[i] = 1\n else:\n if l % 2 == 0:\n l += 1\n else:\n ans *= l\n l -= 1\n lr[i] = 1\n if ans > M:\n ans %= M\n if l < 0:\n print(0)\n sys.exit()\n\nif not lr[-1] or l == 0:\n print(0)\n sys.exit()\n\ndef fact(n):\n result = 1\n for i in range(2, n + 1):\n result *= i\n if result > M:\n result %= M\n return result\nprint((ans * fact(n // 2)) % M)\n", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [299, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u107639613", "n_user": "u107639613", "pos": "n = int(input())\nS = [v for v in input()]\n\n# determine L or R\nlst = [0 for i in range(2 * n)]\nfor i in range(2 * n):\n if S[i] == 'W' and (2 * n - i - 1) % 2 == 0:\n lst[i] = 'L'\n elif S[i] == 'W' and (2 * n - i - 1) % 2 == 1:\n lst[i] = 'R'\n elif S[i] == 'B' and (2 * n - i - 1) % 2 == 0:\n lst[i] = 'R'\n elif S[i] == 'B' and (2 * n - i - 1) % 2 == 1:\n lst[i] = 'L'\n\n\ndeq = 0\nval = 1\n#tracing lst\nfor i in range(2 * n):\n if lst[i] == 'L':\n deq += 1\n elif lst[i] == 'R':\n val *= deq\n val %= 10 ** 9 + 7\n deq -= 1\n\nif deq != 0:\n print(0)\nelse:\n for i in range(1, n + 1):\n val = val * i % (10 ** 9 +7)\n print(val)\n", "neg": "n = int(input())\nS = [v for v in input()]\n\n# determine L or R\nlst = [0 for i in range(2 * n)]\nfor i in range(2 * n):\n if S[i] == 'W' and (2 * n - i - 1) % 2 == 0:\n lst[i] = 'L'\n elif S[i] == 'W' and (2 * n - i - 1) % 2 == 1:\n lst[i] = 'R'\n elif S[i] == 'B' and (2 * n - i - 1) % 2 == 0:\n lst[i] = 'R'\n elif S[i] == 'B' and (2 * n - i - 1) % 2 == 1:\n lst[i] = 'L'\n\nprint(lst)\n\ndeq = 0\nval = 1\n#tracing lst\nfor i in range(2 * n):\n if lst[i] == 'L':\n deq += 1\n elif lst[i] == 'R':\n val *= deq\n val %= 10 ** 9 + 7\n deq -= 1\n\nif deq != 0:\n print(0)\nelse:\n for i in range(1, n + 1):\n val = val * i % (10 ** 9 +7)\n print(val)\n", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [318, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u917092881", "n_user": "u917092881", "pos": "def resolve():\n n = int(input())\n s_list = list(input())\n mod = 10 ** 9 + 7\n\n if s_list[0] == \"W\" or s_list[-1] == \"W\":\n print(0)\n return\n\n from math import factorial\n\n l_counter = 0\n res = 1\n\n for i in range(2 * n):\n s = s_list[i]\n if i % 2 == 0:\n s = \"W\" if s == \"B\" else \"B\"\n\n if s == \"W\":\n l_counter += 1\n else:\n res = res * l_counter % mod\n l_counter -= 1\n if l_counter < 0:\n print(0)\n return\n\n if l_counter != 0:\n print(0)\n else:\n print(res * factorial(n) % mod)\n \nresolve()", "neg": "n = int(input())\ns_list = list(input())\nmod = 10 ** 9 + 7\n\nif s_list[0] == \"W\" or s_list[-1] == \"W\":\n print(0)\n return\n\nfrom math import factorial\n\nl_counter = 0\nres = 1\n\nfor i in range(2 * n):\n s = s_list[i]\n if i % 2 == 0:\n s = \"W\" if s == \"B\" else \"B\"\n\n if s == \"W\":\n l_counter += 1\n else:\n res *= l_counter\n l_counter -= 1\n if l_counter < 0:\n print(0)\n return\n\nif l_counter != 0:\n print(0)\nelse:\n print(res * factorial(n) % mod)", "jacc_sim": 0.9555555555555556, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [228, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u970899068", "n_user": "u970899068", "pos": "mod=10**9+7\nn=int(input())\ns=list(input())\n#\u524d\u51e6\u7406\nfor i in range(0,2*n,2):\n if s[i]=='W':\n s[i]='B'\n else:\n s[i]='W'\n\n#L\u306e\u6570\u3092\u6570\u3048\u3066R\u3068\u30de\u30c3\u30c1\u30f3\u30b0\ncountL=0\nans=1\nfor i in range(2*n):\n if s[i]=='W':\n countL+=1\n else:\n ans*=countL\n if countL==0:\n print(0)\n exit()\n ans%=mod\n countL-=1\nif countL!=0:\n print(0)\n exit()\n# \u7b54\u3048\u306fans\u306e\u968e\u4e57\nfor i in range(1,n+1):\n ans*=i\n ans%=mod\nprint(ans)\n\n\n", "neg": "\n\nn=int(input())\ns=list(input())\n#\u524d\u51e6\u7406\nfor i in range(0,2*n,2):\n if s[i]=='W':\n s[i]='B'\n else:\n s[i]='W'\n\n#L\u306e\u6570\u3092\u6570\u3048\u3066R\u3068\u30de\u30c3\u30c1\u30f3\u30b0\ncountL=0\nans=1\nfor i in range(2*n):\n if s[i]=='W':\n countL+=1\n else:\n ans*=countL\n if countL==0:\n print(0)\n exit()\n countL-=1\n# \u7b54\u3048\u306fans\u306e\u968e\u4e57\nans=ans%(10**9+7)\nfor i in rangea(1,n+1):\n ans*=i\n ans%(10**9+7)\nprint(ans)\n\n\n", "jacc_sim": 0.9491525423728814, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [269, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u693953100", "n_user": "u693953100", "pos": "n = int(input())\ns = input()\nmod = 10**9+7\ndp = []\nimos = [0 for _ in range(n*2+1)]\nnow = 0\nfor i in range(n*2):\n c = 1 if s[i]=='B' else 0\n if c==now%2:\n imos[i]-=1\n dp.append(-1)\n else:\n imos[i]+=1\n dp.append(1)\n now+=imos[i]\nif sum(dp)!=0:\n print(0)\n exit()\nans = 1\ncnt = 0\nfor i in dp:\n if i==1:\n cnt+=1\n else:\n ans*=cnt\n ans%=mod\n cnt-=1\nfor i in range(1,n+1):\n ans*=i\n ans%=mod\nprint(ans)", "neg": "n = int(input())\ns = input()\nmod = 10**9+7\ndp = []\nimos = [0 for _ in range(n*2+1)]\nnow = 0\nfor i in range(n*2):\n c = 1 if s[i]=='B' else 0\n if c==now%2:\n imos[i+1]-=1\n dp.append(-1)\n else:\n imos[i]+=1\n dp.append(1)\n now+=imos[i]\nif now + imos[i+1]!=0:\n print(0)\n exit()\nans = 1\ncnt = 0\nfor i in dp:\n if i==1:\n cnt+=1\n else:\n ans*=cnt\n ans%=mod\n cnt-=1\nfor i in range(1,n+1):\n ans*=i\n ans%=mod\nprint(ans)", "jacc_sim": 0.9767441860465116, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [225, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u753803401", "n_user": "u753803401", "pos": "import math\nn = int(input())\ns = [0 if i == \"W\" else 1 for i in list(input())]\ncnt = 0\nc = 1\nfor i in range(n * 2):\n if (s[i] + cnt) % 2 != 0:\n cnt += 1\n else:\n c = (c * (cnt if cnt != 0 else 1)) % (10 ** 9 + 7)\n cnt -= 1\n if cnt < 0:\n print(0)\n exit()\nif cnt != 0:\n print(0)\nelse:\n print((c * math.factorial(n)) % (10 ** 9 + 7))\n", "neg": "import math\nn = int(input())\ns = [0 if i == \"W\" else 1 for i in list(input())]\ncnt = 0\nc = 1\nfor i in range(n * 2):\n if (s[i] + cnt) % 2 == 0:\n cnt += 1\n else:\n c *= (cnt if cnt != 0 else 1)\n cnt -= 1\n if cnt < 0:\n print(0)\n exit()\nif cnt != 0:\n print(0)\nelse:\n print(c * math.factorial(n))\n", "jacc_sim": 0.9230769230769231, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [156, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u185966380", "n_user": "u185966380", "pos": "N = int(input())\nS = input()\ncount = 0\nans = 1\nm = 10**9 + 7\n \nfor i in range(N):\n if S[2*i] == \"W\":\n ans = ans * ((2*i) - (count*2))%m\n count += 1\n if S[2*i + 1] == \"B\":\n ans = ans * ((2*i + 1) - (count*2))%m\n count += 1\n \nif count != N:\n print(0)\nelse:\n for o in range(1, N+1):\n ans *= o\n ans %= m\n print(ans % m)", "neg": "N = int(input())\nS = input()\ncount = 0\nans = 1\nm = 10**9 + 7\n \nfor i in range(N):\n if s[2*i] == \"W\":\n ans *= (i - (count*2))\n count += 1\n if s[2*i + 1] == \"B\":\n ans *= (i - (count*2))\n count += 1\nif count != N:\n print(0)\nelse:\n for o in range(1, N+1):\n ans *= o\n ans %= m\n print(ans %= m)", "jacc_sim": 0.972972972972973, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [163, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u170201762", "n_user": "u170201762", "pos": "mod = 10**9+7\n\nN = int(input())\nS = input()\nlr = ['L']*(2*N)\n\nfor i in range(1,2*N):\n if S[i]==S[i-1]:\n if lr[i-1]=='L':\n lr[i] = 'R'\n else:\n lr[i] = 'L'\n else:\n lr[i] = lr[i-1]\n\nans = 1\nl = 0\nfor i in range(2*N):\n if lr[i]=='L':\n l += 1\n else:\n ans *= l\n ans %= mod\n l -= 1\n\nfor n in range(1,N+1):\n ans *= n\n ans %= mod\n\nl = [i for i in range(2*N) if lr[i]=='L']\nr = [i for i in range(2*N) if lr[i]=='R']\ns = [0]*(2*N+1)\n\nif len(l)!=len(r):\n ans = 0\nelse:\n for i in range(N):\n s[l[i]] += 1\n s[r[i]+1] -= 1\n for i in range(2*N):\n s[i+1] += s[i]\n if S[i]=='B':\n s[i] += 1\n if s[i]%2!=0:\n ans = 0\n\nprint(ans)", "neg": "mod = 10**9+7\n\nN = int(input())\nS = input()\nlr = ['L']*(2*N)\n\nfor i in range(1,2*N):\n if S[i]==S[i-1]:\n if lr[i-1]=='L':\n lr[i] = 'R'\n else:\n lr[i] = 'L'\n else:\n lr[i] = lr[i-1]\n\nans = 1\nl = 0\nfor i in range(2*N):\n if lr[i]=='L':\n l += 1\n else:\n ans *= l\n ans %= mod\n l -= 1\n\nfor n in range(1,N+1):\n ans *= n\n ans %= mod\n\nl = [i for i in range(2*N) if lr[i]=='L']\nr = [i for i in range(2*N) if lr[i]=='R']\ns = [0]*(2*N+1)\nfor i in range(2*N):\n if S[i]=='W':\n s[i] = 0\n else:\n s[i] = 1\n\nif len(l)!=len(r):\n ans = 0\nelse:\n for i in range(N):\n s[l[i]] += 1\n s[r[i]+1] -= 1\n for i in range(2*N):\n s[i+1] += s[i]\n if s[i]%2!=0:\n ans = 0\n\nprint(ans)", "jacc_sim": 0.9523809523809523, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [363, 385], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\nn = int(input())\ns = input()\nif s[0] == \"W\":\n print(0)\n sys.exit()\nMOD = 10**9+7\nans = 1\ncnt = 1\nright = 1\nfor i in range(2*n-1):\n if s[i+1] == s[i]:\n right ^= 1\n if right:\n cnt += 1\n else:\n ans *= cnt\n ans %= MOD\n cnt -= 1\nif cnt != 0:\n print(0)\nelse:\n for i in range(1, n+1):\n ans *= i\n ans %= MOD\n print(ans)\n", "neg": "import sys\nn = int(input())\ns = input()\nif s[0] == \"W\":\n print(0)\n sys.exit()\nMOD = 10**9+7\nans = 1\ncnt = 1\nfor i in range(2*n):\n if s[i+1] != s[i]:\n cnt += 1\n else:\n ans *= cnt\n ans %= MOD\n cnt -= 1\nif cnt != 0:\n print(0)\nelse:\n print(ans)", "jacc_sim": 0.925, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [161, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u052499405", "n_user": "u052499405", "pos": "MOD = 10**9 + 7\nn = int(input())\ns = input().rstrip()\n\nif s[0] == \"W\" or s[-1] == \"W\":\n print(0)\n exit()\nfront = 0\nans = 1\nfor i, item in enumerate(s):\n if item == \"B\":\n if front % 2 == 0:\n front += 1\n else:\n ans *= front\n ans %= MOD\n front -= 1\n else:\n if front % 2 == 1:\n front += 1\n else:\n ans *= front\n ans %= MOD\n front -= 1\n if front < 0:\n print(0)\n exit()\nif front != 0:\n print(0)\n exit()\nfor i in range(1, n+1):\n ans *= i\n ans %= MOD\n\nprint(ans)", "neg": "MOD = 10**9 + 7\nn = int(input())\ns = input().rstrip()\n\nif s[0] == \"W\" or s[-1] == \"W\":\n print(-1)\n exit()\nfront = 0\nans = 1\nfor i, item in enumerate(s):\n if item == \"B\":\n if front % 2 == 0:\n front += 1\n else:\n ans *= front\n ans %= MOD\n front -= 1\n else:\n if front % 2 == 1:\n front += 1\n else:\n ans *= front\n ans %= MOD\n front -= 1\n if front < 0:\n print(-1)\n exit()\nif front != 0:\n print(-1)\n exit()\nfor i in range(1, n+1):\n ans *= i\n ans %= MOD\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [209, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u116002573", "n_user": "u116002573", "pos": "def main():\n N = int(input())\n S = input()\n div = pow(10, 9) + 7\n facN = 1\n for i in range(1, N+1):\n facN = (facN * i) % div\n\n if S[0] != \"B\": return 0\n t = \"L\"\n ctL, ctR = 1, 0\n for i in range(1, 2*N):\n if S[i-1] != S[i]:\n t += t[-1]\n else:\n if t[-1] == \"L\":\n t += \"R\"\n else:\n t += \"L\"\n if t[-1] == \"L\": ctL += 1\n else: ctR += 1\n if S[-1] != \"B\":\n return 0\n if ctL != ctR: return 0\n\n prefixL = [0]\n for c in t:\n if c == \"L\":\n prefixL.append(prefixL[-1]+1)\n else:\n prefixL.append(prefixL[-1])\n\n # print(S, t)\n # print(prefixL)\n ans = 1\n countR = 0\n for i in range(len(t)):\n if t[i] == \"R\":\n ans *= prefixL[i] - countR\n ans %= div\n countR += 1\n return (ans * facN) % div\n\nif __name__ == '__main__':\n\n print(main())", "neg": "def main():\n N = int(input())\n S = input()\n div = pow(10, 9) + 7\n facN = 1\n for i in range(1, N+1):\n facN = (facN * i) % div\n\n t = \"L\"\n for i in range(1, 2*N-1):\n if S[i-1] != S[i]:\n t += t[-1]\n else:\n if t[-1] == \"L\":\n t += \"R\"\n else:\n t += \"L\"\n t += \"R\"\n\n prefixL = [0]\n for c in t:\n if c == \"L\":\n prefixL.append(prefixL[-1]+1)\n else:\n prefixL.append(prefixL[-1])\n\n # print(S, t)\n # print(prefixL)\n ans = 1\n countR = 0\n for i in range(len(t)):\n if t[i] == \"R\":\n ans *= prefixL[i] - countR\n ans %= div\n countR += 1\n return (ans * facN) % div\n\nif __name__ == '__main__':\n\n print(main())", "jacc_sim": 0.9607843137254902, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [368, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u652057333", "n_user": "u652057333", "pos": "MOD = 10**9+7\n\nn = int(input())\ns = input()\n\nif s[0] == \"W\" or s[-1] == \"W\":\n print(0)\n exit()\n\nkai = [1 for _ in range(n+1)]\nfor i in range(1, n+1):\n kai[i] = kai[i-1] * i\n kai[i] %= MOD\n\ndef mul(a, b):\n return (a * b) % MOD\n\na = \"L\"\nl = [\"L\", \"R\"]\nc = 0\n\nfor i in range(1, len(s)):\n if s[i] == s[i-1]:\n c = not c\n a = a + l[c]\n\n\nans = 1\nnum = 0\nfor i in range(len(s)):\n if a[i] == \"L\":\n num += 1\n else:\n ans *= num\n ans %= MOD\n num -= 1\n\nif num > 0:\n print(0)\n exit()\n\nans *= kai[n]\nans %= MOD\n\nprint(ans)\n", "neg": "MOD = 10**9+7\n\nn = int(input())\ns = input()\n\nif s[0] == \"W\" or s[-1] == \"W\":\n print(0):\n exit()\n\nkai = [1 for _ in range(n+1)]\nfor i in range(1, n+1):\n kai[i] = kai[i-1] * i\n kai[i] %= MOD\n\ndef mul(a, b):\n return (a * b) % MOD\n\na = \"L\"\nl = [\"L\", \"R\"]\nc = 0\n\nfor i in range(1, len(s)):\n if s[i] == s[i-1]:\n c = not c\n a = a + l[c]\n\n\nans = 1\nnum = 0\nfor i in range(len(s)):\n if a[i] == \"L\":\n num += 1\n else:\n ans *= num\n ans %= MOD\n num -= 1\n\nans *= kai[n]\nans %= MOD\n\nprint(ans)\n", "jacc_sim": 0.9791666666666666, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [280, 263], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u160244242", "n_user": "u160244242", "pos": "import math\n\nn = int(input())\ns = input()\n\nif s[0] == 'W' or s[-1] == 'W':\n print(0)\nelse: \n s_lr = 'L'\n for i in range(len(s)-1):\n if s[i+1] == s[i]:\n if s_lr[-1] == 'L':\n s_lr += 'R'\n else:\n s_lr += 'L'\n else:\n if s_lr[-1] == 'L':\n s_lr += 'L'\n else:\n s_lr += 'R' \n l_cnt = 0\n r_cnt = 0\n lst = []\n for i in s_lr:\n if i == 'L':\n l_cnt += 1\n lst.append(0)\n else:\n if l_cnt - r_cnt <= 0:\n print(0)\n break\n else:\n lst.append(l_cnt - r_cnt)\n r_cnt += 1\n else:\n if l_cnt != r_cnt:\n print(0)\n else:\n res = 1\n for i in lst:\n if i > 0:\n res = res * i % (10**9 + 7)\n print(res * math.factorial(n) % (10**9 + 7) )", "neg": "import math\n\nn = int(input())\ns = input()\n\nif s[0] == 'W' or s[-1] == 'W':\n print(0)\nelse: \n s_lr = 'L'\n for i in range(len(s)-1):\n if s[i+1] == s[i]:\n if s_lr[-1] == 'L':\n s_lr += 'R'\n else:\n s_lr += 'L'\n else:\n if s_lr[-1] == 'L':\n s_lr += 'L'\n else:\n s_lr += 'R' \n l_cnt = 0\n r_cnt = 0\n lst = []\n for i in s_lr:\n if i == 'L':\n l_cnt += 1\n lst.append(0)\n else:\n if l_cnt - r_cnt <= 0:\n print(0)\n break\n else:\n lst.append(l_cnt - r_cnt)\n r_cnt += 1\n else:\n if l_cnt != r_cnt:\n print(0)\n else:\n res = 1\n for i in lst:\n if i > 0:\n res = res % (10**9 + 7)\n print(res * math.factorial(n) % (10**9 + 7) )", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [339, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u997113115", "n_user": "u997113115", "pos": "MOD = int(1e9+7)\nN = int(input())\nS = input()\nLR = [0]*(2*N)\nLR[0] = 0\nl, r = 1, 0\nif S[0] == \"W\" or S[-1] == \"W\":\n print(0)\n exit()\nfor i in range(1, 2*N):\n if S[i-1] == S[i]:\n LR[i] = 0 if LR[i-1] == 1 else 1\n else:\n LR[i] = LR[i-1]\n if LR[i] == 0:\n l += 1\n else:\n r += 1\nif l != r:\n print(0)\n exit()\nL = 0\nR = 0\ncount = 1\nfor w in LR:\n if w == 0:\n L += 1\n else:\n count *= L - R\n count %= MOD\n R += 1\nfor i in range(1, N+1):\n count = count * i % MOD\nprint(count)", "neg": "MOD = int(1e9+7)\nN = int(input())\nS = input()\nLR = [0]*(2*N)\nLR[0] = 0\nl, r = 0, 0\nif S[0] == \"W\" or S[-1] == \"W\":\n print(0)\n exit()\nfor i in range(1, 2*N):\n if S[i-1] == S[i]:\n LR[i] = 0 if LR[i-1] == 1 else 1\n else:\n LR[i] = LR[i-1]\n if LR[i] == 0:\n l += 1\n else:\n r += 1\nif l != r:\n print(0)\n exit()\nL = 0\nR = 0\ncount = 1\nfor w in LR:\n if w == 0:\n L += 1\n else:\n count *= L - R\n R += 1\nfor i in range(1, N+1):\n count = count * i % MOD\nprint(count)", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [262, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u065079240", "n_user": "u065079240", "pos": "import math\nN = int(input())\nS = input()\nans = 1\nans_base = 1\nnumofS = 0 # \u7dda\u306e\u5de6\u7aef\u306b\u306a\u3063\u3066\u3044\u308b\u70b9\u3092S\u3068\u3059\u308b\u3068\u305d\u306e\u6570\u306f\u3061\u3087\u3046\u3069N\u3067\u306a\u3044\u3068\u3044\u3051\u306a\u3044\nline = 0 # \u5de6\u304b\u3089\u9806\u306b\u7dda\u3092\u5f15\u304f\u3002\u4e0a\u306b\u4f55\u672c\u901a\u3063\u3066\u3044\u308b\u304b\u3092\u3042\u3089\u308f\u3059\nfor i in range(2*N):\n if S[i] == \"B\":\n if line % 2 == 0:\n numofS += 1\n line += 1\n else:\n ans_base *= line\n line -= 1\n else:\n if line % 2 == 0:\n ans_base *= line\n line -= 1\n else:\n line += 1\n numofS += 1\n\n if line < 0:\n ans = 0\n break\n ans_base %= 10**9+7\nif numofS != N:\n ans = 0\n # print(numofS)\n\nif ans != 0:\n fact = math.factorial(N)\n fact %= 10**9+7\n ans = ans_base * fact\n ans %= 10**9+7\nprint(ans)\n", "neg": "import math\nN = int(input())\nS = input()\nans = 0\nans_base = 1\nnumofS = 0 # \u7dda\u306e\u5de6\u7aef\u306b\u306a\u3063\u3066\u3044\u308b\u70b9\u3092S\u3068\u3059\u308b\u3068\u305d\u306e\u6570\u306f\u3061\u3087\u3046\u3069N\u3067\u306a\u3044\u3068\u3044\u3051\u306a\u3044\nline = 0 # \u5de6\u304b\u3089\u9806\u306b\u7dda\u3092\u5f15\u304f\u3002\u4e0a\u306b\u4f55\u672c\u901a\u3063\u3066\u3044\u308b\u304b\u3092\u3042\u3089\u308f\u3059\nfor i in range(2*N):\n if S[i] == \"B\":\n if line % 2 == 0:\n numofS += 1\n line += 1\n else:\n ans_base *= line\n line -= 1\n else:\n if line % 2 == 0:\n ans_base *= line\n line -= 1\n else:\n line += 1\n numofS += 1\n\n if line < 0:\n ans = -1\nif numofS != N:\n ans = -1\n #print(numofS)\n\nif ans != -1:\n fact = math.factorial(N)\n ans = ans_base * fact\n ans %= 10**9+7\nprint(ans)\n", "jacc_sim": 0.987012987012987, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [412, 392], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u792670114", "n_user": "u792670114", "pos": "N = int(input())\nS = input()\nL = list(S)\nfor i in range(0, 2*N, 2):\n L[i] = \"B\" if L[i] == \"W\" else \"W\"\nS = \"\".join(L)\n#print(S)\nr = 1\ni = 0\nnw = 0\nnb = 0\nwhile i < 2*N:\n j = S.find(\"B\", i)\n if j < 0:\n j = 2*N\n k = S.find(\"W\", j)\n if k < 0:\n k = 2*N\n #print(i, j, k)\n nw += j-i\n nb += k-j\n for i in range(nb):\n r = r*nw%1000000007\n nw -= 1\n nb -= 1\n i = k\nif not(nw == 0 and nb == 0):\n print(0)\n exit()\nfor i in range(1, N+1):\n r = r*i%1000000007\nprint(r)\n", "neg": "N = int(input())\nS = input()\nL = list(S)\nfor i in range(0, 2*N, 2):\n L[i] = \"B\" if L[i] == \"W\" else \"W\"\nS = \"\".join(L)\n#print(S)\nr = 1\ni = 0\nnw = 0\nnb = 0\nwhile i < 2*N:\n j = S.find(\"B\", i)\n if j < 0:\n j = 2*N\n k = S.find(\"W\", j)\n if k < 0:\n k = 2*N\n #print(i, j, k)\n nw += j-i\n nb += k-j\n for i in range(min(nb, nw)):\n r = r*max(nw, nb)%1000000007\n nw -= 1\n nb -= 1\n i = k\nif not(nw == 0 and nb == 0):\n print(0)\n exit()\nfor i in range(1, N+1):\n r = r*i%1000000007\nprint(r)\n", "jacc_sim": 0.9574468085106383, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [260, 270], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u187516587", "n_user": "u187516587", "pos": "N=int(input())\nS=input()\nl=0\na=1\nfor i in range(2*N):\n if S[i]==\"W\":\n if l%2==0:\n a=a*l%(10**9+7)\n l-=1\n else:\n l+=1\n else:\n if l%2==0:\n l+=1\n else:\n a=a*l%(10**9+7)\n l-=1\nif l!=0:\n a=0\nfor i in range(1,N+1):\n a=a*i%(10**9+7)\nprint(a)", "neg": "N=int(input())\nS=input()\nl=0\na=1\nfor i in range(2*N):\n if S[i]==\"W\":\n if l%2==0:\n a=a*l%(10**9+7)\n l-=1\n else:\n l+=1\n else:\n if l%2==0:\n l+=1\n else:\n a=a*l%(10**9+7)\n l-=1\nif l!=1:\n a=0\nfor i in range(1,N+1):\n a=a*i%(10**9+7)\nprint(a)", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [164, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02929", "p_user": "u023540496", "n_user": "u023540496", "pos": "from math import factorial\nMOD = 10**9 + 7\n\nn = int(input())\ns = input()\na = [0] * (n * 2)\nfor i in range(n*2):\n if s[i] == \"B\":\n a[i] = 1\n \nprevbit = 0\nprevlr = 0\nlr = [0] * (n*2)\nfor i in range(n*2):\n if a[i] != prevbit:\n lr[i] = prevlr\n else:\n lr[i] = (prevlr + 1) % 2\n prevlr = lr[i]\n prevbit = a[i]\n \n#print(lr)\n \nans = 1\nif sum(lr) != n:\n ans = 0\nelse:\n suml = 0\n for i in range(n*2):\n if lr[i] == 1:\n ans = (ans * suml) % MOD\n suml -= 1\n if suml < 0:\n ans = 0\n break\n else:\n suml += 1\n \nprint((ans*factorial(n))%MOD)", "neg": "from math import factorial\niMOD = 10**9 + 7\n\nn = int(input())\ns = input()\na = [0] * (n * 2)\nfor i in range(n*2):\n if s[i] == \"B\":\n a[i] = 1\n \nprevbit = 0\nprevlr = 0\nlr = [0] * (n*2)\nfor i in range(n*2):\n if a[i] != prevbit:\n lr[i] = prevlr\n else:\n lr[i] = (prevlr + 1) % 2\n prevlr = lr[i]\n prevbit = a[i]\n \n#print(lr)\n \nans = 1\nif sum(lr) != n:\n ans = 0\nelse:\n suml = 0\n for i in range(n*2):\n if lr[i] == 1:\n ans = (ans * suml) % MOD\n suml -= 1\n if suml < 0:\n ans = 0\n break\n else:\n suml += 1\n \nprint((ans*factorial(n))%MOD)", "jacc_sim": 1.0, "nl": "You are given a string representing the colors of squares arranged from left to right. You can perform N operations, each time choosing two distinct squares and inverting the colors of those squares and the squares between them. Find the number of ways to make all the squares white at the end of the process, considering different ways based on the pairs of squares chosen in each operation. Constraints: 1 \u2264 N \u2264 10^5, |S| = 2N, and each character of S is 'B' or 'W'. Input is given as N and the string S. Output the number of ways to make all squares white, modulo 10^9+7. If there are no such ways, print 0.", "before_after_length": [275, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02931", "p_user": "u134238756", "n_user": "u134238756", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\nN, H, W = map(int, input().split())\nP = [-1 for i in range(H+W)]\nC = [1] * (H+W)\narr = []\nfor _ in range(N):\n r, c, a = map(int, input().split())\n arr.append((a, r-1, c+H-1))\narr = sorted(arr)\n\nans = 0\ndef find(a):\n if P[a] < 0: return a\n t = find(P[a])\n P[a] = t\n return t\n\ndef unite(r, c):\n fr, fc = find(r), find(c)\n if fr == fc: return 0\n C[fr] = C[fc] = C[fr] + C[fc]\n if P[fr] == P[fc]:\n P[fc] = fr\n P[fr] -= 1\n elif P[fr] > P[fc]:\n P[fc] = fr\n else:\n P[fr] = fc\n \nwhile arr:\n a, r, c = arr.pop()\n unite(r, c)\n fr = find(r)\n if C[fr]:\n ans += a\n C[fr] -= 1\nprint(ans)\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\nN, H, W = map(int, input().split())\nP = [-1 for i in range(H+W)]\nC = [1] * (H+W)\narr = []\nfor _ in range(N):\n r, c, a = map(int, input().split())\n arr.append((a, r-1, c+H-1))\narr = sorted(arr)\n\n\ndef find(a):\n if P[a] < 0: return a\n t = find(P[a])\n P[a] = t\n return t\n\ndef unite(r, c):\n fr, fc = find(r), find(c)\n if fr == fc: return 0\n C[fr] = C[fc] = C[fr] + C[fc]\n if P[fr] == P[fc]:\n P[fc] = fr\n P[fr] -= 1\n elif P[fr] > P[fc]:\n P[fc] = fr\n else:\n P[fr] = fc\n \nwhile arr:\n a, r, c = arr.pop()\n unite(r, c)\n fr = find(r)\n if C[fr]:\n ans += a\n C[fr] -= 1\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You have N cards placed on a grid with H rows and W columns. Each card has an integer Ai written on it and is placed on the square at the Ri-th row and Ci-th column. You can pick at most one card from each row and at most one card from each column. Find the maximum possible sum of the integers written on the picked cards. All values are integers, and the constraints are 1 \u2264 N \u2264 10^5, 1 \u2264 H, W \u2264 10^5, 1 \u2264 Ai \u2264 10^5, 1 \u2264 Ri \u2264 H, and 1 \u2264 Ci \u2264 W. The input is given in the format N H W R1 C1 A1 R2 C2 A2 ... RN CN AN, and the output should be the maximum possible sum of the integers written on the picked cards.", "before_after_length": [337, 334], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02931", "p_user": "u134238756", "n_user": "u134238756", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\ndef par(a):\n if P[a] < 0: return a\n t = par(P[a])\n P[a] = t\n return t\ndef unite(a, b):\n if par(a) == par(b): return 0\n C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]\n if P[par(b)] == P[par(a)]:\n P[par(b)] = par(a)\n P[par(a)] -= 1\n elif P[par(b)] > P[par(a)]:\n P[par(b)] = par(a)\n else:\n P[par(a)] = par(b)\nN, H, W = map(int, input().split())\nP = [-1 for i in range(H+W)]\nC = [1] * (H+W)\nX = []\nfor _ in range(N):\n r, c, a = map(int, input().split())\n X.append((a, r-1, c+H-1))\nX = sorted(X)\nans = 0\nwhile X:\n a, r, c = X.pop()\n unite(r, c)\n if C[par(r)]:\n ans += a\n C[par(r)] -= 1\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\ndef par(a):\n if P[a] < 0: return a\n t = par(P[a])\n P[a] = t\n return t\ndef unite(a, b):\n if par(a) == par(b): return 0\n C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]\n if P[par(b)] == P[par(a)]:\n P[par(b)] = par(a)\n P[par(a)] -= 1\n elif P[par(b)] > P[par(a)]:\n P[par(b)] = par(a)\n else:\n P[par(a)] = par(b)\nN, H, W = map(int, input().split())\nP = [-1 for i in range(H+W)]\nC = [1] * (H+W)\nX = []\nfor _ in range(N):\n r, c, a = map(int, input().split())\n X.append((a, r-1, c+H-1))\nX = sorted(X)\nans = 0\nwhile X:\n a, r, c = X.pop()\n unite(r, c)\n if C[par(r)]:\n ans += a\n C[par(r)] -= 1\nprint(ans", "jacc_sim": 1.0, "nl": "You have N cards placed on a grid with H rows and W columns. Each card has an integer Ai written on it and is placed on the square at the Ri-th row and Ci-th column. You can pick at most one card from each row and at most one card from each column. Find the maximum possible sum of the integers written on the picked cards. All values are integers, and the constraints are 1 \u2264 N \u2264 10^5, 1 \u2264 H, W \u2264 10^5, 1 \u2264 Ai \u2264 10^5, 1 \u2264 Ri \u2264 H, and 1 \u2264 Ci \u2264 W. The input is given in the format N H W R1 C1 A1 R2 C2 A2 ... RN CN AN, and the output should be the maximum possible sum of the integers written on the picked cards.", "before_after_length": [369, 368], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02931", "p_user": "u353797797", "n_user": "u353797797", "pos": "import sys\nfrom heapq import *\n\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline\n\ndef main():\n def get_group(k):\n g = pd[k]\n if g < 0:\n return k\n gg = get_group(g)\n pd[k] = gg\n return gg\n\n def merge(j, k):\n g1 = get_group(j)\n g2 = get_group(k)\n if g1 != g2:\n d1 = -pd[g1]\n d2 = -pd[g2]\n if d2 > d1:\n g1, g2 = g2, g1\n pd[g2] = g1\n if d1 == d2:\n pd[g1] -= 1\n\n hp = []\n n, h, w = map(int, input().split())\n pd = [-1] * (h + w + 2) # \u89aa(parent)\u3068\u6df1\u3055(depth)\u30020\u4ee5\u4e0a\u306f\u89aa\u3002\u8ca0\u306e\u5834\u5408\u3001\u305d\u306e\u30ce\u30fc\u30c9\u304c\u6839\u3067\u7d76\u5bfe\u5024\u304c\u6df1\u3055\u3002\n pd[0] = -(h + w + 2)\n for _ in range(n):\n r, c, a = map(int, input().split())\n heappush(hp, [-a, r, h + c])\n cnt = h + w\n ans = 0\n while cnt and hp:\n a, r, c = heappop(hp)\n gr = get_group(r)\n gc = get_group(c)\n if gr + gc == 0: continue\n if gr == gc:\n merge(gr, 0)\n else:\n merge(gr, gc)\n ans -= a\n cnt -= 1\n print(ans)\n\nmain()\n", "neg": "import sys\nfrom heapq import *\n\nsys.setrecursionlimit(10 ** 6)\ninput = sys.stdin.readline\n\ndef main():\n def get_group(k):\n g = pd[k]\n if g < 0:\n return k\n gg = get_group(g)\n pd[k] = gg\n return gg\n\n def merge(j, k):\n g1 = get_group(j)\n g2 = get_group(k)\n if g1 != g2:\n d1 = -pd[g1]\n d2 = -pd[g2]\n if d2 > d1:\n g1, g2 = g2, g1\n pd[g2] = g1\n if d1 == d2:\n pd[g1] -= 1\n\n hp = []\n n, h, w = map(int, input().split())\n pd = [-1] * (h + w + 2) # \u89aa(parent)\u3068\u6df1\u3055(depth)\u30020\u4ee5\u4e0a\u306f\u89aa\u3002\u8ca0\u306e\u5834\u5408\u3001\u305d\u306e\u30ce\u30fc\u30c9\u304c\u6839\u3067\u7d76\u5bfe\u5024\u304c\u6df1\u3055\u3002\n for _ in range(n):\n r, c, a = map(int, input().split())\n heappush(hp, [-a, r, h + c])\n cnt = h + w\n ans = 0\n while cnt and hp:\n a, r, c = heappop(hp)\n gr = get_group(r)\n gc = get_group(c)\n if gr + gc == 0: continue\n if gr == gc:\n merge(gr, 0)\n else:\n merge(gr, gc)\n ans -= a\n cnt -= 1\n print(ans)\n\nmain()\n", "jacc_sim": 1.0, "nl": "You have N cards placed on a grid with H rows and W columns. Each card has an integer Ai written on it and is placed on the square at the Ri-th row and Ci-th column. You can pick at most one card from each row and at most one card from each column. Find the maximum possible sum of the integers written on the picked cards. All values are integers, and the constraints are 1 \u2264 N \u2264 10^5, 1 \u2264 H, W \u2264 10^5, 1 \u2264 Ai \u2264 10^5, 1 \u2264 Ri \u2264 H, and 1 \u2264 Ci \u2264 W. The input is given in the format N H W R1 C1 A1 R2 C2 A2 ... RN CN AN, and the output should be the maximum possible sum of the integers written on the picked cards.", "before_after_length": [502, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02938", "p_user": "u570944601", "n_user": "u570944601", "pos": "from functools import *\nMOD=10**9+7\n@lru_cache(maxsize=None)\ndef solve(L,R):\n if L > R: return 0\n if L == 1: return (1 + solve(2, R)) % MOD\n return (solve(L//2,(R-1)//2) + solve((L+1)//2,R//2) + solve((L+1)//2,(R-1)//2)) % MOD\n \nprint(solve(*map(int,input().split())))", "neg": "from functools import *\nMOD=10**9+7\n@lru_cache(maxsize=None)\ndef solve(L,R):\n print(L, R)\n if L > R: return 0\n assert L >= 1\n if L == 1:\n return (1 + solve(2, R)) % MOD\n ans = solve(L//2,(R-1)//2) + solve((L+1)//2,R//2) + solve((L+1)//2,(R-1)//2)\n return ans % MOD\n \nprint(solve(*map(int,input().split())))", "jacc_sim": 0.9487179487179487, "nl": "You are given two integers, L and R. Find the number of pairs of integers (x, y) (where L \u2264 x \u2264 y \u2264 R) such that the remainder when y is divided by x is equal to y XOR x. The XOR of integers A and B, A XOR B, is defined as follows: when A XOR B is written in base two, the digit in the 2^k's place (where k \u2265 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise. For example, 3 XOR 5 = 6 (In base two: 011 XOR 101 = 110). The input is given in the format L R, and the output should be the number of pairs of integers (x, y) (L \u2264 x \u2264 y \u2264 R) satisfying the condition, modulo 10^9 + 7.", "before_after_length": [128, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02940", "p_user": "u218843509", "n_user": "u218843509", "pos": "n = int(input())\ns = input()\nmod = 998244353\nans = 1\nz, o, t = n, 0, 0\npre = [\"\", [\"\", \"\"]]\nfor i in range(3*n):\n if t != 0 and s[i] not in pre[1]:\n ans *= t\n ans %= mod\n t -= 1\n if t == 0:\n pre[1] = [\"\", \"\"]\n elif s[i] == pre[0] or o == 0:\n o += 1\n ans *= z\n ans %= mod\n z -= 1\n pre[0] = s[i]\n else:\n t += 1\n ans *= o\n ans %= mod\n o -= 1\n pre[1] = [pre[0], s[i]]\n if o == 0:\n pre[0] = \"\"\n\nprint(ans)\n", "neg": "n = int(input())\ns = ineput()\nmod = 998244353\nans = 1\nz, o, t = n, 0, 0\npre = [\"\", [\"\", \"\"]]\nfor i in range(3*n):\n if t != 0 and s[i] not in pre[1]:\n ans *= t\n ans %= mod\n t -= 1\n if t == 0:\n pre[1] = [\"\", \"\"]\n elif s[i] == pre[0] or o == 0:\n o += 1\n ans *= z\n ans %= mod\n z -= 1\n pre[0] = s[i]\n else:\n t += 1\n ans *= o\n ans %= mod\n o -= 1\n pre[1] = [pre[0], s[i]]\n if o == 0:\n pre[0] = \"\"\n\nprint(ans)\n", "jacc_sim": 0.9743589743589743, "nl": "You have 3N colored balls with IDs from 1 to 3N. A string S of length 3N represents the colors of the balls. The color of Ball i is red if Si is R, green if Si is G, and blue if Si is B. There are N red balls, N green balls, and N blue balls. Takahashi will distribute these 3N balls to N people so that each person gets one red ball, one blue ball, and one green ball. The people want balls with IDs close to each other, so he will additionally satisfy the condition: Let aj < bj < cj be the IDs of the balls received by the j-th person in ascending order. Then, \u03a3j (cj-aj) should be as small as possible. Find the number of ways in which Takahashi can distribute the balls, modulo 998244353. We consider two ways to distribute the balls different if and only if there is a person who receives different sets of balls.\n\nConstraints:\n1 \u2264 N \u2264 10^5\n|S|=3N\nS consists of R, G, and B, and each of these characters occurs N times in S.\n\nInput:\nN\nS\n\nOutput:\nPrint the number of ways in which Takahashi can distribute the balls, modulo 998244353.\n\nSample Input 1:\n3\nRRRGGGBBB\n\nSample Output 1:\n216\nThe minimum value of \u03a3j (cj-aj) is 18 when the balls are, for example, distributed as follows:\n- The first person gets Ball 1, 5, and 9.\n- The second person gets Ball 2, 4, and 8.\n- The third person gets Ball 3, 6, and 7.\n\nSample Input 2:\n5\nBBRGRRGRGGRBBGB\n\nSample Output 2:\n960", "before_after_length": [215, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02941", "p_user": "u499381410", "n_user": "u499381410", "pos": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi\nfrom operator import mul\nfrom functools import reduce\nfrom pprint import pprint\n\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 998244353\n\n\nn = I()\nA = LI()\nB = LI()\nq = [(-B[i], i) for i in range(n)]\nheapify(q)\nans = 0\nwhile q:\n _, idx = heappop(q)\n if A[idx] == B[idx]:\n continue\n total = B[(idx-1)%n] + B[(idx+1)%n]\n t = (B[idx] - A[idx]) // total\n B[idx] -= t * total\n if not t:\n print(-1)\n exit()\n ans += t\n heappush(q, (-B[idx], idx))\n\nprint(ans)\n\n\n\n\n\n\n\n", "neg": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations, product\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi\nfrom operator import mul\nfrom functools import reduce\nfrom pprint import pprint\n\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 20\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\ndef MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]\nmod = 998244353\n\n\nn = I()\nA = LI()\nB = LI()\nq = [(-B[i], i) for i in range(n)]\nans = 0\nwhile q:\n a, idx = heappop(q)\n a = -a\n if A[idx] == a:\n continue\n b = B[(idx-1)%n] + B[(idx+1)%n]\n ans += a // b\n ax = a % b\n B[idx] = ax\n if ax < A[idx]:\n print(-1)\n exit()\n elif ax == A[idx]:\n continue\n else:\n heappush(q, (-ax, idx))\n\nprint(ans)\n\n\n\n\n\n\n\n", "jacc_sim": 0.9038461538461539, "nl": "You are given N positive integers arranged in a circle. Takahashi wants to transform the i-th number to a specific value B_i. He can repeatedly choose an integer i and replace the i-th number with the sum of its adjacent numbers. Determine if Takahashi can achieve his objective and find the minimum number of operations required. Constraints: 3 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input format: N, followed by A_i values, followed by B_i values. Output the minimum number of operations required or -1 if the objective cannot be achieved. Example: Input: 3, 1 1 1, 13 5 7. Output: 4. Takahashi can achieve his objective in 4 operations.", "before_after_length": [485, 491], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02941", "p_user": "u905582793", "n_user": "u905582793", "pos": "n = int(input())\nb = list(map(int,input().split()))\na = list(map(int,input().split()))\nlock = [0]*n\n\nans = 0\ntop = []\nfor i in range(n):\n if a[i] < b[i]:\n print(-1)\n exit()\n if a[i] == b[i]:\n lock[i] = 1\n continue\n if a[i-1]+a[(i+1)%n] b[i]:\n print(-1)\n exit()\n if a[i] == b[i]:\n lock[i] = 1\n continue\n if a[i-1]+a[(i+1)%n] A[i]) &\\\n (B[i] > a) &\\\n (B[i] > c):\n d = (B[i]-max(A[i], a, c)+a+c-1)//(a+c)\n B[i] -= (a+c)*d\n cnt += d\n elif B[i] < A[i]:\n print(-1)\n exit()\nprint(cnt)", "neg": "# c\nn = int(input())\n*A, = map(int, input().split())\n*B, = map(int, input().split())\ncnt = 0\nwhile B != A:\n for i in range(n):\n a, c = B[i-1], B[(i+1)%n]\n if (B[i] > A[i]) &\\\n (B[i] > a) &\\\n (B[i] > c):\n B[i] -= (a+c)*((B[i]-A[i]+a+c)//(a+c))\n cnt += 1\n elif B[i] < A[i]:\n print(-1)\n exit()\nprint(cnt)", "jacc_sim": 0.9285714285714286, "nl": "You are given N positive integers arranged in a circle. Takahashi wants to transform the i-th number to a specific value B_i. He can repeatedly choose an integer i and replace the i-th number with the sum of its adjacent numbers. Determine if Takahashi can achieve his objective and find the minimum number of operations required. Constraints: 3 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input format: N, followed by A_i values, followed by B_i values. Output the minimum number of operations required or -1 if the objective cannot be achieved. Example: Input: 3, 1 1 1, 13 5 7. Output: 4. Takahashi can achieve his objective in 4 operations.", "before_after_length": [187, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02941", "p_user": "u163320134", "n_user": "u163320134", "pos": "import heapq\n\nn=int(input())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\nq=[]\nfor i in range(n):\n if arr2[i]!=arr1[i]:\n heapq.heappush(q,(-arr2[i],i))\ncnt=0\nwhile q:\n val,pos=heapq.heappop(q)\n val*=-1\n diff=arr2[pos-1]+arr2[(pos+1)%n]\n move,tmp=divmod(val-arr1[pos],diff)\n if move==0:\n break\n cnt+=move\n tmp+=arr1[pos]\n arr2[pos]=tmp\n if tmp!=arr1[pos]:\n heapq.heappush(q,(-tmp,pos))\nfor i in range(n):\n if arr1[i]!=arr2[i]:\n print(-1)\n break\nelse:\n print(cnt)", "neg": "import heapq\n\nn=int(input())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\nq=[]\nfor i in range(n):\n heapq.heappush(q,(-arr2[i],i))\ncnt=0\nnum=0\nwhile 1:\n val,pos=-heapq.heappop(q)\n diff=arr2[pos-1]+arr2[(pos+1)%n]\n move=(val-diff)//diff+1\n if move<=0:\n break\n tmp=arr2[pos]-diff*move\n if tmp<=0:\n break\n arr2[pos]=tmp\n heapq.heappush(q,-tmp)\n if tmp==arr1[pos]:\n num+=1\n cnt+=move\n if num==n:\n break\nfor i in range(n):\n if arr1[i]!=arr2[i]:\n print(-1)\n break\nelse:\n print(cnt)", "jacc_sim": 0.9148936170212766, "nl": "You are given N positive integers arranged in a circle. Takahashi wants to transform the i-th number to a specific value B_i. He can repeatedly choose an integer i and replace the i-th number with the sum of its adjacent numbers. Determine if Takahashi can achieve his objective and find the minimum number of operations required. Constraints: 3 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 A_i, B_i \u2264 10^9. Input format: N, followed by A_i values, followed by B_i values. Output the minimum number of operations required or -1 if the objective cannot be achieved. Example: Input: 3, 1 1 1, 13 5 7. Output: 4. Takahashi can achieve his objective in 4 operations.", "before_after_length": [259, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02941", "p_user": "u969190727", "n_user": "u969190727", "pos": "n=int(input())\nA=[int(i) for i in input().split()]\nB=[int(i) for i in input().split()]\n\nfrom heapq import heappop, heappush\npush = lambda x,i: heappush(BB,(-x,i))\nBB=[]\n\nfor i,b in enumerate(B):\n push(b,i)\n\nans=0\nwhile BB:\n b,ind=heappop(BB)\n b,ai=-b,A[ind]\n if b rev_s[i:i + n]:\n mido = rev_s[i:i + n]\nind = float(\"inf\")\nfor i in range(n):\n if mido[i] != mido[0]:\n if i < ind:\n ind = i\nans = ind * (2 ** min(k - 1, 20))\nprint((mido[0] * ans + mido[ind:ind + n - ans])[:n])", "neg": "n, k = map(int, input().split())\ns = input()\nrev_s = s + s[::-1]\nmido = \"z\" * n\nfor i in range(n + 1):\n if mido > rev_s[i:i + n]:\n mido = rev_s[i:i + n]\nind = float(\"inf\")\nfor i in range(n):\n if mido[i] != mido[0]:\n if i > ind:\n ind = i\nans = ind * (2 ** (k - 1))\nprint((mido[0] * ans + mido[ind:ind + n - ans])[:n])", "jacc_sim": 0.925, "nl": "Takahashi has a string S of length N consisting of lowercase English letters. He will perform the following operation K times: Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. Then, let S' be some contiguous substring of U with length N, and replace S with S'. Among the strings that can be the string S after the K operations, find the lexicographically smallest possible one.\n\nConstraints:\n1 \u2264 N \u2264 5000\n1 \u2264 K \u2264 10^9\n|S| = N\nS consists of lowercase English letters.\n\nInput:\nN K\nS\n\nOutput:\nPrint the lexicographically smallest possible string that can be the string S after the K operations.\n\nSample Input 1:\n5 1\nbacba\n\nSample Output 1:\naabca\n\nSample Input 2:\n10 2\nbbaabbbaab\n\nSample Output 2:\naaaabbaabb", "before_after_length": [162, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02943", "p_user": "u905582793", "n_user": "u905582793", "pos": "n,k=map(int,input().split())\ns=input()\nt=s[::-1]\nu=\"\".join([s,t])\nls=[]\nfor i in range(n):\n ls.append(u[i:i+n])\nls.sort()\nk-=1\nx=ls[0]\ncnt=1\nfor i in range(1,n):\n if x[0]==x[i]:\n cnt+=1\n else:\n break\nif cnt*2**k 5000 * 26:\n k = 5000 * 26\n\nif k != 1:\n for i in range(k - 1):\n sList = []\n t = (s[::-1])\n u = s + t\n for j in range(0, n+1):\n sList.append((u[j:(j + n)])[::-1])\n sList.sort()\n if s == sList[0][::-1]:\n break\n s = sList[0][::-1]\n\n\nfor i in range(1):\n sList = []\n t = (s[::-1])\n u = s + t\n for j in range(0, n+1):\n sList.append(u[j:(j + n)])\n sList.sort()\n s = sList[0]\n\nprint(s)\n", "neg": "n, k = map(int, input().split())\ns = input()\n\nif k > 5000 * 26:\n k = 5000 * 26\n\nfor i in range(k):\n sList = []\n t = (s[::-1])\n u = s + t\n for j in range(n+1):\n sList.append(u[j:(j + n)])\n sList.sort()\n s = sList[0]\n\nprint(s)\n", "jacc_sim": 0.9459459459459459, "nl": "Takahashi has a string S of length N consisting of lowercase English letters. He will perform the following operation K times: Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. Then, let S' be some contiguous substring of U with length N, and replace S with S'. Among the strings that can be the string S after the K operations, find the lexicographically smallest possible one.\n\nConstraints:\n1 \u2264 N \u2264 5000\n1 \u2264 K \u2264 10^9\n|S| = N\nS consists of lowercase English letters.\n\nInput:\nN K\nS\n\nOutput:\nPrint the lexicographically smallest possible string that can be the string S after the K operations.\n\nSample Input 1:\n5 1\nbacba\n\nSample Output 1:\naabca\n\nSample Input 2:\n10 2\nbbaabbbaab\n\nSample Output 2:\naaaabbaabb", "before_after_length": [234, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02943", "p_user": "u619819312", "n_user": "u619819312", "pos": "n,k=map(int,input().split())\ns=input()\nd=s+s[::-1]\nd=d[::-1]\nr=d[:n]\ne=d[:n]\nfor i in range(n):\n e=e[1:]+d[n+i]\n r=min(r,e)\nt=1\nqo=r[0]\nfor i in range(1,n):\n if qo==r[i]:\n t+=1\n else:\n break\nr=r[::-1]\nfor i in range(k-1):\n p=r+r[n-t:]\n p=p[::-1]\n p=p[:n]\n if r==p:\n break\n else:\n r=p[::-1]\n t+=t\nprint(r[::-1])", "neg": "n,k=map(int,input().split())\ns=input()\nd=s+s[::-1]\nd=d[::-1]\nr=d[:n]\ne=d[:n]\nfor i in range(n):\n e=e[1:]+d[n+i]\n r=min(r,e)\nt=1\nqo=r[0]\nfor i in range(1,n):\n if qo==r[i]:\n t+=1\n else:\n break\nr=r[::-1]\nprint(r)\nfor i in range(k-1):\n p=r+r[n-t:]\n p=p[::-1]\n p=p[:n]\n if r==p:\n break\n else:\n r=p[::-1]\n t+=t\nprint(r[::-1])", "jacc_sim": 1.0, "nl": "Takahashi has a string S of length N consisting of lowercase English letters. He will perform the following operation K times: Let T be the string obtained by reversing S, and U be the string obtained by concatenating S and T in this order. Then, let S' be some contiguous substring of U with length N, and replace S with S'. Among the strings that can be the string S after the K operations, find the lexicographically smallest possible one.\n\nConstraints:\n1 \u2264 N \u2264 5000\n1 \u2264 K \u2264 10^9\n|S| = N\nS consists of lowercase English letters.\n\nInput:\nN K\nS\n\nOutput:\nPrint the lexicographically smallest possible string that can be the string S after the K operations.\n\nSample Input 1:\n5 1\nbacba\n\nSample Output 1:\naabca\n\nSample Input 2:\n10 2\nbbaabbbaab\n\nSample Output 2:\naaaabbaabb", "before_after_length": [217, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u696886537", "n_user": "u696886537", "pos": "#fin=open('in','r')\n#input=lambda:fin.readline().strip()\n\np=int(input())\nfact=[0]*p\ninv=[0]*p\ndef f(x,m=p-2):\n\tans=1\n\twhile m:\n\t\tif m&1:ans=ans*x%p\n\t\tx=x*x%p\n\t\tm>>=1\n\treturn ans\nfact[0]=inv[0]=1\nfor i in range(1,p):\n\tfact[i]=fact[i-1]*i%p\n\tinv[i]=inv[i-1]*f(i)%p\nr=list(map(int,input().split()))\nc=[i for i in range(p) if r[i] == 1]\n#sum of -((x-j)^(p-1)-1)\n# (-j + x)^(p-1) = sum((-j)^i * x^(p-1-i) * binom(p-1,i))\ncoeff=[0]*p\nfor j in c:\n\tfor i in range(p-1,-1,-1):\n\t\tif i&1:coeff[p-1-i]+=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p\n\t\telse:coeff[p-1-i]-=fact[p-1]*inv[i]*inv[p-1-i]*f(j,i)%p\n\tcoeff[0]+=1\ncoeff=[(t%p+p)%p for t in coeff]\nprint(*coeff)", "neg": "fin=open('in','r')\ninput=lambda:fin.readline().strip()\n\np=int(input())\nfact=[0]*p\ninv=[0]*p\ndef f(x):\n\tm=p-2\n\tans=1\n\twhile m:\n\t\tif m&1:ans=ans*x%p\n\t\tx=x*x%p\n\t\tm>>=1\n\treturn ans\nfact[0]=inv[0]=1\nfor i in range(1,p):\n\tfact[i]=fact[i-1]*i%p\n\tinv[i]=inv[i-1]*f(i)%p\nr=list(map(int,input().split()))\nc=[i+1 for i in range(p) if r[i] == 1]\n#sum of -((x-j)^(p-1)-1)\ncoeff=[0]*p\nfor j in c:\n\tfor i in range(p-1,-1,-1):\n\t\tif i&1:coeff[i]-=fact[p-1]*inv[i]*inv[p-1-i]*j**i\n\t\telse:coeff[i]+=fact[p-1]*inv[i]*inv[p-1-i]*j**i\n\tcoeff[0]-=1\ncoeff=[((-t)%p+p)%p for t in coeff]\nprint(*coeff)", "jacc_sim": 0.9818181818181818, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [389, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u073852194", "n_user": "u073852194", "pos": "P = int(input())\nA = list(map(int, input().split()))\n\nQ = [1 for _ in range(P)]\n\nfor i in range(P):\n if A[i]:\n for k in range(P):\n if i == k:\n continue\n Q[i] *= (i - k)\n Q[i] %= P\n Q[i] = pow(Q[i], P - 2, P)\n else:\n Q[i] = 0\n\nF = [0 for _ in range(P + 1)]\nF[0] = 1\n\nfor i in range(P):\n tmp = [0 for _ in range(P + 1)]\n for j in range(1, P + 1):\n tmp[j] += F[j - 1]\n tmp[j] %= P\n for j in range(P + 1):\n tmp[j] += F[j] * (-i)\n tmp[j] %= P\n F = tmp\n\nres = [0 for _ in range(P)]\n\nfor i in range(P):\n G = [0 for _ in range(P)]\n G[P - 1] = F[P]\n res[P - 1] += Q[i] * G[P - 1]\n res[P - 1] %= P\n for j in range(P - 1)[::-1]:\n G[j] = F[j + 1] + i * G[j + 1]\n G[j] %= P\n res[j] += Q[i] * G[j]\n res[j] %= P\n\nprint(*res)", "neg": "P = int(input())\nA = list(map(int, input().split()))\n\nQ = [1 for _ in range(P)]\n\nfor i in range(P):\n if A[i]:\n for k in range(P):\n if i == k:\n continue\n Q[i] *= (i - k)\n Q[i] %= P\n else:\n Q[i] = 0\n\nfor i in range(P):\n Q[i] = pow(Q[i], P - 2, P)\n\nF = [0 for _ in range(P + 1)]\nF[0] = 1\n\nfor i in range(P):\n tmp = [0 for _ in range(P + 1)]\n for j in range(1, P + 1):\n tmp[j] += F[j - 1]\n tmp[j] %= P\n for j in range(P + 1):\n tmp[j] += F[j] * (-i)\n tmp[j] %= P\n F = tmp\n\nres = [0 for _ in range(P)]\n\nfor i in range(P):\n G = [0 for _ in range(P)]\n G[P - 1] = F[P]\n res[P - 1] += Q[i] * G[P - 1]\n res[P - 1] %= P\n for j in range(P - 1)[::-1]:\n G[j] = F[j + 1] + i * G[j + 1]\n G[j] %= P\n res[j] += Q[i] * G[j]\n res[j] %= P\n\nprint(*res)", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [391, 400], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u533039576", "n_user": "u533039576", "pos": "p = int(input())\na = list(map(int, input().split()))\n\nMOD = p\nMAX = p + 10\nfact = [1] * (MAX + 1) # i!\nfinv = [1] * (MAX + 1) # (i!)^{-1}\niinv = [1] * (MAX + 1) # i^{-1}\nfor i in range(2, MAX + 1):\n fact[i] = fact[i - 1] * i % MOD\n iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD\n finv[i] = finv[i - 1] * iinv[i] % MOD\n\n\ndef comb(n: int, k: int) -> int:\n if n < k or n < 0 or k < 0:\n return 0\n return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD\n\n\nb = [0] * p\nfor j in range(p):\n if a[j] == 1:\n b[0] += 1\n for k in range(p):\n b[k] += comb(p - 1, k) * pow(j, p - 1 - k, MOD) * (-1)**(\n (p - k) % 2)\n b[k] %= MOD\n\nprint(*b)\n", "neg": "p = int(input())\na = list(map(int, input().split()))\n\nMOD = p\nMAX = p + 10\nfact = [1] * (MAX + 1) # i!\nfinv = [1] * (MAX + 1) # (i!)^{-1}\niinv = [1] * (MAX + 1) # i^{-1}\nfor i in range(2, MAX + 1):\n fact[i] = fact[i - 1] * i % MOD\n iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD\n finv[i] = finv[i - 1] * iinv[i] % MOD\n\n\ndef comb(n: int, k: int) -> int:\n if n < k or n < 0 or k < 0:\n return 0\n return (fact[n] * finv[k] % MOD) * finv[n - k] % MOD\n\n\nb = [0] * p\nfor j in range(p):\n if a[j] == 1:\n b[0] += 1\n for k in range(p):\n b[k] += comb(p - 1, k) * pow(j, p - 1 - k, MOD)\n b[k] %= MOD\n\nprint(*b)\n", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [335, 319], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u218843509", "n_user": "u218843509", "pos": "p = int(input())\na = list(map(int, input().split()))\n\nlist_size = p-1\n\nf_list = [1] * list_size\nf_r_list = [1] * list_size\n\nfor i in range(list_size - 1):\n\tf_list[i + 1] = int((f_list[i] * (i + 2)) % p)\n\nf_r_list[-1] = pow(f_list[-1], p - 2, p)\n\nfor i in range(2, list_size + 1):\n\tf_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)\n\ndef comb(n, r):\n\tif n < r:\n\t\treturn 0\n\telif n == 0 or r == 0 or n == r:\n\t\treturn 1\n\telse:\n\t\treturn (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p \n\npows = [[1] for x in range(p)]\nfor i in range(p):\n\tfor _ in range(p-1):\n\t\tpows[i].append((pows[i][-1] * i) % p)\n\nans = [0 for _ in range(p)]\nfor i, x in enumerate(a):\n\tif x == 0:\n\t\tcontinue\n\tans[0] += 1\n\tans[0] %= p\n\tfor j in range(p):\n\t\tans[j] -= pows[(p-i)%p][p-1-j] * comb(p-1, j)\n\t\tans[j] %= p\n\nprint(*ans)", "neg": "p = int(input())\na = list(map(int, input().split()))\n\nlist_size = p-1\n\nf_list = [1] * list_size\nf_r_list = [1] * list_size\n\nfor i in range(list_size - 1):\n\tf_list[i + 1] = int((f_list[i] * (i + 2)) % p)\n\nf_r_list[-1] = pow(f_list[-1], p - 2, p)\n\nfor i in range(2, list_size + 1):\n\tf_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)\n\ndef comb(n, r):\n\tif n < r:\n\t\treturn 0\n\telif n == 0 or r == 0 or n == r:\n\t\treturn 1\n\telse:\n\t\treturn (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p \n\npows = [[1] for x in range(p)]\nfor i in range(p):\n\tfor _ in range(p-1):\n\t\tpows[i].append((pows[i][-1] * i) % p)\n\nans = [0 for _ in range(p)]\nfor i, x in enumerate(a):\n\tif x == 0:\n\t\tcontinue\n\tans[0] += 1\n\tans[0] %= p\n\tfor j in range(p):\n\t\tans[j] -= pows[p-i][p-1-j] * comb(p-1, j)\n\t\tans[j] %= p\n\nprint(*ans)", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [428, 424], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u941407962", "n_user": "u941407962", "pos": "import sys\nP = int(input())\nAs = list(map(int, input().split()))\nrs = [0]*P\nmod = P\nsys.setrecursionlimit(pow(10, 8))\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else : return power(x, (y-1)//2)**2 * x % mod\n \ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\ndef div(a, b):\n return mul(a, power(b, mod-2))\n\ndef cmb(n, r):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nNNN = 3000\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\nfor i in range( 2, NNN + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nC = []\nfor i in range(P):\n C.append(cmb(P-1, i))\n\n\nfor i in range(P):\n if As[i]:\n rs[0] += 1\n tmp = 1\n for k in range(P):\n k = P-1-k\n rs[k] += (-1 + 2*(k%2)) * tmp * C[k]\n rs[k] %= mod\n tmp = tmp * i % mod\nprint(*rs)\n\n", "neg": "import sys\nP = int(input())\nAs = list(map(int, input().split()))\nrs = [0]*P\nmod = P\nsys.setrecursionlimit(pow(10, 8))\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y//2)**2 % mod\n else : return power(x, (y-1)//2)**2 * x % mod\n \ndef mul(a, b):\n return ((a % mod) * (b % mod)) % mod\n\ndef div(a, b):\n return mul(a, power(b, mod-2))\n\ndef cmb(n, r):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nNNN = 3000\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\nfor i in range( 2, NNN + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\nC = []\nfor i in range(P):\n C.append(cmb(P-1, i))\n\n\nfor i in range(P):\n if not i % 100:\n print(i)\n if As[i]:\n rs[0] += 1\n tmp = 1\n for k in range(P):\n k = P-1-k\n rs[k] += (-1 + 2*(k%2)) * tmp * C[k]\n rs[k] %= mod\n tmp = tmp * i % mod\nprint(*rs)\n", "jacc_sim": 0.9696969696969697, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [470, 483], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u997113115", "n_user": "u997113115", "pos": "p = int(input())\nA = list(map(int, input().split()))\ncomb = [0]*p\ncomb[0] = 1\nfor i in range(1, p):\n comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p\n\nB = [0]*p\nfor i in range(p):\n if A[i] == 0:\n continue\n B[0] += 1\n Pow = 1\n for j in range(p):\n B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p\n Pow = Pow * (-i) % p\nprint(*[b % p for b in B])", "neg": "p = int(input())\nA = list(map(int, input().split()))\ncomb = [0]*p\nfor i in range(1, p):\n comb[i] = comb[i-1] * (p-i) * pow(i, p-2, p) % p\n\nB = [0]*p\nfor i in range(p):\n if A[i] == 0:\n continue\n B[0] += 1\n Pow = 1\n for j in range(p):\n B[p - 1 - j] = (B[p - 1 - j] - comb[j] * Pow) % p\n Pow = Pow * (-i) % p\nprint(*[b % p for b in B])", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [180, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u201234972", "n_user": "u201234972", "pos": "#import sys\n#input = sys.stdin.readline\ndef getInv(N,Q):\n inv = [0] * (N + 1)\n inv[1] = 1\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q % i]) % Q\n return inv\n\ndef getCmb(N,Q):\n inv = getInv(N,Q)\n nCr = [1] * (N + 1)\n for i in range(1, N + 1):\n nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q\n return nCr\n\n\ndef main():\n p = int( input())\n A = list( map( int, input().split()))\n ANS = [A[0]]\n pm1Ck = getCmb(p-1,p)\n Pow = [[0]*p for _ in range(p+1)]\n for i in range(p+1):\n Pow[i][0] = 1\n for i in range(1,p):\n for k in range(p-1):\n Pow[i][k+1] = Pow[i][k]*i%p\n for k in range(1,p):\n now = 0\n for i in range(p):\n now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]\n# now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]\n now %= p\n ANS.append(now)\n print( \" \".join( map( str, ANS)))\n # for i in range(p):\n # now = 0\n # for k in range(p):\n # now += ANS[k]*pow(i,k,p)\n # now %= p\n # print(A[i], now)\nif __name__ == '__main__':\n main()\n", "neg": "#import sys\n#input = sys.stdin.readline\ndef getInv(N,Q):\n inv = [0] * (N + 1)\n inv[1] = 1\n for i in range(2, N + 1):\n inv[i] = (-(Q // i) * inv[Q % i]) % Q\n return inv\n\ndef getCmb(N,Q):\n inv = getInv(N,Q)\n nCr = [1] * (N + 1)\n for i in range(1, N + 1):\n nCr[i] = (nCr[i - 1] * (N - i + 1) * inv[i]) % Q\n return nCr\n\n\ndef main():\n p = int( input())\n A = list( map( int, input().split()))\n ANS = [A[0]]\n pm1Ck = getCmb(p-1,p)\n Pow = [[0]*p for _ in range(p+1)]\n for i in range(1,p):\n Pow[i][0] = i\n for i in range(1,p):\n for k in range(p-1):\n Pow[i][k+1] = Pow[i][k]*i%p\n for k in range(1,p):\n now = 0\n for i in range(p):\n now -= A[i]*Pow[p-i][p-1-k]*pm1Ck[k]\n# now -= A[i]*pow(p-i,p-1-k,p)*pm1Ck[k]\n now %= p\n ANS.append(now)\n print( \" \".join( map( str, ANS)))\n # for i in range(p):\n # now = 0\n # for k in range(p):\n # now += ANS[k]*pow(i,k,p)\n # now %= p\n # print(A[i], now)\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [493, 493], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u214617707", "n_user": "u214617707", "pos": "import sys\ninput = sys.stdin.readline\np = int(input())\na = list(map(int, input().split()))\nMOD = p\n\nP = p\nfact = [0] * P\nfact[0] = 1\nfor i in range(1, P):\n fact[i] = fact[i - 1] * i\n fact[i] %= MOD\n\nrfact = [0] * P\nrfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)\nfor i in range(P - 2, -1, -1):\n rfact[i] = rfact[i + 1] * (i + 1)\n rfact[i] %= MOD\n\n\ndef comb(n, k):\n return fact[n] * rfact[n - k] * rfact[k] % MOD\n\n\nb = [0] * p\nfor i in range(p):\n if a[i]:\n b[0] += 1\n b[0] %= MOD\n s = 1\n for j in range(p - 1, -1, -1):\n b[j] -= comb(p - 1, j) * s\n b[j] %= MOD\n s *= -i\n s %= MOD\n\nprint(*b)\n", "neg": "p = int(input())\na = list(map(int, input().split()))\nMOD = p\n\nP = p\nfact = [0] * P\nfact[0] = 1\nfor i in range(1, P):\n fact[i] = fact[i - 1] * i\n fact[i] %= MOD\n\nrfact = [0] * P\nrfact[P - 1] = pow(fact[P - 1], MOD - 2, MOD)\nfor i in range(P - 2, -1, -1):\n rfact[i] = rfact[i + 1] * (i + 1)\n rfact[i] %= MOD\n\n\ndef comb(n, k):\n return fact[n] * rfact[n - k] * rfact[k] % MOD\n\n\nb = [0] * p\nfor i in range(p):\n if a[i]:\n b[0] += 1\n b[0] %= MOD\n s = 1\n for j in range(p):\n b[j] -= comb(p - 1, j) * s\n b[j] %= MOD\n s *= -i\n s %= MOD\n\nprint(*b)", "jacc_sim": 0.9111111111111111, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [307, 286], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u969190727", "n_user": "u969190727", "pos": "import sys\ninput = sys.stdin.readline\np=int(input())\nA=[int(i) for i in input().split()]\nB=[0]*p\n\nP=[[0]*p for _ in range(p)]\nfor i in range(1,p): \n for j in range(1,p):\n if j==1:\n P[i][j]=i\n else:\n P[i][j]=(P[i][j-1]*i)%p\n\nfor i in range(p):\n a=A[i]\n B[0]-=a\n for j in range(1,p):\n B[j]-=a*P[i][j]\n if j==p-1:\n B[j]+=a\nB=B[::-1]\nfor i in range(p):\n B[i]%=p\nprint(*B)", "neg": "import sys\ninput = sys.stdin.readline\np=int(input())\nA=[int(i) for i in input().split()]\nB=[0]*p\n\nP=[[0]*p for _ in range(p)]\nfor i in range(1,p): \n for j in range(p):\n if j==0:\n P[i][j]=i\n else:\n P[i][j]=(P[i][j-1]*i)%p\nPP=[0]*p\nfor i in range(1,p):\n for j in range(1,p):\n PP[j]=(PP[j]+P[i][j])%p\nfor i in range(p):\n a=A[i]\n B[0]-=a\n for j in range(1,p):\n B[j]-=a*PP[j]\n if j==p-1:\n B[j]+=a\nB=B[::-1]\nfor i in range(p):\n B[i]%=p\nprint(*B)", "jacc_sim": 0.9722222222222222, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [218, 260], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u104282757", "n_user": "u104282757", "pos": "p = int(input())\na_list = list(map(int, input().split()))\nr_list = [0] * p\n\nfact = [0] * p\nfact[0] = 1\nfor i in range(1, p):\n fact[i] = fact[i - 1] * i % p\n\nfact_inv = [0] * p\nfact_inv[-1] = pow(fact[-1], p-2, p)\nfor i in range(p-2, -1 ,-1):\n fact_inv[i] = (fact_inv[i+1] * (i+1)) % p\n\nncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]\n\nfor j in range(p):\n if a_list[j] == 0:\n continue\n k = 1\n for i in range(p-1, -1, -1):\n r_list[i] -= ncr[i] * k\n r_list[i] %= p\n k *= -j\n k %= p\n r_list[0] += 1\n\nr_list[0] %= p\nprint(*r_list)\n", "neg": "p = int(input())\na_list = list(map(int, input().split()))\nr_list = [0] * p\n\nfact = [0] * p\nfact[0] = 1\nfor i in range(1, p):\n fact[i] = fact[i - 1] * i % p\n\nfact_inv = [0] * p\nfact_inv[-1] = pow(fact[-1], p-2, p)\nfor i in range(p-2, -1 ,-1):\n fact_inv[i] = (fact_inv[i+1] * (i+1)) % p\n\nncr = [(fact[p-1] * fact_inv[p-1-i] * fact_inv[i]) % p for i in range(p)]\n\nfor j in range(p):\n if a_list[j] == 0:\n continue\n k = 1\n for i in range(p-1, -1, -1):\n r_list[i] -= ncr[i] * k\n r_list[i] %= p\n k *= -j\n k %= p\n r_list[0] += 1\n\n\nprint(*r_list)\n", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [299, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02950", "p_user": "u368780724", "n_user": "u368780724", "pos": "p = int(input())\nmod = p\n\n\ndef frac(limit):\n frac = [1]*limit\n for i in range(2,limit):\n frac[i] = i * frac[i-1]%mod\n fraci = [None]*limit\n fraci[-1] = pow(frac[-1], mod -2, mod)\n for i in range(-2, -limit-1, -1):\n fraci[i] = fraci[i+1] * (limit + i + 1) % mod\n return frac, fraci\n\nfrac, fraci = frac(p)\n\n\n\nA = list(map(int, input().split()))\n\nC = [0]*p\nfor i in range(p):\n a = A[i]\n for j in range(i):\n a = (a-C[j]*frac[i]*fraci[i-j])\n C[i] = fraci[i]*a%p\nB = [0]*p\nt = [0]*p\nt[0] = 1\nfor i in range(p):\n for j in range(p):\n B[j] += t[j]*C[i]\n t2 = ([0] + t)[:-1]\n t2 = [(a-b*i)%p for a, b in zip(t2, t)]\n t = t2[:]\n\nB = [b%p for b in B]\nprint(*B)", "neg": "p = int(input())\nmod = p\n\n\ndef frac(limit):\n frac = [1]*limit\n for i in range(2,limit):\n frac[i] = i * frac[i-1]%mod\n fraci = [None]*limit\n fraci[-1] = pow(frac[-1], mod -2, mod)\n for i in range(-2, -limit-1, -1):\n fraci[i] = fraci[i+1] * (limit + i + 1) % mod\n return frac, fraci\n\nfrac, fraci = frac(p)\n\n\n\nA = list(map(int, input().split()))\n\nC = [0]*p\nfor i in range(p):\n a = A[i]\n for j in range(i):\n a = (a-C[j]*frac[i]*fraci[i-j])\n C[i] = fraci[i]*a%p\n\nB = [0]*p\nt = [0]*p\nt[0] = 1\nfor i in range(1, p):\n t2 = ([0] + t)[::-1]\n t2 = [a-b*i for a, b in zip(t2, t)]\n for j in range(p):\n B[j] += t2[j]*C[i]\n t = t2[:]\n\nB = [b%p for b in B]\nprint(*B)\n", "jacc_sim": 1.0, "nl": "You are given a prime number \"p\" and a sequence of \"p\" integers consisting of zeros and ones. Find a polynomial of degree at most \"p-1\" satisfying certain conditions. The coefficients of the polynomial must be integers between 0 and \"p-1\". The polynomial must also satisfy specific congruence conditions. The input is given in a specific format, and the output should be the coefficients of the polynomial. Multiple solutions are acceptable.", "before_after_length": [359, 360], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02962", "p_user": "u794173881", "n_user": "u794173881", "pos": "s = input()\nt = input()\n\ndef z_algorithm(s):\n a = [0] * len(s)\n i = 1\n j = 0\n a[0] = len(s)\n while i < len(s):\n while i + j < len(s) and s[j] == s[i+j]:\n j += 1\n a[i] = j\n if j == 0:\n i += 1\n continue\n k = 1\n while i + k < len(s) and k + a[k] < j:\n a[i+k] = a[k]\n k += 1\n i += k\n j -= k\n return a\n\ndef solve(i, li):\n ans = 0\n while True:\n if i < 0 or len(li) <= i or visited[i]:\n break\n if li[i] < len(t):\n visited[i] = True\n break\n if li[i] >= len(t):\n visited[i] = True\n ans += 1\n i += len(t)\n return ans\n\n#s\u3092\u4f38\u3070\u3059\nnew_s = s\nwhile True:\n if len(new_s) > len(t):\n s = new_s\n break\n new_s += new_s\n\ns = s*3\nli = z_algorithm(t + s)[len(t):]\nvisited = [False] * len(li)\nans1 = 0\nfor i in range(len(li)):\n ans1 = max(ans1, solve(i, li))\n\ns += s\nli = z_algorithm(t + s)[len(t):]\nvisited = [False] * len(li)\nans2 = 0\nfor i in range(len(li)):\n ans2 = max(ans2, solve(i, li))\n\nif ans1 == ans2:\n print(ans1)\nelse:\n print(-1)\n", "neg": "s = input()\nt = input()\n\ndef z_algorithm(s):\n a = [0] * len(s)\n i = 1\n j = 0\n a[0] = len(s)\n while i < len(s):\n while i + j < len(s) and s[j] == s[i+j]:\n j += 1\n a[i] = j\n if j == 0:\n i += 1\n continue\n k = 1\n while i + k < len(s) and k + a[k] < j:\n a[i+k] = a[k]\n k += 1\n i += k\n j -= k\n return a\n\ndef solve(i, li):\n ans = 0\n while True:\n if visited[i]:\n break\n if i < 0 or len(li) <= i:\n break\n if li[i] < len(t):\n visited[i] = True\n break\n if li[i] >= len(t):\n visited[i] = True\n ans += 1\n i += len(t)\n return ans\n\n#s\u3092\u4f38\u3070\u3059\nnew_s = \"\"\nwhile True:\n new_s += s\n if len(new_s) > len(t):\n s = new_s\n break\n\ns = s*3\nli = z_algorithm(t + s)[len(t):]\nvisited = [False] * len(li)\nans1 = 0\nfor i in range(len(li)):\n ans1 = max(ans1, solve(i, li))\n'''\ns += s\nli = z_algorithm(t + s)[len(t):]\nvisited = [False] * len(li)\nans2 = 0\nfor i in range(len(li)):\n ans2 = max(ans2, solve(i, li))\n\nif ans1 == ans2:\n print(ans1)\nelse:\n print(-1)\n'''\nprint(ans1)", "jacc_sim": 0.9811320754716981, "nl": "You are given two strings, s and t, consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the condition is finite, and find the maximum value of such i if the number is finite. The condition is that there exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s. If the number of non-negative integers i satisfying the condition is finite, print the maximum value of such i; if the number is infinite, print -1.", "before_after_length": [484, 496], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02962", "p_user": "u340781749", "n_user": "u340781749", "pos": "import sys\n\nsys.setrecursionlimit(10 ** 6)\n\n\ndef rolling_hash(s, w, MOD):\n ret = []\n tmp = 0\n p = pow(26, w, MOD)\n ords = [ord(c) - 97 for c in s]\n for i, o in enumerate(ords):\n tmp = tmp * 26 + o\n if i >= w:\n tmp = (tmp - ords[i - w] * p)\n tmp %= MOD\n ret.append(tmp)\n return ret\n\n\ndef solve(s, t):\n MOD = 10 ** 9 + 7\n ls, lt = len(s), len(t)\n k = (lt - 1) // ls + 1\n s *= k * 2\n ls *= k\n rs, rt = rolling_hash(s, lt, MOD), rolling_hash(t, lt, MOD)\n rs = rs[ls:]\n ht = rt[-1]\n\n checked = [-1] * ls\n\n def series(i, st):\n if st <= i < st + lt:\n return float('-inf')\n if checked[i] == -1:\n checked[i] = series((i + lt) % ls, st) + 1 if rs[i] == ht else 0\n return checked[i]\n\n for i, hs in enumerate(rs):\n if hs != ht:\n continue\n ret = series((i + lt) % ls, i)\n if ret == float('-inf'):\n return -1\n checked[i] = ret + 1\n\n return max(0, max(checked))\n\n\ns = input()\nt = input()\nprint(solve(s, t))\n", "neg": "def rolling_hash(s, w, MOD):\n ret = []\n tmp = 0\n p = pow(26, w, MOD)\n ords = [ord(c) - 97 for c in s]\n for i, o in enumerate(ords):\n tmp = tmp * 26 + o\n if i >= w:\n tmp = (tmp - ords[i - w] * p)\n tmp %= MOD\n ret.append(tmp)\n return ret\n\n\ndef solve(s, t):\n MOD = 10 ** 9 + 7\n ls, lt = len(s), len(t)\n k = (lt - 1) // ls + 1\n s *= k * 2\n ls *= k\n rs, rt = rolling_hash(s, lt, MOD), rolling_hash(t, lt, MOD)\n rs = rs[ls:]\n ht = rt[-1]\n\n checked = [-1] * ls\n\n def series(i, st):\n print(i, st, checked)\n if i == st:\n return float('-inf')\n if checked[i] == -1:\n checked[i] = series((i + lt) % ls, st) + 1 if rs[i] == ht else 0\n return checked[i]\n\n for i, hs in enumerate(rs):\n if hs != ht:\n continue\n ret = series((i + lt) % ls, i)\n if ret == float('-inf'):\n return -1\n checked[i] = ret + 1\n\n return max(0, max(checked))\n\n\ns = input()\nt = input()\nprint(solve(s, t))\n", "jacc_sim": 0.927536231884058, "nl": "You are given two strings, s and t, consisting of lowercase English letters. Determine if the number of non-negative integers i satisfying the condition is finite, and find the maximum value of such i if the number is finite. The condition is that there exists a non-negative integer j such that the concatenation of i copies of t is a substring of the concatenation of j copies of s. If the number of non-negative integers i satisfying the condition is finite, print the maximum value of such i; if the number is infinite, print -1.", "before_after_length": [412, 401], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u844789719", "n_user": "u844789719", "pos": "import bisect\nN, K, *A = [int(_) for _ in open(0).read().split()]\nK -= 1\nL = [[] for _ in range(2 * 10**5 + 1)]\nfor i, a in enumerate(A * 2):\n L[a] += [i]\nbefore_next = [L[a][bisect.bisect(L[a], i)] for i, a in enumerate(A)]\nfirst_cycle = [None] * N\nnow = 0\nidx = 0\ncycle = 0\nwhile True:\n if first_cycle[now] is not None:\n break\n first_cycle[now] = cycle\n now = before_next[now] + 1\n dcycle, now = divmod(now, N)\n cycle += dcycle\ncycle2 = cycle\ncycle1 = first_cycle[now]\n#K cycle\u76ee=cycle1+(K-cycle1)%(cycle2-cycle1) cycle\u76ee\nK2 = cycle1 + (K - cycle1) % (cycle2 - cycle1)\nif K2:\n f1 = f2 = 0\n for i in range(N - 1, -1, -1):\n if first_cycle[i] == K2 - 1:\n f1 = 1\n break\n for j in range(N - 1, -1, -1):\n if first_cycle[j] == K2:\n f2 = 1\n break\n if f2:\n B = A[j:]\n elif f1:\n B = A[i:] + A\nelse:\n B = A\nans = []\ncnt = [0] * (2 * 10**5 + 1)\nfor a in B:\n if cnt[a] > 0:\n while True:\n cnt[ans.pop()] -= 1\n if cnt[a] == 0:\n break\n else:\n ans += [a]\n cnt[a] += 1\nprint(' '.join(map(str, ans)))\n", "neg": "import bisect\nN, K, *A = [int(_) for _ in open(0).read().split()]\nK -= 1\nL = [[] for _ in range(10)]\nfor i, a in enumerate(A * 2):\n L[a] += [i]\nbefore_next = [L[a][bisect.bisect(L[a], i)] for i, a in enumerate(A)]\nfirst_cycle = [None] * N\nnow = 0\nidx = 0\ncycle = 0\nwhile True:\n if first_cycle[now] is not None:\n break\n first_cycle[now] = cycle\n now = before_next[now] + 1\n dcycle, now = divmod(now, N)\n cycle += dcycle\ncycle2 = cycle\ncycle1 = first_cycle[now]\n#K cycle\u76ee=cycle1+(K-cycle1)%(cycle2-cycle1) cycle\u76ee\nK2 = cycle1 + (K - cycle1) % (cycle2 - cycle1)\nexit()\nif K2:\n f1 = f2 = 0\n for i in range(N - 1, -1, -1):\n if first_cycle[i] == K2 - 1:\n f1 = 1\n break\n for j in range(N - 1, -1, -1):\n if first_cycle[j] == K2:\n f2 = 1\n break\n if f2:\n B = A[j:]\n elif f1:\n B = A[i:] + A\n else:\n raise\nelse:\n B = A\nans = []\ncnt = [0] * 10\nfor a in B:\n if cnt[a] > 0:\n while True:\n cnt[ans.pop()] -= 1\n if cnt[a] == 0:\n break\n else:\n ans += [a]\n cnt[a] += 1\nprint(' '.join(map(str, ans)))\n", "jacc_sim": 0.9571428571428572, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [479, 475], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u690536347", "n_user": "u690536347", "pos": "from collections import defaultdict\nfrom bisect import bisect_right\n\nN, K = map(int, input().split())\n*A, = map(int, input().split())\n\ndd = defaultdict(list)\nfor i, j in enumerate(A):\n dd[j].append(i)\n\npos = 0\nloop = 1\n# l = []\ncic = defaultdict(list)\n\nwhile pos < N:\n num = A[pos]\n \n pp = bisect_right(dd[num], pos)\n if pp < len(dd[num]):\n pos = dd[num][pp]+1\n else:\n pos = dd[num][0]+1 \n loop += 1\n cic[loop].append(pos)\n\npos = cic[K%loop][0] if cic[K%loop] else 0\nans = []\nwhile pos < N:\n num = A[pos]\n pp = bisect_right(dd[num], pos)\n if pp < len(dd[num]):\n pos = dd[num][pp]+1\n else:\n ans.append(num)\n pos += 1\nprint(*ans)\n", "neg": "from collections import defaultdict\nfrom bisect import bisect_right\n\nN, K = map(int, input().split())\n*A, = map(int, input().split())\n\ndd = defaultdict(list)\nfor i, j in enumerate(A):\n dd[j].append(i)\n\npos = 0\nloop = 1\n# l = []\ncic = defaultdict(list)\n\nwhile pos < N:\n num = A[pos]\n \n pp = bisect_right(dd[num], pos)\n if pp < len(dd[num]):\n pos = dd[num][pp]+1\n else:\n pos = dd[num][0]+1 \n loop += 1\n # l.append((pos, loop))\n cic[loop].append(pos)\n\n# for pos, v in l:\n# if (K-v)%loop==0:\n# break\n\nif cic[K%loop]:\n print()\nelse:\n pos = cic[K%loop][0] #pos if pos=len(dic[m]):\n cycle += 1\n ps += 1\n ps %= N\n m = A[ps]\n if ps==0:\n cycle += 1\n break\nk = K%cycle\nj = bisect_left(ls,k*N)\nif ls[j]==k*N:\n c = (ls[j]-1)%N\n print(A[c])\nelif ls[j]==k*N+1:\n pass\nelse:\n c = (ls[j-1]-1)%N\n M = k*N-ls[j-1]\n ans = [A[c]]\n log = set(ans)\n ind = {}\n ind[A[c]] = 0\n cnt = 0\n while M:\n c += 1\n c %= N\n cnt += 1\n cnt %= N\n M -= 1\n if not A[c] in log:\n log.add(A[c])\n ind[A[c]] = cnt\n ans += [A[c]]\n else:\n log.remove(A[c])\n ans = ans[:ind[A[c]]]\n log = set(ans)\n cnt = ind[A[c]]-1\n print(*ans)", "neg": "from bisect import bisect_left\nfrom collections import defaultdict\nN, K, *A = map(int, open('0').read().split())\ndic = defaultdict(list)\nfor i, a in enumerate(A):\n dic[a] += [i]\nls = []\nps = 0\nm = A[0]\ncycle = 0\nwhile True:\n ls.append(ps+N*cycle+1)\n i = bisect_left(dic[m],ps+1)\n ps = dic[m][i%len(dic[m])]\n if i>=len(dic[m]):\n cycle += 1\n ps += 1\n ps %= N\n m = A[ps]\n if ps==0:\n cycle += 1\n break\nk = K%cycle\nj = bisect_left(ls,k*N)\nif ls[j]==k*N:\n c = (ls[j]-1)%N\n print(A[c])\nelif ls[j]==k*N+1:\n pass\nelse:\n c = (ls[j-1]-1)%N\n M = k*N-ls[j-1]\n ans = [A[c]]\n log = set(ans)\n ind = {}\n ind[A[c]] = 0\n cnt = 0\n while M:\n c += 1\n c %= N\n cnt += 1\n cnt %= N\n M -= 1\n if not A[c] in log:\n log.add(A[c])\n ind[A[c]] = cnt\n ans += [A[c]]\n else:\n log.remove(A[c])\n ans = ans[:ind[A[c]]]\n cnt = ind[A[c]]-1\n print(*ans)", "jacc_sim": 0.9846153846153847, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [441, 433], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u819048695", "n_user": "u819048695", "pos": "import itertools\nfrom bisect import bisect_left,bisect\nimport sys\n\nn,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nA_max=max(A)\nlst=[[] for i in range(A_max+1)]\nflag=[0]*(A_max+1)\nfor i in range(n):\n lst[A[i]].append(i)\n\nflag=[0]*n\ndata=[]\ni=0\nwhile flag[i]==0:\n flag[i]=1\n a=A[i]\n b=bisect(lst[a],i)\n if b==len(lst[a]):\n data.append(i)\n i=lst[a][0]+1\n else:\n i=lst[a][b]+1\n if i==n:\n data.append(n)\n i=0\n\n#\u5927\u4e08\u592b\nif not data:\n print()\n sys.exit()\ns=len(data)\nzzz=data[(K-1)%s]\ni=zzz\nd=[]\nwhile ik-2)>j:\n r+=s,\n i+=1\n else:i=b[s][j]+1\n c+=j<1\n s=a[i%n]\nprint(*r)", "neg": "n,k,*a=map(int,open(0).read().split())\nl,r,*b=[[]for _ in range(10**6)]\nfor i,v in enumerate(a):\n b[v]+=i,\n l+=len(b[v]),\ns=a[0]\ni=c=0\nwhile 1:\n j=l[i]%len(b[s])\n if(c>k-2)>j:\n r+=s,\n i+=1\n else:i=-~b[s][j]%n\n c+=j<1\n if i<1:\n if c>k-2:break\n k%=c+1\n c=0\n s=a[i]\nprint(*r)", "jacc_sim": 0.9574468085106383, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [227, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u515207244", "n_user": "u515207244", "pos": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ntable = {}\ninit_table = {}\nmove = {}\n\nfor i in range(N):\n if A[i] in table:\n move[table[A[i]]], move[i] = i+1, init_table[A[i]]+1\n else:\n if A[i] not in init_table:\n init_table[A[i]] = i\n table[A[i]] = i\n\nT = K\nidx = 0\nremain = [0]\nfor i in range(1, K+1):\n while idx in move and idx < move[idx]:\n idx = move[idx]\n remain.append(idx)\n if(idx == N and i != K):\n T = K % i\n break\n if idx in move:\n idx = move[idx]\n else:\n idx += 1\n\nif(T == 0):\n print()\n exit()\nidx = remain[T]\nret = []\nwhile idx < len(A):\n while idx in move and idx < move[idx]:\n idx = move[idx]\n if(idx < len(A)):\n ret.append(A[idx])\n idx += 1\n\nprint(*ret)\n\n", "neg": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ntable = {}\ninit_table = {}\nmove = {}\n\nfor i in range(N):\n if A[i] not in table:\n table[A[i]] = i\n init_table[A[i]] = i\n else: \n move[table[A[i]]], move[i] = i+1, init_table[A[i]]+1\n table[A[i]] = i\n\nT = K\nnext_idx = 0\nremain = [0]\nfor i in range(1, K+1):\n while idx in move and idx < move[idx]:\n idx = move[idx]\n remain.append(idx)\n if idx in move:\n idx = move[idx]\n else:\n idx += 1\n if(idx == N and i != K):\n T = K % i\n break\n\nif(T == 0):\n print()\n exit()\nidx = remain[T]\nret = []\nwhile idx < len(A):\n while idx in move and idx < move[idx]:\n idx = move[idx]\n if(idx < len(A)):\n ret.append(A[idx])\n idx += 1\n\nprint(*ret)\n\n", "jacc_sim": 0.9787234042553191, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [322, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u060938295", "n_user": "u060938295", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jul 21 23:25:47 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\nimport bisect\n\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\n\nT = [[] for _ in range(2*10**5+1)]\n\nfor i in range(N):\n T[A[i]].append(i)\n\ns = A[0]\npointa = 0\ncounta, res = 0, [-1]\nwhile True:\n tmp = bisect.bisect_right(T[s], pointa) % len(T[s])\n p_pointa = pointa\n pointa = T[s][tmp] + 1\n if pointa == p_pointa + 1 or pointa < p_pointa:\n counta += 1\n res.append(p_pointa)\n if pointa == N:\n counta += 1\n res.append(p_pointa)\n break\n s = A[pointa]\n\nans = []\nif K % counta != 0:\n pointa = res[K % counta]\n# ans.append(A[pointa])\n while pointa < N:\n if pointa < T[A[pointa]][-1]:\n tmp = bisect.bisect_right(T[A[pointa]],pointa)\n pointa = T[A[pointa]][tmp] + 1\n else:\n ans.append(A[pointa])\n pointa += 1\n# print(ans)\nprint(' '.join(map(str,ans)))\n", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jul 21 23:25:47 2019\n\n@author: Yamazaki Kenichi\n\"\"\"\nimport bisect\n\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\n\nT = [[] for _ in range(2*10**5+1)]\n\nfor i in range(N):\n T[A[i]].append(i)\n\ns = A[0]\npointa = 0\ncounta, res = 0, [-1]\nwhile True:\n tmp = bisect.bisect_right(T[s], pointa) % len(T[s])\n p_pointa = pointa\n pointa = T[s][tmp] + 1\n if pointa == p_pointa + 1 or pointa < p_pointa:\n counta += 1\n res.append(p_pointa)\n elif pointa == N:\n counta += 1\n res.append(p_pointa)\n break\n s = A[pointa]\n\nans = []\nif K % counta != 0:\n pointa = res[K % counta]\n# ans.append(A[pointa])\n while pointa < N:\n if pointa < T[A[pointa]][-1]:\n tmp = bisect.bisect_right(T[A[pointa]],pointa)\n pointa = T[A[pointa]][tmp] + 1\n else:\n ans.append(A[pointa])\n pointa += 1\n# print(ans)\nprint(' '.join(map(str,ans)))\n", "jacc_sim": 0.9863013698630136, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [410, 410], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u792670114", "n_user": "u792670114", "pos": "N, K = map(int, input().split())\nAs = list(map(int, input().split()))\nM = [[] for i in range(200001)]\nfor i, a in enumerate(As):\n M[a].append(i)\nS = []\nfor i, a in enumerate(As):\n l = M[a]\n index = l.index(i)\n if index+1 == len(l):\n n = l[0]+N\n else:\n n = l[index+1]\n S.append(n+1-i)\n#print(S)\np = 0\nwhile True:\n p = p+S[p%N]\n if p%N == 0:\n break\ncount = p//N\n#print(count)\nK = K%count\n#print(K)\np = 0\ns = []\nwhile p < N*K:\n q = p+S[p%N]\n if q > N*K:\n s.append(As[p%N])\n p = p+1\n else:\n p = q\nprint(\" \".join(map(str, s)))\n", "neg": "N, K = map(int, input().split())\nAs = list(map(int, input().split()))\nM = [[] for i in range(200001)]\nfor i, a in enumerate(As):\n M[a].append(i)\nS = []\nfor i, a in enumerate(As):\n l = M[a]\n index = l.index(i)\n if index+1 == len(l):\n n = l[0]+N\n else:\n n = l[index+1]\n S.append(n+1-i)\n#print(S)\np = 0\nwhile True:\n p = p+S[p%N]\n if p%N == 0:\n break\ncount = p//N\n#print(count)\nK = K%count\n#print(K)\np = 0\nwhile True:\n q = p+S[p%N]\n if p > N*K:\n break\n p = q\nindex = p%N\ns = []\nfor a in As[index-1:]:\n i = -1\n for j in range(len(s)):\n if s[j] == a:\n i = j\n if i < 0:\n s.append(a)\n else:\n s = s[0:i]\nprint(\" \".join(map(str, s)))\n", "jacc_sim": 0.9814814814814815, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [278, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u667469290", "n_user": "u667469290", "pos": "# -*- coding: utf-8 -*-\n\ndef solve():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n D = {}\n for j,a in enumerate(A):\n D[a] = D.get(a,[])+[j]\n\n t,k = 0,0\n T = [0]\n while True:\n k = (D[A[t]].index(t)+1)%len(D[A[t]])\n if k == 0:\n T.append(A[t])\n t = (D[A[t]][k]+1)%N\n if t == 0:\n break\n\n if T == [0]:\n return ''\n if K == 1 or (K-1)%len(T) == 0:\n t = 0\n else:\n t = D[T[(K-1)%len(T)]][0]+1\n S = []\n flag = False\n while t < N:\n k = (D[A[t]].index(t)+1)%len(D[A[t]])\n if k == 0:\n S.append(A[t])\n t += 1\n else:\n t = D[A[t]][k]+1\n\n res = ' '.join(map(str,S))\n\n return str(res)\n\nif __name__ == '__main__':\n print(solve())", "neg": "# -*- coding: utf-8 -*-\n\ndef solve():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n D = {}\n for j,a in enumerate(A):\n D[a] = D.get(a,[])+[j]\n\n t,k = 0,0\n T = [0]\n while True:\n k = (D[A[t]].index(t)+1)%len(D[A[t]])\n if k == 0:\n T.append(A[t])\n t = (D[A[t]][k]+1)%N\n if t == 0:\n break\n\n T[0] = T.pop()\n t = D[T[K%len(T)]][0]+1\n S = []\n while t < N:\n k = (D[A[t]].index(t)+1)%len(D[A[t]])\n if k == 0:\n S.append(A[t])\n t = D[A[t]][k]+1\n\n res = ' '.join(map(str,S))\n\n return str(res)\n\nif __name__ == '__main__':\n print(solve())", "jacc_sim": 0.9193548387096774, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [365, 317], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02964", "p_user": "u211160392", "n_user": "u211160392", "pos": "N,K = map(int,input().split())\nA = list(map(int,input().split()))\nhoge = [[]for i in range(200001)]\nfor i in range(N):\n hoge[A[i]].append(i)\nNEXT = [-1]*N\nfor i in hoge:\n for j in range(-len(i),0):\n NEXT[i[j]] = i[j+1]\ni = 1\np = 0\nwhile i < K:\n #print(i,p)\n if NEXT[p] <= p:\n i += 1\n if NEXT[p] == N-1:\n i += 1\n p = (NEXT[p]+1)%N\n if p == 0:\n i = (K//(i-1))*(i-1)+1\nwhile p < N:\n if NEXT[p] <= p:\n print(A[p],end = \" \")\n p += 1\n else:\n p = NEXT[p]+1\nprint()", "neg": "N,K = map(int,input().split())\nA = list(map(int,input().split()))\nhoge = [[]for i in range(200001)]\nfor i in range(N):\n hoge[A[i]].append(i)\nNEXT = [-1]*N\nfor i in hoge:\n for j in range(-len(i),0):\n NEXT[i[j]] = i[j+1]\ni = 1\np = 0\nwhile i < K:\n #print(i,p)\n if NEXT[p] <= p or NEXT[p] == N-1:\n i += 1\n p = (NEXT[p]+1)%N\n if p == 0:\n i = min(((K-1)//(i-1))*(i-1)+1,K-2)\nwhile p < N:\n if NEXT[p] <= p:\n print(A[p],end = \" \")\n p += 1\n else:\n p = NEXT[p]+1\nprint()", "jacc_sim": 0.9333333333333333, "nl": "You are given a sequence of N * K integers represented by X = (X_0, X_1, ..., X_{N * K - 1}). Each element is represented by another sequence of N integers: A = (A_0, A_1, ..., A_{N-1}). Snuke has an initially empty integer sequence s. For each i in the range 0 to N * K - 1, he performs the following operations: If s does not contain X_i, he adds X_i to the end of s. If s contains X_i, he repeatedly deletes the element at the end of s until s no longer contains X_i. Find the elements of s after Snuke finishes the operations. Constraints: 1 <= N <= 2 * 10^5, 1 <= K <= 10^12, 1 <= A_i <= 2 * 10^5. Input is given as N, K, and the sequence A. Output the elements of s after the operations, in order from beginning to end, with spaces in between.", "before_after_length": [250, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00874", "p_user": "u591052358", "n_user": "u591052358", "pos": "while True:\n w,d = [int(i) for i in input().split()]\n if w == 0:\n break\n h = [int(i) for i in input().split()]\n h_ = [int(i) for i in input().split()]\n h = sorted(h)\n h_ = sorted(h_)\n hdic = {}\n h_dic = {}\n\n for i in h:\n if i in hdic.keys():\n hdic[i]+= 1\n else:\n hdic[i] = 1\n \n for i in h_:\n if i in h_dic.keys():\n h_dic[i]+= 1\n else:\n h_dic[i] = 1\n ans = sum(h)+ sum(h_)\n for num in hdic.keys():\n if num in h_dic.keys():\n ans -= num*min(hdic[num],h_dic[num])\n print(ans)\n\n", "neg": "while True:\n w,d = [int(i) for i in input().split()]\n if w == 0:\n break\n h = [int(i) for i in input().split()]\n h_ = [int(i) for i in input().split()]\n h = sorted(h)\n h_ = sorted(h_)\n hdic = {}\n h_dic = {}\n\n for i in h:\n if i in hdic.keys():\n hdic[i]+= 1\n else:\n hdic[i] = 1\n \n for i in h_:\n if i in h_dic.keys():\n h_dic[i]+= 1\n else:\n h_dic[i] = 1\n ans = sum(h)+ sum(h_)\n print(ans)\n for num in hdic.keys():\n if num in h_dic.keys():\n ans -= num*min(hdic[i],h_dic[i])\n print(hdic,h_dic)\n print(ans)\n\n", "jacc_sim": 1.0, "nl": "Problem A: Cubist Artwork\n\nThe International Center for Picassonian Cubism, a Spanish national museum dedicated to Pablo Picasso, organized a competition for an artwork to be displayed in front of the museum building. The artwork consists of a collection of cubes on a grid, amusing visitors with changing shapes from different views. Each cube has one-foot edges and is placed on the ground or on another cube. The judging committee, responsible for selecting the winning proposal, considers artistic quality and installation cost. The cost is proportional to the number of cubes required for installation. Each proposal includes front and side views, indicating the maximum heights of cube piles for each column and row. The task is to determine the minimum number of cubes needed for installation. The input consists of datasets, each with grid dimensions, front and side views. The output should contain the minimum number of cubes for each dataset.", "before_after_length": [245, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00884", "p_user": "u063091489", "n_user": "u063091489", "pos": "while True:\n N = int(input())\n if N == 0:\n break\n \n first_group_menbers = set(input()[:-1].split(\":\")[1].split(\",\"))\n d = {}\n for i in range(N-1):\n group, members = input()[:-1].split(\":\")\n d[group] = set(members.split(\",\"))\n \n for i in range(N-1):\n for group, members in d.items():\n if group in first_group_menbers:\n first_group_menbers.remove(group)\n for m in members:\n first_group_menbers.add(m)\n \n print(len(first_group_menbers))", "neg": "while True:\n N = int(input())\n if N == 0:\n break\n \n first_group_menbers = set(input()[:-1].split(\":\")[1].split(\",\"))\n d = {}\n for i in range(N-1):\n group, members = input()[:-1].split(\":\")\n d[group] = set(members.split(\",\"))\n \n for i in range(N-3):\n for group, members in d.items():\n if group in first_group_menbers:\n first_group_menbers.remove(group)\n for m in members:\n first_group_menbers.add(m)\n \n print(len(first_group_menbers))", "jacc_sim": 0.9736842105263158, "nl": "Problem A: Membership Management\n\nPeter, a senior manager at Agile Change Management (ACM) Inc., handles membership for employees in task groups. Task groups are frequently reorganized, causing membership changes. Peter updates membership information by specifying group names and their members. Smaller task groups can be included in larger ones. The goal is to write a program that identifies group members, even in deeply nested groups.\n\nInput:\nThe input consists of datasets, each containing group membership information. Each dataset starts with a positive integer n (no more than 100), representing the number of groups. Following this are n lines, each containing the membership information for a group. Each line includes the group name followed by a colon and a list of its members, delimited by commas and terminated by a period. Group names are mutually different, and each member is a non-empty string of lowercase letters, representing either a group name or an employee name.\n\nOutput:\nFor each dataset, output the number of employees included in the first group of the dataset.\n\nSample Input:\n2\ndevelopment:alice,bob,design,eve.\ndesign:carol,alice.\n3\none:another.\nanother:yetanother.\nyetanother:dave.\n3\nfriends:alice,bob,bestfriends,carol,fran,badcompany.\nbestfriends:eve,alice.\nbadcompany:dave,carol.\n5\na:b,c,d,e.\nb:c,d,e,f.\nc:d,e,f,g.\nd:e,f,g,h.\ne:f,g,h,i.\n4\naa:bb.\ncc:dd,ee.\nff:gg.\nbb:cc.\n0\n\nOutput for the Sample Input:\n4\n1\n6\n4\n2", "before_after_length": [181, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00914", "p_user": "u728992264", "n_user": "u728992264", "pos": "import itertools\n\nwhile True:\n n, k, s = map(int, input().split())\n if n + k + s == 0:\n break\n\n a = itertools.combinations(range(1, n + 1), k)\n\n ans = 0\n\n for e in a:\n if sum(e) != s:\n continue\n ans += 1\n\n print(ans) ", "neg": "import itertools\n\nwhile True:\n n, k, s = map(int, input().split())\n if n + k + s == 0:\n break\n\n a = itertools.combinations(range(n + 1), k)\n\n ans = 0\n\n for e in a:\n if sum(e) != s:\n continue\n ans += 1\n\n print(ans) ", "jacc_sim": 1.0, "nl": "Problem A: Equal Sum Sets\n\nLet's consider sets of positive integers less than or equal to \"n\". All elements of a set are different, and the order of elements doesn't matter. Given the number of set elements \"k\" and their sum \"s\", sets satisfying the conditions are limited. For example, when \"n\" = 9, \"k\" = 3, and \"s\" = 23, {6, 8, 9} is the only such set. There may be more than one such set. You need to write a program that calculates the number of sets that satisfy the given conditions.\n\nInput:\nThe input consists of multiple datasets, each containing three integers \"n\", \"k\", and \"s\" in one line, separated by a space. The input ends with a line containing three zeros.\n\nOutput:\nFor each dataset, output a single integer representing the number of sets that satisfy the conditions.\n\nSample Input:\n9 3 23\n9 3 22\n10 3 28\n16 10 107\n20 8 102\n20 10 105\n20 10 155\n3 4 3\n4 2 11\n0 0 0\n\nOutput for the Sample Input:\n1\n2\n0\n20\n1542\n5448\n1\n0\n0", "before_after_length": [98, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00935", "p_user": "u546285759", "n_user": "u546285759", "pos": "n = int(input())\nlength = int(n / 19) + 1\nif n > 19 and n % 19 == 0:\n length -= 1\nd = []\nfor i in range(length):\n d += list(map(int, input().split()))\nstart, end = 1, 10\nl = []\nflag = False\nfor j in range(1, len(d)+1):\n for i in range(0, len(d)):\n tmp = ''.join(map(str, d[i:i+j]))\n if len(tmp) > 1 and tmp[0] == '0':\n pass\n elif len(tmp) == j:\n l.append(int(tmp))\n l = sorted(set(l))\n if start == 1:\n for k in range(0, 10):\n if k not in l:\n print(k)\n flag = True\n break\n else:\n for k in range(start, end):\n if k not in l:\n print(k)\n flag = True\n break\n if flag:\n break\n start, end = start*10, end*10\n l = []", "neg": "n = int(input())\nlength = int(n / 19) + 1 if n > 19 and n % 19 == 0 else int(n / 19)\nd = []\nfor i in range(length):\n d += list(map(int, input().split()))\n\nstart, end = 1, 10\nl = []\nflag = False\nfor j in range(1, len(d)+1):\n for i in range(0, len(d)):\n tmp = ''.join(map(str, d[i:i+j]))\n if len(tmp) > 1 and tmp[0] == '0':\n pass\n elif len(tmp) == j:\n l.append(int(tmp))\n l = sorted(set(l))\n if start == 1:\n for k in range(0, 10):\n if k not in l:\n print(k)\n flag = True\n break\n else:\n for k in range(start, end):\n if k not in l:\n print(k)\n flag = True\n break\n if flag:\n break\n start, end = start*10, end*10\n l = []", "jacc_sim": 0.9814814814814815, "nl": "Problem A: Decimal Sequences\n\nHanako believes that all non-negative integers appear in the infinite digit sequence of the decimal representation of \u03c0 = 3.14159265..., the ratio of a circle's circumference to its diameter. She counts non-negative integers whose decimal representations appear as subsequences in a given sequence of digits.\n\nWrite a program that, given a finite sequence of digits, outputs the smallest non-negative integer not appearing in the sequence.\n\nInput:\nThe input consists of a single test case.\nn\nd1 d2 ... dn\nn is a positive integer indicating the number of digits. Each dk (k = 1, ..., n) is a digit. There is a space or a newline between dk and dk+1 (k = 1, ..., n - 1).\nYou can assume that 1 \u2264 n \u2264 1000.\n\nOutput:\nPrint the smallest non-negative integer not appearing in the sequence.\n\nSample Input 1:\n3\n3 0 1\nSample Output 1:\n2\n\nSample Input 2:\n11\n9 8 7 6 5 4 3 2 1 1 0\nSample Output 2:\n12\n\nSample Input 3:\n10\n9 0 8 7 6 5 4 3 2 1\nSample Output 3:\n10\n\nSample Input 4:\n100\n3 6 7 5 3 5 6 2 9 1 2 7 0 9 3 6 0 6 2\n6 1 8 7 9 2 0 2 3 7 5 9 2 2 8 9 7 3 6\n1 2 9 3 1 9 4 7 8 4 5 0 3 6 1 0 6 3 2\n0 6 1 5 5 4 7 6 5 6 9 3 7 4 5 2 5 4 7\n4 4 3 0 7 8 6 8 8 4 3 1 4 9 2 0 6 8 9\n2 6 6 4 9\nSample Output 4:\n11\n\nSample Input 5:\n100\n7 2 7 5 4 7 4 4 5 8 1 5 7 7 0 5 6 2 0\n4 3 4 1 1 0 6 1 6 6 2 1 7 9 2 4 6 9 3\n6 2 8 0 5 9 7 6 3 1 4 9 1 9 1 2 6 4 2\n9 7 8 3 9 5 5 2 3 3 8 4 0 6 8 2 5 5 0\n6 7 1 8 5 1 4 8 1 3 7 3 3 5 3 0 6 0 6\n5 3 2 2 2\nSample Output 5:\n86\n\nSample Input 6:\n1\n3\nSample Output 6:\n0", "before_after_length": [279, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00948", "p_user": "u509278866", "n_user": "u509278866", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 998244353\ndd = [(0,-1),(1,0),(0,1),(-1,0)]\nddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,q = LI()\n qa = sorted([LI() for _ in range(q)])\n u = [0] * (n+2)\n d = [0] * (n+2)\n\n for x,i in qa:\n u[i+1] = u[i] + 1\n d[i] = d[i+1] + 1\n rr = []\n for i in range(1,n+1):\n rr.append(u[i]+d[i]+1)\n\n\n return ' '.join(map(str,rr))\n\n\nprint(main())\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\neps = 1.0 / 10**10\nmod = 998244353\ndd = [(0,-1),(1,0),(0,1),(-1,0)]\nddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\ndef pf(s): return print(s, flush=True)\n\n\ndef main():\n n,q = LI()\n qa = sorted([LI() for _ in range(q)])\n u = [0] * (n+2)\n d = [0] * (n+2)\n\n for x,i in qa:\n u[i+1] = u[i] + 1\n d[i] = d[i+1] + 1\n rr = []\n for i in range(1,n+1):\n rr.append(u[i]+d[i]+1)\n\n\n return '\\n'.join(map(str,rr))\n\n\nprint(main())\n\n\n", "jacc_sim": 0.9875, "nl": "The Impractically Complicated Products Corporation's factory has manufacturing lines, storage rooms, and conveyor lanes. Robot arms are placed between adjacent lanes to transfer goods, allowing mixing of goods from different manufacturing lines to the storage rooms. Given the number of conveyor lanes and positions of robot arms, the task is to find the number of manufacturing lines from which goods can be transferred to each storage room.\n\nInput:\n- The input consists of a single test case with the following format:\n - n m\n - x1 y1\n - ...\n - xm ym\n- n (2 \u2264 n \u2264 200000) is the number of conveyor lanes, numbered from 1 to n.\n- m (1 \u2264 m < 100000) is the number of robot arms.\n- The following m lines indicate the positions of the robot arms by two integers xi (0 < xi < 100000) and yi (1 \u2264 yi < n).\n\nOutput:\n- Output n integers separated by a space in one line. The ith integer is the number of manufacturing lines from which the storage room connected to the conveyor lane i can accept goods.", "before_after_length": [436, 437], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00991", "p_user": "u186082958", "n_user": "u186082958", "pos": "def func (x):\n\tif x:\n\t\treturn int(x)*func(x-1)\n\telse:\n\t\treturn (1)\ndef comb (x,y):\n\treturn func(x)//func(x-y)//func(y)\n\nimport sys\nsys.setrecursionlimit(10000)\nw,h,ax,ay,bx,by=map(int,input().split())\ndx=min(w-abs(ax-bx),abs(ax-bx))\ndy=min(h-abs(ay-by),abs(ay-by))\nans=1\nif dx*2==w:ans*=2\nif dy*2==h:ans*=2\nans*=comb(dx+dy,dx)\nprint(ans%100000007)", "neg": "def func (x):\n\tif x:\n\t\treturn int(x)*func(x-1)\n\telse:\n\t\treturn (1)\ndef comb (x,y):\n\treturn func(x)//func(x-y)//func(y)\n\nh,w,ax,ay,bx,by=map(int,input().split())\ndx=min(w-abs(ax-bx),abs(ax-bx))\ndy=min(h-abs(ay-by),abs(ay-by))\nans=1\nif dx*2==w:ans*=2\nif dy*2==h:ans*=2\nans*=comb(dx+dy,dx)\nprint(ans%100000007)", "jacc_sim": 0.9047619047619048, "nl": "Problem B: Grid\n\nGiven two coordinates (a1, a2) and (b1, b2) on a 2D grid of size r \u00d7 c, find the number of shortest paths from the first coordinate to the second. Moving from one square (e,f) to (e+1,f), (e-1,f), (e,f+1), or (e,f-1) has a cost of 1. Additionally, moving between (e,c-1) and (e,0), or between (r-1,f) and (0,f) also has a cost of 1.\n\nInput:\nThe input is given in the following format:\nr c a1 a2 b1 b2\nThe input satisfies the following constraints:\n1 \u2264 r, c \u2264 1,000\n0 \u2264 a1, b1 < r\n0 \u2264 a2, b2 < c\n\nOutput:\nOutput the value modulo 100,000,007.\n\nSample Input 1:\n4 4 0 0 3 3\n\nSample Output 1:\n2\n\nSample Input 2:\n4 4 0 0 1 1\n\nSample Output 2:\n2\n\nSample Input 3:\n2 3 0 0 1 2\n\nSample Output 3:\n4\n\nSample Input 4:\n500 500 0 0 200 200\n\nSample Output 4:\n34807775", "before_after_length": [186, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00991", "p_user": "u186082958", "n_user": "u186082958", "pos": "from math import factorial\ndef comb (x,y):\n\treturn factorial(x)//factorial(x-y)//factorial(y)\n\nw,h,ax,ay,bx,by=map(int,input().split())\ndx=abs(ax-bx)\ndx=min(dx,w-dx)\ndy=abs(ay-by)\ndy=min(dy,h-dy)\nans=1\nif dx*2==w:ans*=2\nif dy*2==h:ans*=2\nans*=comb(dx+dy,dx)\nprint(ans%100000007)", "neg": "import math\ndef comb (x,y):\n\treturn factorial(x)//factorial(x-y)//factorial(y)\n\nw,h,ax,ay,bx,by=map(int,input().split())\ndx=min(w-abs(ax-bx),abs(ax-bx))\ndy=min(h-abs(ay-by),abs(ay-by))\nans=1\nif dx*2==w:ans*=2\nif dy*2==h:ans*=2\nans*=comb(dx+dy,dx)\nprint(ans%100000007)", "jacc_sim": 0.975, "nl": "Problem B: Grid\n\nGiven two coordinates (a1, a2) and (b1, b2) on a 2D grid of size r \u00d7 c, find the number of shortest paths from the first coordinate to the second. Moving from one square (e,f) to (e+1,f), (e-1,f), (e,f+1), or (e,f-1) has a cost of 1. Additionally, moving between (e,c-1) and (e,0), or between (r-1,f) and (0,f) also has a cost of 1.\n\nInput:\nThe input is given in the following format:\nr c a1 a2 b1 b2\nThe input satisfies the following constraints:\n1 \u2264 r, c \u2264 1,000\n0 \u2264 a1, b1 < r\n0 \u2264 a2, b2 < c\n\nOutput:\nOutput the value modulo 100,000,007.\n\nSample Input 1:\n4 4 0 0 3 3\n\nSample Output 1:\n2\n\nSample Input 2:\n4 4 0 0 1 1\n\nSample Output 2:\n2\n\nSample Input 3:\n2 3 0 0 1 2\n\nSample Output 3:\n4\n\nSample Input 4:\n500 500 0 0 200 200\n\nSample Output 4:\n34807775", "before_after_length": [148, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00991", "p_user": "u186082958", "n_user": "u186082958", "pos": "from math import factorial\ndef comb (x,y):\n\treturn factorial(x)//factorial(x-y)//factorial(y)\n\nw,h,ax,ay,bx,by=map(int,input().split())\ndx=abs(ax-bx)\ndx=min(dx,w-dx)\ndy=abs(ay-by)\ndy=min(dy,h-dy)\nan=1\nif dx*2==w:an*=2\nif dy*2==h:an*=2\nan*=comb(dx+dy,dx)\nprint(an%int(1E8+7))", "neg": "from math import factorial\ndef comb (x,y):\n\treturn factorial(x)//factorial(x-y)//factorial(y)\n\nw,h,ax,ay,bx,by=map(int,input().split())\ndx=abs(ax-bx)\ndx=min(dx,w-dx)\ndy=abs(ay-by)\ndy=min(dy,h-dy)\nan=1\nif dx*2==w:an*=2\nif dy*2==h:an*=2\nan*=comb(dx+dy,dx)\nprint(an%int(1E9+7))", "jacc_sim": 0.9523809523809523, "nl": "Problem B: Grid\n\nGiven two coordinates (a1, a2) and (b1, b2) on a 2D grid of size r \u00d7 c, find the number of shortest paths from the first coordinate to the second. Moving from one square (e,f) to (e+1,f), (e-1,f), (e,f+1), or (e,f-1) has a cost of 1. Additionally, moving between (e,c-1) and (e,0), or between (r-1,f) and (0,f) also has a cost of 1.\n\nInput:\nThe input is given in the following format:\nr c a1 a2 b1 b2\nThe input satisfies the following constraints:\n1 \u2264 r, c \u2264 1,000\n0 \u2264 a1, b1 < r\n0 \u2264 a2, b2 < c\n\nOutput:\nOutput the value modulo 100,000,007.\n\nSample Input 1:\n4 4 0 0 3 3\n\nSample Output 1:\n2\n\nSample Input 2:\n4 4 0 0 1 1\n\nSample Output 2:\n2\n\nSample Input 3:\n2 3 0 0 1 2\n\nSample Output 3:\n4\n\nSample Input 4:\n500 500 0 0 200 200\n\nSample Output 4:\n34807775", "before_after_length": [152, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02439", "p_user": "u126478680", "n_user": "u126478680", "pos": "nums = list(map(int, input().split(' ')))\n\nmax = -float('inf')\nmin = float('inf')\nfor num in nums:\n if num > max: max = num\n if num < min: min = num\n\nprint(min, max)\n\n", "neg": "nums = list(map(int, input().split(' ')))\n\nmax = -float('inf')\nmin = flaot('inf')\nfor num in nums:\n if num > max: max = num\n if num < min: min = num\n\nprint(min, max)\n\n", "jacc_sim": 0.9615384615384616, "nl": "Min-Max: Given three integers a, b, and c, output the minimum and maximum values. Input format: three integers a, b, and c separated by spaces. Output format: print the minimum and maximum values separated by a space. Constraints: -1,000,000,000 \u2264 a, b, c \u2264 1,000,000,000. Example: Input: 4 5 3, Output: 3 5", "before_after_length": [66, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02439", "p_user": "u255317651", "n_user": "u255317651", "pos": "a, b, c = list(map(int, input().split()))\nprint('{} {}'.format(min([a,b,c]), max([a,b,c])))\n\n", "neg": "a, b, c = list(map(int, input().split()))\nprint('{} {}'.format(min([a,b,c], max([a,b,c])))\n\n", "jacc_sim": 1.0, "nl": "Min-Max: Given three integers a, b, and c, output the minimum and maximum values. Input format: three integers a, b, and c separated by spaces. Output format: print the minimum and maximum values separated by a space. Constraints: -1,000,000,000 \u2264 a, b, c \u2264 1,000,000,000. Example: Input: 4 5 3, Output: 3 5", "before_after_length": [45, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02442", "p_user": "u126478680", "n_user": "u126478680", "pos": "n = int(input())\na = list(map(int, input().split(' ')))\nm = int(input())\nb = list(map(int, input().split(' ')))\n\nrst = None\n\nloop_num = n if n <= m else m\nfor i in range(loop_num):\n if a[i] < b[i]:\n rst = 1\n elif a[i] > b[i]:\n rst = 0\n if rst != None: break\n\nif rst == None:\n if len(a) < len(b):\n rst = 1\n else:\n rst = 0\n\nprint(rst)\n", "neg": "n = int(input())\na = list(map(int, input().split(' ')))\nm = int(input())\nb = list(map(int, input().split(' ')))\n\nloop_num = n if n <= m else m\nfor i in range(loop_num):\n if a[i] < b[i]:\n print(1)\n break\n elif a[i] > b[i]:\n print(0)\n break\n\nif len(a) < len(b):\n print(1)\nelse:\n print(0)\n", "jacc_sim": 0.9166666666666666, "nl": "Title: Lexicographical Comparison\n\nCompare two given sequences A = {a0, a1, ..., an-1} and B = {b0, b1, ..., bm-1} lexicographically.\n\nInput:\nThe input is given in the following format:\nn\na0 a1, ..., an-1\nm\nb0 b1, ..., bm-1\nThe number of elements in A and its elements ai are given in the first and second lines respectively. The number of elements in B and its elements bi are given in the third and fourth lines respectively. All input are given in integers.\n\nOutput:\nPrint 1 if B is greater than A, otherwise 0.\n\nConstraints:\n- 1 \u2264 n, m \u2264 1,000\n- 0 \u2264 ai, bi \u2264 1,000\n\nSample Input 1:\n3\n1 2 3\n2\n2 4\n\nSample Output 1:\n1\n\nSample Input 2:\n4\n5 4 7 0\n5\n1 2 3 4 5\n\nSample Output 2:\n0\n\nSample Input 3:\n3\n1 1 2\n4\n1 1 2 2\n\nSample Output 3:\n1", "before_after_length": [153, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02442", "p_user": "u255317651", "n_user": "u255317651", "pos": "n = int(input())\na = list(map(int, input().split()))\nm = int(input())\nb = list(map(int, input().split()))\n\nla = len(a)\nlb = len(b)\nl = min(la, lb)\n\nfor i in range(l):\n if a[i] > b[i]:\n print(0)\n break\n elif a[i] < b[i]:\n print(1)\n break\nelse:\n if la >= lb:\n print(0)\n else:\n print(1)\n", "neg": "n = int(input())\na = list(map(int, input().split()))\nm = int(input())\nb = list(map(int, input().split()))\n\nla = len(a)\nlb = len(b)\nl = min(la, lb)\n\nfor i in range(l):\n if a[i] > b[i]:\n print(0)\n break\n elif a[i] < b[i]:\n print(1)\n break\nelse:\n if la < lb:\n print(0)\n else:\n print(1)\n", "jacc_sim": 1.0, "nl": "Title: Lexicographical Comparison\n\nCompare two given sequences A = {a0, a1, ..., an-1} and B = {b0, b1, ..., bm-1} lexicographically.\n\nInput:\nThe input is given in the following format:\nn\na0 a1, ..., an-1\nm\nb0 b1, ..., bm-1\nThe number of elements in A and its elements ai are given in the first and second lines respectively. The number of elements in B and its elements bi are given in the third and fourth lines respectively. All input are given in integers.\n\nOutput:\nPrint 1 if B is greater than A, otherwise 0.\n\nConstraints:\n- 1 \u2264 n, m \u2264 1,000\n- 0 \u2264 ai, bi \u2264 1,000\n\nSample Input 1:\n3\n1 2 3\n2\n2 4\n\nSample Output 1:\n1\n\nSample Input 2:\n4\n5 4 7 0\n5\n1 2 3 4 5\n\nSample Output 2:\n0\n\nSample Input 3:\n3\n1 1 2\n4\n1 1 2 2\n\nSample Output 3:\n1", "before_after_length": [143, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02451", "p_user": "u126478680", "n_user": "u126478680", "pos": "n = int(input())\na = list(map(int, input().split(' ')))\n\ndef binary_search(val):\n left, right = 0, n-1\n while right - left >= 0:\n mid = int((right+left)/2)\n if a[mid] == val: return 1\n if a[mid] < val:\n left = mid+1\n elif val < a[mid]:\n right = mid-1\n return 0\n\nq = int(input())\nfor i in range(q):\n k = int(input())\n print(binary_search(k))\n\n", "neg": "n = int(input())\na = list(map(int, input().split(' ')))\n\ndef binary_search(val):\n left, right = 0, n-1\n while right - left >= 1:\n mid = (right+left)//2\n if a[mid] == val: return 1\n if a[mid] < val:\n left = mid\n elif val < a[mid]:\n right = mid\n return 0\n\nq = int(input())\nfor i in range(q):\n k = int(input())\n print(binary_search(k))\n\n", "jacc_sim": 1.0, "nl": "Binary Search:\nFor a given sorted sequence A = {a0, a1, ..., an-1}, find a specific value k given as a query.\n\nInput:\nThe input consists of:\n- The number of elements n and each element ai in the first and second lines respectively.\n- The number of queries q in the third line, followed by q integers ki as queries.\n\nOutput:\nFor each query, print 1 if any element in A is equivalent to k, and 0 otherwise.\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 q \u2264 200,000\n- 0 \u2264 a0 \u2264 a1 \u2264 ... \u2264 an-1 \u2264 1,000,000,000\n- 0 \u2264 ki \u2264 1,000,000,000\n\nSample Input 1:\n4\n1 2 2 4\n3\n2\n3\n5\n\nSample Output 1:\n1\n0\n0", "before_after_length": [147, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02451", "p_user": "u209989098", "n_user": "u209989098", "pos": "input()\n\nb = list(map(int,input().split()))\n\ndef nibu(low,high,i):\n\tmiddle = int((low+high)/2)\n\tif low == high:\n\t\tif i == b[low]:\n\t\t\treturn 1 \n\t\telse:\n\t\t\treturn 0\n\n\tif b[middle] < i:\n\t\tlow = middle + 1\n\t\treturn nibu(low,high,i)\n\telif b[middle] >= i:\n\t\thigh = middle\n\t\treturn nibu(low,high,i)\n\na = int(input())\nfor i in range(a):\n\tk = int(input())\n\tprint(nibu(0,len(b)-1,k))\n", "neg": "input()\n\nb = list(map(int,input().split()))\n\ndef nibu(low,high,i):\n\tmiddle = (low+high)//2\n\tif b[middle] <= i:\n\t\tlow = middle\n\telse:\n\t\thigh = middle\n\n\tif low == high:\n\t\tif i == b[low]:\n\t\t\treturn 1 \n\t\telse:\n\t\t\treturn 0\na = int(input())\nfor i in range(a):\n\tk = int(input())\n\tprint(nibu(0,len(b)-1,k))\n", "jacc_sim": 0.9487179487179487, "nl": "Binary Search:\nFor a given sorted sequence A = {a0, a1, ..., an-1}, find a specific value k given as a query.\n\nInput:\nThe input consists of:\n- The number of elements n and each element ai in the first and second lines respectively.\n- The number of queries q in the third line, followed by q integers ki as queries.\n\nOutput:\nFor each query, print 1 if any element in A is equivalent to k, and 0 otherwise.\n\nConstraints:\n- 1 \u2264 n \u2264 100,000\n- 1 \u2264 q \u2264 200,000\n- 0 \u2264 a0 \u2264 a1 \u2264 ... \u2264 an-1 \u2264 1,000,000,000\n- 0 \u2264 ki \u2264 1,000,000,000\n\nSample Input 1:\n4\n1 2 2 4\n3\n2\n3\n5\n\nSample Output 1:\n1\n0\n0", "before_after_length": [178, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02458", "p_user": "u847467233", "n_user": "u847467233", "pos": "# AOJ ITP2_7_D: Multi-Set\n# Python3 2018.6.24 bal4u\n\nfrom bisect import bisect_left, bisect_right, insort_left\ndict = {}\nkeytbl = []\ncnt = 0\nq = int(input())\nfor i in range(q):\n\ta = list(input().split())\n\tki = int(a[1])\n\tif a[0] == '0':\n\t\tif ki not in dict:\n\t\t\tdict[ki] = 1\n\t\t\tinsort_left(keytbl, ki)\n\t\telse: dict[ki] += 1\n\t\tcnt += 1\n\t\tprint(cnt)\n\telif a[0] == '1': print(dict[ki] if ki in dict else 0)\n\telif a[0] == '2':\n\t\tif ki in dict:\n\t\t\tcnt -= dict[ki]\n\t\t\tdict[ki] = 0\n\telse:\n\t\tL = bisect_left (keytbl, int(a[1]))\n\t\tR = bisect_right(keytbl, int(a[2]), L)\n\t\tfor j in range(L, R):\n\t\t\tfor k in range(dict[keytbl[j]]): print(keytbl[j])\n", "neg": "# AOJ ITP2_7_D: Multi-Set\n# Python3 2018.6.24 bal4u\n\nfrom bisect import bisect_left, bisect_right, insort_left\ndict = {}\nkeytbl = []\ncnt = 0\nq = int(input())\nfor i in range(q):\n\ta = list(input().split())\n\tki = int(a[1])\n\tif a[0] == '0':\n\t\tif ki not in dict:\n\t\t\tdict[ki] = 1\n\t\t\tinsort_left(keytbl, ki)\n\t\telse: dict[ki] += 1\n\t\tcnt += 1\n\t\tprint(cnt)\n\telif a[0] == '1': print(dict[ki] if ki in dict else 0)\n\telif a[0] == '2':\n\t\tif ki in dict:\n\t\t\tcnt -= dict[ki]\n\t\t\tdict[ki] = 0\n\telse:\n\t\tL = bisect_left (keytbl, int(a[1]))\n\t\tR = bisect_right(keytbl, int(a[2]), L)\n\t\tfor j in range(L, R):\n\t\t\tif dict[keytbl[j]] > 0: print(keytbl[j])\n", "jacc_sim": 0.9642857142857143, "nl": "Multi-Set\n\nFor a set S of integers, perform a sequence of the following operations. Note that multiple elements can have equivalent values in S.\n\n- insert(x): Insert x to S and report the number of elements in S after the operation.\n- find(x): Report the number of x in S.\n- delete(x): Delete all x from S.\n- dump(L, R): Print elements x in S such that L \u2264 x \u2264 R.\n\nInput\n\nThe input is given in the following format.\n\nq\nquery_1\nquery_2\n:\nquery_q\n\nEach query query_i is given by\n\n0 x\n\nor\n\n1 x\n\nor\n\n2 x\n\nor\n\n3 L R\n\nwhere the first digits 0, 1, 2, and 3 represent insert, find, delete, and dump operations respectively.\n\nOutput\n\nFor each insert operation, print the number of elements in S.\nFor each find operation, print the number of specified elements in S.\nFor each dump operation, print the corresponding elements in ascending order. Print an element in a line.\n\nConstraints\n\n- 1 \u2264 q \u2264 200,000\n- 0 \u2264 x \u2264 1,000,000,000\n- The total number of elements printed by dump operations does not exceed 1,000,000\n- The sum of numbers printed by find operations does not exceed 2,000,000\n\nSample Input 1\n\n10\n0 1\n0 1\n0 2\n0 3\n2 2\n1 1\n1 2\n1 3\n0 4\n3 1 4\n\nSample Output 1\n\n1\n2\n3\n4\n2\n0\n1\n4\n1\n1\n3\n4", "before_after_length": [301, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u247705495", "n_user": "u247705495", "pos": "N = int(input())\nn = N\nm = N ** 0.5\nL = []\ni = 3\n\nprint(str(N) + ': ', end = '')\n\nwhile n%2 == 0:\n n = n/2\n L.append(2)\n\nwhile i <= m:\n while n%i == 0:\n n = n/i\n L.append(i)\n i += 2\n\nif n not in L:\n L.append(int(n)) \n\nif 1 in L:\n L.remove(1)\n\nif len(L) == 0:\n L.append(N)\n\nprint(' '.join(map(str, L)))\n\n", "neg": "N = int(input())\nn = N\nm = N ** 0.5\nL = []\ni = 3\n\nprint(str(N) + ': ', end = '')\n\nwhile n%2 == 0:\n n = n/2\n L.append(2)\n\nwhile i <= m:\n while n%i == 0:\n n = n/i\n L.append(i)\n i += 2\n\nif n not in L:\n L.append(int(n)) \n\nif len(L) == 0:\n L.append(N)\n\nprint(' '.join(map(str, L)))\n\n", "jacc_sim": 0.9473684210526315, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [166, 151], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u814278309", "n_user": "u814278309", "pos": "a=int(input())\nn=a\ni=2\nfc=[]\nwhile i*i<=a:\n while a%i==0:\n a//=i\n fc.append(i)\n i+=1\nif a>1:\n fc.append(a)\nprint(str(n)+\": \"+\" \".join(str(b) for b in fc))\n", "neg": "a=int(input())\nn=a\ni=2\nfc=[]\nwhile i*i<=a:\n while a%i==0:\n a//=i\n fc.append(i)\n i+=1\nif a>1:\n fc.append(a)\nprint(str(n)+\": \"+\" \".join(str(b) for b in fc))\n", "jacc_sim": 1.0, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [92, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u711765449", "n_user": "u711765449", "pos": "# -*- coding:utf-8 -*-\n\nn = int(input())\nprint(str(n)+':',end='')\narray = []\ncount = 0\nwhile True:\n if n == 999993031:\n break\n for i in range(2,n+1):\n if n%i == 0 and i != n:\n array.append(i)\n n = int(n/i)\n break\n if i == n:\n count += 1\n break\n if count == 24:\n break\n\narray.append(n)\nfor i in range(len(array)):\n print(' ',array[i],sep = '',end='')\nprint('')", "neg": "# -*- coding:utf-8 -*-\n\nwhile True:\n n = int(input())\n print(n,':',sep='',end=' ')\n array = []\n count = 0\n while True:\n for i in range(2,n+1):\n if n%i == 0 and i != n:\n array.append(i)\n n = int(n/i)\n break\n if i == n-1:\n count += 1\n break\n if count == 15:\n break\n array.append(n)\n for i in range(len(array)):\n print(array[i],end=' ')\n print('')", "jacc_sim": 0.9111111111111111, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [167, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u831244171", "n_user": "u831244171", "pos": "n = int(input())\n\ndef function(n):\n a = []\n if n < 2:\n return a\n while n%2 ==0:\n a.append(2)\n n = n//2\n i = 3\n while i*i <= n:\n if n%i ==0:\n a.append(i)\n n = n//i\n else:\n i += 2\n if n > 1:\n a.append(n)\n return a\nprint(str(n)+\":\",*function(n))", "neg": "n = int(input())\n\ndef function(n):\n a = []\n if n < 2:\n return a\n while n%2 ==0:\n a.append(2)\n n = n//2\n i = 3\n while i*i <= n:\n if n%i ==0:\n a.append(i)\n else:\n i += 2\n if n > 1:\n a.append(n)\n return a\nprint(str(n)+\":\",*function(n))", "jacc_sim": 1.0, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [134, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u780342333", "n_user": "u780342333", "pos": "n = int(input())\norig_n = n\nres=[]\ni = 2\nhalf_n = n // 2\nroot_n = int(n ** (1/2))\nis_prime = True\nwhile i <= (root_n):\n if orig_n % i == 0:\n is_prime = False\n break\n i += 1\nif is_prime: res.append(orig_n)\n\nwhile i <= half_n and not(is_prime):\n if n ==1:\n break\n if n % i == 0:\n n = n // i\n res.append(i)\n i = 1\n i += 1\n\nprint(\"{0}: {1}\".format(orig_n, \" \".join(map(str, res))))", "neg": "n = int(input())\norig_n = n\nres=[]\ni = 2\nhalf_n = n // 2\nroot_n = int(n ** (1/2))\nis_prime = True\nwhile i <= (root_n):\n if orig_n % i == 0:\n is_prime = False\n break\n\nwhile i <= half_n and not(is_prime):\n print(n, i)\n if n ==1:\n break\n if n % i == 0:\n n = n // i\n res.append(i)\n i = 1\n i += 1\n\nprint(\"{0}: {1}\".format(orig_n, \" \".join(map(str, res))))", "jacc_sim": 1.0, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [184, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02467", "p_user": "u724963150", "n_user": "u724963150", "pos": "n=int(input())\ns=str(n)+\":\"\nb=True\nd=n\ni=2\nwhile b:\n if d%i==0:\n d/=i\n s+=' '+str(i)\n i-=1\n b=i 1:\n result.append(N)\nprint(str(M) + \": \" + \" \".join(map(str, result)))\n", "neg": "N = int(input())\nM = N\nresult = []\ni = 2\nwhile i * i <= N:\n while N % i == 0:\n N /= i\n result.append(i)\n i += 1\nif N > 1:\n result.append(N)\nprint(str(M) + \": \" + \" \".join(map(str, result)))\n", "jacc_sim": 1.0, "nl": "Title: Prime Factorization\n\nFactorize a given integer \"n\".\n\nInput:\nAn integer \"n\" is given in a line.\n\nOutput:\nPrint the given integer \"n\" and \":\". Then, print prime factors in ascending order. If \"n\" is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before each prime factor.\n\nConstraints:\n2 \u2264 n \u2264 10^9\n\nSample Input 1:\n12\n\nSample Output 1:\n12: 2 2 3\n\nSample Input 2:\n126\n\nSample Output 2:\n126: 2 3 3 7", "before_after_length": [90, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02468", "p_user": "u022407960", "n_user": "u022407960", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ninput:\n5 8\n\noutput:\n390625\n\"\"\"\n\nimport sys\n\n\ndef mod_pow(x, n, _mod):\n res = 1\n while n > 0:\n # check n is odd number\n if n % 2:\n res = res * x % _mod\n x = pow(x, 2) % _mod\n n //= 2\n return res\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n n1, n2 = map(int, _input[0].split())\n M = 1000000007\n # print(pow(n1, n2, M))\n print(mod_pow(n1, n2, M))", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\ninput:\n5 8\n\noutput:\n390625\n\"\"\"\n\nimport sys\n\n\ndef mod_pow(x, n, _mod):\n res = 1\n while n > 0:\n # check n is odd number\n if n % 2:\n res = res * x % _mod\n x = pow(x, 2) % _mod\n n //= 1\n return res\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n n1, n2 = map(int, _input[0].split())\n M = 1000000007\n # print(pow(n1, n2, M))\n print(mod_pow(n1, n2, M))", "jacc_sim": 1.0, "nl": "Title: Power\n\nFor given integers m and n, compute m^n (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nInput\nTwo integers m and n are given in a line.\n\nOutput\nPrint m^n (mod 1,000,000,007) in a line.\n\nConstraints\n- 1 \u2264 m \u2264 100\n- 1 \u2264 n \u2264 10^9\n\nSample Input 1\n2 3\n\nSample Output 1\n8\n\nSample Input 2\n5 8\n\nSample Output 2\n390625", "before_after_length": [201, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02468", "p_user": "u072053884", "n_user": "u072053884", "pos": "d = 1000000007\n\ndef pow_rem(x, n):\n if n == 0:\n return x ** n % d\n if n % 2 == 0:\n return pow_rem(x, n // 2) ** 2 % d\n else:\n return ((pow_rem(x , n // 2) ** 2) * x) % d\n\ndef solve():\n m, n = map(int, input().split())\n print(pow_rem(m, n))\n\nsolve()", "neg": "d = 1000000007\n\ndef pow_rem(x, n):\n if n == 0:\n return x ** n % d\n if n % 2 == 0:\n return pow_rem(x, n // 2) ** 2 % d\n else:\n return ((pow_rem(x , n // 2) ** 2) * x) % d\n\ndef solve():\n m, n = map(int, input().split())\n print(pow_rem(m, n)\n\nsolve()", "jacc_sim": 1.0, "nl": "Title: Power\n\nFor given integers m and n, compute m^n (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nInput\nTwo integers m and n are given in a line.\n\nOutput\nPrint m^n (mod 1,000,000,007) in a line.\n\nConstraints\n- 1 \u2264 m \u2264 100\n- 1 \u2264 n \u2264 10^9\n\nSample Input 1\n2 3\n\nSample Output 1\n8\n\nSample Input 2\n5 8\n\nSample Output 2\n390625", "before_after_length": [118, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02468", "p_user": "u725998488", "n_user": "u908651435", "pos": "m, n = map(int, input().split())\na = pow(m, n, 1000000007)\nprint(a) \n", "neg": "m,n=map(int,input().split())\nprint(pow,m,n,1000000007)\n", "jacc_sim": 0.9333333333333333, "nl": "Title: Power\n\nFor given integers m and n, compute m^n (mod 1,000,000,007). Here, A (mod M) is the remainder when A is divided by M.\n\nInput\nTwo integers m and n are given in a line.\n\nOutput\nPrint m^n (mod 1,000,000,007) in a line.\n\nConstraints\n- 1 \u2264 m \u2264 100\n- 1 \u2264 n \u2264 10^9\n\nSample Input 1\n2 3\n\nSample Output 1\n8\n\nSample Input 2\n5 8\n\nSample Output 2\n390625", "before_after_length": [31, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02469", "p_user": "u067972379", "n_user": "u067972379", "pos": "def gcd(a, b):\n if a < b:\n a, b = b, a\n while b:\n a, b = b, a%b\n return a\n\ndef lcm(a, b):\n\treturn a * b // gcd (a, b)\n\nn = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nfor a in A:\n ans = lcm(ans, a)\nprint(ans)\n", "neg": "def gcd(a, b):\n if a < b:\n a, b = b, a\n while b:\n a, b = b, a%b\n return a\n\ndef lcm(a, b):\n\treturn a * b // gcd (a, b)\n\nn = int(input())\nA = list(map(int, input().split()))\n\nans = 1\nfor a in A:\n ans = (ans, a)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\nn\na1 a2 ... an\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n- 2 \u2264 n \u2264 10\n- 1 \u2264 ai \u2264 1000\n- Product of given integers ai (i = 1, 2, ... n) does not exceed 2^31-1\n\nSample Input 1\n3\n3 4 6\n\nSample Output 1\n12\n\nSample Input 2\n4\n1 2 3 5\n\nSample Output 2\n30", "before_after_length": [116, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02469", "p_user": "u567380442", "n_user": "u567380442", "pos": "import math\ndef sieve(n):\n p = [1] * (n + 1)\n p[0] = p[1] = 0\n \n for i in range(math.ceil((n + 1) ** 0.5)):\n if p[i]:\n for j in range(2 * i, len(p), i):\n p[j] = 0\n return p\n\nfrom itertools import compress, count\ndef prime_factor(n):\n p = sieve(int(n ** 0.5))\n factor = []\n for pi in compress(count(0), p):\n while n % pi == 0:\n n //= pi\n factor.append(pi)\n\n if n != 1:\n factor.append(n)\n return factor\n\nfrom collections import Counter\nfrom sys import stdin\nreadline = stdin.readline\n\nn = int(readline())\nc =[Counter(prime_factor(ai)) for ai in map(int, readline().split())]\ns = set()\nfor ci in c:\n s.update(ci.keys())\n\nret = 1\nfor i in [i ** max(ci[i] for ci in c) for i in s]:\n ret *= i\nprint(ret)", "neg": "import math\ndef sieve(n):\n p = [1] * (n + 1)\n p[0] = p[1] = 0\n \n for i in range(math.ceil((n + 1) ** 0.5)):\n if p[i]:\n for j in range(2 * i, len(p), i):\n p[j] = 0\n return p\n\ndef prime_factor(n):\n p = sieve(int(n ** 0.5))\n factor = []\n for pi in compress(count(0), p):\n while n % pi == 0:\n n //= pi\n factor.append(pi)\n\n if n != 1:\n factor.append(n)\n return factor\n\nfrom collections import Counter\nfrom sys import stdin\nreadline = stdin.readline\n\nn = int(readline())\nc =[Counter(prime_factor(ai)) for ai in map(int, readline().split())]\ns = set()\nfor ci in c:\n s.update(ci.keys())\n\nret = 1\nfor i in [i ** max(ci[i] for ci in c) for i in s]:\n ret *= i\nprint(ret)", "jacc_sim": 0.9830508474576272, "nl": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\nn\na1 a2 ... an\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n- 2 \u2264 n \u2264 10\n- 1 \u2264 ai \u2264 1000\n- Product of given integers ai (i = 1, 2, ... n) does not exceed 2^31-1\n\nSample Input 1\n3\n3 4 6\n\nSample Output 1\n12\n\nSample Input 2\n4\n1 2 3 5\n\nSample Output 2\n30", "before_after_length": [298, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02469", "p_user": "u837811962", "n_user": "u837811962", "pos": "def GCD(x,y):\n r = x%y\n if r == 0:\n return y\n else:\n return GCD(y,r)\n\n\nn = int(input())\nlist1 = list(map(int,input().split()))\nresult = list1[0]\nfor i in list1[1:]:\n result = result*i/GCD(i,result)\n\nprint(int(result))", "neg": "def GCD(x,y):\n r = x%y\n if r == 0:\n return y\n else:\n return GCD(y,r)\n\n\nn = int(input())\nlist1 = list(map(int,input().split()))\nresult = list1[0]\nfor i in list1[1:]:\n result = result*i/GCD(i,result)\n\nprint(result)", "jacc_sim": 1.0, "nl": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\nn\na1 a2 ... an\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n- 2 \u2264 n \u2264 10\n- 1 \u2264 ai \u2264 1000\n- Product of given integers ai (i = 1, 2, ... n) does not exceed 2^31-1\n\nSample Input 1\n3\n3 4 6\n\nSample Output 1\n12\n\nSample Input 2\n4\n1 2 3 5\n\nSample Output 2\n30", "before_after_length": [105, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02469", "p_user": "u255317651", "n_user": "u078042885", "pos": "def gcd(a, b):\n while b:\n a, b = b, a%b\n return a\n \nn = int(input())\na = list(map(int, input().split()))\n\nlcm = 1\nfor i in a:\n lcm = lcm*i//gcd(lcm,i)\n\nprint(lcm)\n", "neg": "def gcd(a,b):\n while b:a,b=b,a%b\n return a\n\ndef lcm(a,b):\n return a/gcd(a,b)*b\n\ninput()\na=list(map(int,input().split()))\nb=1\nfor i in a:\n b=lcm(b,i)\nprint(b)", "jacc_sim": 0.9629629629629629, "nl": "Least Common Multiple\n\nFind the least common multiple (LCM) of given n integers.\n\nInput\nn\na1 a2 ... an\nn is given in the first line. Then, n integers are given in the second line.\n\nOutput\nPrint the least common multiple of the given integers in a line.\n\nConstraints\n- 2 \u2264 n \u2264 10\n- 1 \u2264 ai \u2264 1000\n- Product of given integers ai (i = 1, 2, ... n) does not exceed 2^31-1\n\nSample Input 1\n3\n3 4 6\n\nSample Output 1\n12\n\nSample Input 2\n4\n1 2 3 5\n\nSample Output 2\n30", "before_after_length": [88, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02470", "p_user": "u218655931", "n_user": "u218655931", "pos": "import sys\ndef euler(a):\n i = 2\n res = a\n #standard = a\n while i * i <= a:\n if a % i == 0:\n res = res - res//i\n while a % i == 0:\n a //= i\n\n i += 1\n if a != 1:\n res = res - res//a\n\n return res\n\n\nx = int(input())\n\n\nprint(euler(x))", "neg": "import sys\ndef euler(a):\n i = 2\n res = a\n #standard = a\n while i * i <= a:\n if a % i == 0:\n res = res - res//i\n while a % i == 0:\n a //= i\n\n i += 1\n \n res = res - res//a\n\n return res\n\n\nx = int(input())\n\n\nprint(euler(x))", "jacc_sim": 0.9666666666666667, "nl": "Euler's Phi Function\n\nFor a given integer \"n\", count the totatives of \"n\", which are the positive integers less than or equal to \"n\" that are relatively prime to \"n\".\n\nInput\nAn integer \"n\" (1 \u2264 n \u2264 1000000000).\n\nOutput\nThe number of totatives in a line.\n\nSample Input 1\n6\n\nSample Output 1\n2\n\nSample Input 2\n1000000\n\nSample Output 2\n400000", "before_after_length": [113, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02470", "p_user": "u150984829", "n_user": "u150984829", "pos": "a=[]\nn=int(input());s=n**.5\nwhile n%2==0 and n>3:a+=[2];n//=2\nd=3\nwhile s>d and n>d:\n if n%d>0:d+=2\n else:a+=[d];n//=d\na+=[n]\np=1\nfor f in set(a):\n p*=f**a.count(f)*(1-1/f)\nprint(int(p))\n", "neg": "p=1;a=[]\nn=int(input());s=n**.5\nwhile n%2==0 and n>3:a+=[2];n//=2\nd=3\nwhile s>d and n>d:\n if n%d==0:a+=[d];n//=d\n else:d+=2\na+=[n]\nfor f in set(a):\n p*=f**a.count(f)*(1-1/f)\nprint(int(p)\n", "jacc_sim": 1.0, "nl": "Euler's Phi Function\n\nFor a given integer \"n\", count the totatives of \"n\", which are the positive integers less than or equal to \"n\" that are relatively prime to \"n\".\n\nInput\nAn integer \"n\" (1 \u2264 n \u2264 1000000000).\n\nOutput\nThe number of totatives in a line.\n\nSample Input 1\n6\n\nSample Output 1\n2\n\nSample Input 2\n1000000\n\nSample Output 2\n400000", "before_after_length": [120, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02471", "p_user": "u022407960", "n_user": "u022407960", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n\"\"\"\ninput:\n3 8\n\noutput:\n3 -1\n\"\"\"\n\nimport sys\n\n\ndef ext_euclid(a, b):\n if b == 0:\n return 1, 0\n else:\n x, y = ext_euclid(b, a % b)\n x, y = y, (x - (a // b) * y)\n return x, y\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n n1, n2 = map(int, _input[0].split())\n print(*ext_euclid(n1, n2))", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\n\"\"\"\ninput:\n3 8\n\noutput:\n3 -1\n\"\"\"\n\nimport sys\n\n\ndef ext_euclid(a, b):\n if b == 0:\n return 1, 0, a\n else:\n x, y, q = ext_euclid(b, a % b)\n x, y = y, (x - (a // b) * y)\n return x, y\n\n\nif __name__ == '__main__':\n _input = sys.stdin.readlines()\n n1, n2 = map(int, _input[0].split())\n print(*ext_euclid(n1, n2))", "jacc_sim": 0.98, "nl": "Extended Euclid Algorithm\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nInput\nTwo positive integers a and b are given separated by a space in a line.\n\nOutput\nPrint two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x \u2264 y (secondarily).\n\nConstraints\n1 \u2264 a, b \u2264 10^9\n\nSample Input 1\n4 12\nSample Output 1\n1 0\n\nSample Input 2\n3 8\nSample Output 2\n3 -1", "before_after_length": [182, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02471", "p_user": "u072053884", "n_user": "u072053884", "pos": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef solve():\n a, b = map(int, input().split())\n if a == b or a % b == 0:\n print(0, 1)\n elif b % a == 0:\n print(1, 0)\n else:\n g = gcd(a, b)\n a //= g\n b //= g\n coe = [[1, 0], [0, 1]]\n while b != 1:\n quo = a // b\n coe_d1 = coe[1]\n coe_d2 = [coe[0][0] - coe[1][0] * quo, coe[0][1] - coe[1][1] * quo]\n coe = [coe_d1, coe_d2]\n a, b = b, a % b\n print(*coe[1])\n\nsolve()", "neg": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a\n\ndef solve():\n #a, b = map(int, input().split())\n a,b = 999999937, 123\n if a == b or a % b == 0:\n print(0, 1)\n elif b % a == 0:\n print(1, 0)\n else:\n g = gcd(a, b)\n a //= g\n b //= g\n coe = [[1, 0], [0, 1]]\n while b != 1:\n quo = a // b\n coe_d1 = coe[1]\n coe_d2 = [coe[0][0] - coe[1][0] * quo, coe[0][1] - coe[1][1] * quo]\n coe = [coe_d1, coe_d2]\n a, b = b, a % b\n print(*coe[1])\n\nsolve()", "jacc_sim": 0.9230769230769231, "nl": "Extended Euclid Algorithm\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nInput\nTwo positive integers a and b are given separated by a space in a line.\n\nOutput\nPrint two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x \u2264 y (secondarily).\n\nConstraints\n1 \u2264 a, b \u2264 10^9\n\nSample Input 1\n4 12\nSample Output 1\n1 0\n\nSample Input 2\n3 8\nSample Output 2\n3 -1", "before_after_length": [230, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02471", "p_user": "u150984829", "n_user": "u150984829", "pos": "r,s=map(int,input().split())\na=d=1;b=c=0\nwhile s:q=r//s;r,s,a,c,b,d=s,r%s,c,a-q*c,d,b-q*d\nprint(a,b)\n", "neg": "r,s=map(int,input().split())\na=d=1,b=c=0\nwhile r:\n q=r//s\n r,s,a,c,b,d=s,r%s,c,a-q*c,d,b-q*d\nprint(a,b)\n", "jacc_sim": 0.9615384615384616, "nl": "Extended Euclid Algorithm\n\nGiven positive integers a and b, find the integer solution (x, y) to ax + by = gcd(a, b), where gcd(a, b) is the greatest common divisor of a and b.\n\nInput\nTwo positive integers a and b are given separated by a space in a line.\n\nOutput\nPrint two integers x and y separated by a space. If there are several pairs of such x and y, print that pair for which |x| + |y| is the minimal (primarily) and x \u2264 y (secondarily).\n\nConstraints\n1 \u2264 a, b \u2264 10^9\n\nSample Input 1\n4 12\nSample Output 1\n1 0\n\nSample Input 2\n3 8\nSample Output 2\n3 -1", "before_after_length": [75, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02472", "p_user": "u536089081", "n_user": "u536089081", "pos": "print(sum([int(i) for i in input().split()]))\n", "neg": "sum([int(i) for i in input().split()])\n", "jacc_sim": 0.9230769230769231, "nl": "Title: Addition of Big Integers\n\nGiven two integers A and B, compute the sum, A + B.\n\nInput:\nTwo integers A and B separated by a space character are given in a line.\n\nOutput:\nPrint the sum in a line.\n\nConstraints:\n-1 x 10^100000 <= A, B <= 10^100000\n\nSample Input 1:\n5 8\n\nSample Output 1:\n13\n\nSample Input 2:\n100 25\n\nSample Output 2:\n125\n\nSample Input 3:\n-1 1\n\nSample Output 3:\n0\n\nSample Input 4:\n12 -3\n\nSample Output 4:\n9", "before_after_length": [17, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02472", "p_user": "u806257385", "n_user": "u567267870", "pos": "a,b=map(int, input().split())\nprint(a+b)\n", "neg": "a,b = map(int,input.split())\nprint(a + b)\n", "jacc_sim": 1.0, "nl": "Title: Addition of Big Integers\n\nGiven two integers A and B, compute the sum, A + B.\n\nInput:\nTwo integers A and B separated by a space character are given in a line.\n\nOutput:\nPrint the sum in a line.\n\nConstraints:\n-1 x 10^100000 <= A, B <= 10^100000\n\nSample Input 1:\n5 8\n\nSample Output 1:\n13\n\nSample Input 2:\n100 25\n\nSample Output 2:\n125\n\nSample Input 3:\n-1 1\n\nSample Output 3:\n0\n\nSample Input 4:\n12 -3\n\nSample Output 4:\n9", "before_after_length": [20, 20], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02473", "p_user": "u536089081", "n_user": "u536089081", "pos": "a, b = [int(i) for i in input().split()]\nprint(a-b)\n", "neg": "a, b = [int(i) for i in input().split()])\nprint(a-b)\n", "jacc_sim": 1.0, "nl": "Title: Difference of Big Integers\n\nGiven two integers A and B, compute the difference, A - B.\n\nInput:\nTwo integers A and B separated by a space character are given in a line.\n\nOutput:\nPrint the difference in a line.\n\nConstraints:\n-1 x 10^100000 <= A, B <= 10^100000\n\nSample Input 1:\n5 8\n\nSample Output 1:\n-3\n\nSample Input 2:\n100 25\n\nSample Output 2:\n75\n\nSample Input 3:\n-1 -1\n\nSample Output 3:\n0\n\nSample Input 4:\n12 -3\n\nSample Output 4:\n15", "before_after_length": [25, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u976887940", "n_user": "u976887940", "pos": "k=int(input())\nk+=1\no=''\na='ACL'\nif k==1:\n print('')\n exit()\nelse:\n for i in range(1,k):\n \to=o+a\nprint(o)", "neg": "k=int(input())\nk+=1\no=''\na='ALC'\nif k==1:\n print('')\n exit()\nelse:\n for i in range(1,k):\n \to=o+a\nprint(o)", "jacc_sim": 0.9130434782608695, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [62, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u614100538", "n_user": "u614100538", "pos": "K=input()\nr='ACL'\nfor i in range(1,int(K)):\n r='ACL'+ r \nprint(r)", "neg": "K=input()\nr='ACL'\nfor i in range(1,int(k)):\n r='ACL'+ r \nprint(r)", "jacc_sim": 0.9473684210526315, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [36, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u861274887", "n_user": "u861274887", "pos": "a = input()\nK = int(a)\n\nx = 'ACL'\n\nfor i in range(K):\n print(x, end = \"\")\n", "neg": "a = input()\nK = int(a)\n\nx = 'ACL'\n\nfor i in K:\n print(x, end = \"\")\n", "jacc_sim": 0.9444444444444444, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [38, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u526859732", "n_user": "u526859732", "pos": "k = int(input())\nans=[]\nfor i in range(k):\n ans.append(\"ACL\")\n\nprint(\"\".join(ans))\n", "neg": "k=input()\nans=[]\nfor i in range(int(k)):\n ans.append(\"ACL\")\n\nprint(\"\".joint(ans))\n", "jacc_sim": 0.9047619047619048, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [36, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u208947104", "n_user": "u208947104", "pos": "s=str(\"ACL\")\nn=int(input())\nprint(s*n)", "neg": "s=str(\"As=str(\"ACL\")\nn=int(input())\nprint(s*n)", "jacc_sim": 0.9230769230769231, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [20, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u369630760", "n_user": "u406145181", "pos": "a=\"\"\nfor i in range(int(input())):\n a+=\"ACL\"\nprint(a)", "neg": "a=int(input())\nfor i in range(a):\n print(\"ACL\")\n", "jacc_sim": 0.9333333333333333, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [27, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u947795390", "n_user": "u947795390", "pos": "k = int(input())\ntext = \"ACL\" * k\nprint(text)", "neg": "k = input()\ntext = \"ACL\"*k\nprint(k)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [19, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u973972117", "n_user": "u973972117", "pos": "K = int(input())\nAns = 'ACL'\nfor i in range(K-1):\n Ans += 'ACL'\nprint(Ans)", "neg": "K = int(input())\nAns = 'ACL'\nfor i in range(K-1):\n Ans += Ans\nprint(Ans)", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [37, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u965910858", "n_user": "u965910858", "pos": "num = int(input())\na = \"\"\nfor _ in range(num):\n a += \"ACL\"\nprint(a)", "neg": "num = input()\na = \"\"\nfor _ in range(num):\n a += \"ACL\"\nprint(a)", "jacc_sim": 0.9375, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u667469290", "n_user": "u667469290", "pos": "# -*- coding: utf-8 -*-\n\ndef solve():\n return 'ACL'*int(input())\n\nif __name__ == '__main__':\n print(solve())\n\n", "neg": "# -*- coding: utf-8 -*-\n\ndef solve():\n return 'ALC'*int(input())\n\nif __name__ == '__main__':\n print(solve())\n\n", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [47, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u601508807", "n_user": "u601508807", "pos": "k=int(input())\nlist=[str(\"ACL\")]*k\nans = str()\nfor i in range(k):\n ans = ans+str(list[i])\nprint(ans)", "neg": "k=int(input())\nlist=[str(\"ALK\")]*k\nans = str()\nfor i in range(k):\n ans = ans+str(list[i])\nprint(ans)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [45, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u829270229", "n_user": "u829270229", "pos": "# -*- coding: utf-8 -*-\nk = input()\n\nstr = \"\"\nfor i in range(int(k)):\n str += \"ACL\"\n \nprint(str)", "neg": "# -*- coding: utf-8 -*-\nk = input()\n\nstr = \"\"\nfor i in range(int(k)):\n str += \"ALC\"\n \nprint(str)", "jacc_sim": 0.9130434782608695, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [47, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u711238850", "n_user": "u711238850", "pos": "def main():\n k = int(input())\n\n for _ in range(k):\n print(\"ACL\",end='')\n print()\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n k = int(input)\n\n for _ in range(k):\n print(\"ACL\",end='')\n print()\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [49, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u867200256", "n_user": "u867200256", "pos": "# coding: utf-8\n# Your code here!\n# \u5e45\u512a\u5148\u63a2\u7d22\uff08\u884c\u304d\u304c\u3051\uff09\nimport collections\nimport sys\nimport copy\nimport re\nimport math\n\n\ndef I(): return int(sys.stdin.readline().rstrip())\n\n\ndef LI(): return list(map(int, sys.stdin.readline().rstrip().split()))\n\n\ndef S(): return sys.stdin.readline().rstrip()\n\n\ndef LS(): return list(sys.stdin.readline().rstrip().split())\n\n\ndef main():\n K = I()\n\n ans = \"\"\n\n for _ in range(K):\n ans+=\"ACL\"\n \n print(ans)\n\n \n\n\nif __name__ == '__main__':\n main()\n", "neg": "# coding: utf-8\n# Your code here!\n# \u5e45\u512a\u5148\u63a2\u7d22\uff08\u884c\u304d\u304c\u3051\uff09\nimport collections\nimport sys\nimport copy\nimport re\nimport math\n\n\ndef I(): return int(sys.stdin.readline().rstrip())\n\n\ndef LI(): return list(map(int, sys.stdin.readline().rstrip().split()))\n\n\ndef S(): return sys.stdin.readline().rstrip()\n\n\ndef LS(): return list(sys.stdin.readline().rstrip().split())\n\n\ndef main():\n K = I()\n\n ans = \"\"\n\n for i in range(K):\n ans+=\"ALC\"\n \n print(ans)\n\n \n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9344262295081968, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [209, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u191423660", "n_user": "u191423660", "pos": "def solve():\n K = int(input())\n\n for i in range(K):\n print(\"ACL\", end=\"\")\n\n\nif __name__ == \"__main__\":\n solve()\n", "neg": "def solve():\n K = int(input())\n\n for i in range(K):\n print(\"ALC\", end=\"\")\n\n\nif __name__ == \"__main__\":\n solve()\n", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [47, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u919235786", "n_user": "u919235786", "pos": "#a\nk=int(input())\nans=[]\nfor i in range(k):\n ans.append('ACL')\na=''.join(ans)\nprint(a)", "neg": "#a\nk=int(input())\nans=[]\nfor i in range(k):\n ans.append('acl')\na=''.join(ans)\nprint(a)", "jacc_sim": 0.9130434782608695, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [42, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u218757284", "n_user": "u218757284", "pos": "k = int(input())\nstr = ''\nfor _ in range(k):\n str += 'ACL'\nprint(str)", "neg": "k = input()\nstr = ''\nfor _ in range(k):\n str += 'ACL'\nprint(str)", "jacc_sim": 0.9375, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u922769680", "n_user": "u129798154", "pos": "n=int(input())\nw=\"ACL\"\nprint(w*n)", "neg": "w = 'ACL'\n\nn = input()\n\nprint(n * w)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [18, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u338034490", "n_user": "u338034490", "pos": "K = int(input())\n\na = \"\"\n\nfor i in range(K):\n a += \"ACL\"\n\nprint(\"{}\".format(a))", "neg": "K = int(input())\n\na = \"\"\n\nfor i in range(K):\n a += \"ALT\"\n\nprint(\"{}\".format(a))", "jacc_sim": 0.9047619047619048, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [37, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u095424182", "n_user": "u095424182", "pos": "if __name__==\"__main__\":\n k=int(input())\n print('ACL'*k)\n", "neg": "if __name__==\"__main__\":\n n=int(input())\n print('ACL'*k)", "jacc_sim": 0.9333333333333333, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [27, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u486094752", "n_user": "u486094752", "pos": "K = int(input())\nA = \"\"\nfor i in range(K):\n A += \"ACL\"\n \nprint(A)", "neg": "K = int(input())\nA = \"\"\nfor i in range(K):\n A += ACL\n \nprint(A)", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [32, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u123600620", "n_user": "u934119021", "pos": "input = int(input())\nans = \"ACL\"\nprint(ans*input)", "neg": "k = int(input())\nans = 'ACL' * k\nprint(k)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [19, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u785573018", "n_user": "u578798176", "pos": "k = int(input()); a = \"\"\nfor i in range(k):\n a += \"ACL\"\nprint(a)", "neg": "k=int(input())\na=\"\"\nfor i in range(k):\n a+=ACL\nprint(a)", "jacc_sim": 0.9411764705882353, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [29, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u404034840", "n_user": "u085530099", "pos": "n=int(input())\ns = \"\"\nfor i in range(n):\n s += \"ACL\"\nprint(s)", "neg": "n = input()\ns = ''\nfor i in range(n):\n s += 'ACL'\nprint(s)", "jacc_sim": 0.9375, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u598296382", "n_user": "u840649762", "pos": "k = int(input())\nans = \"ACL\"*k\nprint(ans)", "neg": "k = int(input())\n\nans = \"ACL\" * 5\n\nprint(ans)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [19, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u994147425", "n_user": "u879866069", "pos": "K = int(input())\ns = ''\nfor i in range(K):\n s += 'ACL'\nprint(s)", "neg": "K = int(input())\ns = \"\nfor i in range(K):\n s += \"ACL\"\nprint(s)", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [30, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u054559808", "n_user": "u807028974", "pos": "k = int(input())\ns = ''\nfor i in range(k):\n s += 'ACL'\nprint(s)", "neg": "k = int(input())\ns = ''\nfor i in range(K):\n s += 'ACL'\nprint(s)", "jacc_sim": 0.9411764705882353, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [30, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u289547799", "n_user": "u058592821", "pos": "k = int(input())\nans = \"\"\nfor i in range(k):\n ans = ans + \"ACL\"\nprint(ans)", "neg": "k = int(input())\nans = ''\nfor i in range(k):\n ans += 'ACL'\nprint(k)", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [32, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u358254559", "n_user": "u273746828", "pos": "k=int(input())\n\nfor i in range(k):\n print(\"ACL\",end=\"\")\nprint()", "neg": "k=input()\nfor i in range(k):\n print(\"ACL\",end=\"\")", "jacc_sim": 0.9375, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [27, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u038408819", "n_user": "u463594063", "pos": "k = int(input())\ns = 'ACL'\nprint(s * k)", "neg": "k = int(input())\nprint(\"ACL\" * k", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [19, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u994521204", "n_user": "u179411549", "pos": "k=int(input())\n\nprint(k*'ACL')", "neg": "k = int(input))\na = 'ACL'\nprint(a ** k)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [14, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u022488946", "n_user": "u021019433", "pos": "print('ACL' * int(input()))\t", "neg": "print('ACL' * int(input())\n ", "jacc_sim": 1.0, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [11, 11], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u201928947", "n_user": "u390177101", "pos": "K = int(input())\nS = 'ACL'\nprint(S*K)", "neg": "K = int(input())\nprint(K)\nprint(K*\"ACL\")", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [19, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02534", "p_user": "u642012866", "n_user": "u290886932", "pos": "N = int(input())\nprint(\"ACL\"*N)", "neg": "N = int(input())\nC = 'ACL'\nprint(ACL*N)", "jacc_sim": 0.9090909090909091, "nl": "You are given an integer K. Print the string obtained by repeating the string \"ACL\" K times and concatenating them. Constraints: 1 \u2264 K \u2264 5. Input is given as K. Output the string obtained by repeating \"ACL\" K times and concatenating them. Example Input: 3, Example Output: ACLACLACL", "before_after_length": [14, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u675317308", "n_user": "u675317308", "pos": "n,m=map(int,input().split())\ng=[[] for i in range(n)]\nfor i in range(m):\n\tu,v=map(int,input().split())\n\tu-=1\n\tv-=1\n\tg[u].append(v)\n\tg[v].append(u)\n\nvis=[False]*n\nstk=[]\n\ncnt=0\ntt=0\nfor i in range(n):\n\tif not vis[i]:\n\t\tcnt+=1\n\t\tstk.append(i)\n\twhile len(stk)!=0:\n\t\tu=stk[-1]\n\t\tstk.pop()\n\t\tif vis[u]:\n\t\t\tcontinue\n\t\tvis[u]=True\n\t\tfor v in g[u]:\n\t\t\ttt+=1\n\t\t\tif not vis[v]:\n\t\t\t\tstk.append(v)\nprint(cnt-1)\n", "neg": "n,m=map(int,input().split())\ng=[[],]*n\nfor i in range(m):\n\tu,v=map(int,input().split())\n\tu-=1\n\tv-=1\n\tg[u].append(v)\n\tg[v].append(u)\n\nvis=[False]*n\nstk=[]\n\ncnt=0\nfor i in range(n):\n\tif not vis[i]:\n\t\tcnt+=1\n\t\tvis[i]=True\n\t\tstk.append(i)\n\twhile len(stk)!=0:\n\t\tu=stk[-1]\n\t\tstk.pop()\n\t\tif vis[u]:\n\t\t\tcontinue\n\t\tfor v in g[u]:\n\t\t\tif not vis[v]:\n\t\t\t\tvis[v]=True\n\t\t\t\tstk.append(v)\nprint(cnt-1)\n", "jacc_sim": 0.975609756097561, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [226, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u994935583", "n_user": "u994935583", "pos": "from sys import setrecursionlimit, stdin\nimport numpy as np\n\nreadline = stdin.readline\nsetrecursionlimit(10 ** 6)\n\ndef find(parent, i):\n t = parent[i]\n if t < 0:\n return i\n t = find(parent, t)\n parent[i] = t\n return t\n \ndef unite(parent, i, j):\n i = find(parent, i)\n j = find(parent, j)\n if i == j:\n return\n parent[j] += parent[i]\n parent[i] = j\n\nN,M = map(int,readline().split())\nparent = - np.ones(N,int)\n\nfor _ in range(M):\n A, B = map(lambda x: int(x) - 1, readline().split())\n unite(parent, A, B)\n\nans = 0\nfor i in range(N):\n if parent[i] < 0:\n ans += 1\nprint(ans-1)", "neg": "from sys import setrecursionlimit, stdin\nimport numpy as np\n\nreadline = stdin.readline\nsetrecursionlimit(10 ** 6)\n\ndef find(parent, i):\n t = parent[i]\n if t < 0:\n return i\n t = find(parent, t)\n parent[i] = t\n return t\n \ndef unite(parent, i, j):\n i = find(parent, i)\n j = find(parent, j)\n if i == j:\n return\n parent[j] += parent[i]\n parent[i] = j\n\n\nN,M = map(int,readline().split())\nparent = - np.ones(N,int)\n\nfor _ in range(M):\n A, B = map(lambda x: int(x) - 1, readline().split())\n unite(parent, A, B)\nans = 0\nprint(parent)\nfor i in range(N):\n if parent[i] < 0:\n ans += 1\n else:\n print(parent[i])\nprint(ans-1)", "jacc_sim": 0.9803921568627451, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [247, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u295013286", "n_user": "u295013286", "pos": "n,m=map(int, input().split())\n\nroads=[]\n\nfor _ in range(m):\n a,b=map(int, input().split())\n roads.append([a,b])\n \ngroup=[i for i in range(n)]\n\ngroup2=[]\n\nwhile group2!=group:\n group2=list(group)\n for road in roads:\n if group[road[1]-1]>group[road[0]-1]:\n group[road[1]-1]=group[road[0]-1]\n else:\n group[road[0]-1]=group[road[1]-1]\n \ncounter=1\ngroup.sort()\n\nfor i in range(n-1):\n if group[i]!=group[i+1]:\n counter+=1\n\nprint(counter-1) \n \n\n", "neg": "n,m=map(int, input().split())\n\nroads=[]\n\nfor _ in range(m):\n a,b=map(int, input().split())\n roads.append([a,b].sort())\n \ngroup=[i for i in range(n)]\n\ngroup2=[]\n\nwhile group2!=group:\n group2=group\n for road in roads:\n group[road[1]-1]=group[road[0]-1]\n\ncounter=1\nfor i in range(n-1):\n if group[i]!=group[i+1]:\n counter+=1\n \nprint(counter-1) \n ", "jacc_sim": 0.9230769230769231, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [221, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u602740328", "n_user": "u602740328", "pos": "f = lambda x: x if p[x]<0 else f(p[x])\nN,M = map(int,input().split())\np = [-1]*N\nfor _ in range(M):\n A,B = map(lambda x:f(int(x)-1),input().split())\n if A==B: continue\n elif A self.r[y]:\n self.n[x] += self.n[y]\n self.n[y] = x\n else:\n self.n[y] += self.n[x]\n self.n[x] = y\n if self.r[x] == self.r[y]:\n self.r[y] += 1\n self.co -= 1\n\n def same(self, x, y):\n return self.find_root(x) == self.find_root(y)\n\n def size(self, x):\n return -self.n[self.find_root(x)]\n\n def set_count(self):\n return self.co\n\nn, m = map(int, input().split())\nuf = UnionFind(n)\nfor _ in range(m):\n a, b = map(int, input().split())\n uf.unite(a-1, b-1)\nprint(uf.set_count()-1)", "neg": "class UnionFind:\n def __init__(self, n):\n self.n = [-1]*n\n self.r = [0]*n\n self.co = n\n\n def find(self, x):\n if self.n[x] < 0:\n return x\n else:\n return self.n[x] = self.find(self.n[x])\n\n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.r[x] > self.r[y]:\n x, y = y, x\n self.n[y] += self.n[x]\n self.n[x] = y\n if self.r[x] == self.r[y]:\n self.r[y] += 1\n self.co -= 1\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def size(self, x):\n return -self.n[self.find(x)]\n\n def set_count(self):\n return self.co\n \nn, m = map(int, input().split())\nuf = UnionFind(n)\nfor _ in range(m):\n a, b = map(int, input().split())\n uf.unite(a-1, b-1)\nprint(uf.set_count()-1)", "jacc_sim": 0.9387755102040817, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [400, 359], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u196291054", "n_user": "u179376941", "pos": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\nn, m = map(int, input().split())\nuf = UnionFind(n)\nfor i in range(m):\n a, b = map(int, input().split())\n uf.union(a-1, b-1)\nprint(uf.group_count() - 1)", "neg": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n \n def group_count(self):\n return len(self.roots)\n\nn, m = map(int, input().split())\nun = UnionFind(n)\nfor _ in range(m):\n a, b = map(int, input().split())\n un.union(a, b)\nprint(un.group_count() - 1)\n", "jacc_sim": 0.9387755102040817, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [305, 302], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u694665829", "n_user": "u694665829", "pos": "from collections import deque\nn,m = map(int,input().split())\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = map(int,input().split())\n g[a-1].append(b-1)\n g[b-1].append(a-1)\n\ndist = [-1]*n\nq = deque([])\ncnt = 0\n\n#\u9023\u7d50\u6210\u5206\u306e\u30ab\u30a6\u30f3\u30c8\n\nfor i in range(n):\n if dist[i] != -1:\n continue\n dist[i] = 0\n q.append(i)\n while q:\n v = q.pop()\n s = g[v]\n for j in s:\n if dist[j] != -1:\n continue\n dist[j] = 0\n q.append(j)\n cnt += 1\n\nprint(cnt - 1)", "neg": "from collections import deque\nn,m = map(int,input().split())\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = map(int,input().split())\n g[a-1].append(b-1)\n g[b-1].append(a-1)\n\nchecked = [False]*n\nq = deque([])\ncnt = 0\n\n#\u9023\u7d50\u6210\u5206\u306e\u30ab\u30a6\u30f3\u30c8\n\nfor i in range(n):\n if checked[i]:\n continue\n checked[i] = True\n q.append(i)\n while q:\n v = q.pop()\n s = g[v]\n for j in s:\n if checked[j]:\n continue\n checked[j] = True\n q.append(j)\n cnt += 1\n\nprint(cnt - 1", "jacc_sim": 0.9122807017543859, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [237, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u787792408", "n_user": "u787792408", "pos": "n,m = map(int,input().split())\n\nans = 0\n\nclass UnionFind:\n def __init__(self,n):\n self.root = [i for i in range(n+1)]\n\n def Root_Find(self,x):\n if self.root[x] == x:\n return x\n else:\n self.root[x] = self.Root_Find(self.root[x])\n return self.root[x]\n\n def Unite(self,x,y):\n x = self.Root_Find(x)\n y = self.Root_Find(y)\n if x == y:\n return\n self.root[y] = x\n\ntree = UnionFind(n)\n\nfor i in range(m):\n a,b = map(int,input().split())\n tree.Unite(a,b)\n\nfor i in range(n+1):\n tree.Root_Find(i)\n\nans = len(list(set(tree.root))) - 2\nprint(ans)", "neg": "n,m = map(int,input().split())\n\nans = 0\n\nclass UnionFind:\n def __init__(self,n):\n self.root = [i for i in range(n+1)]\n\n def Root_Find(self,x):\n if self.root[x] == x:\n return x\n else:\n self.root[x] = self.Root_Find(self.root[x])\n return self.root[x]\n\n def Unite(self,x,y):\n x = self.Root_Find(x)\n y = self.Root_Find(y)\n if x == y:\n return\n self.root[y] = x\n\ntree = UnionFind(n)\n\nfor i in range(m):\n a,b = map(int,input().split())\n tree.Unite(a,b)\n \nans = len(list(set(tree.root))) - 1\nprint(ans)", "jacc_sim": 0.9777777777777777, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [255, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u234454594", "n_user": "u234454594", "pos": "from collections import deque\nn,m=map(int,input().split())\nroad=[[] for i in range(n)]\nflag=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n road[a-1].append(b-1)\n road[b-1].append(a-1)\ncount=0\nfor i in range(n):\n if flag[i]!=0:\n continue\n count+=1\n q=deque([i])\n while q:\n p=q.popleft()\n flag[p]=1\n for z in road[p]:\n if flag[z]==0:\n q.append(z)\nprint(count-1)", "neg": "from collections import deque\nn,m=map(int,input().split())\nroad=[[] for i i range(n)]\nflag=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n road[a-1].append(b-1)\n road[b-1].append(a-1)\ncount=0\nfor i in range(n):\n if flag[i]!=0:\n continue\n count+=1\n q=[k]\n while q:\n p=q.popleft()\n for z in road[p]:\n if flag[z]==0:\n q.append(z)\nprint(count-1)", "jacc_sim": 0.9767441860465116, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [184, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u602773379", "n_user": "u602773379", "pos": "#\u5165\u529b:N,M(int:\u6574\u6570)\ndef input2():\n\treturn map(int,input().split())\n\n#\u5165\u529b:[n1,n2,...nk](int:\u6574\u6570\u914d\u5217)\ndef input_array():\n\treturn list(map(int,input().split()))\n\nclass UnionFind():\n\t\"\"\"docstring for UnionFind\"\"\"\n\tdef __init__(self, n):\n\t\tself.parents = [-1]*n\n\n\tdef find(self,x):\n\t\tif self.parents[x] < 0: #\u81ea\u5206\u304c\u89aa\u3067\u3042\u308b\u6642\n\t\t\treturn x\n\t\telse: #\u81ea\u5206\u304c\u5b50\u4f9b\u3067\u3042\u308b\u6642\n\t\t\tself.parents[x]=self.find(self.parents[x])\n\t\t\treturn self.parents[x]\n\n\tdef union(self,x,y):\n\t\t# \u5404\u8981\u7d20\u306e\u89aa\u8981\u7d20\u3092\u8fd4\u3059\n\t\tx=self.find(x)\n\t\ty=self.find(y)\n\n\t\tif x==y:\n\t\t\treturn\n\t\tif self.parents[x] > self.parents[y]:\n\t\t\tx,y=y,x\n\n\t\tself.parents[x]+=self.parents[y]\n\t\tself.parents[y]=x\n\t\t# print(self.parents)\nn,m=input2()\nAB=[input_array() for _ in range(m)]\n\n\nuf = UnionFind(n)\nfor ab in AB:\n\ta=ab[0]\n\tb=ab[1]\n\tuf.union(a-1,b-1)\n\nans=0\nfor i in uf.parents:\n\tif i < 0:\n\t\tans+=1\nprint(ans-1)", "neg": "#\u5165\u529b:N,M(int:\u6574\u6570)\ndef input2():\n\treturn map(int,input().split())\n\n#\u5165\u529b:[n1,n2,...nk](int:\u6574\u6570\u914d\u5217)\ndef input_array():\n\treturn list(map(int,input().split()))\n \nclass UnionFind():\n\t\"\"\"docstring for UnionFind\"\"\"\n\tdef __init__(self, n):\n\t\tself.parents = [-1]*n\n\n\tdef find(self,x):\n\t\tif self.parents[x] < 0: #\u81ea\u5206\u304c\u89aa\u3067\u3042\u308b\u6642\n\t\t\treturn x\n\t\telse: #\u81ea\u5206\u304c\u5b50\u4f9b\u3067\u3042\u308b\u6642\n\t\t\tself.parents[x]=self.find(self.parents[x])\n\t\t\treturn self.parents[x]\n\n\tdef union(self,x,y):\n\t\t# \u5404\u8981\u7d20\u306e\u89aa\u8981\u7d20\u3092\u8fd4\u3059\n\t\tx=self.find(x)\n\t\ty=self.find(y)\n\n\t\tif x==y:\n\t\t\treturn\n\t\tif self.parents[x] > self.parents[y]:\n\t\t\tx,y=y,x\n\n\t\tself.parents[x]+=self.parents[y]\n\t\tself.parents[y]=x\n \nn,m=input2()\nAB=[input_array() for _ in range(m)]\nD=[[0]*n for _ in range(n)]\n\nuf = UnionFind(n)\nfor ab in AB:\n\ta=ab[0]\n\tb=ab[1]\n\tuf.union(a-1,b-1)\n\nans=0\n\nprint(ans-1)\n", "jacc_sim": 0.975609756097561, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [494, 479], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u845573105", "n_user": "u845573105", "pos": "class UnionFind:\n def __init__(self, n):\n self.g = [i for i in range(n)]\n self.n = n\n def whichclass(self, x):\n if self.g[x]==x:\n return x\n else:\n self.g[x] = self.whichclass(self.g[x])\n return self.g[x]\n def union(self, x, y):\n cx = self.whichclass(x)\n cy = self.whichclass(y)\n if cx==cy:\n return\n minc = min(cx, cy)\n maxc = max(cx, cy)\n self.g[maxc] = minc\n def __getitem__(self, x):\n return self.whichclass(x)\n \nN, M = map(int, input().split())\nUF = UnionFind(N)\nfor i in range(M):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n UF.union(a, b)\ncount = [0 for i in range(N)]\nfor i in range(N):\n count[UF[i]] = 1\nprint(sum(count)-1)\n ", "neg": "class UnionFind:\n def __init__(self, n):\n self.class = [i for i in range(n)]\n self.n = n\n def whichclass(self, x):\n if self.class[x]==x:\n return x\n else:\n self.class[x] = self.whichclass(self.class[x])\n return self.class[x]\n def union(self, x, y):\n cx = self.whichclass(x)\n cy = self.whichclass(y)\n if cx==cy:\n return\n minc = min(cx, cy)\n maxc = max(cx, cy)\n self.class[maxc] = minc\n def __getitem__(self, x):\n return self.whichclass(x)\n \nN, M = map(int, input().split())\nUF = UnionFind(N)\nfor i in range(M):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n UF.union(a, b)\ncount = [0 for i in range(N)]\nfor i in range(N):\n count[UF[i]] = 1\nprint(sum(count)-1)\n\n ", "jacc_sim": 0.9795918367346939, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [308, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u724687935", "n_user": "u724687935", "pos": "import sys\nfrom collections import deque\n\n\nN, M = map(int, input().split())\nedge = [[] for _ in range(N)]\nfor s in sys.stdin.readlines():\n a, b = map(lambda x: int(x) - 1, s.split())\n edge[a].append(b)\n edge[b].append(a)\n\npath = [-1] * N\ncnt = 0\nfor i in range(N):\n if path[i] < 0:\n cnt += 1\n q = deque()\n path[i] = i\n q.append(i)\n while q:\n p = q.popleft()\n for np in edge[p]:\n if path[np] < 0:\n path[np] = i\n q.append(np)\n\nprint(cnt - 1)\n", "neg": "import sys\nfrom collections import deque\n\n\nN, M = map(int, input().split())\nedge = [[] for _ in range(N)]\nfor s in sys.stdin.readlines():\n a, b = map(lambda x: int(x) - 1, s.split())\n edge[a].append(b)\n edge[b].append(a)\n\npath = [-1] * N\ncnt = 0\nfor i in range(N):\n if path[i] < 0:\n cnt += 1\n q = deque()\n path[i] = i\n q.append(i)\n while q:\n p = q.popleft()\n for np in edge[p]:\n if path[np] < 0:\n path[np] = i\n q.append(np)\n\nprint(cnt)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [203, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u837507786", "n_user": "u837507786", "pos": "from networkx import *\n\nn,m = map(int, input().split())\nG = Graph()\n\nfor i in range(m):\n a,b = map(int, input().split())\n G.add_edges_from([(a, b)])\n\nm3 = list(connected_components(G))\n\ncount = 0\n\nif len(max(connected_components(G), key=len)) == n:\n print(0)\n exit()\nelse:\n for i in m3:\n count += len(i)\n\nsub = n - count\n\nif sub != 0:\n print((len(m3)-1)+sub)\n\nelse:\n print(len(m3)+sub-1)\n\n\n", "neg": "from networkx import *\n\nn,m = map(int, input().split())\nG = Graph()\n\nfor i in range(m):\n a,b = map(int, input().split())\n G.add_edges_from([(a, b)])\n\nm3 = list(connected_components(G))\n\ncount = 0\n\nif len(max(connected_components(G), key=len)) == n:\n print(0)\n exit()\nelse:\n for i in m3:\n count += len(i)\nprint(n+1-count)", "jacc_sim": 0.9545454545454546, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [177, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u491296898", "n_user": "u491296898", "pos": "import sys\nsys.setrecursionlimit(10**9)\nn,m = list(map(int,input().split()))\n\nd = {}\nfor i in range(m):\n fr, to = list(map(int,input().split()))\n d[fr] = d.get(fr, []) + [to]\n d[to] = d.get(to, []) + [fr]\n \nvisited = [0 for i in range(n+1)]\n\ndef connect(node, i):\n visited[node] = i\n \n if node in d:\n for neig in d[node]:\n if visited[neig] == 0:\n connect(neig, i)\nans = 1\nfor key in range(1,n+1):\n if visited[key] == 0:\n connect(key, ans)\n ans += 1\n\nprint(max(visited)-1)\n\n", "neg": "import sys\nsys.setrecursionlimit(10**9)\nn,m = list(map(int,input().split()))\n\nd = {}\nfor i in range(m):\n fr, to = list(map(int,input().split()))\n d[fr] = d.get(fr, []) + [to]\n d[to] = d.get(to, []) + [fr]\n \nvisited = [0 for i in range(n+1)]\n\ndef connect(node, i):\n visited[node] = i\n \n if node in d:\n for neig in d[node]:\n if visited[neig] == 0:\n connect(neig, i)\nans = 1\nfor key in range(1,n+1):\n if visited[key] == 0:\n connect(key, ans)\n ans += 1\n\nprint(ans-1)\n\n", "jacc_sim": 0.9777777777777777, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [220, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u798136015", "n_user": "u798136015", "pos": "N, M = map(int, input().split())\nABs = [tuple(map(int, input().split())) for _ in range(M)]\n\npar = [i for i in range(N)]\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x != y:\n par[x] = y\n\nfor a, b in ABs:\n unite(a-1, b-1)\n\nfor x in range(N):\n find(x)\n\nprint(len(set(par))-1)\n", "neg": "N, M = map(int, input().split())\nABs = [tuple(map(int, input().split())) for _ in range(M)]\n\npar = [i for i in range(N)]\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef same(x, y):\n return find(x) == find(y)\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x != y:\n par[x] = y\n\nfor a, b in ABs:\n unite(a-1, b-1)\n\nprint(len(set(par) -1))\n", "jacc_sim": 0.9743589743589743, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [186, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u600195339", "n_user": "u600195339", "pos": "from collections import deque\nfrom collections import defaultdict\n\nn, m = map(int, input().split())\ng = defaultdict(list)\ns = set(list(range(1, n+1)))\nans = 0\n\nfor i in range(m):\n a, b = map(int, input().split())\n g[a].append(b)\n g[b].append(a)\n\nwhile s:\n root = s.pop()\n q = deque()\n q.append(root)\n done = set()\n done.add(root)\n\n while q:\n node = q.popleft()\n\n for adj in g[node]:\n if adj not in done:\n done.add(adj)\n q.append(adj)\n s.remove(adj)\n ans += 1\n\nprint(ans - 1)", "neg": "from collections import deque\nfrom collections import defaultdict\nn, m = map(int, input().split())\ng = defaultdict(list)\ns = set(list(range(1, n+1)))\nans = 0\nfor i in range(m):\n a, b = map(int, input().split())\n g[a].append(b)\nwhile s:\n \tans += 1\n root = s.pop()\n q = deque()\n q.append(root)\n done = set()\n done.add(root)\n while q:\n node = q.popleft()\n for adj in g[node]:\n if adj not in done:\n done.add(adj)\n q.append(adj)\n s.remove(adj)\nprint(ans - 1)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [203, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u536017058", "n_user": "u536017058", "pos": "class UnionFind:\n __slots__ = [\"_data_size\", \"_roots\"]\n \n def __init__(self, data_size: int) -> None:\n self._data_size = data_size\n self._roots = [-1] * data_size\n \n def __getitem__(self, x: int) -> int:\n while self._roots[x] >= 0:\n x = self._roots[x]\n return x\n \n def is_connected(self, x: int, y: int) -> bool:\n return self[x] == self[y]\n \n def unite(self, x: int, y: int) -> None:\n x, y = self[x], self[y]\n if x == y:\n return\n if self._roots[x] > self._roots[y]:\n x, y = y, x\n self._roots[x] += self._roots[y]\n self._roots[y] = x\n \n \nimport sys\n \nreadline = sys.stdin.readline\n \nN, Q = map(int, readline().split())\ntree = UnionFind(N)\nres = []\nans=0\nfor _ in range(Q):\n u, v = map(int, readline().split())\n tree.unite(u-1, v-1)\nfor u in range(1,N):\n if not tree.is_connected(u, 0):\n ans+=1\n tree.unite(u, 0)\nprint(ans)\n", "neg": "class UnionFind:\n __slots__ = [\"_data_size\", \"_roots\"]\n \n def __init__(self, data_size: int) -> None:\n self._data_size = data_size\n self._roots = [-1] * data_size\n \n def __getitem__(self, x: int) -> int:\n while self._roots[x] >= 0:\n x = self._roots[x]\n return x\n \n def is_connected(self, x: int, y: int) -> bool:\n return self[x] == self[y]\n \n def unite(self, x: int, y: int) -> None:\n x, y = self[x], self[y]\n if x == y:\n return\n if self._roots[x] > self._roots[y]:\n x, y = y, x\n self._roots[x] += self._roots[y]\n self._roots[y] = x\n \n \nimport sys\n \nreadline = sys.stdin.readline\n \nN, Q = map(int, readline().split())\ntree = UnionFind(N)\nres = []\nans=0\nfor _ in range(Q):\n u, v = map(int, readline().split())\n tree.unite(u-1, v-1)\nfor u in range(1,N):\n print(tree.is_connected(u, 0),u)\n if not tree.is_connected(u, 0):\n ans+=1\n tree.unite(u-1, 0)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [365, 383], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u724549242", "n_user": "u724549242", "pos": "class UnionFind():\n def __init__(self, n):\n self.parents = list(range(n))\n\n def find(self, x):\n if self.parents[x] == x:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n self.parents[y] = x\n \nn,m = map(int,input().split())\nuf = UnionFind(n)\nfor i in range(m):\n a,b=map(int,input().split())\n uf.union(a-1,b-1)\n\nsize = 0\nfor i in range(n):\n if uf.parents[i] == i:\n size += 1\nprint(size-1)", "neg": "class UnionFind():\n def __init__(self, n):\n self.parents = list(range(n))\n\n def find(self, x):\n if self.parents[x] == x:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n self.parents[y] = x\n \nn,m = map(int,input().split())\nuf = UnionFind(n)\nfor i in range(m):\n a,b=map(int,input().split())\n uf.union(a-1,b-1)\n\nsize = 0\nfor i in range(n):\n print(uf.parents[i])\n if uf.parents[i] == i:\n size += 1\nprint(size-1)", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [237, 247], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u306033313", "n_user": "u306033313", "pos": "class UnionFind:\n def __init__(self, n):\n self.r = [-1 for i in range(n)]\n \n def root(self, x):\n if self.r[x] < 0:\n return x\n self.r[x] = self.root(self.r[x])\n return self.r[x]\n \n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return False\n if self.r[x] < self.r[y]:\n temp = x\n x = y\n y = temp\n self.r[x] += self.r[y]\n self.r[y] = x\n return True\n \n def size(self, x):\n return -self.r[self.root(x)]\n\nn, m = map(int, input().split())\nUF = UnionFind(n)\nfor i in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n UF.unite(a, b)\n\nans = 0\nfor i in UF.r:\n if i < 0:\n ans += 1\n\nprint(ans-1)", "neg": "class UnionFind:\n def __init__(self, n):\n self.r = [-1 for i in range(n)]\n \n def root(self, x):\n if self.r[x] < 0:\n return x\n self.r[x] = self.root(self.r[x])\n return self.r[x]\n \n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return False\n if self.r[x] < self.r[y]:\n temp = x\n x = y\n y = temp\n self.r[x] += self.r[y]\n self.r[y] = x\n return True\n \n def size(self, x):\n return -self.r[self.root(x)]\n\nn, m = map(int, input().split())\nUF = UnionFind(n)\nfor i in range(m):\n a, b = map(lambda x: int(x)-1, input().split())\n UF.unite(a, b)\n\nans = 0\nfor i in UF.r:\n if i < 0:\n ans += 1\n\nprint(UF.r)\nprint(ans-1)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [313, 322], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u040298438", "n_user": "u798260206", "pos": "# Union Find\n# x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\n\n# x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x, y):\n x = find(x)\n y = find(y)\n\n if x == y:\n return False\n else:\n # size\u306e\u5927\u304d\u3044\u307b\u3046\u304cx\n if par[x] > par[y]:\n x, y = y, x\n par[x] += par[y]\n par[y] = x\n return True\n\n\n# x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u306e\u5224\u5b9a\ndef same(x, y):\n return find(x) == find(y)\n\n\n# x\u304c\u5c5e\u3059\u308b\u96c6\u5408\u306e\u500b\u6570\ndef size(x):\n return -par[find(x)]\n\n\nn, m = map(int, input().split())\n# \u521d\u671f\u5316\n# \u6839\u306a\u3089-size,\u5b50\u306a\u3089\u89aa\u306e\u9802\u70b9\npar = [-1] * n\n\nfor _ in range(m):\n a, b = map(int, input().split())\n unite(a - 1, b - 1)\nprint(len(list(filter(lambda x: x < 0, par))) - 1)", "neg": "#Union Find\n\n#x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n#x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x == y:\n return False\n else:\n #size\u306e\u5927\u304d\u3044\u307b\u3046\u304cx\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\n#x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u306e\u5224\u5b9a\ndef same(x,y):\n return find(x) == find(y)\n\n#x\u304c\u5c5e\u3059\u308b\u96c6\u5408\u306e\u500b\u6570\ndef size(x):\n return -par[find(x)]\n\n#\u521d\u671f\u5316\n#\u6839\u306a\u3089-size,\u5b50\u306a\u3089\u89aa\u306e\u9802\u70b9\n\nn,m = map(int,input().split())\npar = [-1]*n\nfor i in range(m):\n a,b = map(int,input().split())\n unite(a-1,b-1)\n \nans = 0\n\nfor i in range(n):\n if par[i] < 0:\n ans += 1 \nprint(par)\nprint(ans-1)", "jacc_sim": 0.9176470588235294, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [459, 475], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u177388368", "n_user": "u177388368", "pos": "n,m=list(map(int,input().split()))\n\npar=[i for i in range(n)]\n# ro=dict()\n#\n# for i in range(n):\n# ro[i]=1\n\ndef root(i):\n if par[i]==i:\n return i\n else:\n a=root(par[i])\n par[i]=a\n return a\n\ndef unite(x,y):\n rx=root(x)\n ry=root(y)\n if rx!=ry:\n par[rx]=ry\n # ro[ry]+=ro[rx]\n # ro[rx]=0\n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n unite(a-1,b-1)\n\nans=set()\n\nfor i in range(n):\n rt=root(i)\n ans.add(rt)\n\n# from collections import Counter as cnt\n#\n# bb=ro.values()\n# ans=dict(cnt(ro.values()))\n\nprint(len(ans)-1)", "neg": "n,m=list(map(int,input().split()))\n\npar=[i for i in range(n)]\nro=dict()\n\nfor i in range(n):\n ro[i]=1\ni\ndef root(i):\n if par[i]==i:\n return i\n else:\n a=root(par[i])\n par[i]=a\n return a\n\ndef unite(x,y):\n rx=root(x)\n ry=root(y)\n if rx!=ry:\n par[rx]=ry\n ro[ry]+=ro[rx]\n ro[rx]=0\n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n unite(a-1,b-1)\n\nfrom collections import Counter as cnt\n\nans=dict(cnt(ro.values()))\n\nprint(len(ans)-1)", "jacc_sim": 0.9074074074074074, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [275, 228], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u993808866", "n_user": "u993808866", "pos": "N, M = map(int, input().split())\nPajew = [i for i in range(N)]\nimport sys\nsys.setrecursionlimit(1000000)\n\ndef find(x, Pajew):\n if Pajew[x] == x:\n return x\n else:\n a = find(Pajew[x], Pajew)\n Pajew[x] =a\n return a\n\ndef unite(x, y):\n x = find(x, Pajew)\n y = find(y, Pajew)\n if x != y:\n Pajew[x] = y\n\nfor _ in range(M):\n a, b = map(int, input().split())\n unite(a-1, b-1)\n\ngrou = 0\nfor i in range(N):\n if i == Pajew[i]:\n grou +=1\n\n\nprint(grou-1)", "neg": "N, M = map(int, input().split())\nPajew = [i for i in range(n)]\nimport sys\nsys.setrecursionlimit(1000000)\n\ndef find(x, Pajew):\n if Pajew[x] == x:\n return x\n else:\n a = find(Pajew[x], Pajew)\n Pajew[x] =a\n return a\n\ndef unite(x, y):\n x = find(x, Pajew)\n y = find(y, Pajew)\n if x != y:\n Pajew[x] = y\n\nfor _ in range(M):\n a, b = map(int, input().split())\n unite(a-1, b-1)\n\ngrou = 0\nfor i in range(N):\n if i == Pajew[i]:\n grou +=1\n \n \nprint(grou-1)", "jacc_sim": 0.9761904761904762, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [228, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u395672550", "n_user": "u395672550", "pos": "class union_find():\n \n def __init__(self,n):\n self.n=n\n self.root=[-1]*(n+1)\n self.rank=[0]*(n+1)\n\n def find_root(self,x):\n if self.root[x]<0:\n return x\n else:\n self.root[x]=self.find_root(self.root[x])\n return self.root[x]\n\n def unite(self,x,y):\n x=self.find_root(x)\n y=self.find_root(y)\n \n\n if x==y:\n return \n elif self.rank[x]>self.rank[y]:\n self.root[x]+=self.root[y]\n self.root[y]=x\n else:\n self.root[y]+=self.root[x]\n self.root[x]=y\n\n if self.rank[x]==self.rank[y]:\n self.rank[y]+=1\n\n\nN,M = map(int,input().split())\ng = union_find(N)\ngroup = 0\nfor i in range(M):\n A,B= map(int,input().split())\n g.unite(A,B)\n\nfor j in g.root:\n if j < 0:\n group += 1\n\nprint(group - 2)\n ", "neg": "class union_find():\n \n def __init__(self,n):\n self.n=n\n self.root=[-1]*(n+1)\n self.rank=[0]*(n+1)\n\n def find_root(self,x):\n if self.root[x]<0:\n return x\n else:\n self.root[x]=self.find_root(self.root[x])\n return self.root[x]\n\n def unite(self,x,y):\n x=self.find_root(x)\n y=self.find_root(y)\n \n\n if x==y:\n return \n elif self.rank[x]>self.rank[y]:\n self.root[x]+=self.root[y]\n self.root[y]=x\n else:\n self.root[y]+=self.root[x]\n self.root[x]=y\n\n if self.rank[x]==self.rank[y]:\n self.rank[y]+=1\n\n\nN,M = map(int,input().split())\ng = union_find(N)\ngroup = 0\nfor i in range(M):\n A,B= map(int,input().split())\n g.unite(A,B)\n\nprint(g.root)\n\nfor j in g.root:\n if j < 0:\n group += 1\n\nprint(group - 2)\n ", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [353, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u344030307", "n_user": "u344030307", "pos": "def find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef same(x, y):\n return find(x) == find(y)\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n if par[x] > par[y]:\n x, y = y, x\n par[x] += par[y]\n par[y] = x\n\n\nN, M = map(int, input().split())\npar = [-1 for i in range(N)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n unite(a - 1, b - 1)\n\ncnt = -1\nnum = {0}\n\nfor i in par:\n if i <= -1:\n cnt += 1\n\nprint(cnt)", "neg": "def find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef same(x, y):\n return find(x) == find(y)\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n if par[x] > par[y]:\n x, y = y, x\n par[x] += par[y]\n par[y] = x\n\n\nN, M = map(int, input().split())\npar = [-1 for i in range(N)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n unite(a - 1, b - 1)\n\ncnt = -1\nnum = {0}\n\nfor i in par:\n if i > 0:\n cnt += 1\n\nprint(cnt)\n", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [241, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u501278784", "n_user": "u501278784", "pos": "import collections\nimport sys\nsys.setrecursionlimit(10**6)\ndef dfs(visited,v,adj):\n visited[v]=True \n for i in adj[v]:\n if not visited[i]:\n dfs(visited,i,adj) \nadj=collections.defaultdict(list)\nn,m=map(int,input().split()) \nvisited=[False]*n \nfor i in range(m):\n u,v=map(int,input().split()) \n adj[u-1].append(v-1) \n adj[v-1].append(u-1) \nc=0 \nfor i in range(n):\n if not visited[i]:\n dfs(visited,i,adj) \n c+=1 \nprint(c-1)", "neg": "import collections\nsys.setrecursionlimit(10**6)\ndef dfs(visited,v,adj):\n visited[v]=True \n for i in adj[v]:\n if not visited[i]:\n dfs(visited,i,adj) \nadj=collections.defaultdict(list)\nn,m=map(int,input().split()) \nvisited=[False]*n \nfor i in range(m):\n u,v=map(int,input().split()) \n adj[u-1].append(v-1) \n adj[v-1].append(u-1) \nc=0 \nfor i in range(n):\n if not visited[i]:\n dfs(visited,i,adj) \n c+=1 \nprint(c-1)", "jacc_sim": 1.0, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [189, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u668190572", "n_user": "u668190572", "pos": "import sys,io,os\nI = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n#I = input\n\nn,m = map(int, I().split())\np=[-1]*(n+1)\ns=[0]*(n+1)\nS=n-1\ndef t(a):\n\tb = a\n\twhile p[b] != -1:\n\t\tb = p[b]\n\twhile p[a] != -1:\n\t\tp[a],a = b,p[a]\n\treturn a\nfor _ in range(m):\n\ta,b=map(int, I().split())\n\ta,b = t(a), t(b)\n\tif a != b:\n\t\tS -= 1\n\t\tif s[a] > s[b]:\n\t\t\ta,b = b,a\n\t\tp[a] = b\n\t\ts[b] += s[a]\nprint(S)\n\n", "neg": "import sys,io,os\nI = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\nI = input\n\nn,m = map(int, I().split())\np=[-1]*(n+1)\ns=[0]*(n+1)\nS=n-1\ndef t(a):\n\twhile p[a] != -1:\n\t\ta = p[a]\n\treturn a\nfor _ in range(m):\n\ta,b=map(int, I().split())\n\ta,b = t(a), t(b)\n\tif a != b:\n\t\tS -= 1\n\t\tif s[a] > s[b]:\n\t\t\ta,b = b,a\n\t\tp[a] = b\n\t\ts[b] += s[a]\nprint(S)\n\n", "jacc_sim": 0.9791666666666666, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [241, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u626891113", "n_user": "u439063038", "pos": "import sys\nsys.setrecursionlimit(10**9)\nn, m = map(int, input().split())\n\nroot = [-1]*n\n\ndef find(n):\n if root[n] < 0:\n return n\n else:\n root[n] = find(root[n])\n return root[n]\n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n else:\n root[x] += root[y]\n root[y] = x\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n unite(a, b)\n\nans = -1\nfor i in root:\n if i < 0:\n ans += 1\n\nprint(ans)", "neg": "import sys\nsys.setrecursionlimit(10 ** 9)\n\nn, m = map(int, input().split())\nroot = [-1] * (110000)\ndef find(x):\n if root[x] < 0:\n return x\n else:\n root[x] = find(x)\n return root[x]\n \n\ndef unite(x, y):\n x = find(x)\n y = find(y)\n if x == y:\n return\n root[x] += root[y]\n root[y] = x\n \n\nfor _ in range(m):\n a, b = map(int, input().split())\n unite(a, b)\n\nans = 0\nfor i in range(1, n+1):\n if root[i] < 0:\n ans += 1\nprint(ans-1)\nprint(root)", "jacc_sim": 0.9545454545454546, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [210, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u168416324", "n_user": "u168416324", "pos": "n,m=map(int,input().split())\n\nglobal fri\nfri=[]\nglobal tab\ntab=[0]*n\ndef run(nn):\n #print(tab)\n global cnt\n if tab[nn]:\n return\n tab[nn]=1\n cnt+=1\n for i in fri[nn]:\n que.append(i)\nfor i in range(n):\n fri.append([])\nfor i in range(m):\n a,b=map(int,input().split())\n fri[a-1].append(b-1)\n fri[b-1].append(a-1)\ni=0\nmx=0\ncc=0\nwhile i self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n def size(self, x):\n return -self.parents[self.find(x)]\n def same(self, x, y):\n return self.find(x) == self.find(y)\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n def group_count(self):\n return len(self.roots())\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n \nN, M= map(int,input().split())\nUF=UnionFind(N)\nfor i in range(M):\n A, B=map(int,input().split())\n A=A-1\n B=B-1\n UF.union(A,B)\nprint(UF.group_count()-1)", "neg": "import numpy as np\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nN, M = map(int, input().split())\nuf = UnionFind(N)\nfor i in range(M):\n A, B = map(int, input().split())\n uf.union(A-1, B-1)\n\nprint(uf.group_count())", "jacc_sim": 0.9090909090909091, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [472, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u152417130", "n_user": "u152417130", "pos": "import sys\ninput = sys.stdin.readline\n\nclass UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n\n def find(self, a):\n acopy = a\n while a != self.parent[a]:\n a = self.parent[a]\n while acopy != a:\n self.parent[acopy], acopy = a, self.parent[acopy]\n return a\n\n def union(self, a, b):\n self.parent[self.find(b)] = self.find(a)\n\nn, m = map(int, input().split())\nUF = UnionFind(n)\nfor _ in range(m):\n a,b = map(int, input().split())\n UF.union(a-1,b-1)\no=set()\nfor i in range(n):\n o.add(UF.find(i))\nprint(len(o) - 1)", "neg": "import sys\ninput = sys.stdin.readline\n\nclass UnionFind:\n def __init__(self, n):\n self.parent = list(range(n))\n\n def find(self, a):\n acopy = a\n while a != self.parent[a]:\n a = self.parent[a]\n while acopy != a:\n self.parent[acopy], acopy = a, self.parent[acopy]\n return a\n\n def union(self, a, b):\n self.parent[self.find(b)] = self.find(a)\n\nn, m = map(int, input().split())\nUF = UnionFind(n)\nfor _ in range(m):\n a,b = map(int, input().split())\n UF.union(a-1,b-1)\no=set()\nfor i in range(n):\n o.add(UF.fins(i))\nprint(len(o) - 1)", "jacc_sim": 0.9791666666666666, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [237, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u551909378", "n_user": "u637289184", "pos": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nN, M = map(int, input().split())\ngroup = UnionFind(N)\n\nfor _ in range(M):\n A, B = map(int, input().split())\n A -= 1\n B -= 1\n group.union(A, B)\n\nprint(len(group.roots()) - 1)", "neg": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n uf = UnionFind(N)\nfor _ in range(M):\n a, b = map(int, input().split())\n uf.union(a-1, b-1)\nprint(len(uf.roots())-1)", "jacc_sim": 0.9076923076923077, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [478, 459], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u413165887", "n_user": "u540631540", "pos": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nn, m = map(int, input().split())\nab = [list(map(int, input().split())) for _i in range(m)]\n\nuf = UnionFind(n)\nfor i, j in ab:\n uf.union(i-1, j-1)\nprint(uf.group_count()-1)", "neg": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nn, m = map(int, input().split())\nuf = UnionFind(n)\nfor i in range(m):\n a, b = map(int, input().split())\n uf.union(a - 1, b - 1)\nprint(uf.group_count())", "jacc_sim": 0.90625, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [481, 467], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02536", "p_user": "u642012866", "n_user": "u288430479", "pos": "N, M = map(int, input().split())\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n def size(self, x):\n return -self.parents[self.find(x)]\n def same(self, x, y):\n return self.find(x) == self.find(y)\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n def group_count(self):\n return len(self.roots())\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n \nuf = UnionFind(N)\nfor _ in range(M):\n a, b = map(int, input().split())\n uf.union(a-1, b-1)\n\nprint(len(uf.roots())-1)", "neg": "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nn,m = map(int,input().split())\nu = UnionFind(n)\n\nfor i in range(m):\n a,b = map(int,input().split())\n u.union(a-1,b-1)\n\na = u.roots()\nprint(len(a))", "jacc_sim": 0.90625, "nl": "Score: 300 points\n\nProblem Statement:\nThere are N cities numbered 1 through N, and M bidirectional roads numbered 1 through M. Road i connects City A_i and City B_i. Snuke can perform the following operation zero or more times: Choose two distinct cities that are not directly connected by a road, and build a new road between the two cities. After he finishes the operations, it must be possible to travel from any city to any other cities by following roads (possibly multiple times). What is the minimum number of roads he must build to achieve the goal?\n\nConstraints:\n- 2 <= N <= 100,000\n- 1 <= M <= 100,000\n- 1 <= A_i < B_i <= N\n- No two roads connect the same pair of cities.\n- All values in input are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN M\nA_1 B_1\n:\nA_M B_M\n\nOutput:\nPrint the answer.\n\nSample Input 1:\n3 1\n1 2\n\nSample Output 1:\n1\nInitially, there are three cities, and there is a road between City 1 and City 2. Snuke can achieve the goal by building one new road, for example, between City 1 and City 3. After that, we can travel between 1 and 2 directly, between 1 and 3 directly, and between 2 and 3 by following both roads (2 - 1 - 3).", "before_after_length": [461, 474], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02537", "p_user": "u311379832", "n_user": "u311379832", "pos": "def segfunc(x, y): return max(x, y)\ndef update(i, x):\n i += MAX_N-1\n node[i] = x\n while i:\n i = (i-1)//2\n node[i] = segfunc(node[i*2+1], node[i*2+2])\n\ndef query(l, r):\n L = l + MAX_N\n R = r + MAX_N\n s = INF\n while L < R:\n if R & 1:\n R -= 1\n s = segfunc(s, node[R - 1])\n if L & 1:\n s = segfunc(s, node[L - 1])\n L += 1\n L >>= 1\n R >>= 1\n return s\n\nN, K = map(int, input().split())\nMAX_N = 2**(300005).bit_length()\na = [int(input()) for _ in range(N)]\nnode = [0] * (2 * MAX_N)\nINF = 0\nans = 0\n\n#for i in range(N):\n# update(i, a[i])\n\nfor i in a:\n tmp = query(max(i - K, 0), min(300005, i + K) + 1)\n update(i, tmp + 1)\n ans = max(ans, tmp + 1)\nprint(ans)\n", "neg": "def segfunc(x, y): return max(x, y)\n\ndef update(i, x):\n i += MAX_N - 1\n node[i] = x\n while i:\n i = (i-1)//2\n node[i] = segfunc(node[i*2], node[i*2+1])\n\ndef query(l, r):\n L = l + MAX_N\n R = r + MAX_N\n s = INF\n while L < R:\n if R & 1:\n R -= 1\n s = segfunc(s, node[R - 1])\n if L & 1:\n s = segfunc(s, node[L - 1])\n L += 1\n L >>= 1\n R >>= 1\n return s\n\nN, K = map(int, input().split())\nMAX_N = 2**(N-1).bit_length()\nMAXINDEX = 2 ** (30000).bit_length()\na = [int(input()) for _ in range(N)]\nnode = [0] * (2 * MAXINDEX)\nINF = 0\nma = max(a)\nans = 0\nfor i in a:\n tmp = query(max(i - K, 0), min(ma, i + K) + 1)\n update(i, tmp + 1)\n ans = max(ans, tmp + 1)\nprint(ans)\n", "jacc_sim": 0.9137931034482759, "nl": "You are given a sequence A_1, A_2, ..., A_N and an integer K. Print the maximum possible length of a sequence B that is a subsequence of A, where the absolute difference of adjacent elements in B is at most K. Constraints: 1 \u2264 N \u2264 300,000, 0 \u2264 A_i \u2264 300,000, 0 \u2264 K \u2264 300,000. Input format: N K A_1 A_2 ... A_N. Output: Print the answer. Example: Input: 10 3 1 5 4 3 8 6 9 7 2 4. Output: 7. Example sequence B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.", "before_after_length": [339, 334], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02537", "p_user": "u520276780", "n_user": "u520276780", "pos": "\n## https://atcoder.jp/contests/abc170/submissions/14416787\nclass SegmentTree():\n def __init__(self,n,init):\n self.offset=2**((n-1).bit_length())\n self.tree=[init]*(2*self.offset)\n self.init=init\n def update(self,pos,val):\n pos+=self.offset\n self.tree[pos]=val\n while pos>1:\n pos=pos//2\n self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])\n def query(self,l,r):\n l+=self.offset\n r+=self.offset\n ret=self.init\n while l<=r:\n ret=max(ret,self.tree[r])\n r=(r-1)//2\n ret=max(ret,self.tree[l])\n l=(l+1)//2\n return ret\n\nimport sys\ninput=sys.stdin.readline\nn,k=map(int,input().split())\na=[int(input()) for _ in range(n)]\n\nst=SegmentTree(300001,0)\n##query\u304c\u958b\u533a\u9593\u3067\u306a\u3044\nfor ai in a:\n l=max(0,ai-k)\n r=min(300001,ai+k)\n m=st.query(l,r)\n st.update(ai,m+1)\n\nprint(st.query(0,300001))\n ", "neg": "\n## https://atcoder.jp/contests/abc170/submissions/14416787\n\nimport sys\ninput=sys.stdin.readline\n\nclass SegmentTree():\n def __init__(self,n,init):\n self.offset=2**((n-1).bit_length())\n self.tree=[init]*(2*self.offset)\n self.init=init\n def update(self,pos,val):\n pos+=self.offset\n self.tree[pos]=val\n while pos>1:\n pos=pos//2\n self.tree[pos]=max(self.tree[2*pos],self.tree[2*pos+1])\n def query(self,l,r):\n l+=self.offset\n r+=self.offset\n ret=self.init\n while l<=r:\n ret=max(ret,self.tree[r])\n r=(r-1)//2\n ret=max(ret,self.tree[l])\n l=(l+1)//2\n return ret\n\nimport sys\ninput=sys.stdin.readline\nn,k=map(int,input().split())\na=[int(input()) for _ in range(300001)]\n\nst=SegmentTree(300001,0)\n\nfor ai in a:\n l=max(0,ai-k)\n r=min(n+1,ai+k+1)\n m=st.query(l,r)\n st.update(ai,m+1)\n\nprint(st.query(0,n+1))\n ", "jacc_sim": 0.9041095890410958, "nl": "You are given a sequence A_1, A_2, ..., A_N and an integer K. Print the maximum possible length of a sequence B that is a subsequence of A, where the absolute difference of adjacent elements in B is at most K. Constraints: 1 \u2264 N \u2264 300,000, 0 \u2264 A_i \u2264 300,000, 0 \u2264 K \u2264 300,000. Input format: N K A_1 A_2 ... A_N. Output: Print the answer. Example: Input: 10 3 1 5 4 3 8 6 9 7 2 4. Output: 7. Example sequence B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.", "before_after_length": [393, 388], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02537", "p_user": "u111365362", "n_user": "u111365362", "pos": "n,k = map(int,input().split())\nscale = 21\n#scale = 4\nseg = [0 for _ in range(2**scale)]\ndb = [2**i for i in range(scale)]\nrdb = list(reversed(db))\n#print(rdb)\nfor _ in range(n):\n c = int(input())\n l = max(c-k,0)\n r = min(c+k+1,2**(scale-1))\n maxi = 0\n now = [[l,r]]\n #print(now)\n for i in range(scale):\n last = now\n now = []\n for xy in last:\n x,y = xy\n if x == y:\n continue\n X = (x-1) // rdb[i] + 1\n Y = y // rdb[i]\n #print(x,y,X,Y,rdb[i])\n if X < Y:\n for Z in range(X,Y):\n maxi = max(maxi,seg[db[i]+Z])\n now.append([x,X*rdb[i]])\n now.append([Y*rdb[i],y])\n else:\n now.append(xy)\n #print(int(X 1:\n i >>= 1\n self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])\n\n def fold(self, L, R):\n L += self.N\n R += self.N\n vL = self.X_unit\n vR = self.X_unit\n while L < R:\n if L & 1:\n vL = self.X_f(vL, self.X[L])\n L += 1\n if R & 1:\n R -= 1\n vR = self.X_f(self.X[R], vR)\n L >>= 1\n R >>= 1\n return self.X_f(vL, vR)\n\nN,K = map(int,input().split())\nST = SegTree(300030)\nfor i in range(N):\n A = int(input())\n l = max(0,A-K)+1\n r = min(A+K,300000)+2\n M = ST.fold(l,r)\n ST.set_val(A+1,M+1)\nprint(ST.X[1])", "neg": "class SegTree:\n X_unit = 0\n X_f = max\n\n def __init__(self, N):\n self.N = N\n self.X = [0] * (N + N)\n\n def build(self, seq):\n for i, x in enumerate(seq, self.N):\n self.X[i] = x\n for i in range(self.N - 1, 0, -1):\n self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])\n\n def set_val(self, i, x):\n i += self.N\n self.X[i] = x\n while i > 1:\n i >>= 1\n self.X[i] = self.X_f(self.X[i << 1], self.X[i << 1 | 1])\n\n def fold(self, L, R):\n L += self.N\n R += self.N\n vL = self.X_unit\n vR = self.X_unit\n while L < R:\n if L & 1:\n vL = self.X_f(vL, self.X[L])\n L += 1\n if R & 1:\n R -= 1\n vR = self.X_f(self.X[R], vR)\n L >>= 1\n R >>= 1\n return self.X_f(vL, vR)\n\nN,K = map(int,input().split())\nST = SegTree(300030)\nfor i in range(N):\n A = 300000\n l = max(0,A-K)+1\n r = min(A+K,300000)+2\n M = ST.fold(l,r)\n ST.set_val(A+1,M+1)\nprint(ST.X[1])\n", "jacc_sim": 1.0, "nl": "You are given a sequence A_1, A_2, ..., A_N and an integer K. Print the maximum possible length of a sequence B that is a subsequence of A, where the absolute difference of adjacent elements in B is at most K. Constraints: 1 \u2264 N \u2264 300,000, 0 \u2264 A_i \u2264 300,000, 0 \u2264 K \u2264 300,000. Input format: N K A_1 A_2 ... A_N. Output: Print the answer. Example: Input: 10 3 1 5 4 3 8 6 9 7 2 4. Output: 7. Example sequence B = (1, 4, 3, 6, 9, 7, 4) satisfies the conditions.", "before_after_length": [458, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02540", "p_user": "u368796742", "n_user": "u368796742", "pos": "import sys\ninput = sys.stdin.readline\n\nclass Unionfind:\n \n def __init__(self,n):\n self.uf = [-1]*n\n \n def find(self,x):\n if self.uf[x] < 0:\n return x\n else:\n self.uf[x] = self.find(self.uf[x])\n return self.uf[x]\n \n def same(self,x,y):\n return self.find(x) == self.find(y)\n \n def union(self,x,y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return False\n if self.uf[x] > self.uf[y]:\n x,y = y,x\n self.uf[x] += self.uf[y]\n self.uf[y] = x\n return True\n \n def size(self,x):\n x = self.find(x)\n return -self.uf[x]\n\n\nn = int(input())\nxy = [list(map(int,input().split())) for i in range(n)]\nxy2 = [[x[0],x[1],i] for (i,x) in enumerate(xy)]\nxy2.sort()\nu = Unionfind(n)\n\nl = []\nfor x,y,ind in xy2:\n M = y\n le = ind\n while l and xy[l[-1]][1] < y:\n v = l.pop()\n if M > xy[v][1]:\n M = xy[v][1]\n le = v\n u.union(ind,v)\n l.append(le)\nfor i in range(n):\n print(u.size(i))\n\n", "neg": "import sys\ninput = sys.stdin.readline\n\nclass Unionfind:\n \n def __init__(self,n):\n self.uf = [-1]*n\n \n def find(self,x):\n if self.uf[x] < 0:\n return x\n else:\n self.uf[x] = self.find(self.uf[x])\n return self.uf[x]\n \n def same(self,x,y):\n return self.find(x) == self.find(y)\n \n def union(self,x,y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return False\n if self.uf[x] > self.uf[y]:\n x,y = y,x\n self.uf[x] += self.uf[y]\n self.uf[y] = x\n return True\n \n def size(self,x):\n x = self.find(x)\n return -self.uf[x]\n\n\nn = int(input())\nxy = [[map(int,input().split()),i] for i in range(n)]\nxy2 = sorted(xy)\nu = Unionfind(n)\n\nl = []\nfor x,y,ind in xy2:\n M = y\n le = ind\n while l and xy[l[-1]][1] < y:\n v = l.pop()\n if M > xy[v][1]:\n M = xy[v][1]\n le = v\n u.union(ind,v)\n l.append(le)\nfor i in range(n):\n print(u.size(i))\n\n", "jacc_sim": 0.9354838709677419, "nl": "You are given N cities on a 2D plane with coordinates (x_i, y_i). For each city k, find the number of cities reachable from city k by moving to a city with smaller or larger x and y coordinates. Constraints: 1 \u2264 N \u2264 200,000, (x_1, x_2, ..., x_N) and (y_1, y_2, ..., y_N) are permutations of (1, 2, ..., N). Input format: N, followed by N lines of x and y coordinates. Output format: N lines with the answer for each city.", "before_after_length": [439, 415], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02540", "p_user": "u222668979", "n_user": "u222668979", "pos": "class Unionfind(): # Unionfind\n def __init__(self, N):\n self.N = N\n self.parents = [-1] * N\n\n def find(self, x): # \u30b0\u30eb\u30fc\u30d7\u306e\u6839\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y): # \u30b0\u30eb\u30fc\u30d7\u306e\u4f75\u5408\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x): # \u30b0\u30eb\u30fc\u30d7\u306e\u30b5\u30a4\u30ba\n return -self.parents[self.find(x)]\n\n\nn = int(input())\nxy = [list(map(int, input().split())) for _ in range(n)]\nxysort = [None] * n\nfor x, y in xy:\n xysort[x - 1] = y - 1\n\n# \u89e3\u8aacAC\nuf = Unionfind(n)\ntmp, yfrag = 0, [0] * n\nfor x, y in enumerate(xysort[:n - 1], 1):\n yfrag[y] = 1\n tmp += yfrag[n - x] + (y > n - x)\n if tmp < x:\n uf.union(x, x - 1)\n\nfor x, y in xy:\n print(uf.size(x - 1))\n", "neg": "class Unionfind(): # Unionfind\n def __init__(self, N):\n self.N = N\n self.parents = [-1] * N\n\n def find(self, x): # \u30b0\u30eb\u30fc\u30d7\u306e\u6839\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y): # \u30b0\u30eb\u30fc\u30d7\u306e\u4f75\u5408\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x): # \u30b0\u30eb\u30fc\u30d7\u306e\u30b5\u30a4\u30ba\n return -self.parents[self.find(x)]\n\n\nn = int(input())\nxy = [list(map(int, input().split())) for _ in range(n)]\nxysort = [None] * n\nfor x, y in xy:\n xysort[x - 1] = y - 1\n\n# \u89e3\u8aacAC O(n)\nuf = Unionfind(n)\ncnt, yfrag = 0, [0] * n\nfor x, y in enumerate(xysort[:n - 1]):\n yfrag[y] = 1\n cnt += (y >= n - x - 1)\n if cnt < x + 1:\n uf.union(x, x + 1)\n\nfor x, y in xy:\n print(uf.size(x - 1))\n", "jacc_sim": 0.9538461538461539, "nl": "You are given N cities on a 2D plane with coordinates (x_i, y_i). For each city k, find the number of cities reachable from city k by moving to a city with smaller or larger x and y coordinates. Constraints: 1 \u2264 N \u2264 200,000, (x_1, x_2, ..., x_N) and (y_1, y_2, ..., y_N) are permutations of (1, 2, ..., N). Input format: N, followed by N lines of x and y coordinates. Output format: N lines with the answer for each city.", "before_after_length": [464, 463], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02540", "p_user": "u711539583", "n_user": "u711539583", "pos": "import sys\nimport heapq\ninput = sys.stdin.readline\n\nclass UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\nn = int(input())\nuf = UnionFind(n)\nd = {}\n\nfor i in range(n):\n x, y = map(int, input().split())\n d[x] = (i, y)\n \nq = []\nheapq.heapify(q)\n\nfor x in range(n):\n i, y = d[x+1]\n ym, im = 0, 0\n while q and q[0][0] < y:\n y2, i2 = heapq.heappop(q)\n if ym == 0:\n ym = y2\n im = i2\n uf.union(i,i2)\n heapq.heappush(q, (y,i))\n if ym:\n heapq.heappush(q, (ym,im))\n\nfor i in range(n):\n p = uf.find(i)\n print(-uf.parents[p])\n", "neg": "import sys\nimport heapq\ninput = sys.stdin.readline\n\nclass UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\nn = int(input())\nuf = UnionFind(n)\nd = {}\n\nfor i in range(n):\n x, y = map(int, input().split())\n d[x] = (i, y)\n \nq = []\nheapq.heapify(q)\n\nfor x in range(n):\n i, y = d[x]\n while q[0][0] < y:\n y2, i2 = heapq.heappop(q)\n uf.union(i,i2)\n heapq.heappush(q, (y,i))\n\nfor i in range(n):\n p = uf.find(i)\n print(-uf.parents[p])\n", "jacc_sim": 0.9491525423728814, "nl": "You are given N cities on a 2D plane with coordinates (x_i, y_i). For each city k, find the number of cities reachable from city k by moving to a city with smaller or larger x and y coordinates. Constraints: 1 \u2264 N \u2264 200,000, (x_1, x_2, ..., x_N) and (y_1, y_2, ..., y_N) are permutations of (1, 2, ..., N). Input format: N, followed by N lines of x and y coordinates. Output format: N lines with the answer for each city.", "before_after_length": [430, 373], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02541", "p_user": "u488401358", "n_user": "u488401358", "pos": "from math import gcd\n\ndef euclid(A,B):\n if B==1:\n return 1,1-A\n else:\n q,r = A//B,A%B\n x1,y1 = euclid(B,r)\n return y1,x1-q*y1\n\nN = int(input())\nans = 2*N\nfor i in range(1,2*N+1):\n if i**2>(2*N):\n break\n if (2*N)%i:\n continue\n\n A,B = i,(2*N)//i\n\n if gcd(A,B)!=1:\n continue\n\n x0,y0 = euclid(A,B)\n\n limit1 = (1-y0)//A\n if limit1*A+y0<1:\n limit1+=1\n\n limit2 = (x0+1)//B\n if limit2*B- x0<1:\n limit2+=1\n\n limit = max(limit1,limit2)\n\n tmp = (B*limit-x0)*A\n ans = min(ans,tmp)\n\n A,B = (2*N)//i,i\n\n x0,y0 = euclid(A,B)\n\n limit1 = (1-y0)//A\n if limit1*A+y0<1:\n limit1+=1\n\n limit2 = (x0+1)//B\n if limit2*B- x0<1:\n limit2+=1\n\n limit = max(limit1,limit2)\n\n tmp = (B*limit-x0)*A\n ans = min(ans,tmp)\n\nprint(ans)", "neg": "from math import gcd\n\ndef euclid(A,B):\n if B==1:\n return 1,1-A\n else:\n q,r = A//B,A%B\n x1,y1 = euclid(B,r)\n return y1,x1-q*y1\n\nN = int(input())\nans = 2*N\nfor i in range(1,2*N+1):\n if i**2>(2*N):\n break\n if N%i:\n continue\n\n A,B = i,(2*N)//i\n\n if gcd(A,B)!=1:\n continue\n\n x0,y0 = euclid(A,B)\n\n limit1 = (1-y0)//A\n if limit1*A+y0<1:\n limit1+=1\n\n limit2 = (x0+1)//B\n if limit2*B- x0<1:\n limit2+=1\n\n limit = max(limit1,limit2)\n\n tmp = (B*limit-x0)*A\n ans = min(ans,tmp)\n\n A,B = (2*N)//i,i\n\n x0,y0 = euclid(A,B)\n\n limit1 = (1-y0)//A\n if limit1*A+y0<1:\n limit1+=1\n\n limit2 = (x0+1)//B\n if limit2*B- x0<1:\n limit2+=1\n\n limit = max(limit1,limit2)\n\n tmp = (B*limit-x0)*A\n ans = min(ans,tmp)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given an integer N. Find the minimum positive integer k such that the sum of all integers from 1 to k is a multiple of N. The input is given as N, and the output should be the value of k. The constraints are 1 \u2264 N \u2264 10^15, and all input values are integers. For example, if the input is 11, the output should be 10, as the sum of 1 to 10 is 55, which is a multiple of 11. If the input is 20200920, the output should be 1100144.", "before_after_length": [436, 432], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02541", "p_user": "u583276018", "n_user": "u583276018", "pos": "import math\nn = int(input())\n\ndef yakusu(n):\n a = []\n for i in range(1, int(math.sqrt(2*n))+2):\n if(2*n % i == 0):\n a.append(i)\n for i in range(len(a)):\n a.append(2*n // a[i])\n return sorted(list(set(a)))\n\ndef exgcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = exgcd(b % a, a)\n return g, x - (b // a) * y, y\n \ndef CRT(b1, m1, b2, m2):\n # \u4e2d\u56fd\u5270\u4f59\u5b9a\u7406\n # x \u2261 b1 (mod m1) \u2227 x \u2261 b2 (mod m2) <=> x \u2261 r (mod m)\n # \u3068\u306a\u308b(r. m)\u3092\u8fd4\u3059\n # \u89e3\u7121\u3057\u306e\u3068\u304d(0, -1)\n d, p, q = exgcd(m1, m2)\n if (b2 - b1) % d != 0:\n return 0, -1\n m = m1 * (m2 // d) # m = lcm(m1, m2)\n tmp = (b2-b1) // d * p % (m2 // d)\n r = (b1 + m1 * tmp) % m\n return r, m\nx = yakusu(n)\na = 1e16\nfor i in range(len(x)):\n r, m = CRT(-1, 2*n//x[i], 0, x[i])\n if(r > 0):\n a = min(a, r)\nprint(a)", "neg": "import math\nn = int(input())\n\ndef yakusu(n):\n a = []\n for i in range(1, int(math.sqrt(2*n))+2):\n if(2*n % i == 0):\n a.append(i)\n return a\n\ndef exgcd(a, b):\n if a == 0:\n return b, 0, 1\n else:\n g, y, x = exgcd(b % a, a)\n return g, x - (b // a) * y, y\n \ndef CRT(b1, m1, b2, m2):\n # \u4e2d\u56fd\u5270\u4f59\u5b9a\u7406\n # x \u2261 b1 (mod m1) \u2227 x \u2261 b2 (mod m2) <=> x \u2261 r (mod m)\n # \u3068\u306a\u308b(r. m)\u3092\u8fd4\u3059\n # \u89e3\u7121\u3057\u306e\u3068\u304d(0, -1)\n d, p, q = exgcd(m1, m2)\n if (b2 - b1) % d != 0:\n return 0, -1\n m = m1 * (m2 // d) # m = lcm(m1, m2)\n tmp = (b2-b1) // d * p % (m2 // d)\n r = (b1 + m1 * tmp) % m\n return r, m\nx = yakusu(n)\na = 1e16\nfor i in range(len(x)):\n r, m = CRT(-1, 2*n//x[i], 0, x[i])\n if(r > 0):\n a = min(a, r)\nprint(a)", "jacc_sim": 0.9629629629629629, "nl": "You are given an integer N. Find the minimum positive integer k such that the sum of all integers from 1 to k is a multiple of N. The input is given as N, and the output should be the value of k. The constraints are 1 \u2264 N \u2264 10^15, and all input values are integers. For example, if the input is 11, the output should be 10, as the sum of 1 to 10 is 55, which is a multiple of 11. If the input is 20200920, the output should be 1100144.", "before_after_length": [490, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u034385994", "n_user": "u523087093", "pos": "MOD = 998244353\nN, K = map(int, input().split()) #N\u306f\u30de\u30b9\u76ee\u306e\u6570\u3001K\u306f\u533a\u9593\u306e\u6570(K\u306f10\u4ee5\u4e0b)\nkukan = [tuple(map(int, input().split())) for _ in range(K)]\n\ndp = [0] * (N+1)\ndp[1] = 1\n\nsumdp = [0] * (N+1)\nsumdp[1] = 1\n\nfor i in range(2, N+1):\n for l, r in kukan:\n li = max(i - l, 0)\n ri = max(i - r - 1, 0)\n\n dp[i] += sumdp[li] - sumdp[ri]\n dp[i] %= MOD\n\n sumdp[i] = sumdp[i-1] + dp[i]\n\nprint(dp[N])", "neg": "MOD = 998244353\nN, K = map(int, input().split()) #N\u306f\u30de\u30b9\u76ee\u306e\u6570\u3001K\u306f\u533a\u9593\u306e\u6570(K\u306f10\u4ee5\u4e0b)\nkukan = [tuple(map(int, input().split())) for _ in range(K)]\n\ndp = [0] * (N+1)\ndp[1] = 1\n\nsumdp = [0] * (N+1)\nsumdp[1] = 1\n\nfor i in range(2, N+1):\n for l, r in kukan:\n li = max(i - l, 0)\n ri = max(i - r - 1, 0)\n\n dp[i] += sumdp[li] - sumdp[ri]\n\n sumdp[i] = sumdp[i-1] + dp[i]\n\nprint(dp[N])", "jacc_sim": 0.9803921568627451, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [245, 237], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u383713431", "n_user": "u383713431", "pos": "N, K = map(int, input().split())\nMOD = 998244353\n\nl = [0] * K\nr = [0] * K\n\nfor i in range(K):\n\tl[i], r[i] = map(int, input().split())\n\t\ndp = [0] * (N+1)\ndp[1] = 1\n\ndpsum = [0] * (N+1)\ndpsum[1] = 1\n\nfor i in range(2, N+1):\n\tfor j in range(K):\n\t\tli = i - r[j]\n\t\tri = i - l[j]\n\t\tif li <= 0:\n\t\t\tdp[i] = dp[i] + dpsum[ri]\n\t\t\tdp[i] %= MOD\n\t\telse:\n\t\t\tdp[i] = dpsum[ri] - dpsum[li-1] + dp[i]\n\t\t\tdp[i] %= MOD\n\t\t\t\n\t\t\t\n\tdpsum[i] = dp[i] + dpsum[i-1]\n\tdpsum[i] %= MOD\n\t\nprint(dp[N] % MOD)", "neg": "N, K = map(int, input().split())\nMOD = 998244353\n\nl = [0] * K\nr = [0] * K\n\nfor i in range(K):\n\tl[i], r[i] = map(int, input().split())\n\t\ndp = [0] * (N+1)\ndp[1] = 1\n\ndpsum = [0] * (N+1)\ndpsum[1] = 1\n\nfor i in range(2, N+1):\n\tfor j in range(K):\n\t\tli = i - r[j]\n\t\tri = i - l[j]\n\t\tif li < 0:\n\t\t\tcontinue\n\t\tif li == 0:\n\t\t\tdp[i] = dp[i] + dpsum[ri]\n\t\telse:\n\t\t\tdp[i] = dpsum[ri] - dpsum[li-1] + dp[i]\n\t\t\t\n\t\t\t\n\tdpsum[i] = dp[i] + dpsum[i-1]\n\t\nprint(dp[N] % MOD)", "jacc_sim": 0.9743589743589743, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [281, 265], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u836939578", "n_user": "u836939578", "pos": "#\u3082\u3089\u3046DP\u3067\u8003\u3048\u308b\nN, K = map(int, input().split())\n\nl = []\nr = []\n\nMOD = 998244353\n\nfor i in range(K):\n a,b = map(int, input().split())\n l.append(a)\n r.append(b)\n\ndp = [0] * (N+1)\n#\u30b9\u30bf\u30fc\u30c8\u5730\u70b9\u304c1\u306a\u306e\u3067\u3001dp[1]\u30921\u3068\u3059\u308b\ndp[1] = 1\n\ndpsum = [0] * (N+1)\ndpsum[1] = 1\n\nfor i in range(2, N+1):\n for j in range(K):\n #[l[i], r[i]]\n li = i - r[j]\n ri = i - l[j]\n if ri < 0: continue\n # l1\u304c\u8ca0\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3092\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n li = max(1, li)\n dp[i] += (dpsum[ri] - dpsum[li-1])%MOD #dp[li] ~ dp[ri]\u306e\u548c\u3092\u8db3\u3059\n dpsum[i] = (dpsum[i-1] + dp[i])%MOD\n\nprint(dp[N]%MOD)", "neg": "#\u3082\u3089\u3046DP\u3067\u8003\u3048\u308b\nN, K = map(int, input().split())\n\nl = []\nr = []\n\nMOD = 998244353\n\nfor i in range(K):\n a,b = map(int, input().split())\n l.append(a)\n r.append(b)\n\ndp = [0] * (N+1)\n#\u30b9\u30bf\u30fc\u30c8\u5730\u70b9\u304c1\u306a\u306e\u3067\u3001dp[1]\u30921\u3068\u3059\u308b\ndp[1] = 1\n\ndpsum = [0] * (N+1)\ndpsum[1] = 1\n\nfor i in range(2, N+1):\n for j in range(K):\n #[l[i], r[i]]\n li = i - r[j]\n ri = i - l[j]\n if ri < 0: continue\n # l1\u304c\u8ca0\u306b\u306a\u308b\u30b1\u30fc\u30b9\u3092\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n li = max(1, li)\n dp[i] += dpsum[ri] - dpsum[li-1] #dp[li] ~ dp[ri]\u306e\u548c\u3092\u8db3\u3059\n dpsum[i] = dpsum[i-1] + dp[i]\n\nprint(dp[N])", "jacc_sim": 0.9868421052631579, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [399, 390], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u686036872", "n_user": "u686036872", "pos": "N, K = map(int, input().split())\n\nDP = [0]*(N+1)\nDP[1] = 1\n\nS = []\nfor i in range(K):\n S.append(list(map(int, input().split())))\n\nfor i in range(2, N+1):\n for l, r in S:\n DP[i] += (DP[max(i-l, 0)] - DP[max(i-r-1, 0)])\n DP[i] += DP[i-1]\n DP[i] %= 998244353\n\nprint((DP[N] - DP[N-1])%998244353)", "neg": "N, K = map(int, input().split())\n\nDP = [0]*(N+1)\nDP[1] = 1\n\nS = []\nfor i in range(K):\n S.append(list(map(int, input().split())))\n\nS.sort()\n\nfor i in range(2, N+1):\n for l, r in S:\n DP[i] = (DP[max(i-l, 0)] - DP[max(i-r-1, 0)])%998244353\n DP[i] += DP[i-1]\n\nprint(DP[N]%998244353)", "jacc_sim": 0.9714285714285714, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [170, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u653837719", "n_user": "u653837719", "pos": "n, k = map(int, input().split())\nsec = [list(map(int, input().split())) for _ in range(k)]\nsec.sort()\n\nmod = 998244353\n\ndp = [0] * n\ndp[0] = 1\nsum_dp = [0, 1]\nfor i in range(1, n):\n for l, r in sec:\n if i - l < 0:\n break\n elif i - r > 0:\n dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod\n else:\n dp[i] = (dp[i] + sum_dp[i-l+1]) % mod\n \n sum_dp.append((sum_dp[-1] + dp[i]) % mod)\n\nprint(dp[n-1])", "neg": "n, k = map(int, input().split())\nsec = [list(map(int, input().split())) for _ in range(k)]\nsec.sort()\n\nmod = 998244353\n\ndp = [0] * n\ndp[0] = 1\nsum_dp = [0, 1]\nfor i in range(1, n):\n for l, r in sec:\n if i - l < 0:\n break\n elif i - r > 0:\n dp[i] = ((dp[i] + sum_dp[i-l+1]) % mod - sum_dp[i-r]) % mod\n else:\n dp[i] = (dp[i] + sum_dp[i-l+1]) % mod\n \n sum_dp.append((sum_dp[-1] + dp[i]) % modp)\n\nprint(dp[n-1])", "jacc_sim": 0.9767441860465116, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [214, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u355853184", "n_user": "u355853184", "pos": "N, K = map(int, input().split())\n\nMOD = 998244353\n\nL_list = []\nR_list = []\nfor i in range(K):\n L, R = map(int, input().split())\n L_list.append(L)\n R_list.append(R)\n\ndp = [0] * (N+1)\ndp[0] = 0\ndp[1] = 1\nsdp = [0] * (N+1)\nsdp[0] = 0\nsdp[1] = 1\n\n\nfor i in range(2, N+1):\n for j in range(len(L_list)):\n if i - R_list[j]-1 < 0:\n R_pos = 0\n else:\n R_pos = i - R_list[j] - 1\n dp[i] += (sdp[i - L_list[j]] - sdp[R_pos])%MOD\n dp[i] %= MOD\n sdp[i] = sdp[i-1] + dp[i]\n sdp[i] %= MOD\n #print(dp)\n #print(\"s\", sdp)\nprint(dp[N])", "neg": "N, K = map(int, input().split())\n\nMOD = 998244353\n\nL_list = []\nR_list = []\nfor i in range(K):\n L, R = map(int, input().split())\n L_list.append(L)\n R_list.append(R)\n\ndp = [0] * (N+1)\ndp[0] = 0\ndp[1] = 1\nsdp = [0] * (N+1)\nsdp[0] = 0\nsdp[1] = 1\n\n\nfor i in range(2, N+1):\n for j in range(len(L_list)):\n if i - R_list[j]-1 < 0:\n R_pos = 0\n else:\n R_pos = i - R_list[j] - 1\n dp[i] += (sdp[i - L_list[j]] - sdp[R_pos])%MOD\n sdp[i] = sdp[i-1] + dp[i]\n sdp[i] %= MOD\n #print(dp)\n #print(\"s\", sdp)\nprint(dp[N])", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [289, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u692054751", "n_user": "u692054751", "pos": "n, K = [int(a) for a in input().split()]\ns = [[int(a) for a in input().split()] for _ in range(K)]\n\nMOD = 998244353\n\ndp = [0] * (n + 1)\ndp_sum = [0] * (n + 1)\ndp[1] = 1\n\nfor i in range(1, n+1):\n for l, r in s:\n dp[i] += dp_sum[i-l if (i-l) > 0 else 0] - dp_sum[(i-r-1) if (i-r-1) > 0 else 0]\n dp_sum[i] = (dp[i] + dp_sum[i-1]) % MOD\n\nprint(dp[n] % MOD)", "neg": "n, K = [int(a) for a in input().split()]\ns = [[int(a) for a in input().split()] for _ in range(K)]\n\nMOD = 998244353\n\ndp = [0] * (n + 1)\ndp_sum = [0] * (n + 1)\ndp[1] = 1\n\nfor i in range(1, n+1):\n for l, r in s:\n dp[i] += dp_sum[i-l if (i-l) > 0 else 0] - dp_sum[(i-r-1) if (i-r-1) > 0 else 0]\n dp_sum[i] = (dp[i] + dp_sum[i-1]) % MOD\n\nprint(dp[n] % MOD)", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [192, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u609061751", "n_user": "u609061751", "pos": "import sys\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nmod = 998244353\n\nn, k = map(int, input().split())\nl = []\nr = []\nfor _ in range(k):\n l_, r_ = map(int, input().split())\n l.append(l_)\n r.append(r_)\ndp = [0] * (n + 1)\ndp_csum = [0] * (n + 1)\ndp[1] = 1\ndp_csum[1] = 1\nfor i in range(2, n + 1):\n for j in range(k):\n left = i - r[j]\n right = i - l[j]\n if right >= 1:\n dp[i] += dp_csum[right] - dp_csum[max(left, 1) - 1]\n dp[i] %= mod\n dp_csum[i] = dp_csum[i - 1] + dp[i]\n dp_csum[i] %= mod\nprint(dp[-1])", "neg": "import sys\ninput = lambda: sys.stdin.readline().rstrip(\"\\r\\n\")\n\nmod = 998244353\n\nn, k = map(int, input().split())\nl = []\nr = []\nfor _ in range(k):\n l_, r_ = map(int, input().split())\n l.append(l_)\n r.append(r_)\ndp = [0] * (n + 1)\ndp_csum = [0] * (n + 1)\ndp[1] = 1\ndp_csum[1] = 1\nfor i in range(2, n + 1):\n for j in range(k):\n left = i - r[j]\n right = i - l[j]\n if right > 0:\n dp[i] += dp_csum[right] - dp_csum[max(left, 1) - 1]\n dp[i] %= mod\n dp_csum[i] = dp_csum[i - 1] + dp[i]\n dp_csum[i] %= mod\nprint(dp[-1])", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [266, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u145145077", "n_user": "u145145077", "pos": "n,k=map(int,input().split())\nlr=[list(map(int,input().split())) for _ in range(k)]\n\nmod = 998244353\n\ndp = [0] * (n+1)\nsdp = [0] * (n+1)\ndp[1] = 1\nsdp[1] = 1\n\nfor i in range(n+1):\n for j in range(k):\n left = max(0, i-lr[j][1])\n right = max(0, i-lr[j][0]+1)\n \n dp[i] += sdp[right] - sdp[left]\n if i+1 <= n:\n sdp[i+1] = sdp[i]%mod + dp[i]%mod\n\nprint(dp[n]%mod)", "neg": "n,k=map(int,input().split())\nlr=[list(map(int,input().split())) for _ in range(k)]\n\nmod = 998244353\n\ndp = [0] * (n+1)\nsdp = [0] * (n+1)\ndp[1] = 1\nsdp[1] = 1\n\nfor i in range(n+1):\n for j in range(k):\n left = max(0, i-lr[j][1])\n right = max(0, i-lr[j][0]+1)\n \n dp[i] += sdp[right] - sdp[left]\n if i+1 <= n:\n sdp[i+1] = sdp[i]%mod + dp[i]%mod\n\nprint(dp%mod)", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [198, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u113694671", "n_user": "u113694671", "pos": "#dp\u3067\u7d20\u76f4\u306b\u3084\u308b\u3068O(N^2)\u3060\u304b\u3089\u3001\u7d2f\u7a4d\u548c\u3067\u9ad8\u901f\u5316\u3057O(KN)\u306b\u3059\u308b\n\nn, k = map(int,input().split())\nmod = 998244353\n\ns = []\nfor i in range(k):\n s.append(list(map(int,input().split())))\n\ncnt = [0]*n\ncnt[0] = 1\nsum = [0]*n\nsum[0] = 1\nfor i in range(1,n):\n for j in range(k):\n if i > s[j][1]:\n cnt[i] += sum[i-s[j][0]] - sum[i-s[j][1]-1]\n elif i >= s[j][0]:\n cnt[i] += sum[i-s[j][0]]\n cnt[i] %= mod\n sum[i] = (sum[i-1] + cnt[i]) % mod\n\nprint(cnt[-1])", "neg": "#dp\u3067\u7d20\u76f4\u306b\u3084\u308b\u3068O(N^2)\u3060\u304b\u3089\u3001\u7d2f\u7a4d\u548c\u3067\u9ad8\u901f\u5316\u3057O(KN)\u306b\u3059\u308b\n\nn, k = map(int,input().split())\nmod = 998244353\n\ns = []\nfor i in range(k):\n s.append(list(map(int,input().split())))\n\ncnt = [0]*n\ncnt[0] = 1\nsum = [0]*n\nsum[0] = 1\nfor i in range(1,n):\n for j in range(k):\n if i > s[j][1]:\n cnt[i] += (sum[i-s[j][0]] - sum[i-s[j][1]-1]) % mod\n elif i >= s[j][0]:\n cnt[i] += sum[i-s[j][0]] % mod\n sum[i] = (sum[i-1] + cnt[i]) % mod\n\nprint(cnt[-1])", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [287, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u469254913", "n_user": "u469254913", "pos": "# import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n# sys.setrecursionlimit(10000)\n# from numba import njit,i8\n \n \n# @njit(i8(i8,i8,i8,i8[:,:],i8[:],i8,i8))\ndef give_dp(N,K,mod,LR,dp,l,r):\n for i in range(N):\n if i > 0:\n dp[i] += dp[i-1]\n dp[i] %= mod\n for k in range(K):\n l = LR[k][0]\n r = LR[k][1]\n if i + l < N:\n dp[i+l] += dp[i]\n dp[i+1] %= mod\n if i + r + 1 < N:\n dp[i+r+1] -= dp[i]\n dp[i+1] %= mod\n return dp[-1]\n \n \ndef main():\n N,K = map(int,input().split())\n LR = [list(map(int,input().split())) for i in range(K)]\n # LR = np.array(LR)\n \n mod = 998244353\n \n dp = [0 for i in range(N)]\n dp[0] = 1\n dp[1] = -1\n # dp = np.array(dp)\n \n res = give_dp(N,K,mod,LR,dp,0,0)\n res %= mod\n \n print(res)\n \n \n \nmain()", "neg": "# import numpy as np\n# import math\n# import copy\n# from collections import deque\nimport sys\ninput = sys.stdin.readline\n# sys.setrecursionlimit(10000)\n# from numba import njit,i8\n\n\n# @njit(i8(i8,i8,i8,i8[:,:],i8[:],i8,i8))\ndef give_dp(N,K,mod,LR,dp,l,r):\n for i in range(N):\n if i > 0:\n dp[i] += dp[i-1]\n dp[i] %= mod\n for k in range(K):\n l = LR[k][0]\n r = LR[k][1]\n if i + l < N:\n dp[i+l] += dp[i]\n dp[i+1] %= mod\n if i + r < N:\n dp[i+r+1] -= dp[i]\n dp[i+1] %= mod\n return dp[-1]\n\n\ndef main():\n N,K = map(int,input().split())\n LR = [list(map(int,input().split())) for i in range(K)]\n # LR = np.array(LR)\n\n mod = 998244353\n\n dp = [0 for i in range(N)]\n dp[0] = 1\n dp[1] = -1\n # dp = np.array(dp)\n\n res = give_dp(N,K,mod,LR,dp,0,0)\n res %= mod\n\n print(res)\n\n\n\nmain()\n", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [406, 402], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u222668979", "n_user": "u222668979", "pos": "n, k = map(int, input().split())\nlr = [list(map(int, input().split())) for _ in range(k)]\nmod = 998244353\n\ndp = [0] * (n + 1)\nacc = [0] * (n + 1)\ndp[1], acc[1] = 1, 1\nfor i in range(2, n + 1):\n for l, r in lr:\n dp[i] += acc[max(i - l, 0)]\n dp[i] -= acc[max(i - (r + 1), 0)]\n dp[i] %= mod\n acc[i] = (dp[i] + acc[i - 1]) % mod\nprint(dp[n])\n", "neg": "n, k = map(int, input().split())\nlr = [list(map(int, input().split())) for _ in range(k)]\nmod = 998244353\n\ns = []\nfor l, r in lr:\n s += [i for i in range(l, r + 1)]\n\ndp = [0] * (n + 1)\ndp[1] = 1\nfor i in range(2, n + 1):\n for j in s:\n dp[i] += dp[max(i - j, 0)]\n dp[i] %= mod\nprint(dp)\n", "jacc_sim": 0.9210526315789473, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [176, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u364027015", "n_user": "u364027015", "pos": "N, K = map(int, input().split())\nL=[]\nR=[]\nfor i in range(K):\n l,r= map(int, input().split())\n L.append(l)\n R.append(r)\n\ndp=[0]*N\ndp[0]=1\ndpc=[0]*(N+1)\ndpc[1]=1\n\nfor i in range(N):\n for j in range(K):\n dp[i]+=dpc[max(i-L[j]+1,0)]-dpc[max(i-R[j],0)]\n dp[i]%=998244353\n dpc[i+1]=dpc[i]+dp[i]\n\nprint(dp[N-1])", "neg": "N, K = map(int, input().split())\nL=[]\nR=[]\nfor i in range(K):\n l,r= map(int, input().split())\n L.append(l)\n R.append(r)\n\ndp=[0]*N\ndp[0]=1\ndpc=[0]*(N+1)\ndpc[1]=1\n\nfor i in range(N):\n for j in range(K):\n dp[i]+=dpc[max(i-L[j]+1,0)]-dpc[max(i-R[j],0)]\n dpc[i+1]=dpc[i]+dp[i]\n\nprint(dp[N-1])", "jacc_sim": 0.9428571428571428, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [188, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u152741807", "n_user": "u152741807", "pos": "n,k = (int(x) for x in input().split())\nlr = []\nfor _ in range(k):\n l,r = (int(x) for x in input().split())\n lr.append((l,r))\nlr.sort()\n\nmod = 998244353\n\ndp= [0]*(n+1)\ndp[1] = 1\n\nfor i in range(2,n+1):\n cnt = 0\n for l,r in lr:\n if l >= i:\n break\n else:\n cnt += dp[i-l] - dp[max(0,i-r-1)]\n dp[i] = (dp[i-1] + cnt) % mod\n\nprint(cnt%mod)", "neg": "n,k = (int(x) for x in input().split())\nlr = []\nfor _ in range(k):\n l,r = (int(x) for x in input().split())\n lr.append((l,r))\nlr.sort()\nprint(lr)\n\nmod = 998244353\n\ndp= [0]*(n+1)\ndp[1] = 1\n\nfor i in range(2,n+1):\n cnt = 0\n for l,r in lr:\n if l >= i:\n break\n else:\n cnt += dp[i-l] - dp[max(0,i-r-1)]\n dp[i] = (dp[i-1] + cnt) % mod\n\nprint(cnt%mod)", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [181, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u794448346", "n_user": "u794448346", "pos": "N,K = map(int,input().split())\nLR = [list(map(int,input().split())) for i in range(K)]\nLR.sort()\nmod = 998244353\nma = [0] * N\nma[0] = 1\nfor i in range(N):\n if i >1:\n ma[i] += ma[i-1]\n p = ma[i]%mod\n if p != 0:\n for l,r in LR:\n if i+l 0: dp[i] += cs[i-pts[0]] \n if i - pts[1] > 0: dp[i] -= cs[i-(pts[1] + 1)] \n dp[i] = dp[i] % CON\n cs[i] = (cs[i-1] + dp[i]) % CON\n\n print(dp[N])\n\nsolve()", "neg": "import math\n\nCON = 998244353\n\nN, K = list(map(int,input().split()))\nLR = [list(map(int,input().split())) for _ in range(K)]\n\ndp = [0] * (N + 1)\ncs = [0] * (N + 1)\n\ndef solve():\n dp[1] = 1\n cs[1] = 1\n\n for i in range(2, N + 1):\n for pts in LR:\n if i - pts[0] > 0: dp[i] += cs[i-pts[0]] \n if i - pts[1] > 0: dp[i] -= cs[i-pts[1]] \n dp[i] = dp[i] % CON\n cs[i] = (cs[i-1] + dp[i]) % CON\n\n print(dp[N])\n\nsolve()", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [220, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u711539583", "n_user": "u711539583", "pos": "n, k = map(int, input().split())\ncum = [0, 1]\ndp = [0, 1]\n\nlr = [list(map(int, input().split())) for _ in range(k)] \nmod = 998244353\n# i: \u76ee\u6a19\u306e\u30de\u30b9\ndef check(i):\n res = 0\n for l, r in lr:\n if i - l < 1:\n continue\n res += cum[i-l] - cum[max(i-r-1,0)]\n res %= mod\n return res\n\n\nfor i in range(2,n+1):\n dp.append(check(i))\n cum.append((cum[-1]+dp[-1])%mod)\n\nprint(dp[-1])", "neg": "n, k = map(int, input().split())\ncum = [0, 1]\ndp = [0, 1]\n\nlr = [list(map(int, input().split())) for _ in range(k)] \nmod = 998244353\n# i: \u76ee\u6a19\u306e\u30de\u30b9\ndef check(i):\n res = 0\n for l, r in lr:\n if i - l < 1:\n break\n res += cum[i-l] - cum[max(i-r-1,0)]\n res %= mod\n return res\n\n\nfor i in range(2,n+1):\n dp.append(check(i))\n cum.append((cum[-1]+dp[-1])%mod)\n\nprint(dp[-1])", "jacc_sim": 0.96, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [194, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u629454253", "n_user": "u629454253", "pos": "MOD = 998244353\n\nN, K = map(int, input().split())\nseg = [tuple(map(int, input().split())) for _ in range(K)]\ndp = [0] * (N+1)\ndp[0] = 1\nfor i in range(N):\n for s, t in seg:\n if (i+s) <= N:dp[i+s] += dp[i]\n if (i+t+1) <= N:dp[i+t+1] -= dp[i]\n dp[0] = 0\n dp[i+1] += dp[i]\n dp[i+1] %= MOD\n \nprint(dp[N-1])", "neg": "MOD = 998244353\n\nN, K = map(int, input().split())\nseg = [tuple(map(int, input().split())) for _ in range(K)]\ndp = [0] * (N+1)\ndp[0] = 1\nfor i in range(N):\n for s, t in seg:\n dp[i+s] += dp[i]\n dp[i+t;1] -= dp[i]\n dp[i+1] += dp[i]\n dp[i+1] %= MOD\n \nprint(dp[N-1])\n", "jacc_sim": 0.9166666666666666, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [170, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u952708174", "n_user": "u952708174", "pos": "def d_leaping_tak(MOD=998244353):\n from bisect import bisect_left, bisect_right\n N, K = [int(i) for i in input().split()]\n Ranges = sorted([[int(i) for i in input().split()] for j in range(K)])\n\n dp = [0] * (N + 1) # dp[i]: \u30de\u30b9 i \u3078\u306e\u884c\u304d\u65b9\n dp[1] = 1\n cumsum_dp = dp[:]\n for i in range(2, N + 1):\n for l, r in Ranges:\n if i - l < 0:\n continue\n if i - r < 0:\n r = i\n\n dp[i] += cumsum_dp[i - l] - cumsum_dp[i - r - 1]\n dp[i] %= MOD\n cumsum_dp[i] = cumsum_dp[i - 1] + dp[i]\n # print(dp)\n # print(cumsum_dp)\n return dp[N]\n\nprint(d_leaping_tak())", "neg": "def d_leaping_tak(MOD=998244353):\n from bisect import bisect_left, bisect_right\n N, K = [int(i) for i in input().split()]\n Ranges = sorted([[int(i) for i in input().split()] for j in range(K)])\n\n dp = [0] * (N + 1) # dp[i]: \u30de\u30b9 i \u3078\u306e\u884c\u304d\u65b9\n dp[1] = 1\n cumsum_dp = dp[:]\n for i in range(2, N + 1):\n for l, r in Ranges:\n if i - l < 0:\n continue\n if i - r < 0:\n r = i\n\n dp[i] += cumsum_dp[i - l] - cumsum_dp[i - r - 1]\n dp[i] %= MOD\n cumsum_dp[i] = cumsum_dp[i - 1] + dp[i]\n\nprint(d_leaping_tak())", "jacc_sim": 0.9811320754716981, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [280, 256], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u632395989", "n_user": "u632395989", "pos": "N, K = map(int, input().split())\nS = []\nfor j in range(K):\n S.append(list(map(int, input().split())))\n\nm = 998244353\n\n# print(S)\n\ndp = [0] * N\ndp[0] = 1\nsum_of_region = [0] * K\nfor i in range(1, N):\n for j in range(K):\n if i - S[j][0] >= 0:\n sum_of_region[j] += dp[i - S[j][0]]\n if i - S[j][1] - 1 >= 0:\n sum_of_region[j] -= dp[i - S[j][1] - 1]\n dp[i] += sum_of_region[j] % m\n dp[i] %= m\n # print(i, dp, sum_of_region)\n\nans = dp[N - 1]\nprint(ans)\n", "neg": "N, K = map(int, input().split())\nS = []\nfor j in range(K):\n S.append(list(map(int, input().split())))\n\nm = 998244353\n\nprint(S)\n\ndp = [0] * N\ndp[0] = 1\nsum_of_region = [0] * K\nfor i in range(1, N):\n for j in range(K):\n if i - S[j][0] >= 0:\n sum_of_region[j] += dp[i - S[j][0]]\n if i - S[j][1] - 1 >= 0:\n sum_of_region[j] -= dp[i - S[j][1] - 1]\n dp[i] += sum_of_region[j] % m\n dp[i] %= m\n print(i, dp, sum_of_region)\n\nans = dp[N - 1]\nprint(ans)\n", "jacc_sim": 0.972972972972973, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [237, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u052499405", "n_user": "u052499405", "pos": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nMOD = 998244353\n\nn, k = map(int, input().split())\ndp = [0] * n\ndp[0] = 1\ndp[1] = -1\ndelta = []\nfor _ in range(k):\n l, r = map(int, input().split())\n delta.append((l, 1))\n delta.append((r+1, -1))\n\ntotal = 0\nfor i in range(n):\n total += dp[i]\n total %= MOD\n for p, d in delta:\n if i + p >= n:\n continue\n dp[i + p] += total * d\n dp[i + p] %= MOD\nprint(total % MOD)", "neg": "#!/usr/bin/env python3\nimport sys\ninput = sys.stdin.readline\nMOD = 998244353\n\nn, k = map(int, input().split())\ndp = [0] * n\ndp[0] = 1\ndp[1] = -1 % MOD\ndelta = []\nfor _ in range(k):\n l, r = map(int, input().split())\n delta.append((l, 1))\n delta.append((r+1, -1 % MOD))\n\ntotal = 0\nfor i in range(n):\n total += dp[i]\n total %= MOD\n for p, d in delta:\n if i + p >= n:\n break\n dp[i + p] += total * d\n dp[i + p] %= MOD\nprint(total % MOD)", "jacc_sim": 0.9607843137254902, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [193, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u368796742", "n_user": "u368796742", "pos": "mod = 998244353\nn,k = map(int,input().split())\nK = [list(map(int,input().split())) for i in range(k)]\n\ndp = [0]*(n+5)\ndp[1] = 1\ndp2 = [0]*(n+5)\nfor i in range(1,n+1):\n dp[i] = (dp[i]+dp2[i]+dp2[i-1])%mod\n dp2[i] = (dp2[i]+dp2[i-1])%mod\n for l,r in K:\n dp2[min(i+l,n+2)] += dp[i]\n dp2[min(i+l,n+2)] %= mod\n dp2[min(i+r+1,n+2)] -= dp[i]\n dp2[min(i+r+1,n+2)] %= mod\nprint(dp[n]%mod)\n", "neg": "mod = 998244353\nn,k = map(int,input().split())\nK = [list(map(int,input().split())) for i in range(k)]\n\ndp = [0]*(n+1)\ndp[0] = 1\ndp2 = [0]*(n+1)\nfor i in range(n):\n dp[i] = (dp[i]+dp2[i]+dp2[i-1])%mod\n dp2[i] = (dp2[i]+dp2[i-1])%mod\n for l,r in K:\n dp2[min(i+l,n)] = (dp[i]+dp2[min(i+l,n)])%mod\n dp2[min(i+r+1,n)] = (dp[i]+dp2[min(i+r+1,n)])%mod\nprint(dp[n-1]%mod)\n", "jacc_sim": 0.9444444444444444, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [233, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02549", "p_user": "u111365362", "n_user": "u111365362", "pos": "n,k = map(int,input().split())\nlr = []\nfor _ in range(k):\n lr.append(list(map(int,input().split())))\n#print(lr)\nimos = [0 for _ in range(n)]\nimos[0] = 1\nimos[1] = -1\nnow = 0\nmod = 998244353\nfor i in range(n):\n now += imos[i]\n now %= mod\n #print(now)\n for j in range(k):\n try:\n imos[i+lr[j][0]] += now\n imos[i+lr[j][0]] %= mod\n except:\n pass\n try:\n imos[i+lr[j][1]+1] -= now\n imos[i+lr[j][1]+1] %= mod\n except:\n pass\n #print(imos)\nprint(now)", "neg": "n,k = map(int,input().split())\nlr = []\nfor _ in range(k):\n lr.append(list(map(int,input().split())))\nprint(lr)\nimos = [0 for _ in range(n)]\nimos[0] = 1\nimos[1] = -1\nnow = 0\nmod = 998244353\nfor i in range(n):\n now += imos[i]\n now %= mod\n #print(now)\n for j in range(k):\n try:\n imos[i+lr[j][0]] += now\n imos[i+lr[j][0]] %= mod\n except:\n pass\n try:\n imos[i+lr[j][1]+1] -= now\n imos[i+lr[j][1]+1] %= mod\n except:\n pass\n #print(imos)\nprint(now)", "jacc_sim": 1.0, "nl": "Tak is on Cell 1 and wants to reach Cell N. Given K non-intersecting segments, Tak can move from Cell i to i+d, where d is an integer from the union of these segments. Find the number of ways for Tak to reach Cell N, modulo 998244353. Constraints: 2 \u2264 N \u2264 2 \u00d7 10^5, 1 \u2264 K \u2264 min(N, 10), 1 \u2264 Li \u2264 Ri \u2264 N, non-intersecting segments. Input format: N K L1 R1 L2 R2 ... LK RK. Output the number of ways to reach Cell N. Examples: (5 2, 1 1 3 4) \u2192 4, (5 2, 3 3 5 5) \u2192 0, (5 1, 1 2) \u2192 5, (60 3, 5 8 1 3 10 15) \u2192 221823067 (mod 998244353).", "before_after_length": [227, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02551", "p_user": "u793981991", "n_user": "u793981991", "pos": "import os\nimport io\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\nn, q = list(map(int, input().split()))\ncount = (n - 2) ** 2\nc = [n] * (n + 1)\nr = [n] * (n + 1)\nmc = n\nmr = n\nfor _ in range(q):\n m,q = list(map(int, input().split()))\n if m == 1:\n if q <= mc:\n count -= mr -2\n for p in range(q+1, mc):\n c[p] = mr\n c[q] = 0\n mc = q\n else:\n count -= c[q] - 2\n else:\n if q <= mr:\n count -= mc -2\n for p in range(q+1, mr):\n r[p] = mc\n r[q] = 0\n mr = q\n else:\n count -= r[q] - 2\nprint(count)\n", "neg": "import os\nimport io\ninput = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\nn, q = list(map(int, input().split()))\ncount = (n - 2) ** 2\nc = [n] * n\nr = [n] * n\nmc = n\nmr = n\nfor _ in range(q):\n m,q = list(map(int, input().split()))\n if m == 1:\n if q <= mc:\n count -= mr -2\n for p in range(q+1, mc):\n c[p] = mr\n c[q] = 0\n mc = q\n else:\n count -= c[q-1] - 2\n else:\n if q <= mr:\n count -= mc -2\n for p in range(q+1, mr):\n r[p] = mc\n r[q] = 0\n mr = q\n else:\n count -= r[q-1] - 2\nprint(count)\n", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares. Each of the central (N-2) x (N-2) squares has a black stone, while the 2N - 1 squares on the bottom and right sides have white stones. Q queries are given, each with two types: placing a white stone and updating the grid accordingly. After processing all Q queries, determine the number of black stones on the grid. Constraints: 3 \u2264 N \u2264 2x10^5, 0 \u2264 Q \u2264 min(2N-4, 2x10^5), 2 \u2264 x \u2264 N-1. The input format is N, Q, followed by the queries. Output the number of black stones after processing all queries.", "before_after_length": [259, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02551", "p_user": "u983853152", "n_user": "u983853152", "pos": "N,Q = map(int, input().split())\nANS = (N-2)**2\nR,C=N,N\nRLEN=[]\nCLEN=[]\nfor i in range(Q):\n RC,num = map(int, input().split())\n if RC==1:\n if R>num:\n for j in range(R-num):\n RLEN.append(C)\n ANS-=C-2\n R=num\n else:\n if len(RLEN)>0:\n ANS-=RLEN[N-num-1]-2\n else:\n ANS-=R-2\n else:\n if C>num:\n for j in range(C-num):\n CLEN.append(R)\n ANS-=R-2\n C=num\n else:\n if len(CLEN)>0:\n ANS-=CLEN[N-num-1]-2\n else:\n ANS-=C-2\n\nprint(ANS)\n\n", "neg": "N,Q = map(int, input().split())\nANS = (N-2)**2\nR,C=N,N\nRLEN=[]\nCLEN=[]\nfor i in range(Q):\n RC,num = map(int, input().split())\n if RC==1:\n if R>num:\n for j in range(R-num-2):\n RLEN.append(C)\n ANS-=C-2\n R=num\n else:\n if len(RLEN)>0:\n ANS-=RLEN[N-num-1]-2\n else:\n ANS-=R-2\n else:\n if C>num:\n for j in range(C-num-2):\n CLEN.append(R)\n ANS-=R-2\n C=num\n else:\n if len(CLEN)>0:\n ANS-=CLEN[N-num-1]-2\n else:\n ANS-=C-2\n\nprint(ANS)\n\n", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares. Each of the central (N-2) x (N-2) squares has a black stone, while the 2N - 1 squares on the bottom and right sides have white stones. Q queries are given, each with two types: placing a white stone and updating the grid accordingly. After processing all Q queries, determine the number of black stones on the grid. Constraints: 3 \u2264 N \u2264 2x10^5, 0 \u2264 Q \u2264 min(2N-4, 2x10^5), 2 \u2264 x \u2264 N-1. The input format is N, Q, followed by the queries. Output the number of black stones after processing all queries.", "before_after_length": [253, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02551", "p_user": "u785573018", "n_user": "u785573018", "pos": "n, q = map(int, input().split())\nl = [0]*n; u = [0]*n; lmin = n-2; umin = n-2; lgoal = n; ugoal = n\nfor _ in range(q):\n s, t = map(int, input().split())\n if s == 1:\n if t > ugoal: u[t-1] = 0\n else:\n for i in range(t, ugoal-1):u[i] = umin\n lmin = t-2; ugoal = t\n else:\n if t > lgoal: l[t-1] = 0\n else:\n for i in range(t, lgoal-1):l[i] = lmin\n umin = t-2; lgoal = t\nprint(sum(l)+sum(u)+lmin*umin)", "neg": "n, q = map(int, input().split())\nl = [0]*n; u = [0]*n; lmin = n-2; umin = n-2; lgoal = n; ugoal = n\nfor _ in range(q):\n s, t = map(int, input().split())\n if s == 1:\n if t > ugoal+1: u[t-1] = 0\n else:\n for i in range(t, ugoal-1):u[i] = umin\n lmin = t-2; ugoal = t\n else:\n if t > lgoal+1: l[t-1] = 0\n else:\n for i in range(t, lgoal-1):l[i] = lmin\n umin = t-2; lgoal = t\nprint(sum(l)+sum(u)+lmin*umin)", "jacc_sim": 1.0, "nl": "You are given a grid with N rows and N columns of squares. Each of the central (N-2) x (N-2) squares has a black stone, while the 2N - 1 squares on the bottom and right sides have white stones. Q queries are given, each with two types: placing a white stone and updating the grid accordingly. After processing all Q queries, determine the number of black stones on the grid. Constraints: 3 \u2264 N \u2264 2x10^5, 0 \u2264 Q \u2264 min(2N-4, 2x10^5), 2 \u2264 x \u2264 N-1. The input format is N, Q, followed by the queries. Output the number of black stones after processing all queries.", "before_after_length": [207, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u591143370", "n_user": "u591143370", "pos": "N=int(input())\na = list(map(int, input().split()))\n\ndp=[[0 for i in range(N+1)] for j in range(N+1)]\nfor i in range(1,N+1):\n dp[i][i]=a[i-1]\nfor j in range(1,N+1):\n for i in reversed(range(1,N+1)):\n if i>j:\n continue\n if i==j:\n dp[i][j]=a[i-1]\n if ij:\n continue\n if i==j:\n dp[i][j]=a[i-1]\n if i N:\n continue\n elif (N-w) % 2 == 0:#\u592a\u90ce\n dp[l][r] = max(dp[l+1][r] + A[l], dp[l][r-1] + A[r-1])\n elif (N-w) % 2 == 1:#\u6b21\u90ce\n dp[l][r] = min(dp[l+1][r] - A[l], dp[l][r-1] - A[r-1])\n \nprint(dp[0][N])", "neg": "N = int(input())\nA = list(map(int,input().split()))\nA = [0]\ndp = [[0] * (N+1) for _ in range(N+1)]\n\n#\u534a\u958b\u533a\u9593\u3067\u8003\u3048\u308b\u21d2[i,j)\u3067\u306e\u6700\u9069\u89e3\nfor w in range(1,N+1):#\u533a\u9593\u306e\u6b8b\u308a\u6570\n for l in range(N):# \u5de6\u7aef\n r = l + w#\u53f3\u7aef\n if r > N:\n continue\n elif (N-k) % 2 == 0:#\u592a\u90ce\n #print(i,x)\n dp[l][x] = max(dp[l+1][x] + A[l], dp[l][r-1] + A[r-1])\n elif (N-k) % 2 == 1:#\u6b21\u90ce\n #print(i,x)\n dp[l][x] = min(dp[l+1][x] - A[l], dp[l][r-1] - A[r-1])\n \nprint(dp)", "jacc_sim": 0.96875, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [290, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u263753244", "n_user": "u263753244", "pos": "n=int(input())\na=list(map(int,input().split()))\ndp=[[float(\"inf\")]*(n+1) for _ in range(n)]\nz=0\nfor l in range(n):\n dp[l][l]=0\nfor k in range(1,n+1):\n for i in range(n):\n j=i+k\n if 0<=i<=n-2 and 1<=j<=n:\n if (n-(i+j))%2==0: #\u5148\u624b\n dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1])\n else:\n dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])\n elif 0<=i<=n-2 and 0<=j<=n:\n dp[i][j]=dp[i+1][j]+a[i]\n elif 0<=i<=n-1 and 1<=j<=n:\n dp[i][j]=dp[i][j-1]+a[j-1]\n else:\n z=1\n\nprint(dp[0][n])", "neg": "n=int(input())\na=list(map(int,input().split()))\ndp=[[float(\"inf\")]*(n+1) for _ in range(n+1)]\nz=0\nfor l in range(n):\n dp[l][l]=0\n\nfor k in range(1,n+1):\n for i in range(n-k+1):\n j=i+k\n \n if (n-(i+j))%2==0: #\u5148\u624b\n dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1])\n else:\n dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])\nprint(dp[0][n])", "jacc_sim": 0.9347826086956522, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [320, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u769640830", "n_user": "u769640830", "pos": "import sys\n\ndef f(l,beg,end):\n if beg==end:\n dp[beg][end]=l[beg]\n return l[beg]\n if beg+1==end:\n dp[beg][end] = max(l[beg],l[end]) \n return max(l[beg],l[end])\n if dp[beg][end]!=-1:\n return dp[beg][end]\n ans1=l[beg]+min(f(l,beg+2,end),f(l,beg+1,end-1))\n ans2=l[end]+min(f(l,beg,end-2),f(l,beg+1,end-1))\n dp[beg][end]=max(ans1,ans2)\n return max(ans1,ans2)\n\nn = int(input())\nl = list(map(int, input().split()))\ntl = sum(l)\ndp=[]\nfor _ in range(n):\n dp.append([-1]*n)\na = f(l,0,n-1)\nb = tl-a\nprint(a-b)", "neg": "def f(l,beg,end):\n if beg>=end:\n return 0\n if dp[beg][end]!=-1:\n return dp[beg][end]\n ans1=l[beg]+min(f(l,beg+2,end),f(l,beg+1,end-1))\n ans2=l[end]+min(f(l,beg,end-2),f(l,beg+1,end-1))\n dp[beg][end]=max(ans1,ans2)\n return max(ans1,ans2)\n\nn = int(input())\nl = list(map(int, input().split()))\ntl = sum(l)\ndp=[]\nfor _ in range(n):\n dp.append([-1]*n)\na = f(l,0,n-1)\nb = tl-a\nprint(a-b)", "jacc_sim": 0.9347826086956522, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [290, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u069347602", "n_user": "u069347602", "pos": "import sys\nn=int(sys.stdin.readline())\na=list(map(int,sys.stdin.readline().split()))\ndp=[[0 for i in range(n)] for j in range(n)]\nfor i in range(n):\n dp[i][i]=a[i]\nfor i in range(2,n+1):\n for j in range(n-i+1):\n k=j+i-1 \n dp[j][k]=max(a[k]-dp[j][k-1],a[j]-dp[j+1][k])\nprint(dp[0][len(a)-1])", "neg": "n=int(sys.stdin.readline())\na=list(map(int,sys.stdin.readline().split()))\ndp=[[0 for i in range(n)] for j in range(n)]\nfor i in range(n):\n dp[i][i]=a[i]\nfor i in range(2,n+1):\n for j in range(n-i+1):\n k=j+i-1 \n dp[j][k]=max(a[k]-dp[j][k-1],a[j]-dp[j+1][k])\nprint(dp[0][len(a)-1])", "jacc_sim": 0.9696969696969697, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [157, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u707124227", "n_user": "u707124227", "pos": "n=int(input())\na=list(map(int,input().split()))\ndp=[[0]*n for _ in range(n)]\n# dp[i][j]:i<=j,i\u756a\u76ee\u304b\u3089j\u756a\u76ee\u307e\u3067\u306e\u6570\u5217(j-i+1\u500b)\u3092\u524d\u306b\u3057\u305f\u6642\u3001\u30b2\u30fc\u30e0\u7d42\u4e86\u307e\u3067\u306b\u81ea\u5206\u304c\u53d6\u308c\u308b\u6700\u5927\u5f97\u70b9\u3002i,j=0,..,n-1\nsa=[0]\ns=0\nfor ai in a:\n s+=ai\n sa.append(s)\nfor len in range(1,n+1):\n for l in range(n-len+1):\n r=l+len-1\n s=sa[r+1]-sa[l]\n dp[l][r]=max(s-dp[l][r-1],s-dp[l+1][r] if l+1 n:\n continue\n if (n - (r - l)) % 2 == 0:\n dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1])\n else:\n dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1])\n\nprint(dp[0][n])\n\n\n", "neg": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\na = [int(x) for x in input().split()]\n\ndp = [[0]*(n + 1) for _ in range(n + 1)]\n\nfor i in range(n + 1):\n dp[i][i] = 0\n\nfor width in range(1, n + 1):\n for l in range(n + 1):\n r = width + l\n if r <= l or r > n:\n continue\n if (r - l) % 2 == 1:\n dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1])\n else:\n dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1])\n\nprint(dp[0][n])\n\n\n", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [233, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u997641430", "n_user": "u419963262", "pos": "n = int(input())\n*A, = map(int, input().split())\nDP = [[0 for j in range(n+1)] for i in range(n+1)]\nfor l in range(1, n+1):\n for i in range(n-l+1):\n DP[i][i+l] = max(A[i]-DP[i+1][i+l], A[i+l-1]-DP[i][i+l-1])\nprint(DP[0][n])\n", "neg": "n = int(input())\n*A, = map(int, input().split())\nDP = [[0 for j in range(n+1)] for i in range(n+1)]\nfor l in range(1, n+1):\n for i in range(n-l+1):\n j = i+l\n DP[i][j] = max(A[i]-DP[i+1][j], A[j-1]-DP[i][j-1])\nprint(DP)", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [125, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u861075868", "n_user": "u861075868", "pos": "#dp=[[ for i in range(3000)] for j in range(3000)]\nn=int(input())\nA=list(int(i) for i in input().split())\ndp=[[0 for i in range(n)] for j in range(n)]\nfor i in range(n-1,-1,-1):\n for j in range(i,n):\n if i==j:\n dp[i][j]=A[i]\n else:\n dp[i][j]=max(A[i]-dp[i+1][j],A[j]-dp[i][j-1])\nprint(dp[0][-1])\n", "neg": "n=int(input())\nA=list(int(i) for i in input().split())\na=[0,0]\ndp=[[a for i in range(n)] for j in range(n)]\nfor i in range(n-1,-1,-1):\n for j in range(i,n):\n if i==j:\n dp[i][j][0]=A[i]\n dp[i][j][1]=-A[i]\n else:\n dp[i][j][0]=max(A[i]+dp[i+1][j][1],A[j]+dp[i][j-1][1])\n dp[i][j][1]=-dp[i][j][0]\n#print(dp[0][-1][0])\nprint(dp)\n", "jacc_sim": 0.9354838709677419, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [161, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u945181840", "n_user": "u945181840", "pos": "import sys\n\nread = sys.stdin.read\nsys.setrecursionlimit(10 ** 7)\n\n\ndef solve():\n n, *a = map(int, read().split())\n a = tuple(a)\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n for i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n L = a[i] - dp[i + 1][j]\n R = a[j] - dp[i][j - 1]\n if L > R:\n dp[i][j] = L\n else:\n dp[i][j] = R\n return dp[0][n - 1]\n\n\nprint(solve())\n", "neg": "import sys\n\nread = sys.stdin.read\nsys.setrecursionlimit(10 ** 7)\n\n\ndef solve():\n n, *a = map(int, read().split())\n a = tuple(a)\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n for i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n L = a[i] - dp[i + 1][j]\n R = a[j] - dp[i][j - 1]\n if L > R:\n dp[i][j] = L\n else:\n dp[i][j] = R\n for i in dp:\n print(i)\n return dp[0][n - 1]\n\n\nprint(solve())\n", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [203, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u123756661", "n_user": "u123756661", "pos": "n=int(input())\na=[int(i) for i in input().split()]\ndp=[[0]*(n+1) for i in range(n+1)]\n\nfor w in range(1,n+1):\n#for w in range(1,3,1):\n# print(dp[1])\n for l in range(n-w+1):\n r=l+w\n dpl=-dp[l+1][r]+a[l]\n dpr=-dp[l][r-1]+a[r-1]\n dp[l][r]=max(dpl,dpr)\n#print()\n#for i in dp:\n# print(i)\nprint(dp[0][n])", "neg": "n=int(input())\na=[int(i) for i in input().split()]\n#dp=[[0]*(n+1) for i in range(n+1)]\ndp=[[0]*(n+1) for i in range(n)]\n\nfor w in range(1,n+1):\n#for w in range(1,3,1):\n# print(dp[1])\n for l in range(n-w+1):\n print(\"#\",l)\n r=l+w\n dpl=-dp[l+1][r]+a[l]\n dpr=-dp[l][r-1]+a[r-1]\n dp[l][r]=max(dpl,dpr)\n#print()\n#for i in dp:\n# print(i)\nprint(dp[0][n])\n", "jacc_sim": 0.9696969696969697, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [176, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u221301671", "n_user": "u221301671", "pos": "import numpy as np\n\nn = int(input())\na = np.array([int(i) for i in input().split()], dtype=np.int64)\n\ns = np.copy(a)\nfor i in range(1, n):\n s = np.maximum(a[:n-i]-s[1:n-i+1], a[i:]-s[:n-i])\n\nprint(s[0])\n", "neg": "import numpy as np\n\nn = int(input())\na = np.array([int(i) for i in input().split()], dtype=np.int64)\n\ns = np.copy(a)\nfor i in range(1, n):\n s = np.maximum(a[:n-i]-s[1:n-i+1], a[i:]-s[:n-i])\n print(i, s)\n\nprint(s[0])\n", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [103, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u297801580", "n_user": "u297801580", "pos": "n = int(input())\na = tuple(map(int, input().split()))\ndp = [[0] * n for _ in range(n)]\nfor i in range(n):\n dp[i][i] = a[i]\n\nfor i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n\nprint(dp[0][n - 1])", "neg": "n = int(input())\na = tuple(map(int, input().split()))\ndp = [(0,) * n for _ in range(n)]\nfor i in range(n):\n dp[i][i] = a[i]\n\nfor i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n\nprint(dp[0][n - 1])", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [135, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u297801580", "n_user": "u297801580", "pos": "n = int(input())\na = list(map(int, input().split()))\n\ndef calc():\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n\n for i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n return dp\n\ndp = calc()\nprint(dp[0][n - 1])", "neg": "n = int(input())\na = list(map(int, input().split()))\n\ndef calc():\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n\n for i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n\ndp = calc()\nprint(dp[0][n - 1])", "jacc_sim": 0.9696969696969697, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [152, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u297801580", "n_user": "u297801580", "pos": "n = int(input())\na = list(map(int, input().split()))\n\ndp=[]\nfor i in range(n):\n\tdp.append([0]*n)\nfor i in range(n):\n dp[i][i] = a[i]\n\nfor i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n\nprint(dp[0][n - 1])", "neg": "n = int(input())\na = list(map(int, input().split()))\n\ndp=[]\nfor i in range(n):\n\tdp.append(0)\nfor i in range(n):\n dp[i][i] = a[i]\n\nfor i in range(n - 2, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])\n\nprint(dp[0][n - 1])", "jacc_sim": 0.9666666666666667, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [143, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u353797797", "n_user": "u844005364", "pos": "def kukan(n, a):\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n for i in range(n - 2, -1, -1):\n g0 = dp[i]\n g1 = dp[i + 1]\n for j in range(i + 1, n):\n L = a[i] - g1[j]\n R = a[j] - g0[j - 1]\n dp[i][j] = L if L > R else R\n return dp[0][n - 1]\n\n\nn = int(input())\na = list(map(int, input().split()))\nprint(kukan(n, a))\n", "neg": "def kukan(n, a):\n dp = [[0] * n for _ in range(n)]\n for i in range(n):\n dp[i][i] = a[i]\n for i in range(n - 2, -1, -1):\n g0 = dp[i]\n g1 = dp[i + 1]\n for j in range(i + 1, n):\n L = a[i] - g1[j]\n R = a[j] - g0[j - 1]\n dp[i][j] = L if L > R else R\n print(*dp,sep=\"\\n\")\n return dp[0][n - 1]\n\n\nn = int(input())\na = list(map(int, input().split()))\nprint(kukan(n, a))", "jacc_sim": 0.9285714285714286, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [189, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u147077748", "n_user": "u787059958", "pos": "import sys\n# input\u51e6\u7406\u3092\u9ad8\u901f\u5316\u3059\u308b\ninput = sys.stdin.readline\n\ndef chmax(a, b):\n if a >= b:\n return a\n return b\n\ndef chmin(a, b):\n if a <= b:\n return a\n return b\n\ndef main():\n N = int(input())\n a = list(map(int, input().split()))\n\n # ai\u304b\u3089aj\u306eX\u2212Y\u306e\u6700\u5927\u5024\n # [\u5de6\u7aef,\u53f3\u7aef)=[l,r)\u304b\u3089\u306e\u9077\u79fb \n # \u5de6\u3092\u3068\u308b[l+1,r)\u3001\u53f3\u3092\u3068\u308b[l,r\u22121)\u306e2\u901a\u308a\n dp = [[0] * (N+2) for _ in range(N+2)]\n\n for len in range(1, N + 1):\n for i in range(N + 1 - len):\n j = i + len\n\n if (N - len) % 2 == 0:\n dp[i][j] = chmax(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])\n else:\n dp[i][j] = chmin(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])\n\n print(dp[0][N])\n\nmain()", "neg": "import sys\n# input\u51e6\u7406\u3092\u9ad8\u901f\u5316\u3059\u308b\ninput = sys.stdin.readline\ndef chmax(a, b):\n if a >= b:\n return a\n return b\ndef chmin(a, b):\n if a <= b:\n return a\n return b\ndef main():\n N = int(input())\n a = list(map(int, input().split()))\n # ai\u304b\u3089aj\u306eX\u2212Y\u306e\u6700\u5927\u5024\n # [\u5de6\u7aef,\u53f3\u7aef)=[l,r)\u304b\u3089\u306e\u9077\u79fb \n # \u5de6\u3092\u3068\u308b[l+1,r)\u3001\u53f3\u3092\u3068\u308b[l,r\u22121)\u306e2\u901a\u308a\n dp = [[0] * (N+1) for _ in range(N+1)]\n print(dp)\n for len in range(1, N + 1):\n for i in range(N + 1 - len):\n j = i + len\n if (N - len) % 2 == 0:\n dp[i][j] = chmax(dp[i + 1][j] + a[i], dp[i][j - 1] + a[j - 1])\n else:\n dp[i][j] = chmin(dp[i + 1][j] - a[i], dp[i][j - 1] - a[j - 1])\n print(dp)\n print(dp[0][N])\nmain()", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [414, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03171", "p_user": "u729972685", "n_user": "u729972685", "pos": "from sys import stdin\ninput = stdin.readline\n\nN = int(input())\na = list(map(int, input().split()))\n\ndp = [[0] * (N + 1) for _ in range(N + 1)]\n\nfor i in range(N):\n dp[i][i + 1] = a[i] if N & 1 == 1 else -a[i]\n\nfor j in range(2, N + 1):\n for i in range(0, N + 1 - j):\n # j is the length of the interval + 1\n if (N - j) & 1 == 0:\n dp[i][i + j] = max(a[i] + dp[i + 1][i + j],\n a[i + j - 1] + dp[i][i + j - 1])\n else:\n dp[i][i + j] = min(dp[i + 1][i + j] - a[i],\n dp[i][i + j - 1] - a[i + j - 1])\n\nprint(dp[0][N])\n", "neg": "from sys import stdin\ninput = stdin.readline\n\nN = int(input())\na = list(map(int, input().split()))\n\ndp = [[0] * (N + 1) for _ in range(N + 1)]\n\nfor i in range(N):\n dp[i][i + 1] = a[i] if N & 1 == 1 else -a[i]\n\nfor i in range(0, N - 1):\n for j in range(2, N + 1 - i): # j is the length of the interval\n if (N - j) & 1 == 0:\n dp[i][i + j] = max(a[i + 1] + dp[i + 1][i + j],\n a[i + j - 1] + dp[i][i + j - 1])\n else:\n dp[i][i + j] = min(dp[i + 1][i + j] - a[i + 1],\n dp[i][i + j - 1] - a[i + j - 1])\n\nprint(dp[0][N])", "jacc_sim": 1.0, "nl": "Taro and Jiro play a game with a given sequence of numbers. They take turns removing elements from the beginning or end of the sequence and earn points based on the removed element. Taro aims to maximize his total points minus Jiro's total points, while Jiro aims to minimize the difference. Given optimal play, find the resulting difference between Taro's and Jiro's total points. The input consists of the sequence length and the sequence itself. Output the resulting difference. All input values are integers, and the sequence length is between 1 and 3000, with each element in the sequence between 1 and 10^9. The output may not fit into a 32-bit integer type.", "before_after_length": [259, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u386195929", "n_user": "u386195929", "pos": "mod = 1000000007\nn, k = map(int, input().strip().split())\narr = list(map(int, input().strip().split()))\n\ndp = [[0 for i in range(n+1)] for i in range(k+2)]\n\nfor i in range(1, k+2):\n dp[i][0] = 1\n\nfor i in range(1, k+2):\n for j in range(1, n+1):\n K = i-1\n if K < arr[j-1]:\n dp[i][j] = dp[i-1][j] + dp[i][j-1]-dp[0][j-1]\n else:\n dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-arr[j-1]-1][j-1]\n \n dp[i][j] %= mod\n\n\nprint((dp[-1][-1]-dp[-2][-1] + mod)%mod)", "neg": "n, k = map(int, input().strip().split())\narr = list(map(int, input().strip().split()))\n\ndp = [[0 for i in range(n+1)] for i in range(k+2)]\n\nfor i in range(1, k+2):\n dp[i][0] = 1\n\nfor i in range(1, k+2):\n for j in range(1, n+1):\n K = i-1\n if K < arr[j-1]:\n dp[i][j] = dp[i-1][j] + dp[i][j-1]-dp[0][j-1]\n else:\n dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-arr[j-1]-1][j-1]\n \n\nprint(dp[-1][-1]-dp[-2][-1])", "jacc_sim": 0.9166666666666666, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [248, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u788260274", "n_user": "u788260274", "pos": "from sys import stdin\nimport sys\nimport math\nfrom functools import reduce\nimport functools\nimport itertools\nfrom collections import deque,Counter\nfrom operator import mul\nimport copy\n# ! /usr/bin/env python\n# -*- coding: utf-8 -*-\nimport heapq\nsys.setrecursionlimit(10**6)\n\nN, K = list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nmod = 10**9+7\n\ndp = [[0]*(K+1) for i in range(N+1)]\ndp[0][0] = 1\n\nfor i in range(1,N+1):\n s = list(itertools.accumulate(dp[i - 1]))\n for k in range(K+1):\n m = max(0, k-a[i])\n if m > 0:\n dp[i][k] = ((s[k] % mod) - (s[m-1] % mod)) % mod\n else:\n dp[i][k] = s[k] % mod\n\nprint(dp[N][K] % mod)\n\n", "neg": "from sys import stdin\nimport sys\nimport math\nfrom functools import reduce\nimport functools\nimport itertools\nfrom collections import deque,Counter\nfrom operator import mul\nimport copy\n# ! /usr/bin/env python\n# -*- coding: utf-8 -*-\nimport heapq\nsys.setrecursionlimit(10**6)\nimport numpy as np\n\nN, K = list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nmod = 10**9+7\n\ndp = [[0]*(K+1) for i in range(N+1)]\ndp[0][0] = 1\n\nfor i in range(1,N+1):\n for k in range(K+1):\n s = np.cumsum(dp[i-1])\n m = max(0, k-a[i])\n if m > 0:\n dp[i][k] = ((s[k] % mod) - (s[m-1] % mod)) % mod\n else:\n dp[i][k] = s[k] % mod\n\nprint(dp[N][K] % mod)\n\n", "jacc_sim": 0.9295774647887324, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [274, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u091850723", "n_user": "u091850723", "pos": "n,k=map(int,input().split())\nli=[int(K) for K in input().split()]\ndp=[[0 for j in range(k+1)] for i in range(n+1)]\ndp[0][0]=1\nfor b in range(1,n+1):\n dp[b][0]=1\nmod=10**9+7 \nfor i in range(1,n+1):\n sums=[0]*(k+1)\n sums[0]=1\n for j in range(1,k+1):\n sums[j]=(sums[j-1]+dp[i-1][j])%mod\n for a in range(k+1):\n res=sums[a]\n if(a-li[i-1]-1)>=0:\n res=(res-sums[a-li[i-1]-1]+mod)%mod\n dp[i][a]=res\nprint(dp[n][k]) \n", "neg": "n,k=map(int,input().split())\nli=[int(K) for K in input().split()]\ndp=[[0 for j in range(k+1)] for i in range(n+1)]\ndp[0][0]=1\nfor b in range(1,n+1):\n dp[b][0]=1\nmod=10**9+7 \nfor i in range(1,n+1):\n sums=[0]*(k+1)\n sums[0]=1\n for j in range(1,k+1):\n sums[j]=sums[j-1]+dp[i-1][j]\n for a in range(k+1):\n res=sums[a]\n if(a-li[i-1]-1)>=0:\n res=(res-sums[a-li[i-1]-1]+mod)%mod\n dp[i][a]=res\nprint(dp[n][k]) \n", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [242, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u227082700", "n_user": "u069347602", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndp=[0]*(k+1)\ndp[0]=1\nmod=10**9+7\nfor i in range(n):\n for j in range(k,0,-1):\n if j>a[i]:dp[j]-=dp[j-a[i]-1]\n for j in range(k):dp[j+1]=(dp[j+1]+dp[j])%mod\nprint(dp[k])", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndp=[0]*(k+1)\nmod=10**9+7\nfor i in range(0,a[0]+1):\n dp[i]=1\nfor i in range(1,len(a)):\n for j in range(k+1):\n dp[j]=(dp[j]+dp[j-1])%mod\n for j in range(k,a[i],-1):\n dp[j]=(dp[j]-dp[j-a[i]-1]+mod)%mod\nprint(dp[k])", "jacc_sim": 0.9166666666666666, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [134, 159], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u309716323", "n_user": "u091850723", "pos": "\n\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve():\n \"\"\"\n OPT[N][K] = sum(OPT[N-1][K-i]) 0 <= i <= A[N]\n OPT[0][0] = 1\n N*K\n 3 4\n 1 2 3\n\n1 0 0 0 0\n1 1 0 0 0\n1 2 2 1 0\n1 3 5 6 5\n\nOPT[3][1] = OPT[2][1]+OPT[2][0]\nOPT[3][2] = OPT[2][2]+OPT[2][1]+OPT[2][0]\nOPT[3][3] = OPT[2][3]+OPT\n \"\"\"\n N, K = read_ints()\n A = read_ints()\n modulo = 10**9+7\n OPT = [[0]*(K+1) for _ in range(N+1)]\n for i in range(N+1):\n OPT[i][0] = 1\n for j in range(K+1):\n OPT[0][j] = 1\n for i in range(1, N+1):\n for j in range(1, K+1):\n OPT[i][j] += OPT[i][j-1]+OPT[i-1][j]\n if j-A[i-1]-1 >= 0:\n OPT[i][j] -= OPT[i-1][j-A[i-1]-1]\n OPT[i][j] %= modulo\n if K == 0:\n return OPT[-1][-1]\n return (OPT[-1][-1]-OPT[-1][-2])%modulo\n\n\nif __name__ == '__main__':\n print(solve())\n", "neg": "\ndef read_int():\n return int(input().strip())\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve():\n \"\"\"\n OPT[N][K] = sum(OPT[N-1][K-i]) 0 <= i <= A[N]\n OPT[0][0] = 1\n N*K\n 3 4\n 1 2 3\n\n1 0 0 0 0\n1 1 0 0 0\n1 2 2 1 0\n1 3 5 6 5\n\nOPT[3][1] = OPT[2][1]+OPT[2][0]\nOPT[3][2] = OPT[2][2]+OPT[2][1]+OPT[2][0]\nOPT[3][3] = OPT[2][3]+OPT\n \"\"\"\n N, K = read_ints()\n A = read_ints()\n modulo = 10**9+7\n OPT = [[0]*(K+1) for _ in range(N+1)]\n for i in range(N+1):\n OPT[i][0] = 1\n for j in range(K+1):\n OPT[0][j] = 1\n for i in range(1, N+1):\n for j in range(1, K+1):\n OPT[i][j] += OPT[i][j-1]+OPT[i-1][j]\n if j-A[i-1]-1 >= 0:\n OPT[i][j] -= OPT[i-1][j-A[i-1]-1]\n OPT[i][j] %= modulo\n return (OPT[-1][-1])%modulo\n\n\nif __name__ == '__main__':\n print(solve())\n", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [444, 418], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u606045429", "n_user": "u606045429", "pos": "mod = 10 ** 9 + 7\n\nN, K, *A = map(int, open(0).read().split())\n\ndp = [1] + [0] * (K + 1)\nfor a in A:\n for i in range(1, K + 1):\n dp[i] += dp[i - 1]\n for i in reversed(range(1, K + 1)):\n dp[i] -= dp[max(0, i - a) - 1]\n dp[i] %= mod\n\nprint(dp[K])", "neg": "mod = 10 ** 9 + 7\n\nN, K, *A = map(int, open(0).read().split())\n\ndp = [1] + [0] * K\nfor a in A:\n for i in range(1, K + 1):\n dp[i] += dp[i - 1]\n for i in reversed(range(1, K + 1)):\n dp[i] -= dp[max(0, i - a) - 1]\n dp[i] %= mod\n\nprint(dp[K])", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [129, 125], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u218842729", "n_user": "u218842729", "pos": "N,K = map(int, input().split())\nA = list(map(int, input().split()))\nMOD = 1000000007\n\ndp = [[0] * (K+10) for _ in range(N+1)]\ndp[0][0] = 1\nfor i in range(N):\n for j in range(K,-1,-1):\n dp[i+1][j] += dp[i][j]\n dp[i+1][j] %= MOD\n if j + A[i] + 1 <= K+1:\n dp[i+1][j+A[i]+1] = (dp[i+1][j+A[i]+1] - dp[i][j] + MOD) % MOD\n \n for j in range(K+1):\n dp[i+1][j+1] += dp[i+1][j]\n dp[i+1][j+1] %= MOD\n\nprint(dp[N][K])\n", "neg": "N,K = map(int, input().split())\nA = list(map(int, input().split()))\n\ndp = [[0] * (K+10) for _ in range(N+1)]\ndp[0][0] = 1\nfor i in range(N):\n for j in range(K,0,-1):\n dp[i+1][j] += dp[i][j]\n dp[i+1][j] %= MOD\n if j + a[i] + 1 <= K+1:\n dp[i+1][j+a[i]+1] = (dp[i+1][j+a[i]+1] - dp[i][j] + MOD) % MOD\n \n for j in range(K+1):\n dp[i+1][j+1] += dp[i+1][j]\n dp[i+1][j+1] %= MOD\n\nprint(dp[N][K])\n", "jacc_sim": 0.9444444444444444, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [234, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u222668979", "n_user": "u222668979", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncs_a, cnt = [0] * n, 0\nfor i in range(n):\n cnt += a[i]\n cs_a[i] = cnt\ndp = [[0] * (k + 1) for i in range(n + 1)]\n\nfor i in range(n + 1):\n for j in range(k + 1):\n if j == 0:\n dp[i][j] = 1\n elif (i == 0) or (j > cs_a[i - 1]):\n dp[i][j] = 0\n elif j - a[i - 1] - 1 < 0:\n dp[i][j] = dp[i - 1][j] + dp[i][j - 1]\n else:\n dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1]\n dp[i][j] %= 10 ** 9 + 7\n\nprint(dp[n][k])\n", "neg": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncs_a, cnt = [0] * n, 0\nfor i in range(n):\n cnt += a[i]\n cs_a[i] = cnt\n\ndp = [[0] * (n + 1) for i in range(k + 1)]\ncs_dp = [[0] * (n + 1) for i in range(k + 1)]\n\nfor i in range(k + 1):\n for j in range(1, n + 1):\n if i > cs_a[j - 1]:\n dp[i][j] = 0\n elif i == 0:\n dp[i][j], cs_dp[i][j] = 1, 1\n elif i == 1:\n dp[i][j] = dp[i][j - 1] + min(1, a[j - 1])\n elif i - a[j - 1] - 1 < 0:\n dp[i][j] = cs_dp[i][j - 1]\n else:\n dp[i][j] = cs_dp[i][j - 1] - cs_dp[i - a[j - 1] - 1][j - 1]\n if i > 0:\n cs_dp[i][j] = cs_dp[i - 1][j] + dp[i][j]\n\nprint(dp)\nprint(dp[k][n] % (10 ** 9 + 7))\n", "jacc_sim": 0.9285714285714286, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [273, 358], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u222668979", "n_user": "u222668979", "pos": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncs_a, cnt = [0] * n, 0\nfor i in range(n):\n cnt += a[i]\n cs_a[i] = cnt\ndp = [[0] * (k + 1) for i in range(n + 1)]\n\nfor i in range(n + 1):\n for j in range(k + 1):\n if j == 0:\n dp[i][j] = 1\n elif (i == 0) or (j > cs_a[i - 1]):\n dp[i][j] = 0\n elif j == 1:\n dp[i][j] = dp[i - 1][j] + min(a[i - 1], 1)\n elif j - a[i - 1] - 1 < 0:\n dp[i][j] = dp[i - 1][j] + dp[i][j - 1]\n else:\n dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - a[i - 1] - 1]\n dp[i][j] %= 10 ** 9 + 7\n\nprint(dp[n][k])\n", "neg": "n, k = map(int, input().split())\na = list(map(int, input().split()))\n\ncs_a, cnt = [0] * n, 0\nfor i in range(n):\n cnt += a[i]\n cs_a[i] = cnt\n\ndp = [[0] * (n + 1) for i in range(k + 1)]\n\nfor i in range(k + 1):\n for j in range(1, n + 1):\n if i > cs_a[j - 1]:\n dp[i][j] = 0\n elif i == 0:\n dp[i][j] = 1\n elif i == 1:\n dp[i][j] = dp[i][j - 1] + min(1, a[j - 1])\n else:\n dp[i][j] = sum(dp[i - x][j - 1] for x in range(a[j - 1] + 1))\n\nprint(dp[k][n] % (10 ** 9 + 7))\n", "jacc_sim": 0.9069767441860465, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [308, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u357230322", "n_user": "u357230322", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\n\nm=10**9+7\n\ndp=[ [0]*(k+1) for _ in range(n+1) ]\ndp[0][0]=1\n\ndp_sum=[ [0]*(k+1) for _ in range(n+1) ]\n\nfor i in range(n):\n for j in range(k+1):\n if j==0:\n dp_sum[i][j]=1\n else:\n dp_sum[i][j]= (dp_sum[i][j-1]+dp[i][j])%m\n if j-a[i]>0:\n dp[i+1][j]= (dp_sum[i][j] - dp_sum[i][j-a[i]-1])%m\n else:\n dp[i+1][j]= (dp_sum[i][j])%m\n\nprint(dp[n][k]%m)", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\n\nm=10**9+7\n\ndp=[ [0]*(k+1) for _ in range(n+1) ]\ndp[0][0]=1\n\nfor i in range(n):\n for j in range(k+1):\n if j-a[i]>=0:\n dp[i+1][j]=sum( dp[i][j-a[i]:j+1 ])\n else:\n dp[i+1][j]=sum( dp[i][0:j+1 ])\n\nprint(dp[n][k]%m)", "jacc_sim": 0.9487179487179487, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [254, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u566529875", "n_user": "u566529875", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nif k > sum(a):\n print(0)\n exit()\n\nmod = 1000000007\ndp = [[0 for _ in range(k+1)]for __ in range(n+1)]\nfor i in range(n+1):\n dp[i][0] = 1\nfor i in range(k+1):\n dp[0][i] = 0\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if j > a[i-1]:\n if i is 1:\n break\n dp[i][j] = dp[i-1][j] + dp[i][j-1]\n if j > a[i-1]:\n dp[i][j] -= dp[i-1][j-1-a[i-1]]\n dp[i][j] %= mod\nprint(dp[n][k])", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nif k > sum(a):\n print(-1)\n exit()\n\nmod = 1000000007\ndp = [[0 for _ in range(k+1)]for __ in range(n+1)]\nfor i in range(n+1):\n dp[i][0] = 1\n dp[0][i] = 0\n\nfor i in range(1,n+1):\n for j in range(1,k+1):\n if j > a[i-1]:\n if i is 1:\n break\n dp[i][j] = dp[i-1][j] + dp[i][j-1]\n if j > a[i-1]:\n dp[i][j] -= dp[i-1][j-1-a[i-1]]\n dp[i][j] %= mod\nprint(dp[n][k])", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [242, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u886747123", "n_user": "u572142121", "pos": "N, K = map(int, input().split())\na = [-1] + list(map(int, input().split()))\n\nMOD = 10**9 + 7\n\ndp = [[0]*(K+1) for _ in range(N+1)]\nfor i in range(N+1):\n dp[i][0] = 1\n\nfor i in range(N):\n for j in range(K):\n if j - a[i+1] >= 0:\n dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1] - dp[i][j - a[i+1]]) % MOD\n else:\n dp[i+1][j+1] = (dp[i+1][j] + dp[i][j+1]) % MOD\n\nprint(dp[N][K])", "neg": "N,K= map(int, input().split())\na=list(map(int,input().split()))\ndp=[[0]*(K+1) for i in range(N)]\nfor j in range(a[0]+1):\n dp[0][j]=1\n \nfor i in range(1,N):\n for j in range(1,K+1):\n if j==0:\n dp[i][j]=0\n else:\n dp[i][j]=dp[i][j-1]+dp[i-1][j]\n if j>=a[i]+1:\n dp[i][j]-=dp[i-1][j-1-a[i]]\n dp[i][j]=dp[i][j]%(10**9+7)\nprint(dp[-1][-1])", "jacc_sim": 0.9459459459459459, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [206, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u672220554", "n_user": "u672220554", "pos": "def main():\n N, K = map(int, input().split())\n if K == 0:\n return 1\n A = list(map(int, input().split()))\n MOD = 10**9+7\n dp = [[0]*(K+1) for _ in range(N+1)]\n dp[0][0] = 1\n for i in range(N):\n a = A[i]\n for j in range(K+1):\n dp[i+1][j] += dp[i][j]\n if j+a+1 <= K:\n dp[i+1][j+a+1] -= dp[i][j]\n for j in range(K):\n dp[i+1][j+1] += dp[i+1][j]\n for j in range(K+1):\n dp[i+1][j] = dp[i+1][j] % MOD\n\n return dp[N][K]\n\n\nprint(main())\n", "neg": "def main():\n N, K = map(int, input().split())\n if K == 0:\n return 1\n A = list(map(int, input().split()))\n MOD = 10**9+7\n dp = [[0]*(K+1) for _ in range(N+1)]\n dp[0][0] = 1\n for i in range(N):\n a = A[i]\n for j in range(K):\n dp[i+1][j] += dp[i][j]\n if j+a+1 <= K:\n dp[i+1][j+a+1] -= dp[i][j]\n for j in range(K):\n dp[i+1][j] %= MOD\n dp[i+1][j+1] += dp[i+1][j]\n\n return dp[N][K]\n\n\nprint(main())\n", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [240, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u756829954", "n_user": "u756829954", "pos": "def p_m():\n n, k = map(int, input().split())\n *a, = map(int, input().split())\n mod = 10 ** 9 + 7\n # dp[i][j]\u306fi\u756a\u76ee\u306e\u5b50\u306bj\u500b\u306e\u98f4\u3092\u914d\u308b\u65b9\u6cd5\u304c\u4f55\u901a\u308a\u304b\u3069\u3046\u304b\n dp = [[0] * (k + 1) for _ in range(n + 1)]\n for i in range(n + 1):\n dp[i][0] = 1\n\n for i in range(1, n + 1):\n for j in range(1, k + 1):\n if j - 1 - a[i - 1] >= 0:\n dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1 - a[i - 1]]) % mod\n else:\n dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod\n print(dp[n][k])\n\n\nif __name__ == '__main__':\n p_m()\n", "neg": "def p_m():\n n, k = map(int, input().split())\n *a, = map(int, input().split())\n mod = 10 ** 9 + 7\n # dp[i][j]\u306fi\u756a\u76ee\u306e\u5b50\u306bj\u500b\u306e\u98f4\u3092\u914d\u308b\u65b9\u6cd5\u304c\u4f55\u901a\u308a\u304b\u3069\u3046\u304b\n dp = [[0] * (k + 1) for _ in range(n + 1)]\n dp[0][0] = 1\n\n count = 0\n for i in range(n):\n for j in range(min(k + 1, count + 1)):\n count += a[i]\n for m in range(a[i] + 1):\n if j + m > k:\n break\n dp[i + 1][j + m] += dp[i][j]\n dp[i + 1][j + m] %= mod\n print(dp[n][k])\n\n\nif __name__ == '__main__':\n p_m()", "jacc_sim": 0.9090909090909091, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [314, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u440566786", "n_user": "u440566786", "pos": "import sys\nsys.setrecursionlimit(2147483647)\nINF=float(\"inf\")\nMOD=10**9+7\ninput=lambda :sys.stdin.readline().rstrip()\ndef resolve():\n n,k=map(int,input().split())\n A=list(map(int,input().split()))\n dp=[0]*(k+1)\n dp[k]=1\n for i in range(n):\n ndp=[0]*(k+1)\n # dp\u306e\u7d2f\u7a4d\u548c\u3092\u53d6\u3063\u3066\u304a\u304f\n S=[0]*(k+2)\n for j in range(k+1):\n S[j+1]=S[j]+dp[j]\n S[j+1]%=MOD\n # iterete\n for j in range(k+1):\n ndp[j]=S[min(j+A[i]+1,k+1)]-S[j]\n ndp[j]%=MOD\n dp=ndp\n print(dp[0])\nresolve()", "neg": "import sys\nsys.setrecursionlimit(2147483647)\nINF=float(\"inf\")\nMOD=10**9+7\ninput=lambda :sys.stdin.readline().rstrip()\ndef resolve():\n n,k=map(int,input().split())\n A=list(map(int,input().split()))\n dp=[0]*(k+1)\n dp[k]=1\n for i in range(n):\n ndp=[0]*(k+1)\n # dp\u306e\u7d2f\u7a4d\u548c\u3092\u53d6\u3063\u3066\u304a\u304f\n S=[0]*(k+2)\n for j in range(k+1): S[j+1]=S[j]+dp[j]\n # iterete\n for j in range(k+1):\n ndp[j]=S[min(j+A[i]+1,k+1)]-S[j]\n dp=ndp\n print(dp[0])\nresolve()", "jacc_sim": 0.9841269841269841, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [273, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u655612181", "n_user": "u655612181", "pos": "from itertools import accumulate\n\ndef f(k, A):\n n = len(A)\n\n mod = int(1e9 + 7)\n dp = [0] * (k + 1)\n\n # init for last column\n for j in range(min(A[n - 1], k) + 1):\n dp[j] = 1\n\n for i in range(n - 2, -1, -1):\n dp = list(accumulate(dp))\n a = A[i]\n dp[a+1:] = [x - y for x, y in zip(dp[a + 1:], dp)]\n dp = [x % mod for x in dp]\n\n return dp[-1] % mod\n\nassert f(4, [2, 3]) == 2\nassert f(4, [1, 2, 3]) == 5\nassert f(10, [9]) == 0\nassert f(0, [0, 0]) == 1\nassert f(100000, [100000, 100000, 100000, 100000]) == 665683269\n\nn, k = map(int, input().split())\nA = list(map(int, input().split()))\nans = f(k, A)\nprint(ans)\n", "neg": "from itertools import accumulate\n\ndef f(k, A):\n n = len(A)\n\n mod = int(1e9 + 7)\n dp = [0] * (k + 1)\n\n # init for last column\n for j in range(min(A[n - 1], k) + 1):\n dp[j] = 1\n\n for i in range(n - 2, -1, -1):\n dp = list(accumulate(dp))\n a = A[i]\n dp[a+1:] = [x - y for x, y in zip(dp[a + 1:], dp)]\n\n return dp[-1]\n\nassert f(4, [2, 3]) == 2\nassert f(4, [1, 2, 3]) == 5\nassert f(10, [9]) == 0\nassert f(0, [0, 0]) == 1\n#assert f(100000, [100000, 100000, 100000, 100000]) == 665683269\n\nn, k = map(int, input().split())\nA = list(map(int, input().split()))\nans = f(k, A)\nprint(ans)\n", "jacc_sim": 0.9830508474576272, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [291, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03172", "p_user": "u729972685", "n_user": "u729972685", "pos": "from sys import stdin\nfrom itertools import accumulate\ninput = stdin.readline\n\nMOD = 10**9+7\nN, K = map(int,input().split())\na = list(map(int,input().split()))\n\np = list(accumulate(a))\n\ndp = [0] * (K+1)\ndp[0] = 1\nprefix = [0]+[1]*(K+1)\nfor i in range(N):\n new_dp = [0]*(K+1)\n for j in range(min(p[i],K)+1):\n new_dp[j] = prefix[j+1] - prefix[max(0,j-a[i])]\n dp = new_dp[:]\n prefix = [i % MOD for i in [0]+list(accumulate(dp))]\n\nprint(dp[K]%MOD)\n", "neg": "from sys import stdin\nfrom itertools import accumulate\ninput = stdin.readline\n\nMOD = 10**9+7\nN, K = map(int,input().split())\na = list(map(int,input().split()))\n\np = list(accumulate(a))\n\ndp = [0] * (K+1)\ndp[0] = 1\nprefix = [0]+[1]*(K+1)\nfor i in range(N):\n new_dp = [0]*(K+1)\n for j in range(min(p[i],K)+1):\n new_dp[j] = prefix[j+1] - prefix[max(0,j-a[i])]\n dp = new_dp[:]\n\n\nprint(dp[K]%MOD)\n", "jacc_sim": 1.0, "nl": "You have N children numbered from 1 to N. They want to share K candies among themselves. Each child i (1 \u2264 i \u2264 N) should receive between 0 and a_i candies (inclusive), and no candies should be left over. Find the number of ways to share candies, considering two ways different if a child receives a different number of candies. All input values are integers. Constraints: 1 \u2264 N \u2264 100, 0 \u2264 K \u2264 10^5, 0 \u2264 a_i \u2264 K. Input format: N K a_1 a_2 ... a_N. Output the number of ways to share candies modulo 10^9 + 7. Example: Input: 3 4 1 2 3, Output: 5 (e.g., (0, 1, 3), (0, 2, 2), (1, 0, 3), (1, 1, 2), (1, 2, 1)). If there are no ways to share candies, output 0. Be sure to print the answer modulo 10^9 + 7.", "before_after_length": [208, 187], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u263753244", "n_user": "u263753244", "pos": "import itertools\n\nn=int(input())\na=list(map(int,input().split()))\ns=[0]+list(itertools.accumulate(a))\n\ndp=[[10**20]*(n+1) for _ in range(n)]\nfor l in range(n):\n dp[l][l+1]=0\nfor d in range(2,n+1): \n for k in range(1,d):\n for i in range(n-d+1):\n j=i+d\n S=s[j]-s[i]\n dp[i][j]=min(dp[i][i+k]+dp[i+k][j]+S,dp[i][j])\n\nprint(dp[0][n])", "neg": "import itertools\nn=int(input())\na=list(map(int,input().split()))\n\ns=[0]+list(itertools.accumulate(a))\n\ndp=[[10**10]*(n+1) for _ in range(n)]\nfor l in range(n):\n dp[l][l+1]=0\nfor d in range(2,n+1): \n for k in range(1,d):\n for i in range(n-d+1):\n j=i+d\n S=s[j]-s[i]\n dp[i][j]=min(dp[i][i+k]+dp[i+k][j],dp[i][j])+S\n\nprint(dp[0][n])", "jacc_sim": 0.975, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [181, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u091850723", "n_user": "u091850723", "pos": "import sys\nsys.setrecursionlimit(10**8)\nINF = float(\"inf\")\n\ndef findsum(li):\n\n for i in range(1,len(li)+1):\n tot[i]=tot[i-1]+li[i-1]\n #print(tot)\n\ndef findans(start,end,li):\n global tot\n #print(\"HI\")\n if(start>=end):\n return 0\n if(dp[start][end]!=-1):\n return dp[start][end]\n ans = INF\n for k in range(start,end):\n\n\n ans=min(findans(start,k,li)+findans(k+1,end,li),ans)\n dp[start][end]=ans+(tot[end+1]-tot[start])\n return dp[start][end]\nn=int(input())\nli=[int(k) for k in input().split()]\ntot=[0]*(len(li)+1)\nfindsum(li)\ndp=[[-1 for i in range(n)]for k in range(n)]\nprint(findans(0,n-1,li))\n", "neg": "import sys\nsys.setrecursionlimit(10**8)\nINF = float(\"inf\")\n\ndef findsum(li):\n\n for i in range(1,len(li)+1):\n tot[i]=tot[i-1]+li[i-1]\n #print(tot)\n\ndef findans(start,end,li):\n global tot\n #print(\"HI\")\n if(start>=end):\n return 0\n if(dp[start][end]!=-1):\n return dp[start][end]\n ans = INF\n for k in range(start,end+1):\n\n\n ans=min(findans(start,k,li)+findans(k+1,end,li),ans)\n dp[start][end]=ans+(tot[end+1]-tot[start])\n return dp[start][end]\nn=int(input())\nli=[int(k) for k in input().split()]\ntot=[0]*(len(li)+1)\nfindsum(li)\ndp=[[-1 for i in range(n)]for k in range(n)]\nprint(findans(0,n-1,li))\n", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [281, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u072717685", "n_user": "u072717685", "pos": "from itertools import accumulate\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\nfrom itertools import chain\n\ndp = []\ndp2 = []\naac = []\n\ndef fdp(l, r):\n global dp, dp2\n if dp2[l][r]:\n return dp[l][r]\n else:\n dp2[l][r] = 1\n if l == r:\n return 0\n result_tmp = float('inf')\n for kugiri in range(l, r):\n result_tmp = min(result_tmp, fdp(l, kugiri) + fdp(kugiri+1, r))\n result = result_tmp + (aac[r+1] - aac[l])\n dp[l][r] = result\n return result\ndef main():\n global dp, dp2, aac\n n = int(input())\n a = tuple(map(int, input().split()))\n aac = list(accumulate(a))\n aac = tuple(chain([0], aac))\n dp = [[0] * n for _ in range(n)]\n dp2 = [[0] * n for _ in range(n)]\n fdp(0, n - 1)\n print(dp[0][-1])\nif __name__ == '__main__':\n main()\n", "neg": "from itertools import accumulate\nimport sys\ninput = sys.stdin.readline\nfrom itertools import chain\n\ndp = []\ndp2 = []\naac = []\n\ndef fdp(l, r):\n global dp, dp2\n if dp2[l][r]:\n return dp[l][r]\n else:\n dp2[l][r] = 1\n if l == r:\n return 0\n result_tmp = float('inf')\n for kugiri in range(l, r):\n result_tmp = min(result_tmp, fdp(l, kugiri) + fdp(kugiri+1, r))\n result = result_tmp + (aac[r+1] - aac[l])\n dp[l][r] = result\n return result\n\n\ndef main():\n global dp, dp2, aac\n n = int(input())\n a = tuple(map(int, input().split()))\n aac = list(accumulate(a))\n aac = tuple(chain([0], aac))\n dp = [[0] * n for _ in range(n)]\n dp2 = [[0] * n for _ in range(n)]\n\n fdp(0, n - 1)\n print(dp[0][-1])\n print(dp)\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9482758620689655, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [334, 333], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u994521204", "n_user": "u994521204", "pos": "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\ninfi = 10 ** 20\nSA = list(accumulate([0] + A))\n\ndp = [[infi] * (n + 1) for _ in range(n + 1)]\n# dp[i]\u5de6\u304b\u3089i\u500b\u6c7a\u3081\u305f\u6642\u306e\u6700\u5c0f\u5024\u3068\u3059\u308b\u3002\nif n >= 3:\n for i in range(n):\n dp[i][i] = 0\n dp[i][i + 1] = 0\n if i <= n - 2:\n dp[i][i + 2] = A[i] + A[i + 1]\n for d in range(n + 1):\n for i in range(n):\n j = i + d\n if j > n:\n continue\n if d >= 2:\n for m in range(i + 1, j + 1):\n dp[i][j] = min(dp[i][j], dp[i][m] + dp[m][j] + SA[j] - SA[i])\n print(dp[0][n])\nelse:\n print(sum(A))\n", "neg": "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\ninfi = 10 ** 20\nSA = list(accumulate([0] + A))\n\ndp = [[infi] * (n + 1) for _ in range(n + 1)]\n# dp[i]\u5de6\u304b\u3089i\u500b\u6c7a\u3081\u305f\u6642\u306e\u6700\u5c0f\u5024\u3068\u3059\u308b\u3002\nif n >= 3:\n for i in range(n):\n dp[i][i] = 0\n dp[i][i + 1] = 0\n if i <= n - 2:\n dp[i][i + 2] = A[i] + A[i + 1]\n for d in range(n + 1):\n for i in range(n):\n j = i + d\n if j > n:\n continue\n if d >= 2:\n for m in range(i + 1, j + 1):\n dp[i][j] = min(dp[i][j], dp[i][m] + dp[m][j] + SA[j] - SA[i])\n print(dp[0][n])\nelse:\n", "jacc_sim": 0.984375, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [313, 305], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u606045429", "n_user": "u606045429", "pos": "from itertools import accumulate\n\nN, *A = map(int, open(0).read().split())\n\nS = [0] + list(accumulate(A))\n\nmemo = [[-1] * N for _ in range(N)]\ndef dp(L, R):\n if L == R:\n return 0\n if memo[L][R] >= 0:\n return memo[L][R]\n\n memo[L][R] = min(dp(L, c) + dp(c + 1, R) + S[R + 1] - S[L] for c in range(L, R))\n return memo[L][R]\n\nprint(dp(0, N - 1))", "neg": "from itertools import accumulate\n\nN, *A = map(int, open(0).read().split())\n\nS = [0] + list(accumulate(A))\n\nmemo = [[-1] * N for _ in range(N)]\ndef dp(L, R):\n if L == R:\n return 0\n if memo[L][R] >= 0:\n return memo[L][R]\n\n memo[L][R] = min(dp(L, c) + dp(c + 1, R) + S[R + 1] - S[L] for c in range(L, R))\n return memo[L][R]", "jacc_sim": 0.975609756097561, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [164, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u509368316", "n_user": "u509368316", "pos": "N=int(input())\nA=list(map(int,input().split()))\na=[0]*(N+1)\nfor i in range(N):\n a[i+1]=a[i]+A[i]\nd=[[0]*(N+1) for i in range(N+1)]\nfor w in range(2,N+1):\n for l in range(N+1-w):\n d[l][l+w]=min([d[l][m]+d[m][l+w] for m in range(l+1,l+w)])+a[l+w]-a[l]\nprint(d[0][N])", "neg": "N=int(input())\nA=list(map(int,input().split()))\na=[0]*(N+1)\nfor i in range(N):\n a[i+1]=a[i]+A[i]\nprint(a)\nd=[[0]*(N+1) for i in range(N+1)]\nfor w in range(2,N+1):\n for l in range(N+1-w):\n d[l][l+w]=min([d[l][m]+d[m][l+w] for m in range(l+1,l+w)])+a[l+w]-a[l]\nprint(d[0][N])", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [162, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u891217808", "n_user": "u891217808", "pos": "n = int(input())\nns = list(map(int, input().split()))\ndp = [[0] * n for i in range(n)]\ncur = [0]\ncnt = 0\nfor i in ns:\n cnt += i\n cur.append(cnt)\n\nfor i in range(n-1, -1, -1):\n for j in range(i + 1, n):\n dp[i][j] = min(dp[i][k] + dp[k + 1][j] for k in range(i, j)) + cur[j+1] - cur[i]\nprint(dp[0][-1])", "neg": "n = int(input())\nns = list(map(int, input().split()))\ndp = [[0] * n for i in range(n)]\nfor i in range(n-1): \n dp[i][i+1] = ns[i] + ns[i+1]\ncur = [0]\ncnt = 0\nfor i in ns:\n cnt += i\n cur.append(cnt)\n\nfor i in range(n-1, -1, -1):\n for j in range(i + 2, n):\n dp[i][j] = min(dp[i][k] + dp[k + 1][j] for k in range(i + 1, j)) + cur[j] - cur[i]\nprint(dp[0][-1])", "jacc_sim": 0.9696969696969697, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [151, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u888092736", "n_user": "u888092736", "pos": "from itertools import accumulate\n\n\ndef dfs(l, r):\n if memo[l][r]:\n return dp[l][r]\n for i in range(l, r):\n dp[l][r] = min(max(0, dp[l][r]), dfs(l, i) + dfs(i + 1, r) + acc_A[r] - acc_A[l - 1])\n memo[l][r] = True\n return dp[l][r]\n\n\nn = int(input())\nA = list(map(int, input().split()))\nacc_A = [0] + list(accumulate(A))\n\nINF = 10 ** 18\ndp = [[INF] * (n + 1) for _ in range(n + 1)]\nmemo = [[False] * (n + 1) for _ in range(n + 1)]\nfor i in range(1, n + 1):\n dp[i][i] = 0\n memo[i][i] = True\n\n\nprint(dfs(1, n))\n", "neg": "from itertools import accumulate\n\n\ndef dfs(l, r):\n if memo[l][r]:\n return dp[l][r]\n for i in range(l, r):\n dp[l][r] = min(max(0, dp[l][r]), dfs(l, i) + dfs(i + 1, r) + acc_A[r] - acc_A[l - 1])\n memo[l][r] = True\n return dp[l][r]\n\n\nn = int(input())\nA = list(map(int, input().split()))\nacc_A = [0] + list(accumulate(A))\n\nINF = 10 ** 18\ndp = [[INF] * (n + 1) for _ in range(n + 1)]\nmemo = [[False] * (n + 1) for _ in range(n + 1)]\nfor i in range(1, n + 1):\n dp[i][i] = 0\n memo[i][i] = True\n\n\nprint(dfs(1, n))\n[print(row) for row in memo]\n", "jacc_sim": 0.9787234042553191, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [247, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u572142121", "n_user": "u572142121", "pos": "N=int(input())\nA=list(map(int,input().split()))\nB=[0]*(N+1)\nfor i in range(N):\n B[i+1]=B[i]+A[i]\n\ndp=[[0]*(N+1) for i in range(N)]\n#k:\u3044\u304f\u3064\u306e\u30b9\u30e9\u30a4\u30e0\u3092\u5408\u4f53\u3057\u3066\u3044\u308b\u304b\nfor k in range(2,N+1):\n #i:\u3069\u3053\u306e\u30b9\u30e9\u30a4\u30e0\u3092\u8d77\u70b9\u306b\u5408\u4f53\u3057\u3066\u3044\u308b\u304b\n for i in range(N-k+1):\n dp[i][k]=min(dp[i][j]+dp[i+j][k-j] for j in range(1,k))+B[i+k]-B[i]\nprint(dp[0][N])", "neg": "N=int(input())\nA=list(map(int,input().split()))\nimport numpy\nB=[0]+list(numpy.cumsum(A))\nprint(B)\ndp=[[0]*(N+1) for i in range(N)]\n#k:\u3044\u304f\u3064\u306e\u30b9\u30e9\u30a4\u30e0\u3092\u5408\u4f53\u3057\u3066\u3044\u308b\u304b\nfor k in range(2,N+1):\n #i:\u3069\u3053\u306e\u30b9\u30e9\u30a4\u30e0\u3092\u8d77\u70b9\u306b\u5408\u4f53\u3057\u3066\u3044\u308b\u304b\n for i in range(N-k+1):\n dp[i][k]=min(dp[i][j]+dp[i+j][k-j] for j in range(1,k))+B[i+k]-B[i]\nprint(dp[0][N])", "jacc_sim": 0.9454545454545454, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [267, 253], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u334712262", "n_user": "u334712262", "pos": "from functools import lru_cache\nN = int(input())\nA = list(map(int, input().split()))\n\nINF = 1.0e+100\n\n\ndp = [[[None, INF] for _ in range(N+1)] for _ in range(N+1)]\nfor i in range(N):\n dp[i][i+1] = [A[i], 0]\n\nfor g in range(2, N+1):\n for l in range(N-g+1):\n r = l + g\n for i in range(l+1, r):\n lv, lc = dp[l][i]\n rv, rc = dp[i][r]\n nc = lv + rv + lc + rc\n if dp[l][r][1] > nc:\n dp[l][r][0] = lv + rv\n dp[l][r][1] = nc\n\nprint(dp[0][N][1])\n", "neg": "from functools import lru_cache\nN = int(input())\nA = list(map(int, input().split()))\n\nINF = 1.0e+100\n\n\ndp = [[[None, INF] for _ in range(N+1)] for _ in range(N+1)]\nfor i in range(N):\n dp[i][i+1] = [A[i], 0]\n\nfor g in range(2, N+1):\n for l in range(N-g+1):\n r = l + g\n print(l, r)\n for i in range(l+1, r):\n lv, lc = dp[l][i]\n rv, rc = dp[i][r]\n nc = lv + rv + lc + rc\n print(l, i, r, lv, rc, lc, rc)\n if dp[l][r][1] > nc:\n dp[l][r][0] = lv + rv\n dp[l][r][1] = nc\n\nprint(dp[0][N][1])\n", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [226, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u401843826", "n_user": "u401843826", "pos": "\ndef asum(l,r):\n\tglobal cumsum\n\tl+=1\n\tr+=1\n\treturn cumsum[r-1]-cumsum[l-1]\ndef check(l,r):\n\tglobal dp\n\tif l==r:\n\t\treturn 0\n\tif l == r-1:\n\t\treturn arr[l]+arr[r]\n\tif dp[l][r] != None:\n\t\treturn dp[l][r]\n\telse:\n\t\tans = 10**18\n\t\tfor i in range(l, r):\n\t\t\tst1 = asum(l,i)\n\t\t\tst2 = asum(i,r+1)\n\t\t\tans = min(st1 + st2 + check(l,i)+ check(i+1, r), ans)\n\t\t\n\t\tdp[l][r] = ans\n\t\treturn ans\n\n\n\n\n\nll = int(input())\narr = [int(i) for i in input().split()]\ncumsum = [0]\n\nfor i in arr:\n\tcumsum.append(cumsum[-1]+i)\ndp = [[None for i in range(ll+1)] for j in range(ll+1)]\nprint(check(0, ll-1))\n", "neg": "\ndef asum(l,r):\n\tglobal cumsum\n\tl+=1\n\tr+=1\n\treturn cumsum[r-1]-cumsum[l-1]\ndef check(l,r):\n\tglobal dp\n\tif l==r:\n\t\treturn 0\n\tif l == r-1:\n\t\treturn arr[l]+arr[r]\n\tif dp[l][r] != None:\n\t\treturn dp[l][r]\n\telse:\n\t\tans = 10**9\n\t\tfor i in range(l, r):\n\t\t\tst1 = asum(l,i)\n\t\t\tst2 = asum(i,r+1)\n\t\t\tans = min(st1 + st2 + check(l,i)+ check(i+1, r), ans)\n\t\t\n\t\tdp[l][r] = ans\n\t\treturn ans\n\n\n\n\n\nll = int(input())\narr = [int(i) for i in input().split()]\ncumsum = [0]\n\nfor i in arr:\n\tcumsum.append(cumsum[-1]+i)\ndp = [[None for i in range(ll+1)] for j in range(ll+1)]\nprint(check(0, ll-1))\n", "jacc_sim": 0.9555555555555556, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [299, 299], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u342869120", "n_user": "u342869120", "pos": "import sys\nsys.setrecursionlimit(10**8)\n\nN = int(input())\n*a, = map(int, input().split())\n\ns = [0]*N\ns[0] = a[0]\nfor i in range(1, N):\n s[i] += s[i-1]+a[i]\ns = [0]+s\n\ndp = [[0]*(N+1) for _ in range(N+1)]\n\n\ndef solve(l, r):\n if l == r:\n return 0\n if dp[l][r] > 0:\n return dp[l][r]\n\n n = float('inf')\n m = s[r+1]-s[l]\n for i in range(l, r):\n n = min([n, solve(l, i)+solve(i+1, r)+m])\n dp[l][r] = n\n return n\n\n\nprint(solve(0, N-1))\n", "neg": "import sys\nsys.setrecursionlimit(10**8)\n\nN = int(input())\n*a, = map(int, input().split())\n\ns = [0]*N\ns[0] = a[0]\nfor i in range(1, N):\n s[i] += s[i-1]+a[i]\ns = [0]+s\n\ndp = [[0]*(N+1) for _ in range(N+1)]\n\n\ndef solve(l, r):\n if l == r:\n return 0\n if dp[l][r] > 0:\n return dp[l][r]\n\n n = 10**9\n m = s[r+1]-s[l]\n for i in range(l, r):\n n = min([n, solve(l, i)+solve(i+1, r)+m])\n dp[l][r] = n\n return n\n\n\nprint(solve(0, N-1))\n", "jacc_sim": 0.9130434782608695, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [236, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u941407962", "n_user": "u941407962", "pos": "N = int(input())\nAs = list(map(int, input().split()))\nma = sum(As)\no = dict()\nINF = 10**19\nfrom itertools import accumulate\naa = [0] + list(accumulate(As))\n\nfor i in range(N):\n for j in range(N-i):\n span = i*N+j\n # \u9577\u3055i+1, \u958b\u59cb\u4f4d\u7f6ej\u306e\u5408\u6210\u30b3\u30b9\u30c8+\u69cb\u6210\u8981\u7d20\u306e\u548c\n if i == 0:\n o[span] = As[j]\n continue\n C = INF\n# print(i,j,o)\n for k in range(i):\n # \u9577\u3055k+1\u3068i+1-(k+1)=i-k\u306b\u5206\u5272\n# print(i,j,k*N+j, (i-k-1)*N+j+k, o)\n C = min(C, o[k*N+j]+o[(i-k-1)*N+j+k+1])\n# o[span] = C + sum(As[j:j+i+1])\n o[span] = C + aa[j+i+1] - aa[j]\n\nprint(o[span]-ma)\n", "neg": "N = int(input())\nAs = list(map(int, input().split()))\nma = sum(As)\no = dict()\nINF = 10**19\nfrom itertools import accumulate\naa = [0] + list(accumulate(As))\n\nfor i in range(N):\n for j in range(N-i):\n span = i*N+j\n # \u9577\u3055i+1, \u958b\u59cb\u4f4d\u7f6ej\u306e\u5408\u6210\u30b3\u30b9\u30c8+\u69cb\u6210\u8981\u7d20\u306e\u548c\n if i == 0:\n o[span] = As[j]\n continue\n C = INF\n# print(i,j,o)\n for k in range(i):\n # \u9577\u3055k+1\u3068i+1-(k+1)=i-k\u306b\u5206\u5272\n# print(i,j,k*N+j, (i-k-1)*N+j+k)\n C = min(C, o[k*N+j]+o[(i-k-1)*N+j+k])\n# o[span] = C + sum(As[j:j+i+1])\n o[span] = C + aa[j+i+1] - aa[j]\n\nprint(o[span]-ma)\n", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [354, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u504836877", "n_user": "u504836877", "pos": "import sys\nsys.setrecursionlimit(160000)\n\nN = int(input())\nA = [int(a) for a in input().split()]\n\ndp = [[0]*N for _ in range(N)]\nflag = [[False]*N for _ in range(N)]\nS = [0]*(N+1)\n\nfor i in range(N):\n flag[i][i] = True\n\nS[0] = A[0]\nfor i in range(N):\n S[i+1] = S[i]+A[i]\n \ndef f(l, r):\n if flag[l][r]:\n return dp[l][r]\n flag[l][r] = True\n res = 10**18\n for m in range(l, r):\n res = min(res, f(l, m)+f(m+1, r))\n dp[l][r] = res+S[r+1]-S[l]\n return dp[l][r]\n\nprint(f(0, N-1))", "neg": "import sys\nsys.setrecursionlimit(160000)\n\nN = int(input())\nA = [int(a) for a in input().split()]\n\ndp = [[0]*N for _ in range(N)]\nflag = [[False]*N for _ in range(N)]\nS = [0]*(N+1)\n\nfor i in range(N):\n flag[i][i] = True\n\nS[0] = A[0]\nfor i in range(N):\n S[i+1] = S[i]+A[i]\n \ndef f(l, r):\n if flag[l][r]:\n return dp[l][r]\n flag[l][r] = True\n res = 10**12\n for m in range(l, r):\n res = min(res, f(l, m)+f(m+1, r))\n dp[l][r] = res+S[r+1]-S[l]\n return dp[l][r]\n\nprint(f(0, N-1), dp)", "jacc_sim": 0.9565217391304348, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [252, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u756829954", "n_user": "u756829954", "pos": "def p_n():\n from itertools import accumulate\n n = int(input())\n *a, = map(int, input().split())\n ac = list(accumulate(a)) + [0]\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n for i in range(2, n + 1):\n for j in range(n - i + 1):\n dp[i][j] = ac[j + i - 1] - ac[j - 1] + min(dp[k][j] + dp[i - k][j + k] for k in range(1, i))\n print(dp[-1][0])\n\n\nif __name__ == '__main__':\n p_n()\n", "neg": "def p_n():\n from itertools import accumulate\n n = int(input())\n *a, = map(int, input().split())\n ac = list(accumulate(a)) + [0]\n dp = [[0] * (n + 1) for _ in range(n + 1)]\n for i in range(2, n + 1):\n for j in range(n - i + 1):\n dp[i][j] = ac[j + i - 1] - ac[j - 1] + min(dp[k][j] + dp[i - k][j + k] for k in range(1, i))\n print(dp)\n print(dp[-1][0])\n\n\nif __name__ == '__main__':\n p_n()\n", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [178, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u970899068", "n_user": "u970899068", "pos": "import sys\nimport itertools\ninput = sys.stdin.readline\n\n\nn=int(input())\na=list(map(int, input().split()))\nb=itertools.accumulate(a)\nb=[0]+list(b)\ndp=[[0]*(n) for i in range(n)]\n\nx=float('inf')\nfor i in range(n-1,-1,-1):\n for j in range(i+1,n):\n if j>=i+2:\n for k in range(i,j):\n x=min(dp[i][k]+dp[k+1][j],x)\n dp[i][j]=x+(b[j+1]-b[i])\n x=float('inf')\n else:\n dp[i][j]=b[j+1]-b[i]\nprint(dp[0][-1])\n\n", "neg": "import sys\nimport itertools\ninput = sys.stdin.readline\n\n\nn=int(input())\na=list(map(int, input().split()))\nb=itertools.accumulate(a)\nb=[0]+list(b)\ndp=[[0]*(n) for i in range(n)]\n\nx=float('inf')\nfor i in range(n-1,-1,-1):\n for j in range(i+1,n):\n for k in range(i,j):\n dp[i][j]=min(dp[i+1][k]+dp[k+1][j],x)+(b[j+1]-b[i])\nprint(b)\nprint(dp)", "jacc_sim": 0.9090909090909091, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [220, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u190406011", "n_user": "u190406011", "pos": "import sys\n\nn = int(input())\nINF = 10**20\na_ls = [int(i) for i in sys.stdin.readline().split()]\nmemo_ls = [[0 for j in range(n)] for i in range(n)]\nfor _ in range(1,n):\n for i in range(n-_):\n j = i + _\n sum_ij = sum(a_ls[i:j+1])\n memo_ls[i][j] = sum_ij\n res = INF if j - i > 1 else 0\n for k in range(i,j):\n res = min(memo_ls[i][k] + memo_ls[k+1][j], res)\n memo_ls[i][j] += res\nfor i in range(n):\n memo_ls[i][i] = a_ls[i]\nprint(memo_ls[0][-1])", "neg": "import sys\n\nn = int(input())\nINF = 10**9\na_ls = [int(i) for i in sys.stdin.readline().split()]\nmemo_ls = [[0 for j in range(n)] for i in range(n)]\nfor _ in range(1,n):\n for i in range(n-_):\n j = i + _\n sum_ij = sum(a_ls[i:j+1])\n memo_ls[i][j] = sum_ij\n res = INF if j - i > 1 else 0\n for k in range(i,j):\n res = min(memo_ls[i][k] + memo_ls[k+1][j], res)\n memo_ls[i][j] += res\nprint(memo_ls[0][-1])", "jacc_sim": 0.9523809523809523, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [220, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u983918956", "n_user": "u983918956", "pos": "inf = float('inf')\n\ndef accmulate(array):\n global cs\n cs = [0]*(len(array)+1)\n for i in range(len(array)):\n cs[i+1] = cs[i] + array[i]\n\ndef query(l,r):\n return cs[r+1] - cs[l]\n\nN = int(input())\nA = list(map(int,input().split()))\n\naccmulate(A)\n\ndp = [[inf]*(N+1) for _ in range(N+1)]\n\nfor i in range(N):\n dp[i][i+1] = 0\n\nfor i in range(N-1):\n dp[i][i+2] = A[i] + A[i+1]\n\nfor b in range(3,N+1):\n for i in range(N-b+1):\n j = i + b\n for k in range(i+1,j):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + query(i,j-1))\n\nans = dp[0][N]\nprint(ans)", "neg": "inf = float('inf')\n\ndef accmulate(array):\n global cs\n cs = [0]*(len(array)+1)\n for i in range(len(array)):\n cs[i+1] = cs[i] + array[i]\n\ndef query(l,r):\n return cs[r+1] - cs[l]\n\nN = int(input())\nA = list(map(int,input().split()))\n\naccmulate(A)\n\ndp = [[inf]*(N+1) for _ in range(N+1)]\n\nfor i in range(N):\n dp[i][i+1] = 0\n\nfor b in range(3,N+1):\n for i in range(N-b+1):\n j = i + b\n for k in range(i+1,j):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + query(i,j-1))\n\nans = dp[0][N]\nprint(ans)", "jacc_sim": 0.9787234042553191, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [291, 258], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u640524539", "n_user": "u640524539", "pos": "import fileinput\n\n\ndef solve_slimes(slimes):\n slime_union_table = [0] * len(slimes) * len(slimes)\n slime_cost_table = [0] * len(slimes) * len(slimes)\n\n for i in range(len(slimes)):\n slime_union_table[i] = slimes[i]\n\n for gap in range(1, len(slimes)):\n for li in range(len(slimes) - gap):\n split_size = slime_union_table[li] + slime_union_table[li + 1 + (gap - 1) * len(slimes)]\n slime_union_table[li + gap * len(slimes)] = split_size\n\n for split in range(0, gap):\n split_cost = slime_cost_table[li + split * len(slimes)] + slime_cost_table[li + split + 1 + (gap - split - 1) * len(slimes)] + split_size\n\n if slime_cost_table[li + gap * len(slimes)] == 0:\n slime_cost_table[li + gap * len(slimes)] = split_cost\n\n else:\n slime_cost_table[li + gap * len(slimes)] = min(\n split_cost,\n slime_cost_table[li + gap * len(slimes)]\n )\n return slime_cost_table[len(slimes) * (len(slimes) - 1)]\n\n\ninp = fileinput.FileInput()\n\ninp.readline()\nslimes = [int(v) for v in inp.readline().split()]\n\nprint(solve_slimes(slimes))", "neg": "import fileinput\n\n\ndef solve_slimes(slimes):\n slime_union_table = [0] * len(slimes) * len(slimes)\n slime_cost_table = [0] * len(slimes) * len(slimes)\n\n for i in range(len(slimes)):\n slime_union_table[i] = slimes[i]\n\n for gap in range(1, len(slimes)):\n for li in range(len(slimes) - gap):\n split_size = slime_union_table[li] + slime_union_table[li + 1 + (gap - 1) * len(slimes)]\n slime_union_table[li + gap * len(slimes)] = split_size\n\n for split in range(0, gap):\n split_cost = slime_cost_table[li + split * len(slimes)] + slime_cost_table[li + split + 1 + (gap - split - 1) * len(slimes)] + split_size\n\n if slime_cost_table[li + gap * len(slimes)] == 0:\n slime_cost_table[li + gap * len(slimes)] = split_cost\n\n else:\n slime_cost_table[li + gap * len(slimes)] = min(\n split_cost,\n slime_cost_table[li + gap * len(slimes)]\n )\n return slime_cost_table[len(slimes) * (len(slimes) - 1)]\n\n\ninp = fileinput.FileInput()\n\ninp.readline()\nslimes = [int(v) for v in inp.readline().split()]\n\nprint(solve_slimes(slimes)", "jacc_sim": 1.0, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [423, 423], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u794173881", "n_user": "u794173881", "pos": "n = int(input())\na = list(map(int, input().split()))\n\n#dp[l][r] = [l, r)\u533a\u9593\u306e\u30b9\u30e9\u30a4\u30e0\u3092\u5408\u4f53\u3059\u308b\u3068\u304d\u306e\u30b3\u30b9\u30c8\u306e\u6700\u5c0f\u5024\ndp = [[-1]*(n+1) for i in range(n+1)]\nfor i in range(n):\n dp[i][i] = 0\n\n#cost[r]-cost[l] = [l, r)\u533a\u9593\u3092\u5408\u8a08\u3057\u305f\u3068\u304d\u306e\u30b9\u30e9\u30a4\u30e0\u306e\u7dcf\u548c\ncost = [0]*(n+1)\nfor i in range(n):\n cost[i+1] = cost[i] + a[i]\n\n#\u30e1\u30e2\u5316\u518d\u5e30\u3067dp[0][n]\u6c42\u3081\u308b\ndef dfs(l, r):\n if dp[l][r] != -1:\n return dp[l][r]\n elif (r - l) == 1:\n dp[l][r] = 0\n return dp[l][r]\n else:\n res = float(\"inf\")\n for k in range(l + 1, r):\n #dp[l][k] + dp[k][r] + \u5408\u4f53\u306b\u5fc5\u8981\u306a\u30b3\u30b9\u30c8\n res = min(res, dfs(l, k) + dfs(k, r) + (cost[r] - cost[l]))\n dp[l][r] = res\n return dp[l][r]\n\ndfs(0, n)\nprint(dp[0][n])", "neg": "n = int(input())\na = list(map(int, input().split()))\n\n#dp[l][r] = [l, r)\u533a\u9593\u306e\u30b9\u30e9\u30a4\u30e0\u3092\ndp = [[float(\"inf\")]*(n+1) for i in range(n+1)]\nfor i in range(n):\n dp[i][i] = 0\n\n#cost[r]-cost[l] = [l, r)\u533a\u9593\u3092\u5408\u8a08\u3057\u305f\u3068\u304d\u306e\u30b9\u30e9\u30a4\u30e0\u306e\u7dcf\u548c\ncost = [0]*(n+1)\nfor i in range(n):\n cost[i+1] = cost[i] + a[i]\n\n#\u30e1\u30e2\u5316\u518d\u5e30\u3067dp[0][n]\u6c42\u3081\u308b\ndef dfs(l, r):\n if dp[l][r] != float(\"inf\"):\n return dp[l][r]\n else:\n res = float(\"inf\")\n if (r - l) == 1:\n dp[l][r] = 0\n return dp[l][r]\n for k in range(l, r):\n if k == l or k == r:\n continue\n #dp[l][k] + dp[k][r] + \u5408\u4f53\u306b\u5fc5\u8981\u306a\u30b3\u30b9\u30c8\n res = min(res, dfs(l, k) + dfs(k, r) + (cost[r] - cost[l]))\n print(l,k,r,dfs(l, k) + dfs(k, r))\n dp[l][r] = res\n return dp[l][r]\n\nprint(dp[0][n])", "jacc_sim": 0.9135802469135802, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [480, 470], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u270681687", "n_user": "u270681687", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nINF = float('inf')\ndp = [[INF] * (n+1) for _ in range(n+1)]\n\nacum = [0] * (n+1)\nfor i, ai in enumerate(a):\n acum[i+1] += acum[i] + ai\n\nfor i in range(n+1):\n dp[i][i] = 0\n if i+1 <= n:\n dp[i][i+1] = 0\n\nfor l in range(2, n+1):\n for i in range(n-l+1):\n j = i + l\n for k in range(i+1, j):\n dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + acum[j] - acum[i])\n\nprint(dp[0][n])", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nINF = float('inf')\ndp = [[INF] * (n+1) for _ in range(n+1)]\n\nacum = [0] * (n+1)\nfor i, ai in enumerate(a):\n acum[i+1] += acum[i] + ai\n\nfor i in range(n):\n dp[i][i] = 0\n dp[i][i+1] = 0\n\nfor l in range(2, n+1):\n for i in range(n-l+1):\n j = i + l\n dp[i][j] = min(dp[i+1][j], dp[i][j-1]) + acum[j] - acum[i]\n\nprint(dp[0][n])\n\n", "jacc_sim": 0.926829268292683, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [230, 205], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03173", "p_user": "u375616706", "n_user": "u375616706", "pos": "from itertools import accumulate\nimport sys\n# python template for atcoder1\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndp = [[float(0)]*N for _ in range(N)]\na_acc = [0]+list(accumulate(A))\n\n\ndef dfs(l, r):\n \"\"\"\n List[l:r]\n \"\"\"\n if dp[l][r-1] != float('inf'):\n return dp[l][r-1]\n if r-l == 1:\n dp[l][r-1] = 0\n return 0\n if r-l == 2:\n dp[l][r-1] = A[l]+A[r-1]\n return dp[l][r-1]\n else:\n dp[l][r-1] = min(dfs(l, v)+dfs(v, r)\n for v in range(l+1, r))+a_acc[r]-a_acc[l]\n return dp[l][r-1]\n\n\ndef bfs():\n for d in range(2, N+1):\n for l in range(0, N-d+1):\n r = l + d\n #print(\"l,r->\", l, r)\n tmp = float('inf')\n for m in range(l+1, r):\n tmp = min(tmp, dp[l][m-1]+dp[m][r-1])\n #print(\"tmp->\", tmp)\n #print(\"acc->\", a_acc[r]-a_acc[l])\n dp[l][r-1] = tmp+a_acc[r]-a_acc[l]\n\n\n# print(a_acc)\nbfs()\n# print(dp)\nans = int(dp[0][-1])\nprint(ans)\n", "neg": "from itertools import accumulate\nimport sys\n# python template for atcoder1\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndp = [[float(0)]*N for _ in range(N)]\na_acc = [0]+list(accumulate(A))\n\n\ndef dfs(l, r):\n \"\"\"\n List[l:r]\n \"\"\"\n if dp[l][r-1] != float('inf'):\n return dp[l][r-1]\n if r-l == 1:\n dp[l][r-1] = 0\n return 0\n if r-l == 2:\n dp[l][r-1] = A[l]+A[r-1]\n return dp[l][r-1]\n else:\n dp[l][r-1] = min(dfs(l, v)+dfs(v, r)\n for v in range(l+1, r))+a_acc[r]-a_acc[l]\n return dp[l][r-1]\n\n\ndef bfs():\n for d in range(2, N+1):\n for l in range(0, N-d+1):\n r = l + d\n #print(\"l,r->\", l, r)\n tmp = float('inf')\n for m in range(l+1, r):\n tmp = min(tmp, dp[l][m-1]+dp[m][r-1])\n #print(\"tmp->\", tmp)\n #print(\"acc->\", a_acc[r]-a_acc[l])\n dp[l][r-1] = tmp+a_acc[r]-a_acc[l]\n\n\n# print(a_acc)\nbfs()\n# print(dp)\nprint(dp[0][-1])\n", "jacc_sim": 0.9841269841269841, "nl": "You have N slimes lined up, each with a specific size. You want to combine them into one larger slime with the least total cost. To do this, you repeatedly choose two adjacent slimes and combine them into a new slime. The cost of combining two slimes is the sum of their sizes. Find the minimum possible total cost. The input consists of N and the sizes of the slimes, and the output is the minimum total cost.", "before_after_length": [471, 464], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u408325839", "n_user": "u408325839", "pos": "import sys\nsys.setrecursionlimit(10**9)\n\nMOD = 10**9 + 7\nN = int(input())\npaths = {i:[] for i in range(N+1)}\nfor _ in range(N-1):\n x, y = map(int, input().split())\n paths[x].append(y)\n paths[y].append(x)\n\ndpt = [[-1] * 2 for i in range(N+1)]\n\ndef count_cc(prev, node, color):\n if dpt[node][color] != -1:\n return dpt[node][color]\n if paths[node] == [prev]:\n dpt[node][color] = 1\n return 1\n result = 1\n if color == 0:\n for nxt in paths[node]:\n if nxt == prev:\n continue\n result *= (count_cc(node, nxt, 0) + count_cc(node, nxt, 1))\n result %= MOD\n else:\n for nxt in paths[node]:\n if nxt == prev:\n continue\n result *= count_cc(node, nxt, 0)\n result %= MOD\n\n dpt[node][color] = result\n return result\n\nprint((count_cc(0, 1, 0) + count_cc(0, 1, 1)) % MOD)\n", "neg": "MOD = 10**9 + 7\nN = int(input())\npaths = {i:[] for i in range(N+1)}\nfor _ in range(N-1):\n x, y = map(int, input().split())\n paths[x].append(y)\n paths[y].append(x)\n\ndpt = [[[-1] * 2 for i in range(N+1)] for j in range(N+1)]\n\ndef count_cc(prev, node, color):\n if dpt[prev][node][color] != -1:\n return dpt[prev][node][color]\n if paths[node] == [prev]:\n dpt[prev][node][color] = 1\n return 1\n result = 1\n if color == 0:\n for nxt in paths[node]:\n if nxt == prev:\n continue\n result *= (count_cc(node, nxt, 0) + count_cc(node, nxt, 1))\n result %= MOD\n else:\n for nxt in paths[node]:\n if nxt == prev:\n continue\n result *= count_cc(node, nxt, 0)\n result %= MOD\n\n dpt[prev][node][color] = result\n return result\n\nprint(count_cc(0, 2, 0) + count_cc(0, 2, 1))\n", "jacc_sim": 0.9245283018867925, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [321, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u325227960", "n_user": "u325227960", "pos": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nC = [list(map(int,input().split())) for i in range(n-1)]\nmod = 10**9 + 7\n\nfor i in range(n-1):\n for j in range(2):\n C[i][j] -= 1\n\nans = 0\nM = [[] for i in range(n)]\nfor i in range(n-1):\n M[C[i][0]].append(C[i][1])\n M[C[i][1]].append(C[i][0])\n\nD = [[1,1] for i in range(n)]\nMN = [len(M[i]) for i in range(n)]\n# print(\"MN\", MN)\n\nV = [0] * n\nQ = []\nfor i in range(1, n):\n if MN[i] == 1:\n Q.append(i)\n V[i] = 1\n\n# print(Q)\n\ns = 0\nwhile s < len(Q):\n x = Q[s]\n for y in M[x]:\n if V[y] == 0:\n # print(\"y\",y)\n D[y][0] = (D[y][0] * sum(D[x])) % mod\n D[y][1] = (D[y][1] * D[x][0]) % mod\n MN[y] -= 1\n if (y != 0 and MN[y] == 1) or (y == 0 and MN[y] == 0):\n V[y] = 1\n Q.append(y)\n s += 1\n\nprint(sum(D[0]) % mod)\n", "neg": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nC = [list(map(int,input().split())) for i in range(n-1)]\nmod = 10**9 + 7\n\nfor i in range(n-1):\n for j in range(2):\n C[i][j] -= 1\n\nans = 0\nM = [[] for i in range(n)]\nfor i in range(n-1):\n M[C[i][0]].append(C[i][1])\n M[C[i][1]].append(C[i][0])\n\nD = [[1,1] for i in range(n)]\nMN = [len(M[i]) for i in range(n)]\n# print(\"MN\", MN)\n\nV = [0] * n\nQ = []\nfor i in range(1, n):\n if MN[i] == 1:\n Q.append(i)\n V[i] = 1\n\n# print(Q)\n\ns = 0\nwhile s < len(Q):\n x = Q[s]\n for y in M[x]:\n if V[y] == 0:\n print(\"y\",y)\n D[y][0] = (D[y][0] * sum(D[x])) % mod\n D[y][1] = (D[y][1] * D[x][0]) % mod\n MN[y] -= 1\n if (y != 0 and MN[y] == 1) or (y == 0 and MN[y] == 0):\n V[y] = 1\n Q.append(y)\n s += 1\n\nprint(sum(D[0]) % mod)\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [420, 419], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u581187895", "n_user": "u581187895", "pos": "\nimport sys\nsys.setrecursionlimit(10 ** 7)\ninp = sys.stdin.buffer.readline\n\n\ndef resolve():\n MOD = 10 ** 9 + 7\n\n # 0: white, 1: black\n def dfs(v, parent):\n vistied[v] = True\n dp[v][0] = 1\n dp[v][1] = 1\n for to in G[v]:\n if to == parent or vistied[to]:\n continue\n dfs(to, v)\n # \u89aa\u304c\u767d\u306e\u6642\u306f\u5b50\u306f\u767d\u9ed2\u3069\u3063\u3061\u3067\u3082\u826f\u3044\n # \u89aa\u304c\u9ed2\u306e\u6642\u306f\u5b50\u306f\u767d\u306e\u307f\n dp[v][0] *= (dp[to][0] + dp[to][1]) % MOD\n dp[v][1] *= dp[to][0] % MOD\n\n N = int(inp())\n G = [[] for _ in range(N)]\n for _ in range(N - 1):\n x, y = map(lambda x: int(x) - 1, inp().split())\n G[x].append(y)\n G[y].append(x)\n dp = [[0] * 2 for _ in range(N)]\n vistied = [False] * N\n\n dfs(0, -1)\n ans = dp[0][0] + dp[0][1]\n print(ans % MOD)\n\n\nif __name__ == \"__main__\":\n resolve()", "neg": "\nimport sys\nsys.setrecursionlimit(10 ** 7)\nread = sys.stdin.buffer.read \ninp = sys.stdin.buffer.readline\n\n\ndef resolve():\n MOD = 10 ** 9 + 7\n\n # 0: white, 1: black\n def dfs(v, parent):\n dp[v][0] = 1\n dp[v][1] = 1\n for to in G[v]:\n if to == parent:\n continue\n dfs(to, v)\n # \u89aa\u304c\u767d\u306e\u6642\u306f\u5b50\u306f\u767d\u9ed2\u3069\u3063\u3061\u3067\u3082\u826f\u3044\n # \u89aa\u304c\u9ed2\u306e\u6642\u306f\u5b50\u306f\u767d\u306e\u307f\n dp[v][0] = (dp[v][0] * (dp[to][0] + dp[to][1])) % MOD\n dp[v][1] = (dp[v][1] * dp[to][0]) % MOD\n\n N = int(input())\n G = [[] for _ in range(N)]\n for _ in range(N - 1):\n x, y = map(lambda x: int(x) - 1, inp().split())\n G[x].append(y)\n G[y].append(x)\n dp = [[0] * 2 for _ in range(N + 1)]\n\n dfs(0, -1)\n ans = dp[0][0] + dp[0][1]\n print(ans % MOD)\n\n\nif __name__ == \"__main__\":\n resolve()", "jacc_sim": 0.9230769230769231, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [410, 412], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\nns = [[] for _ in range(n)]\nfor i in range(n-1):\n u,v = map(int, input().split())\n u -= 1\n v -= 1\n ns[u].append(v)\n ns[v].append(u)\n\nd1 = [None]*n\nd2 = [None]*n\nM = 10**9+7\ndef sub(u, p):\n if d1[u] is not None:\n return d1[u], d2[u]\n v1 = 1 # \u767d\n v2 = 1 # \u9ed2\n for v in ns[u]:\n if v==p:\n continue\n w1, w2 = sub(v, u)\n v1 *= (w1+w2)\n v2 *= w1\n v1 %= M\n v2 %= M\n d1[u] = v1\n d2[u] = v2\n return v1, v2\nsub(0, -1)\nprint((d1[0]+d2[0])%M)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\nns = [[] for _ in range(n)]\nfor i in range(n-1):\n u,v = map(int, input().split())\n u -= 1\n v -= 1\n ns[u].append(v)\n ns[v].append(u)\n\nM = 10**9+7\ndef sub(u, p):\n v1 = 1 # \u767d\n v2 = 1 # \u9ed2\n for v in ns[u]:\n if v==p:\n continue\n w1, w2 = sub(v, u)\n v1 *= (w1+w2)\n v2 *= w1\n v1 %= M\n v2 %= M\n return v1, v2\nsub(0, -1)\nprint((d1[0]+d2[0])%M)", "jacc_sim": 0.9538461538461539, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [320, 259], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u225388820", "n_user": "u225388820", "pos": "import sys\nsys.setrecursionlimit(1000000000)\ninput = sys.stdin.readline\nmod=10**9+7\nn=int(input())\nes=[[] for i in range(n)]\nfor i in range(n-1):\n a,b=map(int,input().split())\n es[a-1].append(b-1)\n es[b-1].append(a-1)\ndp=[[0,0] for i in range(n)]\ndef dfs(v,c,p):\n if dp[v][c]:\n return dp[v][c]\n ans=1\n if c:\n for i in es[v]:\n if i-p:\n ans*=dfs(i,0,v)+dfs(i,1,v)\n ans%=mod\n else:\n for i in es[v]:\n if i-p:\n ans*=dfs(i,1,v)\n ans%=mod\n # print(ans,c,v)\n dp[v][c]=ans\n return ans\nprint((dfs(0,0,-1)+dfs(0,1,-1))%mod)", "neg": "import sys\nsys.setrecursionlimit(1000000000)\ninput = sys.stdin.readline\nmod=10**9+7\nn=int(input())\nes=[[] for i in range(n)]\nfor i in range(n-1):\n a,b=map(int,input().split())\n es[a-1].append(b-1)\n es[b-1].append(a-1)\ndp=[[0,0] for i in range(n)]\ndef dfs(v,c,p):\n if dp[v][c]:\n return dp[v][c]\n ans=0\n if c:\n for i in es[v]:\n if i-p:\n ans+=dfs(i,0,v)+dfs(i,1,v)\n else:\n for i in es[v]:\n if i-p:\n ans+=dfs(i,1,v)\n # print(ans,c,v)\n dp[v][c]=max(ans%mod,1)\n return max(ans%mod,1)\nprint((dfs(0,0,-1)+dfs(0,1,-1))%mod)", "jacc_sim": 0.98, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [283, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u886747123", "n_user": "u886747123", "pos": "import sys\ninput = sys.stdin.buffer.readline\nsys.setrecursionlimit(1000000000)\n\nN, *XY = map(int,open(0).read().split())\nMOD = 10**9 + 7\n\nneighbor = [[] for _ in range(N)]\nfor x,y in zip(*[iter(XY)]*2):\n neighbor[x-1] += y-1,\n neighbor[y-1] += x-1,\n\nparent = {0}\n\ndef dp(node):\n black_output = white_output = 1\n for child in neighbor[node]:\n if child in parent:\n continue\n else:\n parent.add(child)\n tmp_black, tmp_white = dp(child)\n black_output *= tmp_white\n white_output *= tmp_black + tmp_white\n black_output %= MOD\n white_output %= MOD\n return black_output, white_output\n\nprint(sum(dp(0)) % MOD)", "neg": "import sys\ninput = sys.stdin.buffer.readline\nsys.setrecursionlimit(1000000000)\n\nN, *XY = map(int,open(0).read().split())\nMOD = 10**9 + 7\n\nneighbor = [[] for _ in range(N)]\nfor x,y in zip(*[iter(XY)]*2):\n neighbor[x-1] += y-1\n neighbor[y-1] += x-1\n\nparent = {0}\n\ndef dp(node):\n black_output = white_output = 1\n for child in neighbor[node]:\n if child in parent:\n continue\n else:\n parent.add(child)\n tmp_black, tmp_white = dp(child)\n black_output *= tmp_white\n white_output *= tmp_black + tmp_white\n black_output %= MOD\n white_output %= MOD\n return black_output, white_output\n\nprint(sum(dp(0)) % MOD)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [234, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u497046426", "n_user": "u497046426", "pos": "MOD = 10**9 + 7\nN = int(input())\nE = [[] for _ in range(N)]\nfor _ in range(N-1):\n x, y = map(int, input().split())\n E[x-1].append(y-1); E[y-1].append(x-1)\n\npreorder = [-1] * N # a dfs preordering of each vertex\ndp = [[1] * 2 for _ in range(N)]\nstack = [(0, -1, 0)] # (vertex, parent, status)\npre_num = 0 # current preordering\nwhile stack:\n v, p, st = stack.pop()\n if st == 0 and preorder[v] < 0: # visited v for the first time\n preorder[v] = pre_num\n pre_num += 1\n n_children = 0\n for u in E[v]:\n if preorder[u] >= 0:\n continue\n if n_children == 0:\n stack += [(v, p, 2), (u, v, 0)]\n n_children += 1\n else:\n stack += [(v, p, 1), (u, v, 0)]\n n_children += 1\n if n_children == 0 and p != -1: # v is a leaf\n dp[p][0] *= dp[v][0] + dp[v][1]\n dp[p][0] %= MOD\n dp[p][1] *= dp[v][0]\n dp[p][1] %= MOD\n elif st == 0 and preorder[v] >= 0: # the edge (v, p) is a back edge\n continue\n elif st == 1: # now searching\n continue\n else: # search finished\n if p != -1:\n dp[p][0] *= dp[v][0] + dp[v][1]\n dp[p][0] %= MOD\n dp[p][1] *= dp[v][0]\n dp[p][1] %= MOD\nprint((dp[0][0] + dp[0][1]) % MOD)", "neg": "MOD = 10**9 + 7\nN = int(input())\nE = [[] for _ in range(N)]\nfor _ in range(N-1):\n x, y = map(int, input().split())\n E[x-1].append(y-1); E[y-1].append(x-1)\n\npreorder = [-1] * N # a dfs preordering of each vertex\ndp = [[1] * 2 for _ in range(N)]\nstack = [(0, -1, 0)] # (vertex, parent, status)\npre_num = 0 # current preordering\nwhile stack:\n v, p, st = stack.pop()\n if st == 0 and preorder[v] < 0: # visited v for the first time\n preorder[v] = pre_num\n pre_num += 1\n n_children = 0\n for u in E[v]:\n if preorder[u] >= 0:\n continue\n if n_children == 0:\n stack += [(v, p, 2), (u, v, 0)]\n n_children += 1\n else:\n stack += [(v, p, 1), (u, v, 0)]\n n_children += 1\n if n_children == 0: # v is a leaf\n dp[v][0] = dp[v][1] = 1\n dp[p][0] *= dp[v][0] + dp[v][1]\n dp[p][0] %= MOD\n dp[p][1] *= dp[v][0]\n dp[p][1] %= MOD\n elif st == 0 and preorder[v] >= 0: # the edge (v, p) is a back edge\n continue\n elif st == 1: # now searching\n continue\n else: # search finished\n if p != -1:\n dp[p][0] *= dp[v][0] + dp[v][1]\n dp[p][0] %= MOD\n dp[p][1] *= dp[v][0]\n dp[p][1] %= MOD\nprint((dp[0][0] + dp[0][1]) % MOD)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [496, 508], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u389347166", "n_user": "u389347166", "pos": "modulo = 1000000007\n\nimport sys\nsys.setrecursionlimit(100000009)\n\n\nmuchii = []\n\n\ndef recursie(x, y):\n alb = 1\n negru = 1\n for elem in muchii[x]:\n if elem == y:\n continue\n result_1, result_2 = recursie(elem, x)\n alb = (alb * (result_1 + result_2)) % modulo\n negru = (negru * result_1) % modulo\n return alb, negru\n \n\nif __name__ == \"__main__\":\n input = sys.stdin.readline\n n = int(input())\n for i in range(n):\n muchii.append([])\n \n for i in range(n-1):\n numbers = list(map(int, input().split(\" \")))\n \n x = numbers[0]\n y = numbers[1]\n \n muchii[x-1].append(y-1)\n muchii[y-1].append(x-1)\n \n result_1, result_2 = recursie(0, None)\n \n result = (result_1 + result_2) % modulo\n \n print(result)\n", "neg": "modulo = 1000000007\n\nimport sys\nsys.setrecursionlimit(100000009)\n\nmuchii = []\n\n\ndef recursie(x, y):\n alb = 1\n negru = 1\n for elem in muchii[x]:\n if x == y:\n continue\n result_1, result_2 = recursie(elem, x)\n alb = (alb * (result_1 + result_2)) % modulo\n negru = (negru * result_1) % modulo\n return alb, negru\n \n\nif __name__ == \"__main__\":\n \n n = int(input())\n for i in range(n):\n muchii.append([])\n \n for i in range(n-1):\n numbers = list(map(int, input().split()))\n \n x = numbers[0]\n y = numbers[1]\n \n muchii[x-1].append(y-1)\n muchii[y-1].append(x-1)\n \n result_1, result_2 = recursie(0, None)\n \n result = (result_1 + result_2) % modulo\n \n print(result)\n", "jacc_sim": 0.9622641509433962, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [310, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u310678820", "n_user": "u310678820", "pos": "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**9)\n from collections import deque\n mod = 10**9+7\n N = int(input())\n G = [[] for _ in range(N)]\n for _ in range(N-1):\n x, y = map(int, input().split())\n G[x-1].append(y-1)\n G[y-1].append(x-1)\n que = deque([0])\n children = [[] for _ in range(N)]\n while que:\n v = que.pop()\n for nv in G[v]:\n if children[nv]:\n continue\n children[v].append(nv)\n que.append(nv) \n memo = [[-1]*2 for _ in range(N)]\n def dp(i, c):\n if memo[i][c] >=0:\n return memo[i][c]\n if c == 1:\n res = 1\n for j in children[i]:\n res*=dp(j, 0)\n res%=mod\n memo[i][c] = res\n else:\n res = 1\n for j in children[i]:\n res*=(dp(j, 0)+dp(j, 1))\n res%=mod\n memo[i][c]= res\n return memo[i][c]\n print((dp(0, 0)+dp(0, 1))%mod)\nmain()\n", "neg": "def main():\n input = sys.stdin.readline\n import sys\n sys.setrecursionlimit(10**9)\n from collections import deque\n mod = 10**9+7\n N = int(input())\n G = [[] for _ in range(N)]\n for _ in range(N-1):\n x, y = map(int, input().split())\n G[x-1].append(y-1)\n G[y-1].append(x-1)\n que = deque([0])\n children = [[] for _ in range(N)]\n while que:\n v = que.pop()\n for nv in G[v]:\n if children[nv]:\n continue\n children[v].append(nv)\n que.append(nv) \n memo = [[-1]*2 for _ in range(N)]\n def dp(i, c):\n if memo[i][c] >=0:\n return memo[i][c]\n if c == 1:\n res = 1\n for j in children[i]:\n res*=dp(j, 0)\n res%=mod\n memo[i][c] = res\n else:\n res = 1\n for j in children[i]:\n res*=(dp(j, 0)+dp(j, 1))\n res%=mod\n memo[i][c]= res\n return memo[i][c]\n print((dp(0, 0)+dp(0, 1))%mod)\nmain()\n", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [366, 366], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u316464887", "n_user": "u316464887", "pos": "import sys\nsys.setrecursionlimit(10000000)\ndef main():\n N = int(input())\n d = {}\n v = set()\n if N == 1:\n return 2\n for _ in range(N-1):\n x, y = map(int, input().split())\n if x in d:\n d[x].append(y)\n else:\n d[x] = [y]\n if y in d:\n d[y].append(x)\n else:\n d[y] = [x]\n w, b = dfs(1, d, v)\n return w + b\ndef dfs(node, d, v):\n v.add(node)\n l = []\n for i in d[node]:\n if i in v:\n continue\n w, b = dfs(i, d, v)\n l.append((w,b))\n w = 1\n b = 1\n for tw, tb in l:\n w *= (tw + tb)\n b *= tw\n return w, b\n\nprint(main() % (10**9 + 7))\n", "neg": "import sys\nsys.setrecursionlimit(10000000)\ndef main():\n N = int(input())\n d = {}\n v = set()\n for _ in range(N-1):\n x, y = map(int, input().split())\n if x in d:\n d[x].append(y)\n else:\n d[x] = [y]\n if y in d:\n d[y].append(x)\n else:\n d[y] = [x]\n w, b = dfs(1, d, v)\n return w + b\ndef dfs(node, d, v):\n v.add(node)\n l = []\n for i in d[node]:\n if i in v:\n continue\n w, b = dfs(i, d, v)\n l.append((w,b))\n w = 1\n b = 1\n for tw, tb in l:\n w *= (tw + tb)\n b *= tw\n return w, b\n\nprint(main() % (10**9 + 7))\n", "jacc_sim": 0.9814814814814815, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [273, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u619819312", "n_user": "u619819312", "pos": "import sys\nsys.setrecursionlimit(10**6)\nn=int(input())\ns=[[]for i in range(n+1)]\nm=10**9+7\nfor i in range(n-1):\n x,y=map(int,input().split())\n s[x].append(y)\n s[y].append(x)\nt=[[0,0]for i in range(n+1)]\ndef f(a,b):\n t[a][0]=t[a][1]=1\n for i in s[a]:\n if i!=b:\n f(i,a)\n t[a][0]*=t[i][0]+t[i][1]\n t[a][1]*=t[i][0]\nf(1,0)\nprint(sum(t[1])%m)", "neg": "import sys\nsys.setrecursionlimit(10**6)\nn=int(input())\ns=[[]for i in range(n+1)]\nm=10**9+7\nfor i in range(n-1):\n x,y=map(int,input().split())\n s[x].append(y)\n s[y].append(x)\nt=[[0,0]for i in range(n+1)]\ndef f(a,b):\n t[a][0]=t[a][1]=1\n for i in s[a]:\n if i!=b:\n f(i,a)\n t[a][0]*=t[i][0]+t[i][1]\n t[a][1]*=*t[i][0]\nf(1,0)\nprint(sum(t[1])%m)", "jacc_sim": 1.0, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [207, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u123756661", "n_user": "u123756661", "pos": "\nimport sys\nsys.setrecursionlimit(100005)\nmod=1000000007\n# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2\n\ndef dfs(v,a):\n w=b=1\n for u in links[v]:\n if u==a:\n continue\n cw,cb=dfs(u,v)\n w*=cw+cb\n b*=cw\n w%=mod\n b%=mod\n return w,b\n\n\nn=int(input())\nlinks=[set() for i in range(n)]\n\nfor line in sys.stdin.readlines():\n x,y=map(int, line.split())\n x-=1\n y-=1\n links[x].add(y)\n links[y].add(x)\n\nprint(sum(dfs(0,None))%mod)", "neg": "import sys\nsys.setrecursionlimit(100005)\nmod=1000000007\n# https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_2\n\ndef dfs(v,a):\n w,b=,1,1\n for u in links[v]:\n if u==a:\n continue\n cw,cb=dfs(u,v)\n w*=cw*cb\n b*=cw\n w%=mod\n b%=mod\n return w,b\n\n\nn=int(input())\nlinks=[set() for i in range(n)]\n\nfor line in sys.stdin.readlines():\n x,y=map(int, input().split())\n x-=1\n y-=1\n links[x].add(y)\n links[y].add(x)\n\nprint(sum(dfs(0,None)%mod))\n", "jacc_sim": 0.9841269841269841, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [233, 236], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u736604846", "n_user": "u736604846", "pos": "import sys\nsys.setrecursionlimit(10**9)\n \nBLK = 1\nWHT = 0\nMOD = 10 ** 9 + 7\n \n \ndef calcdp(r, p, bw):\n if dp[r][bw] != -1:\n return dp[r][bw]\n \n if p == 0:\n cs = H[r]\n else:\n cs = H[r] - {p}\n \n if len(cs) == 0:\n dp[r][bw] = 1\n return 1\n else:\n if bw == BLK:\n res = 1\n for c in cs:\n res = (res * calcdp(c, r, WHT)) % MOD\n dp[r][BLK] = res\n return res\n else:\n res = 1\n for c in cs:\n res = (res * (calcdp(c, r, WHT) + calcdp(c, r, BLK))) % MOD\n dp[r][WHT] = res\n \n return res\n \n \nN = int(input())\nH = [set() for _ in range(N + 1)]\nfor _ in range(1, N):\n x, y = map(int, input().split())\n H[x].add(y)\n H[y].add(x)\n \ndp = [[-1] * 2 for _ in range(N + 1)]\n \nprint((calcdp(1, 0, BLK) + calcdp(1, 0, WHT)) % MOD)", "neg": "import sys\nsys.setrecursionlimit(10**9)\n\nBLK = 1\nWHT = 0\nMOD = 10 ** 9 + 7\n\n\ndef calcdp(r, p, bw):\n if dp[r][bw] != -1:\n return dp[r][bw]\n\n if len(H[r]) <= 1:\n dp[r][bw] = 1\n return 1\n else:\n cs = H[r] - {p}\n if bw == BLK:\n res = 1\n for c in cs:\n res = (res * calcdp(c, r, WHT)) % MOD\n dp[r][BLK] = res\n return res\n else:\n res = 1\n for c in cs:\n res = (res * (calcdp(c, r, WHT) + calcdp(c, r, BLK))) % MOD\n dp[r][WHT] = res\n\n return res\n\n\nN = int(input())\nH = [set() for _ in range(N + 1)]\nfor _ in range(1, N):\n x, y = map(int, input().split())\n H[x].add(y)\n H[y].add(x)\n\ndp = [[-1] * 2 for _ in range(N + 1)]\n\nprint((calcdp(1, 0, BLK) + calcdp(1, 0, WHT)) % MOD)", "jacc_sim": 0.9821428571428571, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [374, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u221230011", "n_user": "u221230011", "pos": "import sys\ninput = sys.stdin.readline\n\nMOD=10**9+7\n \nn=int(input())\nedge=[[] for _ in range(n)]\nfor _ in range(n-1):\n p,q = [int(i)-1 for i in input().split()]\n edge[p].append(q)\n edge[q].append(p)\n\nflag=[0]*n\nflag[0]=1\nif n==1:\n ans=2\nelse:\n dp=[[0] * 2 for i in range(n)]\n for i in range(n):\n if len(edge[i])==1:\n dp[i]=[1,1]\n flag[i]=1\n else:\n dp[i]=[0,0]\n dp[0]=[0,0]\n stack = [0]\n while len(stack)!=0:\n term=0\n white=1\n black=1\n length=len(stack)-1\n for i in range(len(edge[stack[length]])):\n if flag[edge[stack[length]][i]]==0:\n flag[edge[stack[length]][i]]=1\n stack.append(edge[stack[length]][i])\n term=1\n else:\n sub1=max(1,(dp[edge[stack[length]][i]][0]+dp[edge[stack[length]][i]][1])%MOD)\n sub2=max(1,dp[edge[stack[length]][i]][0])\n white=(white*sub1)%MOD\n black=(black*sub2)%MOD\n if term == 0:\n dp[stack[length]]=[white,black]\n stack.pop()\n \n ans = (dp[0][0]+dp[0][1])%MOD\n\nprint(ans)", "neg": "MOD=10**9+7\n \nn=int(input())\nedge=[[] for _ in range(n)]\nfor _ in range(n-1):\n p,q = [int(i)-1 for i in input().split()]\n edge[p].append(q)\n edge[q].append(p)\n\nflag=[0]*n\n\nif n==1:\n ans=2\nelse:\n dp=[[0] * 2 for i in range(n)]\n for i in range(n):\n if len(edge[i])==1:\n dp[i]=[1,1]\n flag[i]=1\n else:\n dp[i]=[0,0]\n dp[0]=[0,0]\n stack = [0]\n while len(stack)!=0:\n term=0\n white=1\n black=1\n for i in range(len(edge[stack[len(stack)-1]])):\n if flag[edge[stack[len(stack)-1]]]==0:\n flag[edge[stack[len(stack)-1]][i]]=1\n stack.append(edge[stack[len(stack)-1]][i])\n term=1\n else:\n sub1=max(1,(dp[edge[stack[len(stack)-1]][i]][0]+dp[edge[stack[len(stack)-1]][i]][0])%MOD)\n sub2=max(1,dp[edge[stack[len(stack)-1]][i]][0])\n white=(white*sub1)%MOD\n black=(black*sub2)%MOD\n if term == 0:\n dp[stack[len(stack)-1]]=[white,black]\n stack.pop()\n \n ans = (dp[0][0]+dp[0][1])%MOD\n\n\nprint(ans)", "jacc_sim": 0.9074074074074074, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [453, 456], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03175", "p_user": "u766684188", "n_user": "u766684188", "pos": "import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10**7)\nmod=10**9+7\nn=int(input())\nedges=[[] for _ in range(n)]\nfor _ in range(n-1):\n x,y=map(int,input().split())\n edges[x-1].append(y-1)\n edges[y-1].append(x-1)\nC=[[] for _ in range(n)]\n\ndef fill_C(v,par):\n for c in edges[v]:\n if c==par:\n continue\n C[v].append(c)\n fill_C(c,v)\nfill_C(0,-1)\n\nDP=[[-1,-1] for _ in range(n)]\n\ndef white(v):\n if DP[v][0]!=-1:\n return DP[v][0]\n res=1\n for c in C[v]:\n res*=white(c)+black(c)\n res%=mod\n DP[v][0]=res\n return res\ndef black(v):\n if DP[v][1]!=-1:\n return DP[v][1]\n res=1\n for c in C[v]:\n res*=white(c)\n res%=mod\n DP[v][1]=res\n return res\n\nprint((black(0)+white(0))%mod)", "neg": "import sys\ninput=sys.stdin.readline\nsys.setrecursionlimit(10**7)\nmod=10**9+7\nn=int(input())\nedges=[[] for _ in range(n)]\nfor _ in range(n-1):\n x,y=map(int,input().split())\n edges[x-1].append(y-1)\n edges[y-1].append(x-1)\nC=[[] for _ in range(n)]\n\ndef fill_C(v,par):\n for c in edges[v]:\n if c==par:\n continue\n C[v].append(c)\n fill_C(c,v)\nfill_C(root,-1)\n\nDP=[[-1,-1] for _ in range(n)]\n\ndef white(v):\n if DP[v][0]!=-1:\n return DP[v][0]\n res=1\n for c in C[v]:\n res*=white(c)+black(c)\n res%=mod\n DP[v][0]=res\n return res\ndef black(v):\n if DP[v][1]!=-1:\n return DP[v][1]\n res=1\n for c in C[v]:\n res*=white(c)\n res%=mod\n DP[v][1]=res\n return res\n\nprint((black(0)+white(0))%mod)", "jacc_sim": 0.9807692307692307, "nl": "You are given a tree with N vertices, numbered 1 to N. Each edge connects two vertices. Taro wants to paint each vertex white or black, but cannot paint two adjacent vertices both black. Find the number of ways to paint the vertices, modulo 10^9 + 7. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 xi, yi \u2264 N, and the given graph is a tree. Input is given as N followed by pairs of xi and yi. Output the number of ways to paint the vertices.", "before_after_length": [356, 356], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03176", "p_user": "u408325839", "n_user": "u408325839", "pos": "class BITmax:\n def __init__(self, N, init=0):\n self.init = init\n self.tree = [self.init] * (N+1)\n \n def set(self, x, value):\n while x < N + 1:\n old = self.tree[x]\n if value <= old:\n break\n self.tree[x] = value\n x += x & -x\n \n def find_max_to(self, x):\n result = self.init\n while x > 0:\n result = max(result, self.tree[x])\n x -= x & -x\n return result\n\nN = int(input())\ndpt = BITmax(N)\n\nh_list = list(map(int, input().split()))\nb_list = list(map(int, input().split()))\n\nfor h, b in zip(h_list, b_list):\n dpt.set(h, dpt.find_max_to(h-1) + b)\n\nprint(max(dpt.tree))\n", "neg": "class BITmax:\n def __init__(self, N, init=0):\n self.init = init\n self.tree = [self.init] * (N+1)\n \n def set(self, x, value):\n while x < N + 1:\n old = self.tree[x]\n if value <= old:\n break\n self.tree[x] = value\n x += x & -x\n \n def find_max_to(self, x):\n result = self.init\n while x > 0:\n result = max(result, self.tree[x])\n x -= x & -x\n return result\n\ndef main():\n N = int(input())\n dpt = BITmax(N)\n\n h_list = list(map(int, input().split()))\n b_list = list(map(int, input().split()))\n\n for h, b in zip(h_list, b_list):\n dpt.set(h, dpt.find_max_to(h-1) + b)\n\n print(max(dpt.tree))\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9245283018867925, "nl": "You are given N flowers arranged in a row, each with a height and beauty. Taro wants to pull out some flowers so that the remaining ones have monotonically increasing heights. Find the maximum sum of the remaining flowers' beauties. Constraints: N (1 \u2264 N \u2264 2 \u00d7 10^5), heights (1 \u2264 hi \u2264 N), distinct heights, and beauty (1 \u2264 ai \u2264 10^9). Input format: N, followed by N heights and N beauties. Output the maximum sum of remaining flowers' beauties. Example: Input 4, heights 3 1 4 2, beauties 10 20 30 40. Output 60.", "before_after_length": [262, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03176", "p_user": "u588341295", "n_user": "u588341295", "pos": "# -*- coding: utf-8 -*-\n\ndef main():\n import sys\n\n def input(): return sys.stdin.readline().strip()\n def INT(): return int(input())\n def MAP(): return map(int, input().split())\n def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\n \n def query(i):\n s = intv\n i += 1\n while i > 0:\n s = max(s, tree[i-1])\n i -= i & -i\n return s\n \n def update(i, x):\n i += 1\n while i <= size:\n tree[i-1] = max(tree[i-1], x)\n i += i & -i\n\n n = INT()\n H = LIST()\n A = LIST()\n\n n += 2\n nv = 1\n while nv < n:\n nv *= 2\n size = nv\n intv = 0\n tree = [intv] * nv\n\n for h, a in zip(H, A):\n mx = query(h)\n update(h, mx + a)\n ans = query(n)\n print(ans)\nmain()\n", "neg": "# -*- coding: utf-8 -*-\n\ndef main():\n import sys\n\n def input(): return sys.stdin.readline().strip()\n def INT(): return int(input())\n def MAP(): return map(int, input().split())\n def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]\n \n def query(i):\n s = intv\n i += 1\n while i > 0:\n s = max(s, tree[i-1])\n i -= i & -i\n return s\n \n def update(i, x):\n i += 1\n while i <= size:\n tree[i-1] = max(tree[i-1], x)\n i += i & -i\n\n n = INT()\n H = LIST()\n A = LIST()\n\n n += 1\n nv = 1\n while nv < n:\n nv *= 2\n size = nv\n intv = 0\n tree = [intv] * nv\n\n for h, a in zip(H, A):\n mx = query(h)\n update(h, mx + a)\n ans = query(n)\n print(ans)\nmain()\n", "jacc_sim": 1.0, "nl": "You are given N flowers arranged in a row, each with a height and beauty. Taro wants to pull out some flowers so that the remaining ones have monotonically increasing heights. Find the maximum sum of the remaining flowers' beauties. Constraints: N (1 \u2264 N \u2264 2 \u00d7 10^5), heights (1 \u2264 hi \u2264 N), distinct heights, and beauty (1 \u2264 ai \u2264 10^9). Input format: N, followed by N heights and N beauties. Output the maximum sum of remaining flowers' beauties. Example: Input 4, heights 3 1 4 2, beauties 10 20 30 40. Output 60.", "before_after_length": [306, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03176", "p_user": "u619819312", "n_user": "u619819312", "pos": "n=int(input())\ndef f(x):\n s=0\n while x>0:\n s=max(s,t[x])\n x-=x&-x\n return s\ndef g(x,y):\n while x0:\n s=max(s,t[x])\n x-=x&-x\n return s\ndef g(x,y):\n while x 0:\n if bit[i] > mx:\n mx = bit[i]\n i -= i & -i\n return mx\n\n\ndef update(i, x):\n while i < n + 1:\n if x > bit[i]:\n bit[i] = x\n i += i & -i\n\n\nn = int(input())\nhs = list(map(int, input().split()))\na_s = list(map(int, input().split()))\n\nbit = [0] * (n + 1)\nfor h, a in zip(hs, a_s):\n update(h, get(h - 1) + a)\nprint(max(bit))\n", "neg": "def get(i):\n mx = 0\n while i > 0:\n if bit[i] > mx:\n mx = bit[i]\n i -= i & -i\n return mx\n\n\ndef update(i, x):\n while i < n + 1:\n if x > bit[i]:\n bit[i] = x\n i += i & -i\n\n\ndef f(hs, a_s):\n for h, a in zip(hs, a_s):\n update(h, get(h - 1) + a)\n print(max(bit))\n\n\nn = int(input())\nhs = list(map(int, input().split()))\na_s = list(map(int, input().split()))\nbit = [0] * (n + 1)\nf(n, hs, a_s)\n", "jacc_sim": 0.9761904761904762, "nl": "You are given N flowers arranged in a row, each with a height and beauty. Taro wants to pull out some flowers so that the remaining ones have monotonically increasing heights. Find the maximum sum of the remaining flowers' beauties. Constraints: N (1 \u2264 N \u2264 2 \u00d7 10^5), heights (1 \u2264 hi \u2264 N), distinct heights, and beauty (1 \u2264 ai \u2264 10^9). Input format: N, followed by N heights and N beauties. Output the maximum sum of remaining flowers' beauties. Example: Input 4, heights 3 1 4 2, beauties 10 20 30 40. Output 60.", "before_after_length": [180, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03176", "p_user": "u318414416", "n_user": "u318414416", "pos": "# coding: utf-8\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\npowof2 = lambda x: len(\"{:b}\".format(x))\n\ndef f2(n, h, a):\n p = powof2(n)\n N = 2 ** p\n segt = [0] * (2 * N - 1)\n\n def getmax(a, b, i = 0, l = 0, r = N - 1):\n if r <= a or b <= l:\n return(0)\n if a <= l and r <= b:\n return(segt[i])\n i1 = 2 * i + 1\n i2 = i1 + 1\n lr = (l + r) // 2\n lmax = getmax(a, b, i1, l, lr)\n rmax = getmax(a, b, i2, lr, r)\n return(lmax if lmax > rmax else rmax)\n\n def setmax(i, v):\n si = i + N - 1\n segt[si] = v\n while si > 0:\n si = (si - 1) // 2\n si1 = 2 * si + 1\n si2 = si1 + 1\n segt[si] = segt[si1] if segt[si1] > segt[si2] else segt[si2]\n\n for i in range(1, n + 1):\n m = getmax(0, h[i])\n setmax(h[i], m + a[i])\n\n return(getmax(0, n))\n\nn = int(input()) # 1 <= n <= 2 x 10^5\nh = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nprint(f2(n, h, a))\n", "neg": "# coding: utf-8\n\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**6)\n\npowof2 = lambda x: len(\"{:b}\".format(x))\n\ndef f2(n, h, a):\n p = powof2(n)\n N = 2 ** p\n segt = [0] * (2 * N - 1)\n\n def getmax(a, b, i = 0, l = 0, r = N - 1):\n if r <= a or b <= l:\n return(0)\n if a <= l and r <= b:\n return(segt[i])\n lmax = getmax(a, b, 2 * i + 1, l, (l + r) // 2)\n rmax = getmax(a, b, 2 * i + 2, (l + r) // 2, r)\n return(lmax if lmax > rmax else rmax)\n\n def setmax(i, v):\n si = i + N - 1\n segt[si] = v\n while si > 0:\n si = (si - 1) // 2\n si1 = 2 * si + 1\n si2 += 1\n segt[si] = segt[si1] if segt[si1] > segt[si2] else segt[si2]\n\n for i in range(1, n + 1):\n m = getmax(0, h[i])\n setmax(h[i], m + a[i])\n\n return(getmax(0, n))\n\nn = int(input()) # 1 <= n <= 2 x 10^5\nh = [0] + list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nprint(f2(n, h, a))\n", "jacc_sim": 0.961038961038961, "nl": "You are given N flowers arranged in a row, each with a height and beauty. Taro wants to pull out some flowers so that the remaining ones have monotonically increasing heights. Find the maximum sum of the remaining flowers' beauties. Constraints: N (1 \u2264 N \u2264 2 \u00d7 10^5), heights (1 \u2264 hi \u2264 N), distinct heights, and beauty (1 \u2264 ai \u2264 10^9). Input format: N, followed by N heights and N beauties. Output the maximum sum of remaining flowers' beauties. Example: Input 4, heights 3 1 4 2, beauties 10 20 30 40. Output 60.", "before_after_length": [461, 446], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03176", "p_user": "u340781749", "n_user": "u340781749", "pos": "def solve(n, hhh, aaa):\n n2 = 1 << n.bit_length()\n offset = n2 - 1\n data = [0] * ((n2 << 1) - 1)\n\n def update(k, x):\n i = k + offset\n data[i] = max(data[i], x)\n while i:\n i = (i - 1) // 2\n data[i] = max(data[i], x)\n\n def get_max(k):\n i = k + offset\n ret = data[i]\n while i:\n if i % 2 == 0:\n ret = max(ret, data[i - 1])\n i = (i - 1) // 2\n return ret\n\n srt = sorted((h, i) for i, h in enumerate(hhh))\n for h, i in srt:\n update(i, get_max(i) + aaa[i])\n\n return data[0]\n\n\nn = int(input())\nhhh = list(map(int, input().split()))\naaa = list(map(int, input().split()))\nprint(solve(n, hhh, aaa))\n", "neg": "def solve(n, hhh, aaa):\n n2 = 1 << n.bit_length()\n offset = n2 - 1\n data = [0] * ((n2 << 1) - 1)\n\n def update(k, x):\n i = k + offset\n data[i] = max(data[i], x)\n while i:\n i = (i - 1) // 2\n data[i] = max(data[i], x)\n\n def get_max(k):\n i = k + offset\n ret = data[i]\n while i:\n i = (i - 1) // 2\n if i % 2 == 0:\n ret = max(ret, data[i - 1])\n return ret\n\n srt = sorted((h, i) for i, h in enumerate(hhh))\n for h, i in srt:\n update(i, get_max(i) + aaa[i])\n\n return get_max(offset)\n\n\nn = int(input())\nhhh = list(map(int, input().split()))\naaa = list(map(int, input().split()))\nprint(solve(n, hhh, aaa))\n", "jacc_sim": 1.0, "nl": "You are given N flowers arranged in a row, each with a height and beauty. Taro wants to pull out some flowers so that the remaining ones have monotonically increasing heights. Find the maximum sum of the remaining flowers' beauties. Constraints: N (1 \u2264 N \u2264 2 \u00d7 10^5), heights (1 \u2264 hi \u2264 N), distinct heights, and beauty (1 \u2264 ai \u2264 10^9). Input format: N, followed by N heights and N beauties. Output the maximum sum of remaining flowers' beauties. Example: Input 4, heights 3 1 4 2, beauties 10 20 30 40. Output 60.", "before_after_length": [290, 292], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u386195929", "n_user": "u771710924", "pos": "mod = 10**9+7\ndef mult(A, B):\n C = [[0 for i in range(len(A))] for i in range(len(A))]\n\n for i in range(len(A)):\n for j in range(len(A)):\n for k in range(len(A)):\n C[i][j] = (C[i][j]+A[i][k]*B[k][j])%mod\n \n return C\n\ndef exp(A, p):\n ans = [[0 for i in range(len(A))] for i in range(len(A))]\n for i in range(len(A)):\n ans[i][i] = 1\n \n while p:\n if p%2 == 0:\n A = mult(A, A)\n p = p//2\n else:\n ans = mult(ans, A)\n p -= 1\n \n return ans\n\nn, k = map(int, input().strip().split())\ngrid = [list(map(int, input().strip().split())) for i in range(n)]\n\nprint(sum([sum(i)%mod for i in exp(grid, k)])%mod)\n\n\n\n", "neg": "def mult(A, B):\n C = [[0 for i in range(len(A))] for i in range(len(A))]\n \n for i in range(len(A)):\n for j in range(len(A)):\n for k in range(len(A)):\n C[i][j] = (C[i][j]+A[i][k]*B[k][j])%mod\n \n return C\n \ndef exp(A, p):\n ans = [[0 for i in range(len(A))] for i in range(len(A))]\n for i in range(len(A)):\n ans[i][i] = 1\n \n while p:\n if p%2 == 0:\n A = mult(A, A)\n p = p//2\n else:\n ans = mult(ans, A)\n p -= 1\n \n return ans\n \nn, k = map(int, input().strip().split())\ngrid = [list(map(int, input().strip().split())) for i in range(n)]\n \nprint(sum([sum(i)%mod for i in exp(grid, k)])%mod)", "jacc_sim": 0.9387755102040817, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [298, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u029251499", "n_user": "u029251499", "pos": "import numpy as np\nN,K=map(int,input().split())\na=[[int(i) for i in input().split()] for _ in range(N)]\na=np.array(a,dtype=np.int64)\nMOD=10**9+7\n\ndef matmul(A,B,MOD):\n N=len(A)\n C=np.zeros((N,N),dtype=np.int64)\n\n for n in range(N):\n C[n] = (A[n,:][:,None] * B % MOD).sum(axis=0) % MOD\n return C\n\ndef mat_power(A,k,MOD):\n N=len(A)\n D=np.identity(N,dtype=np.int64)\n while k:\n if k & 1:\n D=matmul(D,A,MOD)\n A = matmul(A,A,MOD)\n k >>= 1\n\n return D\n\nA=mat_power(a,K,MOD)\nans=0\nfor i in range(N):\n for j in range(N):\n ans=(ans+A[i][j])%MOD\n\nprint(ans)", "neg": "import numpy as np\nN,K=map(int,input().split())\na=[[int(i) for i in input().split()] for _ in range(N)]\na=np.array(a,dtype=np.int64)\nMOD=10**9+7\n\ndef matmul(A,B,MOD):\n N=len(A)\n C=np.zeros(N,dtype=np.int64)\n for i in range(N):\n for j in range(N):\n for k in range(N):\n C[i][j] += A[i][k]B[k][j]%MOD\n return C\n\ndef mat_power(A,k,MOD):\n N=len(A)\n D=np.identity(N,dtype=np.int64)\n while k:\n if k & 1:\n D=matmul(D,A,MOD)\n A = matmul(A,A,MOD)\n k >>= 1\n\n return D\n\nA=mat_power(a,K,MOD)\nans=0\nfor i in range(N):\n for j in range(N):\n ans=(ans+A[i][j])%MOD\n\nprint(ans)", "jacc_sim": 0.9322033898305084, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [287, 294], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u871352270", "n_user": "u871352270", "pos": "N, K = map(int, input().split())\nA = [list(map(int, input().split())) for i in range(N)]\nmod = 10**9+7\n\ndef matrixmul(A, B):\n n = len(A)\n C = []\n for i in range(n):\n c = []\n for j in range(n):\n num = 0\n for k in range(n):\n num = (A[i][k]*B[k][j] + num)%mod\n c.append(num)\n C.append(c)\n return C\n\nnow = [[1 if i == j else 0 for i in range(N)] for j in range(N)] \n\nwhile K:\n if K&1 == 1:\n now = matrixmul(now, A)\n K //= 2\n A = matrixmul(A, A)\n\nans = 0\nfor i in range(N):\n for j in range(N):\n ans = (now[i][j]+ans)%mod\nprint(ans)", "neg": "N, K = map(int, input().split())\nA = [list(map(int, input().split())) for i in range(N)]\nmod = 10**9+7\n\ndef matrixmul(A, B):\n n = len(A)\n C = []\n for i in range(n):\n c = []\n for j in range(n):\n num = 0\n for k in range(n):\n num = (A[i][k]*B[k][j] + num)%mod\n c.append(num)\n C.append(c)\n return C\n\ndef matrixpow(A, n):\n if n == 1:\n return A\n if n&1 == 1:\n return matrixmul(matrixpow(A, n-1), A)\n else:\n return matrixmul(matrixpow(A, n//2), matrixpow(A, n//2))\n \nAn = matrixpow(A, K)\nans = 0\nfor i in range(N):\n for j in range(N):\n ans = (An[i][j]+ans)%mod\nprint(ans)", "jacc_sim": 0.9056603773584906, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [255, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u504836877", "n_user": "u504836877", "pos": "N,K = map(int, input().split())\nA = [[int(a) for a in input().split()] for _ in range(N)]\n\nmod = 10**9+7\n\nimport numpy as np\n\na = np.array(A, dtype=object)\nMat = np.eye(N, dtype=object)\n\nwhile K:\n if K%2:\n Mat = np.dot(Mat, a)%mod\n a = np.dot(a, a)%mod\n K //= 2\n \nans = 0\nfor i in range(N):\n for j in range(N):\n ans += Mat[i, j]\n ans %= mod\n \nprint(ans)", "neg": "N,K = map(int, input().split())\nA = [[int(a) for a in input().split()] for _ in range(N)]\n\nmod = 10**9+7\n\nimport numpy as np\n\na = np.array(A)\nMat = np.eye(N)\nprint(Mat)\nwhile K:\n if K%2:\n Mat = np.dot(Mat, a)%mod\n a = np.dot(a, a)%mod\n K //= 2\n \nans = 0\nfor i in range(N):\n for j in range(N):\n ans += int(Mat[i, j])\n ans %= mod\n \nprint(ans,a)", "jacc_sim": 0.9565217391304348, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [169, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u871201743", "n_user": "u871201743", "pos": "import numpy as np\n\n\ndef main():\n MOD = int(1e9 + 7)\n\n n, k = map(int, input().split())\n can = [[int(c) for c in input().split()] for _ in range(n)]\n can = np.array(can, dtype=object)\n\n answer = np.eye(n, dtype=object)\n while k:\n if k % 2:\n answer = np.dot(answer, can) % MOD\n can = np.dot(can, can) % MOD\n k //= 2\n\n total = 0\n for i in range(n):\n for j in range(n):\n total += answer[i, j]\n if total >= MOD:\n total -= MOD\n\n print(total)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import numpy as np\n\n\ndef main():\n MOD = int(1e9 + 7)\n\n n, k = map(int, input().split())\n can = [[int(c) for c in input().split()] for _ in range(n)]\n can = np.array(can)\n\n answer = np.eye(n)\n while k:\n if k % 2:\n answer = np.dot(answer, can) % MOD\n can = np.dot(can, can) % MOD\n k //= 2\n\n total = 0\n for i in range(n):\n for j in range(n):\n total += answer[i,j]\n if total >= MOD:\n total -= MOD\n\n print(total)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9607843137254902, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [207, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u310678820", "n_user": "u310678820", "pos": "import numpy as np\nmod = 10**9+7\ndef MatPower(A, k):\n B = np.identity(len(A), dtype = object)\n while k:\n if k&1:\n B = np.dot(A, B)%mod\n A = np.dot(A, A)%mod\n k//=2\n return B\nN, K = map(int, input().split())\na = np.array([list(map(int, input().split())) for _ in range(N)], dtype = object)\nv = np.array([1]*N, dtype = object).T\nAn = MatPower(a, K)\nv = np.dot(An, v)%mod\nans = 0\nfor i in range(N):\n ans+=v[i]\n ans%=mod\nprint(ans)\n\n\n\n", "neg": "import numpy as np\nmod = 10**9+7\ndef MatPower(A, k):\n B = np.identity(len(A), dtype = object)\n while k:\n if k&1:\n B = np.dot(A, B)%mod\n A = np.dot(A, A)%mod\n k//=2\n return B\nN, K = map(int, input().split())\na = np.array([list(map(int, input().split())) for _ in range(N)], dtype = object)\nv = np.array([1]*N, dtype = object).T\nAn = MatPower(a, K)\nv = np.dot(An, v)%mod\nprint(v.sum())", "jacc_sim": 0.9310344827586207, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [205, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u221230011", "n_user": "u221230011", "pos": "import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nMOD=10**9+7\nN, K = map(int, input().split())\ngrid = np.empty((0,N), dtype='O')\nfor i in range(N):\n array = list(map(int, input().strip().split()))\n array2 = np.array(array)\n grid = np.append(grid,[array2],axis=0)\n#print(grid)\ndp=[[grid]]\ngridsave=grid\ni=1\nwhile 2**i<=K:\n #print(i)\n #dp.insert(1,grid*grid)\n gridsave=np.dot(dp[i-1][0],dp[i-1][0])\n gridsave=np.mod(gridsave,MOD)\n #print(gridsave)\n dp.append([gridsave])\n i+=1\ni-=1\nK-=2**i\ni-=1\n#print('dp',dp)\ngrid1=dp[len(dp)-1][0]\n#print(grid1)\n#print(i)\nwhile K>0:\n if K>=2**i:\n #print('i',i)\n grid1=np.dot(grid1,dp[i][0])\n grid1=np.mod(grid1,MOD)\n K-=2**i\n #print('grid1',grid1)\n i-=1\n #print('K',K)\nans=0\n#print(grid1)\nfor i in range(N):\n for j in range(N):\n ans=(ans+grid1[i][j])%MOD\nprint(ans)\n", "neg": "import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nMOD=10**9+7\nN, K = map(int, input().split())\ngrid = np.empty((0,N), dtype=Object)\nfor i in range(N):\n array = list(map(int, input().strip().split()))\n array2 = np.array(array)\n grid = np.append(grid,[array2],axis=0)\n#print(grid)\ndp=[[grid]]\ngridsave=grid\ni=1\nwhile 2**i<=K:\n #print(i)\n #dp.insert(1,grid*grid)\n gridsave=np.dot(dp[i-1][0],dp[i-1][0])\n gridsave=np.mod(gridsave,MOD)\n #print(gridsave)\n dp.append([gridsave])\n i+=1\ni-=1\nK-=2**i\ni-=1\n#print('dp',dp)\ngrid1=dp[len(dp)-1][0]\n#print(grid1)\n#print(i)\nwhile K>0:\n if K>=2**i:\n #print('i',i)\n grid1=np.dot(grid1,dp[i][0])\n grid1=np.mod(grid1,MOD)\n K-=2**i\n #print('grid1',grid1)\n i-=1\n #print('K',K)\nans=0\n#print(grid1)\nfor i in range(N):\n for j in range(N):\n ans=(ans+grid1[i][j])%MOD\nprint(ans)\n", "jacc_sim": 0.9682539682539683, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [411, 411], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03177", "p_user": "u221230011", "n_user": "u221230011", "pos": "import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nMOD=10**9+7\nN, K = map(int, input().split())\ngrid = np.empty((0,N), dtype='O')\nfor i in range(N):\n array = list(map(int, input().strip().split()))\n array2 = np.array(array)\n grid = np.append(grid,[array2],axis=0)\n#print(grid)\ndp=[[grid]]\ngridsave=np.eye(N,dtype=\"O\")\n#print(gridsave)\ni=1\nwhile K:\n if K & 1:\n gridsave=np.dot(grid,gridsave) % MOD\n grid=np.dot(grid,grid) % MOD\n K>>=1\nans=np.sum(gridsave)%MOD\n#print(gridsave)\nprint(ans)", "neg": "import sys\nimport numpy as np\ninput = sys.stdin.readline\n\nMOD=10**9+7\nN, K = map(int, input().split())\ngrid = np.empty((0,N), int)\nfor i in range(N):\n array = list(map(int, input().strip().split()))\n array2 = np.array(array)\n grid = np.append(grid,[array2],axis=0)\n#print(grid)\ndp=[[grid]]\ngridsave=np.eye(N,dtype=np.int64)\nprint(gridsave)\ni=1\nwhile K:\n if K & 1:\n gridsave=np.dot(grid,gridsave) % MOD\n grid=np.dot(grid,grid) % MOD\n K>>=1\nans=np.sum(gridsave)%MOD\nprint(gridsave)\nprint(ans)", "jacc_sim": 0.9482758620689655, "nl": "You are given a simple directed graph G with N vertices. For each pair of vertices i and j, you are given an integer a_{i, j} representing the presence of a directed edge from vertex i to j. Find the number of different directed paths of length K in G, considering paths that traverse the same edge multiple times. The input consists of N, K, and the adjacency matrix a_{i, j}. Output the count of different directed paths modulo 10^9 + 7.", "before_after_length": [216, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03178", "p_user": "u306950978", "n_user": "u306950978", "pos": "n = input()\nd = int(input())\nt = len(n)\nmod = 10**9 + 7\ndp1 = [[0 for i in range(d)] for j in range(t)]\ndp2 = [[0 for i in range(d)] for j in range(t)]\n\ndp1[0][int(n[0])%d] += 1\nfor i in range(int(n[0])):\n dp2[0][i%d] += 1\n \nfor i in range(1,t):\n now = int(n[i])\n for j in range(10):\n if j == now:\n for k in range(d):\n dp1[i][(k+j)%d] += dp1[i-1][k]\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp1[i][(k+j)%d] %= mod\n dp2[i][(k+j)%d] %= mod\n elif j < now:\n for k in range(d):\n dp2[i][(k+j)%d] += dp1[i-1][k]\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp2[i][(k+j)%d] %= mod\n else:\n for k in range(d):\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp2[i][(k+j)%d] %= mod\n\nprint((dp1[-1][0]+dp2[-1][0]-1)%mod)", "neg": "d = int(input())\nn = input()\nt = len(n)\nmod = 10**9 + 7\ndp1 = [[0 for i in range(d)] for j in range(t)]\ndp2 = [[0 for i in range(d)] for j in range(t)]\n\ndp1[0][int(n[0])%d] += 1\nfor i in range(int(n[0])):\n dp2[0][i%d] += 1\n \nfor i in range(1,t):\n now = int(n[i])\n for j in range(10):\n if j == now:\n for k in range(d):\n dp1[i][(k+j)%d] += dp1[i-1][k]\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp1[i][(k+j)%d] %= mod\n dp2[i][(k+j)%d] %= mod\n elif j < now:\n for k in range(d):\n dp2[i][(k+j)%d] += dp1[i-1][k]\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp2[i][(k+j)%d] %= mod\n else:\n for k in range(d):\n dp2[i][(k+j)%d] += dp2[i-1][k]\n dp2[i][(k+j)%d] %= mod\n\nprint((dp1[-1][0]+dp2[-1][0]-1)%mod)", "jacc_sim": 1.0, "nl": "You are given a range of integers from 1 to K (inclusive) and a value D. Find the count of integers in the range whose digit sum in base ten is a multiple of D, modulo 10^9 + 7. Input is provided in the format: K, D. Output the count of such integers. All input values are integers. Constraints: 1 \u2264 K < 10^10000, 1 \u2264 D \u2264 100. Example: For input 30, 4, the output is 6, representing the count of integers (4, 8, 13, 17, 22, 26) with digit sum multiples of 4.", "before_after_length": [403, 403], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03178", "p_user": "u021548497", "n_user": "u021548497", "pos": "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n K = input().replace(\"\\n\", \"\")\n D = int(input())\n \n mod = pow(10, 9)+7\n n = len(K)\n dp = [[0]*D for _ in range(n+1)]\n \n dp[0][0] = 1\n sub = 0\n \n if D == 1:\n ans = 0\n for i in range(n):\n ans = (ans*10+int(K[i]))%mod\n print(ans)\n sys.exit()\n\n\n for i in range(n):\n if i != 0:\n for j in range(10):\n for k in range(D):\n dp[i+1][(k+j)%D] += dp[i][k]\n dp[i+1][(k+j)%D] %= mod\n for j in range(1, 10):\n dp[i+1][j%D] += 1\n dp[i+1][j%D] %= mod\n \n \n for j in range(int(K[i])):\n if i == 0 and j == 0:\n continue\n dp[i+1][(j+sub)%D] += 1\n dp[i+1][(j+sub)%D] %= mod\n sub = (sub+int(K[i]))%D\n \n sub = 0\n for i in range(n):\n sub = (sub+int(K[i]))%D\n if sub == 0:\n dp[n][0] += 1\n dp[n][0] %= mod\n \n \n print(dp[n][0])\n \n \nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\ninput = sys.stdin.readline\n\n\ndef main():\n K = input().replace(\"\\n\", \"\")\n D = int(input())\n \n mod = pow(10, 9)+7\n n = len(K)\n dp = [[0]*D for _ in range(n+1)]\n \n dp[0][0] = 1\n sub = 0\n \n if D == 1:\n ans = 0\n for i in range(n):\n ans = (ans*10+int(K[i]))%mod\n print(ans)\n sys.exit()\n \n for i in range(n):\n if i != 0:\n for j in range(10):\n for k in range(D):\n dp[i+1][(k+j)%D] += dp[i][k]\n dp[i+1][(k+j)%D] %= mod\n for j in range(1, 10):\n dp[i+1][j%D] += 1\n dp[i+1][j%D] %= mod\n \n \n for j in range(int(K[i])):\n if i == 0 and j == 0:\n continue\n dp[i+1][(j+sub)%D] += 1\n dp[i+1][(j+sub)%D] %= mod\n sub = (sub+int(K[i]))%D\n print(dp)\n print(dp[n][0])\n \n \nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "You are given a range of integers from 1 to K (inclusive) and a value D. Find the count of integers in the range whose digit sum in base ten is a multiple of D, modulo 10^9 + 7. Input is provided in the format: K, D. Output the count of such integers. All input values are integers. Constraints: 1 \u2264 K < 10^10000, 1 \u2264 D \u2264 100. Example: For input 30, 4, the output is 6, representing the count of integers (4, 8, 13, 17, 22, 26) with digit sum multiples of 4.", "before_after_length": [434, 378], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03178", "p_user": "u561231954", "n_user": "u091850723", "pos": "import sys\nsys.setrecursionlimit(100000000)\nMOD = 10 ** 9 + 7\n\ndef main():\n K = input()\n D = int(input())\n\n dp = [[[0]*2 for _ in range(D)] for _ in range(len(K) + 1)] \n dp[0][0][0] = 1\n for i in range(len(K)):\n M = int(K[i])\n for j in range(D):\n for k in range(10):\n if k < M:\n dp[i + 1][(j + k)%D][1] += dp[i][j][1] + dp[i][j][0]\n elif k == M:\n dp[i + 1][(j + k)%D][1] += dp[i][j][1]\n dp[i + 1][(j + k)%D][0] += dp[i][j][0]\n else:\n dp[i + 1][(j + k)%D][1] += dp[i][j][1]\n dp[i + 1][(j + k)%D][0] %= MOD\n dp[i + 1][(j + k)%D][1] %= MOD\n ans = sum(dp[-1][0])\n print((ans - 1)%MOD) \nif __name__ == '__main__':\n main()\n ", "neg": "import sys\nsys.setrecursionlimit(100000000)\nMOD = 10 ** 9 + 7\n\ndef main():\n K = input()\n D = int(input())\n\n dp = [[[0]*2 for _ in range(D)] for _ in range(len(K) + 1)] \n dp[0][0][0] = 1\n for i in range(len(K)):\n M = int(K[i])\n for j in range(D):\n for k in range(10):\n if k < M:\n dp[i + 1][(j + k)%D][1] += dp[i][j][1] + dp[i][j][0]\n elif k == M:\n dp[i + 1][(j + k)%D][1] += dp[i][j][1]\n dp[i + 1][(j + k)%D][0] += dp[i][j][0]\n #else:\n #dp[i + 1][(j + k)%D][1] += dp[i][j][1]\n dp[i + 1][(j + k)%D][0] %= MOD\n dp[i + 1][(j + k)%D][1] %= MOD\n ans = sum(dp[-1][0])\n print((ans - 1)%MOD) \nif __name__ == '__main__':\n main()\n \n", "jacc_sim": 0.9795918367346939, "nl": "You are given a range of integers from 1 to K (inclusive) and a value D. Find the count of integers in the range whose digit sum in base ten is a multiple of D, modulo 10^9 + 7. Input is provided in the format: K, D. Output the count of such integers. All input values are integers. Constraints: 1 \u2264 K < 10^10000, 1 \u2264 D \u2264 100. Example: For input 30, 4, the output is 6, representing the count of integers (4, 8, 13, 17, 22, 26) with digit sum multiples of 4.", "before_after_length": [335, 338], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03178", "p_user": "u997641430", "n_user": "u997641430", "pos": "n = int(input())\nd = int(input())\np = 10**9+7\nif d == 1:\n print(n % p)\n exit()\nN = [int(i) for i in list(str(n))]\nDP0 = [0] * d\nDP1 = [0] * d\nDP1[0] += 1\nfor i in N:\n DP0_ = [0] * d\n DP1_ = [0] * d\n for r in range(d):\n for j in range(i):\n DP0_[r] += DP1[(r-j) % d]\n DP1_[r] += DP1[(r-j) % d]\n DP0_[r] += DP0[(r-i) % d]\n DP1_[r] += DP1[(r-i) % d]\n for j in range(i+1, 10):\n DP0_[r] += DP0[(r-j) % d]\n DP1_[r] += DP0[(r-j) % d]\n DP0_[r], DP1_[r] = DP0_[r] % p, DP1_[r] % p\n DP0, DP1 = DP0_, DP1_\nprint((DP1[0]-1) % p)\n", "neg": "n = int(input())\nd = int(input())\np = 10**9+7\nif d == 1:\n print(n % d)\n exit()\nN = [int(i) for i in list(str(n))]\nDP0 = [0] * d\nDP1 = [0] * d\nDP1[0] += 1\nfor i in N:\n DP0_ = [0] * d\n DP1_ = [0] * d\n for r in range(d):\n for j in range(i):\n DP0_[r] += DP1[(r-j) % d]\n for j in range(i, 10):\n DP0_[r] += DP0[(r-j) % d]\n for j in range(i+1):\n DP1_[r] += DP1[(r-j) % d]\n for j in range(i+1, 10):\n DP1_[r] += DP0[(r-j) % d]\n DP0_[r], DP1_[r] = DP0_[r] % p, DP1_[r] % p\n DP0, DP1 = DP0_, DP1_\nprint(DP1[0]-1)\n", "jacc_sim": 1.0, "nl": "You are given a range of integers from 1 to K (inclusive) and a value D. Find the count of integers in the range whose digit sum in base ten is a multiple of D, modulo 10^9 + 7. Input is provided in the format: K, D. Output the count of such integers. All input values are integers. Constraints: 1 \u2264 K < 10^10000, 1 \u2264 D \u2264 100. Example: For input 30, 4, the output is 6, representing the count of integers (4, 8, 13, 17, 22, 26) with digit sum multiples of 4.", "before_after_length": [346, 321], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03178", "p_user": "u225388820", "n_user": "u225388820", "pos": "s,d=input(),int(input())\nn=[int(i) for i in s]\nl=len(s)\nmod=10**9+7\ndp=[[[0]*d,[0]*d] for i in range(l+1)]\ndp[0][0][0]=1\nfor i in range(l):\n for smaller in range(2):\n for j in range(d):\n for x in range(10 if smaller else n[i]+1):\n dp[i+1][smaller or x\":\n l=j\n r=i-1\n else:\n\n l=1\n r=j-1\n\n if l>r:\n continue\n dp[i][j]=((pref[r]-pref[l-1])%N + N)%N\nans=0\nfor i in range(1,n+1):\n ans=(ans+dp[n][i])%N\n\nprint(ans)\n\n\n", "neg": "def sep():\n return map(int,input().strip().split(\" \"))\ndef lis():\n return list(sep())\ndef inp():\n return input()\n\nN=10**9 +7\nn=int(inp())\ns=inp()\ndp=[[0]*(n+1) for _ in range(n+1)]#base 1 indexing\ndp[1][1]=1\nfor i in range(2,n+1):\n pref=[0]\n for t in range(1,i):\n pref.append((pref[-1]+dp[i-1][t])%N)\n for j in range(1,i+1):\n\n\n if s[i-2]==\">\":\n l=j\n r=i-1\n else:\n\n l=1\n r=j-1\n\n if l>r:\n continue\n dp[i][j]=((pref[r]-pref[l-1])%N + N)%N\nans=0\nfor i in range(1,n+1):\n ans=(ans+dp[n][i])%N\nprint(dp)\nprint(ans)\n\n\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [277, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u678167152", "n_user": "u678167152", "pos": "def solve():\n N = int(input())\n s = input()\n mod = 10**9+7\n dp = [[0]*N for _ in range(N)]\n dp[-1][0]=1\n for i in range(N-2,-1,-1):\n if s[i]=='>':\n for j in range(N-i-2,-1,-1):\n dp[i][j] = dp[i][j+1]+dp[i+1][j]\n dp[i][j] %= mod\n else:\n for j in range(1,N-i):\n dp[i][j] = dp[i][j-1]+dp[i+1][j-1]\n dp[i][j] %= mod\n ans = sum(dp[0])%mod\n return ans\nprint(solve())", "neg": "def solve():\n N = int(input())\n s = '<>'*N\n mod = 10**9+7\n dp = [[0]*N for _ in range(N)]\n dp[-1][0]=1\n for i in range(N-2,-1,-1):\n if s[i]=='>':\n for j in range(N-i-2,-1,-1):\n dp[i][j] = dp[i][j+1]+dp[i+1][j]\n dp[i][j]%mod\n else:\n for j in range(1,N-i):\n dp[i][j] = dp[i][j-1]+dp[i+1][j-1]\n dp[i][j]%mod\n ans = sum(dp[0])%mod\n return ans\nprint(solve())", "jacc_sim": 0.975, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [207, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\ns = input()\ndp = [[0]*(n+1) for _ in range(n+1)]\ndp[1][1] = 1\nM = 10**9+7\nfor i in range(2, n+1):\n v = 0\n if s[i-2]==\"<\":\n for j in range(1,i+1):\n # j: \u6700\u5f8c\u306e\u6570\n dp[i][j] = v\n v += dp[i-1][j]\n v %= M\n dp[i][i] = v\n else:\n for j in range(i,1,-1):\n # j: \u6700\u5f8c\u306e\u6570\n dp[i][j] = v\n v += dp[i-1][j-1]\n v %= M\n dp[i][1] = v\n# print(dp)\nans = 0\nfor item in dp[n]:\n ans += item\n ans %= M\nprint(ans)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\ns = input()\ndp = [[0]*(n+1) for _ in range(n+1)]\ndp[1][1] = 1\nfor i in range(2, n+1):\n v = 0\n if s[i-2]==\"<\":\n for j in range(1,i+1):\n # j: \u6700\u5f8c\u306e\u6570\n dp[i][j] = v\n v += dp[i-1][j]\n v %= M\n dp[i][i] = v\n else:\n for j in range(i,1,-1):\n # j: \u6700\u5f8c\u306e\u6570\n dp[i][j] = v\n v += dp[i-1][j-1]\n v %= M\n dp[i][1] = v\n# print(dp)\nans = 0\nfor item in dp[n]:\n ans += item\n ans %= M\nprint(ans)", "jacc_sim": 0.9821428571428571, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [306, 298], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u997641430", "n_user": "u997641430", "pos": "n = int(input())\nS = input()\np = 10**9+7\nDP = [[0 for j in range(n+1)] for i in range(n+1)]\nfor j in range(n):\n DP[1][j] = 1\nfor i in range(2, n+1):\n A = [0]\n for j in range(n):\n A.append(A[-1]+DP[i-1][j])\n for j in range(n-i+1):\n if S[i-2] == '<':\n DP[i][j] = (A[n-(i-1)+1]-A[j+1]) % p\n else:\n DP[i][j] = A[j+1] % p\nprint(DP[n][0])\n", "neg": "n = int(input())\nS = input()\np = 10**9 + 7\nDP = [[0 for j in range(n + 1)] for i in range(n + 1)]\nfor i in range(2, n + 1):\n A = [0]\n for j in range(n):\n A.append(A[-1] + DP[i - 1][j])\n for j in range(n - i + 1):\n if S[i - 2] == '<':\n DP[i][j] = (A[n - (i - 1) + 1] - A[j + 1]) % p\n else:\n DP[i][j] = A[j + 1] % p\nprint(DP[n][0])\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [195, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u123756661", "n_user": "u123756661", "pos": "#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_3\nfrom itertools import accumulate\nmod=1000000007\nn=int(input())\ns=input()\ndp=[1]*n\nfor i in range(n-1):\n if s[i]==\">\":\n dp.reverse()\n dp=list(accumulate(dp[:-1]))\n dp.reverse()\n else:\n dp=list(accumulate(dp[:-1]))\n for j in range(len(dp)):\n dp[j]%=mod\nprint(dp[0])\n", "neg": "#from https://ikatakos.com/pot/programming_algorithm/contest_history/atcoder/2019/0106_educational_dp_3\nfrom itertools import accumulate\nmod=1000000007\nn=int(input())\ns=input()\ndp=[1]*n\nfor i in range(n-1):\n if s[i]==\">\":\n dp.reverese()\n dp=list(accumulate(dp[:-1]))\n dp.reverse()\n else:\n dp=list(accumulate(dp[:-1]))\n for j in range(len(dp)):\n dp[j]%=mod\nprint(dp[0])", "jacc_sim": 0.9791666666666666, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [162, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u353797797", "n_user": "u353797797", "pos": "md = 10 ** 9 + 7\nn = int(input())\ns = input()\ndp = [1] * n\nfor i in range(n - 1):\n if s[i] == \"<\":\n for dpi in range(1, n - i - 1):\n dp[dpi] = (dp[dpi] + dp[dpi - 1]) % md\n dp = dp[:-1]\n else:\n for dpi in range(n - i - 2, 0, -1):\n dp[dpi] = (dp[dpi] + dp[dpi + 1]) % md\n dp = dp[1:]\nprint(dp[0])\n", "neg": "md = 10 ** 9 + 7\nn = int(input())\ns = input()\ndp = [1] * n\nfor i in range(n - 1):\n if s[i] == \"<\":\n s = dp[0]\n for dpi in range(1, n - i - 1):\n dp[dpi] = s = (dp[dpi] + s) % md\n dp = dp[:-1]\n else:\n s = dp[-1]\n for dpi in range(n - i - 2, 0, -1):\n dp[dpi] = s = (dp[dpi] + s) % md\n dp = dp[1:]\nprint(dp[0])\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [157, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03179", "p_user": "u270681687", "n_user": "u270681687", "pos": "n = int(input())\ns = input()\n\nmod = 10**9 + 7\n\ndp = [[0] * n for _ in range(n)]\n\nfor more in range(n):\n dp[0][more] = 1\n\nfor i in range(n-1):\n if s[i] == \"<\":\n cum = 0\n for more in reversed(range(n-1-i)):\n cum += dp[i][more+1]\n cum %= mod\n dp[i + 1][more] += cum\n dp[i + 1][more] %= mod\n else:\n cum = 0\n for more in range(n-1-i):\n cum += dp[i][more]\n cum %= mod\n dp[i+1][more] += cum\n dp[i+1][more] %= mod\n\nprint(dp[n-1][0])\n", "neg": "n = int(input())\ns = input()\n\nmod = 10**9 + 7\n\ndp = [[0] * n for _ in range(n)]\n\nfor more in range(n):\n dp[0][more] = 1\n\nfor i in range(n-1):\n if s[i] == \"<\":\n cum = 0\n for more in reversed(range(n-1)):\n cum += dp[i][more+1]\n cum %= mod\n dp[i + 1][more] += cum\n dp[i + 1][more] %= mod\n else:\n cum = 0\n for more in range(n):\n cum += dp[i][more]\n cum %= mod\n dp[i+1][more] += cum\n dp[i+1][more] %= mod\n\nprint(dp[n-1][0])\n", "jacc_sim": 1.0, "nl": "You are given a positive integer N and a string s of length N - 1, consisting of \"<\" and \">\". Find the number of permutations (p1, p2, ..., pN) of (1, 2, ..., N) that satisfy a given condition, modulo 10^9 + 7. The condition is that for each i (1 \u2264 i \u2264 N - 1), pi < pi+1 if the ith character in s is \"<\", and pi > pi+1 if the ith character in s is \">\". Constraints: N is an integer, 2 \u2264 N \u2264 3000, s consists of \"<\" and \">\". Input is given as N and s, and the output should be the number of permutations that satisfy the condition, modulo 10^9 + 7.", "before_after_length": [212, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03183", "p_user": "u712893765", "n_user": "u712893765", "pos": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop,heapify\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n\nfrom itertools import accumulate\nfrom functools import lru_cache\n\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\nn = val()\nl = []\nfor i in range(n):l.append(li())\n\nl.sort(key = lambda x:x[1] + x[0])\n\ndp = [0] * (20001)\n\nfor i in l:\n for j in range(i[1], -1, -1):\n dp[j + i[0]] = max(dp[j + i[0]], dp[j] + i[-1])\n\nprint(max(dp))\n\n\n", "neg": "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop,heapify\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n\nfrom itertools import accumulate\nfrom functools import lru_cache\n\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\nn = val()\nl = []\nfor i in range(n):l.append(li())\n\nl.sort(key = lambda x:x[1])\n\ndp = [0] * (20001)\n\nfor i in l:\n for j in range(i[1], -1, -1):\n dp[j + i[0]] = max(dp[j + i[0]], dp[j] + i[-1])\n\nprint(max(dp))\n\n\n", "jacc_sim": 1.0, "nl": "You are given N blocks, each with a weight, solidness, and value. You need to build a tower by stacking some of the blocks vertically. The tower must satisfy the condition that the sum of the weights of the blocks stacked above each block is not greater than its solidness. Find the maximum possible sum of the values of the blocks in the tower. Constraints: N (1 \u2264 N \u2264 10^3), weights and solidness (1 \u2264 w_i, s_i \u2264 10^4), values (1 \u2264 v_i \u2264 10^9). Input format: N followed by N lines of weight, solidness, and value. Output the maximum possible sum of the values.", "before_after_length": [378, 373], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03183", "p_user": "u657913472", "n_user": "u657913472", "pos": "n=int(input());\nans=0;\np=[0]*22222;\nfor w,s,v in sorted([list(map(int,input().split()))for _ in[0]*n],key=lambda a:a[0]+a[1]):\n for j in range(s,-1,-1):\n p[j+w]=max(p[j+w],p[j]+v);\n ans=max(ans,p[j+w]);\nprint(ans)\n", "neg": "n=int(input());ans=0;p=[0]*22222\nfor w,s,v in sorted([list(map(int,input().split()))for _ in[0]*n],key=lambda a:a[0]+a[1]):\n for j in range(s+1):\n p[j+w]=max(p[j+w],p[j]+v);\n ans=max(ans,p[j+w]);\nprint(ans)\n", "jacc_sim": 0.972972972972973, "nl": "You are given N blocks, each with a weight, solidness, and value. You need to build a tower by stacking some of the blocks vertically. The tower must satisfy the condition that the sum of the weights of the blocks stacked above each block is not greater than its solidness. Find the maximum possible sum of the values of the blocks in the tower. Constraints: N (1 \u2264 N \u2264 10^3), weights and solidness (1 \u2264 w_i, s_i \u2264 10^4), values (1 \u2264 v_i \u2264 10^9). Input format: N followed by N lines of weight, solidness, and value. Output the maximum possible sum of the values.", "before_after_length": [119, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03184", "p_user": "u599213942", "n_user": "u599213942", "pos": "import sys\nh, w, n = [int(i) for i in sys.stdin.readline().split()]\nm = 1000000007\nfact = [1, 1]\nfor i in range(2, 200002):\n fact.append(fact[-1] * i % m)\ninv = [pow(i, m - 2, m) for i in fact]\nf = lambda i: fact[i[0] + i[1]] * inv[i[0]] * inv[i[1]] % m\ndp = [0] * (n + 1)\np = [[int(i) - 1 for i in sys.stdin.readline().split()] for j in range(n)]\np = sorted(p + [[h - 1, w - 1]])\nfor i in range(n + 1):\n h1, w1 = p[i]\n tot = f([h1, w1])\n for j in range(i):\n if p[j][1] > w1:\n continue\n tot = (tot - dp[j] * f([h1 - p[j][0], w1 - p[j][1]]) % m) % m\n dp[i] = tot\nprint(dp[-1])\n", "neg": "import sys\nh, w, n = [int(i) for i in sys.readline().split()]\nm = 1000000007\nfact = [1, 1]\nfor i in range(2, 200002):\n fact.append(fact[-1] * i)\ninv = [pow(i, m - 2, m) for i in fact]\nf = lambda i: fact[i[0] + i[1]] * inv[i[0]] * inv[i[1]] % m\ndp = [0] * (n + 1)\np = [[int(i) - 1 for i in sys.readline().split()] for j in range(n)]\np = sorted(p + [[h - 1, w - 1]])\nfor i in range(n + 1):\n h1, w1 = p[i]\n tot = f([h1, w1])\n for j in range(i):\n if p[j][1] > w1:\n continue\n tot = (tot - dp[j] * f([h1 - p[j][0], w1 - p[j][1]]) % m) % m\n dp[i] = tot\nprint(dp[-1])", "jacc_sim": 0.9791666666666666, "nl": "You are given a grid with H horizontal rows and W vertical columns. Some squares are wall squares, and the rest are empty. Taro starts at (1, 1) and needs to reach (H, W) by moving right or down to an adjacent empty square. Find the number of Taro's paths from (1, 1) to (H, W), modulo 10^9 + 7. The input format is H, W, N, followed by N pairs of coordinates (r_i, c_i). Output the number of paths.", "before_after_length": [292, 285], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03187", "p_user": "u858748695", "n_user": "u858748695", "pos": "#!/usr/bin/env python3\nfrom itertools import accumulate\nL, N = map(int, input().split())\nX = [int(input()) for _ in range(N)]\nY = [L - x for x in X][::-1]\n\nsx = [0] + list(accumulate(X))\nsy = [0] + list(accumulate(Y))\n\nans = 0\nfor i in range(N):\n j = N - i - 1\n mn = min(i, j)\n\n now = X[i]\n now += 2 * (sx[i] - sx[i - mn]) + 2 * (sy[j] - sy[j - mn - (i < j)])\n ans = max(ans, now)\n\n now = Y[j]\n now += 2 * (sx[i] - sx[i - mn - (i > j)]) + 2 * (sy[j] - sy[j - mn])\n ans = max(ans, now)\n\nprint(ans)\n", "neg": "#!/usr/bin/env python3\nfrom itertools import accumulate\nL, N = map(int, input().split())\nX = [int(input()) for _ in range(N)]\nY = [L - x for x in X][::-1]\n\nsx = [0] + list(accumulate(X))\nsy = [0] + list(accumulate(Y))\n\nans = 0\nfor i in range(N):\n j = N - i - 1\n mn = min(i, j)\n\n now = X[i]\n now += 2 * (sx[i] - sx[i - mn]) + 2 * (sy[j] - sy[j - mn - (i < j)])\n print(i - mn)\n ans = max(ans, now)\n\n now = Y[j]\n now += 2 * (sx[i] - sx[i - mn - (i > j)]) + 2 * (sy[j] - sy[j - mn])\n ans = max(ans, now)\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Takahashi Lake has a perimeter of L. On the circumference of the lake, there is a residence of the lake's owner, Takahashi. Each point on the circumference of the lake has a coordinate between 0 and L (including 0 but not L), which is the distance from Takahashi's residence, measured counter-clockwise. There are N trees around the lake; the coordinate of the i-th tree is X_i. There is no tree at coordinate 0, the location of Takahashi's residence. Starting at his residence, Takahashi will repeat the following action: If all trees are burnt, terminate the process. Specify a direction: clockwise or counter-clockwise. Walk around the lake in the specified direction, until the coordinate of a tree that is not yet burnt is reached for the first time. When the coordinate with the tree is reached, burn that tree, stay at the position and go back to the first step. Find the longest possible total distance Takahashi walks during the process.\n\nPartial Score: 300 points will be awarded for passing the input satisfying N \u2264 2000.\n\nConstraints:\n2 \u2264 L \u2264 10^9\n1 \u2264 N \u2264 2\u00d710^5\n1 \u2264 X_1 < ... < X_N \u2264 L-1\nAll values in input are integers.\n\nInput: Input is given from Standard Input in the following format:\nL N\nX_1\n...\nX_N\n\nOutput: Print the longest possible total distance Takahashi walks during the process.\n\nSample Input 1:\n10 3\n2\n7\n9\n\nSample Output 1:\n15\nTakahashi walks the distance of 15 if the process goes as follows:\n- Walk a distance of 2 counter-clockwise, burn the tree at the coordinate 2 and stay there.\n- Walk a distance of 5 counter-clockwise, burn the tree at the coordinate 7 and stay there.\n- Walk a distance of 8 clockwise, burn the tree at the coordinate 9 and stay there.\n\nSample Input 2:\n10 6\n1\n2\n3\n6\n7\n9\n\nSample Output 2:\n27\n\nSample Input 3:\n314159265 7\n21662711\n77271666\n89022761\n156626166\n160332356\n166902656\n298992265\n\nSample Output 3:\n1204124749", "before_after_length": [243, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03187", "p_user": "u785989355", "n_user": "u785989355", "pos": "\nL,N = list(map(int,input().split()))\nX=[]\nY=[]\nSX=[0]\nSY=[0]\nsx=0\nsy=0\nfor i in range(N):\n x=int(input())\n X.append(x)\n sx+=x\n SX.append(sx)\n Y.append(L-x)\n sy+=L-x\n SY.append(sy) \n\nmax_score=0 \nfor i in range(N):\n if i>N-i-1:\n max_score=max(2*(SX[i]-SX[2*i-N])+2*(SY[N]-SY[i+1])+Y[i],max_score)\n elif iN-i-1:\n max_score=max(2*(SX[i]-SX[2*i-N])+2*(SY[N]-SY[i+1])+Y[i],max_score)\n elif i0:\n print(\"first\")\nelse:\n print(\"second\")", "neg": "N=input()\ncount=0\nfor i in range(N):\n \tcount+=input()%2\nif count>0:\n\tprint(\"first\")\nelse:\n \tprint(\"second\")", "jacc_sim": 0.9565217391304348, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [50, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u304050136", "n_user": "u464574147", "pos": "print(\"second\" if all(int(input())%2 == 0 for i in range(int(input()))) else 'first')\n", "neg": "print(\"second\" if all([int(input()) % 2 == 0 for i in range(input())]) else \"first\")\n", "jacc_sim": 0.9047619047619048, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [30, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u304050136", "n_user": "u353402627", "pos": "n = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\nprint('second' if all(a[i]%2==0 for i in range(n)) else 'first')", "neg": "n = int(input())\n\na = []\n\nfor i in range(n):\n a.append(int(input())\n\nprint('second' if all(a[i] % 2 == 0 for i in range(n)) else 'first')\n", "jacc_sim": 1.0, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [56, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u702582248", "n_user": "u702582248", "pos": "n=int(input())\nif [i for i in [int(input()) for _ in range(n)] if i % 2]:\n print('first')\nelse:\n print('second')", "neg": "n=input()\nif [i for i in [int(input()) for _ in range(n)] if i % 2]:\n print('first')\n else:\n print('second')", "jacc_sim": 1.0, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [45, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u099566485", "n_user": "u099566485", "pos": "n=int(input())\na=[int(input()) for i in range(n)]\nb=list(set(a))\nc=0\nfor i in range(n):\n if a[i]%2==1:\n c+=1\nif len(b)==1 and b[0]==1:\n print(\"first\")\nelif sum(a)%2==0:\n if c%2==0 and c>=2:\n print(\"first\")\n else:\n print(\"second\")\nelse:\n print(\"first\")\n\n", "neg": "n=int(input())\na=[int(input()) for i in range(n)]\nb=list(set(a))\nif len(b)==1 and b[0]==1:\n print(\"first\")\nelif sum(a)%2==0:\n if n%2==1:\n print(\"first\")\n else:\n print(\"second\")\nelse:\n print(\"first\")\n\n", "jacc_sim": 0.9117647058823529, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [134, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u060392346", "n_user": "u060392346", "pos": "n = int(input())\na_list = [int(input()) for _ in range(n)]\n\nd = [\"second\", \"first\"]\n\nfor a in a_list:\n if a % 2 != 0:\n print(d[1])\n break\nelse:\n print(d[0])", "neg": "n = int(input())\na_list = [int(input()) for _ in range(n)]\n\nd = [\"second\", \"first\"]\n\nfor a in a_list:\n if a % 2 != 0:\n print(d[1])\nelse:\n print(d[0])", "jacc_sim": 0.9655172413793104, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [73, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u315078622", "n_user": "u708255304", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]\nif all(a % 2 == 0 for a in A):\n print(\"second\")\nelse:\n print(\"first\")\n", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nprint(\"second\" if all(a[i] % 2 == 0 for i in range(N)) else \"first\")\n", "jacc_sim": 0.9230769230769231, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [51, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u761320129", "n_user": "u236127431", "pos": "N = int(input())\nA = [int(input()) for i in range(N)]\n\nfor a in A:\n if a%2:\n print('first')\n exit()\nprint('second')", "neg": "N=int(input())\na=[int(i) for i in range(N)]\nfor i in a:\n if i%2==1:\n print(\"first\")\n exit()\nprint(\"second\")\n", "jacc_sim": 0.9166666666666666, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [50, 51], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03197", "p_user": "u864197622", "n_user": "u415905784", "pos": "N = int(input())\n\nfor i in range(N):\n if int(input()) % 2 == 1:\n print(\"first\")\n break\nelse:\n print(\"second\")", "neg": "N = int(input())\nfor i in range(N):\n if int(input)() % 2:\n print('first')\n break\nelse:\n print('second')", "jacc_sim": 0.9523809523809523, "nl": "You and Lunlun the dachshund take turns eating apples from a tree with apples of different colors. The one who eats the last apple wins. Given the number of apples of each color, determine who will win if both play optimally. The input consists of the number of colors and the count of apples for each color. Output \"first\" if you will win, and \"second\" if Lunlun will win. For example, if there are two colors with 1 and 2 apples respectively, you can win by eating strategically. If there are three colors with large apple counts, Lunlun will win.", "before_after_length": [45, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03198", "p_user": "u236127431", "n_user": "u236127431", "pos": "from math import log,ceil\nN=int(input())\nA=list(map(int,input().split()))\ninf=float(\"inf\")\np=[0]*(N+1)\nn=[0]*(N+1)\nStack_p=[(-inf,N-1)]\nStack_n=[(-inf,0)]\nfor i in range(N-1)[::-1]:\n k=ceil(log(A[i]/A[i+1],4))\n p[i]=p[i+1]\n t=i\n if k>=1:\n while k>0:\n #print(Stack_p,k,t,p)\n s,m=Stack_p.pop()\n p[i]+=k*(m-t)\n if k+s>=0:\n k+=s\n t=m\n else:\n Stack_p.append((k+s,m)) \n k=0\n elif k<0:\n Stack_p.append((k,i))\nfor i in range(2,N+1):\n k=ceil(log(A[i-1]/A[i-2],4))\n n[i]=n[i-1]\n t=i-1\n if k>=1:\n while k>0:\n # print(Stack_n,k,t,n)\n s,m=Stack_n.pop()\n # print(s,m)\n n[i]+=k*(t-m)\n t=m\n if k+s>=0:\n k+=s\n elif k+s<0:\n Stack_n.append((k+s,m)) \n k=0\n # print(Stack_n)\n elif k<0:\n Stack_n.append((k,i-1))\n#print(p)\n#print(n)\nans=inf\nfor i in range(N+1):\n ans=min(ans,i+2*n[i]+2*p[i])\nprint(ans)", "neg": "from math import log,ceil\nN=int(input())\nA=list(map(int,input().split()))\ninf=float(\"inf\")\np=[0]*(N+1)\nn=[0]*(N+1)\nStack_p=[(-inf,N-1)]\nStack_n=[(-inf,0)]\nfor i in range(N-1)[::-1]:\n k=ceil(log(A[i]/A[i+1],4))\n p[i]=p[i+1]\n t=i\n if k>=1:\n while k>0:\n s,m=Stack_p.pop()\n p[i]+=k*(m-t)\n if k+s>=0:\n k+=s\n else:\n k=0\n Stack_p.append((k+s,m)) \n elif k<0:\n Stack_p.append((k,i))\nfor i in range(2,N+1):\n k=ceil(log(A[i-1]/A[i-2],4))\n n[i]=n[i-1]\n t=i-1\n if k>=1:\n while k>0:\n print(Stack_n,k)\n s,m=Stack_n.pop()\n n[i]+=k*(t-m)\n if k+s>=0:\n k+=s\n else:\n k=0\n Stack_n.append((k+s,m)) \n elif k<0:\n Stack_n.append((k,i-1))\n#print(p)\n#print(n)\nans=inf\nfor i in range(N+1):\n ans=min(ans,i+2*n[i]+2*p[i])\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 800 points\nProblem Statement:\nThere are N positive integers A_1, A_2, ..., A_N. Takahashi can perform the following operation on these integers any number of times: Choose 1 \u2264 i \u2264 N and multiply the value of A_i by -2. He would like to make A_1 \u2264 A_2 \u2264 ... \u2264 A_N holds. Find the minimum number of operations required. If it is impossible, print -1.\nConstraints:\n1 \u2264 N \u2264 200000\n1 \u2264 A_i \u2264 10^9\nInput:\nInput is given from Standard Input in the following format:\nN\nA_1 A_2 ... A_N\nOutput:\nPrint the answer.\nSample Input 1:\n4\n3 1 4 1\nSample Output 1:\n3\nOne possible solution is:\n- Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now 3, 1, 4, -2.\n- Choose i=1 and multiply the value of A_1 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, -2.\n- Choose i=4 and multiply the value of A_4 by -2. A_1, A_2, A_3, A_4 are now -6, 1, 4, 4.\nSample Input 2:\n5\n1 2 3 4 5\nSample Output 2:\n0\nA_1 \u2264 A_2 \u2264 ... \u2264 A_N holds before any operation is performed.\nSample Input 3:\n8\n657312726 129662684 181537270 324043958 468214806 916875077 825989291 319670097\nSample Output 3:\n7", "before_after_length": [499, 448], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03202", "p_user": "u873915460", "n_user": "u873915460", "pos": "N=int(input())\nA=list(map(int,input().split()))\ndef judge(X):\n Y=[[A[0],1]]\n Z=0\n for i in range(N-1):\n if A[i]L:\n M=(L+R)//2\n if judge(M):\n R=M\n else:\n L=max(L+1,M)\nprint(L)", "neg": "N=int(input())\nA=list(map(int,input().split()))\ndef judge(X):\n Y=[[A[0],1]]\n Z=0\n for i in range(N-1):\n if A[i]L:\n M=(L+R+1)//2\n if judge(M):\n R=min(M,R-1)\n else:\n L=M\nprint(L)", "jacc_sim": 0.9433962264150944, "nl": "You are given N strings arranged in a row, where each string is lexicographically greater than the one to its left. Determine the minimum number of different characters in the strings, given their respective lengths A_i. The strings may contain any number of characters, and the order is defined for those characters. The input is given in the format: N followed by A_1, A_2, ..., A_N. Output the minimum possible number of different characters in the strings.", "before_after_length": [399, 380], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03202", "p_user": "u467736898", "n_user": "u467736898", "pos": "\nN = int(input())\nB = list(map(int, input().split()))\nA = list(map(lambda x: min(x, 20), B))\n#A = list(map(lambda x: min(int(x), 20), input().split()))\n\n\ndef bis(k):\n if k == 1:\n c = 0\n for a in B:\n if c >= a:\n return False\n else:\n c = a\n return True\n #if k==3:\n # raise ValueError\n\n C = [0] * 20\n for a in A:\n a -= 1\n b = a-1\n while b >= 0:\n if C[b] == 0:\n C[b] = 1\n b -= 1\n else:\n break\n\n for i in range(len(C[a+1:])):\n C[a+1+i] = 0\n while C[a] == k:\n if a == 0:\n return False\n #print(\"a\")\n C[a] = 1\n a -= 1\n C[a] += 1\n #print(C)\n return True\n\n\n\nmi, ma = 0, (1<<19)\nwhile ma-mi!=1:\n c = (mi + ma) >> 1\n if bis(c):\n ma = c\n else:\n mi = c\nif ma==3 and max(B) >= 10**5:\n print(ma-1)\nelse:\n print(ma)\n", "neg": "N = int(input())\nB = list(map(int, input().split()))\nA = list(map(lambda x: min(x, 20), B))\n#A = list(map(lambda x: min(int(x), 20), input().split()))\n\n\ndef bis(k):\n if k == 1:\n raise ValueError\n c = 0\n for a in B:\n if c >= a:\n return False\n else:\n c = a\n return True\n\n C = [0] * 20\n for a in A:\n a -= 1\n b = a-1\n while b >= 0:\n if C[b] == 0:\n C[b] = 1\n b -= 1\n else:\n break\n\n for i in range(len(C[a+1:])):\n C[a+1+i] = 0\n while C[a] == k:\n if a == 0:\n return False\n #print(\"a\")\n C[a] = 1\n a -= 1\n C[a] += 1\n #print(C)\n return True\n\n\n\nmi, ma = 0, (1<<19)\nwhile ma-mi!=1:\n c = (mi + ma) >> 1\n if bis(c):\n ma = c\n else:\n mi = c\nprint(ma)\n\n", "jacc_sim": 0.9180327868852459, "nl": "You are given N strings arranged in a row, where each string is lexicographically greater than the one to its left. Determine the minimum number of different characters in the strings, given their respective lengths A_i. The strings may contain any number of characters, and the order is defined for those characters. The input is given in the format: N followed by A_1, A_2, ..., A_N. Output the minimum possible number of different characters in the strings.", "before_after_length": [373, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03202", "p_user": "u226155577", "n_user": "u226155577", "pos": "N = int(input())\n*A, = map(int, input().split())\n\ndef check(K):\n st = []\n for i, a in enumerate(A):\n #print(K, i, st, a)\n while st and a < st[-1][0]:\n st.pop()\n u = i > 0 and A[i-1] >= A[i]\n if not st:\n st.append([a, u])\n continue\n l = st[-1]\n if l[0] == a:\n l[1] += 1\n while st and l[1] == K:\n st.pop(); a -= 1\n if a == 0:\n return 0\n if not st:\n st.append([a, 1])\n break\n l = st[-1]\n if l[0] == a:\n l[1] += 1\n else:\n st.append([a, 1])\n break\n #print(l, st)\n else:\n st.append([a, u])\n #print(st)\n return 1\n\nok = 1\nfor i in range(N-1):\n if not A[i] < A[i+1]:\n ok = 0\nif ok:\n print(1)\n exit(0)\n\nleft = 1; right = N+1\nwhile left+1 < right:\n mid = (left + right) // 2\n if check(mid):\n right = mid\n else:\n left = mid\nprint(right)", "neg": "N = int(input())\n*A, = map(int, input().split())\n\ndef check(K):\n st = []\n for i, a in enumerate(A):\n #print(K, i, st, a)\n while st and a < st[-1][0]:\n st.pop()\n if not st:\n st.append([a, 1])\n continue\n l = st[-1]\n if l[0] == a:\n l[1] += 1\n while st and l[1] == K+1:\n st.pop(); a -= 1\n if a == 0:\n return 0\n if not st:\n st.append([a, 1])\n break\n l = st[-1]\n if l[0] == a:\n l[1] += 1\n else:\n st.append([a, 1])\n break\n else:\n st.append([a, 1])\n return 1\n\nleft = 0; right = N+1\nwhile left+1 < right:\n mid = (left + right) // 2\n if check(mid):\n right = mid\n else:\n left = mid\nprint(right)", "jacc_sim": 0.9056603773584906, "nl": "You are given N strings arranged in a row, where each string is lexicographically greater than the one to its left. Determine the minimum number of different characters in the strings, given their respective lengths A_i. The strings may contain any number of characters, and the order is defined for those characters. The input is given in the format: N followed by A_1, A_2, ..., A_N. Output the minimum possible number of different characters in the strings.", "before_after_length": [373, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u905582793", "n_user": "u905582793", "pos": "h,w,n=map(int,input().split())\nxy=[list(map(int,input().split())) for i in range(n)]\nxy.sort()\ncnt=0\nans=h\nfor x,y in xy:\n if x-1>=y+cnt:\n ans=x-1\n break\n elif x==y+cnt:\n cnt+=1\nprint(ans)\n", "neg": "h,w,n=map(int,input().split())\nxy=[list(map(int,input().split())) for i in range(n)]\nxy.sort()\ncnt=0\nans=h\nfor i in range(n):\n if x-1>=y+cnt:\n ans=x-1\n break\n elif x==y+cnt:\n cnt+=1\nprint(ans)\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [99, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u310678820", "n_user": "u310678820", "pos": "H, W, N = map(int, input().split())\nxy = []\nfor i in range(N):\n x, y = map(int, input().split())\n xy.append((x, y))\nxy.sort()\n\nans = H\nd = 0\nfor x, y in xy:\n if x-d>y:\n ans = x-1\n break\n if x-d == y:\n d+=1\nprint(ans)\n\n\n\n\n", "neg": "H, W, N = map(int, input().split())\nxy = []\nfor i in range(N):\n x, y = map(int, input().split())\n xy.append((x, y))\nxy.sort()\n\nans = W\nd = 0\nfor x, y in xy:\n if x-d>y:\n print(x, y)\n ans = x-1\n break\n if x-d == y:\n d+=1\nprint(ans)\n\n\n\n\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [116, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u077337864", "n_user": "u077337864", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\ndef main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(int, input().split())) for _ in range(n)]\n miny = [float(\"inf\") for _ in range(h + 1)]\n for x, y in xy:\n miny[x - 1] = min(miny[x - 1], y - 1)\n miny[h] = 0\n \n tmpx, tmpy = 0, 0\n while tmpx < h:\n if miny[tmpx + 1] <= tmpy:\n break\n elif miny[tmpx + 1] == tmpy + 1:\n tmpx += 1\n else:\n tmpx += 1\n tmpy += 1\n \n print(min(tmpx + 1, h))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\ndef main():\n h, w, n = map(int, input().split())\n xy = [tuple(map(int, input().split())) for _ in range(n)]\n miny = [float(\"inf\") for _ in range(h + 1)]\n for x, y in xy:\n miny[x - 1] = min(miny[x - 1], y - 1)\n miny[h] = 0\n \n tmpx, tmpy = 0, 0\n while tmpx < h:\n if miny[tmpx + 1] == tmpy + 1:\n tmpx += 1\n elif miny[tmpy + 1] < tmpy:\n break\n else:\n tmpx += 1\n tmpy += 1\n \n print(tmpx + 1)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [238, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u297574184", "n_user": "u297574184", "pos": "H, W, N = map(int, input().split())\nposObss = [{H} for y in range(W)]\nfor _ in range(N):\n X, Y = map(int, input().split())\n posObss[Y - 1].add(X - 1)\n\nans = H\nxNow = 0\nfor y in range(W):\n xLim = min([x for x in posObss[y] if x > xNow])\n ans = min(ans, xLim)\n\n if y == W - 1: break\n xNow += 1\n while xNow in posObss[y + 1]:\n xNow += 1\n if xNow >= xLim: break\n\nprint(ans)\n", "neg": "H, W, N = map(int, input().split())\nposObss = [{H} for y in range(W)]\nfor _ in range(N):\n X, Y = map(int, input().split())\n posObss[Y - 1].add(X - 1)\n\nans = H\nxNow = 0\nfor y in range(W):\n xLim = min([x for x in posObss[y] if x > xNow])\n ans = min(ans, xLim)\n\n xNow += 1\n while xNow in posObss[y + 1]:\n xNow += 1\n if xNow >= xLim: break\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [176, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u368780724", "n_user": "u368780724", "pos": "from collections import defaultdict\nimport sys\ndef inpl(): return [int(i) for i in input().split()]\nH, W, N = inpl()\nif not N:\n print(H)\n sys.exit()\nA = []\nB = defaultdict(lambda: [])\nC = defaultdict(lambda: H+1)\nfor _ in range(N):\n x, y = inpl()\n A.append((x,y))\n B[y].append(x)\nT = [0]*(W+1)\nT[1] = 2\nfor i in range(1,W):\n if not B[i+1]:\n T[i+1] = T[i] + 1\n continue\n ctr = T[i]\n while True:\n if ctr in B[i+1]:\n ctr += 1\n continue\n break\n T[i+1] = min(ctr+1, H+1)\nfor x,y in A:\n if x >= T[y]:\n C[y] = min(C[y], x)\nprint(min([i-1 for i in C.values()]+[H]))", "neg": "from collections import defaultdict\nimport sys\ndef inpl(): return [int(i) for i in input().split()]\nH, W, N = inpl()\nif not N:\n print(W)\n sys.exit()\nA = []\nB = defaultdict(lambda: [])\nC = defaultdict(lambda: W)\nfor _ in range(N):\n x, y = inpl()\n A.append((x,y))\n B[y].append(x)\nT = [0]*(H+1)\nT[1] = 2\nfor i in range(1,H):\n if not B[i+1]:\n T[i+1] = min(W,T[i] + 1)\n continue\n ctr = T[i]\n while True:\n if ctr in B[i+1]:\n ctr += 1\n continue\n break\n T[i+1] = min(ctr+1, W)\nfor x,y in A:\n if x >= T[y]:\n C[y] = min(C[y], x)\nprint(min([i-1 for i in C.values()]+[W]))\nprint(T)", "jacc_sim": 1.0, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [275, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u281303342", "n_user": "u281303342", "pos": "H,W,N = map(int,input().split())\nXY = []\nfor i in range(N):\n x,y = map(int,input().split())\n XY.append((x,y))\n\nXY.sort()\n\nans,d = H,0\nfor xy in XY:\n x,y = xy[0],xy[1]\n if x == y+d:\n d += 1\n elif x > y+d:\n ans = min(ans, x-1)\n\nprint(ans)\n", "neg": "H,W,N = map(int,input().split())\nXY = []\nfor i in range(N):\n x,y = map(int,input().split())\n XY.append((x,y))\n\nXY.sort()\n\nans,d = 9999999999999,0\nfor xy in XY:\n x,y = xy[0],xy[1]\n if x == y+d:\n d += 1\n elif x > y+d:\n ans = min(ans, x-1)\n\nprint(ans)", "jacc_sim": 0.972972972972973, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [127, 128], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03203", "p_user": "u884982181", "n_user": "u884982181", "pos": "import bisect\nh,w,n = map(int,input().split())\na = []\nfor i in range(n):\n x,y = map(int,input().split())\n x-=1\n y-=1\n a.append([x,y])\nkabe = [[] for i in range(w)]\nfor i,j in a:\n kabe[j].append(i)\nfor i in range(w):\n kabe[i].sort()\nans = float(\"inf\")\nto = 0\nfor i in range(w):\n mo = bisect.bisect_right(kabe[i], to)\n if mo < len(kabe[i]):\n ans = min(ans,kabe[i][mo])\n else:\n ans = min(ans,h)\n if i == w-1:\n break\n c = set(kabe[i+1])\n to += 1\n while to in c:\n to+=1\n if to >h:\n break\nprint(ans)", "neg": "import bisect\nh,w,n = map(int,input().split())\na = []\nfor i in range(n):\n x,y = map(int,input().split())\n x-=1\n y-=1\n a.append([x,y])\nkabe = [[] for i in range(w)]\nfor i,j in a:\n kabe[j].append(i)\nfor i in range(w):\n kabe[i].sort()\nans = float(\"inf\")\nto = 0\nfor i in range(w):\n mo = bisect.bisect_right(kabe[i], to)\n if mo < len(kabe[i]):\n ans = min(ans,kabe[i][mo])\n else:\n ans = min(ans,h+1)\n if i == w-1:\n break\n c = set(kabe[i+1])\n to += 1\n while to in c:\n to+=1\nprint(ans)", "jacc_sim": 0.98, "nl": "In this game, Takahashi and Aoki play on a grid with H rows and W columns. There are N obstacles at specific coordinates. Players take turns moving a piece to an adjacent cell or not moving it. The game ends when the piece doesn't move twice in a row. Takahashi aims to perform as many actions as possible before the game ends, while Aoki aims to perform as few actions as possible. The task is to determine the number of actions Takahashi will perform. The constraints are 1 \u2264 H,W \u2264 2*10^5, 0 \u2264 N \u2264 2*10^5, 1 \u2264 X_i \u2264 H, 1 \u2264 Y_i \u2264 W, and other conditions. The input format is H, W, N, followed by N lines of X and Y coordinates. The output is the number of actions Takahashi will perform. Sample inputs and outputs are provided.", "before_after_length": [259, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u401487574", "n_user": "u401487574", "pos": "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\n\nn,k = ma()\nA = lma()\nbu = []\nfor i in range(n):\n tmp=0\n for j in range(i,n):\n tmp+=A[j]\n bu.append(tmp)\nmb = bin(max(bu))\nls = [0]*(len(mb)-2)\nfor b in bu:\n for i in range(len(bin(b))-2):\n if (b>>i &1):\n ls[i]+=1\nans = 0\ntmp=bu\nfor i in range(len(mb)-3,-1,-1):\n if ls[i]>i &1):\n tmp2.append(b)\n if len(tmp2)>=k:\n ans+=2**i\n tmp=tmp2\n else:\n pass\nprint(ans)\n", "neg": "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\n\nn,k = ma()\nA = lma()\nbu = []\nfor i in range(n):\n tmp=0\n for j in range(i,n):\n tmp+=A[j]\n bu.append(tmp)\nmb = bin(max(bu))\nans = 0\nfor i in range(len(mb)-3,-1,-1):\n tmp=[]\n for b in bu:\n if (b>>i &1):\n tmp.append(b)\n if len(tmp2)>=k:\n ans+=2**i\n bu=tmp\n else:\n pass\nprint(ans)\n", "jacc_sim": 0.9538461538461539, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [322, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u222668979", "n_user": "u222668979", "pos": "from itertools import accumulate\n\ndef main():\n n, k = map(int, input().split())\n a = [0] + list(accumulate(map(int, input().split())))\n\n btfl = []\n for i in range(0, n):\n for j in range(i + 1, n + 1):\n btfl.append(a[j] - a[i])\n\n # \u89e3\u8aacAC\n ans = 0\n for i in range(50)[::-1]:\n num, cnt = ans + pow(2, i), 0\n for b in btfl:\n if num == num & b:\n cnt += 1\n if cnt >= k:\n ans = num\n print(ans)\n\nif __name__ == '__main__':\n main()\n", "neg": "from itertools import accumulate\nn, k = map(int, input().split())\na = [0] + list(accumulate(map(int, input().split())))\n\nbtfl = []\nfor i in range(0, n):\n for j in range(i + 1, n + 1):\n btfl.append(a[j] - a[i])\n\n# \u89e3\u8aacAC\nans = 0\nfor i in range(50)[::-1]:\n num, cnt = ans + pow(2, i), 0\n for b in btfl:\n if num == num & b:\n cnt += 1\n print(num,cnt)\n if cnt >= k:\n ans = num\nprint(ans)\n", "jacc_sim": 0.9019607843137255, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [195, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u346812984", "n_user": "u346812984", "pos": "import sys\nimport copy\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n s = []\n for i in range(N):\n tmp = A[i]\n s.append(tmp)\n for j in range(i + 1, N):\n tmp += A[j]\n s.append(tmp)\n\n s.sort(reverse=True)\n M = s[0]\n ans = 0\n n = M.bit_length()\n for i in range(n):\n tmp = []\n for v in s:\n if 1 << (n - i - 1) & v:\n tmp.append(v)\n if len(tmp) >= K:\n ans += 1 << (n - i - 1)\n s = copy.deepcopy(tmp)\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\nimport copy\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n s = []\n for i in range(N):\n tmp = A[0]\n s.append(tmp)\n for j in range(i + 1, N):\n tmp += A[j]\n s.append(tmp)\n\n s.sort(reverse=True)\n M = s[0]\n ans = 0\n n = M.bit_length()\n for i in range(n):\n tmp = []\n for v in s:\n if 1 << (n - i - 1) & v:\n tmp.append(v)\n if len(tmp) >= K:\n ans += 1 << (n - i - 1)\n s = copy.deepcopy(tmp)\n\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [281, 281], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u932465688", "n_user": "u932465688", "pos": "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nP = [0]+A\nfor i in range(1,n+1):\n P[i] += P[i-1]\ntemp = []\nfor i in range(n+1):\n for j in range(i+1, n+1):\n temp.append(P[j]-P[i])\nans = 0\nfor i in range(40, -1, -1):\n cur = ans+2**i\n cnt = 0\n for j in range(len(temp)):\n if temp[j]&cur == cur:\n cnt += 1\n if cnt >= k:\n break\n if cnt == k:\n ans += 2**i\nprint(ans)\n", "neg": "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nP = [0]+A\nfor i in range(1,n+1):\n P[i] += P[i-1]\ntemp = []\nfor i in range(n+1):\n for j in range(i+1, n+1):\n temp.append(P[j]-P[i])\nprint(temp)\nans = 0\nfor i in range(40, -1, -1):\n cur = ans+2**i\n cnt = 0\n for j in range(len(temp)):\n if temp[j]&cur == cur:\n cnt += 1\n if cnt >= k:\n break\n if cnt == k:\n ans += 2**i\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [193, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u145600939", "n_user": "u145600939", "pos": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nsal = [0] * (n*(n+1)//2)\nl = 0\nfor i in range(n):\n for j in range(i,n):\n sal[l] = sum(a[i:j+1])\n l += 1\nans = 0\nfor i in range(41)[::-1]:\n cnt = 0\n temp = ans + 2**i\n for j in sal:\n if temp&j == temp:\n cnt += 1\n if cnt >= k:\n ans = temp\nprint(ans)\n", "neg": "n,k = map(int,input().split())\na = list(map(int,input().split()))\nsal = [0] * (n*(n+1)//2)\nl = 0\nfor i in range(n):\n for j in range(i,n):\n sal[l] = sum(a[i:j+1])\n l += 1\nans = 0\nfor i in range(40)[::-1]:\n cnt = 0\n temp = ans + 2**i\n for j in a:\n if temp&j == temp:\n cnt += 1\n if cnt >= k:\n ans = temp\nprint(ans)\n", "jacc_sim": 0.95, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [157, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\nimport numpy as np\nimport itertools\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN, K = lr()\nA = np.array([0] + lr())\nA_cum = A.cumsum()\nbeauties = []\nfor i, j in itertools.combinations(range(N+1), 2):\n beauties.append(A_cum[j] - A_cum[i])\n\nbeauties = np.array(beauties)\nj = 0\ndef check(x):\n return np.sum(beauties&x == x) >= K\n\nanswer = 0\nfor i in range(40, -1, -1):\n if check(answer + (1 << i)):\n answer += 1 << i\n\nprint(answer)\n# 00\n", "neg": "import sys\nimport numpy as np\nimport itertools\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN, K = lr()\nA = np.array([0] + lr())\nA_cum = A.cumsum()\nbeauties = []\nfor i, j in itertools.combinations(range(N+1), 2):\n beauties.append(A_cum[j] - A_cum[i])\n\nbeauties.sort(reverse=True)\nj = 0\ndef check(x):\n return sum([x&y == x for y in beauties]) >= K\n\nanswer = 0\nfor i in range(40, -1, -1):\n if check(answer + 1 << i):\n answer += 1 << i\n\nprint(answer)\n# 00\n", "jacc_sim": 0.9354838709677419, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [218, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u227082700", "n_user": "u227082700", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nfor i in range(n):\n x=0\n for j in range(i,n):\n x+=a[j]\n b.append(x)\nans=0\nl=len(b)\nfor i in range(40,-1,-1):\n x=0\n s=2**i\n for j in range(l):\n if b[j]&(ans+s)==ans+s:x+=1\n if x>=k:ans+=s\nprint(ans)", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nb=[]\nfor i in range(n):\n x=0\n for j in range(i,n):\n x+=a[j]\n b.append(x)\nans=0\nl=len(b)\nfor i in range(40,0,-1):\n x=0\n s=2**i-1\n for j in range(l):\n if b[j]%s==0:\n b[j]//=s\n x+=1\n if x>=k:ans+=s\nprint(s)", "jacc_sim": 0.926829268292683, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [156, 162], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u780962115", "n_user": "u780962115", "pos": "n,k=map(int,input().split())\nlists=list(map(int,input().split()))\nGG=[]\nsumlist=[0]\na=0\nfor i in range(len(lists)):\n a+=lists[i]\n sumlist.append(a) \nfor i in range(len(sumlist)):\n for j in range(i+1,len(sumlist)):\n \n G=sumlist[j]-sumlist[i]\n GG.append(G)\n \nGG=sorted(GG,reverse=True) \nmaxi=format(GG[0],\"b\")\nfrom collections import deque\nd=deque()\ne=deque()\nfor j in range(len(GG)):\n d.append(format(GG[j],\"b\").zfill(len(maxi)))\nanswer=0\nindex=0\n \nwhile index!=len(maxi):\n counter=0\n for some in d:\n if some[index]==\"1\":\n counter+=1\n e.append(some)\n if counter>=k:\n answer+=2**(len(maxi)-1-index)\n d=e\n e=deque()\n elif counter=k:\n answer+=2**(len(maxi)-1-index)\n d=e\n e=deque()\n elif counter= k:\n x += t\nprint(x)", "neg": "n,k = map(int, input().split())\nl = [0] + list(map(int, input().split()))\na = list()\nfor i in range(n):\n l[i+1] += l[i]\na = [l[j]-l[i] for j in range(i+1,n+1) for i in range(n)]\nx = 0\nfor i in range(40,-1,-1):\n t = 2**i\n if sum(map(lambda y:(y&(t+x) == t+x),a)) >= k:\n x += t\nprint(x)\n", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [152, 153], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u623819879", "n_user": "u623819879", "pos": "from heapq import heappush, heappop\nfrom collections import deque\nimport itertools\nfrom itertools import permutations\nimport sys\n\nimport bisect\nsys.setrecursionlimit(10**6)\ndef SI():\n return input().split()\ndef MI():\n return map(int,input().split())\ndef I():\n return int(input())\ndef LI():\n return [int(i) for i in input().split()]\nYN=['Yes','No']\nYNeos='YNeos'\nGYN=['Yes','trumpet']\nmo=10**9+7\nimp='IMPOSSIBLE'\n\nn,k=MI()\na=LI()\nA=[0]\nfor i in a:\n A+=[A[-1]+i]\nb=[]\nfor i in range(n+1):\n for j in range(i+1,n+1):\n b+=[A[j]-A[i]]\n \nc=sorted(b)#[-k:]\nans=0\ni=0\ni2=2**40\nwhile i2>0:\n# print(i2,sum([(j&(ans+i2))==(ans+i2) for j in c]))\n ans+=i2 if sum([(j&(ans+i2))==(ans+i2) for j in c])>=k else 0\n i2//=2\n i+=1\n \nprint(ans)#,A,c)\n#print()\n", "neg": "from heapq import heappush, heappop\nfrom collections import deque\nimport itertools\nfrom itertools import permutations\nimport sys\n\nimport bisect\nsys.setrecursionlimit(10**6)\ndef SI():\n return input().split()\ndef MI():\n return map(int,input().split())\ndef I():\n return int(input())\ndef LI():\n return [int(i) for i in input().split()]\nYN=['Yes','No']\nYNeos='YNeos'\nGYN=['Yes','trumpet']\nmo=10**9+7\nimp='IMPOSSIBLE'\n\nn,k=MI()\na=LI()\nA=[0]\nfor i in a:\n A+=[A[-1]+i]\nb=[]\nfor i in range(n+1):\n for j in range(i+1,n+1):\n b+=[A[j]-A[i]]\n \nc=sorted(b)#[-k:]\nans=0\ni=0\ni2=1\nwhile i20 for j in c])>=k else 0\n #print(i2,sum([j>>i&1 for j in c]))\n i2*=2\n i+=1\n \nprint(ans)\n", "jacc_sim": 0.96, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [353, 326], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u552502395", "n_user": "u552502395", "pos": "N, K =map(int, input().split())\na = list(map(int, input().split()))\ncumsum = [0]\nfor i in range(N):\n cumsum.append( a[i] + cumsum[i] )\n#print(\"{}\".format(cumsum))\n\nbeauty = []\nfor l in range(N + 1):\n for r in range(l + 1, N + 1):\n beauty.append(cumsum[r] - cumsum[l])\nbeauty.sort()\n#print(\"{}\".format(beauty))\n\nmax = 0\nfor shift in range(60, -1, -1):\n mask = 1 << shift\n count = 0\n# print(\"{} {}\".format(shift,beauty))\n for i in range(len(beauty)-1,-1,-1):\n# print(\"{} {}\".format(i,beauty[i]))\n if (beauty[i] & mask) == 0:\n continue\n count+=1\n if count >= K:\n# print(\"{} {} {}\".format(shift,max,mask))\n max |= mask;\n# print(\"{} {} {}\".format(shift,max,mask))\n tmp = []\n for i in range(len(beauty) - 1, -1, -1):\n if ((beauty[i] & mask) == 0):\n continue\n tmp.append(beauty[i])\n beauty.clear()\n for i in range(len(tmp)):\n beauty.append(tmp[i])\nprint(max)\n", "neg": "N, K =map(int, input().split())\na = list(map(int, input().split()))\ncumsum = [0]\nfor i in range(N):\n cumsum.append( a[i] + cumsum[i] )\n#print(\"{}\".format(cumsum))\n\nbeauty = []\nfor l in range(N + 1):\n for r in range(l + 1, N + 1):\n beauty.append(cumsum[r] - cumsum[l])\nbeauty.sort()\n#print(\"{}\".format(beauty))\n\nmax = 0\nfor shift in range(4, 0, -1):\n mask = 1 << shift\n count = 0\n# print(\"{} {}\".format(shift,beauty))\n for i in range(len(beauty)-1,-1,-1):\n# print(\"{} {}\".format(i,beauty[i]))\n if (beauty[i] & mask) == 0:\n continue\n count+=1\n if count >= K:\n# print(\"{} {} {}\".format(shift,max,mask))\n max |= mask;\n# print(\"{} {} {}\".format(shift,max,mask))\n tmp = []\n for i in range(len(beauty) - 1, -1, -1):\n if ((beauty[i] & mask) == 0):\n continue\n tmp.append(beauty[i])\n beauty.clear()\n for i in range(len(tmp)):\n beauty.append(tmp[i])\nprint(max)\n", "jacc_sim": 0.9615384615384616, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [391, 390], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u497596438", "n_user": "u497596438", "pos": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\nA=[0]+A\nfor i in range(N):\n A[i+1]+=A[i]\nB=[]\nfor i in range(1,N+1):\n for j in range(N-i+1):\n B.append(A[i+j]-A[j])\nB.sort(reverse=True)\nm=40\nx=0\nfor t in range(m,0,-1):\n res=0\n for a in B:\n if ((x+2**(t-1))&a)==(x+2**(t-1)):\n res+=1\n if res>=K:\n x+=2**(t-1)\n break\nprint(x)\n", "neg": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\nA=[0]+A\nfor i in range(N):\n A[i+1]+=A[i]\nB=[]\nfor i in range(1,N+1):\n for j in range(N-i+1):\n B.append(A[i+j]-A[j])\nB.sort(reverse=True)\nm=40\nx=0\nfor t in range(m,0,-1):\n res=0\n for a in B:\n if ((x+1<<(t-1))&a)==(x+1<<(t-1)):\n res+=1\n if res>=K:\n x+=1<<(t-1)\n break\nprint(x)\n", "jacc_sim": 0.9318181818181818, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [204, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u782098901", "n_user": "u782098901", "pos": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef countMask(a):\n ret = 0\n for x in cand:\n if (x & a) == a:\n ret += 1\n return ret\n\n\ncand = []\nfor i in range(N):\n sum = 0\n for j in range(i, N):\n sum += A[j]\n cand.append(sum)\n\nans = 0\n\nfor i in range(40, -1, -1):\n if (countMask(ans | (1 << i)) >= K):\n ans |= 1 << i\n\nprint(ans)\n", "neg": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n\ndef countMask(a):\n ret = 0\n for x in cand:\n if (x & a) == a:\n ret += 1\n return ret\n\n\ncand = []\nfor i in range(N):\n sum = 0\n for j in range(j, N):\n sum += A[j]\n cand.append(sum)\n\nans = 0\n\nfor i in range(40, -1, -1):\n if (countMask(ans | (1 << i)) >= K):\n ans |= 1 << i\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [165, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u591717585", "n_user": "u284854859", "pos": "n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nb = []\nfor i in range(n):\n r = 0\n for j in range(i,n):\n r += a[j]\n b.append(r)\n\n\nn2 = n*(n+1)//2\n\nres = 0\nfor i in range(41):\n p = res + 2**(40-i)\n \n c = 0\n for j in range(n2):\n if p == p&b[j]:\n c+=1\n \n if c >= k:\n res = p\n\nprint(res)\n", "neg": "n,k = map(int,input().split())\na = list(map(int,input().split()))\n\nb = []\nfor i in range(n):\n r = 0\n for j in range(i+1,n):\n r += a[j]\n b.append(r)\n\n\nn2 = n*(n+1)//2\n\nres = 0\nfor i in range(41):\n p = res + 2**(40-i)\n \n c = 0\n for j in range(n2):\n if p == p&b[j]:\n c+=1\n \n if c >= k:\n res = p\n\nprint(res)", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [166, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u070561949", "n_user": "u070561949", "pos": "n,k=map(int,input().split())\nd=list(map(int,input().split()))\n\nds = []\n \nfor i in range(0,n):\n sum = 0\n for j in range(i,n):\n sum += d[j]\n ds.append(sum)\n\nds.sort(reverse=True)\n \nfor i in range(40,-1,-1):\n count = 0\n o = []\n \n for dss in ds:\n if dss & (1 << i) > 0 :\n count += 1\n o.append(dss)\n if count >= k :\n ds = list(o)\n \nsum = ds[0]\nfor i in range(1,k):\n sum = sum & ds[i]\n \nprint(sum)", "neg": "n,k=map(int,input().split())\n \nd=list(map(int,input().split()))\n\nds = []\n\nfor i in range(0,n):\n for len in range(1,n-i+1):\n sum = 0\n for j in range(i,i+len):\n sum += d[j]\n ds.append(sum)\n\no = []\nds.sort(reverse=True)\n\nsum = 0\nfor i in range(32,-1,-1):\n count = 0\n o.clear()\n\n for dss in ds:\n if dss & (1 << i) > 0 :\n count += 1\n o.append(dss)\n\n if count >= k :\n sum += 1 << i\n ds = o\n\nprint(sum)", "jacc_sim": 0.9069767441860465, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [199, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u070561949", "n_user": "u070561949", "pos": "n,k=map(int,input().split())\nd=list(map(int,input().split()))\n\nds = []\n\nfor i in range(0,n):\n sum = 0\n for j in range(i,n):\n sum += d[j]\n ds.append(sum)\n #print(str(sum) + \" \",end='')\n #print()\n\nds.sort(reverse=True)\n\nsum = 0\nfor i in range(40,-1,-1):\n count = 0\n o = []\n for dss in ds:\n if dss & (1 << i) > 0 :\n count += 1\n o.append(dss)\n\n if count >= k :\n sum += 1 << i\n ds = o\n\nprint(sum)", "neg": "n,k=map(int,input().split())\nd=list(map(int,input().split()))\n\nds = []\n\nfor i in range(0,n):\n sum = 0\n for j in range(i,n):\n sum += d[j]\n ds.append(sum)\n //print(str(sum) + \" \",end='')\n //print()\n\nds.sort(reverse=True)\n\nsum = 0\nfor i in range(40,-1,-1):\n count = 0\n o = []\n for dss in ds:\n if dss & (1 << i) > 0 :\n count += 1\n o.append(dss)\n\n if count >= k :\n sum += 1 << i\n ds = o\n\nprint(sum)", "jacc_sim": 0.9555555555555556, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [195, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u807772568", "n_user": "u807772568", "pos": "a,b = map(int,input().split())\n\nc = list(map(int,input().split()))\n\naa = []\naa.append(0)\naa.append(c[0])\n\nl = []\nfor i in range(1,a):\n\taa.append(aa[i]+c[i])\nd = 0\np = len(aa)\nfor i in range(p):\n\tfor j in range(i+1,p):\n\t\tl.append(aa[j]-aa[i])\nco = 0\nla = 0\nfor i in range(40,-1,-1):\n\tfor j in range(len(l)):\n\t\tif l[j] & (la + 2 ** i) == (la + 2 ** i):\n\t\t\tco += 1\n\tif co >= b:\n\t\tla += (2 ** i)\n\tco = 0\n\nprint(la)\n", "neg": "a,b = map(int,input().split())\n\nc = list(map(int,input().split()))\n\naa = []\naa.append(0)\naa.append(c[0])\n\nl = []\nfor i in range(1,a):\n\taa.append(aa[i]+c[i])\nd = 0\np = len(aa)\nfor i in range(p):\n\tfor j in range(i+1,p):\n\t\tl.append(aa[j]-aa[i])\nco = 0\nla = 0\n\nfor i in range(40,-1,-1):\n\tfor j in range(len(l)):\n\t\tif l[j] & (2 ** i) == (2 ** i):\n\t\t\tco += 1\n\tif co >= b:\n\t\tla += (2 ** i)\n\tco = 0\n\nprint(la)\n", "jacc_sim": 1.0, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [218, 215], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u709304134", "n_user": "u709304134", "pos": "#coding:utf-8\nn,k = map(int,input().split())\nls_a = list(map(int,input().split()))\ntarget = int(k*(k+1)/2)\nls_target = []\ni = 1\nwhile(1):\n for j in range(i):\n temp = ls_a[j:(len(ls_a)-i+j+1)]\n ls_target.append(sum(temp))\n if i==n:\n break\n i+=1\n\ndef check(num):\n for i in range(50):\n if (num < 2**i):\n return i-1, 2**(i-1)\nmx = ls_target[0]\ndigit, mx_bin = check(mx)\nans = 0\nfor d in range(digit+1):\n# print (mx_bin)\n# print (ls_target)\n new_idx = []\n cnt = 0\n for idx,ls in enumerate(ls_target):\n if ls & mx_bin > 0:\n cnt += 1\n new_idx.append(idx)\n if cnt >= k:\n ls_target = [ls_target[i] for i in new_idx]\n ans += mx_bin\n mx_bin = int(mx_bin/2)\nprint (ans)", "neg": "#coding:utf-8\nn,k = map(int,input().split())\nls_a = list(map(int,input().split()))\ntarget = int(k*(k+1)/2)\nls_target = []\ni = 1\nwhile(1):\n for j in range(i):\n temp = ls_a[j:(len(ls_a)-i+j+1)]\n ls_target.append(sum(temp))\n if i==n:\n break\n i+=1\n\ndef check(num):\n for i in range(100):\n if (num < 2**i):\n return i-1, 2**(i-1)\nmx = sum(ls_target[0])\ndigit, mx_bin = check(mx)\nans = 0\nfor d in range(digit+1):\n# print (mx_bin)\n# print (ls_target)\n new_idx = []\n cnt = 0\n for idx,ls in enumerate(ls_target):\n if ls & mx_bin > 0:\n cnt += 1\n new_idx.append(idx)\n if cnt >= k:\n ls_target = [ls_target[i] for i in new_idx]\n ans += mx_bin\n mx_bin = int(mx_bin/2)\nprint (ans)", "jacc_sim": 0.9672131147540983, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [321, 323], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u297109012", "n_user": "u297109012", "pos": "def solve(N, K, As):\n alls = []\n for i in range(N):\n for j in range(i + 1, N + 1):\n alls.append(\"{:041b}\".format(sum(As[i:j])))\n def find(i, alls):\n if i > 40:\n return []\n ones = [a for a in alls if a[i] == \"1\"]\n if len(ones) < K:\n return find(i + 1, alls)\n elif len(ones) == K:\n return ones\n elif len(ones) > K:\n ret = find(i + 1, ones)\n if len(ret) == 0:\n return ones[0:K]\n else:\n return ret\n\n ans = find(0, alls)\n if len(ans):\n a = 0xFFFFFFFFFFF\n for p in ans:\n a &= int(p, 2)\n return a\n else:\n return 0\n\nif __name__ == \"__main__\":\n l = input()\n N = int(l.split(\" \")[0])\n K = int(l.split(\" \")[1])\n As = [int(c) for c in input().split()]\n print(solve(N, K, As))\n", "neg": "\n\n\ndef solve(N, K, As):\n alls = []\n for i in range(N):\n for j in range(i + 1, N + 1):\n alls.append(\"{:061b}\".format(sum(As[i:j])))\n print(\"alls\", len(alls))\n def find(i, alls):\n if i > 60:\n return []\n ones = [a for a in alls if a[i] == \"1\"]\n if len(ones) < K:\n return find(i + 1, alls)\n elif len(ones) == K:\n return ones\n elif len(ones) > K:\n ret = find(i + 1, ones)\n if len(ret) == 0:\n return ones[0:K]\n else:\n return ret\n\n ans = find(0, alls)\n if len(ans):\n a = 0xFFFFFFFFFFF\n for p in ans:\n a &= int(p, 2)\n return a\n else:\n return 0\n\nif __name__ == \"__main__\":\n l = input()\n N = int(l.split(\" \")[0])\n K = int(l.split(\" \")[1])\n As = [int(c) for c in input().split()]\n print(solve(N, K, As))\n", "jacc_sim": 0.9298245614035088, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [322, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u996672406", "n_user": "u996672406", "pos": "import math\n\nn, kk = tuple(map(int, input().split()))\nsumnum = n * (n + 1) // 2\narr = tuple(map(int, input().split()))\nsums = [0 for i in range(sumnum)]\nhojo = [0 for i in range(n)]\npoint = 0\n\nfor i, e in enumerate(arr):\n for k in range(i):\n hojo[k] += e\n sums[point] = hojo[k]\n point += 1\n hojo[i] = e\n sums[point] = hojo[i]\n point += 1\n\nmaxlog = 0\nmaxe = max(sums)\nwhile maxe >= 2**maxlog:\n maxlog += 1\nmaxlog -= 1\n\nres = 0\n\nfor i in range(maxlog, -1, -1):\n ya = [0 for i in range(len(sums))]\n dab = 0\n gaga = 1 << i\n for e in sums:\n if e & gaga:\n ya[dab] = e\n dab += 1\n\n if dab >= kk:\n res += gaga\n sums = ya[:dab]\n\nprint(res)\n", "neg": "import math\n\nn, kk = tuple(map(int, input().split()))\nsumnum = n * (n + 1) // 2\narr = tuple(map(int, input().split()))\nsums = [0 for i in range(sumnum)]\nhojo = [0 for i in range(n)]\npoint = 0\nmaxe = 0\n\nfor i, e in enumerate(arr):\n for k in range(i):\n hojo[k] += e\n sums[point] = hojo[k]\n point += 1\n hojo[i] = e\n sums[point] = hojo[i]\n point += 1\n\n if maxe < e:\n maxe = e\n\nmaxlog = 0\nwhile maxe >= 1 << maxlog:\n maxlog += 1\n\nres = 0\n\nfor i in range(maxlog, -1, -1):\n ya = [0 for i in range(len(sums))]\n dab = 0\n gaga = 1 << i\n for e in sums:\n if e & gaga:\n ya[dab] = e\n dab += 1\n\n if dab >= kk:\n res += gaga\n sums = ya[:dab]\n\nprint(res)\n", "jacc_sim": 0.98, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [303, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u844789719", "n_user": "u844789719", "pos": "N, K = [int(_) for _ in input().split()]\nA = [int(_) for _ in input().split()]\nB = []\nfor i in range(N):\n B += [A[i]]\n for j in range(i+1,N):\n B += [B[-1] + A[j]]\n\nans = 0\nfor i in range(40, -1, -1):\n B_new = []\n for b in B:\n if b & 2 ** i:\n B_new += [b]\n if len(B_new) >= K:\n ans += 2 ** i\n B = [_ - 2 ** i for _ in B_new]\n else:\n B = [_ % 2 ** i for _ in B]\nprint(ans)", "neg": "N, K = [int(_) for _ in input().split()]\nA = [int(_) for _ in input().split()]\nB = []\nfor i in range(N):\n B += [A[i]]\n for j in range(i+1,N):\n B += [B[-1] + A[j]]\n\nans = 0\nfor i in range(40, -1, -1):\n B_new = []\n for b in B:\n if b & 1 << i:\n B_new += [b]\n if len(B_new) >= K:\n ans += 1 << i\n B = [_ % 1 << i for _ in B_new]\n else:\n B = [_ % 1 << i for _ in B]\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [190, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u242196904", "n_user": "u242196904", "pos": "import numpy as np\nN, K = list(map(int,input().split()))\na = list(map(int,input().split()))\n\na = np.array(a)\n\ns = 0\ne = 0\n\narr = []\naa = np.append(0,np.cumsum(a))\nfor s in range(len(aa)):\n for e in range(s+1, len(aa)):\n arr.append(aa[e] - aa[s])\n\nmax_len = len(bin(np.sum(a))[2:])\n\nsu = 0\nb = [bin(aa)[2:] for aa in arr]\nb = ['0' * (max_len - len(bb)) + bb for bb in b]\nwhile True:\n c = [bb for bb in b if bb[0] == '1']\n if len(c) >= K:\n su += 2 ** (len(c[0]) - 1)\n b = [cc[1:] for cc in c]\n else:\n b = [bb[1:] for bb in b]\n if len(b[0]) == 0:\n break\nprint(su)", "neg": "N, K = list(map(int,input().split()))\na = list(map(int,input().split()))\n\na = np.array(a)\n\ns = 0\ne = 0\n\narr = []\nfor s in range(N):\n for e in range(s+1, N+1):\n arr.append(a[s:e])\n\nmax_len = len(bin(np.sum(a))[2:])\n\nsu = 0\nb = [bin(np.sum(aa))[2:] for aa in arr]\nb = ['0' * (max_len - len(bb)) + bb for bb in b]\nwhile True:\n c = [bb for bb in b if bb[0] == '1']\n if len(c) >= K:\n su += 2 ** (len(c[0]) - 1)\n b = [cc[1:] for cc in c]\n else:\n b = [bb[1:] for bb in b]\n if len(b[0]) == 0:\n break\nprint(su)", "jacc_sim": 0.9245283018867925, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [280, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03215", "p_user": "u944209426", "n_user": "u944209426", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nx=[0,a[0]]\nfor i in range(1,n):\n x.append(x[-1]+a[i])\ny=[]\nfor i in range(n+1):\n for j in range(i+1,n+1):\n y.append(x[j]-x[i])\ny.sort()\ny=y[::-1]\nm=len(bin(y[0]))\ny=[\"0\"*(m-len(bin(y[i])))+bin(y[i])[2::] for i in range(len(y))]\nres=[\"0\" for _ in range(m-2)]\nfor x in range(m-2):\n t=0\n z=[]\n for i in range(len(y)):\n if y[i][x]==\"1\":\n t+=1\n z.append(y[i])\n if t>=k:\n res[x]=\"1\"\n y=z[::]\nprint(int(\"\".join(res),2))", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nx=[0,a[0]]\nfor i in range(1,n):\n x.append(x[-1]+a[i])\ny=[]\nfor i in range(n+1):\n for j in range(i+1,n+1):\n y.append(x[j]-x[i])\ny.sort()\ny=y[::-1]\nm=len(bin(y[0]))\ny=[\"0\"*(m-len(bin(y[i])))+bin(y[i])[2::] for i in range(len(y))]\nres=[\"0\" for _ in range(m-2)]\nfor x in range(m-2):\n t=0\n z=[]\n for i in range(len(y)):\n if y[i][x]==\"1\":\n t+=1\n z.append(y[i])\n if t>=k:\n res[x]=\"1\"\n y=z[::]\nprint(res)", "jacc_sim": 0.9767441860465116, "nl": "Niwango-kun, an employee of Dwango Co., Ltd., found an integer sequence (a_1, ..., a_N) of length N. He wants to find the maximum possible value of the bitwise AND of the beauties of K nonempty contiguous subsequences among all N(N+1)/2 nonempty contiguous subsequences. Constraints: 2 \u2264 N \u2264 1000, 1 \u2264 a_i \u2264 10^9, 1 \u2264 K \u2264 N(N+1)/2. Input format: N K, followed by the sequence a_1 to a_N. Output the answer. Example: Input: 4 2, 2 5 2 5. Output: 12.", "before_after_length": [279, 272], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u606045429", "n_user": "u606045429", "pos": "N = int(input())\nS = input()\nQ = int(input())\nK = [int(i) for i in input().split()]\n\nfor k in K:\n ans = 0\n\n d = m = dm = 0\n for i, si in enumerate(S):\n if 0 <= i - k:\n if S[i - k] == \"D\":\n d -= 1\n dm -= m\n elif S[i - k] == \"M\":\n m -= 1\n\n if si == \"D\":\n d += 1\n elif si == \"M\":\n m += 1\n dm += d\n elif si == \"C\":\n ans += dm\n\n print(ans)", "neg": "N = int(input())\nS = input()\nQ = int(input())\nK = [int(i) for i in input().split()]\n\nfor k in K:\n ans = 0\n\n d = m = dm = 0\n for i, si in enumerate(S):\n if 0 <= i - K:\n if S[i - K] == \"D\":\n d -= 1\n dm -= m\n elif S[i - K] == \"M\":\n m -= 1\n\n if si == \"D\":\n d += 1\n elif si == \"M\":\n m += 1\n dm += d\n elif si == \"C\":\n ans += dm\n\n print(ans)", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [169, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u119148115", "n_user": "u119148115", "pos": "import sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #\u7a7a\u767d\u3042\u308a\ndef LS2(): return list(sys.stdin.readline().rstrip()) #\u7a7a\u767d\u306a\u3057\n\n\nN = I()\nS = LS2()\nQ = I()\nK = LI()\n\n\ndef query(k):\n res = 0\n a = 0 # (i-k,i] \u306b\u3042\u308bD\u306e\u500b\u6570\n b = 0 # (i-k,i] \u306b\u3042\u308bM\u306e\u500b\u6570\n c = 0 # (i-k,i] \u306b\u3042\u308b(D,M)\u306e\u500b\u6570\n for i in range(N):\n if i >= k:\n if S[i-k] == 'D':\n a -= 1\n c -= b\n elif S[i-k] == 'M':\n b -= 1\n if S[i] == 'D':\n a += 1\n elif S[i] == 'M':\n b += 1\n c += a\n elif S[i] == 'C':\n res += c\n return res\n\n\nprint(*[query(k) for k in K],sep='\\n')\n", "neg": "import sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split())) #\u7a7a\u767d\u3042\u308a\ndef LS2(): return list(sys.stdin.readline().rstrip()) #\u7a7a\u767d\u306a\u3057\n\n\nN = I()\nS = LS2()\nQ = I()\nK = LI()\n\n\ndef query(k):\n res = 0\n a = 0 # (i-k,i] \u306b\u3042\u308bD\u306e\u500b\u6570\n b = 0 # (i-k,i] \u306b\u3042\u308bM\u306e\u500b\u6570\n c = 0 # (i-k,i] \u306b\u3042\u308b(D,M)\u306e\u500b\u6570\n for i in range(N):\n if i >= k:\n if S[i-k] == 'D':\n a -= 1\n c -= b\n elif S[i-k] == 'M':\n b -= 1\n if S[i] == 'D':\n a += 1\n elif S[i] == 'M':\n b += 1\n c += a\n elif S[i] == 'C':\n res += c\n\n\nprint(*[query(k) for k in K],sep='\\n')", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [366, 361], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u325227960", "n_user": "u325227960", "pos": "import sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n s = input()\n q = int(input())\n K = list(map(int,input().split()))\n # print(s)\n\n for i in range(q):\n ans = 0\n d = 0\n m = 0\n dm = 0\n k = K[i]\n for j in range(n):\n\n if j-k >= 0:\n if s[j-k] == \"D\":\n d -= 1\n dm -= m\n elif s[j-k] == \"M\":\n m -= 1\n\n if s[j] == \"D\":\n d += 1\n elif s[j] == \"M\":\n m += 1\n dm += d\n elif s[j] == \"C\":\n ans += dm\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "neg": "import sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n s = input()\n q = int(input())\n K = list(map(int,input().split()))\n d = 0\n m = 0\n dm = 0\n\n # print(s)\n\n for i in range(q):\n ans = 0\n k = K[i]\n for j in range(n):\n\n if j-k >= 0:\n if s[j-k] == \"D\":\n d -= 1\n dm -= m\n elif s[j-k] == \"M\":\n m -= 1\n\n if s[j] == \"D\":\n d += 1\n elif s[j] == \"M\":\n m += 1\n dm += d\n elif s[j] == \"C\":\n ans += dm\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [233, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u144913062", "n_user": "u144913062", "pos": "import sys\ninput = sys.stdin.readline\n\ndef main():\n N = int(input())\n S = input().rstrip()\n Q = int(input())\n k = list(map(int, input().split()))\n\n for l in k:\n D = 0\n M = 0\n tmp = 0\n ans = 0\n for i in range(N):\n if i >= l:\n if S[i-l] == 'D':\n tmp -= M\n D -= 1\n if S[i-l] == 'M':\n M -= 1\n if S[i] == 'D':\n D += 1\n if S[i] == 'M':\n M += 1\n tmp += D\n if S[i] == 'C':\n ans += tmp\n print(ans)\n\nmain()", "neg": "import sys\ninput = sys.stdin.readline\n\ndef main():\n N = int(input())\n S = [input().rstrip()]\n Q = int(input())\n k = list(map(int, input().split()))\n\n for l in k:\n D = 0\n M = 0\n tmp = 0\n ans = 0\n for i in range(N):\n if i >= l:\n if S[i-l] == 'D':\n tmp -= M\n D -= 1\n if S[i-l] == 'M':\n M -= 1\n if S[i] == 'D':\n D += 1\n if S[i] == 'M':\n M += 1\n tmp += D\n if S[i] == 'C':\n ans += tmp\n print(ans)\n\nmain()", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [204, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u223904637", "n_user": "u223904637", "pos": "import sys\ninput=sys.stdin.readline\nn=int(input())\nl=input()\nq=int(input())\nkl=tuple(map(int,input().split()))\nfor k in kl:\n d=0\n m=0\n dm=0\n ans=0\n for j in range(n):\n if l[j]=='D':\n d+=1\n elif l[j]=='M':\n m+=1\n dm+=d\n elif l[j]=='C':\n ans+=dm\n if j>=k-1:\n if l[j-k+1]=='D':\n dm-=m\n d-=1\n elif l[j-k+1]=='M':\n m-=1\n print(ans)\n", "neg": "import sys\ninput=sys.stdin.readline\nn=int(input())\nl=tuple(input())\nq=int(input())\nkl=tuple(map(int,input().split()))\nfor i in range(q):\n k=kl[i]\n d=0\n m=0\n dm=0\n ans=0\n for j in range(n):\n if l[j]=='D':\n d+=1\n if l[j]=='M':\n m+=1\n dm+=d\n if l[j]=='C':\n ans+=dm\n if j>=k:\n if l[j-k]=='D':\n dm-=m\n d-=1\n if l[j-k]=='M':\n m-=1\n print(ans)\n", "jacc_sim": 0.9534883720930233, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [196, 202], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u729133443", "n_user": "u729133443", "pos": "e=enumerate\nn,s,q,*k=open(0).read().split()\nn=int(n)\nm,c,x=eval('[0]*-~n,'*3)\nfor i,t in e(s,1):\n m[i]=m[i-1]+(t=='M')\n f=t=='C'\n c[i]=c[i-1]+f\n x[i]=x[i-1]+f*m[i]\nfor k in map(int,k):\n a=0\n for i,t in e(s):\n j=min(n,i+k)\n if t=='D':\n a+=x[j]-x[i]-(c[j]-c[i])*m[i]\n print(a)", "neg": "e=enumerate\nn,s,q,*k=open(0).read().split()\nm,c,x=eval('[0]*-~int(n),'*3)\nfor i,t in e(s,1):\n m[i]=m[i-1]+(t=='M')\n f=t=='C'\n c[i]=c[i-1]+f\n x[i]=x[i-1]+f*m[i]\nfor k in map(int,k):\n a=0\n for i,t in e(s):\n j=min(n,i+k)\n if t=='D':a+=x[j]-x[i]-(c[j]-c[i])*m[i]\n print(a)", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [200, 194], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u803848678", "n_user": "u803848678", "pos": "n = int(input())\ns = input()\nq = int(input())\nk = list(map(int, input().split()))\nfor ki in k:\n ans = 0\n DMC = [0]*3\n #for i, c in enumerate(s):\n for i in range(n):\n if s[i] == \"D\":\n DMC[0] += 1\n elif s[i] == \"M\":\n DMC[1] += 1\n DMC[2] += DMC[0]\n if i >= ki:\n j = i-ki\n if s[j] == \"D\":\n DMC[0] -= 1\n DMC[2] -= DMC[1]\n elif s[j] == \"M\":\n DMC[1] -= 1\n if s[i] == \"C\":\n ans += DMC[2]\n print(ans)", "neg": "n = int(input())\ns = input()\nq = int(input())\nk = list(map(int, input().split()))\nfor ki in k:\n ans = 0\n DMC = [0]*3\n for i in range(n):\n if s[i] == \"D\":\n DMC[0] += 1\n elif s[i] == \"M\":\n DMC[1] += 1\n DMC[2] += DMC[0]\n if i >= ki:\n j = i-ki\n if s[j] == \"D\":\n DMC[0] -= 1\n DMC[2] -= DMC[1]\n elif s[j] == \"M\":\n DMC[1] -= 1\n if c == \"C\":\n ans += DMC[2]\n print(ans)", "jacc_sim": 0.9534883720930233, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [219, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u062147869", "n_user": "u062147869", "pos": "N=int(input())\nS=input()\nQ=int(input())\nK=[int(i) for i in input().split()]\ndef f(k):\n num=0\n L=[0,0,0]\n for i in range(N):\n if i-k>=0:\n if S[i-k]=='D':\n L[0]-=1\n L[2]-=L[1]\n elif S[i-k]=='M':\n L[1]-=1\n if S[i]=='D':\n L[0]+=1\n elif S[i]=='M':\n L[1]+=1\n L[2]+=L[0]\n elif S[i]=='C':\n num+=L[2]\n #print(i,':',L,':',num)\n return num\nfor k in K:\n print(f(k))", "neg": "N=int(input())\nS=input()\nQ=int(input())\nK=[int(i) for i in input().split()\ndef f(k):\n num=0\n L=[0,0,0]\n for i in range(N):\n if i-k>=0:\n if S[i-k]=='D':\n L[0]-=1\n L[2]-=L[1]\n elif S[i-k]=='M':\n L[1]-=1\n if S[i]=='D':\n L[0]+=1\n elif S[i]=='M':\n L[1]+=1\n L[2]+=L[0]\n elif S[i]=='C':\n num+=L[2]\n #print(i,':',L,':',num)\n return num\nfor k in K:\n print(f(k))", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [226, 225], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03216", "p_user": "u340781749", "n_user": "u340781749", "pos": "n = int(input())\ns = input()\nacc_cnt_a = [0] * (n + 1)\nacc_cnt_b = [0] * (n + 1)\nacc_cnt_ab = [0] * (n + 1)\nc_loc = []\ncnt_a = 0\ncnt_b = 0\ncnt_ab = 0\nfor i, c in enumerate(s):\n if c == 'D':\n cnt_a += 1\n elif c == 'M':\n cnt_b += 1\n cnt_ab += cnt_a\n elif c == 'C':\n c_loc.append(i + 1)\n acc_cnt_a[i + 1] = cnt_a\n acc_cnt_b[i + 1] = cnt_b\n acc_cnt_ab[i + 1] = cnt_ab\n\nq = int(input())\nbuf = []\nfor k in map(int, input().split()):\n ans = 0\n for r in c_loc:\n l = r - k\n if l > 0:\n rejected_a = acc_cnt_a[l]\n cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]\n cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]\n ans += cnt_internal_ab - rejected_a * cnt_internal_b\n else:\n ans += acc_cnt_ab[r]\n buf.append(ans)\nprint('\\n'.join(map(str, buf)))\n", "neg": "n = int(input())\ns = input()\nacc_cnt_a = [0] * n\nacc_cnt_b = [0] * n\nacc_cnt_ab = [0] * n\nc_loc = []\ncnt_a = 0\ncnt_b = 0\ncnt_ab = 0\nfor i, c in enumerate(s):\n if c == 'D':\n cnt_a += 1\n elif c == 'M':\n cnt_b += 1\n cnt_ab += cnt_a\n elif c == 'C':\n c_loc.append(i)\n acc_cnt_a[i] = cnt_a\n acc_cnt_b[i] = cnt_b\n acc_cnt_ab[i] = cnt_ab\n\nq = int(input())\nbuf = []\nfor k in map(int, input().split()):\n ans = 0\n for r in c_loc:\n l = r - k\n if l > 0:\n rejected_a = acc_cnt_a[l]\n cnt_internal_b = acc_cnt_b[r] - acc_cnt_b[l]\n cnt_internal_ab = acc_cnt_ab[r] - acc_cnt_ab[l]\n ans += cnt_internal_ab - rejected_a * cnt_internal_b\n else:\n ans += acc_cnt_ab[r]\n buf.append(ans)\nprint('\\n'.join(map(str, buf)))\n", "jacc_sim": 1.0, "nl": "In Dwango Co., Ltd., there is a content distribution system named 'Dwango Media Cluster', and it is called 'DMC' for short. The name 'DMC' sounds cool for Niwango-kun, so he starts to define DMC-ness of a string.\n\nGiven a string S of length N and an integer k (k \u2265 3), he defines the k-DMC number of S as the number of triples (a, b, c) of integers that satisfy certain conditions.\n\nFor a string S and Q integers k_0, k_1, ..., k_{Q-1}, calculate the k_i-DMC number of S for each i (0 \u2264 i \u2264 Q-1).\n\nConstraints:\n- 3 \u2264 N \u2264 10^6\n- S consists of uppercase English letters\n- 1 \u2264 Q \u2264 75\n- 3 \u2264 k_i \u2264 N\n- All numbers given in input are integers\n\nInput:\nN\nS\nQ\nk_{0} k_{1} ... k_{Q-1}\n\nOutput:\nPrint Q lines. The i-th line should contain the k_i-DMC number of the string S.\n\nSample Input/Output examples are provided.", "before_after_length": [375, 355], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u193264896", "n_user": "u193264896", "pos": "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n S = input()\n if len(S)==2:\n print(S)\n else:\n print(''.join(list(reversed(S))))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n S = input()\n print(''.join(list(reversed(S))))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.918918918918919, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [113, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u013202780", "n_user": "u227082700", "pos": "s=input();print(s[::-1] if len(s)>2 else s)", "neg": "s=input()\nif len(s)==2;print(s)\nelse:print(s[::-1])", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [22, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u482157295", "n_user": "u136948974", "pos": "n = input()\nn_len = len(n)\nif n_len == 2:\n print(n)\nelse:\n print(n[::-1])", "neg": "n = input()\nprint n if len(n)==2 else n[::-1]", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [40, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u652057333", "n_user": "u614181788", "pos": "s = input().rstrip()\ns_len = len(s)\nif s_len == 2:\n print(s)\nelse:\n print(\"\".join(list(s[::-1])))", "neg": "s = list(input())\nif len(s) == 2:\n print(s)\nelse:\n print(\"\".join(s[::-1]))", "jacc_sim": 0.9047619047619048, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [49, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u310466455", "n_user": "u310466455", "pos": "a = input()\nif len(a) == 2:\n print(a)\nelse:\n new_str = ''.join(list(reversed(a)))\n print(new_str)", "neg": "a = input()\nif len(a) == 2:\n print(a)\nelse:\n new_str = ''.join(list(reversed(a)))", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [47, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u211160392", "n_user": "u121698457", "pos": "S = input()\nif len(S) == 3:\n S = S[2]+S[1]+S[0]\nprint(S)", "neg": "if len(S) == 2:\n print(S)\nif len(S) == 3:\n print(S[2]+S[1]+S[0])", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [34, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u223904637", "n_user": "u223904637", "pos": "s=list(input())\nans=''\nif len(s)==2:\n print(''.join(s))\nelse:\n tmp=s[0]\n s[0]=s[2]\n s[2]=tmp\n print(''.join(s))", "neg": "s=list(input())\nans=''\nif len(s)==2:\n print(','.join(s))\nelse:\n tmp=s[0]\n s[0]=s[2]\n s[2]=tmp\n print(','.join(s))", "jacc_sim": 0.9523809523809523, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [67, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u778814286", "n_user": "u778814286", "pos": "###template###\n#import sys\n#input = sys.stdin.readline\n#def mi(): return map(int, input().split())\n###template###\n\ns = input()\n\nif len(s)==2: print(s)\nelse: print(s[::-1])\n\n", "neg": "###template###\nimport sys\ninput = sys.stdin.readline\ndef mi(): return map(int, input().split())\n###template###\n\ns = input()\n\nif len(s)==2: print(s)\nelse: print(s[::-1])\n\n", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [68, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u542932305", "n_user": "u391731808", "pos": "S = input().rstrip()\nif len(S) == 2:\n print(S)\nelse:\n print(S[::-1])", "neg": "S=input()\nif S.len()==2:print(S)\nelse:print(S[::-1])", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [35, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u333404917", "n_user": "u333404917", "pos": "s = list(input())\nif len(s) == 3:\n print(\"\".join(s[::-1]))\nelse:\n print(\"\".join(s))", "neg": "s = list(input())\nif len(s) == 3:\n print(s[::-1].join())\nelse:\n print(s.join())", "jacc_sim": 0.9473684210526315, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [40, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u166306121", "n_user": "u166306121", "pos": "import sys\ninput = sys.stdin.readline\ndef ii(): return int(input())\ndef mi(): return map(int, input().rstrip().split())\ndef lmi(): return list(map(int, input().rstrip().split()))\ndef li(): return list(input().rstrip())\n# template\n\n\nS = li()\nif len(S) == 2:\n print(''.join(S))\nelse:\n S.reverse()\n print(''.join(S))", "neg": "import sys\ninput = sys.stdin.readline\ndef ii(): return int(input())\ndef mi(): return map(int, input().rstrip().split())\ndef lmi(): return list(map(int, input().rstrip().split()))\ndef li(): return list(input().rstrip())\n# template\n\n\nS = input()\nif len(S) == 2:\n print(S)\nelse:\n list(S).reverse()\n print(''.join(S))\n", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [114, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u678980622", "n_user": "u678980622", "pos": "import sys\n\ns = sys.stdin.read().rstrip()\nif len(s) % 2 == 1:\n s = s[::-1]\nprint(s)\n", "neg": "import sys\n\ns = sys.stdin.read().lstrip()\nif len(s) % 2 == 1:\n s = s[::-1]\nprint(s)\n", "jacc_sim": 0.9047619047619048, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [42, 42], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u177907787", "n_user": "u177907787", "pos": "s = input()\nn = len(s)\nif (n == 3):\n\tfor i in range(n):\n\t\tprint(s[n-i-1],end = \"\")\n\tprint()\nelse:\n\tprint(s)", "neg": "s = input()\nn = len(s)\nif (n == 3):\n\tfor i in range(n):\n\t\tprint(s[n-i-1],end = \"\")\n\t\tprint()\nprint(s)", "jacc_sim": 0.9565217391304348, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [57, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u611495846", "n_user": "u611495846", "pos": "S = input()\n\nlisted_S = list(S)\nif len(listed_S)==2:\n print(S)\nelif len(listed_S)==3:\n print(S[::-1])", "neg": "S = input()\n\nlisted_S = list[S]\nif len(listed_S)==2:\n print(S)\nelif len(listed_S)==3:\n print(S[::-1])", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [53, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u977642052", "n_user": "u977642052", "pos": "s = input()\n\nif s.__len__() == 3:\n print(s[::-1])\nelse:\n print(s)\n", "neg": "s = input()\n\nif ( s.__len__() == 3):\n print(s[::-1])", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [35, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u799629232", "n_user": "u799629232", "pos": "N=input()\nif len(N)==3:\n N = N[::-1]\n print(N)\nelif len(N)==2:\n print(N)", "neg": "N=(input())\nif len(N)==3:\n... N = N[::-1]\n... print(N)\n... elif len(N)==2:\n... print(N)", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [45, 48], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u927764913", "n_user": "u927764913", "pos": "a=input()\nif len(a) == 3:\n print(a[::-1])\nelse:\n print(str(a))", "neg": "a=list(input())\nif len(a) == 3:\n print(str(a[::-1]))\nelse:\n print(str(a))\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [34, 39], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u390694622", "n_user": "u137913818", "pos": "S=input()\nif len(S) == 2:\n print(S)\nelse:\n T=S[2]+S[1]+S[0]\n print(T)", "neg": "S = input()\nT = ''\nif len(S) == 2:\n T = S[1] + S[0]\nelse:\n T = S[2] + S[1] + S[0]\nprint(T)", "jacc_sim": 0.9444444444444444, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [44, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u558782626", "n_user": "u729133443", "pos": "s = input()\nprint(s[::(-1)**(len(s))])", "neg": "s=input();print(s[::-1**len(s)])", "jacc_sim": 0.9285714285714286, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [20, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u440904221", "n_user": "u630004940", "pos": "str = input()\nif len(str) == 2:\n print(str)\nelse :\n print(str[::-1])", "neg": "str=input()\nx=len(str)\nif x=2:\n print(str)\nelse:\n print(str[::-1])", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [32, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u464555934", "n_user": "u464555934", "pos": "S = input()\n\nif len(S) == 2:\n print(S)\nelif len(S) == 3:\n #str_list = list(reversed(S))\n new_str = ''.join(list(reversed(S)))\n print(new_str)", "neg": "S = input()\n\nif len(S) == 2:\n print(S)\nelif len(S) == 3:\n str_list = list(reversed(S))\n new_str = ''.join(list(reversed(org_str)))\n print(new_str)", "jacc_sim": 0.9047619047619048, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [69, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u807772568", "n_user": "u807772568", "pos": "a = list(input())\n\nif len(a) == 2:\n a = \"\".join(a)\n print(a)\nelse:\n a.reverse()\n a = \"\".join(a)\n print(a)", "neg": "a = list(input())\n\nif len(a) == 2:\n print(a)\nelse:\n a.reverse()\n a = \"\".join(a)\n print(a)", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [57, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u475776984", "n_user": "u475776984", "pos": "#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=0\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W:/Competitive Programming/output.txt', 'w')\n sys.stdin = inputfile\n sys.stdout = outputfile\n\n###Defines...###\nmod=1000000007\n \n###FUF's...###\ndef nospace(l):\n ans=''.join(str(i) for i in l)\n return ans\n \n \n \n##### Main ####\ns=str(input())\nif(len(s)==2):\n print(s)\nelse:\n print(s[::-1])\n \n \n#####File Operations#####\nif(fileoperation):\n sys.stdout = orig_stdout\n sys.stdin = orig_stdin\n inputfile.close()\n outputfile.close()", "neg": "#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=1\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W:/Competitive Programming/output.txt', 'w')\n sys.stdin = inputfile\n sys.stdout = outputfile\n\n###Defines...###\nmod=1000000007\n \n###FUF's...###\ndef nospace(l):\n ans=''.join(str(i) for i in l)\n return ans\n \n \n \n##### Main ####\ns=str(input())\nif(len(s)==2):\n print(s)\nelse:\n print(s[::-1])\n \n \n#####File Operations#####\nif(fileoperation):\n sys.stdout = orig_stdout\n sys.stdin = orig_stdin\n inputfile.close()\n outputfile.close()", "jacc_sim": 0.9841269841269841, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [274, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u185688520", "n_user": "u306142032", "pos": "s = input()\nlength = len(s)\nif length == 2:\n print(s)\nelse:\n print(s[::-1])\n", "neg": "s = input()\nif len(s) == 2:\n print s\nelse :\n print s[::-1]", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [37, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u553348533", "n_user": "u278864208", "pos": "S = input()\n\nif len(S) > 2:\n print(S[::-1])\nelse:\n print(S)\n", "neg": "S = input()\nif len(S) ==2:\n print(S)\nelse:\n\u3000print(S[::-1])\n", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [34, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u505420467", "n_user": "u845937249", "pos": "s=input()\nif len(s)==2:\n print(s)\nelse:\n s=list(s)\n s.reverse()\n print(''.join(s))\n", "neg": "s = input()\n\nif len(s)==2:\n\tprint(s)\nelse:\n\ts = list(s)\n\ts.reverse\n\tprint(\"\".join(s))", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [46, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u398846051", "n_user": "u598530761", "pos": "S = input()\nif len(S) == 2:\n print(S)\nelse:\n print(S[-1::-1])", "neg": "S = input()[::-1]\nif len(S) == 2:\n print(S)\nprint(S[::-1])", "jacc_sim": 0.9333333333333333, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [33, 33], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u983918956", "n_user": "u049621131", "pos": "S = input()\nif len(S) == 2:\n print(S)\nelif len(S) == 3:\n print(S[::-1])", "neg": "if len(S)==2:\n print(S)\nelif len(S)==3:\n print(S[::-1])", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [39, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u046187684", "n_user": "u676496404", "pos": "n = input()\nif len(n) == 2:\n print(n)\nelse:\n print(n[::-1])\n", "neg": "n = input()\n\nif len(n) == 2:\n print(n)\nelse if len(n) == 3:\n print(n[::-1])", "jacc_sim": 0.9375, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [33, 40], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u119956734", "n_user": "u623687794", "pos": "l = input()\nif len(l) == 2:\n print(l)\nelse:\n print(l[::-1])\n", "neg": "print(input() if len(input())==2 else input()[::-1])", "jacc_sim": 0.9333333333333333, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [33, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u330712095", "n_user": "u849756457", "pos": "s = input()\nif(len(s) == 2):\n print(s)\nelse:\n print(s[2] + s[1] + s[0])\n", "neg": "s = input()\nif len(S) == 2:\n print(s)\nelse:\n print(s[2]+s[1]+s[0])", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [42, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u453068434", "n_user": "u240793404", "pos": "s=input()\nif(len(s)==2):\n print(s)\nelse:\n print(s[::-1])", "neg": "s = input()\nif len(s) == 2:\n s = s[::-1]\nprint(s)", "jacc_sim": 0.9333333333333333, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [33, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03227", "p_user": "u215115622", "n_user": "u892292299", "pos": "a = input()\nif len(a) == 2:\n\tprint(a)\nelse:\n\tprint(a[::-1])", "neg": " a=input()\n if len(a)==2:\n print(a)\n else:\n print(a[::-1])", "jacc_sim": 1.0, "nl": "You are given a string S of length 2 or 3 consisting of lowercase English letters. If the length of the string is 2, print it as is; if the length is 3, print the string after reversing it.\n\nConstraints:\n- The length of S is 2 or 3.\n- S consists of lowercase English letters.\n\nInput:\nInput is given from Standard Input in the following format:\nS\n\nOutput:\nIf the length of S is 2, print S as is; if the length is 3, print S after reversing it.\n\nSample Input 1:\nabc\n\nSample Output 1:\ncba\nAs the length of S is 3, we print it after reversing it.\n\nSample Input 2:\nac\n\nSample Output 2:\nac\nAs the length of S is 2, we print it as is.", "before_after_length": [32, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03613", "p_user": "u408375121", "n_user": "u408375121", "pos": "n = int(input())\na = list(map(int, input().split()))\nd = [0] * (10**5 + 2)\nneg_count = 0\nfor i in range(len(a)):\n d[a[i] - 1] += 1\n d[a[i]] += 1\n d[a[i] + 1] += 1\nans = max(d)\nprint(ans)", "neg": "n = int(input())\na = list(map(int, input().split()))\nd = [0] * (10**5 + 2)\nneg_count = 0\nfor i in range(len(a)):\n d[a[i] - 1] += 1\n d[a[i]] += 1\n d[a[i] + 1] += 1\nans = max(d)", "jacc_sim": 0.9696969696969697, "nl": "You are given an integer sequence of length N, a_1, a_2, ..., a_N. For each 1\u2264i\u2264N, you have three choices: add 1 to a_i, subtract 1 from a_i, or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.\n\nConstraints:\n- 1\u2264N\u226410^5\n- 0\u2264a_i<10^5 (1\u2264i\u2264N)\n- a_i is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 .. a_N\n\nOutput:\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1:\n7\n3 1 4 1 5 9 2\n\nSample Output 1:\n4\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2:\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2:\n3\n\nSample Input 3:\n1\n99999\n\nSample Output 3:\n1", "before_after_length": [99, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03613", "p_user": "u977193988", "n_user": "u977193988", "pos": "n=int(input())\nA=sorted(list(map(int,input().split())))\nL={}\nif n==1:\n print(1)\nelif n==2:\n if abs(A[0]-A[1])==1:\n print(2)\n else:\n print(1)\nelse:\n for i in A:\n if i not in L:\n L[i]=1\n else:\n L[i]+=1\n ans=[]\n for j in range(A[0],A[-1]+1):\n if (j in L) and (j-1 in L) and (j+1 in L):\n ans.append(L[j]+L[j+1]+L[j-1])\n elif (j in L) and (j-1 in L):\n ans.append(L[j-1]+L[j])\n elif (j in L) and (j+1 in L):\n ans.append(L[j+1]+L[j])\n elif (j-1 in L) and (j+1 in L):\n ans.append(L[j+1]+L[j-1])\n elif (j in L):\n ans.append(L[j])\n print(max(ans))", "neg": "n=int(input())\nA=sorted(list(map(int,input().split())))\nL={}\nif n==1:\n print(1)\nelif n==2:\n if abs(A[0]-A[1])==1:\n print(2)\n else:\n print(1)\nelse:\n for i in A:\n if i not in L:\n L[i]=1\n else:\n L[i]+=1\n print(L)\n ans=[]\n for j in range(A[0],A[-1]+1):\n if (j in L) and (j-1 in L) and (j+1 in L):\n ans.append(L[j]+L[j+1]+L[j-1])\n elif (j in L) and (j-1 in L):\n ans.append(L[j-1]+L[j])\n elif (j in L) and (j+1 in L):\n ans.append(L[j+1]+L[j])\n elif (j-1 in L) and (j+1 in L):\n ans.append(L[j+1]+L[j-1])\n elif (j in L):\n ans.append(L[j])\nprint(max(ans))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N, a_1, a_2, ..., a_N. For each 1\u2264i\u2264N, you have three choices: add 1 to a_i, subtract 1 from a_i, or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.\n\nConstraints:\n- 1\u2264N\u226410^5\n- 0\u2264a_i<10^5 (1\u2264i\u2264N)\n- a_i is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 .. a_N\n\nOutput:\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1:\n7\n3 1 4 1 5 9 2\n\nSample Output 1:\n4\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2:\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2:\n3\n\nSample Input 3:\n1\n99999\n\nSample Output 3:\n1", "before_after_length": [309, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03613", "p_user": "u707870100", "n_user": "u707870100", "pos": "# -*- coding: utf-8 -*-\n#ARC082C\nimport copy\nimport sys\nimport math\n\nn = int(input())\ntmp = input().split()\nhoge = list(map(lambda a: int(a), tmp))\n\nhoge.sort()\nhoge.append(-1)\na=0\nb=0\nc=1\nmaxhoge=0\nfor i in range(0,n):\n\tif(hoge[i]!=hoge[i+1]):\n\t\tif(i!=n-1):\n\t\t\tif(hoge[i+1]-hoge[i]==1):\n\t\t\t\ta=b\n\t\t\t\tb=c\n\t\t\t\tc=1\n\t\t\telif(hoge[i+1]-hoge[i]==2):\n\t\t\t\ta=c\n\t\t\t\tb=0\n\t\t\t\tc=1\n\t\t\telse:\n\t\t\t\ta=0\n\t\t\t\tb=0\n\t\t\t\tc=1\n\telse:\n\t\tc+=1\n#\tprint(\"i:{} | {} {} {}\".format(i,a,b,c))\n\n\tmaxhoge=max(maxhoge,a+b+c)\n\n\n\n#print(hoge)\nprint(maxhoge)\n\n", "neg": "# -*- coding: utf-8 -*-\n#ARC082C\nimport copy\nimport sys\nimport math\n\nn = int(input())\ntmp = input().split()\nhoge = list(map(lambda a: int(a), tmp))\n\nhoge.sort()\nhoge.append(-1)\na=0\nb=0\nc=1\nmaxhoge=0\nfor i in range(0,n):\n\tif(hoge[i]!=hoge[i+1]):\n\t\tmaxhoge=max(maxhoge,a+b+c)\n\t\ta=b\n\t\tb=c\n\t\tc=1\n\telse:\n\t\tc+=1\n\tif(i==n-1):\n\t\tmaxhoge=max(maxhoge,a+b+c)\n#\tprint(\"{} {} {}\".format(a,b,c))\n\n\n#print(hoge)\nprint(maxhoge)\n\n", "jacc_sim": 0.9433962264150944, "nl": "You are given an integer sequence of length N, a_1, a_2, ..., a_N. For each 1\u2264i\u2264N, you have three choices: add 1 to a_i, subtract 1 from a_i, or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.\n\nConstraints:\n- 1\u2264N\u226410^5\n- 0\u2264a_i<10^5 (1\u2264i\u2264N)\n- a_i is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 .. a_N\n\nOutput:\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1:\n7\n3 1 4 1 5 9 2\n\nSample Output 1:\n4\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2:\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2:\n3\n\nSample Input 3:\n1\n99999\n\nSample Output 3:\n1", "before_after_length": [320, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03613", "p_user": "u306773664", "n_user": "u306773664", "pos": "import sys\nN = int(sys.stdin.readline())\ndata = [0] * 100000\nfor i in map(int,sys.stdin.readline().split()):\n\tdata[i] += 1\nprint(max(map(sum,zip(data,data[1:],data[2:]))))\n", "neg": "import sys\nN = int(sys.stdin.readline())\ndata = [0] * 10000\nfor i in map(int,sys.stdin.readline().split()):\n\tdata[i] += 1\nprint(max(map(sum,zip(data,data[1:],data[2:]))))\n", "jacc_sim": 0.9354838709677419, "nl": "You are given an integer sequence of length N, a_1, a_2, ..., a_N. For each 1\u2264i\u2264N, you have three choices: add 1 to a_i, subtract 1 from a_i, or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.\n\nConstraints:\n- 1\u2264N\u226410^5\n- 0\u2264a_i<10^5 (1\u2264i\u2264N)\n- a_i is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 .. a_N\n\nOutput:\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1:\n7\n3 1 4 1 5 9 2\n\nSample Output 1:\n4\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2:\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2:\n3\n\nSample Input 3:\n1\n99999\n\nSample Output 3:\n1", "before_after_length": [73, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03613", "p_user": "u846372029", "n_user": "u846372029", "pos": "#Together\n\nN = int(input())\na = list(map(int, input().split()))\n\nb = []\n\nfor ai in a:\n b.append(ai-1)\n b.append(ai)\n b.append(ai+1)\n#print(b)\n\nimport collections\ncnt = collections.Counter(b)\n#print(cnt)\nprint(max(cnt.values()))", "neg": "#Together\n\nN = int(input())\na = list(map(int, input().split()))\n\nb = []\n\nfor ai in a:\n b.append(ai-1)\n b.append(ai)\n b.append(ai+1)\n#print(b)\n\nimport collections\ncnt = collections.Counter(b)\n#print(cnt)\nmax(cnt.values())", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length N, a_1, a_2, ..., a_N. For each 1\u2264i\u2264N, you have three choices: add 1 to a_i, subtract 1 from a_i, or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices.\n\nConstraints:\n- 1\u2264N\u226410^5\n- 0\u2264a_i<10^5 (1\u2264i\u2264N)\n- a_i is an integer.\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 .. a_N\n\nOutput:\nPrint the maximum possible number of i such that a_i=X.\n\nSample Input 1:\n7\n3 1 4 1 5 9 2\n\nSample Output 1:\n4\nFor example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.\n\nSample Input 2:\n10\n0 1 2 3 4 5 6 7 8 9\n\nSample Output 2:\n3\n\nSample Input 3:\n1\n99999\n\nSample Output 3:\n1", "before_after_length": [101, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03615", "p_user": "u104282757", "n_user": "u104282757", "pos": "# E\nfrom collections import Counter\n\nN = int(input())\nxy_list = [list(map(int, input().split())) for _ in range(N)]\n\nM = 998244353\n\nres = pow(2, N, M)\n# 0 points\nres -= 1\n# 1 points\nres -= N\n\n# all lines\nline_cnt = [0]*(N+1)\n\nfor i in range(N):\n xi, yi = xy_list[i]\n angle_list = []\n for j in range(N):\n xj, yj = xy_list[j]\n if xj != xi:\n angle_list.append((yj-yi)/(xj-xi))\n elif yj != yi:\n angle_list.append(10000.0)\n \n # count points in same line\n cnt_i = Counter(angle_list)\n for k in cnt_i.values():\n line_cnt[k+1] += 1\n\nfor i in range(2, N+1):\n cnt = line_cnt[i] // i\n res -= cnt*(pow(2, i, M)-i-1)\n\nres = res % M\nprint(res)", "neg": "# E\nfrom collections import Counter\n\nN = int(input())\nxy_list = [list(map(int, input().split())) for _ in range(N)]\n\nM = 998244353\n\nres = pow(2, N, M)\n# 0 points\nres -= 1\n# 1 points\nres -= N\n\n# all lines\nline_cnt = [0]*(N+1)\n\nfor i in range(N):\n xi, yi = xy_list[i]\n angle_list = []\n for j in range(N):\n xj, yj = xy_list[j]\n if xj != xi:\n angle_list.append((yj-yi)/(xj-xi))\n elif yj != xj:\n angle_list.append(10000.0)\n \n # count points in same line\n cnt_i = Counter(angle_list)\n for k in cnt_i.values():\n line_cnt[k+1] += 1\n\nfor i in range(2, N+1):\n cnt = line_cnt[i] // i\n res -= cnt*(pow(2, i, M)-i-1)\n\nres = res % M\nprint(res)", "jacc_sim": 1.0, "nl": "You are given N points (x_i, y_i) on a two-dimensional plane. Find the sum of scores for all possible sets S that form convex polygons. The score of a set S is defined as 2^(n-|S|), where n is the number of points inside the convex hull of S. Print the sum modulo 998244353. Constraints: 1\u2264N\u2264200, 0\u2264x_i,y_i<10^4 (1\u2264i\u2264N), x_i and y_i are integers. Input format: N, followed by N lines of x and y coordinates. Output: Print the sum of scores modulo 998244353. Example: Input: 4, 0 0, 0 1, 1 0, 1 1. Output: 5.", "before_after_length": [294, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u285891772", "n_user": "u285891772", "pos": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nA = input()\nN = len(A)\n\nans = N*(N-1)//2\n\nfor v in Counter(A).values():\n\tans -= v*(v-1)//2\n\nprint(ans+1)", "neg": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nA = input()\nN = len(A)\n\nans = N*(N-1)//2\n\nfor v in Counter(A).values():\n\tans -= v*(v+1)//2\n\nprint(ans+1)", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [261, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u588794534", "n_user": "u588794534", "pos": "a=list(input())\n\nunko=[0]*(ord(\"z\")+1-ord(\"a\"))\n\nfor aa in a:\n unko[ord(aa)-ord(\"a\")]+=1\ntmp=0\nfor u in unko:\n tmp+=(u*(u-1))//2\n\nprint((len(a)*(len(a)-1))//2-tmp+1)", "neg": "a=list(input())\n\nunko=[0]*(ord(\"z\")+1-ord(\"a\"))\n\nfor aa in a:\n unko[ord(aa)-ord(\"a\")]+=1\ntmp=0\nfor u in unko:\n tmp+=(u*(u-1))//2\n\nprint((n*(n-1))//2-tmp)", "jacc_sim": 0.9285714285714286, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [95, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u810356688", "n_user": "u810356688", "pos": "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import Counter\ndef main():\n A=input()\n ac=list(Counter(A).values())\n len_a=len(A)\n ans=len_a*(len_a-1)//2\n for acc in ac:\n ans-=acc*(acc-1)//2\n print(ans+1)\n\nif __name__=='__main__':\n main()", "neg": "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom collections import Counter\ndef main():\n A=input()\n ac=list(Counter().values())\n len_a=len(A)\n ans=len_a*(len_a-1)//2\n for acc in ac:\n ans-=acc*(acc-1)//2\n print(ans)\n\nif __name__=='__main__':\n main()", "jacc_sim": 0.9736842105263158, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [113, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u948911484", "n_user": "u948911484", "pos": "s = input()\ncnt = [0]*26\nn = len(s)\nfor i in range(n):\n cnt[ord(s[i])-97] += 1\nans = n*(n-1)//2\nfor i in range(26):\n ans -= (cnt[i]*(cnt[i]-1)//2)\nprint(ans+1)", "neg": "s = input()\ncnt = [0]*26\nn = len(s)\nfor i in range(n):\n cnt[ord(s[i])-97] += 1\nans = n*(n+1)//2\nfor i in range(26):\n ans -= (cnt[i]*(cnt[i]+1)//2)*(cnt[i]>1)\nprint(ans+1)", "jacc_sim": 0.9642857142857143, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [87, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u346308892", "n_user": "u346308892", "pos": "\nimport numpy as np\n\ndic={}\nascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'\n\nA = input()\nfor a in ascii_lowercase:\n dic[a]=[0]*len(A)\n\ni=0\nfor l in A:\n dic[l][i]=1\n i+=1\n\nfor d in dic:\n dic[d]=np.cumsum(dic[d])\n\n\n\ndp=[0]*len(A)\ndp[0]=1\nfor i in range(1,len(A)):\n tmp = (i+1-dic[A[i]][i])\n #print(tmp)\n dp[i]=dp[i-1]+tmp\n\nprint(dp[-1])\n", "neg": "\nimport numpy as np\n\ndic={}\nascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'\n\nA = input()\nfor a in ascii_lowercase:\n dic[a]=[0]*len(A)\n\ni=0\nfor l in A:\n dic[l][i]=1\n i+=1\n\nfor d in dic:\n dic[d]=np.cumsum(dic[d])\n\n\n\ndp=[0]*len(A)\ndp[0]=1\nfor i in range(1,len(A)):\n tmp = (i+1-dic[A[i]][i])\n print(tmp)\n dp[i]=dp[i-1]+tmp\n\nprint(dp[-1])", "jacc_sim": 0.9736842105263158, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [185, 183], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u905582793", "n_user": "u905582793", "pos": "from collections import Counter\ns=list(input())\nn=len(s)\nc=Counter(s)\nans=1+n*(n-1)//2\nfor i in c.values():\n ans-=i*(i-1)//2\nprint(ans)", "neg": "from collections import Counter\ns=list(input())\nn=len(s)\nc=s.Counter()\nans=1+n*(n-1)//2\nfor i in c.values():\n ans-=i*(i-1)//2\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [64, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u968846084", "n_user": "u968846084", "pos": "A=input()\nans=0\na=A.count(\"a\")\nb=A.count(\"b\")\nc=A.count(\"c\")\nd=A.count(\"d\")\ne=A.count(\"e\")\nf=A.count(\"f\")\ng=A.count(\"g\")\nh=A.count(\"h\")\ni=A.count(\"i\")\nj=A.count(\"j\")\nk=A.count(\"k\")\nl=A.count(\"l\")\nm=A.count(\"m\")\nn=A.count(\"n\")\no=A.count(\"o\")\np=A.count(\"p\")\nq=A.count(\"q\")\nr=A.count(\"r\")\ns=A.count(\"s\")\nt=A.count(\"t\")\nu=A.count(\"u\")\nv=A.count(\"v\")\nw=A.count(\"w\")\nx=A.count(\"x\")\ny=A.count(\"y\")\nz=A.count(\"z\")\nB=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]\nfor aa in range(26):\n ans=ans+B[aa]*(len(A)-B[aa])\nprint(ans//2+1)", "neg": "A=input()\nans=0\na=A.count(\"a\")\nb=A.count(\"b\")\nc=A.count(\"c\")\nd=A.count(\"d\")\ne=A.count(\"e\")\nf=A.count(\"f\")\ng=A.count(\"g\")\nh=A.count(\"h\")\ni=A.count(\"i\")\nj=A.count(\"j\")\nk=A.count(\"k\")\nl=A.count(\"l\")\nm=A.count(\"m\")\nn=A.count(\"n\")\no=A.count(\"o\")\np=A.count(\"p\")\nq=A.count(\"q\")\nr=A.count(\"r\")\ns=A.count(\"s\")\nt=A.count(\"t\")\nu=A.count(\"u\")\nv=A.count(\"v\")\nw=A.count(\"w\")\nx=A.count(\"x\")\ny=A.count(\"y\")\nz=A.count(\"z\")\nB=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]\nfor aa in range(26):\n ans=ans+B[aa]*(len(A)-B[aa])\nprint(ans)", "jacc_sim": 0.9444444444444444, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [333, 329], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u780962115", "n_user": "u780962115", "pos": "s=list(input())\nimport collections\ndics=collections.Counter(s)\nnum=len(s)\nans=num*(num-1)//2\nfor i in dics.values():\n ans-=(i*(i-1)//2)\nprint(ans+1)\n", "neg": "s=list(input())\nimport collections\ndics=collections.Counter(s)\nnum=len(s)\nans=num*(num-1)//2\nfor i in dics.values():\n ans-=(i*(i-1)//2)\nprint(ans)", "jacc_sim": 0.9615384615384616, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [68, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u623687794", "n_user": "u623687794", "pos": "from collections import Counter\na=input()\nc=Counter(a)\nn=len(a)\nif n==1:print(1)\nelse:\n ans=n*(n-1)//2\n for i in c.values():\n if i==1:continue\n else:ans-=i*(i-1)//2\n print(ans+1)\n", "neg": "from collections import Counter\na=input()\nc=Counter(a)\nif n==1:print(1)\nelse:\n ans=n*(n-1)//2\n for i in c.values():\n if i==1:continue\n else:ans-=i*(i-1)//2\n print(ans+1)\n", "jacc_sim": 0.9655172413793104, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [89, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u375616706", "n_user": "u375616706", "pos": "from collections import Counter\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n S = input()[:-1]\n N = len(S)\n C = Counter(S)\n ans = 0\n for v in C.values():\n ans += v*(v-1)//2\n print(N*(N-1)//2-ans+1)\n\n\nsolve()\n", "neg": "from collections import Counter\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\ndef solve():\n S = input()[:-1]\n N = len(S)\n C = Counter(S)\n ans = 0\n for v in C.values():\n ans += v*(v-1)//2\n print(N*(N-1)//2-ans)\n\n\nsolve()\n", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [116, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u543954314", "n_user": "u543954314", "pos": "from collections import Counter\ns = input()\nn = len(s)\nd = Counter(s)\nc = 0\nfor x in d:\n c += d[x]*(d[x]-1)//2\nprint(1 + n*(n-1)//2 - c)", "neg": "from collections import Count\ns = input()\nn = len(s)\nd = Count(s)\nc = 0\nfor x in d:\n c += d[x]*(d[x]-1)//2\nprint(n*(n-1)//2 - c)", "jacc_sim": 0.9285714285714286, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [67, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u391875425", "n_user": "u391875425", "pos": "S = input()\nN = len(S)\nans = N * (N - 1) // 2 + 1\na = []\ncnt = 0\nfor c in [chr(i) for i in range(97, 97+26)]:\n cnt = S.count(c)\n a.append(cnt * (cnt - 1) // 2)\nans -= sum(a)\nprint(ans)", "neg": "S = input()\nN = len(S)\nans = N * (N - 1) // 2\na = []\nfor c in [chr(i) for i in range(97, 97+26)]:\n a.append(S.count(c))\nans -= sum(a)\nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [92, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = str(input())\nlis = [0 for i in range(26)]\nans = 1\nfor i in range(len(n)):\n ans += i\n lis[ord(n[i])-ord(\"a\")] += 1\nfor i in range(26):\n for k in range(lis[i]-1):\n ans -= (k+1)\nprint(ans)", "neg": "n = str(input())\nlis = [0 for i in range(26)]\nans = 1\nfor i in range(1,len(n)+1):\n ans += i\n lis[ord(n[i])-\"a\"] += 1\nfor i in range(26):\n for k in range(lis[i]-1):\n ans -= (k+1)\nprint(ans)", "jacc_sim": 0.9629629629629629, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [95, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u225528554", "n_user": "u225528554", "pos": "def main():\n s = list(input())\n count = int((len(s)*(len(s)-1))/2+1)\n dic = {}\n for i in range(len(s)):\n try:\n dic[s[i]].append(i)\n except Exception:\n dic[s[i]] = [i]\n\n for j in dic.values():\n count-=int((len(j)*(len(j)-1))/2)\n print(count)\n\n\nif __name__==\"__main__\":\n main()", "neg": "def main():\n s = list(input())\n count = (len(s)*len(s)-1)/2+1\n dic = {}\n for i in range(len(s)):\n try:\n dic[s[i]].append(i)\n except Exception:\n dic[s[i]] = [i]\n\n for j in dic.values():\n count-=(len(j)*len(j)-1)/2+1\n print(count)\n\n\nif __name__==\"__main__\":\n main()", "jacc_sim": 0.9743589743589743, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [137, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u996252264", "n_user": "u996252264", "pos": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef rls(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\ndef plis(a): return \" \".join(list(map(str, a)))\n\nalf = list(\"abcdefghijklmnopqrstuvwxyz\")\nA = rls()\nn = len(A)\nans = n*(n-1)/2 + 1\nfor i in alf:\n count = 0\n for j in A:\n if(i == j):\n count += 1\n ans -= count*(count-1)/2\n\nprint(int(ans))\n", "neg": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef rls(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\ndef plis(a): return \" \".join(list(map(str, a)))\n\nalf = list(\"abcdefghijklmnopqrstuvwxyz\")\nA = rls()\nn = len(A)\nans = n*(n-1)/2 + 1\nfor i in alf:\n count = 0\n for j in A:\n if(i == j):\n count += 1\n ans -= count*(count-1)/2\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [169, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03618", "p_user": "u190405389", "n_user": "u190405389", "pos": "a=input()\nb=1+(len(a)*(len(a)-1)//2)\nfor i in range(97,123):\n c=a.count(chr(i))\n d=(c*(c-1))//2\n b-=d\nprint(b)", "neg": "a=input()\nl=len(a)\nb=l*(l-1)/2+1\nfor i in range(97,123):\n c=a.count(chr(i))\n d=(c*(c-1))//2\n b-=d\nprint(b)", "jacc_sim": 0.9642857142857143, "nl": "You are given a string consisting of lowercase English letters. You can choose any two indices and reverse the substring between those indices. You can perform this operation at most once. Determine how many different strings you can obtain by reversing any substring at most once. The input is the string, and the output is the number of different strings you can obtain.", "before_after_length": [69, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u788068140", "n_user": "u788068140", "pos": "N = int(input())\nS1 = input()\nS2 = input()\n\ndef prepare(s1,s2,n):\n result = []\n i = 0\n while i < n:\n if s1[i] == s2[i]:\n result.append(1)\n i += 1\n else:\n result.append(0)\n i += 2\n\n return result\n\n\n\ndef calculate(arr):\n ans = 1\n for index in range(len(arr)):\n if index == 0:\n if arr[index] == 0:\n ans = 6\n else:\n ans = 3\n continue\n #xo\n if (arr[index - 1] == 1) and (arr[index] == 0):\n ans *= 2\n\n #xx\n if (arr[index - 1] == 1) and (arr[index] == 1):\n ans *= 2\n\n #oo\n if (arr[index - 1] == 0) and (arr[index] == 0):\n ans *= 3\n\n #ox\n if (arr[index - 1] == 0) and (arr[index] == 1):\n ans *= 1\n\n print(ans % 1000000007)\n\n\n\narr = prepare(S1,S2,N)\ncalculate(arr)", "neg": "N = int(input())\nS1 = input()\nS2 = input()\ndef prepare(s1,s2,n):\n result = []\n i = 0\n while i < n:\n if s1[i] == s2[i]:\n result.append(1)\n i += 1\n else:\n result.append(0)\n i += 2\n\n return result\n\n\n\ndef calculate(arr):\n ans = 3\n for index in range(1, len(arr)):\n #xo\n if (arr[index - 1] == 1) and (arr[index] == 0):\n ans *= 2\n\n #xx\n if (arr[index - 1] == 1) and (arr[index] == 1):\n ans *= 2\n\n #oo\n if (arr[index - 1] == 0) and (arr[index] == 0):\n ans *= 3\n\n #ox\n if (arr[index - 1] == 0) and (arr[index] == 1):\n ans *= 1\n\n print(ans % 1000000007)\n\n\n\narr = prepare(S1,S2,N)\ncalculate(arr)", "jacc_sim": 0.9615384615384616, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [316, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u064434060", "n_user": "u064434060", "pos": "import sys\n#import numpy as np\nimport math\n#from fractions import Fraction\n#import itertools\n#from collections import deque\n#import heapq\n#from fractions import gcd\n\n#input=sys.stdin.readline\nmod=1000000007\nn=int(input())\ns=[input() for _ in range(2)]\nd=[]\ni=0\nwhile i= n:\n break\n if s1[i] == s2[i]:\n pat = 0\n i += 1\n else:\n pat = 1\n i += 2\n ans *= t[pre_pat][pat]\n ans %= MOD\n # print(pre_pat, pat, ans, i)\n pre_pat = pat\nprint(ans)", "neg": "MOD = 10**9+7\n\nn = int(input())\ns1 = input()\ns2 = input()\nans = 1\n\nif s1[0] == s2[0]:\n i = 1\n pre_pat = 0\n ans = 3\nelse:\n i = 2\n pre_pat = 1\n ans = 6\n\nt = [[2, 2], [1, 3]]\nwhile True:\n if i >= n:\n break\n if s1[i] == s2[i]:\n pat = 0\n i += 1\n else:\n pat = 1\n i += 2\n ans *= t[pre_pat][pat]\n ans %= MOD\n print(pre_pat, pat, ans, i)\n pre_pat = pat\nprint(ans)", "jacc_sim": 0.972972972972973, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [192, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u361381049", "n_user": "u361381049", "pos": "mod = int(1e9) + 7\n\nn = int(input())\ns1 = input()\ns2 = input()\n\nif s1[0] == s2[0]:\n ans = 3\n i = 1\nelse:\n ans = 6\n i = 2\nwhile i < n:\n #print(ans, i,s1[i],s2[i],s1[i-1],s2[i-1])\n if s1[i] == s2[i]:\n\n if s1[i-1] == s2[i-1]:\n ans *= 2\n ans %= mod\n i += 1\n else:\n\n if s1[i-1] == s2[i-1]:\n ans *= 2\n ans %= mod\n else:\n ans *= 3\n ans %= mod\n i += 2\nprint(ans)", "neg": "mod = int(1e9) + 7\n\nn = int(input())\ns1 = input()\ns2 = input()\n\nif s1[0] == s2[0]:\n ans = 3\n i = 1\nelse:\n ans = 6\n i = 2\nwhile i < n:\n #print(ans, i,s1[i],s2[i],s1[i-1],s2[i-1])\n if s1[i] == s2[i]:\n\n if s1[i-1] == s2[i-1]:\n ans *= 2\n ans %= mod\n i += 1\n else:\n\n if s1[i-1] == s2[i-1]:\n ans *= 2\n ans %= mod\n else:\n ans *= 6\n ans %= mod\n i += 2\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [211, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u210827208", "n_user": "u210827208", "pos": "n=int(input())\ns1=input()\ns2=input()\nif s1[0]==s2[0]:\n i=1\nelse:\n i=0\nans=3\n\nflag=False\nwhile i1:\n if s1[0]==s1[1]:\n i=0\n else:\n i=1\nelse:\n i=0\nans=3\n\nflag=False\nwhile i= n:\n break\n\n if ls1[i]==ls2[i]:\n if flg == \"a\":\n flg = \"b\"\n else:\n ans = (ans*2)%(10**9+7)\n\n i += 1\n\n else:\n if flg == \"a\":\n ans = (ans*3)%(10**9+7)\n else:\n ans = (ans*2)%(10**9+7)\n flg = \"a\"\n\n i += 2\n if i >= n:\n break\n\n print(ans)\n\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n n = int(input())\n ls1 = list(input())\n ls2 = list(input())\n\n if ls1[0]==ls2[0]:\n ans = 3\n i =1\n flg = \"b\"\n else:\n ans = 3\n flg = \"a\"\n i =2\n \n while 1:\n\n\n if ls1[i]==ls2[i]:\n if flg == \"a\":\n flg = \"b\"\n else:\n ans = (ans*2)%(10**9+7)\n\n i += 1\n\n else:\n if flg == \"a\":\n ans = (ans*3)%(10**9+7)\n else:\n ans = (ans*2)%(10**9+7)\n flg = \"a\"\n \n i += 2\n if i >= n:\n break\n \n print(ans)\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9743589743589743, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [255, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u721316601", "n_user": "u721316601", "pos": "MOD = 1000000007\n\nN = int(input())\nS1 = input()\nS2 = input()\n\nif S1[0] == S2[0]:\n \tans, idx = 3, 1\nelse:\n \tans, idx = 6, 2\n\nwhile idx < N:\n if S1[idx] == S2[idx]:\n if S1[idx-1] == S2[idx-1]:\n ans *= 2\n idx += 1\n else:\n if S1[idx-1] == S2[idx-1]:\n ans *= 2\n else:\n ans *= 3\n idx += 2\n ans %= MOD\nprint(ans)", "neg": "MOD = 1000000007\n\nN = int(input())\nS1 = input()\nS2 = input()\n\nif S1[0] == S2[0]:\n \tans, idx = 3, 1\nelse:\n \tans, idx = 6, 2\n\nwhile idx < N:\n print(S1[idx])\n if S1[idx] == S2[idx]:\n if S1[idx-1] == S2[idx-1]:\n ans *= 2\n idx += 1\n else:\n if S1[idx-1] == S2[idx-1]:\n ans *= 2\n else:\n ans *= 3\n idx += 2\n ans %= MOD\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [163, 172], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u360116509", "n_user": "u360116509", "pos": "def main():\n N = int(input())\n S1 = input()\n S2 = input()\n ans = 3\n i = 0\n while N - 1 > i:\n if S1[i] == S2[i]:\n if S1[i + 1] == S2[i + 1]:\n ans *= 2\n i += 1\n else:\n if N > i + 2 and S1[i + 2] != S2[i + 2]:\n ans *= 3\n else:\n ans *= 2\n i += 2\n print(ans % 1000000007)\n\n\nmain()\n", "neg": "def main():\n N = int(input())\n S1 = input()\n S2 = input()\n ans = 3\n i = 0\n while N - 1 > i:\n print(S1[i], S2[i])\n if S1[i] == S2[i]:\n if S1[i + 1] == S2[i + 1]:\n ans *= 2\n i += 1\n else:\n if N > i + 2 and S1[i + 2] != S2[i + 2]:\n ans *= 3\n else:\n ans *= 2\n i += 2\n print(ans % 1000000007)\n\n\nmain()\n", "jacc_sim": 0.96875, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [149, 163], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u518064858", "n_user": "u518064858", "pos": "n=int(input())\ns1=input()\ns2=input()\nif n==1:\n print(3)\n exit()\ns=\"\"\ni=0\nwhile i i:\n if S1[i] != S2[i] and state == 0:\n ans *= 2\n i+=2\n state = 1\n elif S1[i] != S2[i] and state == 1:\n ans *= 3\n i+=2\n elif S1[i] == S2[i] and state == 0:\n ans *= 2\n i+= 1\n elif S1[i] == S2[i] and state == 1:\n ans *= 1\n i+=1\n state = 0\n\n ans %= mod\nprint(ans)\n", "neg": "N = int(input())\nS1 = input()\nS2 = input()\n\ni = 1\nif S1[0] == S2[0]:\n ans = 3\n state = 0\nelse:\n i+= 1\n ans = 6\n state = 1\nmod = 10**9 + 7\nwhile N > i:\n if S1[i] != S2[i] and state == 0:\n ans *= 2\n i+=2\n state = 1\n elif S1[i] != S2[i] and state == 1:\n ans *= 3\n i+=2\n elif S1[i] == S2[i] and state == 0:\n ans *= 2\n i+= 1\n elif S1[i] == S2[i] and state == 1:\n ans *= 1\n i+=1\n state = 0\n\n ans %= mod\nprint(ans)\n~\n", "jacc_sim": 0.9714285714285714, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [222, 224], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u270681687", "n_user": "u270681687", "pos": "n = int(input())\ns1 = input()\ns2 = input()\n\nmod = 10**9 + 7\n\n# dp[i][j] : i\u756a\u76ee\u307e\u3067\u898b\u305f\u3068\u304d\u306b\u3001i\u756a\u76ee\u306e\u8981\u7d20\u304c j = 0 \u3060\u3068\u7e26\u306b\u3001\n# j = 1 \u3060\u3068\u6a2a\u306b\u30d6\u30ed\u30c3\u30af\u304c\u4e26\u3093\u3067\u3044\u305f\u6642\u306e\u8272\u306e\u5857\u308a\u304b\u305f (mod 10**9+7)\ndp = [[0 for j in range(2)] for i in range(n+1)]\n\nif s1[0] == s2[0]:\n dp[0][0] = 3\n i = 0\nelse:\n dp[1][1] = 3 * 2\n i = 1\nwhile i < n - 1:\n if s1[i] == s2[i]:\n if s1[i+1] == s2[i+1]:\n dp[i+1][0] = dp[i][0] * 2 % mod\n i += 1\n else:\n dp[i+2][1] = dp[i][0] * 2 % mod\n i += 2\n else:\n if s1[i+1] == s2[i+1]:\n dp[i+1][0] = dp[i][1] % mod\n i += 1\n else:\n dp[i+2][1] = dp[i][1] * 3 % mod\n i += 2\n\nprint((dp[n-1][0] % mod + dp[n-1][1] % mod) % mod)", "neg": "n = int(input())\ns1 = input()\ns2 = input()\n\nmod = 10**9 + 7\n\n# dp[i][j] : i\u756a\u76ee\u307e\u3067\u898b\u305f\u3068\u304d\u306b\u3001i\u756a\u76ee\u306e\u8981\u7d20\u304c j = 0 \u3060\u3068\u7e26\u306b\u3001\n# j = 1 \u3060\u3068\u6a2a\u306b\u30d6\u30ed\u30c3\u30af\u304c\u4e26\u3093\u3067\u3044\u305f\u6642\u306e\u8272\u306e\u5857\u308a\u304b\u305f (mod 10**9+7)\ndp = [[0 for j in range(2)] for i in range(n+1)]\n\nif s1[0] == s2[0]:\n dp[1][0] = 3\n i = 1\nelse:\n dp[2][1] = 3 * 2\n i = 2\nwhile i < n:\n if s1[i] == s2[i]:\n if s1[i+1] == s2[i+1]:\n dp[i+1][0] = dp[i][0] * 2\n i += 1\n else:\n dp[i+2][1] = dp[i][0] * 2\n i += 2\n else:\n if s1[i+2] == s2[i+2]:\n dp[i+2][0] = dp[i][1]\n i += 2\n else:\n dp[i+3][1] = dp[i][1] * 2\n i += 3\n\nprint(dp[n][0] + dp[n][1])", "jacc_sim": 0.96875, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [457, 435], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u006657459", "n_user": "u006657459", "pos": "N = int(input())\nS1 = input()\nS2 = input()\npatterns = []\nflag = False\nfor i in range(N):\n if S1[i] == S2[i]:\n patterns.append('row')\n elif flag is False:\n patterns.append('column')\n flag = True\n else:\n flag = False\n\nif patterns[0] == 'row':\n count = 3\nelse:\n count = 6\nfor i in range(1, len(patterns)):\n prev = patterns[i-1]\n current = patterns[i]\n if prev == 'row':\n if current == 'row':\n count *= 2\n else:\n count *= 2\n else: # column\n if current == 'row':\n count *= 1\n else:\n count *= 3\nprint(count % (10**9 + 7))", "neg": "N = int(input())\nS1 = input()\nS2 = input()\npatterns = []\nflag = False\nfor i in range(N):\n if S1[i] == S2[i]:\n patterns.append('row')\n elif flag is False:\n patterns.append('column')\n flag = True\n else:\n flag = False\n\nprint(patterns)\nif patterns[0] == 'row':\n count = 3\nelse:\n count = 6\nfor i in range(1, len(patterns)):\n prev = patterns[i-1]\n current = patterns[i]\n if prev == 'row':\n if current == 'row':\n count *= 2\n else:\n count *= 2\n else: # column\n if current == 'row':\n count *= 1\n else:\n count *= 3\nprint(count % (10**9 + 7))", "jacc_sim": 1.0, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [211, 216], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u827202523", "n_user": "u827202523", "pos": "N = int(input())\nupper = list(input())\nlower = list(input())\nans = 0\n\ndef count(upper, lower, state):\n global ans\n if upper[0] == lower[0]:\n if state == 1:\n ans *= 2\n try:\n count(upper[1:],lower[1:],state=1)\n except:\n return ans\n if state == 2:\n try:\n count(upper[1:], lower[1:], state=1)\n except:\n return ans\n else:\n if state == 1:\n ans *= 2\n try:\n count(upper[2:], lower[2:], state=2)\n except:\n return ans\n if state == 2:\n ans *= 3\n try:\n count(upper[2:], lower[2:], state=2)\n except:\n return ans\n\nif upper[0] == lower[0]:\n ans = 3\n try:\n count(upper[1:], lower[1:], state=1)\n except:\n pass\nelse:\n ans = 6\n try:\n count(upper[2:], lower[2:], state=2)\n except:\n pass\n\nprint(ans%1000000007)", "neg": "N = int(input())\nupper = list(input())\nlower = list(input())\nans = 0\n\ndef count(upper, lower, state):\n global ans\n if upper[0] == lower[0]:\n if state == 1:\n ans *= 2\n try:\n count(upper[1:],lower[1:],state=1)\n except:\n return ans\n if state == 2:\n try:\n count(upper[1:], lower[1:], state=1)\n except:\n return ans\n else:\n if state == 1:\n ans *= 2\n try:\n count(upper[2:], lower[2:], state=2)\n except:\n return ans\n if state == 2:\n ans *= 3\n try:\n count(upper[2:], lower[2:], state=2)\n except:\n return ans\n\nif upper[0] == lower[0]:\n ans = 3\n count(upper[1:], lower[1:], state=1)\nelse:\n ans = 6\n count(upper[2:], lower[2:], state=2)\n\nprint(ans%1000000007)", "jacc_sim": 0.9696969696969697, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [311, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u982762220", "n_user": "u982762220", "pos": "N = int(input())\nS1 = input()\nS2 = input()\nres = 6\nidx = 0\ns = []\nmod = 1000000007\nwhile idx < N:\n if S1[idx] == S2[idx]:\n s.append(0)\n else:\n s.append(1)\n idx += 1\n idx += 1\n\nres = 3 if s[0] == 0 else 6\n\nfor idx in range(1, len(s)):\n prev, cur = s[idx-1], s[idx]\n if prev == 0:\n if cur == 0:\n res *= 2\n else:\n res *= 2\n else:\n if cur == 0:\n res *= 1\n else:\n res *= 3\n\n res %= mod\n\nprint(res)\n", "neg": "N = int(input())\nS1 = input()\nS2 = input()\nres = 6\nidx = 0\ns = []\nmod = 1000000007\nwhile idx < N:\n if S1[idx] == S2[idx]:\n s.append(0)\n else:\n s.append(1)\n idx += 1\n idx += 1\n\nres = 3 if s[0] == 0 else 6\n\nfor idx in range(1, len(s)):\n prev, cur = s[idx-1], s[idx]\n if prev == 0:\n if cur == 0:\n res *= 2\n else:\n res *= 1\n else:\n if cur == 0:\n res *= 2\n else:\n res *= 3\n\n res %= mod\n\nprint(res)\n", "jacc_sim": 1.0, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [196, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u098968285", "n_user": "u098968285", "pos": "N = int(input())\ns1 = input()\ns2 = input()\n\nMOD = int(1e9) + 7\n\ntate = \"tate\"\nyoko = \"yoko\"\n\ni = 0\nans = 0\npre = \"\"\nif s1[i] == s2[i]:\n ans = 3\n i += 1\n pre = tate\nelse:\n ans = 6\n i += 2\n pre = yoko\n\nwhile i < N:\n if s1[i] == s2[i]:\n if pre == tate:\n ans *= 2\n elif pre == yoko:\n ans *= 1\n i += 1\n pre = tate\n else:\n if pre == tate:\n ans *= 2\n elif pre == yoko:\n ans *= 3\n i += 2\n pre = yoko\n ans %= MOD\nprint(ans)\n", "neg": "N = int(input())\ns1 = input()\ns2 = input()\n\nMOD = int(1e9) + 7\n\ntate = \"tate\"\nyoko = \"yoko\"\n\ni = 0\nans = 0\npre = \"\"\nif s1[i] == s2[i]:\n ans = 3\n i += 1\n pre = tate\nelse:\n ans = 6\n i += 2\n pre = yoko\n\nwhile i < N:\n if s1[i] == s2[i]:\n if pre == tate:\n ans *= 2\n ans %= MOD\n i += 1\n else:\n ans *= 1\n ans %= MOD\n i += 2\n pre = tate\n else:\n if pre == tate:\n ans *= 2\n ans %= MOD\n i += 1\n else:\n ans *= 2\n ans %= MOD\n i += 2\n pre = yoko\nprint(ans)\n", "jacc_sim": 0.9705882352941176, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [224, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u796424048", "n_user": "u796424048", "pos": "N = int(input())\nS_1 = list(input())\nS_2 = list(input())\n\n\n\nif S_1[0] == S_2[0]:\n res = 3\n flag = 0\n i = 1\nelse:\n res = 6\n flag = 1\n i = 2\n\nwhile i != N:\n if S_1[i] == S_2[i]:\n if flag == 0:\n res *= 2 \n else:\n res *= 1\n flag = 0\n i += 1\n\n else:\n if flag == 0:\n res *= 2\n flag = 1\n else:\n res *= 3\n i += 2\n \nans = res%1000000007\n\nprint(ans)\n ", "neg": "N = int(input())\nS_1 = list(input())\nS_2 = list(input())\n\n\n\nif S_1[0] == S_2[0]:\n res = 3\n flag = 0\n i = 1\nelse:\n res = 6\n flag = 1\n i = 2\n\nwhile i != N:\n if S_1[i] == S_2[i]:\n if flag == 0:\n res *= 2 \n else:\n res *= 1\n flag = 0\n i += 1\n\n else:\n if flag == 0:\n res *= 2\n flag = 1\n else:\n res *= 3\n i += 2\n \nans = res%100000007\n\nprint(ans) ", "jacc_sim": 0.9354838709677419, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [183, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03626", "p_user": "u626881915", "n_user": "u626881915", "pos": "n = int(input())\ns1 = input()\ns2 = input()\ncount = 1\nj = 0\nif s1[0] == s2[0]:\n count *= 3\nelse:\n count *= 6 \n j += 1\nwhile j < n-1:\n if s1[j] == s2[j]:\n if s1[j+1] == s2[j+1]:\n count *= 2\n count %= 1000000007\n else:\n count *= 2\n count %= 1000000007\n j += 1\n else:\n if s1[j+1] == s2[j+1]:\n count *= 1\n count %= 1000000007\n else:\n count *= 3\n count %= 1000000007\n j += 1\n j += 1\nprint(count)\n", "neg": "n = int(input())\ns1 = input()\ns2 = input()\ncount = 1\nj = 0\nif s1[0] == s2[0]:\n count *= 3\nelse:\n count *= 6 \nwhile j < n-1:\n if s1[j] == s2[j]:\n if s1[j+1] == s2[j+1]:\n count *= 2\n count %= 1000000007\n else:\n count *= 2\n count %= 1000000007\n j += 1\n else:\n if s1[j+1] == s2[j+1]:\n count *= 1\n count %= 1000000007\n else:\n count *= 3\n count %= 1000000007\n j += 1\n j += 1\nprint(count)\n", "jacc_sim": 1.0, "nl": "You are given a board with a 2xN grid. Snuke covered the board with N dominoes without overlaps. Each domino can cover a 1x2 or 2x1 square. Snuke wants to paint these dominoes using three colors: red, cyan, and green. Adjacent dominoes should be painted with different colors. Find the number of ways to paint the dominoes, modulo 1000000007. The arrangement of the dominoes is given as two strings S1 and S2. Constraints: 1 \u2264 N \u2264 52, |S1| = |S2| = N, S1 and S2 consist of lowercase and uppercase English letters, and represent a valid arrangement of dominoes. Input format: N, S1, S2. Output: Print the number of ways to paint the dominoes, modulo 1000000007. Example: Input: 3, aab, ccb. Output: 6.", "before_after_length": [196, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03629", "p_user": "u794173881", "n_user": "u794173881", "pos": "import sys\nsys.setrecursionlimit(10**6)\n\na = input() + \"$\"\nn = len(a)\n\nalph = \"abcdefghijklmnopqrstuvwxyz\"\ndp = [-1] * (n + 1)\n\nnext_ = [[-1] * (n + 1) for i in range(26)]\nfor char in range(26):\n tmp = - 1\n for i in range(n)[::-1]:\n if a[i] == alph[char]:\n tmp = i + 1\n next_[char][i] = tmp\n\n\ndef solve():\n for i in range(n + 1)[::-1]:\n tmp = n + 1\n for char in range(26):\n if next_[char][i] == -1:\n dp[i] = 1\n break\n tmp = min(dp[next_[char][i]] + 1 , tmp)\n else:\n dp[i] = tmp\n\nsolve()\nans = []\ni = 0\nwhile True:\n for char in range(26):\n if next_[char][i] == -1:\n ans.append(alph[char])\n print(\"\".join(ans))\n exit()\n if dp[i] == dp[next_[char][i]] + 1:\n ans.append(alph[char])\n i = next_[char][i]\n break", "neg": "import sys\nsys.setrecursionlimit(10**6)\n\na = input() + \"$\"\nn = len(a)\n\nalph = \"abcdefghijklmnopqrstuvwxyz\"\ndp = [-1] * (n + 1)\n\nnext_ = [[-1] * (n + 1) for i in range(26)]\nfor char in range(26):\n tmp = - 1\n for i in range(n)[::-1]:\n if a[i] == alph[char]:\n tmp = i + 1\n next_[char][i] = tmp\n\n\ndef solve(i):\n if dp[i] != -1:\n return dp[i]\n tmp = n + 1\n for char in range(26):\n if next_[char][i] == -1:\n dp[i] = 1\n return dp[i]\n tmp = min(solve(next_[char][i]) + 1 , tmp)\n dp[i] = tmp\n return dp[i]\n\nsolve(0)\nans = []\ni = 0\nwhile True:\n for char in range(26):\n if dp[i] == dp[next_[char][i]] + 1:\n ans.append(alph[char])\n i = next_[char][i]\n break\n else:\n break\n\nprint(\"\".join(ans))", "jacc_sim": 0.94, "nl": "You are given a string consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of the given string. If there are multiple such strings, output the lexicographically smallest one.", "before_after_length": [339, 331], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03629", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n import sys\n input=sys.stdin.readline\n s=input()\n alpha=\"abcdefghijklmnopqrstuvwxyz\"\n l=len(s)\n alpha2={j:i for i,j in enumerate(alpha)}\n memo=[[0]*26 for _ in range(l,-1,-1)]\n for i in range(26):\n memo[l][i]=l+1\n for x,y in alpha2.items():\n for i in range(l-1,-1,-1):\n if s[i]==x:\n memo[i][y]=i+1\n else:\n memo[i][y]=memo[i+1][y]\n \n search=[1]*(l+2)\n search[l+1]=0\n for i in range(l-1,-1,-1):\n m=max([memo[i][j] for j in range(26)])\n if m!=l+1:\n search[i]=search[m]+1\n \n n,seq=0,0\n ans_len=search[0]\n ans=\"\"\n temp=0\n for i in range(ans_len):\n for j in range(26):\n n=memo[temp][j]\n seq=search[n]+i\n if seq+1==ans_len:\n ans+=alpha[j]\n temp=memo[temp][j]\n break\n print(ans)\nif __name__=='__main__':\n main()", "neg": "def main():\n import sys\n input=sys.stdin.readline\n s=input()\n alpha=\"abcdefghijklmnopqrstuvwxyz\"\n l=len(s)\n alpha2={j:i for i,j in enumerate(alpha)}\n memo=[[0]*26 for _ in range(l,-1,-1)]\n for i in range(26):\n memo[l][i]=l+1\n for i in range(l-1,-1,-1):\n for x,y in alpha2.items(): \n memo[i][y]=memo[i+1][y]\n memo[i][alpha2[s[i]]]=i+1\n \n search=[1]*(l+2)\n search[l+1]=0\n for i in range(l-1,-1,-1):\n m=max([memo[i][j] for j in range(26)])\n if m!=l+1:\n search[i]=search[m]+1\n \n n,seq=0,0\n ans_len=search[0]\n ans=\"\"\n temp=0\n for i in range(ans_len):\n for j in range(26):\n n=memo[temp][j]\n seq=search[n]+i\n if seq+1==ans_len:\n ans+=alpha[j]\n temp=memo[temp][j]\n break\n print(ans)\nif __name__=='__main__':\n main()", "jacc_sim": 0.9824561403508771, "nl": "You are given a string consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of the given string. If there are multiple such strings, output the lexicographically smallest one.", "before_after_length": [382, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03629", "p_user": "u848504701", "n_user": "u848504701", "pos": "abc=\"abcdefghijklmnopqrstuvwxyz\"\n\nA=str(input())\nn=len(A)\n#make matrix (a-z)*(n characters)\n#\u6b21\u306bchr\u304c\u51fa\u3066\u304f\u308bindex\nword_pos=[]\nct=[n]*26\norda=ord(\"a\")\n\nfor i in range(n-1,-1,-1):\n ct[ord(A[i])-orda]=i\n word_pos.append(ct.copy())\n\nword_pos.reverse()\n\ndp=[0]*n+[1,0]\nj=n\nsep=[]\n#\u533a\u5207\u308c\u3081\u3092\u30de\u30fc\u30af\nfor i in range(n-1,-1,-1):\n ct=word_pos[i]\n if(max(ct)end-1):\n ans+=chr(orda+i)\n break\n ans+=\"\\n\"\n print(ans)", "neg": "abc=\"abcdefghijklmnopqrstuvwxyz\"\n\nA=str(input())\nn=len(A)\n#make matrix (a-z)*(n characters)\n#\u6b21\u306bchr\u304c\u51fa\u3066\u304f\u308bindex\nword_pos=[]\nct=[n]*26\norda=ord(\"a\")\n\nfor i in range(n-1,-1,-1):\n ct[ord(A[i])-orda]=i\n word_pos.append(ct.copy())\n\nword_pos.reverse()\n\ndp=[0]*n+[1,0]\nj=n\nsep=[]\n#\u533a\u5207\u308c\u3081\u3092\u30de\u30fc\u30af\nfor i in range(n-1,-1,-1):\n ct=word_pos[i]\n if(max(ct)end-1):\n ans+=chr(orda+i)\n break\nans+=\"\\n\"\nprint(ans)", "jacc_sim": 0.9882352941176471, "nl": "You are given a string consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of the given string. If there are multiple such strings, output the lexicographically smallest one.", "before_after_length": [489, 443], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03629", "p_user": "u466826467", "n_user": "u466826467", "pos": "import string\n\nif __name__ == '__main__':\n A = input()\n\n p = {}\n for x in string.ascii_lowercase:\n p[x] = len(A)\n # print(p)\n '''\n tb\n 1\u3064\u76ee\uff1a\n 2\u3064\u76ee\uff1a\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\n 3\u3064\u76ee\uff1a\n '''\n tb = [(0, 0, 0)] * len(A)\n tb.append((1, 0, 0))\n tb.append((0, 0, 0))\n # print(tb)\n for i, x in reversed(list(enumerate(A))):\n p[x] = i\n tb[i] = min([(tb[p[c] + 1][0] + 1, c, p[c] + 1) for c in string.ascii_lowercase])\n # print(tb)\n i = 0\n ans = []\n while i < len(A):\n ans.append(tb[i][1])\n i = tb[i][2]\n\n print(\"\".join(ans))\n", "neg": "import string\n\nif __name__ == '__main__':\n A = input()\n\n p = {}\n for x in string.ascii_lowercase:\n p[x] = len(A)\n # print(p)\n '''\n tb\n 1\u3064\u76ee\uff1a\n 2\u3064\u76ee\uff1a\u30a2\u30eb\u30d5\u30a1\u30d9\u30c3\u30c8\n 3\u3064\u76ee\uff1a\n '''\n tb = [(0, 0, 0)] * len(A)\n tb.append((1, 0, 0))\n tb.append((0, 0, 0))\n # print(tb)\n for i, x in reversed(list(enumerate(A))):\n p[x] = i\n tb[i] = min([(tb[p[c] + 1][0] + 1, c, p[c] + 1) for c in string.ascii_lowercase])\n print(tb)\n i = 0\n ans = []\n while i < len(A):\n ans.append(tb[i][1])\n i = tb[i][2]\n\n print(\"\".join(ans))\n", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. Find the shortest string among the strings consisting of lowercase English letters that are not subsequences of the given string. If there are multiple such strings, output the lexicographically smallest one.", "before_after_length": [296, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u197956883", "n_user": "u197956883", "pos": "import sys, re\nfrom math import ceil, floor, sqrt, pi, factorial, gcd\nfrom copy import deepcopy\nfrom collections import Counter, deque\nfrom heapq import heapify, heappop, heappush\nfrom itertools import accumulate, product, combinations, combinations_with_replacement\nfrom bisect import bisect, bisect_left, bisect_right\nfrom functools import reduce\nfrom decimal import Decimal, getcontext\n# input = sys.stdin.readline \ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\ndef lcm(a, b): return a * b // gcd(a, b)\nsys.setrecursionlimit(10 ** 6)\nINF = float('inf')\nMOD = 10 ** 9 + 7\nnum_list = []\nstr_list = []\n\ndef main():\n n = i_input()\n\n print('ABC' + str(n))\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys, re\nfrom math import ceil, floor, sqrt, pi, factorial, gcd\nfrom copy import deepcopy\nfrom collections import Counter, deque\nfrom heapq import heapify, heappop, heappush\nfrom itertools import accumulate, product, combinations, combinations_with_replacement\nfrom bisect import bisect, bisect_left, bisect_right\nfrom functools import reduce\nfrom decimal import Decimal, getcontext\n# input = sys.stdin.readline \ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)\ndef lcm(a, b): return a * b // gcd(a, b)\nsys.setrecursionlimit(10 ** 6)\nINF = float('inf')\nMOD = 10 ** 9 + 7\nnum_list = []\nstr_list = []\n\ndef main():\n n = i_input()\n\n print('ABC' + str(n))\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [382, 382], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u739360929", "n_user": "u796424048", "pos": "def solve():\n print(\"ABC\"+input())\n\n\nif __name__ == \"__main__\":\n solve()", "neg": "def solve():\n N = input()\n \n print ('ABC') + N\n\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 0.9333333333333333, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [28, 34], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u729133443", "n_user": "u635974378", "pos": "print(input('ABC'))", "neg": "print('ABC' input())", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [6, 6], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u730710086", "n_user": "u730710086", "pos": "# -*- coding: -*-\n\nn = input()\nprint(\"ABC\" + n)", "neg": "# -*- coding: -*-\n\nn = int(input())\nprint(\"ABC\" + 'n')", "jacc_sim": 0.9473684210526315, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [27, 30], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u884601206", "n_user": "u884601206", "pos": "s=int(input())\nprint('ABC'+str(s))\n", "neg": "s=int(input())\nprint('ABC'+s)\n", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [17, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u577138895", "n_user": "u857673087", "pos": "N = int(input())\nprint(\"ABC\", end = \"\")\nprint(N)", "neg": "N = int(input())\n\nprint('ABC'+ N, end='')", "jacc_sim": 0.9166666666666666, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [20, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u178432859", "n_user": "u667024514", "pos": "a = int(input())\nprint(\"ABC\" + str(a))", "neg": "a = int(input())\nprint(\"ABC\"+a)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [16, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(readline())\n\nprint('ABC' + str(N))\n\n\n\n\n", "neg": "import sys\n\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nN = int(readline())\n\nprint('ABC' + N)\n", "jacc_sim": 0.9444444444444444, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [62, 56], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u275934251", "n_user": "u265118937", "pos": "print(\"ABC{}\".format(int(input())))", "neg": "print(\"ABC{}\".format(int(input()))", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [12, 12], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u854093727", "n_user": "u074445770", "pos": "n = input()\n\nprint(\"ABC\"+n)\n", "neg": "n=input()\n print('ABC'+n)", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [14, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u807772568", "n_user": "u807772568", "pos": "i = int(input())\nprint(\"ABC\"+str(i))", "neg": "i = int(input())\nprint(\"ABC\"+i)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [16, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u221345507", "n_user": "u342051078", "pos": "N=int(input())\nprint('ABC'+str(N))", "neg": "N = int(input())\n\nprint(\"ABC\" + N)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [16, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u306142032", "n_user": "u306142032", "pos": "n = int(input())\n\nprint(\"ABC\" + str(n))\n", "neg": "n = int(input())\n\nprint(\"ABC\" + n)\n", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [18, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u632369368", "n_user": "u992910889", "pos": "N = input()\nprint('ABC{}'.format(N))\n", "neg": "N=str(inputN=input()\nprint('ABC{}'.format(N))", "jacc_sim": 0.9230769230769231, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [15, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u481113010", "n_user": "u185806788", "pos": "N = input()\nx = str('ABC' + str(N))\nprint(x)", "neg": "N=str(input())\nprint(\"ABC\"+\"N\")", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [21, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u697421413", "n_user": "u366959492", "pos": "n = int(input())\nprint(\"ABC\",n,sep = '')\n", "neg": "n=int(input())\nprint(\"ABC\",n)\n", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [17, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u018679195", "n_user": "u446687234", "pos": "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nprint('ABC'+input())", "neg": "print(\"ABC\" ++ input())", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [66, 7], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u231552419", "n_user": "u562016607", "pos": "print(\"ABC{0}\".format(input()))\n", "neg": "print(\"ABC{0}\".format(input())", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [13, 11], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u696449926", "n_user": "u546853743", "pos": "print('ABC',int(input()),sep='')", "neg": "n=int,input()\nprint('ABC',n,sep=\"\")\n", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [12, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u209209182", "n_user": "u353652911", "pos": "print(\"ABC\"+str(input()))\n", "neg": "print(\"ABC\"+str(input())", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [11, 9], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u796424048", "n_user": "u796424048", "pos": "N = int(input())\nprint ('ABC%d' %N)", "neg": "N = int(input())\nprint ('ABC %d' %N)\n", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [16, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u821262411", "n_user": "u480887263", "pos": "N=str(input())\nprint('ABC'+N)\n", "neg": "NN=str(input())\nprint(\"ABC\"+N)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [15, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u108617242", "n_user": "u677320550", "pos": "a = input()\nprint('ABC' + a)", "neg": "a=input()\nprint('ABC'\u3000+a)\n", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [12, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u676264453", "n_user": "u473023730", "pos": "a = str(input())\nprint(\"ABC\" + a)\n", "neg": "n=str(input())\na=\"ABC\"\nprint(n+a)", "jacc_sim": 0.9090909090909091, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [15, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03643", "p_user": "u255555420", "n_user": "u790877102", "pos": "N=(input())\nprint('ABC'+N)", "neg": "N = input()\n\nprint(\"ABC\" + \"N\")", "jacc_sim": 1.0, "nl": "You are tasked with creating a program to determine the abbreviation for the N-th round of the AtCoder Beginner Contest (ABC). The input will be an integer N (100 \u2264 N \u2264 999), and the program should output the abbreviation for the N-th round of ABC. For example, if the input is 100, the output should be ABC100.", "before_after_length": [12, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u188745744", "n_user": "u188745744", "pos": "from collections import deque\nN,M=list(map(int,input().split()))\nN_l=set()\none_l=set()\nfor i in range(M):\n A,B=list(map(int,input().split()))\n if A == 1:\n one_l.add(B)\n elif B==N:\n N_l.add(A)\nif len(N_l & one_l) > 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\n", "neg": "from collections import deque\nN,M=list(map(int,input().split()))\nN_l=set()\none_l=set()\nfor i in range(M):\n A,B=list(map(int,input().split()))\n if A == 1:\n one_l.add(B)\n elif B==N:\n N_l.add(A)\nif len(N_l & one_l) > 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIIBLE\")\n", "jacc_sim": 0.95, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [131, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u170765582", "n_user": "u170765582", "pos": "a,b=map(int,input().split())\nc=[list(map(int,input().split()))for i in[0]*b]\nd=[]\ne=[]\nfor i in c:\n if i[0]==1:d+=[i[1]]\n elif i[1]==a:e+=[i[0]]\nprint((set(d)&set(e)==set())*'IM'+'POSSIBLE')", "neg": "a,b=map(int,input().split())\nc=[list(map(int,input().split()))for i in[0]*b]\nd=[]\ne=[]\nfor i in c:\n if i[0]==1:d+=[i[1]]\n elif i[1]==a:e+=[i[0]]\nprint((set(d)&set(e)=={})*'IM'+'POSSIBLE')", "jacc_sim": 0.9428571428571428, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [106, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u497046426", "n_user": "u497046426", "pos": "N, M = map(int, input().split())\nfrom_1 = [False]*N\nto_N = [False]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if a == 1:\n from_1[b-1] = True\n elif b == N:\n to_N[a-1] = True\nfor i in range(1, N):\n if from_1[i] and to_N[i]:\n print('POSSIBLE')\n break\nelse:\n print('IMPOSSIBLE')", "neg": "N, M = map(int, input().split())\nfrom_1 = [False]*N\nto_N = [False]*N\nfor _ in range(M):\n a, b = map(int, input().split())\n if a-1 == 0:\n from_1[b-1] = True\n elif b-1 == 0:\n to_N[a-1] = True\nfor i in range(1, N):\n if from_1[i] and to_N[i]:\n print('POSSIBLE')\n break\nelse:\n print('IMPOSSIBLE')", "jacc_sim": 0.9736842105263158, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [141, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u450339194", "n_user": "u450339194", "pos": "from collections import defaultdict\n\nN, M = map(int, input().split())\n\nimport sys\n\nteiki = defaultdict(set)\nfor i in range(M):\n a, b = map(int, input().split())\n teiki[a].add(b)\n\n\nif 1 not in teiki:\n print('IMPOSSIBLE')\n sys.exit()\n\nfor i in teiki[1]:\n if i in teiki and N in teiki[i]:\n print('POSSIBLE')\n sys.exit()\n\nprint('IMPOSSIBLE')", "neg": "N, M = map(int, input().split())\n\nimport sys\n\nteiki = defaultdict(set)\nfor i in range(M):\n a, b = map(int, input().split())\n teiki[a].add(b)\n\n\nif 1 not in teiki:\n print('IMPOSSIBLE')\n sys.exit()\n\nfor i in teiki[1]:\n if i in teiki and N in teiki[i]:\n print('POSSIBLE')\n sys.exit()\n\nprint('IMPOSSIBLE')", "jacc_sim": 0.9459459459459459, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [140, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u118642796", "n_user": "u118642796", "pos": "N,M = map(int,input().split())\nab = [[int(i) for i in input().split()] for _ in range(M)]\n\nA = []\nB = [0]*(N+1)\nfor a,b in ab:\n if a==1:\n A.append(b)\n if b==N:\n B[a]=1\n\nfor a in A:\n if B[a]==1:\n print(\"POSSIBLE\")\n break\nelse:\n print(\"IMPOSSIBLE\")", "neg": "N,M = map(int,input().split())\nab = [[int(i) for i in input().split()] for _ in range(M)]\n\nA = []\nB = [0]*N\nfor a,b in ab:\n if a==1:\n A.append(a)\n if b==N:\n B[a]=1\n\nfor a in A:\n if B[a]==1:\n print(\"POSSIBLE\")\n break\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 0.9722222222222222, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [131, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u397531548", "n_user": "u397531548", "pos": "N,M=map(int,input().split())\nx=[0]*(N+1)\ny=[0]*(N+1)\nfor i in range(M):\n a,b=map(int,input().split())\n if a==1:\n x[b]=1\n if b==N:\n y[a]=1\nfor i in range(N+1):\n if x[i]==1 and y[i]==1:\n print(\"POSSIBLE\")\n break\nelse:\n print(\"IMPOSSIBLE\")", "neg": "N,M=map(int,input().split())\nx=[0]*(n+1)\ny=[0]*(n+1)\nfor i in range(M):\n a,b=map(int,input().split())\n if a==1:\n x[b]=1\n if b==N:\n y[a]=1\nfor i in range(N+1):\n if x[i]==1 and y[i]==1:\n print(\"POSSIBLE\")\n break\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 0.9714285714285714, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [136, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u064408584", "n_user": "u064408584", "pos": "n,m=map(int, input().split())\nx=set()\ny=set()\nfor i in range(m):\n a,b=map(int, input().split())\n if a==1:x.add(b)\n if b==n:y.add(a)\nif x&y:print('POSSIBLE')\nelse:print('IMPOSSIBLE')", "neg": "n,m=map(int, input().split())\nx=set()\ny=set()\nfor i in range(m):\n a,b=map(int, input().split())\n if a==1:x.add(b)\n if b==n:y.add(a)\nif x&y:print('POSSIBLE')\nelse:print('IMPOSSILE')", "jacc_sim": 0.9354838709677419, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [94, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u345076485", "n_user": "u345076485", "pos": "N,M=map(int,input().split())\na=[]\nb=[]\nfor i in range(0,M):\n\tc,d=map(int,input().split())\n\ta.append(c)\n\tb.append(d)\n\npos=0\ni=0\ng=[0 for i in range(0,200000)]\ne=[]\nf=[]\nk=0\nl=0\nwhile i < M and pos == 0:\n\tif a[i] == 1:\n\t\tg[b[i]] = 1\n\tif b[i] == 1:\n\t\tg[a[i]] = 1\n\ti=i+1\ni=0\nwhile i < M and pos == 0:\n\tif a[i] == N:\n\t\tif g[b[i]] == 1:\n\t\t\tpos=1\n\tif b[i] == N:\n\t\tif g[a[i]] == 1:\n\t\t\tpos=1\n\ti = i + 1\nif pos == 1:\n\tprint(\"POSSIBLE\")\nelse:\n\tprint(\"IMPOSSIBLE\")", "neg": "N,M=map(int,input().split())\na=[]\nb=[]\nfor i in range(0,M):\n\tc,d=map(int,input().split())\n\ta.append(c)\n\tb.append(d)\n\npos=0\ni=0\ng=[0 for i in range(0,M)]\nprint(g)\ne=[]\nf=[]\nk=0\nl=0\nwhile i < M and pos == 0:\n\tif a[i] == 1:\n\t\tg[b[i]] = 1\n\tif b[i] == 1:\n\t\tg[a[i]] = 1\n\ti=i+1\ni=0\nprint(g)\nwhile i < M and pos == 0:\n\tif a[i] == N:\n\t\tif g[b[i]] == 1:\n\t\t\tpos=1\n\tif b[i] == N:\n\t\tif g[a[i]] == 1:\n\t\t\tpos=1\n\ti = i + 1\nif pos == 1:\n\tprint(\"POSSIBLE\")\nelse:\n\tprint(\"IMPOSSIBLE\")", "jacc_sim": 0.9761904761904762, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [265, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u243370518", "n_user": "u243370518", "pos": "x = input().split(\" \")\nn = int(x[0])\nm = int(x[1])\n\nprobInit = set([])\nprobEnd = set([])\n\nfor i in range(m):\n edge = input().split(\" \")\n if edge[0] == \"1\":\n probInit.add(edge[1])\n\n if edge[1] == str(n):\n probEnd.add(edge[0])\n\nsec = probEnd.intersection(probInit)\nif (len(sec) == 0):\n print(\"IMPOSSIBLE\")\nelse:\n print(\"POSSIBLE\")\n", "neg": "x = input().split(\" \")\nn = int(x[0])\nm = int(x[1])\n\nprobInit = set([])\nprobEnd = set([])\n\nfor i in range(m):\n edge = input().split(\" \")\n if edge[0] == 0:\n probInit.add(edge[1])\n\n if edge[1] == n - 1:\n probEnd.add(edge[0])\n\nsec = probEnd.intersection(probInit)\nif (len(sec) == 0):\n print(\"IMPOSSIBLE\")\nelse:\n print(\"POSSIBLE\")\n", "jacc_sim": 0.9444444444444444, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [150, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u341087021", "n_user": "u677320550", "pos": "n, m = [int(x) for x in input().split()]\n\ns = [0]*(n+1)\nd = [0]*(n+1)\n\nfor i in range(m):\n\ta, b = [int(x) for x in input().split()]\n\tif a == 1:\n\t\ts[b] = 1\n\t\tif d[b] == 1:\n\t\t\tprint('POSSIBLE')\n\t\t\tbreak\n\telif b == n:\n\t\td[a] = 1\n\t\tif s[a] == 1:\n\t\t\tprint('POSSIBLE')\n\t\t\tbreak\nelse:\n\tprint('IMPOSSIBLE')", "neg": "n, m = [int(x) for x in input().split()]\n\n \nfor i in range(m):\n\ta, b = [int(x) for x in input().split()]\n\tif a == 1:\n\t\ts[b] = 1\n\t\tif d[b] == 1:\n\t\t\tprint('POSSIBLE')\n\t\t\tbreak\n\telif b == n:\n\t\td[a] = 1\n\t\tif s[a] == 1:\n\t\t\tprint('POSSIBLE')\n\t\t\tbreak\nelse:\n\tprint('IMPOSSIBLE')", "jacc_sim": 0.9117647058823529, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [164, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u781758937", "n_user": "u781758937", "pos": "N, M = map(int, input().split())\n\nA = set({})\nB = set({})\nfor j in range(M):\n tmp = []\n tmp = [int(i) for i in input().split()]\n if tmp[0] == 1:\n A.add(tmp[1])\n elif tmp[1] == N:\n B.add(tmp[0])\n\nif len(A.intersection(B)) > 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\n", "neg": "N, M = map(int, input().split())\n\nA = set({})\nB = set({})\nfor j in range(N-1):\n tmp = []\n tmp = [int(i) for i in input().split()]\n if tmp[0] == 1:\n A.add(tmp[1])\n elif tmp[1] == N:\n B.add(tmp[0])\n\nif len(A.intersection(B)) > 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\n", "jacc_sim": 0.9743589743589743, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [132, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u314057689", "n_user": "u314057689", "pos": "from collections import defaultdict as dd\ndef main():\n N, M = map(int, input().split())\n\n D = dd(list)\n\n for m in range(M):\n a, b = map(int, input().split())\n D[a-1].append(b-1)\n\n for d in D[0]:\n if N-1 in D[d]:\n print('POSSIBLE')\n return\n\n print('IMPOSSIBLE')\n \n\nif __name__ == \"__main__\":\n # global stime\n # stime = time.clock()\n main()", "neg": "from collections import defaultdict as dd\ndef main():\n N, M = map(int, input().split())\n\n D = dd(list)\n\n for m in range(M):\n a, b = map(int, input().split())\n D[a-1].append(b-1)\n\n for d in D.keys():\n if N-1 in D[d]:\n print('POSSIBLE')\n return\n\n print('IMPOSSIBLE')\n \n\nif __name__ == \"__main__\":\n # global stime\n # stime = time.clock()\n main()\n", "jacc_sim": 0.9591836734693877, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [148, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u190525112", "n_user": "u190525112", "pos": "a=[0]*(200001)\n\n\nN = list(map(int, input().split()))\nx = [list(map(int, input().split())) for i in range(N[1])]\n\n\nfor i in x:\n if i[0]==1 :\n if a[i[1]]==1:\n print('POSSIBLE')\n quit()\n a[i[1]]=1\n if i[1]==N[0]:\n if a[i[0]]==1:\n print('POSSIBLE')\n quit()\n a[i[0]]=1\n\nprint('IMPOSSIBLE')\nquit()", "neg": "a=[0]*(200001)\n\n\nN = list(map(int, input().split()))\nx = [list(map(int, input().split())) for i in range(N[1])]\n\nprint(N,x)\n\nfor i in x:\n if i[0]==1 :\n if a[i[1]]==1:\n print('POSSIBLE')\n quit()\n a[i[1]]=1\n if i[1]==N[0]:\n if a[i[0]]==1:\n print('POSSIBLE')\n quit()\n a[i[0]]=1\n\nprint('IMPOSSIBLE')\nquit()", "jacc_sim": 1.0, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [163, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u996252264", "n_user": "u996252264", "pos": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\n\nN, M = rli()\nkeiro = [[False for i in range(2)] for j in range(N+1)]\nfor i in range(M):\n a, b = rli()\n if(b == 1 or b == N):\n keiro[a][1 if b == 1 else 0] = True\n elif(a == 1 or a == N):\n keiro[b][1 if a == 1 else 0] = True\n\nflag = False\nfor i in range(2, N):\n if(keiro[i][1] and keiro[i][0]):\n flag = True\nif(flag):\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "neg": "def ri(): return int(input())\ndef rli(): return list(map(int, input().split()))\ndef ris(): return list(input())\ndef pli(a): return \"\".join(list(map(str, a)))\n\nN, M = rli()\nkeiro = [[False for i in range(N+1)] for j in range(N+1)]\nfor i in range(M):\n a, b = rli()\n keiro[a][b] = True\n keiro[b][a] = True\n\nflag = False\nfor i in range(N):\n if(keiro[i][1] and keiro[i][N]):\n flag = True\nif(flag):\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 0.9148936170212766, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [228, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03647", "p_user": "u532827876", "n_user": "u532827876", "pos": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\nimport sys\nimport math\n\nN, M = list(map(int, sys.stdin.readline().rstrip().split()))\n\n\nSs = set()\nEs = set()\nfor _ in range(M):\n a_orig, b_orig = list(map(int, sys.stdin.readline().rstrip().split()))\n for a, b in [(a_orig, b_orig), (b_orig, a_orig)]:\n if a== 1:\n Ss.add(b)\n if a == N:\n Es.add(b)\n\nif len(Ss.intersection(Es)):\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\nexit(0)\n", "neg": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\nimport sys\nimport math\n\nN, M = list(map(int, sys.stdin.readline().rstrip().split()))\n\n\nSs = set()\nEs = set()\nfor _ in range(M):\n a_orig, b_orig = list(map(int, sys.stdin.readline().rstrip().split()))\n for a, b in [(a_orig, b_orig), (b_orig, a_orig)]:\n if a== 1:\n Ss.add(b)\n if a == N:\n Es.add(b)\n\nif len(Ss and Es):\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\nexit(0)\n", "jacc_sim": 0.9636363636363636, "nl": "In the Takahashi Kingdom, there are N islands, named Island 1, Island 2, ..., Island N. There are M types of boat services connecting these islands. Cat Snuke is on Island 1 and wants to reach Island N using two boat services. Determine if this is possible. Constraints: 3 \u2264 N \u2264 200,000; 1 \u2264 M \u2264 200,000; 1 \u2264 a_i < b_i \u2264 N; (a_i, b_i) \u2260 (1, N); If i \u2260 j, (a_i, b_i) \u2260 (a_j, b_j). Input format: N M a_1 b_1 a_2 b_2 ... a_M b_M. Output \"POSSIBLE\" if it's possible, \"IMPOSSIBLE\" otherwise. Examples: (3 2, 1 2, 2 3) \u2192 POSSIBLE; (4 3, 1 2, 2 3, 3 4) \u2192 IMPOSSIBLE; (100000 1, 1 99999) \u2192 IMPOSSIBLE; (5 5, 1 3, 4 5, 2 3, 2 4, 1 4) \u2192 POSSIBLE.", "before_after_length": [201, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u923270446", "n_user": "u923270446", "pos": "import numpy as np\nI,S=input,sum\nn,c=int(I()),0\na=np.array(list(map(int, I().split())))\nwhile max(a)>=n:f=a//n;S=sum(f);a=a-f*n+(S-f);c+=sum(f)\nprint(c)", "neg": "import numpy as np\nI,S=input,sum\nn,c=int(I()),0\na=np.array(list(map(int, I().split())))\nwhile max(a)>=n:c+=S(a//n);a=a-a//n*n-(S(a//n)-a//n)\nprint(c)", "jacc_sim": 0.9696969696969697, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [88, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u844789719", "n_user": "u844789719", "pos": "N, *A = [int(_) for _ in open(0).read().split()]\nsumB = max(0, sum(A) - N * (N - 1))\nwhile True:\n B = [0 - (-(a + sumB + 1 - N)) // (N + 1) for a in A]\n if sumB == sum(B):\n break\n sumB += 1\nprint(sumB)\n", "neg": "N, *A = [int(_) for _ in open(0).read().split()]\nsumB = max(0, sum(A) - N * (N - 1))\nwhile True:\n B = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]\n if sumB == sum(B):\n break\n sumB += 1\nprint(sumB)\n", "jacc_sim": 0.9696969696969697, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [100, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u190405389", "n_user": "u190405389", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\nreadline = sys.stdin.buffer.readline\ndef readstr():return readline().rstrip().decode()\ndef readstrs():return list(readline().decode().split())\ndef readint():return int(readline())\ndef readints():return list(map(int,readline().split()))\ndef printrows(x):print('\\n'.join(map(str,x)))\ndef printline(x):print(' '.join(map(str,x)))\n\nfrom math import ceil\n\nn = readint()\na = readints()\n\nans = 0\nfor i in range(n):\n a.sort()\n if a[-1]n+1:\n x = ceil((a[-1]-a[0]-n-1)/(n+1))\n ans += x\n for j in range(n-1):\n a[j] += x\n a[-1] -= n*x\n a.sort()\nif a[-1]>n:\n ans += (a[0]-n+1)*n\n A = a[0]\n for i in range(n):\n a[i] -= A-n+1\n\nwhile a[-1]>=n:\n ans += 1\n for j in range(n-1):\n a[j]+=1\n a[-1]-=n\n a.sort()\n\nprint(ans)\n\n\n", "neg": "import sys\nsys.setrecursionlimit(10**7)\n\nreadline = sys.stdin.buffer.readline\ndef readstr():return readline().rstrip().decode()\ndef readstrs():return list(readline().decode().split())\ndef readint():return int(readline())\ndef readints():return list(map(int,readline().split()))\ndef printrows(x):print('\\n'.join(map(str,x)))\ndef printline(x):print(' '.join(map(str,x)))\n\nfrom math import ceil\n\nn = readint()\na = readints()\n\nans = 0\nfor i in range(n):\n a.sort()\n if a[-1]n+1:\n x = ceil((a[-1]-a[0]-n-1)/(n+1))\n ans += x\n for j in range(n-1):\n a[j] += x\n a[-1] -= n*x\n a.sort()\n\nans += (a[0]-n+1)*n\nA = a[0]\nfor i in range(n):\n a[i] -= A-n+1\n\nwhile a[-1]>=n:\n ans += 1\n for j in range(n-1):\n a[j]+=1\n a[-1]-=n\n a.sort()\n\nprint(ans)\n\n\n", "jacc_sim": 1.0, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [404, 393], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u316464887", "n_user": "u316464887", "pos": "import math\ndef main():\n n = int(input())\n l = list(map(int, input().split()))\n c = 0\n while max(l) > n-1:\n l.sort(reverse=True)\n tc = [0] * n\n for i in range(n):\n if l[i] >= n:\n tc[i] = math.ceil((l[i] - n + 1)/n)\n l[i] -= tc[i] * n\n stc = sum(tc)\n for i in range(n):\n l[i] += stc - tc[i]\n c += stc\n return c\nprint(main())\n", "neg": "import math\ndef main():\n n = int(input())\n l = list(map(int, input().split()))\n c = 0\n while max(l) > n-1:\n l.sort(reverse=True)\n tc = [0] * n\n for i in range(n):\n if l[i] >= n:\n tc[i] = math.ceil((l[i] - n + 1)/(n-1))\n l[i] -= tc[i] * n\n stc = sum(tc)\n for i in range(n):\n l[i] += stc - tc[i]\n c += stc\n return c\nprint(main())\n", "jacc_sim": 1.0, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [168, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u905582793", "n_user": "u905582793", "pos": "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\ncnt = [0]*n\nans = 0\nfor i in range(100000):\n j = i%n\n if a[j]=N:\n d=a[i]//N\n ans+=d\n a[i]%=N\n for j in range(N):\n if i!=j:\n a[j]+=d\n else:\n f+=1\n if f==N:\n break\nprint(ans)\n \n \n ", "neg": "N=int(input())\na=[int(i) for i in input().split()]\nans=0\nwhile True:\n f=0\n for i in range(N):\n if a[i]>N:\n ans+=a[i]//N\n a[i]%=N\n for j in range(N):\n if i!=j:\n a[j]+=1\n f=1\n break\n if f==0:\n break\nprint(ans)\n \n \n ", "jacc_sim": 0.9393939393939394, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [134, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03649", "p_user": "u280667879", "n_user": "u280667879", "pos": "from heapq import*\nn=int(input())\na=[-int(e)for e in input().split()]\nr=0\nheapify(a)\nwhile 1:\n\tx=heappop(a)\n\tif x>-n:break\n\tc=-x//n\n\tx+=c*n\n\tfor i in range(n-1):a[i]-=c\n\theappush(a,x)\n\tr+=c\nprint(r)", "neg": "from heapq import*\nn=int(input())\na=[-int(e)for e in input().split()]\nr=0\nheapify(a)\nwhile 1:\n\tx=heappop(a)\n\tif x>-n:break\n\tc=-x//n\n\tx+=c*n\n\tfor _ in range(n-1):a[i]-=c\n\theappush(a,x)\n\tr+=c\nprint(r)", "jacc_sim": 0.9743589743589743, "nl": "You are given a sequence of non-negative integers of length N. Perform an operation on the sequence until the largest element becomes N-1 or smaller. The operation involves decreasing the largest element by N and increasing all other elements by 1. Determine how many times this operation needs to be performed. Constraints: 2 \u2264 N \u2264 50, 0 \u2264 ai \u2264 10^16 + 1000. Input format: N followed by the sequence a1, a2, ..., aN. Output the number of times the operation will be performed.", "before_after_length": [115, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u023229441", "n_user": "u023229441", "pos": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\nyes=\"POSSIBLE\" ; no=\"IMPOSSIBLE\"\nimport numpy as np\nq= np.gcd.reduce(A)\nif k%q==0 and max(A)>=k:\n print(yes)\nelse:\n print(no)", "neg": "n,k=map(int,input().split())\nA=list(map(int,input().split()))\nyes=\"POSSIBLE\" ; no=\"IMPOSSIBLE\"\nimport numpy as np\nq= np.gcd.reduce(A)\nif k%q==0 and max(A)-min(A)>=k:\n print(yes)\nelse:\n print(no)", "jacc_sim": 0.9459459459459459, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [91, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u088863512", "n_user": "u088863512", "pos": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd, ceil, atan, pi\ndef input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\nimport string\n# string.ascii_lowercase\nfrom bisect import bisect_left, bisect_right\nfrom functools import lru_cache, reduce\nMOD = int(1e9)+7\nINF = float('inf')\n\n\ndef solve():\n # n = int(input())\n n, k = [int(x) for x in input().split()]\n a = [int(x) for x in input().split()]\n g = reduce(gcd, a)\n\n m = max(a)\n if k <= m and k % g == 0:\n print(\"POSSIBLE\")\n else:\n print(\"IMPOSSIBLE\")\n\nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\n1\n4\n-1 1 1 -1\n\n\"\"\"\n", "neg": "# -*- coding: utf-8 -*-\nimport sys\nfrom collections import deque, defaultdict\nfrom math import sqrt, factorial, gcd, ceil, atan, pi\ndef input(): return sys.stdin.readline()[:-1] # warning not \\n\n# def input(): return sys.stdin.buffer.readline().strip() # warning bytes\n# def input(): return sys.stdin.buffer.readline().decode('utf-8')\nimport string\n# string.ascii_lowercase\nfrom bisect import bisect_left, bisect_right\nfrom functools import lru_cache, reduce\nMOD = int(1e9)+7\nINF = float('inf')\n\n\ndef solve():\n # n = int(input())\n n, k = [int(x) for x in input().split()]\n a = [int(x) for x in input().split()]\n g = reduce(gcd, a)\n print(g)\n m = max(a)\n if k <= m and k % g == 0:\n print(\"POSSIBLE\")\n else:\n print(\"IMPOSSIBLE\")\n\nt = 1\n# t = int(input())\nfor case in range(1,t+1):\n ans = solve()\n\n\n\"\"\"\n1\n4\n-1 1 1 -1\n\n\"\"\"\n", "jacc_sim": 1.0, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [305, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u493520238", "n_user": "u493520238", "pos": "from math import gcd\n\nn,k = map(int, input().split())\nal = list(map(int, input().split()))\na_gcd = al[0]\nfor a in al[1:]:\n a_gcd = gcd(a_gcd,a)\n\nif k%a_gcd == 0 and k <= max(al):\n print('POSSIBLE')\nelse:\n print('IMPOSSIBLE')", "neg": "from math import gcd\n\nn,k = map(int, input().split())\nal = list(map(int, input().split()))\na_gcd = al[0]\nfor a in al[1:]:\n a_gcd = gcd(a_gcd,a)\n\nif k%a_gcd == 0:\n print('POSSIBLE')\nelse:\n print('IMPOSSIBLE')", "jacc_sim": 0.9166666666666666, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [107, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u266014018", "n_user": "u266014018", "pos": "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n def gcd(x,y):\n r = x%y\n if r==0:\n return y\n return gcd(y, r)\n\n n, k =map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n c = a[0]\n for i in range(n):\n c = gcd(a[i], c)\n if k%c == 0 and k <= a[0]:\n print('POSSIBLE')\n else:\n print('IMPOSSIBLE')\n \n\n \nif __name__ == '__main__':\n main()", "neg": "def main():\n import sys\n\n def input(): return sys.stdin.readline().rstrip()\n\n def gcd(x,y):\n r = x%y\n if r==0:\n return y\n return gcd(y, r)\n\n n, k =map(int, input().split())\n a = list(map(int, input().split()))\n a.sort(reverse=True)\n c = a[0]\n for i in range(n):\n c = gcd(a[i], c)\n if k%c == 0:\n print('POSSIBLE')\n else:\n print('IMPOSSIBLE')\n \n\n \nif __name__ == '__main__':\n main()", "jacc_sim": 0.9583333333333334, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [187, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u935558307", "n_user": "u935558307", "pos": "import sys\nsys.setrecursionlimit(200000)\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\ndef gcd(a,b):\n return a if b==0 else gcd(b,a%b)\ng = A[0]\nfor i in range(1,N):\n g = gcd(g,A[i])\nif K > max(A):\n print(\"IMPOSSIBLE\")\n exit()\nif K % g == 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "neg": "import sys\nsys.setrecursionlimit(200000)\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\ndef gcd(a,b):\n return a if b==0 else gcd(b,a%b)\ng = gcd(A[0],A[1])\nfor i in range(2,N):\n g = gcd(g,A[i])\nif K % g == 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 0.9069767441860465, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [145, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u871841829", "n_user": "u871841829", "pos": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nP = \"POSSIBLE\"\nIP = \"IMPOSSIBLE\"\n\nM = max(A)\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n return gcd(b%a, a)\n\nt = gcd(A[0], A[0])\nif N > 1:\n for a in A[1:]:\n t = gcd(t, a)\n\nif K%t == 0 and K <= M:\n print(P)\nelse:\n print(IP)", "neg": "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nP = \"POSSIBLE\"\nIP = \"IMPOSSIBLE\"\n\nA.sort()\n\ndef gcd(a, b):\n if a == 0:\n return b\n else:\n gcd(b, b%a)\n\nt = gcd(A[1], A[0])\nif N <= 2:\n for a in A[2:]:\n t = gcd(t, a)\n\nif K%t == 0 and K <= M:\n print(P)\nelse:\n print(IP)", "jacc_sim": 0.9047619047619048, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [157, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u285891772", "n_user": "u285891772", "pos": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7 \n#mod = 998244353\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\nN, K = MAP()\nA = LIST()\n\nG = A[0]\n\nfor i in range(1, N+1):\n\tG = gcd(G, A[i-1])\n\tif G == 1:\n\t\tbreak\n\nif K%G == 0 and K <= max(A):\n\tprint(\"POSSIBLE\")\nelse:\n\tprint(\"IMPOSSIBLE\")", "neg": "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return map(int, input().split())\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return zip(*(MAP() for _ in range(n)))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7 \n#mod = 998244353\nfrom decimal import *\n#import numpy as np\n#decimal.getcontext().prec = 10\n\n\nN, K = MAP()\nA = LIST()\n\ng = A[0]\n\nfor x in A:\n\tg = gcd(g, x)\n\n\nif K%g == 0 and g <= max(A):\n\tprint(\"POSSIBLE\")\nelse:\n\tprint(\"IMPOSSIBLE\")", "jacc_sim": 0.9396551724137931, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [356, 337], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u974792613", "n_user": "u974792613", "pos": "def gcd(a, b):\n return gcd(b, a % b) if b > 0 else a\n\n\nn, k = map(int, input().split())\na = list(map(int, input().split()))\n\nm = max(a)\n\ng = a[0]\n\nfor i in range(n):\n g = gcd(g, a[i])\n\nif k > m:\n print(\"IMPOSSIBLE\")\nelif k % g == 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\n", "neg": "def gcd(a, b):\n return gcd(b, a % b) if b > 0 else a\n\n\nn, k = map(int, input().split())\na = list(map(int, input().split())\n \nm = max(a)\n \ng = a[0]\n \nfor i in range(n):\n g = gcd(g, a[i])\n\nif k > m:\n print(\"IMPOSSIBLE\")\nelif k % g == 0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")\n\n", "jacc_sim": 1.0, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [139, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u693974737", "n_user": "u693974737", "pos": "def gcd(a, b):\n if b == 0: return a\n return gcd(b, a % b)\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\ng = arr[0]\nfor e in arr[1:]:\n g = gcd(g, e)\n\nif k <= max(arr) and k//g*g == k:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "neg": "def gcd(a, b):\n if a == 0: return b\n if b == 0: return a\n return gcd(a % b, b % a)\n\nn, k = map(int, input().split())\narr = list(map(int, input().split()))\ng = arr[0]\nfor e in arr[1:]:\n g = gcd(g, e)\n\nif k <= max(arr) and k//g*g == k:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 1.0, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [121, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u852690916", "n_user": "u852690916", "pos": "N,K=map(int, input().split())\n*A,=map(int, input().split())\ndef gcd(a,b):\n while b: a,b=b,a%b\n return a\ng=0\nfor a in A: g=gcd(g,a)\nprint('POSSIBLE' if K%g==0 and K<=max(A) else 'IMPOSSIBLE')", "neg": "N,K=map(int, input().split())\n*A,=map(int, input().split())\ndef gcd(a,b):\n while b: a,b=b,a%b\n return a\ng=0\nfor a in A: g=gcd(g,a)\nprint('POSSIBLE' if K%g==0 else 'IMPOSSIBLE')", "jacc_sim": 0.9117647058823529, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [100, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u489959379", "n_user": "u489959379", "pos": "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\n\ndef resolve():\n n, k = map(int, input().split())\n A = sorted(list(map(int, input().split())))\n\n if k in set(A):\n print(\"POSSIBLE\")\n exit()\n\n if k > A[-1]:\n print(\"IMPOSSIBLE\")\n exit()\n\n if n == 1:\n print(\"IMPOSSIBLE\")\n exit()\n\n g = A[0]\n for i in range(1, n):\n g = gcd(g, A[i])\n\n if k % g == 0:\n print(\"POSSIBLE\")\n else:\n print(\"IMPOSSIBLE\")\n\n\nif __name__ == '__main__':\n resolve()\n", "neg": "import sys\n\nsys.setrecursionlimit(10 ** 7)\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef gcd(a, b):\n while b != 0:\n a, b = b, a % b\n return a\n\n\ndef resolve():\n n, k = map(int, input().split())\n A = list(map(int, input().split()))\n\n if k in set(A):\n print(\"POSSIBLE\")\n exit()\n\n if k > A[-1]:\n print(\"IMPOSSIBLE\")\n exit()\n\n if n == 1:\n print(\"IMPOSSIBLE\")\n exit()\n\n g = A[0]\n for i in range(1, n):\n g = gcd(g, A[i])\n\n if k % g == 0:\n print(\"POSSIBLE\")\n else:\n print(\"IMPOSSIBLE\")\n\n\nif __name__ == '__main__':\n resolve()\n", "jacc_sim": 0.9824561403508771, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [251, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u896741788", "n_user": "u896741788", "pos": "n,k=map(int,input().split())\nl=sorted(map(int,input().split()))\ndef gcd(x,y):\n if y==0:return x\n return gcd(y,x%y)\nans=\"\"\ns=0\nfor i in l:\n s=gcd(i,s)\n if s==1:break\nelse:\n if k%s!=l[-1]%s:\n ans=\"IM\"\nif l[-1]m:\n a=n\n b=m\n else:\n a=m\n b=n\n while b!=0:\n a,b=b,a%b\n return a\ng=l[0]\nmax=l[0]\nfor i in range(1,1+n-1):\n g=gcd(g,l[i])\n if max=k:\n print('POSSIBLE')\n exit()\nelse:\n if k in a:\n print('POSSIBLE')\n exit()\n if k%t==0 and max(a)>=k:\n print('POSSIBLE')\n exit()\nprint('IMPOSSIBLE')\n", "neg": "from functools import reduce\nn,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a, b):\n while a != 0:\n a,b=b%a,a\n return b\ndef lcm(x, y):\n return (x * y)//gcd(x, y)\nt=reduce(lcm,a)\nif t==1:\n if max(a)>=k:\n print('POSSIBLE')\n exit()\nelse:\n if k in a:\n print('POSSIBLE')\n exit()\n if k%t==0:\n print('POSSIBLE')\n exit()\nprint('IMPOSSIBLE')\n", "jacc_sim": 0.9772727272727273, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [189, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u845333844", "n_user": "u845333844", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\nif n==1:\n x=a[0]\nelse:\n x=gcd(a[0],a[1])\n for i in range(2,n):\n x=gcd(x,a[i])\n\nif max(a)>=k and k%x==0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n if b==0:\n return a\n else:\n return gcd(b,a%b)\n\nif n==1:\n x=a[0]\nelse:\n x=gcd(a[0],a[1])\n for i in range(2,n):\n x=gcd(x,a[i])\n\nif max(a)>=k and k%g==0:\n print(\"POSSIBLE\")\nelse:\n print(\"IMPOSSIBLE\")", "jacc_sim": 0.9743589743589743, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [156, 156], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03651", "p_user": "u143492911", "n_user": "u143492911", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\nans=a[0]\nfor i in range(1,n):\n ans=gcd(ans,a[i])\nif k%ans==0:\n if k<=max(a):\n print(\"POSSIBLE\")\n exit()\nprint(\"IMPOSSIBLE\")\n", "neg": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ndef gcd(a,b):\n while b!=0:\n a,b=b,a%b\n return a\nans=a[0]\nfor i in range(1,n):\n ans=gcd(ans,a[i])\nif ans%k==0:\n if k0:\n a,b = b,a\n b %= a\n return a\n\ndef main():\n N,K = LI()\n a = LI()\n if max(a) < K:\n return 'IMPOSSIBLE'\n if K in a:\n return 'POSSIBLE'\n t = a[0]\n for c in a[1:]:\n t = gcd(c, t)\n if t <= 1:\n return 'POSSIBLE'\n for c in a:\n if (c > K) and (((c-K) % t) == 0):\n return 'POSSIBLE'\n\n return 'IMPOSSIBLE'\n\n\nprint(main())\n\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\ndef main():\n N,K = LI()\n a = LI()\n if max(a) < K:\n return 'IMPOSSIBLE'\n if K in a:\n return 'POSSIBLE'\n t = a[0]\n #for i in range(1,N):\n # t = math.gcd(a[i], t)\n if t <= 1:\n return 'POSSIBLE'\n for c in a:\n if (c > K) and (((c-K) % t) == 0):\n return 'POSSIBLE'\n\n return 'IMPOSSIBLE'\n\n\nprint(main())\n\n\n\n", "jacc_sim": 0.9333333333333333, "nl": "You are given a box with N balls, each labeled with an integer Ai. You can repeatedly perform the following operation: take out two balls, then return them to the box along with a new ball labeled with the absolute difference of the integers on the two balls. Determine if it's possible to reach a state where the box contains a ball labeled with integer K. Constraints: 1 \u2264 N \u2264 10^5, 1 \u2264 Ai \u2264 10^9, 1 \u2264 K \u2264 10^9. Input format: N K followed by A1 A2 ... AN. Output \"POSSIBLE\" if reaching the state is possible, \"IMPOSSIBLE\" otherwise. Example: Input 3 7, 9 3 4. Output: \"POSSIBLE\" as it's possible to reach 7.", "before_after_length": [374, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u426108351", "n_user": "u426108351", "pos": "n, m = map(int, input().split())\na = [list(map(int, input().split())) for i in range(n)]\nfor i in range(n):\n a[i].reverse()\n\nans = n\nused = set()\nfor i in range(m):\n count = [0]*(m+1)\n for j in range(n):\n count[a[j][-1]] += 1\n\n ans = min(max(count), ans)\n num = count.index(max(count))\n used.add(num)\n for j in range(n):\n while len(a[j]) > 0:\n if a[j][-1] in used:\n a[j].pop()\n else:\n break\n\nprint(ans)\n", "neg": "n, m = map(int, input().split())\na = [list(map(int, input().split())) for i in range(n)]\nfor i in range(n):\n a[i].reverse()\n\nans = n\nused = set()\nfor i in range(m):\n count = [0]*(m+1)\n for j in range(n):\n count[a[j][-1]] += 1\n\n ans = min(max(count), ans)\n num = count.index(max(count))\n used.add(num)\n for j in range(n):\n while True:\n if a[j][-1] in used:\n a[j].pop()\n else:\n break\n\nprint(ans)\n", "jacc_sim": 0.9333333333333333, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [191, 184], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u476604182", "n_user": "u476604182", "pos": "N, M, *X = map(int, open(0).read().split())\nA = []\nfor a in zip(*[iter(X)]*M):\n A.append(a)\nlog = set(range(1,M+1))\nans = []\nwhile log:\n dic = {}\n for i in range(N):\n for j in range(M):\n if A[i][j] in log:\n dic[A[i][j]] = dic.get(A[i][j],0)+1\n break\n ans.append(max(dic.values()))\n c = max(dic.keys(),key=lambda x:dic[x])\n log.remove(c)\nprint(min(ans))", "neg": "N, M, *X = map(int, open('0').read().split())\nA = []\nfor a in zip(*[iter(X)]*M):\n A.append(a)\nlog = set(range(1,M+1))\nans = N\nwhile log:\n dic = {}\n for i in range(N):\n for j in range(M):\n if A[i][j] in log:\n dic[A[i][j]] = dic.get(A[i][j],0)+1\n break\n ans = min(ans,max(dic.values()))\n c = max(dic.keys(),key=lambda x:dic[x])\n log.remove(c)\nprint(ans)", "jacc_sim": 0.9803921568627451, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [175, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u102445737", "n_user": "u102445737", "pos": "from sys import stdout\nprintn = lambda x: stdout.write(str(x))\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True and False\nBIG = 999999999\nR = 10**9 + 7\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ndef foo(x):\n b = []\n for i in range(n):\n b.append([y for y in a[i]])\n #ddprint(b)\n cnt = 0\n rem = [False]*m\n while cntx:\n ok = False\n rem[j] = True\n cnt += 1\n if cnt==m:\n return False\n if ok:\n return True\n for i in range(n):\n while len(b[i])>0 and rem[b[i][-1]]:\n b[i].pop()\n return True\n\nn,m = inm()\na = []\nfor i in range(n):\n aa = inl()\n aa = [x-1 for x in aa]\n aa.reverse()\n a.append(aa)\n\nddprint(a)\nmx = n\nmn = 0\nwhile mx>mn+1:\n mid = (mx+mn)//2\n if foo(mid):\n mx = mid\n else:\n mn = mid\nprint(mx)\n", "neg": "from sys import stdout\nprintn = lambda x: stdout.write(str(x))\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 999999999\nR = 10**9 + 7\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ndef foo(x):\n b = []\n for i in range(n):\n b.append([x for x in a[i]])\n cnt = 0\n rem = [False]*m\n while cntx:\n ok = False\n rem[j] = True\n cnt += 1\n if cnt==n:\n return False\n if ok:\n return True\n for i in range(n):\n while len(b[i])>0 and rem[b[i][-1]]:\n b[i].pop()\n return True\n\nn,m = inm()\na = []\nfor i in range(m):\n aa = inl()\n aa = [x-1 for x in aa]\n aa.reverse()\n a.append(aa)\nmx = n\nmn = 0\nwhile mx>mn+1:\n mid = (mx+mn)//2\n if foo(mid):\n mx = mid\n else:\n mn = mid\nprint(mx)\n", "jacc_sim": 0.926829268292683, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [466, 413], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u375616706", "n_user": "u375616706", "pos": "from collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\nN, M = map(int, input().split())\nmat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]\n\nans = N\nQ = [set([v for v in range(M)])]\nwhile Q:\n C = Counter()\n sports_cand = Q.pop(0)\n for n in range(N):\n for m in range(M):\n if mat[n][m] in sports_cand:\n C[mat[n][m]] += 1\n break\n tmp = 0\n for key, val in C.most_common():\n if val > tmp:\n tmp = val\n ans = min(ans, val)\n if len(sports_cand) > 2:\n Q.append(sports_cand-{key})\n else:\n break\nprint(ans)\n", "neg": "from collections import Counter\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\n\nN, M = map(int, input().split())\nmat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]\n\nans = N\nQ = [set([v for v in range(M)])]\nwhile Q:\n C = Counter()\n sports_cand = Q.pop(0)\n for n in range(N):\n for m in range(M):\n if mat[n][m] in sports_cand:\n C[mat[n][m]] += 1\n break\n tmp = 0\n for key, val in C.most_common():\n if val >= tmp:\n ans = min(ans, val)\n if len(sports_cand) > 2:\n Q.append(sports_cand-{key})\n else:\n break\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [246, 241], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u415905784", "n_user": "u415905784", "pos": "N, M = map(int, input().split())\nA = [[0 for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n A[i] = [int(x) - 1 for x in input().split()]\nS = [[0, i] for i in range(M)]\nfor a in A:\n S[a[0]][0] += 1\nminmax = N\nfor _ in range(M - 1):\n _S = sorted(S, reverse=True)\n s = _S[0][1]\n minmax = min(S[s][0], minmax)\n S[s][0] = -1\n for a in A:\n if S[a[0]][0] > 0:\n continue\n while S[a[0]][0] < 0:\n a.pop(0)\n S[a[0]][0] += 1\nprint(minmax)", "neg": "N, M = map(int, input().split())\nA = [[0 for _ in range(M)] for _ in range(N)]\nfor i in range(N):\n A[i] = [int(x) - 1 for x in input().split()]\nS = [[0, i] for i in range(M)]\nfor a in A:\n S[a[0]][0] += 1\nminmax = N\nfor _ in range(M - 1):\n _S = sorted(S, reverse=True)\n s = _S[0][1]\n minmax = min(S[s][0], minmax)\n S[s][0] = -1\n for a in A:\n while S[a[0]][0] < 0:\n a.pop(0)\n S[a[0]][0] += 1\nprint(minmax)", "jacc_sim": 0.926829268292683, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [226, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u062147869", "n_user": "u062147869", "pos": "import sys\ninput = sys.stdin.readline\nN,M=map(int,input().split())\nA=[[int(i)-1 for i in input().split()] for i in range(N)]\nL=set()\n#print(A)\ndef f(L):\n K=[0]*M\n for i in range(N):\n for j in range(M):\n if A[i][j] not in L:\n K[A[i][j]]+=1\n break\n a=0\n b=0\n for i in range(M):\n if amax(ma):\n ans=max(ma)\n mi=ma.index(max(ma))+1\n for j in range(n):\n k[j].remove(mi)\nif m==1:\n print(n)\nelse:\n print(ans)\n \n", "neg": "n,m=map(int,input().split())\nk=[[0]*m for i in range(n)]\nfor i in range(n):\n k[i]=list(map(int,input().split()))\nans=1000\nfor i in range(m-1):\n ma=[0]*m\n mi=-1\n for j in range(n):\n ma[k[j][0]]+=1\n if ans>max(ma):\n ans=max(ma)\n mi=ma.index(max(ma))+1\n for j in range(n):\n k[j].remove(mi)\nprint(ans)\n \n", "jacc_sim": 0.972972972972973, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [176, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u201234972", "n_user": "u201234972", "pos": "from collections import Counter\nN, M = map( int, input().split())\nA = [ [] for _ in range(N)]\nfor i in range(N):\n A[i] = list( map( int, input().split())) \nV = [1]*(M+1)\nans = N\nfor _ in range(M-1):\n W = []\n for i in range(N):\n while True:\n if V[A[i][0]] == 1:\n W.append(A[i][0])\n break\n else:\n A[i].pop(0)\n a, c = Counter(W).most_common()[0]\n ans = min( ans, c)\n V[a] = 0\nprint(ans)\n", "neg": "from collections import Counter\nN, M = map( int, input().split())\nA = [ [] for _ in range(N)]\nfor i in range(N):\n A[i] = list( map( int, input().split())) \nV = [1]*(M+1)\nans = N\nfor _ in range(M-1):\n W = []\n for i in range(N):\n while A[i]:\n a = A[i].pop(0)\n if V[a] == 1:\n W.append(a)\n if not W:\n break\n a, c = Counter(W).most_common()[0]\n ans = min( ans, c)\n V[a] = 0\nprint(ans)", "jacc_sim": 0.9347826086956522, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [184, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u624475441", "n_user": "u624475441", "pos": "from collections import Counter\nfrom operator import itemgetter\n\ndef sub(prefers, canceled):\n res = Counter()\n for pref in prefers:\n pt = -1\n while pref[pt] in canceled:\n pt -= 1\n res[pref[pt]] += 1\n return max(res.items(), key=itemgetter(1))\n\ndef solve(m, prefers):\n canceled = set()\n ans = float('inf')\n for _ in [0] * m:\n s, c = sub(prefers, canceled)\n canceled.add(s)\n ans = min(ans, c)\n return ans\n\nif __name__ == '__main__':\n N, M = map(int, input().split())\n A = [list(map(int, input().split()))[::-1] for _ in [0] * N]\n print(solve(M, A))", "neg": "from collections import Counter\nfrom operator import itemgetter\n\ndef sub(prefers, canceled):\n res = Counter()\n for pref in prefers:\n p = pref[-1]\n while p in canceled:\n pref.pop()\n p = pref[-1]\n res[p] += 1\n return max(res.items(), key=itemgetter(1))\n\ndef solve(m, prefers):\n canceled = set()\n ans = float('inf')\n for _ in [0] * m:\n s, c = sub(prefers, canceled)\n canceled.add(s)\n ans = min(ans, c)\n return ans\n\nif __name__ == '__main__':\n N, M = map(int, input().split())\n A = [list(map(int, input().split()))[::-1] for _ in [0] * N]\n print(solve(M, A))", "jacc_sim": 0.9491525423728814, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [215, 221], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03652", "p_user": "u594567187", "n_user": "u594567187", "pos": "def dfs(people, sports, use_sports, answer):\n rank = [0 for n in range(sports)]\n for p in range(people):\n for s in (preference[p]):\n if s in use_sports:\n rank[s] += 1\n break\n will_delete = []\n max_p = max(rank)\n exclude = rank.index(max_p)\n if len(use_sports) > 1:\n answer = min(answer, dfs(people, sports, use_sports - {exclude}, answer))\n answer = min(answer, max_p)\n return answer\n\npeople, sports = (int(n) for n in input().split(\" \"))\npreference = []\nfor _ in range(people):\n pre = [int(n) - 1 for n in input().split(\" \")]\n preference.append(pre)\nanswer = float(\"inf\")\nuse_sports = {n for n in range(sports)}\nprint(dfs(people, sports, use_sports, answer))\n", "neg": "def dfs(people, sports, use_sports, answer):\n rank = [0 for n in range(sports)]\n for p in range(people):\n for s in (preference[p]):\n if s in use_sports:\n rank[s] += 1\n break\n will_delete = []\n max_p = max(rank)\n exclude = rank.index(max_p)\n answer = min(answer, max_p, dfs(people, sports, use_sports - {exclude}, answer))\n return answer\n\npeople, sports = (int(n) for n in input().split(\" \"))\npreference = []\nfor _ in range(people):\n pre = [int(n) for n in input().split(\" \")]\n preference.append(pre)\nanswer = float(\"inf\")\nuse_sports = {n for n in range(sports)}\nprint(dfs(people, sports, use_sports, answer))\n", "jacc_sim": 0.9591836734693877, "nl": "Takahashi is organizing a sports event with N participants and M sports options. Each person has a favorite sport, and they will only participate in their favorite sport among those selected for the event. Takahashi wants to minimize the number of participants in the most popular sport. The task is to find the minimum number of participants in the most popular sport. Constraints: 1 \u2264 N \u2264 300, 1 \u2264 M \u2264 300, and the favorite sports are permutations of integers from 1 to M. The input consists of N, M, and the favorite sports for each person. The output should be the minimum number of participants in the most popular sport. Two sample inputs and outputs are provided.", "before_after_length": [255, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u657913472", "n_user": "u729133443", "pos": "from networkx import*\n(N,),*t=[s.split()for s in open(0)]\nG=Graph()\nG.add_edges_from(t)\ns=shortest_path_length\nx=s(G,'1')\ny=s(G,N)\nprint('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(N)::2])", "neg": "from networkx import*\nN,*t=map(str.split,open(0))\ns=shortest_path_length\nx=s(G:=Graph(t),'1')\ny=s(G,N)\nprint('FSennunkeec'[sum(x[k]>y[k]for k in x)*2>=int(*N)::2])", "jacc_sim": 0.918918918918919, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [103, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u691018832", "n_user": "u691018832", "pos": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import deque\n\n\ndef bfs(s, flag):\n if flag:\n global check\n else:\n check = [-1] * (n + 1)\n cnt = 0\n ans = 0\n q = deque([s, cnt])\n while q:\n now = q.popleft()\n cnt = q.popleft()\n check[now] = cnt\n ans += 1\n for next in graph[now]:\n if flag:\n if check[next] > cnt + 1:\n q.append(next)\n q.append(cnt + 1)\n else:\n if check[next] == -1:\n q.append(next)\n q.append(cnt + 1)\n if flag:\n return ans\n else:\n return check\n\n\nn = int(readline())\ngraph = [[] for _ in range(n + 1)]\nfor i in range(n - 1):\n a, b = map(int, readline().split())\n graph[a].append(b)\n graph[b].append(a)\ncheck = bfs(1, False)\nprint('Snuke' if bfs(n, True) >= n / 2 else 'Fennec')\n", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\nfrom collections import deque\n\n\ndef bfs(s, flag):\n if flag:\n global check\n else:\n check = [-1] * (n + 1)\n cnt = 0\n q = deque([s, cnt])\n ans = 0\n while q:\n now = q.popleft()\n cnt = q.popleft()\n check[now] = cnt\n ans += 1\n for next in graph[now]:\n if flag:\n if check[next] > cnt + 1:\n q.append(next)\n q.append(cnt + 1)\n else:\n if check[next] == -1:\n q.append(next)\n q.append(cnt + 1)\n if flag:\n return ans\n else:\n return check\n\n\nn = int(readline())\ngraph = [[] for _ in range(n + 1)]\nfor i in range(n - 1):\n a, b = map(int, readline().split())\n graph[a].append(b)\n graph[b].append(a)\ncheck = bfs(1, False)\nprint('Sunuke' if bfs(n, True) > n / 2 else 'Fennec')\n", "jacc_sim": 0.9692307692307692, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [344, 344], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u547167033", "n_user": "u547167033", "pos": "n=int(input())\ntree=[[] for i in range(n)]\nfor i in range(n-1):\n a,b=map(int,input().split())\n tree[a-1].append(b-1)\n tree[b-1].append(a-1)\ndef dist(k):\n l=[-1]*n\n node=[k]\n while node:\n s=node.pop()\n d=l[s]\n for t in tree[s]:\n if l[t]!=-1:\n continue\n l[t]=d+1\n node.append(t)\n return l\nfrom_fennec=dist(0)\nfrom_snuke=dist(n-1)\nres=0\nfor i,j in zip(from_fennec,from_snuke):\n if i<=j:\n res+=1\n else:\n res-=1\nprint('Snuke' if res<=0 else 'Fennec')", "neg": "n=int(input())\ntree=[[] for i in range(n)]\nfor i in range(n-1):\n a,b=map(int,input().split())\n tree[a-1].append(b-1)\n tree[b-1].append(a-1)\ndef dist(k):\n l=[-1]*n\n node=[k]\n while node:\n s=node.pop()\n d=l[s]\n for t in tree[s]:\n if l[t]!=-1:\n continue\n l[t]=d+1\n node.append(t)\n return l\nfrom_fennec=dist(0)\nfrom_snuke=dist(n-1)\nres=0\nfor i,j in zip(from_fennec,from_snuke):\n if i>=j:\n res+=1\n else:\n res-=1\nprint('Snuke' if res>=0 else 'Fennec')", "jacc_sim": 0.9615384615384616, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [245, 245], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u426108351", "n_user": "u426108351", "pos": "import sys\ninput = sys.stdin.readline\nN = int(input())\ntree = [[] for i in range(N+1)]\n\nfor i in range(N-1):\n a, b = map(int, input().split())\n tree[a].append(b)\n tree[b].append(a)\n\ndist_fennec = [100001] * (N+1)\ndist_snuke = [100001] * (N+1)\nq = [1]\ndist_fennec[1] = 0\nwhile q:\n now = q.pop()\n for next in tree[now]:\n if dist_fennec[next] == 100001:\n dist_fennec[next] = dist_fennec[now] + 1\n q.append(next)\n\nq = [N]\ndist_snuke[N] = 0\nwhile q:\n now = q.pop()\n for next in tree[now]:\n if dist_snuke[next] == 100001:\n dist_snuke[next] = dist_snuke[now] + 1\n q.append(next)\n\nfennec, snuke = 0, 0\nfor i in range(1, N+1):\n if dist_snuke[i] >= dist_fennec[i]:\n fennec += 1\n else:\n snuke += 1\n\nif fennec > snuke:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")\n", "neg": "import sys\ninput = sys.stdin.readline\nN = int(input())\ntree = [[] for i in range(N+1)]\n\nfor i in range(N-1):\n a, b = map(int, input().split())\n tree[a].append(b)\n tree[b].append(a)\n\ndist_fennec = [100001] * (N+1)\ndist_snuke = [100001] * (N+1)\nq = [1]\ndist[1] = 0\nwhile q:\n now = q.pop()\n for next in tree[now]:\n if dist_fennec[next] == 100001:\n dist_fennec[next] = dist_fennec[now] + 1\n q.append(next)\n\nq = [N]\ndist[N] = 0\nwhile q:\n now = q.pop()\n for next in tree[now]:\n if dist_snuke[next] == 100001:\n dist_snuke[next] = dist_snuke[now] + 1\n q.append(next)\n\nfennec, snuke = 0, 0\nfor i in range(1, N+1):\n if dist_snuke[i] <= dist_fennec[i]:\n fennec += 1\n else:\n snuke += 1\n\nif fennec > snuke:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")\n", "jacc_sim": 0.9591836734693877, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [371, 363], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u785578220", "n_user": "u785578220", "pos": "n = int(input())\nedges = [[] for _ in range(n)]\n \nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\ndp = [0]*n\ndp[0] =1\nfp = [0]*n\nfp[n-1] =1\ndef bfs(u):\n q = []\n q.append(u)\n while q:\n p = q.pop()\n for i in edges[p]:\n if dp[i] ==0 :\n q.append(i)\n dp[i]+=dp[p]+1\ndef ffs(u):\n q = []\n q.append(u)\n while q:\n p = q.pop()\n for i in edges[p]:\n if fp[i] ==0 :\n q.append(i)\n fp[i]+=fp[p]+1\nbfs(0)\nffs(n-1)\nc = 0\nfor i in range(n):\n if dp[i] <= fp[i]:\n c += 1\nif 2*c > n:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")", "neg": "n = int(input())\nedges = [[] for _ in range(n)]\n \nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\ndp = [0]*n\ndp[0] =1\nfp = [0]*n\nfp[n-1] =1\ndef bfs(u):\n q = []\n q.append(u)\n while q:\n p = q.pop()\n for i in edges[p]:\n if dp[i] ==0 :\n q.append(i)\n dp[i]+=dp[p]+1\ndef ffs(u):\n q = []\n q.append(u)\n while q:\n p = q.pop()\n for i in edges[p]:\n if fp[i] ==0 :\n q.append(i)\n fp[i]+=fp[p]+1\nbfs(0)\nffs(n-1)\nc = 0\nfor i in range(n):\n if dp[i] <= fp[i]:\n c += 1\nif 2*c > n:\n print(\"Snuke\")\nelse:\n print(\"Fennec\")", "jacc_sim": 1.0, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [318, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u572144347", "n_user": "u572144347", "pos": "N=int(input())\n\nimport sys\nsys.setrecursionlimit(10**5)\nab=[list(map(int, input().split())) for _ in range (N-1)]\ncon=[[] for _ in range(N+1)]\n\n#print(ab)\nfor a,b in ab :\n con[a].append(b)\n con[b].append(a)\n\n#black Fennec\npc=[0]*(N+1)\nq=[(1,0)]\nvis=[False]*(N+1)\nvis[1]=True\nFcnt=N\nwhile q:\n n,c=q.pop()\n pc[n]=c\n for ch in con[n]:\n if vis[ch]==True:\n continue\n vis[ch]=True\n q.append((ch,c+1))\n \nq=[(N,0)]\nvis=[False]*(N+1)\nvis[N]=True\nwhile q:\n n,c=q.pop()\n if pc[n]>c:\n Fcnt-=1\n for ch in con[n]:\n if vis[ch]==True:\n continue\n vis[ch]=True\n q.append((ch,c+1))\n \nif Fcnt>N-Fcnt:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")\n", "neg": "N=int(input())\nimport sys\nab=[list(map(int, input().split())) for _ in range (N-1)]\ncon=[[] for _ in range(N+1)]\n\n#print(ab)\nfor a,b in ab :\n con[a].append(b)\n con[b].append(a)\n\n#black Fennec\npc=[0]*(N+1)\nq=[(1,0)]\nvis=[False]*(N+1)\nvis[1]=True\nFcnt=N\nwhile q:\n n,c=q.pop()\n pc[n]=c\n for ch in con[n]:\n if vis[ch]==True:\n continue\n q.append((ch,c+1))\n \nq=[(N,0)]\nvis=[False]*(N+1)\nvis[1]=True\nwhile q:\n n,c=q.pop()\n if pc[n]>c:\n Fcnt-=1\n for ch in con[n]:\n if vis[ch]==True:\n continue\n q.append((ch,c+1))\n \nif Fcnt>N-Fcnt:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")\n", "jacc_sim": 0.9444444444444444, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [335, 307], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u536113865", "n_user": "u536113865", "pos": "ai = lambda: list(map(int,input().split()))\nai_ = lambda: [int(x)-1 for x in input().split()]\n\nn = int(input())\n\npath = [[] for _ in range(n)]\nfor _ in range(n-1):\n a,b = ai_()\n path[a].append(b)\n path[b].append(a)\n\nfrom collections import deque\nq = deque()\nq.append(0)\n\nd1 = [float('inf') for _ in range(n)]\nd1[0] = 0\nw = set()\nwhile q:\n v = q.popleft()\n w.add(v)\n for vv in path[v]:\n if vv not in w:\n d1[vv] = d1[v] + 1\n q.append(vv)\n\n\nq = deque()\nq.append(n-1)\n\ndn = [float('inf') for _ in range(n)]\ndn[n-1] = 0\nw = set()\nwhile q:\n v = q.popleft()\n w.add(v)\n for vv in path[v]:\n if vv not in w:\n dn[vv] = dn[v] + 1\n q.append(vv)\n\n\nd = [1 if d1[v] <= dn[v] else -1 for v in range(n)]\n\nif sum(d) > 0:\n print('Fennec')\nelse:\n print('Snuke')\n", "neg": "ai = lambda: list(map(int,input().split()))\nai_ = lambda: [int(x)-1 for x in input().split()]\n\nn = int(input())\n\npath = [[] for _ in range(n)]\nfor _ in range(n-1):\n a,b = ai_()\n path[a].append(b)\n path[b].append(a)\n\nfrom collections import deque\nq = deque()\nq.append(0)\n\nd1 = [float('inf') for _ in range(n)]\nd1[0] = 0\nc = 0\nw = set()\nwhile q:\n c += 1\n v = q.popleft()\n w.add(v)\n for vv in path[v]:\n if vv not in w:\n d1[vv] = c\n q.append(vv)\n\n\nq = deque()\nq.append(n-1)\n\ndn = [float('inf') for _ in range(n)]\ndn[n-1] = 0\nc = 0\nw = set()\nwhile q:\n c += 1\n v = q.popleft()\n w.add(v)\n for vv in path[v]:\n if vv not in w:\n dn[vv] = c\n q.append(vv)\n\n\nprint(d1,dn)\nd = [1 if d1[v] >= dn[v] else 0 for v in range(n)]\n\nif d.count(1) > d.count(0):\n print('Snuke')\nelse:\n print('Fennec')\n", "jacc_sim": 0.9322033898305084, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [367, 387], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u218843509", "n_user": "u218843509", "pos": "from collections import deque\n\ndef bfs(start):\n queue = deque([start])\n visited = []\n\n while queue:\n label = queue.pop()\n\n visited.append(label)\n\n for v in d[label]:\n if tekazu[v] == float(\"inf\"):\n tekazu[v] = tekazu[label] + 1\n queue.appendleft(v)\n\n return\n\nn = int(input())\nd = [[] for _ in range(n)]\n\nfor _ in range(n - 1):\n a, b = map(int, input().split())\n d[a - 1].append(b - 1)\n d[b - 1].append(a - 1)\n\ntekazu = [float(\"inf\") for _ in range(n)]\ntekazu[0] = 0\nbfs(0)\ntekazu_Fennec = tekazu\n\ntekazu = [float(\"inf\") for _ in range(n)]\ntekazu[-1] = 0\nbfs(n - 1)\ntekazu_Snuke = tekazu\n\nFennec = 0\nSnuke = 0\n\nfor i in range(n):\n if tekazu_Fennec[i] <= tekazu_Snuke[i]:\n Fennec += 1\n else:\n Snuke += 1\n\nif Fennec > Snuke:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")", "neg": "from collections import deque\n\ndef bfs(start):\n queue = deque([start])\n visited = []\n\n while queue:\n label = queue.pop()\n\n visited.append(label)\n\n for v in d[label]:\n if tekazu[v] == float(\"inf\"):\n tekazu[v] = tekazu[label] + 1\n queue.appendleft(v)\n\n return\n\nn = int(input())\nd = [[] for _ in range(n)]\n\nfor _ in range(n - 1):\n a, b = map(int, input().split())\n d[a - 1].append(b - 1)\n d[b - 1].append(a - 1)\n\ntekazu = [float(\"inf\") for _ in range(n)]\ntekazu[0] = 0\nbfs(0)\ntekazu_Fennec = tekazu\n\ntekazu = [float(\"inf\") for _ in range(n)]\ntekazu[-1] = 0\nbfs(n - 1)\ntekazu_Snuke = tekazu\n\nFennec = 0\nSnuke = 0\n\nfor i in range(n):\n if tekazu_Fennec[i] <= tekazu_Snuke[i]:\n Fennec += 1\n else:\n Snuke += 1\n\nif Fennec > Snuke:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")", "jacc_sim": 1.0, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [367, 367], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u884982181", "n_user": "u884982181", "pos": "import sys\nsys.setrecursionlimit(2000000)\nn = int(input())\np = []\nfor i in range(n-1):\n p.append(list(map(int, input().split()))+ [1])\nl = [[] for i in range(n+1)]\nfor pi in p: \n l[pi[0]].append([pi[0],pi[1]])\n l[pi[1]].append([pi[1],pi[0]])\nkyo = [float(\"inf\")]*(n+1)\nkyo[1] = 0\nmemo = [0] * (n+1)\nmemo[1] = 1\nruto = []\ndef dfs(start,ruto):\n ruto.extend(l[start])\n memo[start] = 1\n while ruto:\n a = ruto.pop()\n if memo[a[1]] == 1:\n continue\n kyo[a[1]] = kyo[a[0]] + 1\n dfs(a[1],ruto)\n return\ndfs(1,ruto)\n\nnkyo = [float(\"inf\")]*(n+1)\nnkyo[n] = 0\nmemo = [0] * (n+1)\nmemo[n] = 1\nruto = []\ndef dfs(start,ruto):\n ruto.extend(l[start])\n memo[start] = 1\n while ruto:\n a = ruto.pop()\n if memo[a[1]] == 1:\n continue\n nkyo[a[1]] = nkyo[a[0]] + 1\n dfs(a[1],ruto)\n return\ndfs(n,ruto)\niti = 0\nnko = 0\nfor i in range(1,n+1):\n if kyo[i] <= nkyo[i]:\n iti += 1\n else:\n nko += 1\nif iti <= nko:\n print(\"Snuke\")\nelse:\n print(\"Fennec\")", "neg": "import sys\nsys.setrecursionlimit(2000000)\nn = int(input())\np = []\nfor i in range(n-1):\n p.append(list(map(int, input().split()))+ [1])\nl = [[] for i in range(n+1)]\nfor pi in p: \n l[pi[0]].append([pi[0],pi[1]])\n l[pi[1]].append([pi[1],pi[0]])\nkyo = [float(\"inf\")]*(n+1)\nkyo[1] = 0\nmemo = [0] * (n+1)\nmemo[1] = 1\nruto = []\ndef dfs(start,ruto):\n ruto.extend(l[start])\n memo[start] = 1\n while ruto:\n a = ruto.pop()\n if memo[a[1]] == 1:\n continue\n kyo[a[1]] = kyo[a[0]] + 1\n dfs(a[1],ruto)\n return\ndfs(1,ruto)\n\nnkyo = [float(\"inf\")]*(n+1)\nnkyo[n] = 0\nmemo = [0] * (n+1)\nmemo[n] = 1\nruto = []\ndef dfs(start,ruto):\n ruto.extend(l[start])\n memo[start] = 1\n while ruto:\n a = ruto.pop()\n if memo[a[1]] == 1:\n continue\n nkyo[a[1]] = nkyo[a[0]] + 1\n dfs(a[1],ruto)\n return\ndfs(n,ruto)\niti = 0\nnko = 0\nfor i in range(1,n+1):\n if kyo[i] <= nkyo[i]:\n iti += 1\n else:\n nko += 1\nprint(kyo,nkyo)\nif iti <= nko:\n print(\"Snuke\")\nelse:\n print(\"Fennec\")", "jacc_sim": 1.0, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [494, 504], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u957084285", "n_user": "u957084285", "pos": "n = int(input())\nedges = [[] for _ in range(n)]\n\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\n\ndef bfs(v):\n q = []\n depth = [n]*n\n q.append(v)\n depth[v] = 0\n i = 0\n while i < len(q):\n x = q[i]\n d = depth[x]\n for e in edges[x]:\n if depth[e] == n:\n depth[e] = d+1\n q.append(e)\n i += 1\n return depth\n\nd1 = bfs(0)\nd2 = bfs(n-1)\n\nc = 0\nfor i in range(n):\n if d1[i] <= d2[i]:\n c += 1\nif 2*c > n:\n print(\"Fennec\")\nelse:\n print(\"Snuke\")\n", "neg": "n = int(input())\nedges = [[] for _ in range(n)]\n\nfor _ in range(n-1):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\n\ndef bfs(x):\n q = []\n depth = [n]*n\n q.append(x)\n depth[x] = 0\n i = 0\n while i < len(q):\n x = q[i]\n d = depth[x]\n for e in edges[x]:\n if depth[e] == n:\n depth[e] = d+1\n q.append(e)\n i += 1\n return depth\n\nd1 = bfs(0)\nd2 = bfs(n-1)\n\nc = 0\nfor i in range(n):\n if d1[i] > d2[i]:\n c += 1\nif 2*c < n:\n print(\"Fennec\")\nelse:\n print(\"Sunuke\")\n", "jacc_sim": 0.9411764705882353, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [267, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03662", "p_user": "u329749432", "n_user": "u329749432", "pos": "def black(now):\n nextb=[]\n while now:\n a=now.pop()\n while desn[a]:\n go=desn[a].pop()\n if nodes[go]=='N':\n nodes[go]='B'\n nextb.append(go)\n return nextb\n\ndef white(now):\n nextb=[]\n while now:\n a=now.pop()\n while desn[a]:\n go=desn[a].pop()\n if nodes[go]=='N':\n nodes[go]='W'\n nextb.append(go)\n return nextb\n\nn = int(input())\nnodes=[]\ndesn=[]\nfor i in range(0,n+1):\n nodes.append(\"N\")\n desn.append([])\nnodes[1]='B'\nnodes[n]='W'\nfor i in range(0,n-1):\n b, c = (int(i) for i in input().split())\n desn[b].append(c)\n desn[c].append(b)\n\nnowb=[1]\nnoww=[n]\nwhile nowb or noww:\n nowb=black(nowb)\n noww=white(noww)\n\nb=nodes.count('B')\nw=nodes.count('W')\nif b>w:\n print('Fennec')\nelse:\n print('Snuke')\n", "neg": "def black(now):\n nextb=[]\n while now:\n a=now.pop()\n while desn[a]:\n go=desn[a].pop()\n if nodes[go]=='N':\n nodes[go]='B'\n nextb.append(go)\n return nextb\n\ndef white(now):\n nextb=[]\n while now:\n a=now.pop()\n while desn[a]:\n go=desn[a].pop()\n if nodes[go]=='N':\n nodes[go]='W'\n nextb.append(go)\n return nextb\n\nn = int(input())\nnodes=[]\ndesn=[]\nfor i in range(0,n+1):\n nodes.append(\"N\")\n desn.append([])\nnodes[1]='B'\nnodes[n]='W'\nfor i in range(0,n-1):\n b, c = (int(i) for i in input().split())\n desn[b].append(c)\n desn[c].append(b)\n\nnowb=[1]\nnoww=[n]\nwhile nowb or noww:\n nowb=black(nowb)\n noww=white(noww)\n\nb=nodes.count('B')\nw=nodes.count('W')\nif b>w:\n print('Fennec')\nelse:\n print('Sunuke')\n", "jacc_sim": 0.9607843137254902, "nl": "In a board game, Fennec and Snuke take turns coloring cells on a board with N cells and N-1 roads. The cells form a tree graph. Initially, Cell 1 is black, and Cell N is white. Players take turns coloring uncolored cells adjacent to cells of their respective colors. The game ends when a player cannot color a cell. Determine the winner when both players play optimally. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 a_i, b_i \u2264 N. Input format: N, a_1, b_1, ..., a_{N-1}, b_{N-1}. Output \"Fennec\" if Fennec wins, \"Snuke\" if Snuke wins. Example: Input 1: 7, 3 6, 1 2, 3 1, 7 4, 5 7, 1 4. Output 1: Fennec. Input 2: 4, 1 4, 4 2, 2 3. Output 2: Snuke.", "before_after_length": [353, 353], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03666", "p_user": "u572142121", "n_user": "u572142121", "pos": "N,a,b,c,d=map(int, input().split())\nN-=1\na,b=0,abs(b-a)\n#\u4e0a\u4e0b\u3092n\u56de\u3068\u3059\u308b\u3068\u30010<=n<=N//2\nif d*N B:\n A, B = B, A\n\nflag = False\ndiff = B-A\nd = 0\nfor i in range(0, N, 2):\n if i > 0:\n d += D-C\n j = N-1 - i\n if diff == d and j % 2 == 0:\n flag == True\n break\n if j == 0:\n break\n\n k = abs(diff - d) / j\n if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):\n flag = True\n break\n k = abs(diff + d) / j\n if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):\n flag = True\n break\n\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n", "neg": "N,A,B,C,D=map(int,input().split())\nif A> B:\n A,B=B,A\nif C>D:\n C,B=B,C\n\nflag=False\ndiff=B-A\nd=0\nfor i in range(0,N,2):\n d+=D-C\n j= N-1 - i\n if j==0:\n if diff==d:\n flag=True\n break\n k=abs(diff - d) / j\n if k>=C and k<=D:\n flag=True\n break\n \nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "jacc_sim": 0.9555555555555556, "nl": "You are given a row of N squares, with the leftmost containing integer A and the rightmost containing integer B. The other squares are empty. You need to fill the empty squares with integers such that the absolute difference between any two adjacent squares is between C and D (inclusive). Determine if it's possible to fill the squares under this condition. The constraints are: 3 \u2264 N \u2264 500000, 0 \u2264 A, B, C, D \u2264 10^9. Input is given as N A B C D, and the output should be \"YES\" if it's possible, and \"NO\" otherwise.", "before_after_length": [247, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03666", "p_user": "u543954314", "n_user": "u543954314", "pos": "n,a,b,c,d = map(int,input().split())\nlo,hi = -d*(n-1), -c*(n-1)\nfor _ in range(n):\n if lo <= a-b <= hi:\n print(\"YES\")\n break\n lo += c+d\n hi += c+d\nelse:\n print(\"NO\")", "neg": "n,a,b,c,d = map(int,input().split())\nlo,hi = -d*n, -c*n\nfor _ in range(n+1):\n if lo <= a-b <= hi:\n print(\"YES\")\n break\n lo += c+d\n hi += c+d\nelse:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "You are given a row of N squares, with the leftmost containing integer A and the rightmost containing integer B. The other squares are empty. You need to fill the empty squares with integers such that the absolute difference between any two adjacent squares is between C and D (inclusive). Determine if it's possible to fill the squares under this condition. The constraints are: 3 \u2264 N \u2264 500000, 0 \u2264 A, B, C, D \u2264 10^9. Input is given as N A B C D, and the output should be \"YES\" if it's possible, and \"NO\" otherwise.", "before_after_length": [88, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03666", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,a,b,c,d=map(int,input().split());print('NYOE S'[any(c*i-d*(~i+n)<=b-a<=d*i-c*(~i+n)for i in range(n))::2])", "neg": "n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2])", "jacc_sim": 0.9411764705882353, "nl": "You are given a row of N squares, with the leftmost containing integer A and the rightmost containing integer B. The other squares are empty. You need to fill the empty squares with integers such that the absolute difference between any two adjacent squares is between C and D (inclusive). Determine if it's possible to fill the squares under this condition. The constraints are: 3 \u2264 N \u2264 500000, 0 \u2264 A, B, C, D \u2264 10^9. Input is given as N A B C D, and the output should be \"YES\" if it's possible, and \"NO\" otherwise.", "before_after_length": [68, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03666", "p_user": "u729133443", "n_user": "u729133443", "pos": "n,a,b,c,d=map(int,input().split())\nf=0\nfor i in range(n):f|=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c\nprint('NYOE S'[f::2])", "neg": "n,a,b,c,d=map(int,input().split())\nf=0\nfor i in range(n):f^=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c\nprint('NYOE S'[f::2])", "jacc_sim": 0.9428571428571428, "nl": "You are given a row of N squares, with the leftmost containing integer A and the rightmost containing integer B. The other squares are empty. You need to fill the empty squares with integers such that the absolute difference between any two adjacent squares is between C and D (inclusive). Determine if it's possible to fill the squares under this condition. The constraints are: 3 \u2264 N \u2264 500000, 0 \u2264 A, B, C, D \u2264 10^9. Input is given as N A B C D, and the output should be \"YES\" if it's possible, and \"NO\" otherwise.", "before_after_length": [76, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03666", "p_user": "u163320134", "n_user": "u163320134", "pos": "n,a,b,c,d=map(int,input().split())\na,b=min(a,b),max(a,b)\npl1=b-d\npr1=b-c\npl2=b+c\npr2=b+d\nflag=False\nfor i in range((n-2)//2+1):\n j=(n-2)-i*2\n al=a+j*c+i*(c-d)\n ar=a+j*d+i*(d-c)\n if (al0:\n\t\tif not l[p]: E-=1\n\t\tl[p]+=1\nfor e in A:Z(e)\nA=[0]+A\nfor m in range(M):\n\tx,y=map(int,sys.stdin.readline().split())\n\tp=A[x]-c[A[x]]+1\n\tc[A[x]]-=1\n\tif p>0:\n\t\tl[p]-=1\n\t\tif not l[p]: E+=1\n\tA[x]=y\n\tZ(A[x])\n\tprint(E)", "neg": "import sys\nN,M=map(int,sys.stdin.readline().split())\nE=N;c=[0]*300000;l=[0]*300000\nA=list(map(int,sys.stdin.readline().split()))\ndef Z(e):\n\tglobal E\n\tp=e-c[e]\n\tc[e]+=1\n\tif p:\n\t\tif not l[p]: E-=1\n\t\tl[p]+=1\nfor e in A:Z(e)\nA=[0]+A\nfor m in range(M):\n\tx,y=map(int,sys.stdin.readline().split())\n\tp=A[x]-c[A[x]]+1\n\tc[A[x]]-=1\n\tif p:\n\t\tl[p]-=1\n\t\tif not l[p]: E+=1\n\tA[x]=y\n\tZ(A[x])\n\tprint(E)", "jacc_sim": 0.9772727272727273, "nl": "You are given a row of N balls, each initially labeled with an integer Ai. When a spell is cast, all balls with the current number k vanish simultaneously. The objective is to make all balls vanish by casting the spell some number of times. If this is not initially possible, the minimum number of modifications to the integers on the balls is sought. The integers on the balls may change by themselves in M such changes. After each change, the minimum number of modifications needed to achieve the objective before the next change is to be found. Constraints: 1 \u2264 N, M, Ai, Xj, Yj \u2264 200000. In the test set worth 500 points, N, M \u2264 200. Input format: N M, followed by A1...AN, then X1 Y1, X2 Y2, ..., XM YM. Output format: M lines, each containing the minimum necessary number of modifications. Examples are provided.", "before_after_length": [237, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03668", "p_user": "u754022296", "n_user": "u754022296", "pos": "import sys\nsys.setrecursionlimit(9**9)\nn=int(input())\nT=[[]for _ in\"_\"*(n+1)]\nfor _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,\ndef d(v,p):\n r=0\n for s in T[v]:\n if s!=p:r^=d(s,v)+1\n return r\nprint(\"ABloibc e\"[d(1,1)<1::2])", "neg": "import sys\nsys.setrecursionlimit(k:=2*n)\nn=int(input())\nT=[[]for _ in\"_\"*k]\nfor _ in range(n-1):a,b=map(int,input().split());T[a]+=b,;T[b]+=a,\ndef d(v,p):\n r=0\n for s in T[v]:\n if s!=p:r^=d(s,v)+1\n return r\nprint(\"ABloibc e\"[d(1,1)<1::2])", "jacc_sim": 0.9574468085106383, "nl": "In this problem, there is a tree with N vertices numbered 1 to N. The edges of the tree are represented by (x_i, y_i). Alice and Bob play a game on this tree. Starting from Alice, they take turns removing an existing edge, disconnecting it into two separate connected components, and then removing the component that does not contain Vertex 1. A player loses when unable to perform the operation. Determine the winner assuming both players play optimally.\n\nConstraints:\n- 2 \u2264 N \u2264 100000\n- 1 \u2264 x_i, y_i \u2264 N\n- The given graph is a tree.\n\nInput:\nThe input is given in the format:\nN\nx_1 y_1\nx_2 y_2\n...\nx_{N-1} y_{N-1}\n\nOutput:\nPrint \"Alice\" if Alice wins; print \"Bob\" if Bob wins.\n\nSample Input 1:\n5\n1 2\n2 3\n2 4\n4 5\n\nSample Output 1:\nAlice\n\nSample Input 2:\n5\n1 2\n2 3\n1 4\n4 5\n\nSample Output 2:\nBob\n\nSample Input 3:\n6\n1 2\n2 4\n5 1\n6 3\n3 2\n\nSample Output 3:\nAlice\n\nSample Input 4:\n7\n1 2\n3 7\n4 6\n2 3\n2 4\n1 5\n\nSample Output 4:\nBob", "before_after_length": [133, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u201928947", "n_user": "u201928947", "pos": "def cmb(n,k):\n if n < k:\n return 0\n return fac[n]*inv_fac[n-k]*inv_fac[k] % mod\nfac = [1]\nmod = 10**9+7\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(1,n+2):\n fac.append(fac[-1]*i % mod)\ninv_fac = [pow(fac[n+1],mod-2,mod)]\nfor i in range(1,n+2)[::-1]:\n inv_fac.append(inv_fac[-1]*i % mod)\ninv_fac = inv_fac[::-1]\ns = set()\nnum = -1\nfor i in range(n+1):\n if a[i] in s:\n idx2 = i\n num = a[i]\n break\n s.add(a[i])\nfor i in range(n+1):\n if a[i] == num:\n idx1 = i\n break\nfor i in range(1,n+2):\n ans = cmb(n+1,i)\n ans -= cmb(n+idx1-idx2,i-1)\n ans %= mod\n print(ans)", "neg": "def cmb(n,k):\n if n < k:\n return 0\n return fac[n]*inv_fac[n-k]*inv_fac[k] % mod\nfac = [1]\nmod = 10**9+7\nn = int(input())\na = list(map(int,input().split()))\nfor i in range(1,n+2):\n fac.append(fac[-1]*i % mod)\ninv_fac = [pow(fac[n+1],mod-2,mod)]\nfor i in range(1,n+2)[::-1]:\n inv_fac.append(inv_fac[-1]*i % mod)\ninv_fac = inv_fac[::-1]\ns = set()\nnum = -1\nfor i in range(n+1):\n if a[i] in s:\n idx = i\n break\n s.add(a[i])\n\nfor i in range(1,n+2):\n ans = cmb(n+1,i)\n ans -= cmb(n-idx,i-1)\n ans %= mod\n print(ans)", "jacc_sim": 0.94, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [311, 270], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u923270446", "n_user": "u923270446", "pos": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nclass nCr():\n def __init__(self, n):\n self.n = n\n self.fa = [1] * (self.n + 1)\n self.fi = [1] * (self.n + 1)\n for i in range(1, self.n + 1):\n self.fa[i] = self.fa[i - 1] * i % mod\n self.fi[i] = pow(self.fa[i], mod - 2, mod)\n def comb(self, n, r):\n if n < r:return 0\n if n < 0 or r < 0:return 0\n return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod\ncomb = nCr(2 * n)\nc = Counter(a)\nnum = c.most_common()[0][0]\nl, r = a.index(num), n - list(reversed(a)).index(num)\nfor i in range(1, n + 2):\n print((comb.comb(n + 1, i) - comb.comb(n - (r - l), i - 1)) % mod)", "neg": "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nclass nCr():\n def __init__(self, n):\n self.n = n\n self.fa = [1] * (self.n + 1)\n self.fi = [1] * (self.n + 1)\n for i in range(1, self.n + 1):\n self.fa[i] = self.fa[i - 1] * i % mod\n self.fi[i] = pow(self.fa[i], mod - 2, mod)\n def comb(self, n, r):\n if n < r:return 0\n if n < 0 or r < 0:return 0\n return self.fa[n] * self.fi[r] % mod * self.fi[n - r] % mod\ncomb = nCr(2 * n)\nc = Counter(a)\nnum = c.most_common()[0][0]\nl, r = a.index(num) + 1, n - list(reversed(a)).index(num) + 1\nprint(l, r)\nfor i in range(1, n + 2):\n print(comb.comb(n + 1, i) - comb.comb(n - (r - l) - 1, i - 1))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [312, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u425184437", "n_user": "u425184437", "pos": "N=int(input())\nA=list(map(int,input().split()))\nfrom collections import Counter\ntwo=0\na=Counter(A)\nfor k,v in a.items():\n if v==2:\n two=k\nLR=[]\nfor i in range(N+1):\n if A[i]==two:\n LR.append(i)\nL=LR[0]\nR=LR[1]\nmod=10**9+7\nP=[1 for i in range(10**6+1)]\nfor i in range(10**6):\n P[i+1]=P[i]*(i+1)%mod\nL+=1\nR+=1\ndef comb(a,b):\n if a>=b:\n return P[a]*pow(P[a-b],mod-2,mod)*pow(P[b],mod-2,mod)%mod\n else:\n return 0\n\nfor i in range(1,N+2):\n print((comb(N+1,i)-comb(N+L-R,i-1))%mod)", "neg": "N=int(input())\nA=list(map(int,input().split()))\nfrom collections import Counter\ntwo=0\na=Counter(A)\nfor k,v in a.items():\n if v==2:\n two=k\nLR=[]\nfor i in range(N):\n if A[i]==two:\n LR.append(i)\nL=LR[0]\nR=LR[1]\nmod=10**9+7\nP=[1 for i in range(10**6+1)]\nfor i in range(10**6):\n P[i+1]=P[i]*(i+1)%mod\nL+=1\nR+=1\ndef comb(a,b):\n if a>=b:\n return P[a]*pow(P[a-b],mod-2,mod)*pow(P[b],mod-2,mod)%mod\n else:\n return 0\n\nfor i in range(1,N+2):\n print(comb(N+1,i)-comb(N+L-R,i-1))", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [267, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u021548497", "n_user": "u021548497", "pos": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nmod = pow(10, 9)+7\nct = [1]*(n+1)\nfor i in range(1, n+1):\n ct[i] = ct[i-1]*i%mod\n\ndef comb(n, k):\n res = ct[n]*pow(ct[n-k], mod-2, mod)%mod*pow(ct[k], mod-2, mod)%mod\n return res\n\ndef main():\n a = [int(x) for x in input().split()]\n\n already = [-1]*n\n for i in range(n+1):\n if already[a[i]-1] != -1:\n f, s = already[a[i]-1], n-i\n break\n already[a[i]-1] = i\n \n ans = [0]*(n+1)\n c = 1\n for i in range(n+1):\n c = c*(n+1-i)%mod*pow(i+1, mod-2, mod)%mod\n ans[i] += c%mod\n\n for i in range(n):\n if s+f >= i:\n ans[i] += mod-(comb(f+s, i))%mod\n ans[i] %= mod\n for a in ans:\n print(a)\n\nif __name__ == \"__main__\":\n main()", "neg": "import sys\ninput = sys.stdin.readline\n\nn = int(input())\nmod = pow(10, 9)+7\nct = [1]*(n+1)\nfor i in range(1, n+1):\n ct[i] = ct[i-1]*i%mod\n\ndef comb(n, k):\n res = ct[n]*pow(ct[n-k], mod-2, mod)%mod*pow(ct[k], mod-2, mod)%mod\n return res\n\ndef main():\n a = [int(x) for x in input().split()]\n\n already = [-1]*n\n for i in range(n+1):\n if already[a[i]-1] != -1:\n f, s = i-already[a[i]-1], n-i\n break\n already[a[i]-1] = i\n \n ans = [0]*(n+1)\n c = 1\n for i in range(n+1):\n c = c*(n+1-i)%mod*pow(i+1, mod-2, mod)%mod\n ans[i] += c%mod\n \n for i in range(n):\n if s < i:\n break\n ans[i] += mod-(comb(s, i))%mod \n ans[i] %= mod\n for a in ans:\n print(a)\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9636363636363636, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [356, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u896741788", "n_user": "u896741788", "pos": "n=int(input())\nl=list(map(int,input().split()))\nmemo={}\n\nfor i in range(n+1):\n if l[i]in memo:\n g=l[i]\n x,y=memo[g],i\n break\n memo[l[i]]=i\nmod=10**9+7\n\nfact=[1]*(n+1+1)\ninv=[1]*(n+1+1)\nfor i in range(2,n+1+1):\n fact[i]=i*fact[i-1]%mod\ninv[-1]=pow(fact[-1],mod-2,mod)\nfor i in range(n+1,1,-1):\n inv[i-1]=inv[i]*i%mod\ndef comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0\nfor i in range(1,n+2):print((comb(n+1,i)-comb(x+n-y,i-1))%mod)", "neg": "n=int(input())\nl=list(map(int,input().split()))\nmemo={}\n\nfor i in range(n+1):\n if l[i]in memo:\n g=l[i]\n x,y=memo[g],i\n break\n memo[l[i]]=i\nmod=10**9+7\nprint(x,y)\nfact=[1]*(n+1+1)\ninv=[1]*(n+1+1)\nfor i in range(2,n+1+1):\n fact[i]=i*fact[i-1]%mod\ninv[-1]=pow(fact[-1],mod-2,mod)\nfor i in range(n+1,1,-1):\n inv[i-1]=inv[i]*i%mod\ndef comb(x,y):return fact[x]*inv[y]%mod*inv[x-y]%mod if x>=y>=0 else 0\nprint(n)\nfor i in range(2,n+2):\n ans=comb(n+1,i)\n if n-y+x>=i-1:ans-=comb(x+n-y,i-1)\n else:ans-=comb(x,i-1)-comb(n-y,i-1)\n \n print(ans)", "jacc_sim": 0.9791666666666666, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [264, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u380524497", "n_user": "u380524497", "pos": "mod = 10 ** 9 + 7\n\nSIZE = 10 ** 5 + 5\nfact = [0] * SIZE\ninv = [0] * SIZE\nfinv = [0] * SIZE\nfact[0], fact[1] = 1, 1\ninv[1] = 1\nfinv[0], finv[1] = 1, 1\nfor i in range(2, SIZE):\n fact[i] = fact[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\n\ndef nCr(n, r):\n if n < 0 or r < 0 or n < r:\n return 0\n return fact[n] * (finv[r] * finv[n - r] % mod) % mod\n\n\nfrom collections import Counter\n\n\nn = int(input())\nA = list(map(int, input().split()))\ncounterA = Counter(A)\nduplicate = 0\nfor num, count in counterA.items():\n if count == 2:\n duplicate = num\n break\n\nduplicate_pos = []\nfor i, a in enumerate(A):\n if a == duplicate:\n duplicate_pos.append(i)\n\nfirst, second, *_ = duplicate_pos\n\nfor k in range(1, n+2):\n base = nCr(n+1, k)\n duplicate_pattern = nCr(first + n-second, k-1)\n print((base - duplicate_pattern) % mod)\n\n", "neg": "mod = 10 ** 9 + 7\n\nSIZE = 10 ** 5 + 5\nfact = [0] * SIZE\ninv = [0] * SIZE\nfinv = [0] * SIZE\nfact[0], fact[1] = 1, 1\ninv[1] = 1\nfinv[0], finv[1] = 1, 1\nfor i in range(2, SIZE):\n fact[i] = fact[i - 1] * i % mod\n inv[i] = mod - inv[mod % i] * (mod // i) % mod\n finv[i] = finv[i - 1] * inv[i] % mod\n\n\ndef nCr(n, r):\n if n < 0 or r < 0 or n < r:\n return 0\n return fact[n] * (finv[r] * finv[n - r] % mod) % mod\n\n\nfrom collections import Counter\n\n\nn = int(input())\nA = list(map(int, input().split()))\ncounterA = Counter(A)\nduplicate = 0\nfor num, count in counterA.items():\n if count == 2:\n duplicate = num\n break\n\nduplicate_pos = []\nfor i, a in enumerate(A):\n if a == duplicate:\n duplicate_pos.append(i)\n\nfirst, second, *_ = duplicate_pos\n\nfor k in range(1, n+2):\n base = nCr(n+1, k)\n duplicate_pattern = nCr(n-second, k-1)\n print(base - duplicate_pattern)\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [379, 373], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u342869120", "n_user": "u342869120", "pos": "\nclass Combination:\n def __init__(self, n, mod):\n fact = [0]*(n+1)\n ifact = [0]*(n+1)\n fact[0] = 1\n for i in range(1, n+1):\n fact[i] = (fact[i-1]*i) % mod\n # 1/n!\u3092\u9006\u5143\u3067\u6c42\u3081\u308b\n ifact[n] = pow(fact[n], mod-2, mod)\n for i in range(n, 0, -1):\n ifact[i-1] = (ifact[i]*i) % mod\n\n self.n = n\n self.mod = mod\n self.fact = fact\n self.ifact = ifact\n\n def choose(self, n, r):\n if r < 0 or r > n:\n return 0\n ret = (self.fact[n]*self.ifact[r]) % self.mod\n return (ret*self.ifact[n-r]) % self.mod\n\n\nn = int(input())\n*a, = map(int, input().split())\nindices = [-1]*n\nl, r = 0, 0\nfor i in range(n+1):\n if indices[a[i]-1] != -1:\n l = indices[a[i]-1]\n r = i\n break\n indices[a[i]-1] = i\n\nMOD = 10**9+7\nc = Combination(n+2, MOD)\nfor i in range(1, n+2):\n ans = c.choose(n+1, i) - c.choose(l+n-r, i-1)\n ans = (ans+MOD) % MOD\n print(ans)\n", "neg": "\nclass Combination:\n def __init__(self, n, mod):\n fact = [0]*(n+1)\n ifact = [0]*(n+1)\n fact[0] = 1\n for i in range(1, n+1):\n fact[i] = (fact[i-1]*i) % mod\n # 1/n!\u3092\u9006\u5143\u3067\u6c42\u3081\u308b\n ifact[n] = pow(fact[n], mod-2, mod)\n for i in range(n, 0, -1):\n ifact[i-1] = (ifact[i]*i) % mod\n\n self.n = n\n self.mod = mod\n self.fact = fact\n self.ifact = ifact\n\n def choose(self, n, r):\n if r < 0 or r > n:\n return 0\n ret = (self.fact[n]*self.ifact[r]) % self.mod\n return (ret*self.ifact[n-r]) % self.mod\n\n\nn = int(input())\n*a, = map(int, input().split())\nindices = [-1]*n\nl, r = 0, 0\nfor i in range(n+1):\n if indices[a[i]-1] != -1:\n l = indices[a[i]-1]\n r = i\n break\n indices[a[i]-1] = i\n\nMOD = 10**9+7\nc = Combination(n+100, MOD)\nfor i in range(1, n+2):\n ans = c.choose(n+1, i) - c.choose(l-1+n-r, i-1)\n print(ans)\n", "jacc_sim": 0.9841269841269841, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [436, 427], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u426108351", "n_user": "u426108351", "pos": "n = int(input())\na = list(map(int, input().split()))\nb = [0]*(n+1)\nfor i in range(n+1):\n if b[a[i]] == 0:\n b[a[i]] += 1\n else:\n d = a[i]\n\nl = 0\nr = 0\nc = 0\nfor i in range(n+1):\n if a[i] != d and c == 0:\n l += 1\n elif a[i] != d and c == 2:\n r += 1\n elif a[i] == d:\n c += 1\n\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9 + 7\nN = 100011\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\nfor i in range(1, n+2):\n print((cmb(n+1, i, mod)-cmb(r+l, i-1, mod))%mod)\n", "neg": "n = int(input())\na = list(map(int, input().split()))\nb = [0]*(n+1)\nfor i in range(n):\n if b[a[i]] == 0:\n b[a[i]] += 1\n else:\n d = a[i]\n\nl = 0\nr = 0\nc = 0\nfor i in range(n+1):\n if a[i] != d and c == 0:\n l += 1\n elif a[i] != d and c == 2:\n r += 1\n if a[i] == d:\n c += 1\n\n\ndef cmb(n, r, mod):\n if ( r<0 or r>n ):\n return 0\n r = min(r, n-r)\n return g1[n] * g2[r] * g2[n-r] % mod\n\nmod = 10**9 + 7\nN = 100001\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\nfor i in range( 2, N + 1 ):\n g1.append( ( g1[-1] * i ) % mod )\n inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )\n g2.append( (g2[-1] * inverse[-1]) % mod )\n\n\nprint(n)\nfor i in range(2, n+2):\n print(cmb(n+1, i, mod)-max(0, r-i+2)-max(0, l-i+2))\n", "jacc_sim": 0.9473684210526315, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [381, 388], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u470542271", "n_user": "u470542271", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\nc = Counter(a)\nfor k in c.keys():\n if c[k] == 2:\n break\nl = []\nfor i in range(len(a)):\n if a[i] == k:\n l.append(i)\n if len(l) == 2:\n break\nd = n - l[1] + l[0]\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod\n else : return power(x, y // 2) ** 2 * x % mod\n\nmod = 10 ** 9 + 7\nN = n + 2\n\nfactorial = [1]\nfor i in range(1, N):\n factorial.append(factorial[i - 1] * i % mod)\n\ninverseFactorial = [0] * N\ninverseFactorial[N - 1] = power(factorial[N - 1], mod - 2)\nfor i in range(N - 2, -1, -1):\n inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % mod\n\ndef comb(x, y):\n return factorial[x] * inverseFactorial[y] * inverseFactorial[x - y] % mod\n\nfor k in range(1, n + 2):\n if d >= k - 1:\n print((comb(n+1, k) - comb(d, k-1)) % mod)\n else:\n print(comb(n+1, k))\n", "neg": "n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\nc = Counter(a)\nfor k in c.keys():\n if c[k] == 2:\n break\nl = []\nfor i in range(len(a)):\n if a[i] == k:\n l.append(i)\n if len(l) == 2:\n break\nd = n - l[1] + l[0]\n\ndef power(x, y):\n if y == 0 : return 1\n elif y == 1 : return x % mod\n elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod\n else : return power(x, y // 2) ** 2 * x % mod\n\nmod = 10 ** 9 + 7\n\nfactorial = [1]\nfor i in range(1, N):\n factorial.append(factorial[i - 1] * i % mod)\n\ninverseFactorial = [0] * N\ninverseFactorial[N - 1] = power(factorial[N - 1], mod - 2)\nfor i in range(N - 2, -1, -1):\n inverseFactorial[i] = inverseFactorial[i + 1] * (i + 1) % mod\n\ndef comb(x, y):\n return factorial[x] * inverseFactorial[y] * inverseFactorial[x - y] % mod\n\nfor k in range(1, n + 2):\n if d >= k - 1:\n print((comb(n+1, k) - comb(d, k-1)) % mod)\n else:\n print(comb(n+1, k))\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [413, 407], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u263830634", "n_user": "u263830634", "pos": "MOD = 10 ** 9 + 7\nn = int(input())\na = list(map(int, input().split()))\nlst = [-1] * n\n\n# O(N)\nfor i in range(n + 1):\n if lst[a[i] - 1] != -1:\n first = lst[a[i] - 1]\n second = i\n break\n lst[a[i] - 1] = i\n\n# print (first, second) \nleft = first\nright = n - second\n\nU = 10 ** 5 + 1\ndef power_mod(a, n):\n if n == 0:\n return 1\n x = power_mod(a//2)\n\ndef make_fact(fact, fact_inv):\n for i in range(1, U + 1):\n fact[i] = (fact[i - 1] * i) % MOD\n fact_inv[U] = pow(fact[U], MOD - 2, MOD)\n for i in range(U, 0, -1):\n fact_inv[i - 1] = (fact_inv[i] * i) % MOD\n\ndef comb(n, k):\n if k < 0 or n < k:\n return 0\n x = fact[n]\n x *= fact_inv[k]\n x %= MOD\n x *= fact_inv[n - k]\n x %= MOD\n return x\n\nfact = [1] * (U + 1)\nfact_inv = [1] * (U + 1)\nmake_fact(fact, fact_inv)\n\nfor i in range(1, n + 2):\n ans = comb(n + 1, i) - comb(left + right, i - 1)\n print (ans % MOD)", "neg": "MOD = 10 ** 9 + 7\nn = int(input())\na = list(map(int, input().split()))\nlst = [-1] * n\n\n# O(N)\nfor i in range(n + 1):\n if lst[a[i] - 1] != -1:\n first = lst[a[i] - 1]\n second = i\n break\n lst[a[i] - 1] = i\n\nprint (first, second) \nleft = first\nright = n - second\n\nU = 10 ** 5 + 1\ndef power_mod(a, n):\n if n == 0:\n return 1\n x = power_mod(a//2)\n\ndef make_fact(fact, fact_inv):\n for i in range(1, U + 1):\n fact[i] = (fact[i - 1] * i) % MOD\n fact_inv[U] = pow(fact[U], MOD - 2, MOD)\n for i in range(U, 0, -1):\n fact_inv[i - 1] = (fact_inv[i] * i) % MOD\n\ndef comb(n, k):\n print ('A')\n if k < 0 or n < k:\n return 0\n x = fact[n]\n x *= fact_inv[k]\n x %= MOD\n x *= fact_inv[n - k]\n x %= MOD\n return x\n\nfact = [1] * (U + 1)\nfact_inv = [1] * (U + 1)\nmake_fact(fact, fact_inv)\n\nfor i in range(1, n + 2):\n ans = comb(n + 1, i) - comb(left + right, i - 1)\n print (ans % MOD)", "jacc_sim": 0.9666666666666667, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [418, 423], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u170201762", "n_user": "u170201762", "pos": "mod = 10**9+7\nfact = [1]*(10**5+2)\nfor n in range(1,10**5+2):\n fact[n] = n*fact[n-1]%mod\ndef comb(n,k):\n return fact[n]*pow(fact[k],mod-2,mod)*pow(fact[n-k],mod-2,mod)%mod\n\nN = int(input())\na = list(map(int,input().split()))\nc = [-1]*N\nfor j in range(N+1):\n if c[a[j]-1] != -1:\n break\n c[a[j]-1] = j\ni = c[a[j]-1]\nj = N-j\n\nfor k in range(1,N+2):\n ans = comb(N+1,k)\n if k-1<=i+j:\n ans -= comb(i+j,k-1)\n print(ans%mod)", "neg": "mod = 10**9+7\nfact = [1]*(10**5+2)\nfor n in range(1,10**5+2):\n fact[n] = n*fact[n-1]%mod\ndef comb(n,k):\n return fact[n]*pow(fact[k],mod-2,mod)*pow(fact[n-k],mod-2,mod)%mod\n\nN = int(input())\na = list(map(int,input().split()))\nc = [-1]*N\nfor j in range(N+1):\n if c[a[j]-1] != -1:\n break\n c[a[j]-1] = j\ni = c[a[j]-1]\nj = N-j\n\nfor k in range(1,N+2):\n if k == 1:\n print(N)\n else:\n ans = comb(N+1,k)\n if k-1<=i:\n ans -= comb(i,k-1)\n if k-1<=j:\n ans -= comb(j,k-1)\n print(ans%mod)", "jacc_sim": 0.9782608695652174, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [242, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u844789719", "n_user": "u844789719", "pos": "N = int(input())\nA = [int(_) for _ in input().split()]\nmod = 10**9 + 7\n\nf = [1] * (N + 2)\nfi = [1] * (N + 2)\nfor i in range(2, N + 2):\n f[i] = i * f[i - 1]\n f[i] %= mod\nfor i in range(2, N + 2):\n fi[i] = fi[i - 1] * pow(i, mod - 2, mod)\n fi[i] %= mod\n\n\ndef comb(n, r):\n if 0 <= n and 0 <= r and 0 <= n - r:\n return (f[n] * fi[r] * fi[n - r]) % mod\n else:\n return 0\n\n\nb = set()\nfor a in A:\n if a in b:\n break\n b.add(a)\nc = []\nfor i in range(N + 1):\n if A[i] == a:\n c += [i]\ni, j = c\nfor x in range(1, N + 2):\n print((comb(N + 1, x) - (comb(N - j + i, x - 1))) % mod)\n", "neg": "N = int(input())\nA = [int(_) for _ in input().split()]\nmod = 10**9 + 7\n\nf = [1] * (N + 2)\nfi = [1] * (N + 2)\nfor i in range(2, N + 2):\n f[i] = i * f[i - 1]\n f[i] %= mod\nfor i in range(2, N + 2):\n fi[i] = fi[i - 1] * pow(i, mod - 2, mod)\n fi[i] %= mod\n\n\ndef comb(n, r):\n if 0 <= n and 0 <= r and 0 <= n - r:\n return (f[n] * fi[r] * fi[n - r]) % mod\n else:\n return 0\n\n\nb = set()\nfor a in A:\n if a in b:\n break\n b.add(a)\nc = []\nfor i in range(N):\n if A[i] == a:\n c += [i]\ni, j = c\nfor x in range(1, N + 2):\n print((comb(N + 1, x) - (comb(N - j + i, x - 1))) % mod)\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [300, 298], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u315485238", "n_user": "u315485238", "pos": "n = int(input())\nA= list(map(int, input().split()))\n\nmod = 10**9+7\n\nclass combinationmod():\n def __init__(self,MAX, mod):\n self.mod =mod\n self.fac=[0]*(MAX+1)\n self.finv=[0]*(MAX+1)\n self.inv=[0]*(MAX+1)\n self.fac[0]=self.fac[1]=1\n self.finv[0]=self.finv[1]=1\n self.inv[1]=1\n for i in range(2,MAX+1):\n self.fac[i] = self.fac[i-1]*i%self.mod\n self.inv[i] = (-self.inv[mod%i]*(mod//i))%self.mod\n self.finv[i] = self.finv[i-1]* self.inv[i] %self.mod\n\n def nCk(self,n,k):\n if nint:\n b, u, v = mod, 1, 0\n while b > 0:\n t = n // b\n\n n -= t * b\n u -= t * v\n\n n, b = b, n\n u, v = v, u\n\n return (u+mod) % mod\n\n\ndef _11(N: int, A: list)->list:\n MOD = 10**9 + 7\n\n d = {}\n l, r = 0, 0\n for i, a in enumerate(A):\n if a in d:\n l, r = d[a], N-i\n else:\n d[a] = i\n\n c1, c2 = [1]*(N+2), [1]*(N+2)\n for i in range(N+1):\n c1[i+1] = (c1[i] * (N+1-i) * mod_inv(i+1, MOD)) % MOD\n c2[i+1] = (c2[i] * (l+r-i) * mod_inv(i+1, MOD)) % MOD\n\n return [(c1[k+1]-c2[k]+MOD) % MOD for k in range(N+1)]\n\n\nif __name__ == \"__main__\":\n N = int(input())\n A = [int(s) for s in input().split()]\n ans = _11(N, A)\n print('\\n'.join(map(str, ans)))\n", "neg": "def mod_inv(n: int, mod: int)->int:\n b, u, v = mod, 1, 0\n while b > 0:\n t = n // b\n\n n -= t * b\n u -= t * v\n\n a, b = b, a\n u, v = v, u\n\n return (u+mod) % mod\n\n\ndef _11(N: int, A: list)->list:\n MOD = 10**9 + 7\n\n d = {}\n l, r = 0, 0\n for i, a in enumerate(A):\n if a in d:\n l, r = d[a], N-i\n else:\n d[a] = i\n\n c1, c2 = [1]*(N+2), [1]*(N+2)\n for i in range(N+1):\n c1[i+1] = (c1[i] * (N+1-i) * mod_inv(i+1, MOD)) % MOD\n c2[i+1] = (c2[i] * (l+r-i) * mod_inv(i+1, MOD)) % MOD\n\n return [(c1[k+1]-c2[k]+MOD) % MOD for k in range(N+1)]\n\n\nif __name__ == \"__main__\":\n N = int(input())\n A = [int(s) for s in input().split()]\n ans = _11(N, A)\n print('\\n'.join(map(str, ans)))\n", "jacc_sim": 1.0, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [379, 379], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u824237520", "n_user": "u824237520", "pos": "n = int(input())\na = list(map(int, input().split()))\n\nclass ModInv:\n def __init__(self, size, MOD):\n self.inv = [0] * (size + 1)\n self.inv[1] = 1\n for i in range(2, size + 1):\n self.inv[i] = (-(MOD // i) * self.inv[MOD%i]) % MOD\n\nif n == 1:\n print(1)\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\nb = sorted(a)\n\nfor i in range(n):\n if b[i] == b[i + 1]:\n break\n\nfirst = a.index(b[i])\nfor i in range(first + 1, n + 1):\n if a[i] == a[first]:\n second = i\n\nw = n + first - second\n\ninv = ModInv(n + 1, MOD)\nc = [1] * (n + 2)\nd = [1] * (n + 2)\n\nfor i in range(n + 1):\n d[i + 1] = (d[i] * inv.inv[i + 1]) % MOD\nfor i in range(n + 1):\n c[i + 1] = (c[i] * (i + 1)) % MOD\n\nprint(n)\nfor k in range(2, n + 2):\n ans = (((c[n+1] * d[n+1-k]) % MOD) * d[k]) % MOD\n if w >= k - 1:\n ans -= (((c[w] * d[w-k+1]) % MOD) * d[k-1]) % MOD\n print( ans % MOD )\n", "neg": "n = int(input())\na = list(input().split())\n\nclass ModInv:\n def __init__(self, size, MOD):\n self.inv = [0] * (size + 1)\n self.inv[1] = 1\n for i in range(2, size + 1):\n self.inv[i] = (-(MOD // i) * self.inv[MOD%i]) % MOD\n\nif n == 1:\n print(1)\n print(1)\n exit()\n\nMOD = 10 ** 9 + 7\n\nb = sorted(a)\n\nfor i in range(n):\n if b[i] == b[i + 1]:\n d = b[i]\n break\n\nfirst = a.index(d)\nfor i in range(first + 1, n + 1):\n if a[i] == d:\n second = i\n\nw = n + first - second\n\ninv = ModInv(n + 1, MOD)\nc = [1] * (n + 2)\nd = [1] * (n + 2)\n\nfor i in range(n + 1):\n d[i + 1] = (d[i] * inv.inv[i + 1]) % MOD\nfor i in range(n + 1):\n c[i + 1] = (c[i] * (i + 1)) % MOD\n\nprint(n)\nfor k in range(2, n + 2):\n if k < w:\n print( (((c[n+1] * d[k]) * d[n+1-k]) % MOD) - (((c[w] * d[k]) * d[w-k]) % MOD) )\n else:\n print( ((c[n+1] * d[k]) * d[n+1-k]) % MOD )", "jacc_sim": 0.9107142857142857, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [424, 434], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u270681687", "n_user": "u270681687", "pos": "n = int(input())\na = list(map(int, input().split()))\ns = set()\n\nindex2 = 0\nfor i in range(n+1):\n if a[i] in s:\n index2 = i\n s.add(a[i])\n\nindex1 = 0\nfor i in range(n+1):\n if a[i] == a[index2]:\n index1 = i\n break\n\n#combination---\nm = 10**9 + 7\nfac = [1, 1]\ninv = [1, 1]\nfinv = [1, 1]\nfor i in range(2, n+5):\n fac.append(fac[i-1] * i % m)\n inv.append(m - inv[m%i] * (m//i) % m)\n finv.append(finv[i-1] * inv[i] % m)\n\ndef nck(n, k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n-k] % m) % m\n\n#-----\n\n\nfor k in range(1, n+2):\n print((nck(n + 1, k) - nck(index1 + n - index2, k-1)) % m)\n", "neg": "n = int(input())\na = list(map(int, input().split()))\ns = set()\nindex = 0\nfor i in range(n):\n if a[i] in s:\n index = i\n s.add(a[i])\n\n#combination---\nm = 10**9 + 7\nfac = [1, 1]\ninv = [1, 1]\nfinv = [1, 1]\nfor i in range(2, n+5):\n fac.append(fac[i-1] * i % m)\n inv.append(m - inv[m%i] * (m//i) % m)\n finv.append(finv[i-1] * inv[i] % m)\n\ndef nck(n, k):\n if n < k:\n return 0\n if n < 0 or k < 0:\n return 0\n return fac[n] * (finv[k] * finv[n-k] % m) % m\n\nfor k in range(1, n+2):\n print(nck(n+1, k) - nck(n-index, k-1))", "jacc_sim": 0.9245283018867925, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [332, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u415905784", "n_user": "u415905784", "pos": "def factorial_memo(n, p):\n F = [1] * (n + 1)\n for i in range(n):\n F[i + 1] = F[i] * (i + 1) % p\n return F\n\ndef inverse(F, p):\n Finv = [x for x in F]\n Finv[-1] = pow(Finv[-1], p - 2, p)\n for i in range(len(F) - 2, 0, -1):\n Finv[i] = Finv[i + 1] * (i + 1) % p\n return Finv\n\ndef comb(a, b):\n if a < b:\n return 0\n return F[a] * Finv[a - b] * Finv[b] % p\n\nn = int(input())\nA = [int(x) for x in input().split()]\np = 10 ** 9 + 7\nD = [-1] * n\ndouble = [-1, -1]\nfor i, a in enumerate(A):\n if D[a - 1] == -1:\n D[a - 1] = i\n else:\n double = [D[a - 1], i]\n break\nF = factorial_memo(n + 1, p)\nFinv = inverse(F, p)\nn_a = double[0]\nn_b = n - double[1]\nprint(n)\nC = [0] * n\nfor i in range(2, n + 2):\n cnt = (comb(n + 1, i) - comb(n_a + n_b, i - 1)) % p\n print(cnt)", "neg": "def factorial_memo(n, p):\n F = [1] * (n + 1)\n for i in range(n):\n F[i + 1] = F[i] * (i + 1) % p\n return F\n\ndef inverse(F, p):\n Finv = [x for x in F]\n Finv[-1] = pow(Finv[-1], p - 2, p)\n for i in range(len(F) - 2, 0, -1):\n Finv[i] = Finv[i + 1] * (i + 1) % p\n return Finv\n\ndef comb(a, b):\n if a < b:\n return 0\n return F[a] * Finv[a - b] * Finv[b] % p\n\nn = int(input())\nA = [int(x) for x in input().split()]\np = 10 ** 9 + 7\nD = [-1] * n\ndouble = [-1, -1]\nfor i, a in enumerate(A):\n if D[a - 1] == -1:\n D[a - 1] = i\n else:\n double = [D[a - 1], i]\n break\nF = factorial_memo(n + 1, p)\nFinv = inverse(F, p)\nn_a = double[0]\nn_b = n - double[1]\nprint(n)\nC = [0] * n\nfor i in range(2, n + 2):\n cnt = (comb(n, i) + comb(n, i - 1) - max((n_a + n_b + 2 - i), 0)) % p\n print(cnt)\n ", "jacc_sim": 0.9811320754716981, "nl": "You are given an integer sequence of length n+1, a_1, a_2, ..., a_{n+1}, consisting of n integers 1,...,n. Each of the n integers 1,...,n appears at least once in this sequence. For each integer k=1,...,n+1, find the number of different subsequences (not necessarily contiguous) of the given sequence with length k, modulo 10^9+7. If the contents of two subsequences are the same, they are not separately counted even if they originate from different positions in the original sequence. A subsequence of a sequence a with length k is a sequence obtained by selecting k of the elements of a and arranging them without changing their relative order. The input is given in the format: n a_1 a_2 ... a_{n+1}. Print n+1 lines. The k-th line should contain the number of different subsequences of the given sequence with length k, modulo 10^9+7.", "before_after_length": [396, 407], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03674", "p_user": "u729707098", "n_user": "u729707098", "pos": "def comb(n,k):\n\tif n=2:\n print(0)\nelse:\n if n==m:\n print(kaidan[n]*kaidan[n]*2%mod)\n else:\n a=max(n,m)\n b=min(n,m)\n print(kaidan[a]*kaidan[b]%mod)", "neg": "###ncr\u306emod\u3042\u307e\u308a\u306e\u8a71\nmod=10**9+7\nN=100005\nkaidan=[1 for i in range(N)]\ngyaku=[1 for i in range(N)]\nfor i in range(1,N):\n kaidan[i] = (i * kaidan[i-1])%mod\n gyaku[i]=pow(bikkuri[i], mod-2, mod)\ndef comb(a,b):\n return kaidan[a]*gyaku[b]*gyaku[a-b]\nn,m=map(int,input().split())\nif abs(n-m)>=2:\n print(0)\nelse:\n if n==m:\n print(kaidan[n]*kaidan[n]*2%mod)\n else:\n a=max(n,m)\n b=min(n,m)\n print(kaidan[a]*kaidan[b]%mod)", "jacc_sim": 0.9814814814814815, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [251, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u993435350", "n_user": "u993435350", "pos": "import sys\nfrom functools import reduce,lru_cache\nimport math\nfrom operator import mul\n\ndef main():\n #sys.setrecursionlimit(10 ** 5 + 1)\n N,M = map(int,input().split())\n \n @lru_cache(maxsize = None)\n def recur(n):\n if n == 0:\n return 1\n else:\n m = n * recur(n - 1)\n return m\n \n if N == M:\n L = [i for i in range(1,N + 1)]\n #ans = (reduce(mul,L) ** 2) * 2 % (10 ** 9 + 7)\n ans = (math.factorial(M) ** 2) * 2 % ((10 ** 9) + 7)\n print(ans)\n elif abs(M - N) == 1: \n ans = math.factorial(N) * math.factorial(M) % ((10 ** 9) + 7)\n print(ans)\n \n else:\n print(0)\n \nmain()", "neg": "import sys\nfrom functools import reduce,lru_cache\nfrom operator import mul\n\ndef main():\n sys.setrecursionlimit(10 ** 5)\n N,M = map(int,input().split())\n \n @lru_cache(maxsize = None)\n def recur(n):\n if n == 0:\n return 1\n else:\n m = n * recur(n - 1)\n return m\n \n if N == M:\n L = [i for i in range(1,N + 1)]\n #ans = (reduce(mul,L) ** 2) * 2 % (10 ** 9 + 7)\n ans = (recur(N) % (10 ** 9 + 7))\n print(ans)\n elif abs(M - N) == 1: \n ans = 1\n ans *= (recur(N) % (10 ** 9 + 7)) \n ans *= (recur(M) % (10 ** 9 + 7))\n print(ans)\n \n else:\n print(0)\n \nmain()", "jacc_sim": 0.9649122807017544, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [253, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u077291787", "n_user": "u077291787", "pos": "# ARC076C - Reconciled?\ndef factorial_mod(x):\n MOD = 10 ** 9 + 7\n ret = 1\n for i in range(1, x + 1):\n ret = (ret * i) % MOD\n return ret\n\n\ndef main():\n n, m = list(map(int, input().rstrip().split()))\n MOD = 10 ** 9 + 7\n n, m = min(n, m), max(n, m)\n dif = m - n\n if dif > 1: # must be ...DDM...\n print(0)\n else:\n if dif == 0: # start with either D or M (DM..., MD...)\n ans = (factorial_mod(n) ** 2 * 2) % MOD\n else: # sandwich (DMD or MDM)\n ans = (factorial_mod(n) ** 2 * m) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# ARC076C - Reconciled?\ndef factorial(x):\n ret = 1\n for i in range(1, x + 1):\n ret *= i\n return ret\n\n\ndef main():\n n, m = list(map(int, input().rstrip().split()))\n MOD = 10 ** 9 + 7\n dif = abs(n - m)\n if dif > 1: # must be ...DDM...\n print(0)\n else:\n if dif == 0: # start with either D or M (DM..., MD...)\n ans = (factorial(n) * factorial(m) * 2) % MOD\n else: # sandwich (DMD or MDM)\n ans = (factorial(n) * factorial(m)) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9242424242424242, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [245, 214], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u077291787", "n_user": "u077291787", "pos": "# ARC076C - Reconciled?\nfrom math import factorial\n\n\ndef main():\n n, m = list(map(int, input().rstrip().split()))\n MOD = 10 ** 9 + 7\n dif = abs(n - m)\n if abs(n - m) not in (0, 1):\n print(0)\n else:\n if dif == 0:\n ans = (factorial(n) * factorial(m) * 2) % MOD\n else:\n ans = (factorial(n) * factorial(m)) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# ARC076C - Reconciled?\nfrom math import factorial\n\n\ndef main():\n n, m = list(map(int, input().rstrip().split()))\n MOD = 10 ** 9 + 7\n if abs(n - m) not in (0, 1):\n print(0)\n else:\n ans = (factorial(n) * factorial(m) * 2) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9782608695652174, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [160, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u967835038", "n_user": "u967835038", "pos": "n, m = map(int, input().split())\na = 1\nb = 1\nif abs(n-m) >= 2:\n print(0)\nelse:\n for i in range(2, n+1):\n a = (a*i) % (10**9+7)\n for j in range(2, m+1):\n b = (b*j) % (10**9+7)\n if n == m:\n print((a*b*2) % (10**9+7))\n else:\n print((a*b) % (10**9+7))", "neg": "n, m = map(int, input().split())\na = 0\nb = 0\nif abs(n-m) >= 2:\n print(0)\nelse:\n for i in range(2, n+1):\n a = (a*i) % (10**9+7)\n for j in range(2, m+1):\n b = (b*j) % (10**9+7)\n if n == m:\n print((a*b*2) % (10**9+7))\n else:\n print((a*b) % (10**9+7))\n", "jacc_sim": 1.0, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [145, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u848647227", "n_user": "u848647227", "pos": "a,b = map(int,input().split(\" \"))\nc = 1\nd = 1\nfor i in range(2,a+1):\n c = (c * i) % (10 ** 9 + 7)\nfor i in range(2,b+1):\n d = (d * i) % (10 ** 9 + 7)\nif abs(a - b) >= 2:\n print(0)\nelif a == b:\n print(((c * d) * 2) % (10 ** 9 + 7))\nelse:\n print((c * d) % (10 ** 9 + 7))", "neg": "a,b = map(int,input().split(\" \"))\nc = 1\nd = 1\nfor i in range(2,a+1):\n c *= i % (10 ** 9 + 7)\nfor i in range(2,b+1):\n d *= i % (10 ** 9 + 7)\nif abs(a - b) >= 2:\n print(0)\nelif a == b:\n print(((c * d) * 2) % (10 ** 9 + 7))\nelse:\n print((c * d) % (10 ** 9 + 7))", "jacc_sim": 1.0, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [143, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u038353231", "n_user": "u038353231", "pos": "import math\nN,M = map(int,input().split())\nif abs(N - M) > 1:\n print(0)\nelif N == M:\n print((2*(math.factorial(N) * math.factorial(M))) % 1000000007)\nelse:\n print(((math.factorial(N) * math.factorial(M))) % 1000000007)", "neg": "import math\nN,M = map(int,input().split())\nif abs(N - M) > 1:\n print(0)\nelse:\n print((math.factorial(N) * math.factorial(M)) % 1000000007)", "jacc_sim": 0.9285714285714286, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [93, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u667024514", "n_user": "u667024514", "pos": "n,m = map(int,input().split())\nif abs(n - m) >= 2:\n print(\"0\")\nelse:\n if n == m:cou = 2\n else:cou = 1\n while n > 1:\n cou *= n\n cou %= (10 ** 9 + 7)\n n -= 1\n while m > 1:\n cou *= m\n cou %= (10 ** 9 + 7)\n m -= 1\n print(cou)", "neg": "n,m = map(int,input().split())\nif abs(n - m) >= 2:\n print(\"0\")\nelse:\n cou = 2\n while n > 1:\n cou *= n\n cou %= (10 ** 9 + 7)\n n -= 1\n while m > 1:\n cou *= m\n cou %= (10 ** 9 + 7)\n m -= 1\nprint(cou)", "jacc_sim": 1.0, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [118, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u581337384", "n_user": "u038353231", "pos": "import math\nPRIME_NUM = 1000000007\nN, M = map(int, input().split())\nif abs(N - M) > 1:\n print(0)\nelif N == M:\n print(2 * (math.factorial(N) % PRIME_NUM) * (math.factorial(M) % PRIME_NUM) % PRIME_NUM)\nelse:\n print((math.factorial(N) % PRIME_NUM) * (math.factorial(M) % PRIME_NUM) % PRIME_NUM)\n", "neg": "import math\nN,M = map(int,input().split())\nif abs(N - M) > 1:\n print(0)\nelse:\n print((2*(math.factorial(N) * math.factorial(M))) % 1000000007)", "jacc_sim": 0.9310344827586207, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [131, 61], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u835482198", "n_user": "u835482198", "pos": "\nN, M = map(int, input().split())\n# N, M = 100000, 100000\n\nmod = 10 ** 9 + 7\nif N > M:\n N, M = M, N\n\nif M - N >= 2:\n print(0)\nelif M - N == 1:\n prod = 1\n for i in range(1, N + 1):\n prod = (prod * i) % mod\n print((prod * prod * M) % mod)\nelse:\n prod = 1\n for i in range(1, N + 1):\n prod = (prod * i) % mod\n print((2 * prod * prod) % mod)\n", "neg": "N, M = map(int, input().split())\n# N, M = 100000, 100000\n\nmod = 10 ** 9 + 7\nif N < M:\n N, M = M, N\n\nif M - N >= 2:\n print(0)\nelif M - N == 1:\n prod = 1\n for i in range(1, N + 1):\n prod = (prod * i) % mod\n print((prod * prod * M) % mod)\nelse:\n prod = 1\n for i in range(1, N + 1):\n prod = (prod * i) % mod\n print((2 * prod * prod) % mod)\n", "jacc_sim": 0.9722222222222222, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [158, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u329749432", "n_user": "u329749432", "pos": "import sys\nimport math\nn, m = (int(i) for i in input().split())\nl=abs(n-m)\ndiv=int(10**9+7)\n\nif l>1:\n print(0)\n sys.exit()\n\nif l==1:\n ans=(math.factorial(n)*math.factorial(m))%div\n print(ans)\nelse:\n ans=(math.factorial(n)*math.factorial(m)*2)%div\n print(ans)\n", "neg": "import sys\nimport math\nn, m = (int(i) for i in input().split())\nl=abs(n-m)\ndiv=int(10e9+7)\n\nif l>1:\n print(0)\n sys.exit()\n\nif l==1:\n ans=(math.factorial(n)*math.factorial(m))%div\n print(ans)\nelse:\n ans=(math.factorial(n)*math.factorial(m)*2)%div\n print(ans)\n", "jacc_sim": 0.9210526315789473, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [126, 126], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u256786023", "n_user": "u256786023", "pos": "#encoding: utf-8\n\ndef main():\n N,M=map(int,input().split())\n if(abs(N-M)>=2):\n print(0)\n return\n\n ret=1\n mod=10**9+7\n for i in range(1,N+1):\n ret*=i\n ret%=mod\n for i in range(1,M+1):\n ret*=i\n ret %= mod\n if(N==M):\n r=2\n else:\n r=1\n print((ret*r)%mod)\n\n\nif __name__ == '__main__':\n main()", "neg": "#encoding: utf-8\n\ndef main():\n N,M=map(int,input().split())\n if(abs(N-M)>=2):\n print(0)\n return \n\n ret=1\n mod=10**9+7\n for i in range(1,N+1):\n ret*=i\n ret%=mod\n for i in range(1,M+1):\n ret*=i\n ret %= mod\n print(ret*2)\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 0.9545454545454546, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [161, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u989047187", "n_user": "u989047187", "pos": "dog_ape = list(map(int,input().split(\" \")))\ndog_ape.sort()\ncut = (10**9)+7\n\ndef kai(n):\n ans = 1\n r = 0\n for i in range(n):\n ans *= (i+1)**2\n if ans > cut:\n ans %= cut\n return ans\n\nif dog_ape[0] == dog_ape[1]:\n ans = ( kai(dog_ape[0]) )*2\n ans %= cut\n print(ans)\n\nelif dog_ape[1] - dog_ape[0] == 1:\n ans = kai(dog_ape[0])*(dog_ape[1])\n ans %= cut\n print(ans)\n\nelse:\n print(0) \n", "neg": "dog_ape = list(map(int,input().split(\" \")))\ndog_ape.sort()\ncut = (10**9)+7\n\ndef kai(n):\n ans = 1\n r = 0\n for i in range(n):\n ans *= (i+1)**2\n return ans\n\nif dog_ape[0] == dog_ape[1]:\n ans = ( kai(dog_ape[0]) )*2\n ans %= cut\n print(ans)\n\nelif dog_ape[1] - dog_ape[0] == 1:\n ans = kai(dog_ape[0])*(dog_ape[1])\n ans %= cut\n print(ans)\n\nelse:\n print(0) \n", "jacc_sim": 0.9761904761904762, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [197, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u229757277", "n_user": "u229757277", "pos": "import math\nimport sys\n\na = sys.stdin.readline().split(' ')\nn = int(a[0])\nm = int(a[1])\n\nmodulator = 1000000007\n\nif n == m:\n\tprint((math.factorial(n) * math.factorial(m) * 2) % modulator)\nelif abs(n - m) == 1 :\n\tprint((math.factorial(n) * math.factorial(m)) % modulator)\nelse:\n\tprint(0)\n", "neg": "import math\nimport sys\n\na = sys.stdin.readline().split(' ')\nn = int(a[0])\nm = int(a[1])\n\nmodulator = 1000000007\n\nif n == m:\n\tprint((math.factorial(n) * math.factorial(m) * 2) % modulator)\nelif abs(n - m) == 1 :\n\tprint((math.factorial(n) * math.factorial(n)) % modulator)\nelse:\n\tprint(0)\n", "jacc_sim": 1.0, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [123, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u346308892", "n_user": "u346308892", "pos": "\ndef Factorial(integer) :\n global M\n product = 1\n if integer == 0 : return 1\n\n for num in range(1 ,integer + 1):\n product *= num\n product%=M\n return product%M\n\n\nd=sorted(list(map(int,input().split(\" \"))))\nM=10**9+7\n\nif abs(d[0]-d[1])>1:\n res=0\nelif d[0]==d[1]:\n\n res=((Factorial(d[0])%M)**2)*2\nelse:\n res=Factorial(d[1])*Factorial(d[0])\n\nprint(res%(M))\n", "neg": "def Factorial(integer) :\n global M\n\n product = 1\n if integer == 0 : return 1\n for num in range(1 ,integer + 1):\n product *= num\n product%=M\n return product\n\n\nd=sorted(list(map(int,input().split(\" \"))))\nM=10**9+7\n\nif abs(d[0]-d[1])>1:\n res=0\nelif d[0]==d[1]:\n\n res=((Factorial(d[0])%M)**2)*2\nelse:\n res=Factorial(d[1])*Factorialo(d[0])\n\nprint(res%(10**9+7))", "jacc_sim": 0.9777777777777777, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [170, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03683", "p_user": "u854685751", "n_user": "u854685751", "pos": "from math import factorial\n\nN,M = map(int,input().split())\n\ndef foo(N,M):\n\tif N == M+1 or N+1 == M:\n\t\ttm = factorial(min(N,M))\n\t\treturn(tm*max(N,M)*tm)\n\n\telif N==M:\n\t\treturn((factorial(N)**2)*2)\n\n\telse:\n\t\treturn(0)\n\nprint(foo(N,M)%(10**9+7))", "neg": "from math import factorial\n\nN,M = map(int,input().split())\n\ndef foo(N,M):\n\tif N == M+1 or N+1 == M:\n\t\ttm = factorial(min(N,M))\n\t\treturn(tm*max(N,M)+tm)\n\n\telif N==M:\n\t\treturn(2*factorial(N)*2)\n\n\telse:\n\t\treturn(0)\n\nprint(foo(N,M)/(10**9+7))", "jacc_sim": 0.9459459459459459, "nl": "Snuke has N dogs and M monkeys and wants to line them up in a row. The animals are on bad terms, and Snuke wants to arrange them so that there are neither two adjacent dogs nor two adjacent monkeys. The task is to find the count of such arrangements modulo 10^9+7. Dogs and monkeys are distinguishable, and reversed arrangements are also distinct. Constraints: 1 \u2264 N,M \u2264 10^5. Input is given as N and M, and the output should be the number of possible arrangements, modulo 10^9+7.", "before_after_length": [125, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03684", "p_user": "u059586440", "n_user": "u059586440", "pos": "n = int(input())\nxs = []\nys = []\n\nfor i in range(n):\n x, y = map(int, input().split())\n xs.append((x, i))\n ys.append((y, i))\n\n\nxs.sort()\nys.sort()\n\nes = []\n\nfor i in range(n-1):\n es.append((xs[i+1][0] - xs[i][0], xs[i][1], xs[i+1][1]))\n es.append((ys[i+1][0] - ys[i][0], ys[i][1], ys[i+1][1]))\n\nes.sort()\n\nclass UF:\n def __init__(self):\n self.p = {}\n def find(self, x):\n if x not in self.p:\n self.p[x] = x\n if x == self.p[x]:\n return x\n self.p[x] = self.find(self.p[x])\n return self.p[x]\n def merge(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x != y:\n self.p[x] = y\n\n\nuf = UF()\nans = 0\ntry:\n for d, i0, i1 in es:\n c0 = uf.find(i0)\n c1 = uf.find(i1)\n if c0 == c1:\n continue\n ans += d\n uf.merge(i0, i1)\n print(ans)\nexcept:\n print(0)\n", "neg": "n = int(input())\nxs = []\nys = []\n\nfor i in range(n):\n x, y = map(int, input().split())\n xs.append((x, i))\n ys.append((y, i))\n\n\nxs.sort()\nys.sort()\n\nes = []\n\nfor i in range(n-1):\n es.append((xs[i+1][0] - xs[i][0], xs[i][1], xs[i+1][1]))\n es.append((ys[i+1][0] - ys[i][0], ys[i][1], ys[i+1][1]))\n\nes.sort()\nprint(0)\nexit()\n\nclass UF:\n def __init__(self):\n self.p = {}\n def find(self, x):\n if x not in self.p:\n self.p[x] = x\n if x == self.p[x]:\n return x\n self.p[x] = self.find(self.p[x])\n return self.p[x]\n def merge(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x != y:\n self.p[x] = y\n\n\nuf= UF()\nans = 0\nfor d, i0, i1 in es:\n c0 = uf.find(i0)\n c1 = uf.find(i1)\n if c0 == c1:\n continue\n ans += d\n uf.merge(i0, i1)\nprint(ans)\n", "jacc_sim": 0.9444444444444444, "nl": "You are given the coordinates of N towns on a plane. You can build roads between towns at a cost equal to the minimum of the absolute differences in their x or y coordinates. Your task is to determine the minimum amount of money needed to build roads such that it will be possible to travel between every pair of towns. The input is given in a specific format, and the output should be the minimum necessary amount of money.", "before_after_length": [403, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03684", "p_user": "u835482198", "n_user": "u835482198", "pos": "class UnionFind(object):\n\n def __init__(self, n):\n self.n = n\n self.par = list(range(n))\n self.rank = [1] * n\n\n def is_same(self, a, b):\n return self.root(a) == self.root(b)\n\n def root(self, x):\n if self.par[x] == x:\n return x\n self.par[x] = self.root(self.par[x])\n return self.par[x]\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return\n if self.rank[x] > self.rank[y]:\n self.par[y] = x\n elif self.rank[x] < self.rank[y]:\n self.par[x] = y\n else:\n self.par[y] = x\n self.rank[x] += 1\n\n\nN = int(input())\nX = []\nY = []\nfor i in range(N):\n x, y = map(int, input().split())\n X.append((x, i))\n Y.append((y, i))\n\nX = sorted(X)\nY = sorted(Y)\ngraph = []\nfor i in range(N - 1):\n graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))\n graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))\n\ngraph.sort()\nuf = UnionFind(N)\n\ntotal_cost = 0\nfor cost, a, b in graph:\n if not uf.is_same(a, b):\n uf.unite(a, b)\n total_cost += cost\n\nprint(total_cost)\n", "neg": "s UnionFind(object):\n\n def __init__(self, n):\n self.n = n\n self.par = list(range(n))\n self.rank = [1] * n\n\n def is_same(self, a, b):\n return self.root(a) == self.root(b)\n\n def root(self, x):\n if self.par[x] == x:\n return x\n self.par[x] = self.root(self.par[x])\n return self.par[x]\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return\n if self.rank[x] > self.rank[y]:\n self.par[y] = x\n elif self.rank[x] < self.rank[y]:\n self.par[x] = y\n else:\n self.par[y] = x\n self.rank[x] += 1\n\n\nN = int(input())\nX = []\nY = []\nfor i in range(N):\n x, y = map(int, input().split())\n X.append((x, i))\n Y.append((y, i))\n\nX = sorted(X)\nY = sorted(Y)\ngraph = []\nfor i in range(N - 1):\n graph.append((X[i + 1][0] - X[i][0], X[i][1], X[i + 1][1]))\n graph.append((Y[i + 1][0] - Y[i][0], Y[i][1], Y[i + 1][1]))\n\ngraph.sort()\nuf = UnionFind(N)\n\ntotal_cost = 0\nfor cost, a, b in graph:\n if not uf.is_same(a, b):\n uf.unite(a, b)\n total_cost += cost\n\nprint(total_cost)\n", "jacc_sim": 0.9655172413793104, "nl": "You are given the coordinates of N towns on a plane. You can build roads between towns at a cost equal to the minimum of the absolute differences in their x or y coordinates. Your task is to determine the minimum amount of money needed to build roads such that it will be possible to travel between every pair of towns. The input is given in a specific format, and the output should be the minimum necessary amount of money.", "before_after_length": [484, 484], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03685", "p_user": "u923270446", "n_user": "u923270446", "pos": "import cmath\n\n\nr, c, n = map(int, input().split())\nlis = []\n\n\nfor i in range(n):\n x1, y1, x2, y2 = map(int, input().split())\n if (0 < x1 < r and 0 < y1 < c) or (0 < x2 < r and 0 < y2 < c):\n continue\n else:\n lis.append((i, x1 - r / 2 + (y1 - c / 2) * 1j))\n lis.append((i, x2 - r / 2 + (y2 - c / 2) * 1j))\n\n\nlis.sort(key=lambda x: cmath.phase(x[1]))\nstack = []\n\n\nfor i in lis:\n if stack == [] or stack[-1] != i[0]:\n stack.append(i[0])\n else:\n stack.pop()\n\n \nif stack == []:\n print(\"YES\")\nelse:\n print(\"NO\")", "neg": "import cmath\nr, c, n = map(int, input().split())\nlis = []\nfor i in range(n):\n x1, y1, x2, y2 = map(int, input().split())\n if 0 < x1 < r and 0 < x2 < r and 0 < y1 < c and 0 < y2 < c:\n continue\n else:\n lis.append((i, x1 - r / 2 + (y1 - c / 2) * 1j))\n lis.append((i, x2 - r / 2 + (y2 - c / 2) * 1j))\nlis.sort(key=lambda x: cmath.phase(x[1]))\nstack = []\nfor i in lis:\n if stack == [] or stack[-1] != i[0]:\n stack.append(i[0])\n else:\n stack.pop()\nif stack == []:\n print(\"YES\")\nelse:\n print(\"NO\")", "jacc_sim": 1.0, "nl": "You are given a rectangular board filled with numbers. Each integer from 1 to N is written twice at specific coordinates. The task is to draw a curve connecting the pairs of points where the same integer is written, for every integer from 1 to N. The curves must not go outside the board or cross each other. Determine if this is possible. Constraints: 1 \u2264 R,C \u2264 10^8, 1 \u2264 N \u2264 10^5, 0 \u2264 x_{i,1},x_{i,2} \u2264 R, 0 \u2264 y_{i,1},y_{i,2} \u2264 C, all given points are distinct, and all input values are integers. Input format: R, C, N, followed by x and y coordinates for each point. Output \"YES\" if the objective is achievable; otherwise, output \"NO\".", "before_after_length": [249, 235], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03685", "p_user": "u980322611", "n_user": "u980322611", "pos": "def main():\n import sys\n input = sys.stdin.readline\n \n R,C,N = map(int,input().split())\n P = []\n X = {0,R}\n Y = {0,C}\n M = 0\n for i in range(N):\n x1,y1,x2,y2 = map(int,input().split())\n if (x1 in X or y1 in Y) and (x2 in X or y2 in Y):\n if y1==0:\n L1 = x1\n elif x1==R:\n L1 = R+y1\n elif y1==C:\n L1 = 2*R + C - x1\n else:\n L1 = 2*(R+C) - y1\n \n if y2==0:\n L2 = x2\n elif x2==R:\n L2 = R+y2\n elif y2==C:\n L2 = 2*R + C - x2\n else:\n L2 = 2*(R+C) - y2\n \n P.append([min(L1,L2), max(L1,L2)])\n P = sorted(P, key = lambda a:a[0])\n M = len(P)\n \n flag = 0\n Q = []\n for i in range(M):\n x1,x2 = P[i]\n if Q == []:\n Q.append([x1,x2])\n else:\n while Q!=[] and Q[-1][1] < x1:\n Q.pop()\n if Q==[]:\n Q.append([x1,x2])\n else:\n y1,y2 = Q[-1]\n if y2 < x2:\n flag = 1\n break\n else:\n Q.append([x1,x2])\n if flag == 1:\n print(\"NO\")\n else:\n print(\"YES\")\n \nmain()", "neg": "def main():\n import sys\n input = sys.stdin.readline\n \n R,C,N = map(int,input().split())\n P = []\n X = {0,R}\n Y = {0,C}\n M = 0\n for i in range(N):\n x1,y1,x2,y2 = map(int,input().split())\n if (x1 in X or y1 in Y) and (x2 in X or y2 in Y):\n if y1==0:\n L1 = x1\n elif x1==R:\n L1 = R+y1\n elif y1==C:\n L1 = 2*R + C - x1\n else:\n L1 = 2*(R+C) - y1\n \n if y2==0:\n L2 = x2\n elif x2==R:\n L2 = R+y2\n elif y2==C:\n L2 = 2*R + C - x2\n else:\n L2 = 2*(R+C) - y2\n \n P.append([min(L1,L2), max(L1,L2)])\n P = sorted(P, key = lambda a:a[0])\n M = len(P)\n print(\"AAA\")\n \n flag = 0\n Q = []\n for i in range(M):\n x1,x2 = P[i]\n if Q == []:\n Q.append([x1,x2])\n else:\n while Q[-1][1] < x1 and Q!=[]:\n Q.pop()\n if Q==[]:\n Q.append([x1,x2])\n else:\n y1,y2 = Q[-1]\n if y2 < x2:\n flag = 1\n break\n else:\n Q.append([x1,x2])\n if flag == 1:\n print(\"NO\")\n else:\n print(\"YES\")\n \nmain()", "jacc_sim": 0.9852941176470589, "nl": "You are given a rectangular board filled with numbers. Each integer from 1 to N is written twice at specific coordinates. The task is to draw a curve connecting the pairs of points where the same integer is written, for every integer from 1 to N. The curves must not go outside the board or cross each other. Determine if this is possible. Constraints: 1 \u2264 R,C \u2264 10^8, 1 \u2264 N \u2264 10^5, 0 \u2264 x_{i,1},x_{i,2} \u2264 R, 0 \u2264 y_{i,1},y_{i,2} \u2264 C, all given points are distinct, and all input values are integers. Input format: R, C, N, followed by x and y coordinates for each point. Output \"YES\" if the objective is achievable; otherwise, output \"NO\".", "before_after_length": [491, 497], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03685", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\n\ndef main():\n R,C,N = LI()\n a = []\n def ff(x,y):\n if x == 0:\n return (0,y)\n if x == R:\n return (R,-y)\n if y == 0:\n return (R+1, -x)\n return (1, x)\n\n for _ in range(N):\n x1,y1,x2,y2 = LI()\n if (0 < x1 < R and 0 < y1 < C) or (0 < x2 < R and 0 < y2 < C):\n continue\n a.append((ff(x1,y1),_))\n a.append((ff(x2,y2),_))\n a.sort()\n b = [a[i][1] for i in range(len(a))]\n s = [None] * (len(b))\n si = -1\n for c in b:\n if si < -1:\n si += 1\n s[0] = c\n continue\n if s[si] == c:\n si -= 1\n else:\n si += 1\n s[si] = c\n\n if si > 1:\n return 'NO'\n return 'YES'\n\nprint(main())\n\n\n\n\n\n\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n\n\n\ndef main():\n R,C,N = LI()\n a = []\n def ff(x,y):\n if x == 0:\n return (0,y)\n if x == R:\n return (R,-y)\n if y == 0:\n return (R+1, -x)\n return (1, x)\n\n for _ in range(N):\n x1,y1,x2,y2 = LI()\n if (0 < x1 < R and 0 < y1 < C) or (0 < x2 < R and 0 < y2 < C):\n continue\n a.append((ff(x1,y1),_))\n a.append((ff(x2,y2),_))\n a.sort()\n b = [a[i][1] for i in range(len(a))]\n s = [None] * (len(b))\n si = -1\n for c in b:\n if si < -1:\n si += 1\n s[0] = c\n continue\n if s[si] == c:\n si -= 1\n else:\n si += 1\n s[si] = c\n\n if len(s) > 2:\n return 'NO'\n return 'YES'\n\nprint(main())\n\n\n\n\n\n\n", "jacc_sim": 0.9885057471264368, "nl": "You are given a rectangular board filled with numbers. Each integer from 1 to N is written twice at specific coordinates. The task is to draw a curve connecting the pairs of points where the same integer is written, for every integer from 1 to N. The curves must not go outside the board or cross each other. Determine if this is possible. Constraints: 1 \u2264 R,C \u2264 10^8, 1 \u2264 N \u2264 10^5, 0 \u2264 x_{i,1},x_{i,2} \u2264 R, 0 \u2264 y_{i,1},y_{i,2} \u2264 C, all given points are distinct, and all input values are integers. Input format: R, C, N, followed by x and y coordinates for each point. Output \"YES\" if the objective is achievable; otherwise, output \"NO\".", "before_after_length": [507, 510], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u810625173", "n_user": "u810625173", "pos": "import copy\nchar = list(map(chr, range(ord('a'), ord('z')+1)))\ntarget = list(input())\nans = float(\"inf\")\nfor c in char:\n s = copy.deepcopy(target)\n tmpans = 0\n while True:\n flag = True\n for si in s:\n if si != s[0]:\n flag = False\n if flag==True:\n break\n for i in range(len(s)-1):\n if s[i] == c or s[i+1] == c:\n s[i] = c\n s.pop()\n tmpans += 1\n if ans > tmpans:\n ans = tmpans\nprint(ans)\n \n\n", "neg": "import copy\nchar = list(map(chr, range(ord('a'), ord('z')+1)))\ntarget = list(input())\nans = float(\"inf\")\nfor c in char:\n s = copy.deepcopy(target)\n tmpans = 0\n while True:\n for i in range(len(s)-1):\n if s[i] == c or s[i+1] == c:\n s[i] = c\n s.pop()\n tmpans += 1\n flag = True\n for si in s:\n if si != s[0]:\n flag = False\n if flag==True:\n break\n if ans > tmpans:\n ans = tmpans\nprint(ans)\n \n\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [177, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u626891113", "n_user": "u626891113", "pos": "from collections import Counter\ns = list(input())\nd = Counter(s)\nkey = d.keys()\nans = len(s)//2 + len(s)%2\nfor k in key:\n ck = 0\n i = 0\n while True:\n if s[i] == k:\n i += 1\n if i == len(s):\n break\n else:\n cnt = 0\n while s[i + cnt] != k:\n cnt += 1\n if i + cnt == len(s):\n break\n ck = max(ck, cnt)\n i += cnt\n if i == len(s):\n break\n ans = min(ans, ck)\nprint(ans)", "neg": "from collections import Counter\ns = list(input())\nd = Counter(s)\nkey = d.keys()\nans = 0\nfor k in key:\n ck = 0\n i = 0\n while True:\n if s[i] == k:\n i += 1\n if i == len(s):\n break\n else:\n cnt = 0\n while s[i + cnt] != k:\n cnt += 1\n if i + cnt == len(s):\n break\n ck = max(ck, cnt)\n i += cnt\n if i == len(s):\n break\n ans = max(ans, ck)\nif ans == len(s) - 1:\n ans = len(s)//2 + len(s)%2\nprint(ans)\n", "jacc_sim": 0.9523809523809523, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [172, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u039623862", "n_user": "u039623862", "pos": "import string\ns = input()\nn = len(s)\n\nmin_cnt = float('inf')\n\nfor c in string.ascii_lowercase:\n if c not in s:\n continue\n cnt = 0\n s_ = s[:]\n while s_:\n m = len(s_) - 1\n is_same = True\n for d in s_:\n if d != c:\n is_same = False\n break\n if is_same:\n min_cnt = min(min_cnt, n - m-1)\n s_next = [''] * m\n for i in range(m):\n if s_[i] == c or s_[i + 1] == c:\n s_next[i] = c\n else:\n s_next[i] = s_[i]\n s_ = s_next\n\nprint(min_cnt)\n", "neg": "import string\ns = input()\nn = len(s)\n\nmin_cnt = float('inf')\n\nfor c in string.ascii_lowercase:\n if c not in s:\n continue\n cnt = 0\n s_ = s[:]\n while s_:\n is_same = True\n for d in s_:\n if d != c:\n is_same = False\n break\n if is_same:\n min_cnt = min(min_cnt, n - m)\n m = len(s_) - 1\n s_next = [''] * m\n for i in range(m):\n if s_[i] == c or s_[i + 1] == c:\n s_next[i] = c\n else:\n s_next[i] = s_[i]\n s_ = s_next\n\nprint(min_cnt)\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [219, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u871841829", "n_user": "u871841829", "pos": "S = input()\nans = 10e9\n\nvoc = set(S)\nfor c in voc:\n cnt = 0\n tmp = list(S)\n\n while True:\n if all([w == c for w in tmp]):\n ans = min(cnt, ans)\n break\n cnt += 1\n for u in range(len(tmp)-1):\n tmp[u] = c if tmp[u] == c or tmp[u+1] == c else tmp[u] \n tmp.pop()\n\n\nprint(ans)", "neg": "S = input()\nans = 10e9\nvoc = set(S)\nfor c in voc:\n cnt = 0\n tmp = list(S)\n\n while True:\n cnt += 1\n for u in range(len(tmp)-1):\n tmp[u] = c if tmp[u] == c or tmp[u+1] == c else tmp[u]\n \n tmp.pop()\n if all([w == c for w in tmp]):\n ans = min(cnt, ans)\n break\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [133, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u771007149", "n_user": "u771007149", "pos": "#AGC016-A\nfrom collections import Counter \ns = input()\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\n\nresult = []\nif len(set(s)) == 1:\n result.append(0)\nfor i in alphabet:\n s_tmp = s \n cnt = 0\n for k in range(len(s_tmp)):\n s_new= \"\"\n for j in range(len(s_tmp)-1):\n if s_tmp[j] == i or s_tmp[j+1] == i:\n s_new += i\n else:\n s_new += s_tmp[j]\n cnt += 1\n if len(set(s_new)) == 1:\n result.append(cnt)\n break \n\n s_tmp = s_new\n \n \n \n\n#print(result)\nprint(min(result))\n\n", "neg": "#AGC016-A\nfrom collections import Counter \ns = input()\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\ncnt = 0\nresult = []\nfor i in alphabet:\n s_tmp = s \n cnt = 0\n for k in range(len(s_tmp)):\n s_new= \"\"\n for j in range(len(s_tmp)-1):\n if s_tmp[j] == i or s_tmp[j+1] == i:\n s_new += i\n else:\n s_new += s_tmp[j]\n cnt += 1\n s_tmp = s_new\n if len(set(s_new)) == 1:\n result.append(cnt)\n break\n \n \n\n#print(result)\nprint(min(result))\n\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [219, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u619144316", "n_user": "u619144316", "pos": "from collections import Counter\n\nA = list(input())\nS = A\nMIN = 2000\nfor t in set(A):\n count = 0\n S = A\n while count <= MIN:\n if len(set(S)) == 1:\n MIN = min(count,MIN)\n break\n T = [None] * (len(S)-1)\n for i in range(len(T)):\n if S[i] == t or S[i+1] == t:\n T[i] = t\n else:\n T[i] = S[i]\n\n S = T\n count += 1\n\n\nprint(MIN)\n", "neg": "from collections import Counter\n\nA = list(input())\n\n\nS = A\nMIN = 100\nfor t in set(S):\n count = 0\n while True:\n T = [None] * (len(S)-1)\n for i in range(len(T)):\n if S[i] == t or S[i+1] == t:\n T[i] = t\n else:\n T[i] = S[i]\n\n S = T\n count += 1\n if len(set(S)) == 1:\n break\n\n MIN = min(count,MIN)\n S = A\n\nprint(MIN)\n", "jacc_sim": 0.9047619047619048, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [158, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u064434060", "n_user": "u064434060", "pos": "#import sys\n#import numpy as np\nimport math\n#import itertools\n#from fractions import Fraction\n#import itertools\nfrom collections import deque\nfrom collections import Counter\n#import heapq\n#from fractions import gcd\n#input=sys.stdin.readline\n#import bisect\ns=list(input())\nn=len(s)\ns_set=set(s)\nc=Counter(s)\ndic=[]\nfor i in s_set:\n bef=-1\n delta=0\n if c[i]==1:\n continue\n else:\n for j in range(n):\n if i==s[j]:\n res=j-bef-1\n bef=j\n delta = max(delta,res)\n res=n-1-bef\n dic.append(max(delta,res))\nif not dic:\n print(n//2)\nelse:\n print(min(n//2,min(dic)))\n", "neg": "#import sys\n#import numpy as np\nimport math\n#import itertools\n#from fractions import Fraction\n#import itertools\nfrom collections import deque\nfrom collections import Counter\n#import heapq\n#from fractions import gcd\n#input=sys.stdin.readline\n#import bisect\ns=list(input())\nn=len(s)\ns_set=set(s)\nc=Counter(s)\ndic=[]\nfor i in s_set:\n bef=-1\n delta=0\n if c[i]==1:\n continue\n else:\n print(i)\n for j in range(n):\n if i==s[j]:\n res=j-bef-1\n bef=j\n delta = max(delta,res)\n res=n-1-bef\n print(bef)\n dic.append(max(delta,res))\nprint(dic)\nif not dic:\n print(n//2)\nelse:\n print(min(n//2,min(dic)))\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [233, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u453642820", "n_user": "u453642820", "pos": "S=input()\nA=\"abcdefghijklmnopqrstuvwxyz\"\nminimum=len(S)//2\nfor a in A:\n ans_max=0\n p=0\n for s in S:\n if a==s:\n ans_max=max(p,ans_max)\n p=0\n else:\n p+=1\n ans_max=max(p,ans_max)\n minimum=min(ans_max,minimum)\nprint(minimum)", "neg": "S=input()\nA=\"abcdefghijklmnopqrstuvwxyz\"\nminimum=len(S)//2\nfor a in set(S):\n maximum=0\n ans_max=0\n p=0\n for s in S:\n if a==s:\n ans_max=max(p-1,maximum)\n p=0\n else:\n p+=1\n minimum=min(ans_max,minimum)\nprint(minimum)", "jacc_sim": 0.9032258064516129, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [119, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u760636024", "n_user": "u760636024", "pos": "S = input()\nres = len(S)\nkind_all = set(S)\nfor i in kind_all:\n temp = S.split(i)\n cnt = 0\n for j in temp:\n cnt = max(cnt,len(j))\n res = min(res,cnt)\nprint(res)", "neg": "S = list(input())\nres = len(S)\nkind_all = set(S)\nfor i in kind_all:\n temp = S.split(i)\n cnt = 0\n for j in temp:\n cnt = max(cnt,len(j))\n res = min(res,cnt)\nprint(res)", "jacc_sim": 0.9583333333333334, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [77, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u593567568", "n_user": "u593567568", "pos": "S = input()\nuni_s = list(set(list(S)))\n\nans = len(S) - 1\n\n# -1,1\nfor s in uni_s:\n L = len(S)\n T = list(S)\n all_same = [s == t for t in S]\n cnt = 0\n while not all(all_same):\n cnt += 1\n newT = [False] * (L-1)\n for i in range(L):\n t = T[i]\n if s == t:\n if i < L-1:\n newT[i] = t\n if 0 <= i-1:\n newT[i-1] = t\n else:\n if i < L-1 and not newT[i]:\n newT[i] = t\n if 0 <= i-1 and not newT[i-1]:\n newT[i-1] = t\n \n all_same = [s==t for t in newT]\n T = newT\n L = len(T)\n ans = min(ans,cnt)\n\nprint(ans)\n \n \n", "neg": "S = input()\nuni_s = list(set(list(S)))\n\nans = len(S) - 1\n\n# -1,1\nfor s in uni_s:\n L = len(S)\n T = list(S)\n all_same = [s == t for t in S]\n cnt = 0\n while not all(all_same):\n newT = [False] * (L-1)\n for i in range(L):\n t = T[i]\n if s == t:\n if i < L-1:\n newT[i] = t\n if 0 <= i-1:\n newT[i-1] = t\n else:\n if i < L-1 and not newT[i]:\n newT[i] = t\n if 0 <= i-1 and not newT[i-1]:\n newT[i-1] = t\n \n all_same = [s==t for t in newT]\n T = newT\n L = len(T)\n ans = min(ans,cnt)\n\nprint(ans)\n \n \n", "jacc_sim": 0.975609756097561, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [279, 274], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u623687794", "n_user": "u623687794", "pos": "s=input()\nans=1000\nfor i in range(26):\n if chr(97+i) not in s:continue\n S=s\n cnt=0\n while(len(set(S)))!=1:\n cnt+=1\n t=\"\"\n for j in range(len(S)-1):\n if S[j] == chr(97+i) or S[j+1] == chr(97+i):\n t+=chr(97+i)\n else:\n t+=S[j]\n S=t\n ans=min(cnt,ans)\nprint(ans)\n", "neg": "s=input()\nans=1000\nfor i in range(26):\n if chr(97+i) not in s:continue\n S=s\n cnt=0\n while(len(set(S)))!=1:\n cnt+=1\n t=\"\"\n for j in range(len(S)-1):\n if S[j] == chr(97+i) or S[j+1] == chr(97+i):\n t+=chr(97+i)\n else:\n t+=S[j]\n ans=min(cnt,ans)\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [151, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u797550216", "n_user": "u797550216", "pos": "s = input()\nl = list(set(s))\n\nif len(set(s)) == 1:\n print(0)\n exit()\n\nmin_c = 10**8\nfor i in l:\n old_s = s\n new_s = ''\n idx = 1\n c = 0\n \n while True:\n for j in range(len(s)-idx):\n if old_s[j] == i or old_s[j+1] == i:\n new_s += i\n \n else:\n new_s += old_s[j]\n \n idx += 1\n c += 1\n \n if len(set(new_s)) == 1:\n break\n \n else:\n old_s = new_s\n new_s = ''\n \n min_c = min(min_c,c)\n\nprint(min_c)", "neg": "s = input()\nl = list(set(s))\n\nmin_c = 10**8\nfor i in l:\n old_s = s\n new_s = ''\n idx = 1\n c = 0\n while True:\n for j in range(len(s)-idx):\n if old_s[j] == i or old_s[j+1] == i:\n new_s += i\n \n else:\n new_s += old_s[j]\n \n idx += 1\n c += 1\n \n if len(set(new_s)) == 1:\n break\n \n else:\n old_s = new_s\n new_s = ''\n \n min_c = min(min_c,c)\n\nprint(min_c)\n ", "jacc_sim": 0.975, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [219, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u520276780", "n_user": "u995062424", "pos": "s = input()\nal = set(list(s))\nans = 100\nfor c in al:\n L = list(s.split(c))\n tmp = 0\n for st in L:\n tmp = max(tmp,len(st))\n tmp = max(tmp,len(L[0]))\n tmp = max(tmp,len(L[-1]))\n ans = min(tmp,ans)\nprint(ans)\n\n", "neg": "s = input()\nal = set(list(s)) \nans = 100\n\nfor c in al:\n L = list(s.split(c))\n print(L)\n tmp = 0\n for st in L:\n tmp = max(tmp, len(st))\n #tmp = max(tmp, len(L[0]))\n #tmp = max(tmp, len(L[-1]))\n ans = min(tmp, ans)\n #print(ans)\nprint(ans)", "jacc_sim": 0.9666666666666667, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [104, 119], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u691018832", "n_user": "u691018832", "pos": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\ns = input()\nlen_s = len(s)\ncnt = [0] * 26\nal = [chr(ord('a') + i) for i in range(26)]\nans = [''] * (len_s + 1)\nans[0] = s\nfor i in range(26):\n check = list(s)\n if al[i] in check:\n ans[0] = s\n while any([al[i] != a for a in check]):\n cnt[i] += 1\n for j in range(len_s - cnt[i]):\n if ans[cnt[i] - 1][j + 1] == al[i]:\n ans[cnt[i]] += al[i]\n else:\n ans[cnt[i]] += ans[cnt[i] - 1][j]\n check = list(ans[cnt[i]])\n ans[cnt[i] - 1] = ''\nif all(cnt[i] == 0 for i in range(26)):\n print(0)\nelse:\n cnt = sorted(set(cnt))\n if cnt[0] == 0:\n print(cnt[1])\n else:\n print(cnt[0])\n", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\nsys.setrecursionlimit(10 ** 7)\n\ns = input()\nlen_s = len(s)\ncnt = [0] * 26\nal = [chr(ord('a') + i) for i in range(26)]\nans = [''] * (len_s + 1)\nans[0] = s\nfor i in range(26):\n check = list(s)\n if al[i] in check:\n ans[0] = s\n while any([al[i] != a for a in check]):\n cnt[i] += 1\n for j in range(len_s - cnt[i]):\n if ans[cnt[i] - 1][j + 1] == al[i]:\n ans[cnt[i]] += al[i]\n else:\n ans[cnt[i]] += ans[cnt[i] - 1][j]\n check = list(ans[cnt[i]])\n ans[cnt[i] - 1] = ''\nif all(cnt[i] == 0 for i in range(26)):\n print(0)\nelse:\n s = list(set(s))\n s.sort()\n if s[0] == 0:\n print(s[1])\n else:\n print(s[0])\n", "jacc_sim": 0.9607843137254902, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [337, 343], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u217627525", "n_user": "u217627525", "pos": "s=input()\nn=len(s)\nans=n\nfor i in range(97, 97+26):\n x=chr(i)\n cnt=s.count(x)\n if cnt==n:\n ans=0\n break\n if cnt!=0:\n t=list(s)\n for j in range(n-1):\n u=[\"\"]*(n-1-j)\n for k in range(n-1-j):\n if t[k]==x or t[k+1]==x:\n u[k]=x\n else:\n u[k]=t[k]\n if u.count(x)==n-1-j:\n ans=min(ans,j+1)\n break\n else:\n t=u\nprint(ans)", "neg": "s=input()\nn=len(s)\nans=n\nfor i in range(97, 97+26):\n x=chr(i)\n cnt=s.count(x)\n if cnt!=0:\n t=list(s)\n for j in range(n-1):\n u=[\"\"]*(n-1-j)\n for k in range(n-1-j):\n if t[k]==x or t[k+1]==x:\n u[k]=x\n else:\n u[k]=t[k]\n if u.count(x)==n-1-j:\n ans=min(ans,j+1)\n break\n else:\n t=u\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [200, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u987164499", "n_user": "u987164499", "pos": "from sys import stdin\nimport string\n\nt = stdin.readline().rstrip()\nalpha = string.ascii_lowercase\nmi = 10**10\nif len(set(t)) == 1:\n print(0)\n exit() \nfor target in alpha:\n s = t\n cnt = 0\n while True:\n cnt += 1\n sin = \"\"\n for i in range(len(s)-1):\n sin += s[i] if s[i] == target else s[i+1]\n s = sin\n if s.count(target) == len(s):\n break\n mi = min(mi,cnt)\n\nprint(mi)", "neg": "from sys import stdin\nimport string\n\nt = stdin.readline().rstrip()\nalpha = string.ascii_lowercase\nmi = 10**10\n\nfor target in alpha:\n s = t\n cnt = 0\n while True:\n cnt += 1\n sin = \"\"\n for i in range(len(s)-1):\n sin += s[i] if s[i] == target else s[i+1]\n s = sin\n if s.count(target) == len(s):\n break\n mi = min(mi,cnt)\n\nprint(mi)", "jacc_sim": 0.9555555555555556, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [160, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u754022296", "n_user": "u861141787", "pos": "s = input()\nans = float(\"inf\")\nfor i in range(26):\n c = chr(ord(\"a\")+i)\n if c not in s:\n continue\n temp = s\n count = 0\n while set(temp) != {c}:\n t = \"\"\n for j in range(len(temp)-1):\n if temp[j] == c or temp[j+1] == c:\n t += c\n else:\n t += \"#\"\n temp = t\n count += 1\n ans = min(ans, count)\nprint(ans)", "neg": "s = input()\nans = float(\"inf\")\nfor i in range(26):\n c = chr(ord(\"a\")+i)\n if c not in s:\n continue\n temp = s\n count = 0\n while set(temp) != {c}:\n t = \"\"\n for j in range(len(temp)-1):\n if temp[j] == c or temp[j+1] == c:\n t += c\n else:\n t += \"#\"\n temp = t\n count += 1\n print(temp)\n ans = min(ans, count)\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [140, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u644907318", "n_user": "u644907318", "pos": "s = input().strip()\nn = len(s)\nD = {chr(i):[] for i in range(97,123)}\nfor i in range(97,123):\n for j in range(n):\n if s[j]==chr(i):\n D[chr(i)].append(j)\ncntmin = 1000\nfor i in range(97,123):\n if len(D[chr(i)])==1:\n d = D[chr(i)][0]\n cntmin = min(cntmin,max(d,n-1-d))\n elif len(D[chr(i)])>1:\n A = []\n for j in range(len(D[chr(i)])):\n if j==0:\n A.append(D[chr(i)][0])\n if j1:\n A = []\n for j in range(len(D[chr(i)])):\n if j==0:\n A.append(D[chr(i)][0])\n A.append(D[chr(i)][1]-D[chr(i)][0]-1)\n elif j==len(D[chr(i)])-1:\n A.append(n-D[chr(i)][-1])\n else:\n A.append(D[chr(i)][j+1]-D[chr(i)][j]-1)\n cntmin = min(cntmin,max(A))\nprint(cntmin)", "jacc_sim": 0.9285714285714286, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [284, 318], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u263830634", "n_user": "u263830634", "pos": "s = list(input())\nN = len(s)\nif N == 1:\n print (0)\n exit()\n\nans = 99\nfor i in range(1, N): #\u6b8b\u3059\u6587\u5b57\u6570\n tmp = 0 #\u6b8b\u3059\u6587\u5b57\u4ee5\u5916\u306e\u6700\u5927\u9023\u7d9a\u6570\n count = 0 #\u6b8b\u3059\u6587\u5b57\u4ee5\u5916\u304c\u4f55\u6587\u5b57\u7d9a\u3044\u3066\u3044\u308b\u304b\u3092\u30ab\u30a6\u30f3\u30c8\n for j in range(i):\n if s[j] == s[i]:\n tmp = max(tmp, count)\n count = 0\n else:\n count += 1\n tmp = max(tmp, count)\n ans = min(ans, max(tmp, N - i - 1))\n\nprint (ans)", "neg": "s = list(input())\nN = len(s)\nif N == 1:\n print (0)\n exit()\n\n ans = 99\nfor i in range(1, N): #\u6b8b\u3059\u6587\u5b57\u6570\n tmp = 0 #\u6b8b\u3059\u6587\u5b57\u4ee5\u5916\u306e\u6700\u5927\u9023\u7d9a\u6570\n count = 0 #\u6b8b\u3059\u6587\u5b57\u4ee5\u5916\u304c\u4f55\u6587\u5b57\u7d9a\u3044\u3066\u3044\u308b\u304b\u3092\u30ab\u30a6\u30f3\u30c8\n for j in range(i):\n if s[j] == s[i]:\n tmp = max(tmp, count)\n count = 0\n else:\n count += 1\n tmp = max(tmp, count)\n ans = min(ans, max(tmp, N - i - 1))\n\nprint (ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [250, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u256868077", "n_user": "u256868077", "pos": "s=input()\nl=len(s)\na=[1]*(l+1)\nc=[]\nx=0\nwhile(x<=l-1):\n if(a[x]==1):\n a[x]=0\n k=0\n b=[x]\n t=s+s[x]\n for i in range(x+1,l+1):\n if(t[x]==t[i]):\n b.append(k)\n a[i]=0\n k=0\n else:\n k+=1\n c.append(max(b))\n x+=1\nprint(min(c))", "neg": "s=input()\nl=len(s)\na=[1]*(l+1)\nc=[]\nx=0\nwhile(x<=l-1):\n if(a[x]==1):\n a[x]=0\n k=0\n b=[x-1]\n t=s+s[x]\n for i in range(x+1,l+1):\n if(t[x]==t[i]):\n b.append(k)\n a[i]=0\n k=0\n else:\n k+=1\n c.append(max(b))\n x+=1\nprint(min(c))", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [162, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u712822150", "n_user": "u712822150", "pos": "from sys import stdin\n\n# n = int(stdin.readline().rstrip())\ns = stdin.readline().rstrip()\n# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]\n# data = [stdin.readline().rstrip().split() for _ in range(n)]\n\nans = len(s)\nfor c in range(ord('a'), ord('z')+1):\n cnt, cntMax = 0, 0\n for i in range(0, len(s)):\n if s[i] == chr(c):\n cntMax = max(cnt, cntMax)\n cnt = 0\n continue\n cnt += 1\n cntMax = max(cnt, cntMax)\n ans = min(ans, cntMax)\nprint(ans, '\\n')\n# print(*data, sep='\\n')\n", "neg": "from sys import stdin\n\n# n = int(stdin.readline().rstrip())\ns = stdin.readline().rstrip()\n# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]\n# data = [stdin.readline().rstrip().split() for _ in range(n)]\n\nans = len(s)\nfor c in range(ord('a'), ord('z')+1):\n cnt, cntMax = 0, 0\n for i in range(0, len(s)-1):\n if s[i] == chr(c):\n cntMax = max(cnt, cntMax)\n cnt = 0\n continue\n cnt += 1\n cntMax = max(cnt, cntMax)\n ans = min(ans, cntMax)\nprint(ans, '\\n')\n# print(*data, sep='\\n')\n", "jacc_sim": 0.9803921568627451, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [208, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u500297289", "n_user": "u500297289", "pos": "s = input()\nl = list(s)\nN = len(s)\nn = len(s)\nans = 0\n\nif len(set(s)) == 1:\n print(0)\n exit()\n\nfor ll in l:\n S = s\n n = N\n while n > 0:\n tmp = ''\n for i in range(n - 1):\n if S[i] == ll or S[i + 1] == ll:\n tmp += ll\n else:\n tmp += S[i]\n if len(set(tmp)) == 1:\n ans = max(ans, len(tmp))\n break\n n -= 1\n S = tmp\n\nprint(N - ans)\n", "neg": "s = input()\nl = set(list(s))\nN = len(s)\nn = len(s)\nans = 0\n\nfor ll in l:\n S = s\n while n > 0:\n tmp = ''\n for i in range(n - 1):\n if S[i] == ll or S[i + 1] == ll:\n tmp += ll\n else:\n tmp += S[i]\n if len(set(tmp)) == 1:\n ans = max(ans, len(tmp))\n break\n n -= 1\n S = tmp\n\nprint(N - ans)\n", "jacc_sim": 0.972972972972973, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [173, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u623819879", "n_user": "u623819879", "pos": "\ns=input()\ndef change(s,x):\n if s.count(x)==len(s):\n return 0\n t=s\n u=''\n for i in range(1,len(s)):\n for j in range(len(t)-1):\n if t[j]==x or t[j+1]==x:\n u+=x\n else:\n u+=t[j]\n if u.count(x)==len(u):\n return i\n t=u\n u=''\nm=[]\nfor i in s:\n m.append(change(s,i))\nprint(min(m))", "neg": "\ns=input()\ndef change(s,x):\n t=s\n u=''\n for i in range(1,len(s)):\n for j in range(len(t)-1):\n if t[j]==x or t[j+1]==x:\n u+=x\n else:\n u+=t[j]\n if u.count(x)==len(u):\n return i\n t=u\n u=''\nm=[]\nfor i in s:\n m.append(change(s,i))\nprint(min(m))", "jacc_sim": 0.9714285714285714, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [163, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u163320134", "n_user": "u163320134", "pos": "check='abcdefghijklmnopqrstuvwxyz'\ns=input()\nl=len(s)\npos=[[0] for _ in range(26)]\nfor i in range(l):\n for j in range(26):\n if s[i]==check[j]:\n pos[j].append(i+1)\nans=10**9\nfor i in range(26):\n tmp=0\n for j in range(len(pos[i])-1):\n tmp=max(tmp,pos[i][j+1]-pos[i][j]-1)\n tmp=max(tmp,l-pos[i][-1])\n ans=min(ans,tmp)\nprint(ans)\n", "neg": "check='abcdefghijklmnopqrstuvwxyz'\ns=input()\nl=len(s)\npos=[0]*26\nfor i in range(l):\n for j in range(26):\n if s[i]==check[j]:\n pos[j].append(i)\nans=10**9:\n for i in range(26):\n tmp=0\n for j in range(len(pos[i])-1):\n tmp=max(tmp,pos[i][j+1]-pos[i][j])\n tmp=max(tmp,(l-1)-pos[i][-1])\n ans=min(ans,tmp)\nprint(ans)", "jacc_sim": 0.972972972972973, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [173, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u945418216", "n_user": "u945418216", "pos": "from collections import Counter\nss = input()\n\nans = 1000\ncandidates = set(ss)\nfor s in candidates:\n count = 0\n t = list(ss)\n while True:\n if len(set(t))==1:\n ans = min(ans, count)\n break\n t = [t[i] if t[i+1] != s else t[i+1] for i in range(len(t)-1)]\n count += 1\nprint(ans)", "neg": "from collections import Counter\nss = input()\n\nans = 1000\ncandidates = list(set(ss))\nfor s in candidates:\n count = 0\n t = list(ss)\n while True:\n t = [t[i] if t[i+1] != s else t[i+1] for i in range(len(t)-1)]\n count += 1\n # print(count, s, t)\n if len(set(t))==1:\n ans = min(ans, count)\n break\nprint(ans)", "jacc_sim": 0.9743589743589743, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [116, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u619819312", "n_user": "u619819312", "pos": "s=list(input())\np=[chr(ord(\"a\")+i)for i in range(26)]\nq=100\nif len(list(set(s)))==1:\n print(0)\nelse:\n for i in range(26):\n t=p[i]\n d=s[:]\n c=0\n while len(d)>0:\n c+=1\n for j in range(len(d)-1):\n if d[j]==t or d[j+1]==t:\n d[j]=t\n else:\n d.pop(-1)\n if len(list(set(d)))==1 and d[0]==t:\n break\n q=min(q,c)\n print(q)", "neg": "s=list(input())\np=[chr(ord(\"a\")+i)for i in range(26)]\nq=100\nfor i in range(26):\n t=p[i]\n d=s[:]\n c=0\n while len(d)>0:\n c+=1\n for j in range(len(d)-1):\n if d[j]==t or d[j+1]==t:\n d[j]=t\n else:\n d.pop(-1)\n if len(list(set(d)))==1 and d[0]==t:\n break\n q=min(q,c)\nprint(q)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [188, 164], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u745087332", "n_user": "u745087332", "pos": "# coding:utf-8\n\nfrom collections import Counter\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nS = input()\nC = Counter(S)\nif len(S) == 1:\n print(0)\n exit()\n\nans = 100\nfor key in C.keys():\n prev_S = list(S)\n cnt = 0\n t = len(S) - 1\n while t > 0:\n if all([1 if s == key else 0 for s in prev_S]):\n ans = min(ans, cnt)\n break\n SS = []\n for i in range(t):\n if key in prev_S[i: i + 2]:\n SS.append(key)\n else:\n SS.append(prev_S[i])\n cnt += 1\n t -= 1\n prev_S = SS[:]\n # print(cnt, prev_S)\n\nprint(ans)\n", "neg": "# coding:utf-8\n\nfrom collections import Counter\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nS = input()\nC = Counter(S)\nif len(S) == 1:\n print(0)\n exit()\n\nans = 100\nfor key in C.keys():\n prev_S = list(S)\n cnt = 0\n t = len(S) - 1\n while t > 0:\n if all([1 if s == key else 0 for s in prev_S]):\n ans = min(ans, cnt)\n break\n SS = []\n for i in range(t):\n if key in prev_S[i: i + 2]:\n SS.append(key)\n else:\n SS.append(prev_S[i])\n cnt += 1\n t -= 1\n prev_S = SS[:]\n print(cnt, prev_S)\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [232, 231], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u785989355", "n_user": "u785989355", "pos": "def itoa(i):\n alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',\n 'p','q','r','s','t','u','v','w','x','y','z']\n return alphabet[i]\ns = input()\nscore_list = []\nfor i in range(26):\n c = itoa(i)\n prev = -1\n score = 0\n flag=False\n for j in range(len(s)):\n if c==s[j]:\n score=max(j-prev-1,score)\n flag=True\n prev=j\n score = max(j-prev,score)\n if flag==False:\n score=10**3\n score_list.append(score)\n\nprint(min(score_list))", "neg": "def itoa(i):\n alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',\n 'p','q','r','s','t','u','v','w','x','y','z']\n return alphabet[i]\ns = input()\nscore_list = []\nfor i in range(26):\n c = itoa(i)\n prev = 0\n score = 0\n flag=False\n for j in range(len(s)):\n if c==s[j]:\n score=max(j-prev-1,score)\n flag=True\n prev=j\n score = max(j-prev,score)\n if flag==False:\n score=10**3\n score_list.append(score)\n \nprint(min(score_list))", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [208, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u624475441", "n_user": "u624475441", "pos": "S = input()\nans = min(max(map(len, S.split(c)))\n for c in [chr(i + 97) for i in range(26)]\n if c in S)\nprint(ans)", "neg": "S = input()\nans = min(max(map(len, S.split(c)))\n for c in [chr(i + 97) for i in range(26)]\n if c not in S))\nprint(ans)", "jacc_sim": 0.9629629629629629, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [52, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u323680411", "n_user": "u323680411", "pos": "import sys\n\n\ndef next_str() -> str:\n result = \"\"\n while True:\n tmp = sys.stdin.read(1)\n if tmp.strip() != \"\":\n result += tmp\n elif tmp != '\\r':\n break\n return result\n\n\ndef main() -> None:\n s = next_str()\n dic = [set() for _ in range(len(s))]\n\n flg = False\n\n for i in range(len(s)):\n dic[i].add(s[i])\n\n while True:\n for c in range(ord('a'), ord('z') + 1):\n for i in range(len(dic)):\n if chr(c) not in dic[i]:\n break\n else:\n flg = True\n\n for i in range(len(dic) - 1):\n dic[i] |= dic[i + 1]\n\n if flg: break\n dic = dic[:-1]\n\n print(len(s) - len(dic))\n\n\nif __name__ == '__main__':\n main()", "neg": "import sys\n\n\ndef next_str() -> str:\n result = \"\"\n while True:\n tmp = sys.stdin.read(1)\n if tmp.strip() != \"\":\n result += tmp\n elif tmp != '\\r':\n break\n return result\n\n\ndef main() -> None:\n s = next_str()\n dic = [set() for _ in range(len(s))]\n\n flg = False\n\n for i in range(len(s)):\n dic[i].add(s[i])\n\n print(dic)\n\n while True:\n for c in range(ord('a'), ord('z') + 1):\n for i in range(len(dic)):\n if chr(c) not in dic[i]:\n break\n else:\n flg = True\n\n for i in range(len(dic) - 1):\n dic[i] |= dic[i + 1]\n\n if flg: break\n dic = dic[:-1]\n\n print(len(s) - len(dic))\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [268, 275], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u879870653", "n_user": "u879870653", "pos": "S = input()\nP = list(set(S))\nANS = []\nfor i in range(len(P)) :\n T = list(S.split(P[i]))\n U = []\n for j in range(len(T)) :\n U.append(len(T[j]))\n ANS.append(max(U))\nprint(min(ANS))\n", "neg": "S = input()\nP = list(set(P))\nANS = []\nfor i in range(len(P)) :\n T = list(S.split(P[i]))\n U = []\n for j in range(len(T)) :\n U.append(len(T[j]))\n ANS.append(max(U))\nprint(min(ANS))\n", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [90, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u309977459", "n_user": "u309977459", "pos": "s = input()\nf = {}\ng = {}\n\nchars = [c for c in s]\n#print(chars)\n\nfor char in chars:\n f[char] = []\n f[char].append(-1)\n for i, c in enumerate(s):\n if(c==char):\n f[char].append(i)\n f[char].append(len(s))\n\nmax_len_all = len(s)\nfor char in chars:\n max_len = 0\n for i in range(len(f[char])-1):\n max_len = max(max_len, f[char][i+1]-f[char][i])\n g[char] = max_len\n if(g[char] min:\n break\n s = new_s\n if min > j:\n min = j\n\nprint(min)", "neg": "\na = input()\n\nfor target in set(s):\n s = a\n j = 0\n min = 10000\n while(1):\n \n if len(set(s)) == 1:\n break\n new_s = \"\"\n for i in range(len(s)-1):\n if s[i] == target or s[i+1] == target:\n new_s +=target\n else:\n new_s += s[i]\n j+=1;\n s = new_s\n if min > j:\n min = j\nprint(min)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [151, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u063962277", "n_user": "u063962277", "pos": "ans = 999\ns = input()\nabc = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(26):\n ls = [list(s)]\n j = 0\n while True:\n if ls[j] == list(abc[i]*(len(s)-j)):\n break\n ls.append([])\n for k in range(len(ls[j])-1):\n if ls[j][k] == abc[i] or ls[j][k+1] == abc[i]:\n ls[j+1].append(abc[i])\n else:\n ls[j+1].append(ls[j][k])\n j += 1\n \n \n ans = min(ans, len(ls)-1) \n \nprint(ans)", "neg": "ans = 999\ns = input()\nabc = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(26):\n ls = [s]\n j = 0\n while True:\n ls.append([])\n for k in range(len(ls[j])-1):\n if ls[j][k] == abc[i] or ls[j][k+1] == abc[i]:\n ls[j+1].append(abc[i])\n else:\n ls[j+1].append(ls[j][k])\n j += 1\n if ls[j] == list(abc[i]*(len(s)-j)):\n break\n \n ans = min(ans, len(ls)-1) \n \nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [190, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03687", "p_user": "u039623862", "n_user": "u039623862", "pos": "s = input()\nn = len(s)\nmin_t = float('inf')\nfor i in range(n):\n target = s[i]\n pre = -1\n max_t = 0\n for j in range(n):\n if s[j] == s[i]:\n max_t = max(max_t, j-pre-1)\n pre = j\n max_t = max(max_t, n - pre-1)\n if max_t < min_t:\n min_t = min(min_t, max_t)\nprint(min_t)", "neg": "s = input()\nn = len(s)\nmin_t = float('inf')\nfor i in range(n):\n target = s[i]\n pre = 0\n max_t = 0\n for j in range(n):\n if s[j] == s[i]:\n max_t = max(max_t, j-pre-1)\n pre = j\n max_t = max(max_t, n - pre-1)\n if max_t < min_t:\n min_t = min(min_t, max_t)\nprint(min_t)", "jacc_sim": 1.0, "nl": "Snuke can transform a string \"t\" of length \"N\" into a string \"t'\" of length \"N - 1\" by a specific rule. For each \"i\" (1 \u2264 i \u2264 N - 1), the \"i\"-th character of \"t'\" must be either the \"i\"-th or \"(i + 1)\"-th character of \"t\". Given a string \"s\" consisting of lowercase English letters, Snuke aims to apply the operation to \"s\" repeatedly until all characters in \"s\" are the same. Find the minimum number of operations needed. Constraints: 1 \u2264 |s| \u2264 100, and \"s\" consists of lowercase English letters. Input is given as \"s\", and the output should be the minimum number of operations required to achieve the objective.", "before_after_length": [145, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03690", "p_user": "u582577761", "n_user": "u582577761", "pos": "n,a,b=int(input()),list(map(int,input().split()))+[0],list(map(int,input().split()))+[0]\nfor i in range(n):\n\ta[n]^=a[i]\n\tb[n]^=b[i]\nna,nb=sorted(a),sorted(b)\nif na!=nb:\n\tprint(\"-1\")\n\texit()\nf=dict()\ndef find(x):\n\tif f[x]==x:\n\t\treturn x\n\telse:\n\t\tf[x]=find(f[x])\n\t\treturn f[x]\nans=0\nfor i in range(n):\n\tif a[i]!=b[i]:\n\t\tf[a[i]]=a[i]\nf[a[n]]=a[n]\nfor i in range(n):\n\tif a[i]!=b[i]:\n\t\tans+=1\n\t\tf[find(b[i])]=find(a[i])\nfor i in f:\n\tif i==f[i]:\n\t\tans+=1\nprint(ans-1)", "neg": "n,a,b,ax,bx=int(input()),list(map(int,input().split()))+[0],list(map(int,input().split()))+[0],0,0\nna,nb=a,b\nfor i in range(n):\n\ta[n]^=a[i]\n\tb[n]^=b[i]\na,b=sorted(a),sorted(b)\nif sum([a[i]!=b[i] for i in range(n+1)]):\n\tprint(\"-1\")\n\texit()\nf=dict()\ndef find(x):\n\tif f[x]==x:\n\t\treturn x\n\telse:\n\t\tf[x]=find(f[x])\n\t\treturn f[x]\nans=0\nfor i in range(n):\n\tif na[i]!=nb[i]:\n\t\tf[na[i]]=na[i]\nf[a[n]]=a[n]\nfor i in range(n):\n\tif na[i]!=nb[i]:\n\t\tans+=1\n\t\tf[find(nb[i])]=find(na[i])\nfor i,j in f:\n\tif i==j:\n\t\tans+=1\nprint(ans-1)", "jacc_sim": 0.9111111111111111, "nl": "You are given a sequence of non-negative integers. You can perform an operation where you replace an element with the XOR of all elements. Your goal is to match the sequence with another given sequence. Determine if this is achievable and find the minimum number of operations needed. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 a_i, b_i < 2^30. Input format: N, followed by sequences a and b. Output the minimum number of operations or -1 if not achievable.", "before_after_length": [283, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00439", "p_user": "u476702877", "n_user": "u476702877", "pos": "def func(n,k):\n SUM = 0\n ans = 0\n A = [int(input()) for _ in range(n)]\n for i in range(k):\n SUM += A[i]\n for i in range(k,len(A)):\n ans = max(ans,SUM+A[i]-A[i-k])\n SUM = SUM+A[i]-A[i-k]\n print(ans)\n\nfor _ in range(10):\n n,k = [int(s) for s in input().split()]\n if n == 0 and k ==0:\n break\n else:\n func(n,k)\n", "neg": "def func(n,k):\n SUM = 0\n ans = 0\n A = [int(input()) for _ in range(n)]\n for i in range(k-1):\n SUM += A[i]\n for i in range(k,len(A)):\n ans = max(ans,SUM+A[i]-A[i-k])\n SUM = SUM+A[i]-A[i-k]\n print(ans)\n\nfor _ in range(10):\n n,k = [int(s) for s in input().split()]\n if n == 0 and k ==0:\n break\n else:\n func(n,k)\n", "jacc_sim": 0.9722222222222222, "nl": "Title: Maximum Sum\n\nProblem:\nGiven a sequence of n integers a1, a2, ..., an and a positive integer k (1 \u2264 k \u2264 n), create a program to output the maximum value of the sum Si = ai + ai+1 + ... + ai+k-1 (1 \u2264 i \u2264 n - k + 1).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format and ends with a line containing two zeros.\n- The first line contains two positive integers n (1 \u2264 n \u2264 100000) and k (1 \u2264 k \u2264 n) separated by a space.\n- Starting from the second line, each line i (1 \u2264 i \u2264 n) contains the i-th term of the sequence ai (-10000 \u2264 ai \u2264 10000).\nAmong the test data for evaluation, 60% satisfy n \u2264 5000 and k \u2264 1000.\nThe number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum value of Si on a separate line.\n\nExample:\nInput\n5 3\n2\n5\n-4\n10\n3\n0 0\n\nOutput\n11", "before_after_length": [163, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00439", "p_user": "u859393176", "n_user": "u859393176", "pos": "def main():\n\twhile True:\n\t\ta = []\n\t\tn, k = [int(x) for x in input().split()]\n\t\tif n == 0 and k == 0: break\n\t\tfor i in range(n): a.append(int(input()))\n\t\tl = [0]\n\t\tfor i in range(1, n - k + 1): l.append(a[i + k - 1] - a[i - 1])\n\t\tmaxsum = 0\n\t\tmaxi = 0\n\t\ts = 0\n\t\tfor i, x in enumerate(l):\n\t\t\ts += x\n\t\t\tif s >= maxsum:\n\t\t\t\tmaxsum = s\n\t\t\t\tmaxi = i\n\t\tprint(sum(a[maxi:maxi + k]))\nmain()", "neg": "def main():\n\twhile True:\n\t\ta = []\n\t\tn, k = [int(x) for x in input().split()]\n\t\tif n == 0 and k == 0: break\n\t\tfor i in range(n): a.append(int(input()))\n\t\tl = [0]\n\t\tfor i in range(1, n - k + 2): l.append(a[i + k - 2] - a[i - 1])\n\t\tmaxsum = 0\n\t\tmaxi = 0\n\t\ts = 0\n\t\tfor i, x in enumerate(l):\n\t\t\ts += x\n\t\t\tif s >= maxsum:\n\t\t\t\tmaxsum = s\n\t\t\t\tmaxi = i\n\t\tprint(sum(a[i - 1:i + k - 1]))\nmain()", "jacc_sim": 0.975, "nl": "Title: Maximum Sum\n\nProblem:\nGiven a sequence of n integers a1, a2, ..., an and a positive integer k (1 \u2264 k \u2264 n), create a program to output the maximum value of the sum Si = ai + ai+1 + ... + ai+k-1 (1 \u2264 i \u2264 n - k + 1).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format and ends with a line containing two zeros.\n- The first line contains two positive integers n (1 \u2264 n \u2264 100000) and k (1 \u2264 k \u2264 n) separated by a space.\n- Starting from the second line, each line i (1 \u2264 i \u2264 n) contains the i-th term of the sequence ai (-10000 \u2264 ai \u2264 10000).\nAmong the test data for evaluation, 60% satisfy n \u2264 5000 and k \u2264 1000.\nThe number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum value of Si on a separate line.\n\nExample:\nInput\n5 3\n2\n5\n-4\n10\n3\n0 0\n\nOutput\n11", "before_after_length": [190, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00439", "p_user": "u563075864", "n_user": "u563075864", "pos": "while 1:\n n,k = [int(i) for i in input().split()]\n if not (n and k):\n break\n a = [int(input()) for i in range(n)]\n b = [0]*len(a)\n\n for i in range(n):\n b[i] = b[i-1] + a[i]\n b = b + [0]\n\n c = [b[i + k - 1] - b[i - 1] for i in range(n - k + 1)]\n\n print(max(c))\n", "neg": "while 1:\n n,k = [int(i) for i in input().split()]\n if not n and k:\n break\n a = [int(input()) for i in range(n)]\n b = [0]*len(a)\n\n for i in range(n):\n b[i] = b[i-1] + a[i]\n b = b + [0]\n\n c = [b[i + k - 1] - b[i - 1] for i in range(n - k + 1)]\n\n print(max(c))\n", "jacc_sim": 1.0, "nl": "Title: Maximum Sum\n\nProblem:\nGiven a sequence of n integers a1, a2, ..., an and a positive integer k (1 \u2264 k \u2264 n), create a program to output the maximum value of the sum Si = ai + ai+1 + ... + ai+k-1 (1 \u2264 i \u2264 n - k + 1).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format and ends with a line containing two zeros.\n- The first line contains two positive integers n (1 \u2264 n \u2264 100000) and k (1 \u2264 k \u2264 n) separated by a space.\n- Starting from the second line, each line i (1 \u2264 i \u2264 n) contains the i-th term of the sequence ai (-10000 \u2264 ai \u2264 10000).\nAmong the test data for evaluation, 60% satisfy n \u2264 5000 and k \u2264 1000.\nThe number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum value of Si on a separate line.\n\nExample:\nInput\n5 3\n2\n5\n-4\n10\n3\n0 0\n\nOutput\n11", "before_after_length": [140, 139], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00441", "p_user": "u797673668", "n_user": "u797673668", "pos": "while True:\n n = int(input())\n if not n:\n break\n\n poles = [tuple(map(int, input().split())) for _ in range(n)]\n poles_set = set(poles)\n\n max_square = 0\n for i in range(n):\n x1, y1 = poles[i]\n for j in range(i, n):\n x2, y2 = poles[j]\n dx, dy = x2 - x1, y2 - y1\n if ((x2 + dy, y2 - dx) in poles_set and (x1 + dy, y1 - dx) in poles_set) \\\n or ((x2 - dy, y2 + dx) in poles_set and (x1 - dy, y1 + dx) in poles_set):\n edge = dx ** 2 + dy ** 2\n if max_square < edge:\n max_square = edge\n print(max_square)", "neg": "n = int(input())\n\npoles = [tuple(map(int, input().split())) for _ in range(n)]\npoles_set = set(poles)\n\nmax_square = 0\nfor i in range(n):\n x1, y1 = poles[i]\n for j in range(i, n):\n x2, y2 = poles[j]\n dx, dy = x2 - x1, y2 - y1\n if ((x2 + dy, y2 - dx) in poles_set and (x1 + dy, y1 - dx) in poles_set) \\\n or ((x2 - dy, y2 + dx) in poles_set and (x1 - dy, y1 + dx) in poles_set):\n edge = dx ** 2 + dy ** 2\n if max_square < edge:\n max_square = edge\nprint(max_square)", "jacc_sim": 0.9130434782608695, "nl": "Oldest Ruins\n\nProblem:\nLong ago, there was a settlement where many people lived. The people built various buildings of different shapes and sizes. However, these structures have been lost, and the only clues to their locations are found in literature and the pillars discovered at the ruins.\n\nThe literature describes a temple. When viewed from above, the temple is precisely a square, with pillars at each of its four corners. It is unknown which direction the temple faced, and it is also unclear whether there were pillars on the edges or inside. Archaeologists believed that among the pillars found at the ruins, the one with the largest area forming a square must be the temple.\n\nGiven the coordinates of the pillars, write a program to find the largest square formed by four pillars and output its area. Note that the sides of the square may not be parallel to the coordinate axes.\n\nExample:\nIn the example below, there are 10 pillars. Four pillars at coordinates (4, 2), (5, 2), (5, 3), (4, 3) form a square, as do four pillars at coordinates (1, 1), (4, 0), (5, 3), (2, 4). The larger square is formed by the latter set of pillars, with an area of 10.\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format and ends with a line containing a single zero.\n\nThe first line contains the number of pillars found at the ruins, n.\n\nThe next n lines each contain the x and y coordinates of a pillar, separated by a space.\n\nEach pillar appears only once.\n\nn is an integer satisfying 1 \u2264 n \u2264 3000, and the x and y coordinates of the pillars are integers between 0 and 5000.\n\nOutput:\nFor each dataset, output a single integer. If there exists a square formed by four pillars, output the area of the largest such square. If no such square exists, output 0.\n\nInput/Output Example:\nInput:\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n10\n9 4\n4 3\n1 1\n4 2\n2 4\n5 8\n4 0\n5 3\n0 5\n5 2\n0\n\nOutput:\n10\n10", "before_after_length": [238, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00443", "p_user": "u352394527", "n_user": "u352394527", "pos": "from math import gcd\nwhile True:\n try:\n n = int(input())\n if not n: break\n lst = [[]]\n weight = [-1 for i in range(n + 1)]\n def setWeight(n):\n p,q,r,b = lst[n]\n if weight[n] != -1:pass\n elif r == 0 and b == 0:\n weight[n] = (p + q) // gcd(p,q)\n elif r == 0:\n setWeight(b)\n wb = weight[b]\n g = gcd(wb * q, p)\n lcm = wb * q * p // g\n weight[n] = lcm // q + lcm // p\n# print(\"wr:\",str(lcm//p),\"wb:\",str(wb),\"g:\",g,\"p:\",p,\"lcm\",lcm)\n elif b == 0:\n setWeight(r)\n wr = weight[r]\n g = gcd(wr * p, q)\n lcm = wr * p * q // g\n weight[n] = lcm // p + lcm // q\n else:\n if weight[r] == -1: setWeight(r)\n if weight[b] == -1: setWeight(b)\n wr = weight[r]\n wb = weight[b]\n g = gcd(wr * p, wb * q)\n lcm = wr * p * wb * q // g\n weight[n] = lcm // p + lcm // q\n for i in range(n):\n lst.append(list(map(int,input().split())))\n for i in range(0,n):\n if weight[i + 1] == -1:\n setWeight(i+1)\n print(max(weight))\n# print(weight)\n except EOFError:\n break\n\n\n", "neg": "from math import gcd\nwhile True:\n try:\n n = int(input())\n if not n: break\n lst = [[]]\n weight = [-1 for i in range(n + 1)]\n def setWeight(n):\n p,q,r,b = lst[n]\n if weight[n] != -1:pass\n elif r == 0 and b == 0:\n weight[n] = (p + q) // gcd(p,q)\n elif r == 0:\n setWeight(b)\n wb = weight[b]\n g = gcd(wb * q, p)\n lcm = wb * q * p // g\n weight[n] = lcm // q + lcm // p\n print(\"wr:\",str(lcm//p),\"wb:\",str(wb),\"g:\",g,\"p:\",p,\"lcm\",lcm)\n elif b == 0:\n setWeight(r)\n wr = weight[r]\n g = gcd(wr * p, q)\n lcm = wr * p * q // g\n weight[n] = lcm // p + lcm // q\n else:\n if weight[r] == -1: setWeight(r)\n if weight[b] == -1: setWeight(b)\n wr = weight[r]\n wb = weight[b]\n g = gcd(wr * p, wb * q)\n lcm = wr * p * wb * q // g\n weight[n] = lcm // p + lcm // q\n for i in range(n):\n lst.append(list(map(int,input().split())))\n for i in range(0,n):\n if weight[i + 1] == -1:\n setWeight(i+1)\n print(max(weight))\n print(weight)\n except EOFError:\n break\n\n\n", "jacc_sim": 0.9833333333333333, "nl": "Title: Lightest Mobile\n\nProblem:\nMobiles are widely appreciated as moving works of art. The IOI Japanese Committee has decided to create a mobile to promote JOI. The JOI promotional mobile is composed of three elements: a rod, a string, and a weight. The rod has one end painted blue and the other end painted red. The rod is suspended by a string at one point other than the ends. The length from the suspension point to the red end and from the suspension point to the blue end is a positive integer. The rod's ends are suspended with a weight or another rod using a string. The weight is suspended at one end of a rod using a string. The weight is a positive integer. One of the strings is tied to the suspension point of a rod to suspend another rod, and the other end is not tied to any other component. The weight of the rod and string is negligible, so they are considered to have a weight of 0. Each rod must be balanced. The program should find a way to attach the weights to minimize the total weight of the mobile while keeping each rod balanced. The program should output the total weight of the mobile. The program is given the following information about the mobile's composition:\n- Number of rods, n\n- Information for each rod (rod number from 1 to n)\n - Ratio of length from the suspension point to the red end and from the suspension point to the blue end\n - Number of the rod suspended at the red end (0 if a weight is suspended)\n - Number of the rod suspended at the blue end (0 if a weight is suspended)\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format and ends with a line containing a single 0.\n- The first line contains the number of rods, n.\n- The next n lines (1 \u2264 n \u2264 100) contain data for each rod. The i-th line (1 \u2264 i \u2264 n) contains four integers p, q, r, b separated by a space, representing the ratio of length from the suspension point to the red end and from the suspension point to the blue end for rod i, the number of the rod suspended at the red end, and the number of the rod suspended at the blue end, respectively. Rod number 0 represents a weight suspended. For all inputs, let w be the minimum weight of the mobile and L be the maximum value of a positive integer used to represent a ratio in the input. It holds that wL < 2^31.\n\nOutput:\nFor each dataset, output the weight of the mobile on a separate line.\n\nInput/Output Example:\nInput:\n1\n6 9 0 0\n4\n3 2 0 4\n1 3 0 0\n4 4 2 1\n2 2 0 0\n0\n\nOutput:\n5\n40", "before_after_length": [463, 461], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u404942781", "n_user": "u404942781", "pos": "#!/usr/bin/env python\n#coding:utf-8\n\nwhile True:\n coin = [500,100,50,10,5,1]\n oturi = 1000 - int(input())\n if oturi == 1000:\n break\n ret = 0\n for c in coin:\n ret += oturi // c\n oturi %= c\n print(ret)", "neg": "#!/usr/bin/env python\n#coding:utf-8\n\ncoin = [500,100,50,10,5,1]\noturi = 1000 - int(input())\nret = 0\nfor c in coin:\n ret += oturi // c\n oturi %= c\nprint(ret)", "jacc_sim": 0.9024390243902439, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [92, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u355726239", "n_user": "u355726239", "pos": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ncoins = [500, 100, 50, 10, 5, 1]\n\nwhile True:\n x = 1000 - int(input())\n if x == 1000:\n break\n\n ret = 0\n for coin in coins:\n n = x//coin\n x = x - n*coin\n ret += n\n\n print(ret)", "neg": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nx = 1000 - int(input())\n\ncoins = [500, 100, 50, 10, 5, 1]\n\nret = 0\nfor coin in coins:\n n = x//coin\n x = x - n*coin\n ret += n\n\nprint(ret)", "jacc_sim": 0.9047619047619048, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [107, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u546285759", "n_user": "u546285759", "pos": "def change(v):\n global c, o\n if o>= v:\n t= o//v\n o, c= o-(v*t), c+t\n\nwhile True:\n o= int(input())\n if o== 0: break\n c, o= 0, 1000-o\n for l in [500, 100, 50, 10, 5, 1]: change(l)\n print(c+o)", "neg": "c, o= 0, 1000-int(input())\ndef change(v):\n global c, o\n if o>= v:\n t= o//v\n o, c= o-(v*t), c+t\n\nfor l in [500, 100, 50, 10, 5, 1]: change(l)\nprint(int(c+o))", "jacc_sim": 0.918918918918919, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [104, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u227162786", "n_user": "u227162786", "pos": "coins = [500, 100, 50, 10, 5, 1]\nif __name__ == '__main__':\n while True:\n p = int(input())\n if p == 0:\n break\n ch = 1000 - p\n\n count = 0\n for coin in coins:\n n = ch // coin\n ch -= coin * n\n count += n\n \n print(count)", "neg": "coins = [500, 100, 50, 10, 5, 1]\nif __name__ == '__main__':\n p = int(input())\n ch = 1000 - p\n\n count = 0\n for coin in coins:\n n = ch // coin\n ch -= coin * n\n count += n\n \n print(count)", "jacc_sim": 0.918918918918919, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [97, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u376883550", "n_user": "u376883550", "pos": "COINS = [500, 100, 50, 10, 5, 1]\n\nchange = 1000 - int(input())\nwhile change != 1000:\n total = 0\n for coin in COINS:\n total += change // coin\n change %= coin\n\n print(total)\n\n change = 1000 - int(input())", "neg": "COINS = [500, 100, 50, 10, 5, 1]\n\nchange = 1000 - int(input())\ntotal = 0\nfor coin in COINS:\n total += change // coin\n change %= coin\n\nprint(total)", "jacc_sim": 0.9333333333333333, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [77, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n b,c=1000-int(e),0\n for i in[500,100,50,10,5]:\n d,b=divmod(b,i)\n c+=d\n print(b+c)\n", "neg": "for e in iter(input,'0'):\nwhile 1:\n b,c=1000-int(e),0\n for i in[500,100,50,10,5]:\n d,b=divmod(b,i)\n c+=d\n print(b+c)\n", "jacc_sim": 0.9354838709677419, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [64, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00444", "p_user": "u365131854", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n\ta,b=0,1000-int(e)\n\tfor i in[500,100,50,10,5]:\n\t\ta+=b//i\n\t\tb%=i\n\tprint(a+b)\n", "neg": "for e in iter(input,'0'):\n a,b=0,1000-int(e)\n for i in[500,100,50,10,5]:\n b%=i\n a+=b//i\n print(b+a)\n", "jacc_sim": 1.0, "nl": "Title: \u304a\u3064\u308a\n\nProblem:\nTaro often shops at the JOI variety store. The store has an ample supply of coins in denominations of 500 yen, 100 yen, 50 yen, 10 yen, 5 yen, and 1 yen. Taro always pays in a way that minimizes the number of coins he receives as change. Write a program to determine the number of coins Taro receives as change when he pays with a 1000 yen bill at the JOI store.\n\nFor example, for input 1, the output should be 4.\n\nInput:\nThe input consists of multiple datasets. Each dataset consists of a single line containing the amount Taro pays (an integer between 1 and 999). The input ends with a single line containing 0.\n\nThere are no more than 5 datasets.\n\nOutput:\nFor each dataset, output the number of coins in the change received in a single line.\n\nInput Example:\n380\n1\n0\n\nOutput Example:\n4\n15", "before_after_length": [65, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00446", "p_user": "u408260374", "n_user": "u408260374", "pos": "def discard(c, cards):\n for card in cards:\n if c < card:\n return card\n return 0\n\nwhile True:\n n = int(input())\n if n == 0: \n break\n taro = [int(input()) for _ in range(n)]\n hanako = [x + 1 for x in range(2*n) if (x + 1) not in taro]\n taro.sort()\n hanako.sort()\n\n table = 0\n while True:\n if taro:\n table = discard(table, taro)\n if table:\n taro.remove(table)\n \n if not taro:\n print(len(hanako))\n print(0)\n break\n \n if hanako:\n table = discard(table, hanako)\n if table:\n hanako.remove(table)\n if not hanako:\n print(0)\n print(len(taro))\n break", "neg": "n = int(input())\ntaro = [int(input()) for _ in range(n)]\nhanako = [x + 1 for x in range(2*n) if (x + 1) not in taro]\ntaro.sort()\nhanako.sort()\n\ndef discard(c, cards):\n for card in cards:\n if c < card:\n return card\n return 0\n\ntable = 0\nwhile True:\n if taro:\n table = discard(table, taro)\n if table:\n taro.remove(table)\n \n if not taro:\n print(len(hanako))\n print(0)\n break\n \n if hanako:\n table = discard(table, hanako)\n if table:\n hanako.remove(table)\n if not hanako:\n print(0)\n print(len(taro))", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nProblem:\nThere is a card game played by two people. In this game, 2n cards with integers from 1 to 2n are used, where n is an integer between 1 and 100, inclusive. The cards are distributed equally between the two players. Players take turns placing a card on the table according to specific rules. The game starts with no cards on the table. The game ends when one player runs out of cards, and the opponent's remaining cards determine their score.\n\nTaro and Hanako are playing this game, starting with Taro's turn. Both players always play the smallest available card. Given the cards Taro receives, create a program to output the scores of Taro and Hanako.\n\nInput:\nThe input consists of multiple datasets. Each dataset has the following format: The first line contains an integer n. The next n lines each contain an integer representing the cards Taro receives. When n is 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output Taro's score on the first line and Hanako's score on the second line.\n\nInput Example:\n5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0\n\nOutput Example:\n3\n0\n2\n0", "before_after_length": [252, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00446", "p_user": "u546285759", "n_user": "u546285759", "pos": "import bisect\nwhile True:\n n = int(input())\n if n == 0:\n break\n tc = sorted([int(input()) for _ in range(n)])\n hc = sorted([v for v in range(1, 2*n+1) if v not in tc])\n ba = []\n flag = True\n while tc and hc:\n if len(ba) == 0:\n try:\n if flag:\n tmp = tc.pop(0)\n flag = False\n else:\n tmp = hc.pop(0)\n flag = True\n except IndexError:\n pass\n ba = [tmp]\n continue\n\n last_card = ba[-1]\n if flag:\n x = bisect.bisect_left(tc, last_card)\n flag = False\n try:\n tmp = tc.pop(x)\n except IndexError:\n ba = []\n continue\n else:\n x = bisect.bisect_left(hc, last_card)\n flag = True\n try:\n tmp = hc.pop(x)\n except IndexError:\n ba = []\n continue\n ba.append(tmp)\n print(len(hc))\n print(len(tc))", "neg": "import bisect\nwhile True:\n n = int(input())\n if n == 0:\n break\n tc = sorted([int(input()) for _ in range(n)])\n hc = sorted([v for v in range(1, 2*n+1) if v not in tc])\n ba = []\n flag = True\n while tc and hc:\n if len(ba) == 0:\n try:\n if flag:\n tmp = tc.pop(0)\n flag = False\n else:\n tmp = hc.pop(0)\n flag = True\n except IndexError:\n pass\n ba = [tmp]\n continue\n\n last_card = ba[-1]\n if flag:\n x = bisect.bisect_left(tc, last_card)\n flag = False\n try:\n tmp = tc.pop(x)\n except IndexError:\n ba = []\n continue\n else:\n x = bisect.bisect_left(hc, last_card)\n flag = True\n try:\n tmp = hc.pop(x)\n except IndexError:\n ba = []\n continue\n ba.append(tmp)\n print(len(tc))\n print(len(hc))", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nProblem:\nThere is a card game played by two people. In this game, 2n cards with integers from 1 to 2n are used, where n is an integer between 1 and 100, inclusive. The cards are distributed equally between the two players. Players take turns placing a card on the table according to specific rules. The game starts with no cards on the table. The game ends when one player runs out of cards, and the opponent's remaining cards determine their score.\n\nTaro and Hanako are playing this game, starting with Taro's turn. Both players always play the smallest available card. Given the cards Taro receives, create a program to output the scores of Taro and Hanako.\n\nInput:\nThe input consists of multiple datasets. Each dataset has the following format: The first line contains an integer n. The next n lines each contain an integer representing the cards Taro receives. When n is 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output Taro's score on the first line and Hanako's score on the second line.\n\nInput Example:\n5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0\n\nOutput Example:\n3\n0\n2\n0", "before_after_length": [300, 300], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00446", "p_user": "u546285759", "n_user": "u546285759", "pos": "import bisect\nwhile True:\n n = int(input())\n if n == 0:\n break\n card_set = [sorted(int(input()) for _ in range(n)), []]\n card_set[1] = sorted({i for i in range(1, 2*n+1)}.difference(card_set[0]))\n card = turn = 0\n flag = 1\n ba = []\n while flag:\n if len(ba) == 0:\n card = card_set[turn].pop(0)\n ba.append(card)\n flag = 0 if len(card_set[turn])==0 else 1\n turn = 0 if turn else 1\n continue\n last_card = ba[-1]\n x = bisect.bisect_left(card_set[turn], last_card)\n try:\n card = card_set[turn].pop(x)\n ba.append(card)\n except IndexError:\n ba = []\n flag = 0 if len(card_set[turn])==0 else 1\n turn = 0 if turn else 1\n print(*[len(cet) for cet in card_set[::-1]], sep='\\n')", "neg": "import bisect\nwhile True:\n n = int(input())\n if n == 0:\n break\n card_set = [sorted(int(input()) for _ in range(n)), []]\n card_set[1] = sorted({i for i in range(1, 2*n+1)}.difference(card_set[0]))\n card = turn = 0\n flag = 1\n ba = []\n while flag:\n if len(ba) == 0:\n card = card_set[turn].pop(0)\n ba.append(card)\n flag = 0 if len(card_set[turn])==0 else 1\n turn = 0 if turn else 1\n continue\n last_card = ba[-1]\n x = bisect.bisect_left(card_set[turn], last_card)\n try:\n card = card_set[turn].pop(x)\n ba.append(card)\n except IndexError:\n ba = []\n flag = 0 if len(card_set[turn])==0 else 1\n turn = 0 if turn else 1\n print(*[len(cet) for cet in card_set], sep='\\n')", "jacc_sim": 1.0, "nl": "Title: Card Game\n\nProblem:\nThere is a card game played by two people. In this game, 2n cards with integers from 1 to 2n are used, where n is an integer between 1 and 100, inclusive. The cards are distributed equally between the two players. Players take turns placing a card on the table according to specific rules. The game starts with no cards on the table. The game ends when one player runs out of cards, and the opponent's remaining cards determine their score.\n\nTaro and Hanako are playing this game, starting with Taro's turn. Both players always play the smallest available card. Given the cards Taro receives, create a program to output the scores of Taro and Hanako.\n\nInput:\nThe input consists of multiple datasets. Each dataset has the following format: The first line contains an integer n. The next n lines each contain an integer representing the cards Taro receives. When n is 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output Taro's score on the first line and Hanako's score on the second line.\n\nInput Example:\n5\n1\n7\n9\n6\n10\n10\n8\n7\n14\n18\n4\n11\n3\n17\n5\n19\n0\n\nOutput Example:\n3\n0\n2\n0", "before_after_length": [288, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u352394527", "n_user": "u352394527", "pos": "def main():\n while True:\n m = int(input())\n if not m: break\n seiza = []\n for i in range(m):\n seiza.append(list(map(int,input().split())))\n kijun = seiza.pop(0)\n \n n = int(input())\n hosi = []\n point = {}\n \n for i in range(n):\n x,y = map(int,input().split())\n point[x,y] = 1\n hosi.append([x,y])\n \n for a in hosi:\n dx,dy = a[0] - kijun[0], a[1] - kijun[1]\n for b in seiza:\n if not (b[0] + dx, b[1] + dy) in point:\n break\n else:\n print(dx,dy)\n break\nmain() \n", "neg": "def main()\n while True:\n m = int(input())\n if not m: break\n seiza = []\n for i in range(m):\n seiza.append(list(map(int,input().split())))\n kijun = seiza.pop(0)\n \n n = int(input())\n hosi = []\n point = {}\n \n for i in range(n):\n x,y = map(int,input().split())\n point[x,y] = 1\n hosi.append([x,y])\n \n for a in hosi:\n dx,dy = a[0] - kijun[0], a[1] - kijun[1]\n for b in seiza:\n if not (b[0] + dx, b[1] + dy) in point:\n break\n else:\n print(dx,dy)\n break\nmain() \n", "jacc_sim": 1.0, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [232, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])\n b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n if not set((u+x,v+y)for u,v in a)-set(b):print(x,y);break\n", "neg": "\u0001\u0001for e in iter(input,'0'):\n a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])\n b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n for u,v in a:\n if (u+x,v+y)not in b:break\n else:print(x,y)\n", "jacc_sim": 0.9069767441860465, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [146, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n a=[list(map(int,input().split()))for _ in[0]*int(e)]\n b=[list(map(int,input().split()))for _ in[0]*int(input())]\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n for u,v in a:\n if[u+x,v+y]not in b:break\n else:print(x,y)\n", "neg": "\u0001\u0001for e in iter(input,'0'):\n a=[list(map(int,input().split()))for _ in[0]*int(e)]\n b=[list(map(int,input().split()))for _ in[0]*int(input())]\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n for u,v in a:\n if[u+x,v+y]not in b:break\n else:print(x,y)\n", "jacc_sim": 0.972972972972973, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [127, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n a=[list(map(int,input().split()))for _ in[0]*int(e)]\n b=[tuple(map(int,input().split()))for _ in[0]*int(input())]\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n if not set((u+x,v+y)for u,v in a)-set(b):print(x,y);break\n", "neg": "for e in iter(input,'0'):\n a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])\n b=sorted([tuple(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])\n for s,t in b:\n if not set((u+s-a[0][0],v+t-a[0][1])for u,v in a)-set(b):print(x,y);break\n", "jacc_sim": 0.9047619047619048, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [123, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "def f(e):\n a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])\n b=sorted([list(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n for u,v in a:\n if[u+x,v+y]not in b:break\n else:return print(x,y)\nfor e in iter(input,'0'):f(e)\n", "neg": "def f():\n for e in iter(input,'0'):\n a=sorted([list(map(int,input().split()))for _ in[0]*int(e)],key=lambda x:x[0])\n b=sorted([list(map(int,input().split()))for _ in[0]*int(input())],key=lambda x:x[0])\n for s,t in b:\n u,v=a[0]\n x,y=s-u,t-v\n for u,v in a:\n if[u+x,v+y]not in b:break\n else:return print(x,y)\nf()\n", "jacc_sim": 1.0, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [161, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0'):\n a=list(tuple(map(int,input().split())) for _ in range(int(e)))\n s,t=a[0]\n b=[tuple(map(int,input().split())) for _ in range(int(input()))]\n for x,y in b:\n flag = True\n for u,v in a[1:]:\n if(x+u-s,y+v-t)not in b:\n flag = False\n break\n if flag == True:\n print(x - s, y - t)\n break\n", "neg": "for e in iter(input,'0'):\n a={tuple(map(int,input().split())) for _ in range(int(e))}\n s,t=a[0]\n b={tuple(map(int,input().split())) for _ in range(int(input()))}\n for x,y in b:\n flag = True\n for u,v in a[1:]:\n if(x+u-s,y+v-t)not in b:\n flag = False\n break\n if flag == True:\n print(x - s, y - t)\n break\n", "jacc_sim": 0.9285714285714286, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [145, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "def f(e):\n a=list([*map(int,input().split())]for _ in range(int(e)))\n s,t=a[0]\n b={tuple(map(int,input().split()))for _ in range(int(input()))}\n for x,y in b:\n for u,v in a[1:]:\n if(x+u-s,y+v-t)not in b:break\n else:return print(x-s,y-t)\nfor e in iter(input,'0'):f(e)\n", "neg": "def f(e):\n a=list([*map(int,input().split())]for _ in range(int(e)))\n s,t=a[0]\n b={(*map(int,input().split()))for _ in range(int(input()))}\n for x,y in b:\n for u,v in a[1:]:\n if(x+u-s,y+v-t)not in b:break\n else:return print(x-s,y-t)\nfor e in iter(input,'0'):f(e)\n", "jacc_sim": 0.9772727272727273, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [135, 134], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00447", "p_user": "u150984829", "n_user": "u150984829", "pos": "import operator\nfor e in iter(input,'0'):\n target = [[*map(int,input().split())]for _ in[0]*int(e)]\n s,t = min(target)\n target = {(x - s, y - t) for x, y in target}\n max_tx = max(target)[0]\n b = {tuple(map(int,input().split()))for _ in[0]*int(input())}\n max_sx = max(map(operator.itemgetter(0), b))\n lim_x = max_sx - max_tx\n for x,y in b:\n if x > lim_x:continue\n for u,v in target:\n if (x + u, y + v) not in b:break\n else:\n print(x - s, y - t)\n break\n", "neg": "import operator\nfor e in iter(input,'0'):\n target = [[*map(int,input().split())]for _ in[0]*int(e)]\n s,t = min(target)\n target = {(x - bx, y - by) for x, y in target}\n max_tx = max(map(lambda x:x[0], target))\n b = {tuple(map(int,input().split()))for _ in[0]*int(input())}\n max_sx = max(map(operator.itemgetter(0), b))\n lim_x = max_sx - max_tx\n for x,y in b:\n if x > lim_x:continue\n for u,v in target:\n if (x + u, y + v) not in b:break\n else:\n print(x - s, y - t)\n break\n", "jacc_sim": 0.9411764705882353, "nl": "Constellation Search\n\nProblem:\nYou are searching for a constellation in a photo of the night sky. The photo contains exactly one shape that matches the shape, orientation, and size of the constellation you are looking for. However, there may be extra stars in the photo that are not part of the constellation.\n\nFor example, the constellation in Figure 1 is included in the photo in Figure 2 (highlighted by a circle). Shifting the coordinates of the stars in the constellation by +2 in the x-direction and -3 in the y-direction aligns them with the positions in the photo.\n\nGiven the shape of the desired constellation and the positions of stars in the photo, write a program to determine the amount by which the constellation's coordinates should be shifted to align with the coordinates in the photo.\n\nInput:\nThe input consists of multiple datasets. Each dataset is provided in the following format:\n\nThe first line of each dataset contains the number of stars m in the desired constellation. The next m lines contain the x and y coordinates of the m stars in the constellation, separated by a space. The m+2nd line contains the number of stars n in the photo. The following n lines contain the x and y coordinates of the n stars in the photo, separated by a space.\n\nThe positions of the m stars in the constellation are all distinct. Similarly, the positions of the n stars in the photo are all distinct. 1 ≤ m ≤ 200, 1 ≤ n ≤ 1000. The x and y coordinates of the stars are all between 0 and 1000000.\n\nWhen m is 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output a single line containing two integers separated by a space. These integers represent the amount by which the coordinates of the desired constellation should be shifted parallel to the x and y axes to align with the coordinates in the photo.\n\nInput/Output Example:\n(Provided in the original problem description)", "before_after_length": [205, 212], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00448", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0'):\n r,_=map(int,e.split())\n d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]\n a=0\n for i in range(1<i,j represents the state of the senbei at row i and column j. If ai,j is 1, it indicates that the top side is baked, and if it is 0, it indicates that the bottom side is baked.\n\nWhen both C and R are 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum number of shippable senbei on a single line.\n\nInput/Output Example:\nInput:\n2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n\nOutput:\n9\n15", "before_after_length": [124, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00448", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0'):\n r=int(e.split()[0])\n d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]\n a=[]\n for i in range(1<r//2 else r-c\n a+=[b]\n print(max(a))\n", "neg": "for e in iter(input,'0 0'):\n r=int(e.split()[0])\n d=[int(''.join(x))for x in zip(*[input().split()for _ in[0]*r])]\n a=[]\n for i in range(1<r//2 else r-c\n a+=[b]\n print(max(a))\n", "jacc_sim": 1.0, "nl": "Title: \u304a\u305b\u3093\u3079\u3044\n\nProblem:\nIOI Seika has been using traditional methods to bake senbei (rice crackers) since its establishment. This traditional method involves baking one side over charcoal for a certain time, then flipping it to bake the other side for an equal amount of time. While adhering to this tradition, the senbei are baked using a machine. The machine arranges the senbei in a rectangular shape with R (1 \u2264 R \u2264 10) rows and C (1 \u2264 C \u2264 10000) columns. Normally, the machine operates automatically, flipping the senbei all at once after one side is baked to proceed with baking the other side over charcoal.\n\nOne day, during the process of baking, an earthquake occurred just before flipping the senbei, causing some of them to flip prematurely. Fortunately, the charcoal remained at the appropriate temperature. However, further baking the top side would exceed the traditional baking time, making the senbei unsuitable for shipment. To address this, the machine was quickly switched to manual operation to flip only the senbei that had not yet been flipped. The machine can flip several rows simultaneously or several columns simultaneously, but unfortunately, it cannot flip one senbei at a time.\n\nTo prevent the unsuitable baking of the unflipped senbei, the decision was made to flip several rows at once, followed by flipping several columns at once, ensuring that both sides are baked without exceeding the appropriate time. The goal is to maximize the number of senbei that can be shipped, referred to as \"shippable senbei.\" It is also considered that no rows or columns need to be flipped. Write a program to output the maximum number of shippable senbei.\n\nAfter the earthquake, the senbei were in the following state, with black circles representing the baked top side and white circles representing the baked bottom side.\n\n[Image: Senbei State]\n\nFlipping the first row results in the following state.\n\n[Image: Senbei State After Flipping First Row]\n\nFurthermore, flipping the 1st and 5th columns results in a state where 9 senbei can be shipped.\n\n[Image: Senbei State After Flipping Columns]\n\nHint:\nNote that the upper limit of R (10) is smaller than the upper limit of C (10000).\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format. The first line of input contains two integers R, C (1 \u2264 R \u2264 10, 1 \u2264 C \u2264 10000) separated by a space. The following R lines represent the state of the senbei after the earthquake. The (i+1)th line (1 \u2264 i \u2264 R) contains C integers separated by spaces, where ai,j represents the state of the senbei at row i and column j. If ai,j is 1, it indicates that the top side is baked, and if it is 0, it indicates that the bottom side is baked.\n\nWhen both C and R are 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum number of shippable senbei on a single line.\n\nInput/Output Example:\nInput:\n2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n\nOutput:\n9\n15", "before_after_length": [125, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00448", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0'):\n r=int(e.split()[0])\n d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]\n a=0\n for m in range(1<<~-r):\n t=0\n for s in d:\n c=bin(m^s).count('1')\n t+=c if c>r//2 else r-c\n if ar//2 else r-c\n if ai,j represents the state of the senbei at row i and column j. If ai,j is 1, it indicates that the top side is baked, and if it is 0, it indicates that the bottom side is baked.\n\nWhen both C and R are 0, it indicates the end of the input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum number of shippable senbei on a single line.\n\nInput/Output Example:\nInput:\n2 5\n0 1 0 1 0\n1 0 0 0 1\n3 6\n1 0 0 0 1 0\n1 1 1 0 1 0\n1 0 1 1 0 1\n0 0\n\nOutput:\n9\n15", "before_after_length": [128, 152], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00449", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nfrom heapq import*\nr=sys.stdin.readline\ndef g(E,n,s,g):\n F=[1e7]*-~n;F[s]=0\n H=[(0,s)]\n while H:\n c,u=heappop(H)\n if u==g:return c\n for f,v in E[u]:\n t=c+f\n if t= m:\n tab[i][k] -= tab[i-1][k-1-m]\n tab[i][k] %= 100000\n return tab[n][s]\n\nwhile True:\n n,m,s = map(int,input().split())\n if n == 0 : break\n n *= n\n print(listrep(n,m,s))", "neg": "def listrep(n,m,s):\n tab = [[[0]*(s+1) for j in range(n+1)]\n tab[0][0] = 1\n for i in range(1,n+1):\n for k in range(s+1):\n if i <= k:\n tab[i][k] += tab[i][k-i] + tab[i-1][k-i]\n if j-1 >= m:\n tab[i][k] -= tab[i-1][j-1-m]\n return tab[n][m][s]\n\nwhile True:\n n,m,s = map(int,input().split())\n if n == 0 : break\n n *= n\n print(listrep(n,m,s))", "jacc_sim": 0.9487179487179487, "nl": "Title: Bingo\n\nProblem:\nIn a programming contest, it is customary to play a bingo game during the post-competition social gathering. However, the bingo cards used in this game are somewhat special and are created according to the following conditions:\n- The bingo card is divided into N rows and N columns, with each cell containing a unique positive integer.\n- The integers in the cells range from 1 to M.\n- The sum of all N\u00d7N integers on the bingo card is S.\n- When viewing any column, the integers are arranged in ascending order from top to bottom.\n- Each integer in any cell is greater than any integer to its left in the same row.\n\nAn example of a bingo card for N = 5, M = 50, and S = 685 is provided.\n\nObjective:\nFor the social gathering, we want to create as many bingo cards as possible that satisfy the above conditions. However, the same card cannot be created more than twice. Create a program to output the maximum number of bingo cards that can be created, divided by 100000 and the remainder.\n\nInput:\nThe input consists of multiple datasets. Each dataset is given in the following format:\nA single line containing three positive integers separated by spaces: N (1\u2264N\u22647), the upper limit of integers written in the cells M (1\u2264M\u22642000), and the total sum of integers written on the bingo card S (1\u2264S\u22643000). For any given input data, it is possible to create at least one bingo card that satisfies the conditions.\nThe input ends when N, M, and S are all 0. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the maximum number of bingo cards that can be created, divided by 100000 and the remainder, on a single line.\n\nInput/Output Example:\nInput:\n3 9 45\n3 100 50\n5 50 685\n0 0 0\n\nOutput:\n1\n7\n74501\n\nFor the third input example, the maximum number of bingo cards that can be created is 642499974501, so the output is the remainder when divided by 100000, which is 74501.", "before_after_length": [196, 189], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00467", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0'):\n N,M=map(int,e.split())\n S=[int(input())for _ in[0]*N]\n p=b=1\n for i in range(M):\n d=int(input())\n p+=d\n if N<=p:\n if b:print(-~i);b=0\n continue\n p+=S[~-p]\n if(N<=p)*b:print(-~i);b=0\n", "neg": "for e in iter(input,'0 0'):\n N,M=map(int,e.split())\n S=[int(input())for _ in[0]*N]\n p=b=1\n for i in range(M):\n d=int(input())\n p+=d\n p+=S[~-p]\n if(N<=p)*b:print(-~i);b=0\n", "jacc_sim": 0.972972972972973, "nl": "Title: Sugoroku\n\nProblem:\nJOI is playing a game of sugoroku alone. The sugoroku consists of N squares arranged in a straight line, each containing instructions for movement. The starting point is square 1, and the goal is square N. JOI repeats the following until reaching the goal:\n- Roll a die and move forward by the number rolled, following the instructions on the new square.\n- Do not follow the instructions on the square moved to.\n- The game ends not only when stopping exactly at square N, but also when moving beyond square N.\nGiven the game board and M sets of die rolls, create a program to output the number of times the die needs to be rolled to reach the goal.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in the following format:\n- Each dataset consists of 1+N+M lines.\n- The first line of input contains two integers N and M (2 \u2264 N \u2264 1000, 1 \u2264 M \u2264 1000). N represents the number of squares in the sugoroku, and M represents the number of die rolls given.\n- The next N lines each contain an integer between -999 and 999, representing the instruction for the i-th square of the sugoroku.\n- The subsequent M lines each contain an integer between 1 and 6, representing the result of the j-th die roll.\n- The second and 1+N-th lines always contain 0.\n- There are no instructions to move to squares before the first square.\n- In any input dataset, it is always possible to reach the goal in M or fewer die rolls.\n\nWhen both N and M are 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the number of times the die needs to be rolled to reach the goal as an integer on a single line.\n\nInput/Output Example:\n(Provided input and output examples are not included here.)", "before_after_length": [122, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00467", "p_user": "u150984829", "n_user": "u150984829", "pos": "for e in iter(input,'0 0'):\n N,M=map(int,e.split())\n k,p=1,0\n S=[int(input()) for _ in[0]*N]\n for d in[int(input())for _ in[0]*M]:\n p+=d if N<=p+d else d+S[p+d]\n if N<=p+1:break\n k+=1\n print(k)\n", "neg": "for e in iter(input,'0 0'):\n N,M=map(int,e.split())\n k=p=1\n S=[int(input()) for _ in[0]*N]\n for d in[int(input())for _ in[0]*M]:\n p+=n if n-1<=p+i else i+S[p+i]\n if n<=p:break\n k+=1\n print(k)\n", "jacc_sim": 0.9166666666666666, "nl": "Title: Sugoroku\n\nProblem:\nJOI is playing a game of sugoroku alone. The sugoroku consists of N squares arranged in a straight line, each containing instructions for movement. The starting point is square 1, and the goal is square N. JOI repeats the following until reaching the goal:\n- Roll a die and move forward by the number rolled, following the instructions on the new square.\n- Do not follow the instructions on the square moved to.\n- The game ends not only when stopping exactly at square N, but also when moving beyond square N.\nGiven the game board and M sets of die rolls, create a program to output the number of times the die needs to be rolled to reach the goal.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in the following format:\n- Each dataset consists of 1+N+M lines.\n- The first line of input contains two integers N and M (2 \u2264 N \u2264 1000, 1 \u2264 M \u2264 1000). N represents the number of squares in the sugoroku, and M represents the number of die rolls given.\n- The next N lines each contain an integer between -999 and 999, representing the instruction for the i-th square of the sugoroku.\n- The subsequent M lines each contain an integer between 1 and 6, representing the result of the j-th die roll.\n- The second and 1+N-th lines always contain 0.\n- There are no instructions to move to squares before the first square.\n- In any input dataset, it is always possible to reach the goal in M or fewer die rolls.\n\nWhen both N and M are 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the number of times the die needs to be rolled to reach the goal as an integer on a single line.\n\nInput/Output Example:\n(Provided input and output examples are not included here.)", "before_after_length": [109, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00467", "p_user": "u150984829", "n_user": "u150984829", "pos": "def s():\n import sys\n r=sys.stdin.readline\n for e in iter(r,'0 0\\n'):\n N,M=map(int,e.split())\n k,p=1,0\n S=[int(r()) for _ in[0]*N]\n for d in[int(r())for _ in[0]*M]:\n p+=d if N<=p+d else d+S[p+d]\n if N<=p+1:break\n k+=1\n print(k)\nif'__main__'==__name__:s()\n", "neg": "def s():\n import sys\n r=sys.stdin.readline\n for e in iter(r,'0 0'):\n N,M=map(int,e.split())\n k,p=1,0\n S=[int(r()) for _ in[0]*N]\n for d in[int(r())for _ in[0]*M]:\n p+=d if N<=p+d else d+S[p+d]\n if N<=p+1:break\n k+=1\n print(k)\nif'__main__'==__name__:s()\n", "jacc_sim": 0.9534883720930233, "nl": "Title: Sugoroku\n\nProblem:\nJOI is playing a game of sugoroku alone. The sugoroku consists of N squares arranged in a straight line, each containing instructions for movement. The starting point is square 1, and the goal is square N. JOI repeats the following until reaching the goal:\n- Roll a die and move forward by the number rolled, following the instructions on the new square.\n- Do not follow the instructions on the square moved to.\n- The game ends not only when stopping exactly at square N, but also when moving beyond square N.\nGiven the game board and M sets of die rolls, create a program to output the number of times the die needs to be rolled to reach the goal.\n\nInput:\nThe input consists of multiple datasets. Each dataset is in the following format:\n- Each dataset consists of 1+N+M lines.\n- The first line of input contains two integers N and M (2 \u2264 N \u2264 1000, 1 \u2264 M \u2264 1000). N represents the number of squares in the sugoroku, and M represents the number of die rolls given.\n- The next N lines each contain an integer between -999 and 999, representing the instruction for the i-th square of the sugoroku.\n- The subsequent M lines each contain an integer between 1 and 6, representing the result of the j-th die roll.\n- The second and 1+N-th lines always contain 0.\n- There are no instructions to move to squares before the first square.\n- In any input dataset, it is always possible to reach the goal in M or fewer die rolls.\n\nWhen both N and M are 0, it indicates the end of input. The number of datasets does not exceed 5.\n\nOutput:\nFor each dataset, output the number of times the die needs to be rolled to reach the goal as an integer on a single line.\n\nInput/Output Example:\n(Provided input and output examples are not included here.)", "before_after_length": [145, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00467", "p_user": "u150984829", "n_user": "u150984829", "pos": "import sys\nr=sys.stdin.readline\nfor e in iter(r,'0 0\\n'):\n N,M=map(int,e.split())\n k,p=1,0\n S=[int(r())for _ in[0]*N]\n for d in[int(r())for _ in[0]*M]:\n p+=d;\n if p ices[i+1]:\n peaks.append(upPeak)\n upPeak = L - ices[i+1]\n downPeak += L - ices[i+1]\n elif i == N-1:\n peaks.append(upPeak)\n peaks.append(downPeak)\n print(max(peaks))\n\nN,L = map(int,input().strip().split())\nices = [int(input().strip()) for _ in range(N)]\n\n\norderN(N,L,ices)", "neg": "def orderN(N,L,ices):\n upPeak = L - ices[0]\n downPeak = L - ices[0]\n peaks = []\n for i in range(len(ices)):\n if i < N-1:\n if ices[i] < ices[i+1]:\n peaks.append(downPeak)\n downPeak = L - ices[i+1]\n upPeak += L - ices[i+1]\n elif ices[i] > ices[i+1]:\n peaks.append(upPeak)\n upPeak = L - ices[i+1]\n downPeak += L - ices[i+1]\n elif i == N-1:\n peaks.append(upPeak)\n peaks.append(downPeak)\n print(max(peaks))\n\nN,L = map(int,input().strip().split())\nices = [int(raw_input().strip()) for _ in xrange(N)]\n\norderN(N,L,ices)", "jacc_sim": 0.9512195121951219, "nl": "Title: \u3064\u3089\u3089\n\nProblem:\nJOI, who lives in Canada, has icicles hanging from the eaves of his house. He decides to investigate them. There are N icicles (2 \u2264 N \u2264 100,000) hanging from the eaves of JOI's house. These icicles are lined up in a straight line, with the i-th icicle hanging at a position i cm from the left end of the eaves. The initial length of the i-th icicle is ai cm (where ai is an integer greater than or equal to 1). These icicles grow according to the following rules:\n\n- The i-th icicle grows 1 cm per hour only if it is longer than both the (i-1)-th and (i+1)-th icicles (except for the icicles at the ends).\n- All icicles break at the moment they reach a length of L cm (2 \u2264 L \u2264 50,000), and are considered to have a length of 0 cm thereafter.\n\nAt the initial stage, the lengths of adjacent pairs of icicles are all different. JOI wants to know the time it takes for all the icicles to break and become 0 cm in length.\n\nInput:\nThe first line of input contains two integers N and L, representing the number of icicles and the maximum length of the icicles, respectively. The following N lines (1 \u2264 i \u2264 N) contain integers ai (1 \u2264 ai < L), representing the initial length of the i-th icicle.\n\nOutput:\nOutput a single integer representing the time it takes for all the icicles to break.\n\nExample:\nInput\n4 6\n4\n2\n3\n5\n\nOutput\n8\n\nIn this case, the icicles break after 2, 8, 4, and 1 hours, respectively. Therefore, the time it takes for all the icicles to break is 8 hours.", "before_after_length": [256, 257], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00474", "p_user": "u352394527", "n_user": "u352394527", "pos": "def solve():\n n,l = map(int,input().split())\n \n length = [int(input()) for i in range(n)]\n pare = [(length[i], i) for i in range(n)]\n pare.sort(reverse=True)\n dp = [0] * (n + 1)\n for p in pare:\n i = p[1]\n if i == 0:\n dp[i] = dp[i + 1] + (l - length[i])\n else:\n dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])\n print(max(dp))\nsolve()\n", "neg": "def solve():\n n,l = map(int,input().split())\n \n length = [int(input()) for i in range(n)]\n pare = [(length[i], i) for i in range(n)]\n pare.sort(reverse=True)\n dp = [0] * (n + 1)\n for p in pare:\n i = p[0]\n if i == 0:\n dp[i] = dp[i + 1] + (l - length[i])\n else:\n dp[i] = max(dp[i - 1], dp[i + 1]) + (l - length[i])\n print(max(dp))\nsolve()\n", "jacc_sim": 1.0, "nl": "Title: \u3064\u3089\u3089\n\nProblem:\nJOI, who lives in Canada, has icicles hanging from the eaves of his house. He decides to investigate them. There are N icicles (2 \u2264 N \u2264 100,000) hanging from the eaves of JOI's house. These icicles are lined up in a straight line, with the i-th icicle hanging at a position i cm from the left end of the eaves. The initial length of the i-th icicle is ai cm (where ai is an integer greater than or equal to 1). These icicles grow according to the following rules:\n\n- The i-th icicle grows 1 cm per hour only if it is longer than both the (i-1)-th and (i+1)-th icicles (except for the icicles at the ends).\n- All icicles break at the moment they reach a length of L cm (2 \u2264 L \u2264 50,000), and are considered to have a length of 0 cm thereafter.\n\nAt the initial stage, the lengths of adjacent pairs of icicles are all different. JOI wants to know the time it takes for all the icicles to break and become 0 cm in length.\n\nInput:\nThe first line of input contains two integers N and L, representing the number of icicles and the maximum length of the icicles, respectively. The following N lines (1 \u2264 i \u2264 N) contain integers ai (1 \u2264 ai < L), representing the initial length of the i-th icicle.\n\nOutput:\nOutput a single integer representing the time it takes for all the icicles to break.\n\nExample:\nInput\n4 6\n4\n2\n3\n5\n\nOutput\n8\n\nIn this case, the icicles break after 2, 8, 4, and 1 hours, respectively. Therefore, the time it takes for all the icicles to break is 8 hours.", "before_after_length": [167, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00484", "p_user": "u352394527", "n_user": "u352394527", "pos": "def solve():\n n, k = map(int,input().split())\n group_num = 10\n \n book_map = [[] for i in range(group_num)]\n acc_map = [[0] for i in range(group_num)]\n\n for i in range(n):\n c, g = map(int,input().split())\n book_map[g - 1].append(c)\n\n for i in range(group_num):\n bmi = book_map[i]\n bmi.sort(reverse=True)\n ami = acc_map[i]\n acc = 0\n for j in range(len(bmi)):\n acc += (bmi[j] + j * 2)\n ami.append(acc)\n \n dp = [[0] * (k + 1) for i in range(group_num + 1)]\n for y in range(1, k + 1):\n for x in range(1, group_num + 1):\n accs = acc_map[x - 1]\n dp_pre = dp[x - 1]\n dp[x][y] = max([dp_pre[y - z] + accs[z] for z in range(min(y + 1, len(accs)))])\n \n print(dp[group_num][k])\nsolve()\n\n", "neg": "def solve():\n n, k = map(int,input().split())\n group_num = 10\n \n book_map = [[] for i in range(group_num)]\n acc_map = [[0] for i in range(group_num)]\n\n for i in range(n):\n c,g = map(int,input().split())\n book_map[g - 1].append(c)\n\n for i in range(group_num):\n book_map[i].sort(reverse=True)\n acc = 0\n for j in range(len(book_map[i])):\n book_map[i][j] += j * 2\n acc += book_map[i][j]\n acc_map[i].append(acc)\n print(acc_map) \n dp = [[0] * (k + 1) for i in range(group_num + 1)]\n for y in range(1,k + 1):\n for x in range(1,group_num + 1):\n for z in range(min(y + 1, len(acc_map[x - 1]))):\n dp[x][y] = max(dp[x][y], dp[x - 1][y - z] + acc_map[x - 1][z])\n \n# print(dp[group_num][k])\nsolve()\n\n", "jacc_sim": 0.9019607843137255, "nl": "Title: \u53e4\u672c\u5c4b (Books)\n\nIn your town, there is a long-established second-hand bookstore called JOI Bookstore, which you frequently visit. Each book has a set standard price, and if you take it to JOI Bookstore, they will buy it at that price.\n\nAt JOI Bookstore, books are classified into 10 genres such as novels, manga, and magazines, each assigned a number from 1 to 10. They offer a service where if you sell a group of books of the same genre, they will buy them at a higher price. Specifically, if you sell T books of the same genre, the purchase price per book will be T - 1 yen higher than the standard price. For example, if you sell books priced at 100 yen, 120 yen, and 150 yen of the same genre to JOI Bookstore, the purchase prices will be 102 yen, 122 yen, and 152 yen, respectively.\n\nNow, due to personal circumstances, you have to move suddenly. You have N books, but it's difficult to take all of them to your new residence, so you decide to sell K of the N books to JOI Bookstore.\n\nTask:\nCreate a program to find the maximum total purchase price when given the standard price and genre number for each of the N books.\n\nConstraints:\n2 \u2264 N \u2264 2000: Number of books you have\n1 \u2264 K < N: Number of books to sell to JOI Bookstore\n1 \u2264 Ci \u2264 100000 = 10^5: Standard price of the i-th book\n1 \u2264 Gi \u2264 10: Genre number of the i-th book\n\nInput:\nRead the following input from standard input:\n- The first line contains two integers N and K separated by a space, representing the number of books you have and the number of books to sell to JOI Bookstore, respectively.\n- The next N lines contain information about the books you have. The i+1-th line (1 \u2264 i \u2264 N) contains two integers Ci and Gi separated by a space, representing the standard price of the i-th book and the genre number of the i-th book.\n\nOutput:\nOutput a single integer representing the maximum total purchase price to standard output.\n\nScoring Criteria:\n- 20% of the test data will have N \u2264 20.\n- 20% of the test data will have all book genres as 1 or 2.\n- 10% of the test data will satisfy both of the above conditions.\n- 30% of the test data will satisfy at least one of the above conditions.\n\nExample Input:\n7 4\n14 1\n13 2\n12 3\n14 2\n8 2\n16 3\n11 2\n\nExample Output:\n60\n\nIn this example, when you sell the 2nd, 4th, 6th, and 7th books, the purchase price for books of genre 2 will be 1 yen higher per book. Therefore, the purchase prices for these books will be as follows:\nNumber: 2, 4, 6, 7\nStandard Price: 13, 14, 16, 11\nGenre: 2, 2, 3, 2\nPurchase Price: 15, 16, 16, 13\n\nThus, the total purchase price is 15 + 16 + 16 + 13 = 60 yen, which is the maximum total purchase price.", "before_after_length": [323, 325], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00489", "p_user": "u228488524", "n_user": "u228488524", "pos": "t = int(input())\npoint_l = [0 for i in range(t)]\nfor i in range(int(t*(t-1)/2)):\n tmp = [int(x) for x in input().split()]\n if tmp[2] > tmp[3]:\n point_l[tmp[0]-1] += 3\n elif tmp[3] > tmp[2]:\n point_l[tmp[1]-1] += 3\n elif tmp[2] == tmp[3]:\n point_l[tmp[0]-1] += 1\n point_l[tmp[1]-1] += 1\n\nrank_l = [0 for i in range(t)]\nrank = 1\nfor l in sorted(point_l, reverse=True):\n dup = point_l.count(l)\n for j in range(dup):\n rank_l[point_l.index(l)] += rank\n point_l[point_l.index(l)] = -1\n rank += dup\n\nfor l in rank_l:\n print(l)", "neg": "t = int(input())\npoint_l = [0 for i in range(t)]\nfor i in range((t*(t-1))/2):\n input_line = input()\n tmp = [int(x) for x in input_line.rstrip().split(' ')]\n if tmp[2] > tmp[3]:\n point_l[tmp[0]-1] += 3\n elif tmp[3] > tmp[2]:\n point_l[tmp[1]-1] += 3\n elif tmp[2] == tmp[3]:\n point_l[tmp[0]-1] += 1\n point_l[tmp[1]-1] += 1\n\nrank_l = [0 for i in range(t)]\nrank = 1\nfor l in sorted(point_l, reverse=True):\n dup = point_l.count(l)\n for j in range(dup):\n rank_l[point_l.index(l)] += rank\n point_l[point_l.index(l)] = -1\n rank += dup\n\nfor l in rank_l:\n print(l)", "jacc_sim": 0.9318181818181818, "nl": "Title: Soccer\n\nProblem:\nIn the JOI country, soccer is popular, and the JOI League, a weekly league, is held. N teams are part of the JOI League, numbered from 1 to N. Each team plays every other team exactly once, resulting in N \u00d7 (N - 1) / 2 matches. The outcome of each match is determined by the points earned by each team. A winning team earns 3 points, a losing team earns 0 points, and in case of a draw, both teams earn 1 point. Rankings are based on the total points earned by each team, without considering goal differences. In case of equal points, teams are ranked higher. Given the results of all matches, create a program to determine the ranking of each team.\n\nInput:\nThe first line of the input file contains the number of teams, N (2 \u2264 N \u2264 100). The following N \u00d7 (N - 1) / 2 lines contain the results of each match. Each line (1 \u2264 i \u2264 N \u00d7 (N - 1) / 2) contains integers A_i, B_i, C_i, D_i (1 \u2264 A_i \u2264 N, 1 \u2264 B_i \u2264 N, 0 \u2264 C_i \u2264 100, 0 \u2264 D_i \u2264 100), representing a match between teams A_i and B_i, where A_i scored C_i points and B_i scored D_i points. No match is repeated.\n\nOutput:\nThe output consists of N lines, each containing a single integer representing the ranking of each team.\n\nExample:\nInput\n4\n1 2 0 1\n1 3 2 1\n1 4 2 2\n2 3 1 1\n2 4 3 0\n3 4 1 3\n\nOutput\n2\n1\n4\n2", "before_after_length": [257, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00491", "p_user": "u150984829", "n_user": "u150984829", "pos": "N,K=map(int,input().split())\nS=[-1]*N\nfor _ in[0]*K:a,b=map(int,input().split());S[a-1]=b-1\ndp=[0]*9\nst,nd=S[:2]\nif st+1:\n if nd+1:dp[st*3+nd]=1\n else:dp[st*3:st*4]=[1]*3\nelif nd+1:dp[nd::3]=[1]*3\nelse:dp=[1]*9\nfor i in range(2,N):\n cur=S[i];tmp=[0]*9\n if cur+1:\n for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)\n else:\n for cur in range(3):\n for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)\n dp=tmp[:]\nprint(sum(dp)%10000)\n", "neg": "N,K=map(int,input().split())\nS=[0]*N\nfor _ in[0]*K:\n a,b=map(int,input().split())\n S[a-1]=b-1\ndp=[0]*9\nst,nd=S[:2]\nif st+1:\n if nd+1:dp[st*3+nd]=1\n else:dp[st*3:-~st*3]=[1]*3\nelif nd+1:dp[nd::3]=[1]*3\nelse:dp=[1]*9\nprint(dp)\nfor i in range(2,N):\n cur=S[i];tmp=[0]*9\n if cur+1:\n for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)\n else:\n for cur in range(3):\n for k in range(3):tmp[k*3+cur]=sum(dp[k::3])-dp[cur*4]*(k==cur)\n dp=tmp[:]\nprint(sum(dp)%10000)\n", "jacc_sim": 0.9782608695652174, "nl": "Title: Pasta\n\nProblem:\nYou love pasta and have it for dinner every day. You can make three types of pasta: tomato sauce, cream sauce, and basil sauce.\n\nYou want to plan dinner for N days. Each day, you choose one type of pasta. However, you shouldn't choose the same pasta for more than three consecutive days. Also, K days of pasta are already decided within the N days.\n\nInput:\nThe input consists of K + 1 lines.\nThe first line contains two integers N and K (3 \u2264 N \u2264 100, 1 \u2264 K \u2264 N).\nThe following K lines each contain two integers Ai and Bi (1 \u2264 Ai \u2264 N, 1 \u2264 Bi \u2264 3), where Ai represents the day and Bi represents the type of pasta (1 for tomato, 2 for cream, 3 for basil). All Ai values are distinct.\n\nOutput:\nOutput the number of possible dinner plans that satisfy the conditions, modulo 10000.\n\nExample:\nInput\n5 3\n3 1\n1 1\n4 2\n\nOutput\n6\n\nIn this example, you need to plan dinner for 5 days. On days 1 and 3, you have tomato sauce, and on day 4, you have cream sauce. There are 6 possible dinner plans that satisfy the conditions.\n\nNote: The source of the problem statement and test data used for automatic judgment is provided by the Information Olympiad Japan Committee.", "before_after_length": [262, 270], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00499", "p_user": "u286298310", "n_user": "u811434779", "pos": "import math\n\nl = [int(input()) for i in range(5)]\nd = max( math.ceil(l[1]/l[3]), math.ceil(l[2]/l[4]))\nprint(l[0]-d)\n", "neg": "import math\nl = [input() for i in range(5)]\nprint l[0] - int(max(math.ceil(l[1]/l[3]), math.ceil(l[2]/l[4])))", "jacc_sim": 0.9642857142857143, "nl": "Title: Homework\n\nProblem:\nJOI has always struggled with his winter homework. This time, he plans to execute it systematically. His homework consists of language and math drills, with A pages for language and B pages for math.\n\nJOI can complete a maximum of C pages of language and D pages of math in a day, but he can't play on days when he does homework. Winter break lasts for L days, and JOI must finish his homework during this time. Create a program to determine the maximum number of days JOI can play during the winter break.\n\nInput:\nThe input consists of 5 lines, each containing a positive integer.\n- Line 1: Integer L (2 \u2264 L \u2264 40) representing the number of days in winter break.\n- Line 2: Integer A (1 \u2264 A \u2264 1000) representing the number of pages for the language drill.\n- Line 3: Integer B (1 \u2264 B \u2264 1000) representing the number of pages for the math drill.\n- Line 4: Integer C (1 \u2264 C \u2264 100) representing the maximum pages of language drill JOI can do in a day.\n- Line 5: Integer D (1 \u2264 D \u2264 100) representing the maximum pages of math drill JOI can do in a day.\n\nOutput:\nOutput the maximum number of days JOI can play during the winter break in a single line.\n\nInput/Output Examples:\nInput 1:\n20\n25\n30\n6\n8\n\nOutput 1:\n15\n\nInput 2:\n15\n32\n48\n4\n6\n\nOutput 2:\n7\n\nNote: The input data ensures that JOI will definitely finish his homework during the winter break and will have at least one day to play.", "before_after_length": [61, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00500", "p_user": "u352394527", "n_user": "u352394527", "pos": "n = int(input())\n\nlst = [list(map(int,input().split())) for i in range(n)]\np = [0 for i in range(n)]\nfor i in range(3):\n dic = [[] for _ in range(101)]\n for j in range(n):\n dic[lst[j][i]].append(j)\n for x in range(101):\n l = dic[x]\n if lst:\n if len(l) == 1:\n p[l[0]] += x\nfor i in p:\n print(i)\n", "neg": "n = int(input())\n\nlst = [list(map(int,input().split())) for i in range(n)]\np = [0 for i in range(n)]\nfor i in range(3):\n dic = [[] for _ in range(101)]\n for j in range(n):\n print(lst)\n dic[lst[j][i]].append(j)\n for x in range(101):\n l = dic[x]\n if lst:\n if len(l) == 1:\n p[l[0]] += x\nfor i in p:\n print(i)\n", "jacc_sim": 1.0, "nl": "Title: Unique Number Game\n\nProblem:\nJOI and his friends decide to play a game. The game involves N players. In each round, each player submits an integer between 1 and 100. A player earns points if no one else submits the same number. They play this game three times. Create a program to calculate the total points earned by each player over the three rounds.\n\nInput:\nThe input consists of 1 + N lines. The first line contains an integer N (2 \u2264 N \u2264 200), representing the number of players. The next N lines (1 \u2264 i \u2264 N) each contain three integers separated by spaces, representing the numbers submitted by the i-th player in the first, second, and third rounds.\n\nOutput:\nThe output consists of N lines. Each line (1 \u2264 i \u2264 N) contains an integer representing the total points earned by the i-th player over the three rounds.\n\nExample:\nInput\n5\n100 99 98\n100 97 92\n63 89 63\n99 99 99\n89 97 98\n\nOutput\n0\n92\n215\n198\n89\n\nIn the first example, the total points earned by each player are as follows:\nPlayer 1: 0 + 0 + 0 = 0\nPlayer 2: 0 + 0 + 92 = 92\nPlayer 3: 63 + 89 + 63 = 215\nPlayer 4: 99 + 0 + 99 = 198\nPlayer 5: 89 + 0 + 0 = 89\n\nInput\n3\n89 92 77\n89 92 63\n89 63 77\n\nOutput\n0\n63\n63", "before_after_length": [141, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00501", "p_user": "u334031393", "n_user": "u334031393", "pos": "n = int(input())\ns = input()\nt = [input() for i in range(n)]\nc = 0\nfor tt in t:\n\tf = False\n\tfor i in range(len(tt)):\n\t\tfor j in range(len(tt))[1:]:\n\t\t\tf |= s == tt[i::j][:len(s)]\n\tif f: c += 1\nprint(c)", "neg": "n = int(input())\ns = input()\nt = [input() for i in range(n)]\nc = 0\nfor tt in t:\n\tf = False\n\tfor i in range(len(tt)):\n\t\tfor j in range(len(tt))[1:]:\n\t\t\tprint(tt[i::j][:len(s)])\n\t\t\tf |= s == tt[i::j][:len(s)]\n\tif f: c += 1\nprint(c)", "jacc_sim": 1.0, "nl": "Title: Signboard\n\nProblem:\nJOI decided to create a signboard for his shop. He has N old signboards with characters written at equal intervals. JOI wants to create a signboard by removing some characters from the old signboards. The remaining string should form the name of the shop, and the remaining characters should be equally spaced. He cannot cut or connect old signboards. Given the shop's name and information about N old signboards, create a program to determine the number of signboards JOI can create. If there are multiple ways to create a signboard from one old signboard, it is considered as one signboard.\n\nInput:\nThe input consists of 2 + N lines.\nThe first line contains an integer N (1 \u2264 N \u2264 100), representing the number of old signboards.\nThe second line contains a string of 3 to 25 lowercase alphabets, representing the shop's name.\nThe next N lines (1 \u2264 i \u2264 N) contain strings of 1 to 100 lowercase alphabets, representing the strings written on the i-th old signboard.\n\nOutput:\nOutput the number of signboards JOI can create as an integer on a single line.\n\nExample:\nInput\n4\nbar\nabracadabra\nbear\nbar\nbaraxbara\n\nOutput\n3\n\nExplanation:\nThe shop's name is \"bar\".\nFrom the first old signboard, removing characters at positions 2, 6, and 10 creates a signboard.\nThe second signboard can form \"bar\" by removing the 2nd character, but the remaining characters are not equally spaced.\nThe third signboard is already a valid signboard without removing any characters.\nFor the fourth signboard, there are two ways to create a signboard by removing characters. Thus, JOI can create signboards from the 1st, 3rd, and 4th old signboards, resulting in an output of 3.", "before_after_length": [98, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u137226361", "n_user": "u137226361", "pos": "n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0] * n\n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x, y, z):\n s, ws = find(x)\n t, wt = find(y)\n # print(ws, wt)\n if s == t:\n if ws - wt == z:\n pass\n else:\n print('No')\n exit(0)\n else:\n if ws < z + wt:\n par[s] = t\n diff[s] = z + wt - ws\n else:\n par[t] = s\n diff[t] = ws - z - wt\n\n\nfor _ in range(m):\n l, r, d = map(int, input().split())\n unite(l - 1, r - 1, d)\n\nprint('Yes')", "neg": "n, m = map(int, input().split())\npar = [i for i in range(n)]\ndiff = [0]*n\n\ndef find(x):\n if par[x] == x:\n return x, 0\n else:\n a, b = find(par[x])\n par[x] = a\n diff[x] += b\n return a, diff[x]\n\n\ndef unite(x,y,z):\n s, ws = find(x)\n t, wt = find(y)\n #print(ws, wt)\n if s==t:\n if ws - wt == z:\n pass\n else:\n print('Yes')\n exit(0)\n else:\n par[s] = t\n diff[s] = z\n\nfor _ in range(m):\n l,r,d = map(int, input().split())\n unite(l-1,r-1,d)\n\nprint('No')", "jacc_sim": 0.9807692307692307, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [278, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u893478938", "n_user": "u893478938", "pos": "def resolve():\n\n N,M = map(int,input().split())\n root = list(range(N))\n depth = [1 for _ in range(N)]\n dist = [0 for _ in range(N)]\n\n def find(a,root,dist):\n if root[a] == a:\n return (a,0)\n else:\n root[a],d = find(root[a],root,dist)\n dist[a] += d\n return(root[a],dist[a])\n\n def unite(a,b,d,root,depth,dist):\n A,dist_a = find(a,root,dist)\n B,dist_b = find(b,root,dist)\n if A == B:\n if dist_b - dist_a == d:\n return True\n else:\n return False\n else:\n if depth[A] > depth[B]:\n root[B] = A\n depth[A] += depth[B]\n dist[B] = dist_a - dist_b + d\n else:\n root[A] = B\n depth[B] += depth[A]\n dist[A] = dist_b - dist_a - d\n return True\n \n ans = True\n for _ in range(M):\n L,R,D = map(int,input().split())\n if not (unite(L-1,R-1,D,root,depth,dist)):\n ans = False\n break\n print(\"Yes\" if ans else \"No\")\nresolve()", "neg": "def resolve():\n\n N,M = map(int,input().split())\n root = list(range(N))\n depth = [1 for _ in range(N)]\n dist = [0 for _ in range(N)]\n\n def find(a,root,dist):\n if root[a] == a:\n return (a,0)\n else:\n root[a],d = find(root[a],root,dist)\n dist[a] += d\n return(root[a],dist[a])\n\n def unite(a,b,d,root,depth,dist):\n A,dist_a = find(a,root,dist)\n B,dist_b = find(b,root,dist)\n # print(\"a:{} A:{} dist_a:{}\".format(a,A,dist_a))\n # print(\"b:{} B:{} dist_b:{}\".format(b,B,dist_b))\n\n if A == B:\n if dist_b - dist_a == d:\n return True\n else:\n return False\n else:\n if depth[A] > depth[B]:\n root[B] = A\n depth[A] += depth[B]\n dist[B] = dist_a - dist_b + d\n else:\n root[A] = B\n depth[B] += depth[A]\n dist[A] = dist_b - dist_a - d\n return True\n \n ans = True\n for _ in range(M):\n L,R,D = map(int,input().split())\n if not (unite(L-1,R-1,D,root,depth,dist)):\n ans = False\n break\n print(\"Yes\" if ans else \"No\")\n", "jacc_sim": 0.9298245614035088, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [383, 434], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u879870653", "n_user": "u879870653", "pos": "N,M = map(int,input().split())\nA = [[] for i in range(N+1)]\n\nfor i in range(M) :\n l,r,d = map(int,input().split())\n \n l -= 1\n r -= 1\n \n A[l].append([r,d])\n A[r].append([l,-d])\n\ndistance = [\"#\" for i in range(N)]\n\nans = \"Yes\"\n\nflg = 0\n\nfor i in range(N) :\n if flg == 1 :\n break\n \n if distance[i] != \"#\" :\n continue\n \n distance[i] = 0\n stack = [i]\n \n while stack :\n v = stack.pop()\n \n for to,d in A[v] :\n if distance[to] == \"#\" :\n distance[to] = distance[v] + d\n stack.append(to)\n \n elif distance[to] != distance[v] + d :\n ans = \"No\"\n stack = []\n flg = 1\n break\n \n\nprint(ans)\n", "neg": "N,M = map(int,input().split())\nA = [[] for i in range(N+1)]\n\nfor i in range(M) :\n l,r,d = map(int,input().split())\n \n l -= 1\n r -= 1\n \n A[l].append([r,d])\n A[r].append([l,d])\n\ndistance = [\"#\" for i in range(N)]\n\nans = \"Yes\"\n\nflg = 0\n\nfor i in range(N) :\n if flg == 1 :\n break\n \n if distance[i] != \"#\" :\n continue\n \n distance[i] = 0\n stack = [i]\n \n while stack :\n v = stack.pop()\n \n for to,d in L[v] :\n if distance[to] == \"#\" :\n distance[to] = distance[v] + d :\n stack.append(to)\n \n elif distance[to] != distance[v] + d :\n ans = \"No\"\n stack = []\n flg = 1\n break\n \n\nprint(ans)", "jacc_sim": 0.9782608695652174, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [277, 276], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u572144347", "n_user": "u572144347", "pos": "import sys\nsys.setrecursionlimit(10**5)\nN,M = map(int, input().split())\ninput = sys.stdin.readline\nLRD = [ [int(j) for j in input().split()] for _ in range(M)]\n\ndata = [x for x in range(N+1)]\nrank = [0] * (N+1)\ndiff_weight = [0] * (N+1)\n\ndef root(x):\n if data[x] == x:\n return x\n else:\n r = root( data[x] )\n diff_weight[x] += diff_weight[ data[x] ]\n data[x] = r\n return r\n\ndef weight(x):\n # _ = root(x)\n return diff_weight[x]\n\n\ndef diff(x,y):\n return weight(y) - weight(x)\n\ndef merge(x,y,w):\n w += weight(x); w -= weight(y)\n x = root(x)\n y = root(y)\n if x == y: return False\n if rank[x] < rank[y]: x,y = y,x; w = -w\n if rank[x] == rank[y]: rank[x] += 1\n data[y] = x\n diff_weight[y] = w\n return True\n\ndef issame(x,y):\n return root(x) == root(y)\n\nfor i in range(M):\n L,R,D = LRD[i]\n # print(L,R,D)\n if not issame(L,R):\n _ = merge(L,R,D)\n else:\n if diff(L,R) != D:\n print(\"No\")\n exit(0)\n \nprint(\"Yes\")\n\n \n \n", "neg": "import sys\nsys.setrecursionlimit(10**9)\nN,M = map(int, input().split())\nLRD = [ [int(j) for j in input().split()] for _ in range(M)]\n\ndata = [-1] * (N+1)\nrank = [0] * (N+1)\ndiff_weight = [0] * (N+1)\n\ndef root(x):\n if data[x] == x:\n return x\n else:\n r = root(x)\n diff_weight[x] += diff_weight[ data[x] ]\n data[x] = r\n return r\n\ndef weight(x):\n _ = root(x)\n return diff_weight[x]\n\n\ndef diff(x,y):\n return weight(y) - weight(x)\n\ndef merge(x,y,w):\n w += weight(x); w -= weight(y)\n x = root(x)\n y = root(y)\n if x == y: return False\n if rank[x] < rank[y]: x,y = y,x; w = -w\n if rank[x] == rank[y]: rank[x] += 1\n data[y] = x\n diff_weight[y] = w\n return True\n\ndef issame(x,y):\n return root(x) == root(y)\n\nfor i in range(M):\n L,R,D = LRD[i]\n if not issame(L,R):\n merge(L,R,D)\n else:\n if weight(L,R) != D:\n print(\"No\")\n exit(0)\n \nprint(\"Yes\")\n\n \n \n", "jacc_sim": 0.9230769230769231, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [450, 421], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u608088992", "n_user": "u608088992", "pos": "from collections import deque\nN, M = map(int, input().split())\nInf = 10000000000\nEdge = [[] for i in range(N)]\nfor i in range(M):\n l, r, d = map(int, input().split())\n Edge[l-1].append((r-1, d))\n Edge[r-1].append((l-1, -d))\n \nNode = [Inf for i in range(N)]\nPossible = True\nfor i in range(N):\n if not Possible:\n break\n elif Node[i] == Inf:\n Node[i] = 0\n Q = deque([i])\n while Q:\n now = Q.popleft()\n for e in Edge[now]:\n if Node[e[0]] == Inf:\n Node[e[0]] = Node[now] + e[1]\n Q.append(e[0])\n elif Node[now] + e[1] != Node[e[0]]:\n Possible = False\n break\nprint(\"Yes\" if Possible else \"No\")", "neg": "from collections import deque\nN, M = map(int, input().split())\nInf = 10000000000\nEdge = [[] for i in range(N)]\nfor i in range(M):\n l, r, d = map(int, input().split())\n Edge[l-1].append((r-1, d))\n Edge[r-1].append((l-1, -d))\n \nNode = [Inf for i in range(N)]\nPossible = True\nfor i in range(N):\n if not Possible:\n break\n elif Node[i] == Inf:\n Node[i] = 0\n Q = [i]\n while Q:\n now = deque.popleft(Q)\n for e in Edge[now]:\n if Node[e[0]] == Inf:\n Node[e[0]] = Node[now] + e[1]\n Q.append(e[0])\n elif Node[now] + e[1] != Node[e[0]]:\n Possible = False\n break\nprint(\"Yes\" if Possible else \"No\")", "jacc_sim": 1.0, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [254, 255], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u692336506", "n_user": "u692336506", "pos": "from sys import exit, setrecursionlimit\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict\nfrom bisect import bisect\n\nsetrecursionlimit(1000000)\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (place[i], place[i])\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n #print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print(\"No\")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\n\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n # \u9023\u7d50\u6210\u5206\u306emin\u3068max\n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print(\"No\")\n exit()\n\nprint(\"Yes\")", "neg": "from sys import exit, setrecursionlimit\nfrom functools import reduce\nfrom itertools import *\nfrom collections import defaultdict\nfrom bisect import bisect\n\nsetrecursionlimit(1000000)\nN,M = list(map(int,input().split()))\n\nedges = [[] for _ in range(N)]\n\nfor i in range(M):\n L,R,D = list(map(int,input().split()))\n edges[L - 1].append((R -1,D))\n edges[R - 1].append((L-1, -D))\n\n\nvisited = [None] * N\nplace = [0] * N\ninf = 10 ** 10\n\n\ndef walk(i):\n if visited[i]:\n return (place[i], place[i])\n visited[i] = True\n (n,m) = (inf, - inf)\n for j,d in edges[i]:\n #print(j,d)\n if visited[j] and place[j] != place[i] + d:\n print(\"No\")\n exit()\n place[j] = place[i] + d\n (x,y) = walk(j)\n (n,m) = (min(n,x),max(m,y))\n return (n,m)\n\n'''\nfor i in range(N):\n if not visited[i]:\n place[i] = 0\n # \u9023\u7d50\u6210\u5206\u306emin\u3068max\n (n,m) = walk(i)\n if m - n > 10 ** 9:\n print(\"No\")\n exit()\n'''\nprint(\"Yes\")", "jacc_sim": 1.0, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [393, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u062147869", "n_user": "u062147869", "pos": "from collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\n\nN,M = map(int,input().split())\nGraph =[[] for i in range(N)]\nfor i in range(M):\n L,R,D = map(int,input().split())\n Graph[L-1].append((R-1,D))\n Graph[R-1].append((L-1 ,-D))\nvisit=[False]*N\ndist=[0]*N\nfor i in range(N):\n if visit[i]==False:\n visit[i]=True\n A = deque()\n A.append(i)\n while A:\n x = A.pop()\n for y,d in Graph[x]:\n if (visit[y] == True) and (dist[y]!=d+dist[x]):\n print('No')\n sys.exit()\n elif (visit[y] == False):\n visit[y]=True\n A.append(y)\n dist[y]=d+dist[x] \n \nprint('Yes')", "neg": "from collections import deque\nimport sys\nsys.setrecursionlimit(10**7)\n\nN,M = map(int,input().split())\nGraph =[[] for i in range(N)]\nfor i in range(M):\n L,R,D = map(int,input().split())\n Graph[L-1].append((R-1,D))\n Graph[R-1].append((L-1 ,-D))\nvisit=[False]*N\nfor i in range(N):\n if visit[i]==False:\n visit[i]=1\n A = deque()\n A.append(i)\n while A:\n x = A.pop()\n for y,d in Graph[x]:\n if (visit[y] != False) and (visit[y]!=d+visit[x]):\n print('No')\n sys.exit()\n elif (visit[y] == False):\n A.append(y)\n visit[y]=d+visit[x] \n \nprint('Yes')", "jacc_sim": 0.9454545454545454, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [262, 248], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u336193675", "n_user": "u336193675", "pos": "import sys\nfrom collections import deque\n\nn,m = map(int, input().split())\nadj_list = [[] for i in range(n)]\nfor i in range(m):\n l, r, d = map(int, input().split())\n adj_list[l-1].append((r-1, d))\n adj_list[r-1].append((l-1, -d))\ndef search(start, dist_all):\n q = deque([start])\n dist_all[i] = 0\n while(len(q) > 0):\n w = q.popleft()\n for x in adj_list[w]:\n if dist_all[x[0]] is None:\n dist_all[x[0]] = dist_all[w] + x[1]\n q.append(x[0])\n elif dist_all[x[0]] != dist_all[w] + x[1]:\n return False\n return True\ndist_all = [None for i in range(n)]\nfor i in range(n):\n if dist_all[i] is None:\n if not search(i, dist_all):\n print('No')\n exit(0)\nprint('Yes')", "neg": "import sys\nfrom collections import deque\n\nn,m = map(int, input().split())\nadj_list = [[] for i in range(n)]\nfor i in range(m):\n l, r, d = map(int, input().split())\n adj_list[l-1].append((r-1, d))\n adj_list[r-1].append((l-1, -d))\ndef search(start, dist_all):\n q = deque([[start]])\n q_d = deque([0])\n while(len(q) > 0):\n path = q.popleft()\n dist = q_d.popleft()\n w = path[len(path) - 1]\n for x in adj_list[w]:\n if dist_all[x[0]] is None:\n dist_all[x[0]] = dist + x[1]\n new_path = path[:]\n new_path.append(x[0])\n elif dist_all[x[0]] != dist + x[1]:\n return False\n q.append(new_path)\n q_d.append(dist + x[1])\n return True\ndist_all = [None for i in range(n)]\nfor i in range(n):\n if dist_all[i] is None:\n if not search(i, dist_all):\n print('No')\n exit(0)\nprint('Yes')", "jacc_sim": 0.9344262295081968, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [295, 346], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03452", "p_user": "u761320129", "n_user": "u761320129", "pos": "N,M = map(int,input().split())\nes = [[] for i in range(N)]\n\nfor i in range(M):\n l,r,d = map(int,input().split())\n l,r = l-1, r-1\n es[l].append((r,d))\n es[r].append((l,-d))\n\ndist = [None] * N\nfor i in range(N):\n if dist[i] is not None: continue\n stack = [i]\n dist[i] = 0\n while stack:\n v = stack.pop()\n for to,d in es[v]:\n if dist[to] is None:\n stack.append(to)\n dist[to] = dist[v] + d\n elif dist[to] != dist[v] + d:\n print('No')\n exit()\nprint('Yes')\n", "neg": "N,M = map(int,input().split())\nes = [[] for i in range(N)]\nfor i in range(M):\n l,r,d = map(int,input().split())\n l,r = l-1,r-1\n es[l].append((r,d))\n es[r].append((l,-d))\n\nfor i in range(N):\n if dist[i] is not None: continue\n dist = [None] * N\n dist[i] = 0\n stack = [i]\n while stack:\n v = stack.pop()\n for to,d in es[v]:\n if dist[to] is None:\n dist[to] = dist[v] + d\n if not checked[to]:\n stack.append(to)\n else:\n if dist[to] != dist[v] + d:\n print('No')\n exit()\nprint('Yes')\n", "jacc_sim": 0.9375, "nl": "You are given the positions of N people standing on the x-axis. Each person's position is represented by an integer coordinate between 0 and 10^9. You are also given M pieces of information about the relative positions of these people. Some of this information may be incorrect. Your task is to determine if there exists a set of values (x1, x2, ..., xN) that is consistent with all the given pieces of information. If such a set exists, output \"Yes\"; otherwise, output \"No\". The input is given in the format N M followed by M lines of L, R, and D values. The output should indicate whether a consistent set of values exists. Examples of input and output are provided for reference.", "before_after_length": [217, 229], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u814781830", "n_user": "u814781830", "pos": "import math\nK = int(input())\nA = list(map(int, input().split()))\ndef check(init, A):\n cnt = init\n for a in A:\n group = cnt // a\n cnt = group * a\n return cnt\n\nl,r = 0, 2**100\nwhile r-l > 1:\n mid = (l+r)//2\n if check(mid, A) > 2:\n r = mid\n else:\n l = mid\nmaxcnt = l\n\nl,r = 0, 2**100\nwhile r-l > 1:\n mid = (l+r)//2\n if check(mid, A) < 2:\n l = mid\n else:\n r = mid\nmincnt = r\n\n\nif check(mincnt, A) == check(maxcnt, A) == 2:\n print(mincnt, maxcnt)\nelse:\n print(-1)\n\n", "neg": "import math\nK = int(input())\nA = list(map(int, input().split()))\ndef check(init, A):\n cnt = init\n for a in A:\n group = cnt // a\n cnt = group * a\n return cnt\n\nl,r = 2, 2**100\nwhile r-l > 1:\n mid = (l+r)//2\n if check(mid, A) >= 2:\n r = mid\n else:\n l = mid\nmincnt = r\n\nl,r = 2, 2**100\nwhile r-l > 1:\n mid = (l+r)//2\n if check(mid, A) <= 2:\n l = mid\n else:\n r = mid\nmaxcnt = l\n\n\nif check(mincnt, A) == check(maxcnt, A) == 2:\n print(mincnt, maxcnt)\nelse:\n print(-1)\n\n", "jacc_sim": 0.9767441860465116, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [226, 226], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u413165887", "n_user": "u413165887", "pos": "k = int(input())\na = list(map(int, input().split()))\n\ndef solve(num, checker):\n return checker*(num//checker)\n\nmax_A = max(a)\n\nleft, right = 0, k*max_A + 1\nwhile left < right:\n middle = (left+right)//2\n num = middle\n for i in a:\n num = solve(num, i)\n if num >= 2:\n right = middle\n else:\n left = middle + 1\nx = right\n\nleft, right = 0, k*max_A + 1\nwhile left < right:\n middle = -((-left-right)//2)\n #print(left, right, middle, num)\n num = middle\n \n for i in a:\n num = solve(num, i)\n if num <= 2:\n left = middle\n else:\n right = middle - 1\n \ny = right\n\nif y < x:\n print(-1)\nelse:\n print(x, y)\n", "neg": "k = int(input())\na = list(map(int, input().split()))\n\ndef solve(num, checker):\n return checker*(num//checker)\n\nleft, right = 0, 10**9\nwhile left < right:\n middle = (left+right)//2\n num = middle\n for i in a:\n num = solve(num, i)\n if num >= 2:\n right = middle\n else:\n left = middle + 1\nx = right\n\nleft, right = 0, 10**9\nwhile left < right:\n middle = (left+right)//2\n #print(left, right, middle, num)\n num = middle\n \n for i in a:\n num = solve(num, i)\n if num > 2:\n right = middle - 1\n else:\n left = middle + 1\ny = left\n\nif y < x:\n print(-1)\nelse:\n print(x, y)", "jacc_sim": 0.9090909090909091, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [255, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u644907318", "n_user": "u644907318", "pos": "import math\nK = int(input())\nA = list(map(int,input().split()))\nif A[K-1]!=2:\n print(-1)\nelif K==1:\n print(2,3)\nelse:\n nmin = 2\n nmax = 2+A[K-1]-1\n flag = 0\n for i in range(K-2,-1,-1):\n b = A[i]\n nmin = math.ceil(nmin/b)*b\n nmax = math.floor(nmax/b)*b\n if nmin>nmax:\n flag = 1\n break\n nmax += b-1\n if flag==1:\n print(-1)\n else:\n print(nmin,nmax)", "neg": "import math\nK = int(input())\nA = list(map(int,input().split()))\nif A[0]!=2:\n print(-1)\nelif K==1:\n print(2,3)\nelse:\n nmin = 2\n nmax = 2+A[K-1]-1\n flag = 0\n for i in range(K-2,-1,-1):\n b = A[i]\n nmin = math.ceil(nmin/b)*b\n nmax = math.floor(nmax/b)*b\n if nmin>nmax:\n flag = 1\n break\n nmax += b-1\n if flag==1:\n print(-1)\n else:\n print(nmin,nmax)", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [194, 192], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u730769327", "n_user": "u730769327", "pos": "n=int(input())\na=list(map(int,input().split()))[::-1]\nif a[0]!=2:\n print(-1)\n exit()\nmn,mx=2,2\nfor j in a:\n if (mn+j-1)//j>mx//j:\n print(-1)\n exit()\n mn=(mn+j-1)//j*j\n mx=mx//j*j+j-1\nprint(mn,mx)", "neg": "n=int(input())\na=list(map(int,input().split()))[::-1]\nmn,mx=2,2\nfor j in a:\n mn=(mn+j-1)//j*j\n mx=mx//j*j+j-1\n if mx==0:\n print(-1)\n exit()\nprint(mn,mx)", "jacc_sim": 0.9375, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [120, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u888337853", "n_user": "u888337853", "pos": "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef main():\n k = ni()\n a = na()\n a.reverse()\n\n min_num = 2\n max_num = 2\n\n for ai in a:\n min_num = int(math.ceil(min_num / ai) * ai)\n max_num = int(math.floor(max_num / ai + 1) * ai) - 1\n\n if min_num <= max_num:\n print(min_num, max_num)\n else:\n print(-1)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\nimport math\nimport collections\nimport bisect\nimport itertools\n\n# import numpy as np\n\nsys.setrecursionlimit(10 ** 7)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n# MOD = 998244353\n\nni = lambda: int(sys.stdin.readline().rstrip())\nns = lambda: map(int, sys.stdin.readline().rstrip().split())\nna = lambda: list(map(int, sys.stdin.readline().rstrip().split()))\nna1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))\n\n\n# ===CODE===\n\ndef main():\n k = ni()\n a = na()\n a.reverse()\n\n min_num = 2\n max_num = 2\n\n for ai in a:\n min_num = int(math.ceil(min_num / ai) * ai)\n max_num = int(math.floor(max_num / ai + 1) * ai) - 1\n\n print(min_num, max_num if min_num <= max_num else -1)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [305, 295], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u197457087", "n_user": "u197457087", "pos": "N = int(input())\nA = list(map(int,input().split()))\nA.reverse() #\u5f8c\u308d\u304b\u3089\u898b\u308b\u3002\n\nif A[0] != 2:\n print(-1)\n exit()\nMIN = 2\nMAX = 3\nfor i in range(1,N):\n nxt = A[i]\n if MAX < nxt:\n print(-1)\n exit() \n #\u30aa\u30c3\u30b1\u30fc\u306e\u6700\u5927\u5024\n MAX = (MAX//nxt)*nxt #MAX\u306f\u7d76\u5bfe\u524d\u306e\u6570\u306e\u500d\u6570\n if MAX < MIN:\n print(-1)\n exit()\n #\u30aa\u30c3\u30b1\u30fc\u306e\u6700\u5c0f\u5024\n MIN = min(MAX,((MIN+nxt-1)//nxt)*nxt)\n\n #print(MIN,MAX)\n \n #\u6700\u5c0f\u5024\u306f\u5909\u5316\u306a\u3057\u3002\n MAX = MAX+(nxt-1)\n #print(nxt,MIN,MAX)\nprint(MIN,MAX)\n", "neg": "N = int(input())\nA = list(map(int,input().split()))\nA.reverse() #\u5f8c\u308d\u304b\u3089\u898b\u308b\u3002\n\nif A[0] != 2:\n print(-1)\n exit()\nMIN = 2\nMAX = 3\nfor i in range(1,N):\n nxt = A[i]\n if MAX < nxt:\n print(-1)\n exit() \n #\u30aa\u30c3\u30b1\u30fc\u306e\u6700\u5927\u5024\n MAX = (MAX//nxt)*nxt #MAX\u306f\u7d76\u5bfe\u524d\u306e\u6570\u306e\u500d\u6570\n if MAX < MIN:\n print(-1)\n exit()\n #\u30aa\u30c3\u30b1\u30fc\u306e\u6700\u5c0f\u5024\n MIN = min(MAX,((MIN+nxt-1)//nxt)*nxt)\n\n print(MIN,MAX)\n \n #\u6700\u5c0f\u5024\u306f\u5909\u5316\u306a\u3057\u3002\n MAX = MAX+(nxt-1)\n print(nxt,MIN,MAX)\nprint(MIN,MAX)\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [318, 316], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u372144784", "n_user": "u372144784", "pos": "#AGC020-B Ice Rink Game\n\"\"\"\n\u9006\u64cd\u4f5c\u3092\u8003\u3048\u308b\u3002\n\u4f55\u4eba\u7d44\u3092\u4f5c\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001mod\u306b\u304a\u3051\u308b\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u6c42\u3081\u7d9a\u3051\u308b\u3068\u3044\u3046\u3053\u3068\u3002\n\u305d\u306e\u3088\u3046\u306a\u7d44\u304c\u4f5c\u308c\u306a\u3044\u3088\u3046\u306a\u5834\u5408(\u5168\u54e1\u304c\u8131\u843d\u3059\u308b\u3088\u3046\u306a\u5834\u5408)\u306f\u3001-1\u3092\u51fa\u529b\u3002\n\"\"\"\nimport sys\nreadline = sys.stdin.buffer.readline\ndef even(n): return 1 if n%2==0 else 0\n\nk = int(readline())\nlst1 = list(map(int,readline().split()))\nlst1.reverse()\nif lst1[0] != 2:\n print(-1)\n exit()\n\n\ndef min_lot(value,unit):\n if value%unit == 0:\n return value//unit\n else:\n return value//unit + 1\nmn = 2\nmx = 3\nfor i in range(1,k):\n res = min_lot(mn,lst1[i])\n\n if not mn <= res*lst1[i] <= mx:\n print(-1)\n exit()\n\n mn = res*lst1[i]\n\n lim = (mx//lst1[i] + 1)*lst1[i] - 1\n mx = lim\n\n\n\nprint(mn,mx)", "neg": "#AGC020-B Ice Rink Game\n\"\"\"\n\u9006\u64cd\u4f5c\u3092\u8003\u3048\u308b\u3002\n\u4f55\u4eba\u7d44\u3092\u4f5c\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u3001mod\u306b\u304a\u3051\u308b\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u6c42\u3081\u7d9a\u3051\u308b\u3068\u3044\u3046\u3053\u3068\u3002\n\u305d\u306e\u3088\u3046\u306a\u7d44\u304c\u4f5c\u308c\u306a\u3044\u3088\u3046\u306a\u5834\u5408(\u5168\u54e1\u304c\u8131\u843d\u3059\u308b\u3088\u3046\u306a\u5834\u5408)\u306f\u3001-1\u3092\u51fa\u529b\u3002\n\"\"\"\nimport sys\nreadline = sys.stdin.buffer.readline\ndef even(n): return 1 if n%2==0 else 0\n\nk = int(readline())\nlst1 = list(map(int,readline().split()))\nlst1.reverse()\nif lst1[0] != 2:\n print(-1)\n exit()\n\n\ndef min_lot(value,unit):\n if value%unit == 0:\n return value//unit\n else:\n return value//unit + 1\nmn = 2\nmx = 3\nfor i in range(1,k):\n if not mn <= lst1[i] <= mx:\n print(-1)\n exit()\n res = min_lot(mn,lst1[i])\n mn = res*lst1[i]\n\n lim = (mx//lst1[i] + 1)*lst1[i] - 1\n mx = lim\n\n\n\nprint(mn,mx)", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [489, 485], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u346812984", "n_user": "u346812984", "pos": "import sys\nimport math\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n K = int(input())\n A = list(map(int, input().split()))\n\n # \u30e9\u30a6\u30f3\u30c9i\u306b\u304a\u3051\u308b\u901a\u904e\u8005\u3092\u4fdd\u5b58\n m = 2\n M = 2\n for i in range(K - 1, -1, -1):\n n = (m + A[i] - 1) // A[i]\n tmp_m = n * A[i]\n tmp_M = (M // A[i]) * A[i] + A[i] - 1\n if tmp_m > M or tmp_M < m:\n print(-1)\n return\n m = tmp_m\n M = tmp_M\n\n print(m, M)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\nimport math\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n K = int(input())\n A = list(map(int, input().split()))\n\n if A[-1] != 2:\n print(-1)\n return\n\n # \u30e9\u30a6\u30f3\u30c9i\u306b\u304a\u3051\u308b\u901a\u904e\u8005\u3092\u4fdd\u5b58\n m = 2\n M = 2\n for i in range(K - 2, -1, -1):\n n = (m + A[i] - 1) // A[i]\n tmp_m = n * A[i]\n tmp_M = (n + 1) * A[i] - 1\n if tmp_m > M or tmp_M < m:\n print(-1)\n return\n m = tmp_m\n M = tmp_M\n\n print(m, M)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9861111111111112, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [274, 287], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u186838327", "n_user": "u186838327", "pos": "k = int(input())\nA = list(map(int, input().split()))\nA.reverse()\n\nL = [-1]*(k+1)\nR = [-1]*(k+1)\n\nL[0] = 2\nR[0] = 2\nfor i in range(1, k+1):\n if L[i-1]%A[i-1] == 0 or R[i-1]%A[i-1] == 0:\n pass\n else:\n if R[i-1] - L[i-1] >= A[i-1] or L[i-1]%A[i-1]>R[i-1]%A[i-1]:\n pass\n else:\n #print(i, A[i-1], L[i-1], R[i-1])\n print(-1)\n exit()\n if L[i-1]%A[i-1] == 0:\n L[i] = (L[i-1]//A[i-1])*A[i-1]\n else:\n L[i] = (L[i-1]//A[i-1]+1)*A[i-1]\n R[i] = (R[i-1]//A[i-1])*A[i-1]+A[i-1]-1\n #print(i, L[i], R[i])\n\n#print(L)\n#print(R)\nprint(L[k], R[k])", "neg": "k = int(input())\nA = list(map(int, input().split()))\nA.reverse()\n\nL = [-1]*(k+1)\nR = [-1]*(k+1)\n\nL[0] = 2\nR[0] = 2\nfor i in range(1, k+1):\n if L[i-1]%A[i-1] == 0 or R[i-1]%A[i-1] == 0:\n pass\n else:\n if R[i-1] - L[i-1] >= A[i-1] or L[i-1]%A[i-1]>R[i-1]%A[i-1]:\n pass\n else:\n print(-1)\n exit()\n if L[i-1]%A[i-1] == 0:\n L[i] = (L[i-1]//A[i-1])*A[i-1]\n else:\n L[i] = (L[i-1]//A[i-1]+1)*A[i-1]\n R[i] = (R[i-1]//A[i-1])*A[i-1]+A[i-1]-1\n\nprint(L)\nprint(R)\nprint(L[k], R[k])\n", "jacc_sim": 0.9736842105263158, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [365, 324], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u497046426", "n_user": "u497046426", "pos": "def div_ceil(x, y): return (x + y - 1) // y\n\nN = int(input())\n*A, = map(int, input().split())\ncand_min, cand_max = 2, 2\nfor a in reversed(A):\n if div_ceil(cand_min, a) * a > cand_max: print(-1); break\n cand_min = div_ceil(cand_min, a) * a\n cand_max = (cand_max // a) * a + a - 1\nelse:\n print(cand_min, cand_max)", "neg": "def div_ceil(x, y): return (x + y - 1) // y\n\nN = int(input())\n*A, = map(int, input().split())\ncand_min, cand_max = 2, 2\nfor a in reversed(A):\n if a > cand_max: print(-1); break\n cand_max = (cand_max // a) * a\n cand_min = div_ceil(cand_min, a) * a\n cand_max = cand_max + a - 1\nelse:\n cand_max = (cand_max // a) * a\n print(cand_min, cand_max)", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [145, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u223904637", "n_user": "u223904637", "pos": "n=int(input())\nl=list(map(int,input().split()))\nl.reverse()\nm=[2,3]\nif l[0]!=2:\n print(-1)\n exit()\nfor i in range(1,n):\n p=l[i]\n s=-(-m[0]//p)*p\n e=(m[1]//p)*p+p-1\n if not m[0]<=s<=m[1]:\n print(-1)\n exit()\n m=[s,e]\nprint(*m)\n", "neg": "n=int(input())\nl=list(map(int,input().split()))\nl.reverse()\nm=[2,3]\nif l[0]!=2:\n print(-1)\n exit()\nfor i in range(1,n):\n p=l[i]\n s=-(-m[0]//p)*p\n e=(m[1]//p)*p\n if not m[0]<=s<=m[1]:\n print(-1)\n exit()\n m=[s,e]\nprint(*m)", "jacc_sim": 0.9736842105263158, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [140, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u779455925", "n_user": "u779455925", "pos": "# input = sys.stdin.readline\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\nimport copy\nK=int(input())\nA=list(map(int,input().split()))\nif A[-1]!=2:\n print(-1)\n exit()\n\nmaX=2\nmiN=2\n\nfor i in range(K-1,-1,-1):\n\n if A[i]//maX>=2:\n print(-1)\n exit()\n if A[i]//miN>=2:\n miN=A[i]\n else:\n if miN%A[i]==0:\n pass\n else:\n miN=(miN//A[i] +1) *A[i]\n maX=maX-maX%A[i] + A[i]-1\n\nmmaX=maX\nfor i in range(K):\n mmaX-=mmaX%A[i]\nif mmaX==2:\n print(miN,maX)\nelse:\n print(-1)\n", "neg": "# input = sys.stdin.readline\nfrom bisect import *\nfrom collections import *\nfrom heapq import *\nimport copy\nK=int(input())\nA=list(map(int,input().split()))\nif A[-1]!=2:\n print(-1)\n exit()\n\nmaX=2\nmiN=2\nfor i in range(K-1,-1,-1):\n if A[i]%miN>=2:\n print(-1)\n exit()\n\n if miN%A[i]==0:\n pass\n else:\n miN=(miN//A[i] +1) *A[i]\n\n if maX%A[i]==0:\n maX=(maX//A[i]) *A[i] + A[i]-1\n else:\n maX=(maX//A[i]) *A[i] + A[i]-1\n\nprint(miN,maX)\n", "jacc_sim": 0.9795918367346939, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [270, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u620480037", "n_user": "u620480037", "pos": "K=int(input())\nA=list(map(int,input().split()))\nA=A[::-1]\n#print(A)\nif A[0]!=2:\n print(-1)\n exit()\n\nM=3\nm=2\nimport math\nfor i in range(1,K):\n if m%A[i]==0:\n Lm=m\n else:\n Lm=(m//A[i]+1)*A[i]\n #print(Lm)\n if Lm h:\n print(-1)\n else:\n print(l, h)\n\n\nif __name__ == \"__main__\":\n main()", "neg": "# AGC020B - Ice Rink Game\ndef main():\n K, *A = map(int, open(0).read().split())\n l, h = 2, 2 # low, high\n for i in A[::-1]:\n l = (l + i - 1) // i * i\n h = (h / i + 1) * i - 1\n if l > h:\n print(-1)\n else:\n print(l, h)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9545454545454546, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [120, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u509368316", "n_user": "u509368316", "pos": "K=int(input())\nA=list(map(int,input().split()))\nl,h=2,2\nfor a in A[::-1]:\n l=-(-l//a)*a\n h=(h//a+1)*a-1\n if l>h:\n l=h=-1\n break\nif l==h==-1:\n print(-1)\nelse:\n print(l,h)", "neg": "K=int(input())\nA=list(map(int,input().split()))\nl,h=2,2\nfor a in A[::-1]:\n if hMax or ma*iMax or ma*i r:\n l = r = -1\n print(l)\n exit()\n\nprint(l,r)\n", "neg": "def L(l,a):\n return ((l-1)//a)*a+a\n\ndef R(r,a):\n return (r//a)*a+a-1\nK = int(input())\nx = list(map(int,input().split()))\nl=2\nr=2\nfor i in range(K):\n a = x.pop()\n l = L(l,a)\n r = R(r,a)\n if l > r:\n l = r = -1\n break\n\nprint(l,r)\n", "jacc_sim": 0.9444444444444444, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [142, 135], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u075012704", "n_user": "u075012704", "pos": "K = int(input())\nA = list(map(int, input().split()))\n\n# \u6700\u5f8c\u306b2\u4eba\u4ee5\u4e0a\u6b8b\u308b\u3088\u3046\u306a\u6700\u5c0f\u306eN\u3092\u63a2\u3059\nok, ng = 10 ** 18, 0\nwhile abs(ok - ng) > 1:\n n = (ok + ng) // 2\n x = n\n for a in A:\n x = (x // a) * a\n if x >= 2:\n ok = n\n else:\n ng = n\nm = ok\n\n# \u6700\u5f8c\u306b2\u4eba\u4ee5\u4e0b\u306b\u306a\u308b\u3088\u3046\u306a\u6700\u5927\u306eN\u3092\u63a2\u3059\nok, ng = 0, 10 ** 18\nwhile abs(ok - ng) > 1:\n x = (ok + ng) // 2\n n = x\n for a in A:\n x = x // a * a\n\n if x <= 2:\n ok = n\n else:\n ng = n\nM = ok\n\n\n# \u6761\u4ef6\u3092\u6e80\u305f\u3059\u304b\u30c1\u30a7\u30c3\u30af\nmx, Mx = m, M\nfor a in A:\n mx = (mx // a) * a\n Mx = (Mx // a) * a\n\nif mx == 2 and Mx == 2:\n print(m, M)\nelse:\n print(-1)\n", "neg": "K = int(input())\nA = list(map(int, input().split()))\n\n# \u6700\u5f8c\u306b2\u4eba\u4ee5\u4e0a\u6b8b\u308b\u3088\u3046\u306a\u6700\u5c0f\u306eN\u3092\u63a2\u3059\nok, ng = 0, 10 ** 18\nwhile abs(ok - ng) > 1:\n n = (ok + ng) // 2\n x = n\n for a in A:\n x = (x // a) * a\n if x >= 2:\n ok = n\n else:\n ng = n\nm = ok\n\n# \u6700\u5f8c\u306b2\u4eba\u4ee5\u4e0b\u306b\u306a\u308b\u3088\u3046\u306a\u6700\u5927\u306eN\u3092\u63a2\u3059\nok, ng = 0, 10 ** 18\nwhile abs(ok - ng) > 1:\n x = (ok + ng) // 2\n n = x\n for a in A:\n x = x // a * a\n\n if x <= 2:\n ok = n\n else:\n ng = n\nM = ok\n\n\n# \u6761\u4ef6\u3092\u6e80\u305f\u3059\u304b\u30c1\u30a7\u30c3\u30af\nmx, Mx = m, M\nfor a in A:\n mx = (mx // a) * a\n Mx = (Mx // a) * a\n\nif mx == 2 and Mx == 2:\n print(m, M)\nelse:\n print(-1)\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [400, 400], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u201234972", "n_user": "u201234972", "pos": "K = int( input())\nA = list( map( int, input().split()))\nnowm = 2\nnowM = 2\nans = 0\nfor i in range(K-1,-1,-1):\n a = A[i]\n if nowm <= ((nowm+a-1)//a)*a and ((nowm+a-1)//a)*a <= nowM:\n nowm = ((nowm+a-1)//a)*a\n nowM = (nowM//a)*a + a - 1\n else:\n ans = -1\n break\n # if nowM < A[i]:\n # ans = -1\n # break\n # elif nowm <= A[i]:\n # nowm = A[i]\n # nowM = A[i]*2 - 1\n # else:\n # M = nowM\n # nowm = (nowm//A[i]+1)*A[i]\n # if nowm > M:\n # ans = -1\n # break\n # if (nowM//A[i]+1)*A[i] <= M:\n # nowM = (nowM//A[i]+1)*A[i] - 1\n # if nowM < nowm:\n # nowM = nowm + A[i] - 1\n # else:\n # nowM = nowm + A[i] - 1\nif ans == -1:\n print( -1)\nelse:\n print(\"{} {}\".format(nowm, nowM))", "neg": "K = int( input())\nA = list( map( int, input().split()))\nnowm = 2\nnowM = 2\nans = 0\nfor i in range(K-1,-1,-1):\n if nowM < A[i]:\n ans = -1\n break\n elif nowm <= A[i]:\n nowm = A[i]\n nowM = A[i]*2 - 1\n else:\n nowm = (nowm//A[i]+1)*A[i]\n nowM = (nowM//A[i]+1)*A[i] - 1\n if nowm > nowM:\n nowM = nowm + A[i] -1\n print(nowm, nowM)\nif ans == -1:\n print( -1)\nelse:\n print(\"{} {}\".format(nowm, nowM))\n", "jacc_sim": 0.9318181818181818, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [382, 210], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u810735437", "n_user": "u810735437", "pos": "# \u5f8c\u308d\u304b\u3089\u9806\u306b\u8003\u3048\u308b\n# \u6700\u5f8c\u306eA_K\u306f\u5fc5\u305a2\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\n# A_K\u306e\u524d\u306b\u306f2~3\u4eba\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\n# ...\n\nK = int(input())\nAs = list(map(int, input().split()))\nAs.reverse()\n\nfail = False\nif As[0] != 2:\n fail = True\nelse:\n mn = 2\n mx = 3\n for a in As[1:]:\n # \u4eca [mn, mx] = [4, 13], a = 3\u3060\u3068\u3059\u308b\n # a\u4eba\u7d44\u3092\u3064\u304f\u3063\u305f\u3042\u3068\u306b\u3042\u308a\u3046\u308b\u6570\u306f3\u306e\u500d\u6570\u306a\u306e\u3067\u3001\u3053\u3053\u3067\u306f6, 9, 12\u306e\u307f\u3042\u308a\u3046\u308b\n if mn % a != 0:\n mn = (mn // a) * a + a\n if mx % a != 0:\n mx = (mx // a) * a\n if mn > mx:\n fail = True\n break\n\n # mx\u3092\u4fee\u6b63\n mx = mx + (a - 1)\nif fail:\n print(-1)\nelse:\n print(mn, mx)\n", "neg": "# \u5f8c\u308d\u304b\u3089\u9806\u306b\u8003\u3048\u308b\n# \u6700\u5f8c\u306eA_K\u306f\u5fc5\u305a2\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\n# A_K\u306e\u524d\u306b\u306f2~3\u4eba\u3067\u3042\u308b\u5fc5\u8981\u304c\u3042\u308b\n# ...\n\nK = int(input())\nAs = list(map(int, input().split()))\nAs.reverse()\n\nfail = False\nif As[0] != 2:\n fail = True\nelse:\n mn = 2\n mx = 3\n for a in As[1:]:\n # \u4eca [mn, mx] = [4, 13], a = 3\u3060\u3068\u3059\u308b\n # a\u4eba\u7d44\u3092\u3064\u304f\u3063\u305f\u3042\u3068\u306b\u3042\u308a\u3046\u308b\u6570\u306f3\u306e\u500d\u6570\u306a\u306e\u3067\u3001\u3053\u3053\u3067\u306f6, 9, 12\u306e\u307f\u3042\u308a\u3046\u308b\n if mn % a != 0:\n mn = (mn // a) * a + a\n if mx % a != 0:\n mx = (mx // a) * a\n if mn > mx:\n fail = True\n break\n\n # mx\u3092\u4fee\u6b63\n mx = mx + (a - 1)\nif fail:\n print(-1)\nelse:", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [443, 434], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u284854859", "n_user": "u284854859", "pos": "k = int(input())\na = list(map(int,input().split()))\na = a[::-1]\n\nc = 2 #min\nd = 2 #max\nres = 1 #\u5224\u5b9a\n\nfor i in range(k):\n if d < a[i]:\n res = -1\n break\n if i != k-1:\n if c % a[i] != 0 or d % a[i] != 0:\n res = -1\n break\n else:\n d = d + a[i] -1\n p = c%a[i+1]\n q = d%a[i+1]\n if p == 0:\n c2 = c\n else:\n c2 = c + a[i+1]-p\n d2 = d-q\n \n if c2 <= d2:\n c = c2\n d = d2\n else:\n res = -1\n break\n else:\n d = d + a[i] -1\n \n \n \n \nif res == -1:\n print(-1)\nelse:\n print(str(c) + ' ' + str(d))", "neg": "k = int(input())\na = list(map(int,input().split()))\na = a[::-1]\n\nc = 2 #min\nd = 2 #max\nres = 1 #\u5224\u5b9a\n\nfor i in range(k):\n if d > a[i]:\n res = -1\n break\n if i != k-1:\n if c % a[i] != 0 or d % a[i] != 0:\n res = -1\n break\n else:\n d = d + a[i] -1\n p = c%a[i+1]\n q = d%a[i+1]\n if p == 0:\n c2 = c\n else:\n c2 = c + a[i+1]-p\n d2 = d-q\n \n if c2 <= d2:\n c = c2\n d = d2\n else:\n res = -1\n break\n else:\n d = d + a[i] -1\n \n \n \n \nif res == -1:\n print(-1)\nelse:\n print(str(c) + ' ' + str(d))", "jacc_sim": 0.9787234042553191, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [291, 291], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u858136677", "n_user": "u858136677", "pos": "def minandmax(bottom,up,mod): #bottom< n < up\u306a\u308bmod\u3067\u5272\u308a\u5207\u308c\u308bn\u306e\u5024\u306e\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u8fd4\u3059\n if bottom%mod == 0:\n mnm = bottom\n else:\n mnm = bottom + (mod-bottom%mod)\n if mnm > up:\n mnm = None\n if up%mod == 0:\n mxm = up\n else:\n mxm = up - up%mod\n if mxm < bottom:\n mxm = None\n ans = [mnm,mxm]\n return ans\n\nk = int(input())\na = list(map(int,input().split()))\ni = k-1\nbottom = 2\nup = 2\n\ncheck = True\nif a[-1] != 2:\n check = False\nwhile i >= 1 and check:\n nbottom = minandmax(bottom,up+a[i]-1,a[i-1])[0]\n nup = minandmax(bottom,up+a[i]-1,a[i-1])[1]\n if nbottom == None and nup == None:\n check = False\n elif nbottom == None:\n nbottom = nup\n elif nup == None:\n nup = nbottom\n i += -1\n bottom = nbottom\n up = nup\n\nif check:\n bottom = minandmax(bottom,bottom+a[0]-1,1)[0]\n up = minandmax(up,up+a[0]-1,1)[1]\n print(bottom,up)\nelse:\n print(\"-1\")", "neg": "def minandmax(bottom,up,mod): #bottom< n < up\u306a\u308bmod\u3067\u5272\u308a\u5207\u308c\u308bn\u306e\u5024\u306e\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u3092\u8fd4\u3059\n if bottom%mod == 0:\n mnm = bottom\n else:\n mnm = bottom + (mod-bottom%mod)\n if mnm > up:\n mnm = None\n if up%mod == 0:\n mxm = up\n else:\n mxm = up - up%mod\n if mxm < bottom:\n mxm = None\n ans = [mnm,mxm]\n return ans\n\nk = int(input())\na = list(map(int,input().split()))\ni = k-1\nbottom = 2\nup = 2\n\ncheck = True\nif a[-1] != 2:\n check = False\nwhile i >= 1 and check:\n bottom = minandmax(bottom,up+a[i]-1,a[i-1])[0]\n up = minandmax(bottom,up+a[i]-1,a[i-1])[1]\n if bottom == None and up == None:\n check = False\n elif bottom == None:\n bottom = up\n elif up == None:\n up = bottom\n i += -1\n\nif check:\n bottom = minandmax(bottom,bottom+a[0]-1,1)[0]\n up = minandmax(up,up+a[0]-1,1)[1]\n print(bottom,up)\nelse:\n print(\"-1\")", "jacc_sim": 0.9692307692307692, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [449, 421], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u333945892", "n_user": "u333945892", "pos": "from collections import defaultdict,deque\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\n\nK = int(input())\naa = reversed(inpl())\n\nMIN = MAX = 2\nfor a in aa:\n if MIN%a == 0 or MAX//a - MIN//a > 0:\n MIN = ((MIN-1)//a+1) *a\n MAX = MAX//a*a+a-1\n else:\n print(-1)\n sys.exit()\n\nprint(MIN,MAX)\n", "neg": "from collections import defaultdict,deque\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\n\nK = int(input())\naa = reversed(inpl())\n\nMIN = MAX = 2\nfor a in aa:\n print(a,MIN,MAX)\n if MIN%a == 0 or MAX//a - MIN//a > 0:\n MIN = ((MIN-1)//a+1) *a\n MAX = MAX//a*a+a-1\n else:\n print(-1)\n sys.exit()\n\nprint(MIN,MAX)\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [186, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u257974487", "n_user": "u257974487", "pos": "N = int(input())\nP = list(reversed(list(map(int, input().split()))))\n\ns, t = 2, 2\nfor i in P:\n p = max((s + i - 1) // i, 1)\n q = t // i\n if q < p:\n print(-1)\n quit(0)\n s, t = p * i, q * i + i - 1\n\nprint(s, t)\n", "neg": "N = int(input())\nP = list(reversed(list(map(int, input().split()))))\n\ns, t = 2, 2\nfor i in P:\n p = max((s + i - 1) // i, 1)\n q = t // i\n print(i)\n if q < p:\n print(-1)\n quit(0)\n s, t = p * i, q * i + i - 1\n\nprint(s, t)\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [110, 116], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u391475811", "n_user": "u391475811", "pos": "K = int(input())\nA = [int(i) for i in input().split()]\nA.reverse()\n\nmin_A=2\nmax_A=3\ncnt=True\nif A[0]!=2:\n print(-1)\n cnt=False\nfor i in range(1,K):\n a=(min_A+A[i]-1)//A[i]*A[i]\n b=max_A//A[i]*A[i]\n if a>b and cnt:\n print(-1)\n cnt=False\n break\n else:\n min_A=a\n max_A=b+A[i]-1\n\nif cnt:\n print(min_A,max_A)\n", "neg": "K = int(input())\nA = [int(i) for i in input().split()]\nA.reverse()\n\nmin_A=2\nmax_A=3\ncnt=True\nif A[-1]!=2:\n print(-1)\n cnt=False\nfor i in range(1,K):\n a=(min_A+A[i]-1)//A[i]*A[i]\n b=max_A//A[i]*A[i]\n if a>b:\n print(-1)\n cnt=False\n break\n else:\n min_A=a\n max_A=b+A[i]-1\n\nif cnt:\n print(min_A,max_A)\n", "jacc_sim": 0.95, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [181, 179], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u057463552", "n_user": "u057463552", "pos": "from math import floor,ceil\nK = int(input())\nA = [int(x) for x in input().split()]\nA.reverse()\njmax, jmin = 2,2\n\nfor i in range(0,K):\n mmax,mmin = jmax,jmin\n if mmin % A[i] != 0:\n if (mmin + (A[i] - (mmin % A[i]))) > mmax:\n print(-1)\n exit()\n\n jmin = ceil(jmin / A[i]) * A[i]\n jmax = floor(jmax / A[i]) * A[i] + A[i] -1\n\nprint(jmin, jmax)\n\n#\u8a08\u7b97\u91cf\u306fO(3K)\u3059\u306a\u308f\u3061O(K)", "neg": "from math import floor,ceil\nK = int(input())\nA = [int(x) for x in input().split()]\nA.reverse()\njmax, jmin = 2,2\n\nfor i in range(0,K):\n if jmin % A[i] != 0:\n if (jmin + (A[i] - (jmin % A[i]))) > jmin:\n print(-1)\n exit()\n\n jmin = ceil(jmin / A[i]) * A[i]\n jmax = floor(jmax / A[i]) * A[i] + A[i] -1\n\nprint(jmin, jmax)\n\n#\u8a08\u7b97\u91cf\u306fO(3K)\u3059\u306a\u308f\u3061O(K)", "jacc_sim": 0.9615384615384616, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [210, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u451017206", "n_user": "u451017206", "pos": "from math import floor, ceil\nk = int(input())\na = [int(i) for i in input().split()]\nl,r = 2,2\nfor ai in a[::-1]:\n xi = ceil(l/ai)\n yi = floor(r/ai)\n if xi > yi:\n print(-1)\n exit()\n l = xi * ai\n r = yi * ai + ai - 1\nprint(l, r)", "neg": "from math import floor, ceil\nk = int(input())\na = [int(i) for i in input().split()]\nl,r = 2,2\nfor ai in a[::-1]:\n if l // ai >= 1 or r // ai >= 1:\n print(-1)\n exit()\n l = ceil(l/ai)*ai\n r = floor(r/ai) * ai + ai - 1\nprint(l,r)\n", "jacc_sim": 0.918918918918919, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [109, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u636684559", "n_user": "u636684559", "pos": "K=int(input())\nA=input().split(' ')\nmin=2\nmax=2\nflag=0\nwhile K>0:\n K=K-1\n i=int(A[K])\n if maxmax:\n print('-1')\n flag=1\n break\n else:\n min=i\n max=max+i-(max%i)-1\nif flag==0:\n print('{0} {1}'.format(min,max))", "neg": "K=int(input())\nA=input().split(' ')\nmin=2\nmax=2\nflag=0\nwhile K>0:\n K=K-1\n i=int(A[K])\n if max ns:\n ns +=(((s-ns)//i)*i)\n if s > ns:\n ns+=i\n s = ns\nsn = s\nfor i in AT:\n sn = sn-sn%i\n\nif sn!=2:\n print(-1)\n exit()\nb = 1\nAT.reverse()\nfor i in AT:\n b=b-b%i\n nb = i\n if b > nb:\n nb +=(((b-nb)//i)*i)\n if b > nb:\n nb+=i\n b= (nb+i-1)\nprint(s,b)\n", "neg": "K = int(input())\nAT = list(map(int,input().split()))\n\nA=reversed(AT)\ns = 2;b = 1;lis=[]\nfor i in A:\n ns = i\n if s > ns:\n ns +=(((s-ns)//i)*i)\n if s > ns:\n ns+i\n s = ns\nsn = s\nfor i in AT:\n sn = sn-sn%i\n\nif sn!=2:\n print(-1)\n exit()\nb = 1\nAT.reverse()\nfor i in AT:\n b=b-b%i\n nb = i\n if b > nb:\n nb +=(((b-nb)//i)*i)\n if b > nb:\n nb+i\n b= (nb+i-1)\nprint(s,b)\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [213, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03464", "p_user": "u925364229", "n_user": "u925364229", "pos": "K = int(input())\nA = list(map(int,input().split()))\n\nif A[-1] != 2:\n\tprint(-1)\n\texit(0)\n\nminval = 2\nmaxval = 3\nfor i in range(K-1,-1,-1):\n\tif maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval))):\n\t\tprint(-1)\n\t\texit(0)\n\n\tif minval > A[i]:\n\t\tif minval % A[i] != 0:\n\t\t\tminval = minval + (A[i] - (minval % A[i]))\n\n\t\tmaxval = (maxval - (maxval % A[i]) + A[i] - 1)\n\n\telse:\n\t\tmaxval = A[i] + (A[i] - 1)\n\t\tminval = A[i]\n\t\t\n\nprint(str(minval) + \" \" + str(maxval))\n", "neg": "K = int(input())\nA = list(map(int,input().split()))\n\nif A[-1] != 2:\n\tprint(-1)\n\texit(0)\n\nminval = 2\nmaxval = 3\nfor i in range(K-1,-1,-1):\n\tif maxval < A[i] or (minval > A[i] and ((maxval - (maxval % A[i]) < minval)):\n\t\tprint(-1)\n\t\texit(0)\n\n\tif minval > A[i]:\n\t\tif minval % A[i] != 0:\n\t\t\tminval = minval + (A[i] - (minval % A[i]))\n\n\t\tmaxval = (maxval - (maxval % A[i]) + A[i] - 1)\n\n\telse:\n\t\tmaxval = A[i] + (A[i] - 1)\n\t\tminval = A[i]\n\t\t\n\nprint(str(minval) + \" \" + str(maxval))\n", "jacc_sim": 1.0, "nl": "In a game, an adult game master and N children play on an ice rink for K rounds. In each round, the game master announces to form groups of Ai children. Children form as many groups as possible, with one child in at most one group. Those without a group leave the game. After K rounds, exactly two children remain as winners. Given A1 to AK, find the smallest and largest possible N, or determine if no valid N exists. Constraints: 1 \u2264 K \u2264 10^5, 2 \u2264 Ai \u2264 10^9. Input format: K followed by A1 to AK. Output: Print the smallest and largest possible N, or -1 if the situation is impossible. Sample inputs and outputs are provided.", "before_after_length": [249, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03466", "p_user": "u545001286", "n_user": "u144695182", "pos": "T=int(input())\nfor t in range(T):\n\ta,b,c,d=map(int,input().split(' '))\n\tl,x,y,o=(a+b)//(min(a,b)+1),0,0,\"\"\n\tif a*l<=b:y=a+b\n\telif b*l<=a:x=a+b\n\telse:x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)\n\tfor i in range(c,d+1):o+=\"AB\"[i%(l+1)==0] if i<=x else \"BA\"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else \"AB\"[a-x+x//(l+1)-y//(l+1)==0]\n\tprint(o)", "neg": "for t in range(int(input())):\n a,b,c,d=map(int,input().split(' '));l,x,y,o=(a+b)//(min(a,b)+1),0,0,\"\"\n\tif a*l<=b:y=a+b\n\telif b*l<=a:x=a+b\n\telse:x,y=(a*l-b)//(l-1),(b*l-a)//(l-1)\n\tfor i in range(c,d+1):o+=\"AB\"[i%(l+1)==0] if i<=x else \"BA\"[(a+b-i+1)%(l+1)==0] if a+b-i+1<=y else \"AB\"[a-x+x//(l+1)-y//(l+1)==0]\n\tprint(o)", "jacc_sim": 0.9534883720930233, "nl": "You are given a function f(A, B), where A and B are positive integers. The function returns a string that meets the following conditions: it has a length of A + B, contains A letters \"A\" and B letters \"B\", has the smallest possible length of the longest substring of equal letters, and is the lexicographically smallest string satisfying the conditions. You need to answer Q queries, finding the substring of f(Ai, Bi) from position Ci to position Di (1-based). The constraints are: 1 \u2264 Q \u2264 10^3, 1 \u2264 Ai, Bi \u2264 5 \u00d7 10^8, 1 \u2264 Ci \u2264 Di \u2264 Ai + Bi, and Di - Ci + 1 \u2264 100. For each query, print the substring of f(Ai, Bi) from position Ci to position Di.", "before_after_length": [225, 220], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u278143034", "n_user": "u278143034", "pos": "# \u6307\u5b9a\u6642\u523b\u306e\u53d6\u5f97\nM = int(input())\n \n# 12/30\u306e\u6b8b\u308a\u6642\u9593\u306812/31\u306e24\u6642\u9593\u3092\u52a0\u7b97\u3057\u7d50\u679c\u3092\u51fa\u529b\ntotal = (24 - M) + 24\nprint(total)", "neg": "# \u6307\u5b9a\u6642\u523b\u306e\u53d6\u5f97\nM = int(input())\n\n# 12/30\u306e\u6b8b\u308a\u6642\u9593\u306812/31\u306e24\u6642\u9593\u3092\u52a0\u7b97\u3057\u7d50\u679c\u3092\u51fa\u529b\ntotal = M + 24\nprint(total)", "jacc_sim": 0.9714285714285714, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [111, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u744920373", "n_user": "u744920373", "pos": "import sys\ndef ii(): return int(sys.stdin.readline())\n\nM = ii()\n\nprint(48-M)\n", "neg": "def ii(): return int(sys.stdin.readline())\n\nM = ii()\n\nprint(48-M)", "jacc_sim": 0.9411764705882353, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [31, 27], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u902380746", "n_user": "u902380746", "pos": "import sys\nimport math\nimport bisect\n \ndef main():\n n = int(input())\n print(48 - n)\n \nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\nimport math\nimport bisect\n\ndef main():\n\tn = int(input())\n print(48 - n)\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [47, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u207799478", "n_user": "u207799478", "pos": "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\nm = int(input())\nprint(24+(24-m))\n", "neg": "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\nm = int(input)\nprint(24+(24-m)s)\n", "jacc_sim": 0.9655172413793104, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [84, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u482228764", "n_user": "u710282484", "pos": "i = int(input())\nprint(48-i)", "neg": "print(48-i)\ni=int(input())", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [13, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u550943777", "n_user": "u350049649", "pos": "n=int(input())\nprint(48 - n)", "neg": "n=int(input)\nprint(48-n)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [13, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u688055251", "n_user": "u545447142", "pos": "a=int(input())\nb=24-a\na=b+24\nprint(a)", "neg": "a=int(input())\nb=24-a\nprint(a)", "jacc_sim": 0.9090909090909091, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [23, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u742851263", "n_user": "u477696265", "pos": "a=int(input())\nb=24-a\nc=24+b\nprint(c)", "neg": "a = input()\nb = 24 - a\nc = 24 + b \nprint(c)", "jacc_sim": 0.9166666666666666, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [23, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u776871252", "n_user": "u776871252", "pos": "h = int(input())\n\nprint(24 + (24 - h))\n", "neg": "h = int(input())\n\nprint(24 + (24 - h)\n", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [18, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u914671452", "n_user": "u914671452", "pos": "#coding: utf-8\n\na = int(input())\n\nprint(24 - a + 24)", "neg": "#coding: utf-8\n\na = input()\n\nprint(24 - a + 24)", "jacc_sim": 0.9333333333333333, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [24, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u762420987", "n_user": "u799443198", "pos": "print(24+(24-int(input())))\n", "neg": "print(24+24-int(input())", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [13, 10], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u984870883", "n_user": "u984870883", "pos": "# -*- coding: utf-8 -*-\n\na=int(input())\n\ns=48-a\n\nprint(s)\n\n", "neg": "# -*- coding: utf-8 -*-\n\nint a=input()\n\nprint(48-a)\n", "jacc_sim": 0.9375, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [35, 28], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u636775911", "n_user": "u636775911", "pos": "#coding:utf-8\nn=int(input())\nn=48-n\nprint(n)\n\n", "neg": "#coding:utf-8\nn=int(input())\nn-=48\nprint(n)\n\n", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [26, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u339025042", "n_user": "u604655161", "pos": "\nM = int(input())\n\nprint(48-M)", "neg": " M = int(input())\n \n print(48-M)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [15, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u881621300", "n_user": "u881621300", "pos": "print(\"{}\".format(24 - int(input()) + 24))\n", "neg": "print(\"{}\".format(int(input()) + 24))\n", "jacc_sim": 0.9230769230769231, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [16, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u562060790", "n_user": "u941884460", "pos": "M = input()\nN = 48 - int(M)\nprint(N)\n", "neg": "N = int(input())\nprint(48-M)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [19, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u879082556", "n_user": "u879082556", "pos": "# -*- coding: utf-8 -*-\n# \u6574\u6570\u306e\u5165\u529b\na=input()\na=int(a)\nb=24+(24-a)\nprint(b)", "neg": "# -*- coding: utf-8 -*-\n# \u6574\u6570\u306e\u5165\u529b\na=input()\na=int(a)\nb=24-a\nprint(b)", "jacc_sim": 0.9545454545454546, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [57, 53], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u227210643", "n_user": "u602677143", "pos": "print(48-(int(input())))", "neg": "print(int(input())-48)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [10, 9], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u794543767", "n_user": "u036492525", "pos": "m =int(input())\nprint(48-m)", "neg": "m=int(input())\n print(48-m)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [13, 14], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u220345792", "n_user": "u740047492", "pos": "a=input()\nprint(48-int(a))", "neg": "a = int(input)\nprint(48-a)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [13, 13], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u714587753", "n_user": "u714587753", "pos": "# Try AtCoder\n# author: Leonardone @ NEETSDKASU\n \nm = int(input())\nans = 24 - m + 24\nprint(ans)", "neg": "# Try AtCoder\n# author: Leonardone @ NEETSDKASU\n\nm = int(input())\nans = m + 24\nprint(ans)", "jacc_sim": 0.95, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [41, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u865646085", "n_user": "u865646085", "pos": "a = int(input())\nans = 48 - a\nprint(ans)\n", "neg": "a = int(input())\nans = 48 - a\nprint(a)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [18, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u825528847", "n_user": "u825528847", "pos": "M = int(input())\nprint(24 + (24-M))\n", "neg": "M = int(input())\nprint(24 + (M-24))\n", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [17, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u865741247", "n_user": "u865741247", "pos": "temp=input()\nb=int(temp)\nprint(48-b)", "neg": "temp=input()\nb=int(temp)\nprint(48-temp)\n", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [18, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u590211278", "n_user": "u763249708", "pos": "m = int(input())\n\nans = 24 + 24-m\n\nprint(ans)\n", "neg": "m = int(input())\n\nprint(24-m+24", "jacc_sim": 0.9090909090909091, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [22, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u667024514", "n_user": "u355154595", "pos": "a = int(input())\n\nprint((24-a)+24)", "neg": "a=int(input())\nprint(24+(24-a)", "jacc_sim": 1.0, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [16, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03473", "p_user": "u652737716", "n_user": "u366959492", "pos": "x = int(input())\nprint(24 - x + 24)\n", "neg": "m=int(input())\nx=24+(24-m)\nprint(m)\n", "jacc_sim": 0.9090909090909091, "nl": "You have to determine the number of hours remaining until New Year's at a given time on December 30th. The input is the time in 24-hour notation, and the output is the number of hours remaining. The time is an integer between 1 and 23.", "before_after_length": [16, 22], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u074220993", "n_user": "u074220993", "pos": "S = list(input())\nlenS = len(S)\nS = S + ['.']\nK = lenS\ni = 0\nps = S[0]\nfor s in S:\n if s != ps:\n K = min(K, max(i, lenS-i))\n ps = s\n i += 1\nprint(K)", "neg": "S = list(input())\nlenS = len(S)\nS = S + ['.']\nK = 0\ni = 1\nps = S[1]\nfor s in S:\n if s != ps:\n K = min(K, max(i, lenS-i))\n ps = s\n i += 1\nprint(K)", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [83, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u798316285", "n_user": "u798316285", "pos": "S=input()\nl=len(S)\nif l%2==1:\n m=S[l//2]\n c=1\n for i in range(l//2):\n if S[l//2-i-1]==m and S[l//2+i+1]==m:\n c+=2\n else:\n break\n ans=c+(l-c)//2\nelse:\n m1=S[l//2-1]\n m2=S[l//2]\n c=0\n if m1==m2:\n c=2\n for i in range(l//2-1):\n if S[l//2-i-2]==m1 and S[l//2+i+1]==m1:\n c+=2\n else:\n break\n ans=c+(l-c)//2\nprint(ans)\n\n", "neg": "S=input()\nl=len(S)\nif l%2==1:\n m=S[l//2]\n c=1\n for i in range l//2:\n if S[l//2-i-1]==m and S[l//2+i+1]==m:\n c+=2\n else:\n break\n ans=c+(l-c)//2\nelse:\n m1=S[l//2-1]\n m2=S[l//2]\n c=0\n if m1==m2:\n c=2\n for i in range l//2-1:\n if S[l//2-i-2]==m1 and S[l//2+i+1]==m1:\n c+=2\n else:\n break\n ans=c+(l-c)//2\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [223, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u819135704", "n_user": "u819135704", "pos": "S = input()\n\nn = len(S)\na = n\nfor i in range(n-1):\n if S[i] != S[i+1]:\n a = min(a, max(i+1, n-i-1))\n\nprint(a)\n", "neg": "S = input()\n\na = n\nn = len(S)\nfor i in range(n-1):\n if S[i] != S[i+1]:\n a = min(a, max(i+1, n-i+1))\n\nprint(a)\n", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [67, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u519923151", "n_user": "u519923151", "pos": "s = input()\n\nsl = list(s)\nsl.append(\"2\")\n\nn = len(sl)\nres=[]\n\ntemp =1\nfor i in range(n-1):\n if sl[i+1] == sl[i]:\n temp +=1\n else:\n res.append(temp)\n temp = 1\n\nresu = n-1\nm = n-1\n\nwhile len(res) >1:\n resu = min(resu,max(res[0],m-res[0]))\n x = res.pop(1)\n res[0] = res[0]+x \n \nprint(resu)", "neg": "s = input()\n\nsl = list(s)\nsl.append(\"2\")\n\nn = len(sl)\nres=[]\n\ntemp =1\nfor i in range(n-1):\n if sl[i+1] == sl[i]:\n temp +=1\n else:\n res.append(temp)\n temp = 1\n\nresu = n-1\n\nwhile len(res) >1:\n resu = min(resu,max(res[0],res[1:]))\n x = res.pop(1)\n res[0] = res[0]+x \n\"\"\"\n if res[0] > sum(res[1:]):\n resu = min(resu,res[0])\n x = res.pop(1)\n res[0] = res[0]+x\n else:\n resu = min(resu,sum(res[1:]))\n x = res.pop(1)\n res[0] =res[0]+x\n\"\"\"\nprint(resu)", "jacc_sim": 0.9487179487179487, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [161, 250], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u336979293", "n_user": "u336979293", "pos": "S = list(input())\n\ndef check(x):\n #print(S[len(S)-x:x])\n for y in S[len(S)-x:x]:\n if y != S[len(S)-x]: break\n else:\n return True\n return False\n\ndef bisect(l,r):\n if r - l == 1: return l\n mid = (l+r) // 2\n if check(mid) == False:\n return bisect(l,mid)\n else:\n return bisect(mid,r)\nprint(bisect(0,len(S)+1))\n\n", "neg": "S = list(input())\n\ndef check(x):\n print(S[len(S)-x:x])\n for y in S[len(S)-x:x]:\n if y != S[len(S)-x]: break\n else:\n return True\n return False\n\ndef bisect(l,r):\n if r - l == 1: return l\n mid = (l+r) // 2\n if check(mid) == False:\n return bisect(l,mid)\n else:\n return bisect(mid,r)\nprint(bisect(1,len(S)+1))\n\n", "jacc_sim": 0.9444444444444444, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [149, 148], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u426108351", "n_user": "u426108351", "pos": "s = input()\nn = len(s)\n\nl = 0\nr = n//2 + 1\n\nwhile r - l > 1:\n m = l + (r-l)//2\n d = n//2 - m\n if s[d:n-d].count(\"0\") == 0 or s[d:n-d].count(\"1\") == 0:\n l = m\n else:\n r = m\n\nif n % 2 == 0:\n print(n//2+l)\nelse:\n print(n//2+l+1)\n", "neg": "s = input()\nn = len(s)\n\nl = 0\nr = n//2 + 1\n\nwhile r - l > 1:\n m = l + (r-l)//2\n d = n//2 - m\n print(s[d:n-d])\n if s[d:n-d].count(\"0\") == 0 or s[d:n-d].count(\"1\") == 0:\n l = m\n else:\n r = m\n\nif n % 2 == 0:\n print(n//2+l)\nelse:\n print(n//2+l+1)\n", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [137, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u488401358", "n_user": "u488401358", "pos": "S=input()\nN=len(S)\n\nb=[int(S[i]) for i in range(N)]\nfor i in range(1,N):\n b[i]+=b[i-1]\nblack=[0 for i in range(0,N+1)]\nfor i in range(0,N):\n black[i+1]=b[i]\n\ndef condition(K):\n if 2*K-11:\n test=(end+start)//2\n if condition(test):\n start=test\n else:\n end=test\n\nif condition(end):\n print(end)\nelse:\n print(start)\n", "neg": "S=input()\nN=len(S)\n\nb=[int(S[i]) for i in range(N)]\nfor i in range(1,N):\n b[i]+=b[i-1]\nblack=[0 for i in range(0,N+1)]\nfor i in range(0,N):\n black[i+1]=b[i]\n\n\ndef condition(K):\n if 2*K-11:\n test=(end+start)//2\n if condition(test):\n start=test\n else:\n end=test\n\nif condition(end):\n print(end)\nelse:\n print(start)", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [233, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u654470292", "n_user": "u654470292", "pos": "import bisect\nimport copy\nimport heapq\nimport math\nimport sys\nfrom collections import *\nfrom itertools import accumulate, combinations, permutations, product\n# from math import gcd\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\ns=input()\nls=len(s)\nkijun=s[ls//2]\nif ls%2==0:\n tmp=0\n for i in range(ls//2):\n if kijun==s[ls//2+i]==s[ls//2-1-i]:\n tmp+=1\n else:\n break\n print(ls//2+tmp)\nelse:\n tmp=1\n for i in range(ls//2):\n if kijun==s[ls//2+1+i]==s[ls//2-1-i]:\n tmp+=1\n else:\n break\n print(ls//2+tmp)", "neg": "import bisect\nimport copy\nimport heapq\nimport math\nimport sys\nfrom collections import *\nfrom itertools import accumulate, combinations, permutations, product\n# from math import gcd\ndef input():\n return sys.stdin.readline()[:-1]\ndef ruiseki(lst):\n return [0]+list(accumulate(lst))\nmod=pow(10,9)+7\nal=[chr(ord('a') + i) for i in range(26)]\ndirection=[[1,0],[0,1],[-1,0],[0,-1]]\n\ns=input()\nls=len(s)\nif ls%2==0:\n tmp=0\n for i in range(ls//2):\n if s[ls//2+i]==s[ls//2-1-i]:\n tmp+=1\n else:\n break\n print(ls//2+tmp)\nelse:\n tmp=1\n for i in range(ls//2):\n if s[ls//2+1+i]==s[ls//2-1-i]:\n tmp+=1\n else:\n break\n print(ls//2+tmp)", "jacc_sim": 0.984375, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [296, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u787456042", "n_user": "u787456042", "pos": "s=input();l=[];n=len(s)\nfor i in range(n-1):\n if s[i]!=s[i+1]:l+=[max(i+1,n-i-1)]\nprint(min(l)if l else n)", "neg": "s=input();l=[]\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:l+=[max(i,len(s)-i-1)]\nprint(min(l))", "jacc_sim": 0.9230769230769231, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [65, 55], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u792670114", "n_user": "u792670114", "pos": "S = input()\nc0 = S[len(S)//2]\nr = S.find(\"1\" if c0 == \"0\" else \"0\", len(S)//2)\nif r < 0: r = len(S)\nl = S.rfind(\"1\" if c0 == \"0\" else \"0\", 0, len(S)//2)\nl += 1\nK = min(r, len(S)-l)\n#print(l, r, K)\nprint(K)\n", "neg": "S = input()\nc0 = S[len(S)//2]\nr = S.find(\"1\" if c0 == \"0\" else \"0\", len(S)//2)\nif r < 0: r = len(S)//2\nl = S.rfind(\"1\" if c0 == \"0\" else \"0\", 0, len(S)//2)\nl += 1\nK = min(r, len(S)-l)\n#print(l, r, K)\nprint(K)\n", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [119, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u163320134", "n_user": "u227082700", "pos": "s=input()\nl=len(s)\nans=l\nfor i in range(l-1):\n if s[i]!=s[i+1]:\n tmp=max(i+1,l-i-1)\n ans=min(ans,tmp)\nprint(ans)", "neg": "s=input()\nans=len(s)\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:\n ans=min(ans,max(i+1,len(s)-i))\nprint(ans)\n", "jacc_sim": 0.92, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [71, 64], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u558242240", "n_user": "u558242240", "pos": "s = input()\n\"\"\"\ns = '101'\ns = '100000000'\ns = '00001011'\n\"\"\"\nk = len(s)\nfor i in range(1, len(s)):\n if s[i-1] != s[i]:\n k = min(k, max(i, len(s)-i))\nprint(k)\n\n\n", "neg": "#s = input()\n\"\"\"\ns = '101'\ns = '100000000'\ns = '00001011'\n\"\"\"\nk = len(s)\nfor i in range(1, len(s)):\n if s[i-1] != s[i+1]:\n k = min(k, max(i, len(s)-i))\nprint(k)\n\n\n", "jacc_sim": 0.9285714285714286, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [89, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u644778646", "n_user": "u644778646", "pos": "S = input()\n\nans = 0\nif len(S) % 2 == 0:\n ans = len(S)//2\n c = ans\n t = S[ans]\n for i in range(len(S)//2-1,-1,-1):\n if S[i] == S[c] and S[i] == t:\n ans += 1\n c += 1\n else:\n break\nelse:\n ans = len(S)//2+1\n c = ans\n t = S[ans-1]\n for i in range(len(S)//2-1,-1,-1):\n if S[i] == S[c] and S[i] == t:\n ans += 1\n c += 1\n else:\n break\n\n ans = max(len(S)//2,ans)\n\nprint(ans)\n", "neg": "S = input()\n\nans = 0\nif len(S) % 2 == 0:\n ans = len(S)//2\n c = ans\n t = S[ans]\n for i in range(len(S)//2-1,-1,-1):\n if S[i] == S[c] and S[i] == t:\n ans += 1\n c += 1\n else:\n break\nelse:\n ans = len(S)//2\n c = ans+1\n t = S[ans+1]\n for i in range(len(S)//2-1,-1,-1):\n if S[i] == S[c] and S[i] == t:\n ans += 1\n c += 1\n else:\n break\nprint(ans)\n", "jacc_sim": 0.9666666666666667, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [214, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u037430802", "n_user": "u037430802", "pos": "s = input()\n\n\n\ntmp = []\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n tmp.append(max(i+1,len(s)-(i+1)))\n\nif len(tmp) == 0:\n #\u5143\u304b\u3089\u5168\u90e8\u540c\u3058\n print(len(s))\nelse:\n print(min(tmp))", "neg": "s = input()\n\nif len(s) == 1:\n\n\ntmp = []\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n tmp.append(max(i+1,len(s)-(i+1)))\n\nif len(tmp) == 0:\n #\u5143\u304b\u3089\u5168\u90e8\u540c\u3058\n print(len(s))\nelse:\n print(min(tmp))", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [111, 120], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u505830998", "n_user": "u505830998", "pos": "# -*- coding: utf-8 -*-\n\nimport sys\ninput = sys.stdin.readline\n\ndef io_generator():\n\treturn input()\n\n#+++++++++++++++++++\n\ndef main(io):\n\ts=list(io())[:-1]\n\tif len(s)% 2==1:\n\t\tcenter=len(s)//2\n\t\tmm=s[center]\n\t\tret=center+1\n\t\tla=s[center-1::-1]\n\t\tlb=s[center+1:]\n\t\tfor ca,cb in zip(la,lb):\n\t\t\t#print(ca,cb,mm)\n\t\t\tif ca == mm and cb == mm:\n\t\t\t\tret += 1\n\t\t\telse:\n\t\t\t\tbreak\n\telse:\n\t\tcenter=len(s)//2\n\t\tret=center\n\t\tmm=-1\n\t\tla=s[center-1::-1]\n\t\tlb=s[center:]\n\t\tfor ca, cb in zip(la, lb):\n\t\t\tif (mm == ca or mm == -1) and ca == cb:\n\t\t\t\tret+=1\n\t\t\t\tmm=ca\n\t\t\telse:\n\t\t\t\tbreak\n\t\t\t\t\n\tif 0:\n\t\tprint(la)\n\t\tprint(lb)\n\t\tprint(mm)\n\treturn ret\n\n#++++++++++++++++++++\n\nif __name__ == \"__main__\":\n\tio= lambda : io_generator()\n\tprint (main(io))", "neg": "# -*- coding: utf-8 -*-\n\nimport sys\ninput = sys.stdin.readline\n\ndef io_generator():\n\treturn input()\n\n#+++++++++++++++++++\n\ndef main(io):\n\ts=list(io())\n\tif len(s)% 2==1:\n\t\tcenter=len(s)//2\n\t\tmm=s[center]\n\t\tret=center\n\t\tfor ca,cb in zip(s[:center-1:-1],s[center+1:]):\n\t\t\t#print(ca,cb)\n\t\t\tif ca == mm and cb == mm:\n\t\t\t\tret += 1\n\t\t\telse:\n\t\t\t\tbreak\n\telse:\n\t\tcenter=len(s)//2\n\t\tret=center\n\t\tmm=-1\n\t\tla=s[center:-1]\n\t\tlb=s[center:]\n\t\tfor ca, cb in zip(la, lb):\n\t\t\t#print(mm,ca,cb, center)\n\t\t\tif (mm == ca or mm == -1) and ca == cb:\n\t\t\t\tret+=1\n\t\t\t\tmm=ca\n\t\t\telse:\n\t\t\t\tbreak\n\treturn ret\n\n#++++++++++++++++++++\n\nif __name__ == \"__main__\":\n\tio= lambda : io_generator()\n\tprint (main(io))", "jacc_sim": 0.9811320754716981, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [357, 320], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u052499405", "n_user": "u052499405", "pos": "s = input()\nif len (s) % 2 == 1:\n l = r = (len(s) + 1) // 2\n k = l-1\nelse:\n l = len(s) // 2\n r = len(s) // 2 + 1\n k = l\ncenter = s[l-1]\n\nwhile s[l-1] == center and s[r-1] == center:\n k += 1\n l -= 1\n r += 1\n if l - 1 < 0:\n break\n\nprint(k)", "neg": "s = input()\nif len (s) % 2 == 1:\n l = r = (len(s) + 1) // 2\n k = l-1\nelse:\n l = len(s) // 2\n r = len(s) // 2 + 1\n k = l\n\nwhile s[l-1] == s[r-1]:\n k += 1\n l -= 1\n r += 1\n if l - 1 < 0:\n break\n\nprint(k)", "jacc_sim": 0.9259259259259259, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [131, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u046187684", "n_user": "u046187684", "pos": "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(zip(l[:h], l[1:h + 1], l_r[:h], l_r[1:h + 1])):\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", "neg": "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(zip(l[:h], l[1:h + 1], l_r[:h], l_r[1:h + 1])):\n if c ^ n or c_r ^ n_r:\n index = i + 1\n print(len(string) - index)\n\n\nif __name__ == '__main__':\n print(solve(input()))\n", "jacc_sim": 0.9512195121951219, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [155, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u623819879", "n_user": "u547167033", "pos": "s=input()\npre=s[0]\nn=len(s)\nans=n\nfor i in range(n-1):\n if s[i]!=s[i+1]:\n ans=min(ans,max(i+1,n-(i+1)))\n pre=s[i]\nprint(ans)", "neg": "s=input()\nn=len(s)\nans=n\nfor i in range(n-1):\n if s[i+1]!=s[i]: \n ans=min(ans,max(i,n-i-1))\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [81, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u745087332", "n_user": "u745087332", "pos": "s = input()\nn = len(s)\nk = 0\ntmp = set()\nwhile k * 2 < n and len(tmp) < 2:\n tmp.add(s[n // 2 + k])\n tmp.add(s[(n - 1) // 2 - k])\n k += 1\nprint(n // 2 + k - (len(tmp) == 2))", "neg": "s = input()\nn = len(s)\nk = 0\ntmp = set()\nwhile k * 2 < n and len(tmp) < 2:\n print(k)\n tmp.add(s[n // 2 + k])\n tmp.add(s[(n - 1) // 2 - k])\n k += 1\nprint(n // 2 + k - (len(tmp) == 2))", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [89, 95], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u864197622", "n_user": "u864197622", "pos": "s = input()\nt = s[len(s)//2]\nj = len(s)//2\ni = len(s)-j-1\nans = j\nwhile i >= 0:\n if s[i] != t or s[j] != t:\n break\n ans += 1\n i -= 1\n j += 1\n\nprint(ans)", "neg": " = input()\nt = s[len(s)//2]\nj = len(s)//2\ni = len(s)-j-1\nans = j\nwhile i >= 0:\n if s[i] != t or s[j] != t:\n break\n ans += 1\n i -= 1\n j += 1\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [86, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u824237520", "n_user": "u595952233", "pos": "s = list(map(int, list(input())))\n\nn = len(s)\nans = n\nfor i in range(1, n):\n if s[i] != s[i - 1]:\n ans = min(ans, max(i, n-i))\n\nprint(ans)", "neg": "s = list(map(int, list(input())))\nans = n\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:\n ans = min(ans, max(i+1, len(s)-i-1))\nprint(ans)\n", "jacc_sim": 0.9629629629629629, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [71, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u232852711", "n_user": "u232852711", "pos": "s = input()\n\ni_flips = []\ni = 0\nfor j in range(1, len(s)):\n if s[j] != s[i]:\n i_flips.append(j)\n i = j\n# print(i_flips)\n\nif len(i_flips) == 0:\n print(len(s))\nelse:\n ans = len(s)\n for i in i_flips:\n ans = min(ans, max(i, len(s)-i))\n print(ans)\n", "neg": "s = input()\n\ni_flips = []\ni = 0\nfor j in range(1, len(s)):\n if s[j] != s[i]:\n i_flips.append(j)\n i = j\nprint(i_flips)\n\nif len(i_flips) == 0:\n print(len(s))\nelse:\n ans = len(s)\n for i in i_flips:\n ans = min(ans, max(i, len(s)-i))\n print(ans)\n", "jacc_sim": 0.9655172413793104, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [133, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u075012704", "n_user": "u006657459", "pos": "S = input()\nK = len(S)\nfor i in range(1, len(S)):\n if S[i-1] != S[i]:\n K = min(K, max(i, len(S)-i))\n\nprint(K)\n", "neg": "S = input()\nbest = len(S)\nfor i in range(1, len(S)):\n if S[i-1] != S[i]:\n best = min(best, max(i, len(S) - 1))\nprint(best)", "jacc_sim": 0.9130434782608695, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [63, 62], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u255001744", "n_user": "u255001744", "pos": "S = input()\n\n# s = S[0]\ntemp_T = len(S)\nfor i in range(len(S)-1):\n if(S[i] != S[i+1]):\n judge = max(i+1,len(S)-(i+1))\n temp_T = min(judge, temp_T)\n\nprint(temp_T)\n", "neg": "S = input()\n\ns = S[0]\ntemp_T = 100000\nfor i in range(1, len(S)+1):\n if(S[i] != s):\n judge = max(i,len(S)-i)\n temp_T = min(judge, temp_T)\n s = S[i]\n\nprint(temp_T)\n", "jacc_sim": 0.9285714285714286, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [94, 90], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u480847874", "n_user": "u480847874", "pos": "def ans():\n S = input()\n N = len(S)\n if not ('1' in S and '0' in S):\n return print(N)\n\n tmp = 1000000\n for i, v in enumerate(S):\n if i == 0:\n continue\n if S[i-1] != v:\n tmp = min(max(i, N-i), tmp)\n return print(tmp)\n\n# main()\nans()", "neg": "def ans():\n S = input()\n N = len(S)\n if not ('1' in S and '0' in S):\n return print(N)\n\n tmp = 1000000\n for i, v in enumerate(S):\n if i == 0:\n continue\n if S[i-1] != v:\n tmp = min(max(i, N-i), tmp)\n return print(tmp)\n", "jacc_sim": 0.9428571428571428, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [110, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u000349418", "n_user": "u000349418", "pos": "S=input()\nif len(S)==1:\n print('1')\nelse:\n k=0\n L=[]\n while k < (len(S)-1):\n if S[k] != S[k+1]:\n L.append(max(k+1,len(S)-k-1))\n k += 1\n else:\n k += 1\n L.sort()\n if len(L)==0:\n print(len(S))\n else:\n print(L[0])", "neg": "S=input()\nif len(S)==1:\n print('1')\nelse:\n k=0\n L=[]\n while k < (len(S)-1):\n if S[k] != S[k+1]:\n L.append(max(k,len(S)-k))\n k += 1\n else:\n k += 1\n L.sort()\n print(L[0])", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [128, 102], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u327248573", "n_user": "u327248573", "pos": "# -- coding: utf-8 --\n\nbinary = input()\nn = len(binary)\nk = n\nfor i in range(n - 1):\n if binary[i] != binary[i + 1]:\n k = min(k, max(i + 1, n - i - 1))\n\nprint(k)", "neg": "# -- coding: utf-8 --\n\nbinary = input()\nn = len(binary)\nk = n\nfor i in range(n - 1):\n if binary[i] != binary[i + 1]:\n k = min(k, max(i, n - i - 1))\n\nprint(k)", "jacc_sim": 1.0, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [75, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u910288980", "n_user": "u543954314", "pos": "s = input()\nn = len(s)\n\nans = n\nfor i in range(n-1) :\n if s[i] != s[i+1] :\n ans = min(ans, max(i+1, n-i-1))\n\nprint(ans)\n", "neg": "s = input()\nn = len(s)\nt = s[::-1]\nans = n\nfor i in range(n-1):\n if s[i] != s[i+1]:\n ans = min(ans,max(i+2,n-i-1))\nprint(ans)", "jacc_sim": 0.9230769230769231, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [69, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u930964209", "n_user": "u361243145", "pos": "l = input()\n\nans = len(l)\nfor i in range(len(l)-1):\n if l[i] != l[i+1]:\n ans = min(ans, max(i+1, len(l)-i-1))\n\nprint(ans)\n", "neg": "S = input()\n\nans = len(S)\nfor i in range(len(S)-1):\n if S[i] != S[i+1]:\n ans = min(ans, max(i, len(S)-i))\n\nprint(ans)\n", "jacc_sim": 0.9166666666666666, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [67, 63], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u846150137", "n_user": "u846150137", "pos": "l=input()\nn=len(l)\nx = n\nfor i in range(1,n):\n if l[i-1] != l[i]:\n nx = max(i, n-i)\n x = min(x,nx)\nprint(x)", "neg": "l=input()\nn=len(l)\n\nfor i in range(1,n):\n x = n\n nx=0\n if l[i-1] != l[i]:\n nx = max(i, n-i)\n x = min(x,nx)\nprint(x)", "jacc_sim": 0.96, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [66, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u225528554", "n_user": "u225528554", "pos": "if __name__==\"__main__\":\n l = list(input())\n N = len(l)\n results = []\n for i in range(0,N-1):\n if not l[i]==l[i+1]:\n results.append(max(i+1,N-i-1))\n if len(results):\n print(min(results))\n else:\n print(N)", "neg": "if __name__==\"__main__\":\n l = list(input())\n N = len(l)\n pre = l[0]\n results = []\n for i in range(1,N):\n if not l[i]==pre:\n pre = l[i]\n results.append(max(i+1,N-i-1))\n print(min(results))", "jacc_sim": 0.9393939393939394, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [101, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03480", "p_user": "u948374595", "n_user": "u948374595", "pos": "import math\nS = input()\nL = S[:math.ceil(len(S)/2)]\nR = S[len(S)//2:]\n#print(L, R)\nif L[-1] == R[0]:\n j = 1\n i = 1\n while i < len(L):\n if R[0] == R[i] and L[-i-1] == R[i]:\n #print(-i-1, i)\n #print(L[-i-1], R[i])\n j += 1\n #print(j)\n else:\n break\n i+=1\n #print(i)\nelse:\n j = 0 \n \n#print(j)\nprint(math.floor(len(S)/2) + j)", "neg": "import math\nS = input()\nt = len(S)-1\nL = S[:math.ceil(len(S)/2)]\nR = S[len(S)//2:]\n#print(L, R)\nif L[-1] == R[0]:\n j = 0\n i = 1\n while i < len(L):\n if R[0] == R[i] and L[-i-1] == R[i]:\n j += 1\n i+=1\nelse:\n j = 0 \n \n#print(j)\nprint(math.floor(len(S)/2) + j)", "jacc_sim": 0.9411764705882353, "nl": "You are given a string S consisting of 0 and 1. Find the maximum integer K not greater than the length of S such that we can turn all the characters of S into 0 by repeating a specific operation. The operation involves choosing a contiguous segment in S of length at least K and toggling the 0s to 1s and 1s to 0s. The input is given as S, and the output should be the maximum integer K.", "before_after_length": [188, 149], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03483", "p_user": "u057109575", "n_user": "u057109575", "pos": "from collections import defaultdict\nS = input()\n\nclass BIT:\n def __init__(self, n):\n self.n = n\n self.bit = [0] * (n + 1)\n\n def update(self, i, v):\n while i <= self.n:\n self.bit[i] += v\n i += i & -i\n \n def query(self, i):\n ret = 0\n while i > 0:\n ret += self.bit[i]\n i -= i & -i\n \n return ret\n\nd = defaultdict(list)\nfor i, v in enumerate(S):\n d[v].append(i + 1)\n\nif sum(len(l) % 2 != 0 for l in d.values()) > 1:\n print(-1)\n exit()\n\nN = len(S)\nctr = []\nkey_map = [-1] * (N + 1)\n\nfor k, v in d.items():\n t = len(v)\n if t % 2 == 1:\n key_map[v[t // 2]] = N // 2 + 1\n\n for j in range(t // 2):\n ctr.append((v[j], v[-j - 1]))\n \nctr.sort()\n\nfor i, (l, r) in enumerate(ctr):\n key_map[l] = i + 1\n key_map[r] = N - i\n\ntree = BIT(N)\nans = 0\nfor i, v in enumerate(key_map[1:]):\n ans += i - tree.query(v)\n tree.update(v, 1)\nprint(ans)\n", "neg": "from collections import defaultdict\nS = input()\n\nclass BIT:\n def __init__(self, n):\n self.n = n\n self.bit = [0] * (n + 1)\n\n def update(self, i, v):\n while i <= self.n:\n self.bit[i] += v\n i += i & -i\n \n def query(self, i):\n ret = 0\n while i > 0:\n ret += self.bit[i]\n i -= i & -i\n \n return ret\n\nd = defaultdict(list)\nfor i, v in enumerate(S):\n d[v].append(i + 1)\n\nif sum(len(l) % 2 != 0 for l in d.values()) > 1:\n print(-1)\n exit()\n\nN = len(S)\nctr = []\nkey_map = [-1] * (N + 1)\n\nfor k, v in d.items():\n t = len(v)\n if t % 2 == 1:\n key_map[v[t % 2]] = N // 2 + 1\n\n for j in range(t // 2):\n ctr.append((v[j], v[-j - 1]))\n \nctr.sort()\n\nfor i, (l, r) in enumerate(ctr):\n key_map[l] = i + 1\n key_map[r] = N - i\n\ntree = BIT(N)\nans = 0\nfor i, v in enumerate(key_map[1:]):\n ans += i - tree.query(v)\n tree.update(v, 1)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. Determine whether it can be turned into a palindrome by repeatedly swapping two adjacent characters. If possible, find the minimum required number of operations. Constraints: 1 \u2264 |S| \u2264 2 \u00d7 10^5. If it cannot be turned into a palindrome, print -1; otherwise, print the minimum required number of operations.", "before_after_length": [398, 398], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03483", "p_user": "u785578220", "n_user": "u785578220", "pos": "from collections import defaultdict\n\na = list(map(ord, input()))\nN = len(a)\nLa = ord(\"a\")\n\ndata = [0]*(N+1)\n\n\nd = [[] for i in range(26)]\nfor i , c in enumerate(a):\n d[c-La].append(i)\n\nodd = 0\nfor v in d:\n if len(v) % 2:\n odd += 1\nif not odd <= N%2:\n print(-1)\n exit(0)\n\ndata = [0]*(N+1)\ndef add(k, x):\n while k <= N:\n data[k] += x\n k += k & -k\ndef get(k):\n s = 0\n while k:\n s += data[k]\n k -= k & -k\n return s\n\nM = [None]*N\nfor v in d:\n vl = len(v)\n for i in range(vl):\n if not i <= vl-1-i:\n break\n p = v[i]; q = v[-i-1]\n M[p] = q\n M[q] = p\ncnt = 0\nB = [0]*N\nfor i in range(N-1, -1, -1):\n if M[i] <= i:\n B[i] = B[M[i]] = cnt\n cnt += 1\n\ncur = -1\nans = 0\nfor i in range(N-1, -1, -1):\n\n if cur < B[i]:\n cur = B[i]\n if M[i] == i:\n ans += N//2 - cur\n else:\n ans += M[i] - get(M[i]+1)\n add(M[i]+1, 1)\nprint(ans)\n", "neg": "from collections import defaultdict\n\na = list(map(ord, input()))\nN = len(a)\nLa = ord(\"a\")\n\ndata = [0]*(N+1)\n\n\nd = defaultdict(list)\nfor i , c in enumerate(a):\n d[c-La].append(i)\nprint(d)\nodd = 0\nfor v in d:\n if len(d[v]) % 2:\n odd += 1\nif not odd <= N%2:\n print(-1)\n exit(0)\n\ndata = [0]*(N+1)\ndef add(k, x):\n while k <= N:\n data[k] += x\n k += k & -k\ndef get(k):\n s = 0\n while k:\n s += data[k]\n k -= k & -k\n return s\n\nM = [None]*N\nfor v in d:\n v = d[v]\n vl = len(v)\n for i in range(vl):\n if not i <= vl-1-i:\n break\n p = v[i]; q = v[-i-1]\n M[p] = q\n M[q] = p\ncnt = 0\nB = [0]*N\nfor i in range(N-1, -1, -1):\n if M[i] <= i:\n B[i] = B[M[i]] = cnt\n cnt += 1\n\ncur = -1\nans = 0\nfor i in range(N-1, -1, -1):\n\n if cur < B[i]:\n cur = B[i]\n if M[i] == i:\n ans += N//2 - cur\n else:\n ans += M[i] - get(M[i]+1)\n add(M[i]+1, 1)\nprint(ans)\n", "jacc_sim": 0.9850746268656716, "nl": "You are given a string consisting of lowercase English letters. Determine whether it can be turned into a palindrome by repeatedly swapping two adjacent characters. If possible, find the minimum required number of operations. Constraints: 1 \u2264 |S| \u2264 2 \u00d7 10^5. If it cannot be turned into a palindrome, print -1; otherwise, print the minimum required number of operations.", "before_after_length": [442, 451], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03483", "p_user": "u343675824", "n_user": "u343675824", "pos": "from collections import Counter\nimport sys\ns = input()\nN = len(s)\nsc = Counter(s)\nodds = [1 for x in sc if sc[x] % 2 == 1]\nif len(odds) > 1:\n print(-1)\n sys.exit(0)\n\nclass BIT:\n def __init__(self, size):\n self.bit = [0] * (size+1)\n def add(self, index, elem):\n index += 1\n while index < len(self.bit):\n self.bit[index] += elem\n index += index & -index\n def get(self, index):\n index += 1\n ret = 0\n while 0 < index:\n ret += self.bit[index]\n index -= index & -index\n return ret\n\nindices = [-1] * N\ntb = {c: [None] * (sc[c]//2) for c in sc}\nlens = {c: 0 for c in sc}\np = 0\nfor i in range(N):\n c = s[i]\n l = lens[c]\n if 2 * (l+1) <= sc[c]:\n indices[p] = i\n tb[c][l] = p\n lens[c] += 1\n p += 1\n elif 2 * (l+1) == sc[c] + 1:\n indices[N//2] = i\n lens[c] += 1\n else:\n indices[N-1-tb[c][sc[c]-l-1]] = i\n lens[c] += 1\n\nans = 0\nbit = BIT(N)\nfor i in indices:\n bit.add(i, 1)\n ans += bit.get(N-1) - bit.get(i)\nprint(ans)\n", "neg": "from collections import Counter\nimport sys\ns = input()\nN = len(s)\nsc = Counter(s)\nodds = [1 for x in sc if sc[x] % 2 == 1]\nif len(odds) > 1:\n print(-1)\n sys.exit(0)\n\nclass BIT:\n def __init__(self, size):\n self.bit = [0] * (size+1)\n def add(self, index, elem):\n index += 1\n while index < len(self.bit):\n self.bit[index] += elem\n index += index & -index\n def get(self, index):\n index += 1\n ret = 0\n while 0 < index:\n ret += self.bit[index]\n index -= index & -index\n return ret\n\nindices = [-1] * N\ntb = {c: [None] * (sc[c]//2) for c in sc}\nlens = {c: 0 for c in sc}\np = 0\nfor i in range(N):\n c = s[i]\n l = lens[c]\n if 2 * l < sc[c]:\n indices[p] = i\n tb[c][l] = p\n lens[c] += 1\n p += 1\n elif 2 * l == sc[c] + 1:\n indices[N//2] = i\n else:\n indices[N-1-tb[c][sc[c]-l-1]] = i\n lens[c] += 1\n\nans = 0\nbit = BIT(N)\nfor i in indices:\n bit.add(i, 1)\n ans += bit.get(N-1) - bit.get(i)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a string consisting of lowercase English letters. Determine whether it can be turned into a palindrome by repeatedly swapping two adjacent characters. If possible, find the minimum required number of operations. Constraints: 1 \u2264 |S| \u2264 2 \u00d7 10^5. If it cannot be turned into a palindrome, print -1; otherwise, print the minimum required number of operations.", "before_after_length": [436, 420], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u401487574", "n_user": "u401487574", "pos": "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nceil = math.ceil\n\nn = ni()\nA = lma()\nco = collections.Counter(A)\nans = 0\nfor num,cnt in co.items():\n if numcnt:\n ans+=cnt\nprint(ans)\n", "neg": "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nceil = math.ceil\n\nn = ni()\nA = lma()\nco = collections.Counter(A)\nans = 0\nfor num,cnt in co.items():\n if numcnt:\n ans+=cnt\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [166, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u672454878", "n_user": "u672454878", "pos": "n = len(input())\nmp, res = {}, 0\nfor el in list(map(int, input().split())): mp[el] = mp.get(el, 0) + 1\nfor key in mp:\n val = mp[key]\n if key > val: res += val\n elif key < val: res += val - key\nprint(res)", "neg": "n = len(input())\nmp, res = {}, 0\nfor el in list(map(int, input().split())): mp[el] = mp.get(el, 0) + 1\nfor key, val in mp:\n if key > val: res += val\n elif key < val: res += val - key\nprint(res)", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [85, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u475581024", "n_user": "u475581024", "pos": "n = int(input())\narr = list(map(int,input().split()))\ndicta={}\nans=0\nfor i in arr:\n dicta[i] = dicta.get(i,0)+1\n\nfor key,value in dicta.items():\n if key == value:\n continue\n elif key > value:\n ans+=value\n else:\n diff = abs(value-key)\n ans += diff\n\nprint(ans)\n\n\n\n\n", "neg": "n = int(input())\narr = list(map(int,input().split()))\ndicta={}\nans=0\nfor i in arr:\n dicta[i] = dicta.get(i,0)+1\nfor key,value in dicta.items():\n if key == value:\n continue\n else:\n diff = abs(key-value)\n ans+=diff\n\nprint(ans)", "jacc_sim": 0.9473684210526315, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [117, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u408375121", "n_user": "u408375121", "pos": "n = int(input())\na = list(map(int, input().split()))\ndic = {}\nfor i in range(n):\n if a[i] in dic:\n dic[a[i]] += 1\n else:\n dic[a[i]] = 1\nclear = 0\nfor k, v in dic.items():\n if k > v:\n clear += v\n else:\n clear += v-k\nprint(clear)\n", "neg": "n = int(input())\na = list(map(int, input().split()))\ndic = {}\nfor i in range(n):\n if a[i] in dic:\n dic[a[i]] += 1\n else:\n dic[a[i]] = 1\nclear = 0\nfor k, v in dic.items():\n if k >= v:\n clear += v\n else:\n clear += v-k\nprint(clear)", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [109, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u075888178", "n_user": "u075888178", "pos": "hm={}\nn=int(input())\nans=n\narr=[int(i) for i in input().split()]\nfor i in arr:\n hm[i]=hm.get(i,0)+1\nfor i in hm:\n if hm[i]!=i:\n if hm[i]>i:\n ans-=hm[i]-i\n else:\n ans-=hm[i]\nprint(n-ans)", "neg": "hm={}\nn=int(input())\nans=n\narr=[int(i) for i in input().split()]\nfor i in arr:\n hm[i]=hm.get(i,0)+1\nprint(hm)\nfor i in hm:\n if hm[i]!=i:\n if hm[i]>i:\n ans-=hm[i]-i\n else:\n ans-=hm[i]\nprint(n-ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [112, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u133505967", "n_user": "u133505967", "pos": "n=int(input())\narr=list(map(int,input().split()))\nd=dict()\ncount=0 \nfor i in arr:\n d[i]=d.get(i,0)+1 \nfor k,v in d.items():\n if not d[k]==k:\n if d[k]=c[i]:\n count+=kosuu_list[i]-c[i]\n else:\n count+=kosuu_list[i]\nprint(count)", "neg": "n=int(input())\na=list(map(int,input().split()))\nb=sorted(a)#n\nc=[x for x in set(b) if b.count(x) > 0]\nkosuu_list=[]\nkosuu=1\nfor i in range(len(b)-1):\n #kosuu=0\n #print(b[i])\n if b[i]==b[i+1]:\n kosuu+=1\n else:\n kosuu_list.append(kosuu)\n kosuu=1\nkosuu_list.append(b.count(b[-1]))\n\ncount=0\nfor i in range(len(c)):\n if kosuu_list[i]==c[i]:\n count+=0\n elif kosuu_list[i]>=c[i]:\n count+=kosuu_list[i]-c[i]\n else:\n count+=kosuu_list[i]\nprint(count)", "jacc_sim": 0.95, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [260, 252], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u426108351", "n_user": "u426108351", "pos": "import collections\nN = int(input())\na = list(map(int, input().split()))\na = collections.Counter(a)\na = a.most_common()\nans = 0\nfor i in range(len(a)):\n if a[i][0] <= a[i][1]:\n ans += a[i][1] - a[i][0]\n else:\n ans += a[i][1]\n \nprint(ans)", "neg": "import collections\nN = int(input())\na = list(map(int, input().split()))\na = collections.Counter(a)\na = a.most_common()\nans = 0\nfor i in range(len(a)):\n if a[i][0] >= a[i][1]:\n ans += a[i][0] - a[i][1]\n else:\n ans += a[i][1]\n \nprint(ans)", "jacc_sim": 0.9411764705882353, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [110, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u200030766", "n_user": "u200030766", "pos": "N=int(input().strip())\na=list(map(int, input().split()))\nnlis={}\n\nfor i in range(N):\n if (a[i] in nlis)==False:\n nlis[a[i]]=1\n else:\n nlis[a[i]]+=1\nans=0\nfor i in nlis:\n if nlis[i]= a[i]:\n\t\t\tans += j - a[i]\n\t\telse:\n\t\t\tans += j\n\t\tj = 1\nif a[N-1] != a[N-2]:\n\tif a[N-1] != 1:\n\t\tans += 1\nelse:\n\tif j >= a[i]:\n\t\tans += j - a[i]\n\telse:\n\t\tans += j\nprint(ans)", "neg": "N = int(input())\na = list(map(int, input().strip().split()))\na.sort()\n\ni = 0\nj = 1\nans = 0\n\nfor i in range(N-1):\n\tif a[i] == a[i+1]:\n\t\tj += 1\n\telse:\n\t\tif j >= a[i]:\n\t\t\tans += j - a[i]\n\t\telse:\n\t\t\tans += j\nif a[N-1] != A[N-2]:\n\tif a[N-1] != 1:\n\t\tans += 1\nelse:\n\tif j >= a[i]:\n\t\tans += j - a[i]\n\telse:\n\t\tans += j\n", "jacc_sim": 0.9411764705882353, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [183, 174], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u603234915", "n_user": "u603234915", "pos": "N = int(input())\nl = list(map(int, input().split()))\nunique_l = list(set(l))\nunique_l.sort()\nl.sort()\nl.append(0)\nans = 0\nj = 0\ncnt =[]\nfor i in unique_l:\n temp = 0\n while l[j] == i and j < N:\n temp += 1\n j += 1\n cnt.append(temp)\nfor i, j in zip(unique_l, cnt):\n if i == j:\n pass\n elif j > i:\n ans += j - i\n elif j < i:\n ans += j\nprint(ans)", "neg": "N = int(input())\nl = list(map(int, input().split()))\nunique_l = list(set(l))\nl.sort()\nl.append(0)\nans = 0\nj = 0\nfor i in unique_l:\n cnt = 0\n while l[j] == i and j < N:\n cnt += 1\n j += 1\n if cnt == i:\n pass\n elif cnt > i:\n ans += cnt - 1\n elif cnt < i:\n ans += cnt\nprint(ans)", "jacc_sim": 0.9487179487179487, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [162, 129], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u817026203", "n_user": "u817026203", "pos": "from collections import Counter\nn = input()\nxs = [int(c) for c in input().split()]\nc = Counter(xs)\nans = 0\nfor x, cnt in c.items():\n ans += cnt if cnt < x else (cnt - x)\nprint(ans)", "neg": "from collections import Counter\nn = input()\nxs = [int(c) for c in input().split()]\nc = Counter(xs)\nans = 0\nfor x, cnt in c.items():\n ans += cnt if x < cnt else (x - cnt)\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [66, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u318861481", "n_user": "u318861481", "pos": "length = input()\nnums = input().split(\" \")\n\nnumdict = {}\nfor i, num in enumerate(nums):\n\tif num not in numdict:\n\t\tnumdict[str(num)] = 1\n\telse:\n\t\tnumdict[str(num)] += 1\n\nret = 0\nfor k,v in numdict.items():\n\tif int(k) > int(v):\n\t\tret += int(v) \n\telse:\n\t\tret += int(v) - int(k)\n\nprint(ret)", "neg": "length = input()\nnums = input().split(\" \")\n\nnumdict = {}\nfor i, num in enumerate(nums):\n\tif num not in numdict:\n\t\tnumdict[str(num)] = 1\n\telse:\n\t\tnumdict[str(num)] += 1\n\nret = 0\nfor k,v in numdict.items():\n\tif int(k) > int(v):\n\t\tret += int(k) - int(v) \n\telse:\n\t\tret += int(v) - int(k)\n\nprint(ret)", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [126, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u810735437", "n_user": "u810735437", "pos": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport array\nfrom bisect import *\nfrom collections import *\nimport fractions\nimport heapq \nfrom itertools import *\nimport math\nimport random\nimport re\nimport string\n\nN = int(input())\nc = Counter(map(int, input().split()))\nans = 0\nfor k, v in c.items():\n if k < v:\n ans += v - k\n elif k > v:\n ans += v\nprint(ans)\n\n", "neg": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport array\nfrom bisect import *\nfrom collections import *\nimport fractions\nimport heapq \nfrom itertools import *\nimport math\nimport random\nimport re\nimport string\n\nN = int(input())\nc = Counter(map(int, input().split()))\nans = 0\nfor k, v in c.items():\n if k < v:\n ans = v - k\n elif k > v:\n ans += v\nprint(ans)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of positive integers of length N, a = (a_1, a_2, ..., a_N). Your objective is to remove some of the elements in a so that a will be a good sequence. Here, a sequence b is a good sequence when for each element x in b, the value x occurs exactly x times in b. Find the minimum number of elements that need to be removed so that a will be a good sequence.\n\nConstraints:\n1 \u2264 N \u2264 10^5\na_i is an integer.\n1 \u2264 a_i \u2264 10^9\n\nInput:\nInput is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the minimum number of elements that need to be removed so that a will be a good sequence.\n\nSample Input 1:\n4\n3 3 3 3\n\nSample Output 1:\n1\nWe can, for example, remove one occurrence of 3. Then, (3, 3, 3) is a good sequence.\n\nSample Input 2:\n5\n2 4 1 4 2\n\nSample Output 2:\n2\nWe can, for example, remove two occurrences of 4. Then, (2, 1, 2) is a good sequence.\n\nSample Input 3:\n6\n1 2 2 3 3 3\n\nSample Output 3:\n0\n\nSample Input 4:\n1\n1000000000\n\nSample Output 4:\n1\nRemove one occurrence of 10^9. Then, () is a good sequence.\n\nSample Input 5:\n8\n2 7 1 8 2 8 1 8\n\nSample Output 5:\n5", "before_after_length": [132, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03489", "p_user": "u692632484", "n_user": "u692632484", "pos": "N=int(input())\na=[int(i) for i in input().split()]\ndata={}\nfor num in a:\n if num in data:\n data[num]+=1\n else:\n data[num]=1\n\nans=0\nfor key in data.keys():\n if data[key]0:\n if t%2==0:\n if t==0:\n x-=f\n else:\n xl.append(f)\n else:\n yl.append(f)\n f=0\n t+=1\ndef solve(x,l):\n n=len(l)\n k=2*8000+1\n dp=[[-1 for p in range(k)] for q in range(n+1)]\n dp[0][k//2]=0\n for i in range(1,n+1):\n for j in range(k):\n if dp[i-1][j]>=0:\n dp[i][j-l[i-1]]=1\n dp[i][j+l[i-1]]=1\n #print(j)\n if dp[-1][x+k//2]>=0:\n return True\n else:\n return False\nif solve(x,xl) and solve(y,yl):\n print('Yes')\nelse:\n print('No')\n#print(xl,yl)\n", "neg": "s=list(input())\nx,y=map(int,input().split())\nf=0\nt=0\ns.append('T')\nn=len(s)\nxl=[]\nyl=[]\nfor i in range(n):\n if s[i]=='F':\n f+=1\n else:\n if t%2==0:\n xl.append(f)\n else:\n yl.append(f)\n f=0\n t+=1\ndef solve(x,l):\n n=len(l)\n k=2*8000+1\n dp=[[-1 for p in range(k)] for q in range(n+1)]\n dp[0][k//2]=0\n for i in range(1,n+1):\n for j in range(k):\n if dp[i][j]==i:\n dp[i+1][j-l[i]]=i\n if dp[n][x]>0:\n return True\n else:\n return False\nif solve(x,xl) and solve(y,yl):\n print('Yes')\nelse:\n print('No')", "jacc_sim": 0.9827586206896551, "nl": "A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of \"F\" (move forward) and \"T\" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be \"Yes\" if the objective is achievable, and \"No\" if it is not. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [348, 283], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03490", "p_user": "u492026192", "n_user": "u492026192", "pos": "import sys\ns=input()\nx,y=map(int,input().split())\ns=s+'T'\ndp=[[] for i in range(2)]\nt=0\nbuf=0\nfor j in range(len(s)):\n if s[j]=='T':\n break\n\nfor i in range(j,len(s)):\n if s[i]=='F':\n buf+=1\n else:\n if buf!=0:\n dp[t].append(buf)\n buf=0\n t=1-t\n#print(s) \n#print(dp)\nxb=1<<(len(s)+j)\nyb=1<<(len(s))\n\nfor i in range(len(dp[0])):\n xb=(xb<>dp[0][i])\nif xb & 1<<(len(s)+x)==0:\n print('No')\n sys.exit()\nfor i in range(len(dp[1])):\n yb=(yb<>dp[1][i])\n\nif yb & 1<<(len(s)+y)==0:\n print('No')\n sys.exit()\nprint('Yes')", "neg": "import sys\ns=input()\nx,y=map(int,input().split())\ns=s+'T'\ndp=[[] for i in range(2)]\nt=0\nbuf=0\nfor i in range(len(s)):\n if s[i]=='F':\n buf+=1\n else:\n if buf!=0:\n dp[t].append(buf)\n buf=0\n t=1-t\n#print(s) \n#print(dp)\nxb=1<<(len(s))\nyb=1<<(len(s))\n\nfor i in range(len(dp[0])):\n xb=(xb<>dp[0][i])\nif xb & 1<<(len(s)+x)==0:\n #print('No')\n sys.exit()\nfor i in range(len(dp[1])):\n yb=(yb<>dp[1][i])\n\nif yb & 1<<(len(s)+y)==0:\n print('No')\n sys.exit()\nprint('Yes')", "jacc_sim": 0.96, "nl": "A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of \"F\" (move forward) and \"T\" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be \"Yes\" if the objective is achievable, and \"No\" if it is not. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [307, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03490", "p_user": "u177398299", "n_user": "u177398299", "pos": "s = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\n# \u6700\u521d\u306f\u53f3\u306b\u884c\u304f\u3057\u304b\u306a\u3044\ndp_x = {m[0]}\nfor i in m[2::2]:\n new_dp = set()\n for v in dp_x:\n new_dp |= {v + i, v - i}\n dp_x = new_dp\n\ndp_y = {0}\nfor i in m[1::2]:\n new_dp = set()\n for v in dp_y:\n new_dp |= {v + i, v - i}\n dp_y = new_dp\n\nprint('Yes' if x in dp_x and y in dp_y else 'No')", "neg": "s = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\n# \u6700\u521d\u306f\u53f3\u306b\u884c\u304f\u3057\u304b\u306a\u3044\ndp_x = {m[0]}\nfor i in m[2::2]:\n new_dp = set()\n for v in dp_x:\n new_dp += {v + i, v - i}\n dp_x = new_dp\n\ndp_y = {0}\nfor i in m[1::2]:\n new_dp = set()\n for v in dp_y:\n new_dp += {v + i, v - i}\n dp_y = new_dp\n\nprint('Yes' if x in dp_x and y in dp_y else 'No')\n\nprint(dp_x)\nprint(dp_y)", "jacc_sim": 0.9814814814814815, "nl": "A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of \"F\" (move forward) and \"T\" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be \"Yes\" if the objective is achievable, and \"No\" if it is not. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [212, 227], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03490", "p_user": "u218843509", "n_user": "u218843509", "pos": "s = input().split(\"T\")\nx, y = map(int, input().split())\nx -= len(s[0])\ns.pop(0)\n\nlist_yoko = [len(s[i]) for i in range(1, len(s), 2)]\nlist_tate = [len(s[i]) for i in range(0, len(s), 2)]\n\nif list_yoko == []:\n\tlist_yoko = [0]\n\nif list_tate == []:\n\tlist_tate = [0]\n\t\nset_yoko = {list_yoko[0], -list_yoko[0]}\nset_tate = {list_tate[0], -list_tate[0]}\n\nfor i in list_yoko[1:]:\n\tsy = set()\n\tfor j in set_yoko:\n\t\tsy |= {j + i, j - i}\n\tset_yoko = sy\n\nfor i in list_tate[1:]:\n\tst = set()\n\tfor j in set_tate:\n\t\tst |= {j + i, j - i}\n\tset_tate = st\n\nif (x in set_yoko) and (y in set_tate):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "neg": "import sys\n\ns = input().split(\"T\")\nx, y = map(int, input().split())\nx -= len(s[0])\ns.pop(0)\n\nlist_yoko = [len(s[i]) for i in range(1, len(s), 2)]\nlist_tate = [len(s[i]) for i in range(0, len(s), 2)]\n\nset_yoko = {list_yoko[0], -list_yoko[0]}\nset_tate = {list_tate[0], -list_tate[0]}\n\nfor i in list_yoko[1:]:\n\tsy = set()\n\tfor j in set_yoko:\n\t\tsy |= {j + i, j - i}\n\tset_yoko = sy\n\nfor i in list_tate[1:]:\n\tst = set()\n\tfor j in set_tate:\n\t\tst |= {j + i, j - i}\n\tset_tate = st\n\nif (x in sy) and (y in st):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "jacc_sim": 0.9574468085106383, "nl": "A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of \"F\" (move forward) and \"T\" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be \"Yes\" if the objective is achievable, and \"No\" if it is not. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [323, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03490", "p_user": "u268210555", "n_user": "u268210555", "pos": "def f(m, s, g):\n for i in m:\n if s > g:\n s -= i\n else:\n s += i\n return s == g\ns = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\nif (f(sorted(m[::2][1::])[::-1], m[0], x)\n and f(sorted(m[1::2])[::-1], 0, y)):\n print('Yes')\nelse:\n print('No')", "neg": "def f(m, s, g):\n for i in m:\n if s > g:\n s -= i\n else:\n s += i\n return s == g\ns = input()\nx, y = map(int, input().split())\nm = list(map(len, s.split('T')))\nprint(m)\nif (f(sorted(m[::2][1::])[::-1], m[0], x)\n and f(sorted(m[1::2])[::-1], 0, y)):\n print('Yes')\nelse:\n print('No')", "jacc_sim": 1.0, "nl": "A robot starts at the origin on a 2D plane, facing the positive x-axis. It receives a sequence of instructions, consisting of \"F\" (move forward) and \"T\" (turn 90 degrees). The goal is to determine if the robot can reach a specific coordinate (x, y) after executing the instructions. Constraints include the length of the instruction sequence, the integer values of x and y, and their bounds. The input format is the instruction sequence followed by the target coordinates, and the output should be \"Yes\" if the objective is achievable, and \"No\" if it is not. Sample inputs and outputs are provided to illustrate the problem.", "before_after_length": [141, 146], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u742729271", "n_user": "u742729271", "pos": "from collections import Counter \n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ns = len(set(A))\nt = s-K\n\nc = Counter(A)\nnum = list(c.values())\nnum.sort()\n\nprint(sum(num[:t])) if t>0 else print(0)", "neg": "from collections import Counter \n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ns = len(set(A))\nt = s-K\n\nc = Counter(A)\nnum = list(c)\nnum.sort()\nprint(num,t)\nprint(sum(num[:t])) if t>0 else print(0)", "jacc_sim": 0.9714285714285714, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [88, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u760771686", "n_user": "u760771686", "pos": "from collections import defaultdict\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\nD = defaultdict(int)\nfor a in A:\n D[a]+=1\nD = sorted(D.values())\nans = 0\nif len(D)<=K:\n print(ans)\nelse:\n print(sum(D[:len(D)-K]))", "neg": "from collections import defaultdict\nN, K = map(int,input().split())\nA = list(map(int,input().split()))\nD = defaultdict(int)\nfor a in A:\n D[a]+=1\nD = sorted(D.values())\nans = 0\nif len(D)<=K:\n print(ans)\nelse:\n print(sum(D[:K]))", "jacc_sim": 0.972972972972973, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [98, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u640922335", "n_user": "u640922335", "pos": "from collections import Counter\nN,K=map(int,input().split())\nN=list(map(int,input().split()))\nA=Counter(N)\nC=list(A.values())\nC.sort(reverse=True)\nif len(C)<=K:\n print(0)\nelse:\n ans=sum(C[-(len(C)-K):])\n print(ans)", "neg": "from collections import Counter\nN,K=map(int,input().split())\nN=list(map(int,input().split()))\nA=Counter(N)\nC=list(A.values())\nif len(C)<=K:\n print(0)\nelse:\n ans=sum(C[-(len(C)-K):])\n print(ans)", "jacc_sim": 0.9117647058823529, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [97, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u575956662", "n_user": "u575956662", "pos": "n,k = map(int, input().split())\nnum = [0] * 200000\nan = list(map(int, input().split()))\nfor i in range(len(an)):\n num[an[i]] += 1\nAns = 0\nnum2 = [s for s in num if s != 0]\nnum2.sort()\nlength = len(num2)\nif k < length:\n for i in range(length):\n Ans += num2[i]\n length = length - 1\n if length == k:\n break\nprint(Ans)", "neg": "n,k = map(int, input().split())\nnum = [0] * 200000\nan = list(map(int, input().split()))\nfor i in range(len(an)):\n num[an[i]] += 1\nAns = 0\nnum2 = [s for s in num if s != 0]\nnum2.sort()\nlength = len(num2)\nfor i in range(length):\n Ans += num2[i]\n length = length - 1\n if length == k:\n break\nprint(Ans)", "jacc_sim": 0.9736842105263158, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [138, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u193927973", "n_user": "u193927973", "pos": "N, K=map(int, input().split())\nA=list(map(int, input().split()))\nsa=set(A)\nif len(sa)<=K:\n print(0)\nelse:\n # \u66f8\u304d\u63db\u3048\u308b\u8981\u7d20\u306e\u7a2e\u985e\u6570\n sub=len(sa)-K\n # \u5c11\u306a\u3044\u3084\u3064\u3092\u66f8\u304d\u63db\u3048\u305f\u3044\n A.sort()\n A.append(A[-1])\n a=[0]*len(sa)\n j=0\n for i in range(N):\n a[j]+=1\n if A[i]!=A[i+1]:\n j+=1\n \n a.sort()\n print(sum(a[:sub]))", "neg": "N, K=map(int, input().split())\nA=list(map(int, input().split()))\nsa=set(A)\nif len(sa)<=K:\n print(0)\nelse:\n # \u66f8\u304d\u63db\u3048\u308b\u8981\u7d20\u306e\u7a2e\u985e\u6570\n sub=len(sa)-K\n # \u5c11\u306a\u3044\u3084\u3064\u3092\u66f8\u304d\u63db\u3048\u305f\u3044\n A.sort()\n A.append(A[-1])\n a=[0]*len(sa)\n j=0\n for i in range(N):\n a[j]+=1\n if A[i]!=A[i+1]:\n j+=1\n \n a.sort()", "jacc_sim": 0.9827586206896551, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [224, 214], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u593567568", "n_user": "u593567568", "pos": "from collections import Counter\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nC = Counter(A).most_common()\nL = len(C)\n\nif L <= K:\n print(0)\n exit()\n\nans = 0\ncnt = 0\nfor k,v in C:\n cnt += 1\n if K < cnt:\n ans += v\n \nprint(ans)\n", "neg": "from collections import Counter\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nC = Counter(A).most_common()\nL = len(C)\n\nif L <= K:\n print(0)\n exit()\n\nans = 0\ncnt = 0\nfor v in C.values():\n cnt += 1\n if K < cnt:\n ans += v\n \nprint(ans)\n", "jacc_sim": 0.9444444444444444, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [110, 110], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u860002137", "n_user": "u860002137", "pos": "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nli = Counter(A)\nli = list(li.values())\nli.sort()\n\nprint(sum(li[:max(len(li) - K, 0)]))", "neg": "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nli = Counter(A)\nli = list(li.values())\nli.sort()\n\nsum(li[:max(len(li) - K, 0)])", "jacc_sim": 0.9655172413793104, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [74, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u193264896", "n_user": "u193264896", "pos": "import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N, K = map(int, readline().split())\n A = list(map(int, readline().split()))\n count = Counter(A)\n L = len(count)\n if L<=K:\n print(0)\n else:\n B = list(count.values())\n B.sort()\n print(sum(B[:L-K]))\n\n\n\nif __name__ == '__main__':\n main()", "neg": "import sys\nfrom collections import Counter\nreadline = sys.stdin.buffer.readline\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\n\n\ndef main():\n N, K = map(int, readline().split())\n A = list(map(int, readline().split()))\n count = Counter(A)\n L = len(count)\n print(L)\n if L<=K:\n print(0)\n else:\n B = list(count.values())\n B.sort()\n print(sum(B[:L-K]))\n\n\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [159, 165], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u488884575", "n_user": "u488884575", "pos": "n, k = map(int, input().split())\nA = list(map(int, input().split()))\n\nimport collections\nc = collections.Counter(A)\n#print(c)\nif len(c.keys()) > k:\n num = len(c.keys()) - k\n print(sum(sorted(c.values())[:num]))\nelse:\n print(0)\n\n\n", "neg": "n, k = map(int, input().split())\nA = list(map(int, input().split()))\n\nimport collections\nc = collections.Counter(A)\nprint(c)\nif len(c.keys()) > k:\n num = len(c.keys()) - k\n print(sum(sorted(c.values())[:num]))\nelse:\n print(0)", "jacc_sim": 0.9696969696969697, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [95, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u441599836", "n_user": "u441599836", "pos": "import collections\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nt = 0\nans = n\n\nl = collections.Counter(a)\nx = l.most_common(k)\n\nfor i in range(len(x)):\n t += x[i][1]\n\nans -= t\nif ans < 0:\n ans = 0\nprint(ans)\n", "neg": "import collections\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nt = 0\nans = n\n\nl = collections.Counter(a)\nx = l.most_common(k)\n\nfor i in range(k):\n t += x[i][1]\n\nans -= t\nif ans < 0:\n ans = 0\nprint(ans)\n", "jacc_sim": 0.9722222222222222, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [102, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u166340293", "n_user": "u166340293", "pos": "N,K=map(int,input().split())\na=input().split()\n\nlist.sort(a)#\u5c0f\u3055\u3044\u9806\u306b\u4e26\u3073\u66ff\u3048\u308b\n \ncount=1#\u5404\u6570\u5b57\u304c\u4f55\u56de\u51fa\u3066\u304f\u308b\u304b\nsize=0#\u4f55\u7a2e\u985e\u306e\u6570\u5b57\u304c\u51fa\u3066\u304f\u308b\u304b\nb=[]#\u5404\u6570\u5b57\u304c\u4f55\u56de\u51fa\u3066\u304d\u305f\u304b\u3092\u5165\u308c\u308b\u7bb1\nfor p in range (N-1):\n if a[p]==a[p+1]:\n count+=1\n else:\n b.append(count)\n count=1\n size+=1\n\nb.append(count)\nsize+=1\n \nlist.sort(b,reverse=True)#\u5927\u304d\u3044\u9806\u306b\u4e26\u3073\u66ff\u3048\u308b\n\ns=0\nif K=len(C):\n print(0)\nelse:\n s=0\n for i in range(0,len(C)-K):\n s=s+C[i]\n print(s)\n", "neg": "N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\nB=[0]*(N+1)\nfor i in range(0,N):\n B[A[i]]=B[A[i]]+1\nC=[]\nfor i in range(0,N+1):\n if B[i]!=0:\n C.append(B[i])\nprint(C)\nC.sort()\nprint(C)\nif K>=len(C):\n print(0)\nelse:\n s=0\n for i in range(0,len(C)-K):\n s=s+C[i]\n print(s)\n", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [161, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u520276780", "n_user": "u520276780", "pos": "n,k = map(int, input().split( ))\nimport sys\nfrom collections import Counter\ninput = sys.stdin.readline\na = list(map(int,input().split( )))\n\nac = Counter(a)\ncnt = []\nfor ke in ac:\n cnt.append(ac[ke])\ncnt.sort()\nif len(cnt)<=k:\n print(0)\nelse:\n print(sum(cnt[:-k]))", "neg": "n,k = map(int, input().split( ))\nimport sys\nfrom collections import Counter\ninput = sys.stdin.readline\na = list(map(int,input().split( )))\n\nac = Counter(a)\ncnt = []\nfor k in ac:\n cnt.append(ac[k])\ncnt.sort()\nif len(cnt)<=2:\n print(0)\nelse:\n print(sum(cnt[:-2]))", "jacc_sim": 0.9487179487179487, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [108, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u226191225", "n_user": "u487594898", "pos": "import collections\nimport sys\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\ncnt = 0\nif len(c)<= K:\n print(0)\n sys.exit()\n\nfor i in c.most_common(K):\n cnt += i[1]\n\nprint(N-cnt)\n", "neg": "import collections\nimport sys\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nif len(c)<= K:\n print(0)\n sys.exit()\nfor i in range(K):\n cnt += c.most_common()[i][1]\n if cnt >= K:\n\nprint(N-cnt)\n\n", "jacc_sim": 0.9459459459459459, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [98, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u417014669", "n_user": "u417014669", "pos": "n,k=map(int,input().split())\nt= list(map(int,input().split()))\n\nimport sys\nimport collections\nc = collections.Counter(t)\nc=sorted(list(c.values()))\nans=0\ndelete_count=len(c)-k\nif delete_count<=0:\n print(0)\n sys.exit()\nelse:\n for i in range(delete_count):\n if len(c)>k:\n ans+=c[i]\n \nprint(ans)\nsys.exit()\n \n\n", "neg": "n=map(int,input().split())\nt= list(map(int,input().split()))\n\nimport sys\nimport collections\nc = collections.Counter(t)\nc=sorted(list(c.values()))\nans=0\ndelete_count=len(c)-k\nif delete_count<=0:\n print(0)\nelse:\n for i in range(delete_count):\n if len(c)>k:\n ans+=c[i]\n \nprint(ans)\nsys.exit()\n \n\n", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [138, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u350997995", "n_user": "u350997995", "pos": "import collections\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A).most_common()[::-1]\nk = len(c)\nif k<=K:print(0)\nelse: print(sum([e[1] for e in c[:k-K]]))", "neg": "import collections\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = collections.Counter(A).most_common()[::-1]\nprint(c)\nk = len(c)\nif k<=K:print(0)\nelse: print(sum([e[1] for e in c[:k-K]]))", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [86, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u346395915", "n_user": "u346395915", "pos": "from collections import defaultdict\n\nn,k = map(int,input().split())\na_li = list(map(int,input().split()))\n\nd = defaultdict(int)\n\nfor key in a_li:\n d[key] += 1\nd = sorted(d.items(), key=lambda x:x[1])\n \ns = len(d) - k\nans = 0\n\nfor i in range(s):\n ans += d[i][1]\n \nprint(ans)", "neg": "from collections import defaultdict\n\nn,k = map(int,input().split())\na_li = list(map(int,input().split()))\n\nd = defaultdict(int)\n\nfor key in a_li:\n d[key] += 1\nd = sorted(d.items(), key=lambda x:x[1])\n\nif k >= len(d):\n print(0)\n \ns = len(d) - k\nans = 0\n\nfor i in range(s):\n ans += d[i][1]\n \nprint(ans)", "jacc_sim": 0.95, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [118, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u978494963", "n_user": "u978494963", "pos": "from collections import defaultdict\nn,k = map(int,input().split())\nnums = input().split()\ncount_per_nums = defaultdict(int)\nfor n in nums:\n count_per_nums[n] += 1\ncount_per_nums = sorted(count_per_nums.items(), key=lambda x:x[1])\nans = 0\nfor i in range(len(count_per_nums)-k):\n ans += count_per_nums[i][1]\nprint(ans)\n", "neg": "from collections import defaultdict\nn,k = map(int,input().split())\nnums = input().split()\ncount_per_num = defaultdict(int)\nfor n in nums:\n count_per_num[n] += 1\ncount_per_nums = sorted(count_per_nums, key=lambda x:x[1])\nans = 0\nfor i in range(len(count_per_nums)-k):\n ans += count_per_nums[i]\nprint(ans)", "jacc_sim": 0.9459459459459459, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [119, 114], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u864453204", "n_user": "u864453204", "pos": "from collections import Counter\n\nn, k = map(int, input().split())\nA = sorted(Counter(list(map(int, input().split()))).most_common(), key=lambda x:x[1])\ncnt = 0\nif len(A) > k:\n for i in range(len(A)-k):\n cnt += A[i][1]\nprint(cnt)", "neg": "from collections import Counter\n\nn, k = map(int, input().split())\nA = sorted(Counter(list(map(int, input().split()))).most_common(), key=lambda x:x[1])\ncnt = 0\nprint(A)\nif len(A) > k:\n for i in range(len(A)-k):\n cnt += A[i][1]\nprint(cnt)", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [91, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u298297089", "n_user": "u298297089", "pos": "from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ndA = Counter(A)\nif len(dA) - K <= 0:\n print(0)\n exit()\nprint(sum(sorted(dA.values())[:len(dA)-K] ))\n", "neg": "from collections import Counter\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\ndA = Counter(A)\nif len(dA) - K <= 0:\n print(0)\n exit()\nprint(sum(sorted(dA.values())[:len(dA)-K])))", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [83, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u243699903", "n_user": "u243699903", "pos": "n,k=map(int,input().split())\na_list=[int(i) for i in input().split()]\ncount={}\nfor a in a_list:\n count[a]=count.get(a,0)+1\nval=list(count.values())\nval.sort(reverse=True)\nprint(sum(val[k:]))", "neg": "n,k=map(int,input().split())\na_list=[int(i) for i in input().split()]\ncount={}\nfor a in a_list:\n count[a]=count.get(a,0)+1\nval=list(count.values())\nsorted(val,reverse=True)\nprint(sum(val[k:]))", "jacc_sim": 0.9428571428571428, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [84, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u859897687", "n_user": "u859897687", "pos": "n,k=map(int,input().split())\nd=dict()\nfor i in map(int,input().split()):\n if i not in d:\n d[i]=1\n else:\n d[i]+=1\nm=list(d.values())\nm.sort()\na=len(m)-k\nans=0\nfor i in m:\n if a<=0:\n break\n a-=1\n ans+=i\nprint(ans)\n", "neg": "n,k=map(int,input().split())\nd=dict()\nfor i in map(int,input().split()):\n if i not in d:\n d[i]=1\n else:\n d[i]+=1\nm=list(d.keys())\nm.sort()\na=len(d.values())-k\nans=0\nfor i in m:\n if a<=0:\n break\n a-=1\n ans+=1\nprint(ans)", "jacc_sim": 0.972972972972973, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [119, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u983918956", "n_user": "u983918956", "pos": "from collections import Counter\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = Counter(A)\nvalues_list = list(c.values())\nvalues_list.sort()\nans = 0\nfor i in range(len(values_list)-K):\n ans += values_list[i]\nprint(ans)", "neg": "from collections import Counter\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nc = Counter(A)\nvalues_list = list(c.values())\nvalues_list.reverse()\nans = 0\nfor i in range(len(values_list)-K):\n ans += values_list[i]\nprint(ans)", "jacc_sim": 0.9428571428571428, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [89, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u536113865", "n_user": "u536113865", "pos": "from collections import Counter\nimport sys\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nc = Counter(a)\n\nif k>=len(c):\n print(0)\n sys.exit()\nd = c.values()\nprint(sum(sorted(d)[:len(c)-k]))\n", "neg": "from collections import Counter\nimport sys\n\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nc = Counter(a)\n\nif k>=len(c):\n print(0)\n sys.exit()\nd = c.values()\nprint(sorted(d))\nprint(sum(sorted(d)[:len(c)-k]))\n", "jacc_sim": 1.0, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [91, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u200239931", "n_user": "u200239931", "pos": "import math\nimport sys\nfrom collections import Counter\ndef getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nk = int(arr_data[0][1])\n\narr=arr_data[1]\n\n\nlist01=Counter(arr)\n\n#print(list01,len(list01))\n\n#print(list01)\n\ncnt=0\nif len(list01) > k:\n \n for key,val in sorted(list01.items(),key=lambda x: x[1]):\n\n# print(key,val,len(list01))\n\n cnt+=list01.pop(key)\n \n \n if len(list01)==k:\n \n break\n \n\nprint(cnt)\n", "neg": "import math\nimport sys\nfrom collections import Counter\ndef getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\n\n\n\n\narr_data = getinputdata()\n\nn = int(arr_data[0][0])\nk = int(arr_data[0][1])\n\narr=arr_data[1]\n\n\nlist01=Counter(arr)\n\n#print(list01,len(list01))\n\n#print(list01)\n\ncnt=0\nif len(list01) > k:\n \n for key,val in sorted(list01.items(),reverse=True):\n\n print(key,val,len(list01))\n\n cnt+=list01.pop(key)\n \n \n if len(list01)==k:\n \n break\n \n\nprint(cnt)\n", "jacc_sim": 0.9354838709677419, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [339, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u005388620", "n_user": "u005388620", "pos": "lis = list(map(int, input().split()))\nlis2 = input().split()\nn = lis[0]\nk = lis[1]\nd = {}\n\nfor i in range(n):\n if lis2[i] not in d.keys():\n d[lis2[i]] = 1\n else:\n d[lis2[i]] += 1 \n \nif len(list(d.values())) <= k:\n print(0)\nelse:\n a = list(d.values())\n a.sort()\n a.reverse()\n swap = 0\n for i in range(k,len(a)):\n swap += a[i]\n print(swap)", "neg": "lis2 = list(map(int, input().split()))\nn = lis[0]\nk = lis[1]\nd = {}\n\nfor i in range(n):\n if lis2[i] not in d.keys():\n d[lis2[i]] = 1\n else:\n d[lis2[i]] += 1 \n \nif len(b) <= k:\n print(0)\nelse:\n a = d.values()\n a.sort()\n a.reverse()\n swap = 0\n for i in range(k,len(a)):\n swap += a[i]\n print(swap)", "jacc_sim": 0.975, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [175, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u143492911", "n_user": "u143492911", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\nimport collections\ncount=0\ndata=collections.Counter(a)\ndata=sorted(data.items(),key=lambda x:x[1])\nif k k:\n # \u8272\u3092\u5857\u308a\u66ff\u3048\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u6570\u3048\u306a\u3051\u308c\u3070\u2026\n v = list(d.values())\n v.sort()\n ans = sum(v[:len(d.keys()) - k])\nprint(ans)", "neg": "from collections import defaultdict\n\nn, k = map(int, input().split())\nal = [int(i) for i in range(n)]\n\n# dictionary \u3067\u7a2e\u985e\u3068\u6570\u5024\u3092\u3068\u3063\u3066\u304a\u304f\nd = defaultdict(int)\nfor a in al:\n d[a] += 1\n\n# \u7a2e\u985e\u304c\u5c11\u306a\u3044\u3082\u306e\u304b\u3089\u8272\u3092\u5909\u3048\u3066\u3044\u304f\u3068\u6700\u5c0f\u306e\u5909\u3048\u306a\u3051\u308c\u3070\u3044\u3051\u306a\u3044\u30dc\u30fc\u30eb\u306e\u6570\u304c\u308f\u304b\u308b\nans = 0\nif d.keys() > k:\n # \u8272\u3092\u5857\u308a\u66ff\u3048\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u306e\u3067\u6570\u3048\u306a\u3051\u308c\u3070\u2026\n v = d.values()\n v.sort()\n ans = sum(v[:d.keys() - k])\nprint(ans)", "jacc_sim": 0.9615384615384616, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [343, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u280269055", "n_user": "u280269055", "pos": "from collections import Counter\n\nn,k = map(int, input().split())\na = input().split()\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = c.most_common()[-t:]\n for s in serial:\n r += s[1]\n\nprint(r)", "neg": "from collections import Counter\n\nn,k = map(int, input().split())\na = [input() for _ in range(n)]\nc = Counter(a)\nt = len(c) - k\nr = 0\n\nif t > 0:\n serial = list(map(list, c.most_common[-t:]))\n for s in serial:\n r += s[1]\n\nprint(r)", "jacc_sim": 0.9210526315789473, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [86, 98], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03497", "p_user": "u988832865", "n_user": "u988832865", "pos": "N, K = map(int, input().split())\nA = map(int, input().split())\n\ncnt = {}\n\nfor a in A:\n if a not in cnt:\n cnt[a] = 0\n cnt[a] += 1\n\ncnt = sorted(cnt.items(), key=lambda x: x[1])\nans = 0\n\nfor i in range(len(cnt)):\n if len(cnt) - i <= K:\n break\n ans += cnt[i][1]\n\nprint(ans)\n", "neg": "N, K = map(int, input().split())\nA = map(int, input().split())\n\ncnt = {}\n\nfor a in A:\n if a not in cnt:\n cnt[a] = 0\n cnt[a] += 1\n\ncnt = sorted(cnt.items(), key=lambda x: x[1])\nans = 0\ni = 0\n\nfor i in range(len(cnt)):\n if len(cnt) + i <= K:\n break\n ans += cnt[i][1]\n\nprint(ans)\n", "jacc_sim": 0.9743589743589743, "nl": "Takahashi has N balls, each initially labeled with an integer Ai. He wants to rewrite some labels so that there are at most K different integers on the N balls. Find the minimum number of balls he needs to rewrite. Constraints: 1 \u2264 K \u2264 N \u2264 200000, 1 \u2264 Ai \u2264 N. Input format: N K, followed by A1 to AN. Output: Print the minimum number of balls to rewrite. Example: Input 5 2, with labels 1 1 2 2 5, should output 1.", "before_after_length": [126, 130], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03499", "p_user": "u875291233", "n_user": "u875291233", "pos": "n, = map(int, input().split())\np = [-1] + [*map(int, input().split())]\n\nMOD = 10**9+7\ndp = [[] for _ in range(n+1)]\ndep = [0]*(n+1)\nnxt = [0]*(n+1)\n\nfor v in range(n,0,-1):\n _,nxt[p[v]],dep[p[v]] = sorted([nxt[p[v]],dep[p[v]],dep[v]+1])\n\ntot = [0]*(dep[0]+1)\nfor i in range(n+1): tot[dep[i]] += 1\n\ndef merge(p,v):\n if len(dp[p]) < len(dp[v]):\n dp[p],dp[v]=dp[v],dp[p]\n for i in range(-len(dp[v]),0):\n a,b,c = dp[p][i]\n d,e,f = dp[v][i]\n dp[p][i][:] = [a*d%MOD,(b*d+a*e)%MOD,c*f%MOD]\n\nfor v in range(n,-1,-1):\n dp[v].append([1,1,2])\n for i in range(-nxt[v]-1,0):\n dp[v][i][0] = dp[v][i][2] - dp[v][i][1]\n if v: merge(p[v],v)\n\nans = 0\nfor d in dp[0]:\n ans += pow(d[2],MOD-2,MOD)*d[1]%MOD\nprint(ans*pow(2,n+1,MOD)%MOD)", "neg": "n, = map(int, input().split())\np = [-1] + [*map(int, input().split())]\n\nMOD = 10**9+7\ndp = [[] for _ in range(n+1)]\ndep = [0]*(n+1)\nnxt = [0]*(n+1)\n\nfor v in range(n,0,-1):\n _,nxt[p[v]],dep[p[v]] = sorted([nxt[p[v]],dep[p[v]],dep[v]+1])\n\ntot = [0]*(dep[0]+1)\nfor i in range(n+1): tot[dep[i]] += 1\n\ndef merge(p,v):\n if len(dp[p]) < len(dp[v]):\n dp[p],dp[v]=dp[v],dp[p]\n for i in range(-len(dp[v]),0):\n a,b,c = dp[p][i]\n d,e,f = dp[v][i]\n dp[p][i][:] = [a*d%MOD,(b*d+a*e)%MOD,c*f%MOD]\n\nfor v in range(n,-1,-1):\n dp[v].append([1,1,2])\n for i in range(-nxt[v]-1,0):\n dp[v][i][0] = dp[v][i][2] - dp[v][i][1]\n if v: merge(p[v],v)\n\nans = 0\nfor d in dp[0]:\n ans += pow(d[2],MOD-2,MOD)*d[1]%MOD\nprint(ans*pow(2,n+1,MOD)%MOD)\nprint(1)", "jacc_sim": 1.0, "nl": "Snuke has a rooted tree with N+1 vertices, numbered 0 through N, where 0 is the root. Snuke also has an initially empty box and marbles. The play begins by placing one marble on some vertices and follows specific rules for moving and removing marbles. The task is to find the total number of marbles in the box at the end of the play for all possible marble placements, and compute the sum modulo 1,000,000,007. Constraints: 1 \u2264 N < 2 \u00d7 10^5, 0 \u2264 p_i < i. For the test set worth 400 points, N < 2,000. Input format: N followed by p_1, p_2, ..., p_N. Output the answer.", "before_after_length": [427, 432], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u223646582", "n_user": "u223646582", "pos": "from decimal import *\nimport math\nK,A,B=map(int,input().split())\nif A>=K:\n print(1)\nelif A-B>0:\n print(1+math.ceil(Decimal(K-A)/Decimal(A-B))*2)\nelse:\n print(-1)\n", "neg": "import math\nK,A,B=map(int,input().split())\nif A>=K:\n print(1)\nelif A-B>0:\n print(1+math.ceil((K-A)/(A-B))*2)\nelse:\n print(-1)", "jacc_sim": 0.9032258064516129, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [80, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u556589653", "n_user": "u556589653", "pos": "K, A, B = map(int, input().split())\n\nif A >= K:\n print(1)\nelse:\n if A-B <= 0:\n print(-1)\n else:\n S = -(-(K-A)//(A-B))\n print(S*2+1)", "neg": "K,A,B = map(int,input().split())\nif K<=A:\n print(1)\nelse:\n if A<=B:\n print(-1)\n else:\n S = (K-A)//(A-B)\n print(2*S+1)", "jacc_sim": 0.9230769230769231, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [76, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u596421790", "n_user": "u126823513", "pos": "k,a,b = map(int, input().split())\nif k <= a:\n print(1)\nelif b >= a:\n print(-1)\nelse:\n print(((k-a-1)//(a-b)+1)*2+1)\n", "neg": "k, a, b = map(int, input().split())\n\nif a <= b:\n if a < k:\n print(-1)\n else:\n print(1)\nelse:\n if a > k:\n print(1)\n else:\n diff = a - b\n print(2 * ((k - a) // diff) + 1)\n", "jacc_sim": 0.9230769230769231, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [66, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u905715926", "n_user": "u905715926", "pos": "p,a,b = map(int,input().split())\nif(a<=b):\n if(a>=p):\n print(1)\n else:\n \tprint(-1)\nelse:\n p-=a\n up=a-b\n if(p<=0):\n print(1)\n else:\n \tnum=p//up+(p%up!=0)\n \tprint(num*2+1)\n", "neg": "p,a,b = map(int,input().split())\nif(a<=b):\n print(-1)\nelse:\n p-=a\n up=a-b\n if(p<=0):\n print(1)\n else\n \tnum=p//up+(p%up!=0)\n \tprint(num*2+1)\n", "jacc_sim": 0.9655172413793104, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [112, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u566529875", "n_user": "u969190727", "pos": "k,a,b=map(int,input().split())\nif k<=a:\n print(1)\nelif a-b <= 0:\n print(-1)\nelse:\n print(1+(k-a+(a-b)-1)//(a-b)*2)", "neg": "k,a,b=map(int,input().split())\nans=0\nk-=a\nif a-b<=0:\n print(-1)\nelif k<=0:\n print(1)\nelse:\n print((k-1)//(a-b)+2)", "jacc_sim": 0.9230769230769231, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [71, 71], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u690536347", "n_user": "u619819312", "pos": "k,a,b=map(int,input().split())\nprint(1 if k<=a else 1+(k-b-1)//(a-b)*2 if a>b else -1)", "neg": "k,a,b=map(int,input().split());print((-1 if kb:\n print(1+(k-b-1)//(a-b)*2)\nelse:\n print(-1)", "neg": "from math import ceil\nk,a,b=map(int,input().split())\nk-=a\nif k<=0:\n print(1)\nelif a>b:\n print(1+ceil(k/(a-b))*2)\nelse:\n print(-1)", "jacc_sim": 0.9666666666666667, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [69, 72], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u200239931", "n_user": "u200239931", "pos": "def getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\narr_data = getinputdata()\n\nk = int(arr_data[0][0])\na = int(arr_data[0][1])\nb = int(arr_data[0][2])\n\ncnt = a - b\n\nrate = a\n\nif rate >= k:\n \n print(1)\n \nelif cnt==0:\n\n print(-1)\nelse:\n \n if (k-rate) % cnt == 0:\n \n num = (k-rate) // cnt \n \n print(1+ num*2)\n \n else:\n \n num = ((k-rate) // cnt) + 1\n \n if num>=1 :\n \n print(num*2+1)\n \n else:\n \n print(-1)\n", "neg": "def getinputdata():\n\n # \u914d\u5217\u521d\u671f\u5316\n array_result = []\n \n data = input()\n\n array_result.append(data.split(\" \"))\n\n flg = 1\n\n try:\n\n\n while flg:\n\n data = input()\n\n array_temp = []\n\n if(data != \"\"):\n \n array_result.append(data.split(\" \"))\n\n flg = 1\n\n else:\n\n flg = 0\n finally:\n\n\n return array_result\n\narr_data = getinputdata()\n\nk = int(arr_data[0][0])\na = int(arr_data[0][1])\nb = int(arr_data[0][2])\n\ncnt = (k-a) // (a-b)\n\n#print(cnt)\n\nif k > a:\n\n print(-1)\n\nelse:\n if ((k-a) % (a-b) == 0):\n\n print(1 + cnt * 2)\n\n else:\n\n print(1 + (cnt + 1) * 2)\n\n \n", "jacc_sim": 0.9387755102040817, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [341, 288], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u729707098", "n_user": "u729707098", "pos": "k,a,b = (int(i) for i in input().split())\nnum = k-a\nif num<=0: print(1)\nelif a<=b: print(-1)\nelse: print(((num-num%(a-b))//(a-b))*2+2*(min(1,num%(a-b)))+1)", "neg": "k,a,b = (int(i) for i in input().split())\nnum = k-a\nif num<0: print(1)\nelif a= k:\n print(1)\nelse:\n if a <= b:\n print(-1)\n else:\n print(2*math.ceil(Decimal(k-a)/Decimal(a-b))+1)", "neg": "# -*- coding:utf-8 -*-\nimport math\nk,a,b = map(int, input().split())\nif a >= k:\n print(1)\nelse:\n if a <= b:\n print(-1)\n else:\n print((2*math.ceil((k-a)/(a-b)))+1)", "jacc_sim": 0.9117647058823529, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [93, 85], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u344627992", "n_user": "u344627992", "pos": "K, A, B = map(int, input().split())\nif K <= A :\n print ('1')\nelif A <= B :\n print ('-1')\nelse :\n delta = A - B\n ans = (K - A + delta - 1) // delta * 2 + 1\n print ('%ld' % ans)\n", "neg": "K, A, B = map(int, input().split())\nif A <= B :\n print ('-1')\nelif K < B:\n print ('1')\nelse :\n delta = A - B\n ans = (K - A) // delta * 2 + 1\n print ('%ld' % ans)\n", "jacc_sim": 1.0, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [80, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03505", "p_user": "u356832650", "n_user": "u356832650", "pos": "import sys\nimport math\nK, A, B = list(map(int, input().split()))\n \nif (A >= K):\n print('1')\n sys.exit()\nelif (A - B) <= 0:\n print('-1')\n sys.exit()\nd = A-B\np = K-A\nq = int(p//d)\nif ((p % d) != 0):\n q += 1\nprint(str(2*q + 1))", "neg": " import sys\n import math\n K, A, B = list(map(int, input().split()))\n\n if A >= K:\n print(1)\n sys.exit()\n elif (A - B) <= 0:\n print(-1)\n sys.exit()\n d = A - B\n\n p = K-A\n q = math.ceil(p/d)\n if p % d != 0:\n q += 1\n print(int(2*q + 1))", "jacc_sim": 0.9210526315789473, "nl": "ButCoder Inc. hosts a programming competition site called ButCoder. Users are given a skill rating that changes with each contest. A new user starts with a rating of 0 and becomes \"Kaiden\" when their rating reaches K or higher. Hikuhashi's rating increases by A in odd-numbered contests and decreases by B in even-numbered contests. The task is to determine after how many contests Hikuhashi becomes Kaiden for the first time, or if he never becomes Kaiden. Constraints: 1 \u2264 K, A, B \u2264 10^18. Input format: K A B. Output -1 if Hikuhashi never becomes Kaiden, otherwise print the number of contests before he becomes Kaiden for the first time.", "before_after_length": [115, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03506", "p_user": "u619819312", "n_user": "u619819312", "pos": "n,q=map(int,input().split())\nif n==1:\n for i in range(q):\n v,w=map(int,input().split())\n print(min(v,w))\nelse:\n for i in range(q):\n v,w=map(int,input().split())\n while v!=w:\n if v>w:v,w=w,v\n w=(w+n-2)//n\n print(v)\n", "neg": "n,q=map(int,input().split())\nfor i in range(q):\n v,w=map(int,input().split())\n while v!=w:\n if v>w:\n v=(v+n-2)//n\n else:\n w=(w+n-2)//n\n print(v)", "jacc_sim": 0.9333333333333333, "nl": "You are given an integer N. Consider an infinite N-ary tree where each vertex is indexed with a unique positive integer. The root of the tree has the index 1. Process Q queries to find the index of the lowest common ancestor of two given vertices. The lowest common ancestor of two vertices v and w is the farthest vertex from the root that is an ancestor of both v and w. Input is given in the format N Q followed by pairs of vertices v_i and w_i. Output the index of the lowest common ancestor for each query. Constraints: 1 \u2264 N \u2264 10^9, 1 \u2264 Q \u2264 10^5, 1 \u2264 v_i < w_i \u2264 10^9.", "before_after_length": [118, 83], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03506", "p_user": "u499381410", "n_user": "u499381410", "pos": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\n\n\nINF = float('inf')\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef LIRM(n): return [LIM() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\nmod = 1000000007\n\n\nn, q = LI()\n\n\n\n\nfor i, j in LIR(q):\n if n == 1:\n print(min(i, j))\n else:\n while i != j:\n if i < j:\n i, j = j, i\n i = (i - 2) // n + 1\n print(i)\n", "neg": "from collections import defaultdict, deque, Counter\nfrom heapq import heappush, heappop, heapify\nimport math\nimport bisect\nimport random\nfrom itertools import permutations, accumulate, combinations\nimport sys\nimport string\nfrom bisect import bisect_left, bisect_right\nfrom math import factorial, ceil, floor\n\n\nINF = float('inf')\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef I(): return int(sys.stdin.readline())\ndef LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef S(): return sys.stdin.readline().strip()\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef LIRM(n): return [LIM() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef LSR(n): return [LS() for i in range(n)]\ndef SRL(n): return [list(S()) for i in range(n)]\nmod = 1000000007\n\n\nn, q = LI()\n\n\n\n\nfor i, j in LIR(q):\n if n == i:\n print(min(i, j))\n else:\n while i != j:\n if i < j:\n i, j = j, i\n i = (i + 1) // n\n print(i)", "jacc_sim": 0.9873417721518988, "nl": "You are given an integer N. Consider an infinite N-ary tree where each vertex is indexed with a unique positive integer. The root of the tree has the index 1. Process Q queries to find the index of the lowest common ancestor of two given vertices. The lowest common ancestor of two vertices v and w is the farthest vertex from the root that is an ancestor of both v and w. Input is given in the format N Q followed by pairs of vertices v_i and w_i. Output the index of the lowest common ancestor for each query. Constraints: 1 \u2264 N \u2264 10^9, 1 \u2264 Q \u2264 10^5, 1 \u2264 v_i < w_i \u2264 10^9.", "before_after_length": [373, 370], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03507", "p_user": "u574113926", "n_user": "u574113926", "pos": "n, k = map(int, input().split())\nkadan = [list(map(int, input().split())) for _ in range(n)]\n\nleft = 0\nright = 10**18*2\nwhile right -left > 1:\n mid = (right+left)//2\n cnt = 0\n for i in range(n):\n if mid >= kadan[i][0]:\n cnt += (mid - kadan[i][0])//kadan[i][1] + 1\n if k > cnt :\n left = mid \n elif k <= cnt :\n right = mid \nprint(right)\n\n", "neg": "n, k = map(int, input().split())\nkadan = [list(map(int, input().split())) for _ in range(n)]\n\nleft = 0\nright = 10**18\nwhile right -left > 1:\n mid = (right+left)//2\n cnt = 0\n for i in range(n):\n cnt += (mid - kadan[i][0])//kadan[i][1] + 1\n if k > cnt :\n left = mid \n elif k <= cnt :\n right = mid \nprint(right)", "jacc_sim": 1.0, "nl": "In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flower 1, 2, \u2026, N. Also, we will call the position that is p centimeters from the west end of the flowerbed Position p.\n\nYou will plant Flower i (1 \u2264 i \u2264 N) as follows: first, plant one at Position w_i, then plant one every d_i centimeters endlessly toward the east. That is, Flower i will be planted at the positions w_i, w_i + d_i, w_i + 2 d_i, \u2026 Note that more than one flower may be planted at the same position.\n\nFind the position at which the K-th flower from the west is planted. If more than one flower is planted at the same position, they are counted individually.\n\nConstraints:\n- 1 \u2264 N \u2264 10^5\n- 1 \u2264 K \u2264 10^9\n- 1 \u2264 w_i \u2264 10^18\n- 1 \u2264 d_i \u2264 10^9\n- All input values are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN K\nw_1 d_1\n...\nw_N d_N\n\nOutput:\nWhen the K-th flower from the west is planted at Position X, print the value of X. (The westmost flower is counted as the 1-st flower.)\n\nSample Input 1:\n2 6\n20 10\n25 15\n\nSample Output 1:\n50\nTwo kinds of flowers are planted at the following positions:\n- Flower 1: Position 20, 30, 40, 50, 60, \u2026\n- Flower 2: Position 25, 40, 55, 70, 85, \u2026\nThe sixth flower from the west is the Flower 1 planted at Position 50. Note that the two flowers planted at Position 40 are counted individually.\n\nSample Input 2:\n3 9\n10 10\n10 10\n10 10\n\nSample Output 2:\n30\nThree flowers are planted at each of the positions 10, 20, 30, \u2026 Thus, the ninth flower from the west is planted at Position 30.\n\nSample Input 3:\n1 1000000000\n1000000000000000000 1000000000\n\nSample Output 3:\n1999999999000000000", "before_after_length": [153, 136], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03507", "p_user": "u814986259", "n_user": "u814986259", "pos": "import sys\nN, K = map(int, input().split())\ninput = sys.stdin.readline\nwd = [tuple(map(int, input().split())) for i in range(N)]\nwd.sort()\nd = 0\ndp = [0]*N\nl = 0\nr = wd[0][0] + wd[0][1]*K\nwhile(r - l > 1):\n tmp = (l+r)//2\n num = 0\n for w, d in wd:\n if w <= tmp:\n num += ((tmp - w) // d) + 1\n if num >= K:\n r = tmp\n else:\n l = tmp\n\nprint(r)\n", "neg": "import sys\ndef main():\n N, K = map(int, input().split())\n input = sys.stdin.readline\n wd = [tuple(map(int, input().split())) for i in range(N)]\n wd.sort()\n d = 0\n dp = [0]*N\n l = 0\n r = wd[0][0] + wd[0][1]*K\n while(r - l > 1):\n tmp = (l+r)//2\n num = 0\n for w, d in wd:\n if w <= tmp:\n num += ((tmp - w) // d) + 1\n if num >= K:\n r = tmp\n else:\n l = tmp\n print(r)\nmain()\n", "jacc_sim": 0.9574468085106383, "nl": "In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant N kinds of flowers in this empty flowerbed. For convenience, we will call these N kinds of flowers Flower 1, 2, \u2026, N. Also, we will call the position that is p centimeters from the west end of the flowerbed Position p.\n\nYou will plant Flower i (1 \u2264 i \u2264 N) as follows: first, plant one at Position w_i, then plant one every d_i centimeters endlessly toward the east. That is, Flower i will be planted at the positions w_i, w_i + d_i, w_i + 2 d_i, \u2026 Note that more than one flower may be planted at the same position.\n\nFind the position at which the K-th flower from the west is planted. If more than one flower is planted at the same position, they are counted individually.\n\nConstraints:\n- 1 \u2264 N \u2264 10^5\n- 1 \u2264 K \u2264 10^9\n- 1 \u2264 w_i \u2264 10^18\n- 1 \u2264 d_i \u2264 10^9\n- All input values are integers.\n\nInput:\nInput is given from Standard Input in the following format:\nN K\nw_1 d_1\n...\nw_N d_N\n\nOutput:\nWhen the K-th flower from the west is planted at Position X, print the value of X. (The westmost flower is counted as the 1-st flower.)\n\nSample Input 1:\n2 6\n20 10\n25 15\n\nSample Output 1:\n50\nTwo kinds of flowers are planted at the following positions:\n- Flower 1: Position 20, 30, 40, 50, 60, \u2026\n- Flower 2: Position 25, 40, 55, 70, 85, \u2026\nThe sixth flower from the west is the Flower 1 planted at Position 50. Note that the two flowers planted at Position 40 are counted individually.\n\nSample Input 2:\n3 9\n10 10\n10 10\n10 10\n\nSample Output 2:\n30\nThree flowers are planted at each of the positions 10, 20, 30, \u2026 Thus, the ninth flower from the west is planted at Position 30.\n\nSample Input 3:\n1 1000000000\n1000000000000000000 1000000000\n\nSample Output 3:\n1999999999000000000", "before_after_length": [166, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03510", "p_user": "u619819312", "n_user": "u619819312", "pos": "from itertools import accumulate as ac\nn=int(input())\na,b=[],[]\nfor i in range(n):\n x,s=map(int,input().split())\n a.append(x)\n b.append(s)\nr=[0]+list(ac(b))\nl=r[:]\nfor i in range(n):\n r[i]+=-a[i]\n l[i+1]+=-a[i]\nq,d=r[0],0\nfor i in range(1,n+1):\n d=max(l[i]-q,d)\n q=min(q,r[i])\nprint(d)", "neg": "from itertools import accumulate as ac\nn=int(input())\na,b=[],[]\nfor i in range(n):\n x,s=map(int,input().split())\n a.append(x)\n b.append(s)\nr=[0]+list(ac(b))\nl=b[:]\nfor i in range(n):\n r[i]+=-a[i]\n l[i+1]+=-a[i]\nq,d=0,0\nfor i in range(1,n+1):\n d=max(l[i]-q,d)\n q=min(q,r[i-1])\nprint(d)", "jacc_sim": 1.0, "nl": "In a long narrow forest stretching east-west, there are N beasts. Each beast is located at a specific point and can be sold for a certain amount. You need to choose two points, L and R, and throw a net to capture the beasts within that range. The net costs R - L yen, and your profit is the sum of the selling prices of the captured beasts minus the net cost. Find the maximum profit achievable by throwing the net only once.\n\nConstraints:\n- 1 \u2264 N \u2264 2 \u00d7 10^5\n- 1 \u2264 x_1 < x_2 < ... < x_N \u2264 10^15\n- 1 \u2264 s_i \u2264 10^9\n- All input values are integers.\n\nInput:\nThe input consists of N lines, each containing the position and selling price of a beast.\n\nOutput:\nPrint the maximum profit achievable.\n\nSample Input 1:\n5\n10 20\n40 50\n60 30\n70 40\n90 10\n\nSample Output 1:\n90\n\nSample Input 2:\n5\n10 2\n40 5\n60 3\n70 4\n90 1\n\nSample Output 2:\n5\n\nSample Input 3:\n4\n1 100\n3 200\n999999999999999 150\n1000000000000000 150\n\nSample Output 3:\n299", "before_after_length": [161, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03511", "p_user": "u969174266", "n_user": "u969174266", "pos": "def main():\n L = int(input())\n S, T = (input() for _ in [0] * 2)\n\n ans = []\n apnd = ans.append\n a = S\n b = T\n i = 0\n for _ in [0] * 2:\n while 1:\n x = L - (len(b) * i)\n div_, mod_ = divmod(x, len(a))\n if not mod_:\n apnd(a * div_ + b * i)\n break\n i += 1\n i = 0\n a, b = b, a\n print(min(ans))\n\nmain()\n", "neg": "def main():\n L = int(input())\n S, T = (input() for _ in [0] * 2)\n\n ans = []\n apnd = ans.append\n a = S\n b = T\n i = 0\n for _ in [0] * 2:\n while 1:\n x = L - (len(b) * i)\n div_, mod_ = divmod(x, len(a))\n if not mod_:\n apnd(a * div_ + b * i)\n break\n i += 1\n a, b = b, a\n print(min(ans))\n\nmain()\n", "jacc_sim": 1.0, "nl": "You are given two strings, s and t, consisting of lowercase English letters, and an integer L. Generate a string of length L by concatenating one or more copies of s and t. The same string can be used more than once. Find the lexicographically smallest string that can be generated in this way. Constraints: 1 \u2264 L \u2264 2 \u00d7 10^5, 1 \u2264 |s|, |t| \u2264 L, s and t consist of lowercase English letters, and it is always possible to generate a string of length L. Input is given in the format: N, x_1 s_1, x_2 s_2, ..., x_N s_N. Output the lexicographically smallest string among the ones that can be generated.", "before_after_length": [160, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03526", "p_user": "u488401358", "n_user": "u488401358", "pos": "import bisect\n\nN=int(input())\nhito=[]\nfor i in range(N):\n h,p=map(int,input().split())\n hito.append((h+p,h,p))\n\nhito.sort()\ndata=[0]\nfor i in range(0,N):\n gomi,h,p=hito[i]\n for j in range(len(data)-1,-1,-1):\n if j==len(data)-1:\n if h>=data[-1]:\n data.append(data[-1]+p)\n if h>=data[j-1] and j!=0:\n data[j]=min(data[j],data[j-1]+p)\n else:\n if h>=data[j-1] and j!=0:\n data[j]=min(data[j],data[j-1]+p)\n \n\nprint(len(data)-1)\n\n", "neg": "import bisect\n\nN=int(input())\nhito=[]\nfor i in range(N):\n h,p=map(int,input().split())\n hito.append((h+p,h,p))\n\nhito.sort()\nprint(hito)\ndata=[0]\nfor i in range(0,N):\n gomi,h,p=hito[i]\n for j in range(len(data)-1,-1,-1):\n if j==len(data)-1:\n if h>=data[-1]:\n data.append(data[-1]+p)\n if h>=data[j-1] and j!=0:\n data[j]=min(data[j],data[j-1]+p)\n else:\n if h>=data[j-1] and j!=0:\n data[j]=min(data[j],data[j-1]+p)\n \n\nprint(len(data)-1)\n\n", "jacc_sim": 1.0, "nl": "In the final of CODE FESTIVAL, there are N participants with heights and powers. Ringo is hosting a game where participants add zabuton to a stack. Each participant can add zabuton based on their height and power. The goal is to maximize the number of participants who can add zabuton. Constraints: 1 \u2264 N \u2264 5000, 0 \u2264 Hi \u2264 10^9, 1 \u2264 Pi \u2264 10^9. Input format: N, H1 P1, H2 P2, ..., HN PN. Output: Maximum number of participants who can add zabuton.", "before_after_length": [236, 242], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03526", "p_user": "u935558307", "n_user": "u935558307", "pos": "N = int(input())\nHP = [list(map(int,input().split())) for _ in range(N)]\nHP.sort(key=lambda x: x[0]+x[1])\nceil = max(HP,key=lambda x: x[0])[0]\n#dp[i][j] -> i\u4eba\u76ee\u307e\u3067\u898b\u308b\u3002j\u4eba\u7a4d\u3080\u3068\u304d\u306e\u3001\u5ea7\u5e03\u56e3\u306e\u679a\u6570\u306e\u6700\u5c0f\u5024\ndp = [[ceil+1]*(N+1) for _ in range(N+1)]\nans = 0\nfor i in range(N+1):\n dp[i][0] = 0\nfor i in range(1,N+1):\n h,p = HP[i-1]\n for j in range(1,N+1):\n if dp[i-1][j-1]<=h:\n dp[i][j] = min(dp[i-1][j],dp[i-1][j-1]+p)\n ans = max(ans,j)\n else:\n dp[i][j] = dp[i-1][j]\n\nprint(ans)", "neg": "N = int(input())\nHP = [list(map(int,input().split())) for _ in range(N)]\nHP.sort(key=lambda x: x[0]+x[1])\nceil = max(HP,key=lambda x: x[0])[0]\n#dp[i][j] -> i\u4eba\u76ee\u307e\u3067\u898b\u308b\u3002j\u4eba\u7a4d\u3080\u3068\u304d\u306e\u3001\u5ea7\u5e03\u56e3\u306e\u679a\u6570\u306e\u6700\u5c0f\u5024\ndp = [ceil+1]*(N+1)\nans = 0\nfor i in range(N+1):\n dp[i][0] = 0\nfor i in range(N):\n h,p = HP[i]\n for j in range(N,0,-1):\n if dp[j-1]<=h:\n dp[j] = min(dp[j],dp[j-1]+p)\n ans = max(ans,j)\n\nprint(ans)", "jacc_sim": 0.984375, "nl": "In the final of CODE FESTIVAL, there are N participants with heights and powers. Ringo is hosting a game where participants add zabuton to a stack. Each participant can add zabuton based on their height and power. The goal is to maximize the number of participants who can add zabuton. Constraints: 1 \u2264 N \u2264 5000, 0 \u2264 Hi \u2264 10^9, 1 \u2264 Pi \u2264 10^9. Input format: N, H1 P1, H2 P2, ..., HN PN. Output: Maximum number of participants who can add zabuton.", "before_after_length": [319, 270], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03526", "p_user": "u905582793", "n_user": "u905582793", "pos": "n = int(input())\nhp = [list(map(int,input().split())) for i in range(n)]\nhp.sort(key = lambda x:x[0]+x[1])\ndp = [[10**18 for i in range(j+1)] for j in range(n+1)]\ndp[0][0] = 0\nfor i in range(1,n+1):\n h,p = hp[i-1]\n for j in range(i+1):\n if j < i:\n dp[i][j] = dp[i-1][j]\n if j and dp[i-1][j-1] <= h:\n dp[i][j] = min(dp[i][j],dp[i-1][j-1]+p)\nfor i in range(n+1):\n if dp[-1][i] == 10**18:\n print(i-1)\n break\nelse:\n print(n)", "neg": "n = int(input())\nhp = [list(map(int,input().split())) for i in range(n)]\nhp.sort(key = lambda x:x[0]+x[1])\ndp = [[10**18 for i in range(n+1)] for j in range(n+1)]\ndp[0][0] = 0\nfor i in range(1,n+1):\n dp[i] = dp[i-1][:]\n h,p = hp[i-1]\n for j in range(1,i+1):\n if dp[i-1][j-1] <= h:\n dp[i][j] = min(dp[i][j],dp[i-1][j-1]+p)\nfor i in range(n+1):\n if dp[-1][i] == 10**18:\n print(i-1)\n break", "jacc_sim": 0.9512195121951219, "nl": "In the final of CODE FESTIVAL, there are N participants with heights and powers. Ringo is hosting a game where participants add zabuton to a stack. Each participant can add zabuton based on their height and power. The goal is to maximize the number of participants who can add zabuton. Constraints: 1 \u2264 N \u2264 5000, 0 \u2264 Hi \u2264 10^9, 1 \u2264 Pi \u2264 10^9. Input format: N, H1 P1, H2 P2, ..., HN PN. Output: Maximum number of participants who can add zabuton.", "before_after_length": [230, 211], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03526", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n import sys\n input=sys.stdin.readline\n n=int(input())\n hp=sorted([list(map(int,input().split())) for _ in [0]*n],key=lambda x:sum(x))\n dp=[10**10]*(n+1)\n dp[0]=0\n for c,[h,p] in enumerate(hp):\n for k in range(c,-1,-1):\n if dp[k]<=h:\n dp[k+1]=min(dp[k+1],dp[k]+p)\n for i in range(n,-1,-1):\n if dp[i]!=10**10:\n print(i)\n break\nif __name__=='__main__':\n main()", "neg": "def main():\n import sys\n input=sys.stdin.readline\n n = int(input())\n hp = sorted([tuple(map(int, input().split()))\n for _ in [0]*n], key=lambda x: sum(x))\n dp = [10**10]*(n+1)\n dp[0] = 0\n for c, (h, p) in enumerate(hp):\n for k in range(c, -1, -1):\n if dp[k] <= h:\n dp[k+1] = min(dp[k+1], dp[k]+p)\n for i in range(n, -1, -1):\n if dp[i] != 10**10:\n print(i)\n break\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9622641509433962, "nl": "In the final of CODE FESTIVAL, there are N participants with heights and powers. Ringo is hosting a game where participants add zabuton to a stack. Each participant can add zabuton based on their height and power. The goal is to maximize the number of participants who can add zabuton. Constraints: 1 \u2264 N \u2264 5000, 0 \u2264 Hi \u2264 10^9, 1 \u2264 Pi \u2264 10^9. Input format: N, H1 P1, H2 P2, ..., HN PN. Output: Maximum number of participants who can add zabuton.", "before_after_length": [195, 199], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02733", "p_user": "u539692012", "n_user": "u861899479", "pos": "x,*s=open(0)\nh,w,k,*m=map(int,x.split())\nfor b in range(512):\n r=t=j=0;d=[0]*h\n while j'0';x=d[c]>k\n if(t>i&1;i+=1\n else:j+=1\n while b:r+=b&1;b>>=1\n m+=r,\nprint(min(m))", "neg": "x,*s=open(0)\nh,w,k,*m=map(int,x.split())\nfor b in range(512):\n r=t=j=0;d[0]*h\n while w-j:\n i=c=0\n while(h-i):\n d[c]+=s[i][j]>'0'; x=d[c]>k\n if(t>i&1;i+=1\n else:j+=1\n m+=r+bin(b).count('1'),\nprint(min(m))", "jacc_sim": 0.9574468085106383, "nl": "You have a chocolate bar divided into H horizontal rows and W vertical columns of squares. Each square is dark if S_{i,j} is 0, and white if S_{i,j} is 1. The task is to determine the minimum number of cuts needed to ensure that each resulting block has K or fewer white squares. Constraints: 1 \u2264 H \u2264 10, 1 \u2264 W \u2264 1000, 1 \u2264 K \u2264 H \u00d7 W, and S_{i,j} is 0 or 1. The input is given in the format H W K followed by the arrangement of dark and white squares. Output the minimum number of cuts required.", "before_after_length": [180, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02734", "p_user": "u923270446", "n_user": "u227082700", "pos": "mod = 998244353\nn, s = map(int, input().split())\na = list(map(int, input().split()))\ndp = [0] * (s + 1)\nans = 0\nfor i in range(n):\n dp[0] += 1\n for j in range(a[i], s + 1)[::-1]:\n dp[j] += dp[j - a[i]]\n dp[j] %= mod\n ans += dp[-1]\n ans %= mod\nprint(ans)", "neg": "n,s=map(int,input().split())\na=list(map(int,input().split()))\ndp=[0]*6007\nans=0\nfor i in range(n):\n for j in range(s,0,-1):dp[a[i]+j]+=dp[j]\n d[a[i]]+=i\n ans+=d[s]\nprint(ans%998244353)", "jacc_sim": 0.9117647058823529, "nl": "You are given a sequence of N integers A_1, A_2, ..., A_N and a positive integer S. For a pair of integers (L, R) such that 1 \u2264 L \u2264 R \u2264 N, find the number of sequences of integers (x_1, x_2, ..., x_k) such that L \u2264 x_1 < x_2 < ... < x_k \u2264 R and A_{x_1} + A_{x_2} + ... + A_{x_k} = S. Print the sum of these numbers modulo 998244353. The input consists of N, S, and the sequence A_1, A_2, ..., A_N. Output the sum of f(L, R) modulo 998244353.", "before_after_length": [127, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02734", "p_user": "u585482323", "n_user": "u585482323", "pos": "#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 998244353\n\ndef solve():\n n,s = LI()\n a = LI()\n ans = 0\n dp = [0]*(s+1)\n for i in range(n):\n ai = a[i]\n for j in range(s+1)[::-1]:\n nj = j+ai\n if nj > s:\n continue\n dp[nj] += dp[j]\n dp[nj] %= mod\n if ai <= s:\n dp[ai] += i+1\n dp[ai] %= mod\n ans += dp[s]\n ans %= mod\n print(ans)\n return\n\n#Solve\nif __name__ == \"__main__\":\n solve()\n", "neg": "#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 998244353\n\ndef solve():\n n,s = LI()\n a = LI()\n ans = 0\n dp = [0]*(s+1)\n for i in range(n):\n ai = a[i]\n for j in range(s+1)[::-1]:\n nj = j+ai\n if nj > s:\n continue\n dp[nj] += dp[j]\n dp[nj] %= mod\n dp[ai] += i+1\n dp[ai] %= mod\n ans += dp[s]\n ans %= mod\n print(ans)\n return\n\n#Solve\nif __name__ == \"__main__\":\n solve()\n", "jacc_sim": 0.9873417721518988, "nl": "You are given a sequence of N integers A_1, A_2, ..., A_N and a positive integer S. For a pair of integers (L, R) such that 1 \u2264 L \u2264 R \u2264 N, find the number of sequences of integers (x_1, x_2, ..., x_k) such that L \u2264 x_1 < x_2 < ... < x_k \u2264 R and A_{x_1} + A_{x_2} + ... + A_{x_k} = S. Print the sum of these numbers modulo 998244353. The input consists of N, S, and the sequence A_1, A_2, ..., A_N. Output the sum of f(L, R) modulo 998244353.", "before_after_length": [417, 410], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02734", "p_user": "u218843509", "n_user": "u218843509", "pos": "import sys\ndef input():\n\treturn sys.stdin.readline()[:-1]\nn, s = map(int, input().split())\na = list(map(int, input().split()))\nMOD = 998244353\ndp = [0 for _ in range(3001)]\ndp[0] = 1\nans = 0\nfor i in range(n):\n\tfor j in range(s, a[i]-1, -1):\n\t\tdp[j] += dp[j-a[i]]\n\t\tdp[j] %= MOD\n\tdp[a[i]] += i\n\tdp[a[i]] %= MOD\n\tans += dp[s]\n\tans %= MOD\nprint(ans)", "neg": "import sys\ndef input():\n\treturn sys.stdin.readline()[:-1]\nn, s = map(int, input().split())\na = list(map(int, input().split()))\nMOD = 998244353\ndp = [0 for _ in range(s+1)]\ndp[0] = 1\nans = 0\nfor i in range(n):\n\tfor j in range(s, a[i]-1, -1):\n\t\tdp[j] += dp[j-a[i]]\n\t\tdp[j] %= MOD\n\tdp[a[i]] += i\n\tdp[a[i]] %= MOD\n\tans += dp[s]\n\tans %= MOD\nprint(ans)", "jacc_sim": 0.9743589743589743, "nl": "You are given a sequence of N integers A_1, A_2, ..., A_N and a positive integer S. For a pair of integers (L, R) such that 1 \u2264 L \u2264 R \u2264 N, find the number of sequences of integers (x_1, x_2, ..., x_k) such that L \u2264 x_1 < x_2 < ... < x_k \u2264 R and A_{x_1} + A_{x_2} + ... + A_{x_k} = S. Print the sum of these numbers modulo 998244353. The input consists of N, S, and the sequence A_1, A_2, ..., A_N. Output the sum of f(L, R) modulo 998244353.", "before_after_length": [170, 171], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02736", "p_user": "u683134447", "n_user": "u683134447", "pos": "n = int(input())\nal = list(input())\n\nal = [int(a) - 1 for a in al]\nflag = False\nif 1 not in al:\n flag = True\n al = [a // 2 for a in al]\nelse:\n al = [a if a != 2 else 0 for a in al]\n\ncountl = [0]\na = 0\nfor i in range(1, n+1):\n while i % 2 == 0:\n a += 1\n i //= 2\n countl.append(a)\n\ndef comb(a,b):\n if countl[a] - countl[a-b] - countl[b] > 0:\n return 0\n else:\n return 1\n\nans = 0\nfor idx, a in enumerate(al):\n if a == 1:\n ans += comb(n-1, idx)\n\n\nif ans % 2 == 0:\n print(0)\nelse:\n if flag:\n print(2)\n else:\n print(1)\n\n", "neg": "n = int(input())\nal = list(input())\n\nal = [int(a) - 1 for a in al]\nflag = False\nif 1 not in al:\n flag = True\n al = [a // 2 for a in al]\nelse:\n al = [a if a != 2 else 0 for a in al]\n\ncountl = [0]\na = 0\nfor i in range(1, n+1):\n if i % 2 == 0:\n a += 1\n countl.append(a)\n\ndef comb(a,b):\n if countl[a] - countl[a-b] - countl[b] > 0:\n return 0\n else:\n return 1\n\nans = 0\nfor idx, a in enumerate(al):\n if a == 1:\n ans += comb(n-1, idx)\n\nif ans % 2 == 0:\n print(0)\nelse:\n if flag:\n print(2)\n else:\n print(1)\n\n", "jacc_sim": 0.9772727272727273, "nl": "You are given a sequence of N digits, where each element is 1, 2, or 3. Define x_{i,j} as follows: x_{1,j} = a_j (1 \u2264 j \u2264 N), x_{i,j} = | x_{i-1,j} - x_{i-1,j+1} | (2 \u2264 i \u2264 N and 1 \u2264 j \u2264 N+1-i). Find x_{N,1}. Constraints: 2 \u2264 N \u2264 10^6, a_i = 1,2,3 (1 \u2264 i \u2264 N). Input is given as N and a_1a_2...a_N. Output x_{N,1}. Example: Input: 4, 1231; Output: 1.", "before_after_length": [253, 246], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02736", "p_user": "u577170763", "n_user": "u577170763", "pos": "N = int(input())\na = [ int(s) - 1 for s in input()]\n\n# r! \u306b\u542b\u307e\u308c\u308b 2 \u306e\u6570\ntwos = {}\ntwos[0] = 0\nfor r in range(1, N):\n\n count = 0\n tmp = r\n while tmp % 2 == 0:\n tmp //= 2\n count += 1\n \n twos[r] = twos[r-1] + count\n\n\n# {N-1}_C_r \u306e\u5076\u6570\u5947\u6570\u5224\u5b9a\nncr = {}\nfor r in range(N):\n if twos[N-1] - twos[N-1-r] - twos[r] > 0:\n ncr[r] = 0\n else:\n ncr[r] = 1\n\n\n# \u7b54\u3048\u306e\u5224\u5b9a\noe = 0\nfor r, ai in enumerate(a):\n oe = (oe + ncr[r] * ai) % 2\n\nif oe == 1:\n print(1)\nelse:\n if 1 in a:\n print(0)\n else:\n oe2 = 0\n for r, ai in enumerate(a):\n oe2 = (oe2 +ncr[r] * ai // 2 ) %2\n if oe2 == 1:\n print(2)\n else:\n print(0)", "neg": "N = int(input())\na = [ int(s) - 1 for s in input()]\n\n# r! \u306b\u542b\u307e\u308c\u308b 2 \u306e\u6570\ntwos = {}\ntwos[0] = 0\nfor r in range(1, N):\n\n count = 0\n tmp = r\n while tmp % 2 != 0:\n tmp //= 2\n count += 1\n \n twos[r] = twos[r-1] + count\n\n# {N-1}_C_r \u306e\u5076\u6570\u5947\u6570\u5224\u5b9a\nncr = {}\nfor r in range(N):\n if twos[N-1] - twos[N-1-r] - twos[r] > 0:\n ncr[r] = 0\n else:\n ncr[r] = 1\n\n# \u7b54\u3048\u306e\u5224\u5b9a\noe = 0\nfor r, ai in enumerate(a):\n oe = (oe + ncr[r] * ai) % 2\n\nif oe == 1:\n print(1)\nelse:\n if 1 in a:\n print(0)\n else:\n print(2)\n", "jacc_sim": 0.9818181818181818, "nl": "You are given a sequence of N digits, where each element is 1, 2, or 3. Define x_{i,j} as follows: x_{1,j} = a_j (1 \u2264 j \u2264 N), x_{i,j} = | x_{i-1,j} - x_{i-1,j+1} | (2 \u2264 i \u2264 N and 1 \u2264 j \u2264 N+1-i). Find x_{N,1}. Constraints: 2 \u2264 N \u2264 10^6, a_i = 1,2,3 (1 \u2264 i \u2264 N). Input is given as N and a_1a_2...a_N. Output x_{N,1}. Example: Input: 4, 1231; Output: 1.", "before_after_length": [373, 313], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02736", "p_user": "u268554510", "n_user": "u268554510", "pos": "N = int(input())\na = list(map(int,list(input())))\na = list(map(lambda x:x-1,a))\nx = 0\nnum_mod = [0]*N\nfor i in range(1,N):\n tmp = 0\n t = i\n while t%2==0:\n t//=2\n tmp+=1\n num_mod[i] = num_mod[i-1]+tmp\n \nfor i,n in enumerate(a):\n if n%2==0:\n continue\n else:\n if num_mod[N-1]==(num_mod[i]+num_mod[N-1-i]):\n x+=1\n\nif x%2!=0:\n print(1)\n \nelif 1 in a:\n print(0)\n\nelse:\n a = [x//2 for x in a]\n x = 0\n for i,n in enumerate(a):\n if n%2==0:\n continue\n else:\n if num_mod[N-1]==(num_mod[i]+num_mod[N-1-i]):\n x+=1\n if x%2!=0:\n print(2)\n else:\n print(0)", "neg": "N = int(input())\na = list(map(int,list(input())))\na = list(map(lambda x:x-1,a))\nx = 0\nnum_mod = [0]*N\nfor i in range(1,N):\n x = 0\n while i%2==0:\n i//=2\n x+=1\n num_mod[i] = num_mod[i-1]+x\n \n\nfor i,n in enumerate(a):\n if n%2==0:\n continue\n else:\n if num_mod[N-1]==(num_mod[i]+num_mod[N-1-i]):\n x+=1\n\nif x%2!=0:\n print(1)\n \nelif 1 in a:\n print(0)\n\nelse:\n a = [x//2 for x in a]\n x = 0\n for i,n in enumerate(a):\n if n%2==0:\n continue\n else:\n if num_mod[N-1]==(num_mod[i]+num_mod[N-1-i]):\n x+=1\n if x%2!=0:\n print(2)\n else:\n print(0)\n", "jacc_sim": 0.9487179487179487, "nl": "You are given a sequence of N digits, where each element is 1, 2, or 3. Define x_{i,j} as follows: x_{1,j} = a_j (1 \u2264 j \u2264 N), x_{i,j} = | x_{i-1,j} - x_{i-1,j+1} | (2 \u2264 i \u2264 N and 1 \u2264 j \u2264 N+1-i). Find x_{N,1}. Constraints: 2 \u2264 N \u2264 10^6, a_i = 1,2,3 (1 \u2264 i \u2264 N). Input is given as N and a_1a_2...a_N. Output x_{N,1}. Example: Input: 4, 1231; Output: 1.", "before_after_length": [314, 310], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02736", "p_user": "u467736898", "n_user": "u467736898", "pos": "def pascal_parity(N):\n if N & -N == N:\n return [1] * N\n else:\n n = N - (1<<(N.bit_length()-1))\n p = pascal_parity(n)\n return p + [0]*(N-2*n) + p\n\nN = int(input())\nA = list(map(lambda x: int(x)-1, input()))\nP = pascal_parity(N)\nif 1 in A:\n if sum(a*p for a,p in zip(A, P)) % 2 == 1:\n print(1)\n else:\n print(0)\nelse:\n pa = 0\n for p, a in zip(P, A):\n if p==1 and a==2:\n pa += 1\n if pa % 2 == 1:\n print(2)\n else:\n print(0)\n", "neg": "def pascal_parity(N):\n if N & -N == N:\n return [1] * N\n else:\n n = N - (1<<(N.bit_length()-1))\n p = pascal_parity(n)\n return p + [0]*(N-2*n) + p\n\nN = int(input())\nA = list(map(int, input()))\nif 1 in A:\n if sum(A) % 2 == 1:\n print(1)\n else:\n print(0)\nelse:\n P = pascal_parity(N)\n pa = 0\n for p, a in zip(P, A):\n if p==1 and a==2:\n pa += 1\n if pa % 2 == 1:\n print(2)\n else:\n print(0)\n", "jacc_sim": 0.9523809523809523, "nl": "You are given a sequence of N digits, where each element is 1, 2, or 3. Define x_{i,j} as follows: x_{1,j} = a_j (1 \u2264 j \u2264 N), x_{i,j} = | x_{i-1,j} - x_{i-1,j+1} | (2 \u2264 i \u2264 N and 1 \u2264 j \u2264 N+1-i). Find x_{N,1}. Constraints: 2 \u2264 N \u2264 10^6, a_i = 1,2,3 (1 \u2264 i \u2264 N). Input is given as N and a_1a_2...a_N. Output x_{N,1}. Example: Input: 4, 1231; Output: 1.", "before_after_length": [226, 208], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02745", "p_user": "u623819879", "n_user": "u623819879", "pos": "R=range\ndef F(a,b):A=len(a);r=[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)];return r+[1]\ndef Z(X):\n i,j,k=X;A,B,C=map(len,[S[i]for i in X]);q=1e5\n for l in R(A+1):\n if M[i][j][l]:\n for r in R(l,A+B+1):\n if(B x:\n answer = x\nprint(answer)", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nimport itertools\n\nA,B,C = read().decode().split()\n\nA = list(A)\nB = list(B)\nC = list(C)\n\ndef can_match(x,y):\n return x == '?' or y == '?' or x == y\n\nM = 2020\n\ndef solve(A,B,C,LA,LB,LC):\n B_from_A = [False] * (M+M+1)\n for i in range(M+M+1):\n B_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],B))\n C_from_A = [False] * (M+M+1)\n for i in range(M+M+1):\n C_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],C))\n C_from_B = [False] * (M+M+1)\n for i in range(M+M+1):\n C_from_B[i] = all(can_match(x,y) for x,y in zip(B[i:],C))\n for i in range(M):\n if not B_from_A[i]:\n continue\n for j in range(i,i+M):\n if not C_from_A[j]:\n continue\n if not C_from_B[j-i]:\n continue\n yield max(LA, LB+i, LC+j)\n\nanswer = 10 ** 9\nfor A,B,C in itertools.permutations([A,B,C]):\n LA = len(A)\n LB = len(B)\n LC = len(C)\n x = min(solve(A,B,C,LA,LB,LC))\n if answer > x:\n answer = x\nprint(answer)\n\n", "jacc_sim": 0.9393939393939394, "nl": "Snuke has a string \"s\". From this string, Anuke, Bnuke, and Cnuke obtained strings \"a\", \"b\", and \"c\", respectively, as follows: Choose a non-empty (contiguous) substring of \"s\" (possibly \"s\" itself). Then, replace some characters (possibly all or none) in it with '?'s. You are given the strings \"a\", \"b\", and \"c\". Find the minimum possible length of \"s\".\n\nConstraints:\n1 \u2264 |a|, |b|, |c| \u2264 2000\n\"a\", \"b\", and \"c\" consist of lowercase English letters and '?'s.\n\nInput:\nInput is given from Standard Input in the following format:\na\nb\nc\n\nOutput:\nPrint the minimum possible length of \"s\".\n\nSample Input 1:\na?c\nder\ncod\n\nSample Output 1:\n7\nFor example, \"s\" could be \"atcoder\".\n\nSample Input 2:\natcoder\natcoder\n???????\nSample Output 2:\n7\n\"a\", \"b\", and \"c\" may not be distinct.", "before_after_length": [492, 501], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02746", "p_user": "u227082700", "n_user": "u227082700", "pos": "s=lambda t,i:0--t//3**i\nfor _ in range(int(input())):\n a,b,c,d=map(int,input().split());mx=max([i for i in range(30) if s(a,i)==s(c,i)and s(a,i)%3==2and abs(s(b,i)-s(d,i))>=2]+[-1])+1;my=max([i for i in range(30) if s(b,i)==s(d,i)and s(b,i)%3==2and abs(s(a,i)-s(c,i))>=2]+[-1])+1\n if mx==my==0:print(abs(b-d)+abs(a-c));continue\n if mx=2]+[-1])+1;my=max([i for i in range(30) if s(b,i)==s(d,i)and s(b,i)%3==2and abs(s(a,i)-s(c,i))>=2]+[-1])+1\n if mx 0, a 3^K x 3^K grid with the central subgrid being black and the other eight subgrids being fractals of level K-1. Given Q quadruples of integers (a_i, b_i, c_i, d_i), find the minimum integer n such that there exists a sequence of white squares from (a_i, b_i) to (c_i, d_i) where each pair of adjacent squares shares a side. Constraints: 1 \u2264 Q \u2264 10000, 1 \u2264 a_i, b_i, c_i, d_i \u2264 3^30, (a_i, b_i) \u2260 (c_i, d_i), and (a_i, b_i) and (c_i, d_i) are white squares. The input format is Q followed by Q lines of quadruples, and the output should contain Q lines with the distances from (a_i, b_i) to (c_i, d_i).", "before_after_length": [299, 275], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02746", "p_user": "u484902431", "n_user": "u484902431", "pos": "def solve():\n a, b, c, d = map(int, input().split())\n a -= 1\n b -= 1\n c -= 1\n d -= 1\n if a > c:\n a, b, c, d = c, d, a, b\n for k in range(30, -1, -1):\n def check(a, b, c, d):\n if a // 3 ** k == c // 3 ** k and a // 3 ** k % 3 == 1 \\\n and (min(b, d) // 3 ** k % 3 == 0 and max(b, d) // 3 ** k % 3 == 2\n or max(b, d) // 3 ** k - min(b, d) // 3 ** k >= 3):\n print(min(a % 3 ** k + 1 + c % 3 ** k + 1 + abs(b - d),\n 3 ** k - a % 3 ** k + 3 ** k - c % 3 ** k + abs(b - d)))\n return True\n if check(a, b, c, d) or check(b, a, d, c):\n return\n print(abs(a - c) + abs(b - d))\n\nq = int(input())\nfor _ in range(q):\n solve()", "neg": "def solve():\n a, b, c, d = map(int, input().split())\n a -= 1\n b -= 1\n c -= 1\n d -= 1\n if a > c:\n a, b, c, d = c, d, a, b\n for k in range(30, -1, -1):\n if a // 3 ** k == c // 3 ** k and a // 3 ** k % 3 == 1 \\\n and min(b, d) // 3 ** k % 3 == 0 and max(b, d) // 3 ** k % 3 == 2:\n print(min(a % 3 ** k + 1 + c % 3 ** k + 1 + abs(b - d),\n 3 ** k - a % 3 ** k + 3 ** k - c % 3 ** k + abs(b - d)))\n return\n if b // 3 ** k == d // 3 ** k and b // 3 ** k % 3 == 1:\n and min(a, c) // 3 ** k % 3 == 0 and max(a, c) // 3 ** k % 3 == 2:\n print(min(b % 3 ** k + 1 + d % 3 ** k + 1 + abs(a - c),\n 3 ** k - b % 3 ** k + 3 ** k - d % 3 ** k + abs(a - c)))\n return\n print(abs(a - c) + abs(b - d))\n\nq = int(input())\nfor _ in range(q):\n solve()", "jacc_sim": 0.9318181818181818, "nl": "You are given a fractal of level K, defined as a grid with one white square for level 0, and for K > 0, a 3^K x 3^K grid with the central subgrid being black and the other eight subgrids being fractals of level K-1. Given Q quadruples of integers (a_i, b_i, c_i, d_i), find the minimum integer n such that there exists a sequence of white squares from (a_i, b_i) to (c_i, d_i) where each pair of adjacent squares shares a side. Constraints: 1 \u2264 Q \u2264 10000, 1 \u2264 a_i, b_i, c_i, d_i \u2264 3^30, (a_i, b_i) \u2260 (c_i, d_i), and (a_i, b_i) and (c_i, d_i) are white squares. The input format is Q followed by Q lines of quadruples, and the output should contain Q lines with the distances from (a_i, b_i) to (c_i, d_i).", "before_after_length": [302, 351], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02750", "p_user": "u102461423", "n_user": "u102461423", "pos": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom functools import cmp_to_key\nimport itertools\n\nN, T = map(int, readline().split())\nm = map(int, read().split())\nAB0 = []\nAB1 = []\nfor a,b in zip(m,m):\n if a == 0:\n AB0.append(b)\n else:\n AB1.append((a,b))\n\ndef sort_func(ab0, ab1):\n a0, b0 = ab0\n a1, b1 = ab1\n return a1*(1+b0) - a0*(1+b1)\n\nAB0.sort()\nAB1.sort(key=cmp_to_key(sort_func))\nAB0, AB1\n\ndef compute_0():\n INF = T + 1\n dp = [INF] * 40\n dp[0] = 0\n for a,b in AB1:\n for n in range(39, -1, -1):\n if dp[n] > T:\n continue\n x = (dp[n] + 1) * (a + 1) + b\n if x < dp[n+1]:\n dp[n+1] = x\n return dp\n\ndef compute_1():\n return [0] + list(itertools.accumulate(x + 1 for x in AB0))\n\ndp0 = compute_0()\ndp1 = compute_1()\n\nR = len(dp1) - 1\nanswer = 0\nfor i,x in enumerate(dp0):\n if x > T:\n break\n while x + dp1[R] > T:\n R -= 1\n value = i + R\n if answer < value:\n answer = value\n\nprint(answer)", "neg": "import sys\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\nfrom functools import cmp_to_key\nimport itertools\n\nN, T = map(int, readline().split())\nm = map(int, read().split())\nAB0 = []\nAB1 = []\nfor a,b in zip(m,m):\n if a == 0:\n AB0.append(b)\n else:\n AB1.append((a,b))\n\nif N == 1:\n raise\n\ndef sort_func(ab0, ab1):\n a0, b0 = ab0\n a1, b1 = ab1\n return a1*b0 - a0*b1\n\nAB0.sort()\nAB1.sort(key=cmp_to_key(sort_func))\nAB0, AB1\n\ndef compute_0():\n INF = T + 1\n dp = [INF] * 40\n dp[0] = 0\n for a,b in AB1:\n for n in range(39, -1, -1):\n if dp[n] > T:\n continue\n x = (dp[n] + 1) * (a + 1) + b\n if x < dp[n+1]:\n dp[n+1] = x\n return dp\n\ndef compute_1():\n return [0] + list(itertools.accumulate(x + 1 for x in AB0))\n\ndp0 = compute_0()\ndp1 = compute_1()\n\nR = len(dp1) - 1\nanswer = 0\nfor i,x in enumerate(dp0):\n if x > T:\n break\n while x + dp1[R] > T:\n R -= 1\n value = i + R\n if answer < value:\n answer = value\n\nprint(answer)", "jacc_sim": 0.987012987012987, "nl": "Takahashi plans to visit N stores, each with a specific waiting time. He starts at his house at time 0 and can travel between stores in one unit of time. Each store closes at time T + 0.5. Takahashi can shop at a store after waiting in a queue for a specific duration. He cannot shop more than once at the same store. The task is to find the maximum number of times he can shop before time T + 0.5. The input consists of N, T, a_i, and b_i, and the output is the maximum number of times he can shop.", "before_after_length": [452, 456], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02758", "p_user": "u535803878", "n_user": "u535803878", "pos": "\nM = 998244353\n\nn = int(input())\nxs = [0] * n\nds = [0] * n\nfor i in range(n):\n x, d = (int(c) for c in input().split())\n ds[i] = d\n xs[i] = (x,i)\n\nimport sys\nsys.setrecursionlimit(max(1000,n))\n\nxs.sort()\nindex = [x[1] for x in xs]\nxs = [x[0] for x in xs]\nds = [ds[ind] for ind in index]\n\ndef _sub(i):\n # \u6df1\u3055\u512a\u5148\u63a2\u7d22\u3057\u306a\u304c\u3089i\u756a\u76ee\u4ee5\u4e0b\u306e\u7d44\u307f\u5408\u308f\u305b\u3068\u3001\u6b21\u306b\u8abf\u3079\u308b\u3079\u304d\u756a\u53f7\u3092\u8fd4\u3059\n if i==n-1:\n return 2, n\n res = 1\n ind = i+1\n while True:\n if (xs[i]+ds[i] <= xs[ind]):\n break\n o, ind = _sub(ind)\n res *= o\n res %= M\n if ind>=n:\n break\n return res+1, ind\nout = []\ndone = 0\nwhile True:\n o, done = _sub(done)\n out.append(o)\n if done>=n:\n break\nresult = 1\nfor o in out:\n result *= o\n result %= M\nprint(result)", "neg": "\nimport numpy as np\n\nM = 998244353\n\nn = int(input())\nxs = [0] * n\nds = [0] * n\nfor i in range(n):\n x, d = (int(c) for c in input().split())\n ds[i] = d\n xs[i] = x\nxs = np.array(xs)\nds = np.array(ds)\n\nimport sys\nsys.setrecursionlimit(n)\n\nindex = xs.argsort()\nxs = xs[index]\nds = ds[index]\n\ndef _sub(i):\n # \u6df1\u3055\u512a\u5148\u63a2\u7d22\u3057\u306a\u304c\u3089i\u756a\u76ee\u4ee5\u4e0b\u306e\u7d44\u307f\u5408\u308f\u305b\u3068\u3001\u6b21\u306b\u8abf\u3079\u308b\u3079\u304d\u756a\u53f7\u3092\u8fd4\u3059\n if i==n-1:\n return 2, n\n res = 1\n ind = i+1\n while True:\n if (xs[i]+ds[i] <= xs[ind]):\n break\n o, ind = _sub(ind)\n res *= o\n res %= M\n if ind>=n:\n break\n return res+1, ind\nout = []\ndone = 0\nwhile True:\n o, done = _sub(done)\n out.append(o)\n if done>=n:\n break\nresult = 1\nfor o in out:\n result *= o\n result %= M\nprint(result)", "jacc_sim": 0.9130434782608695, "nl": "You are given N robots placed on a number line. Each robot moves a specific distance when activated. Takahashi can activate robots, and if a moving robot touches another, that robot also activates. Find the number of possible sets of remaining robots after Takahashi's operations, modulo 998244353. The input format is N followed by N lines of X and D values for each robot. Output the count of possible sets.", "before_after_length": [416, 410], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02758", "p_user": "u686230543", "n_user": "u686230543", "pos": "import heapq\n\nmod = 998244353\n\nn = int(input())\nrobot = [tuple(map(int, input().split())) for _ in range(n)]\nrobot.sort(reverse=True)\nparent = list(range(n))\n\nroot = []\nfor i in range(n):\n x, d = robot[i]\n while root:\n r = heapq.heappop(root)\n if r[0] < x + d:\n parent[r[1]] = i\n else:\n heapq.heappush(root, r)\n break\n heapq.heappush(root, (x, i))\n \ncount = 1\ndp = [1] * n\nfor i in range(n):\n p = parent[i]\n if p == i:\n count = count * (dp[i] + 1) % mod\n else:\n dp[p] = dp[p] * (dp[i] + 1) % mod\nprint(count)", "neg": "import heapq\n\nmod = 998244353\n\nn = int(input())\nrobot = [tuple(map(int, input().split())) for _ in range(n)]\nrobot.sort(reverse=True)\nparent = list(range(n))\n\nroot = []\nfor i in range(n):\n x, d = robot[i]\n while root:\n r = heapq.heappop(root)\n if r[0] < x + d:\n parent[r[1]] = i\n else:\n heapq.heappush(root, r)\n break\n heapq.heappush(root, (x, i))\n \ncount = 1\ndp = [1] * n\nfor i in range(n):\n p = parent[i]\n if p == i:\n count = count * dp[i] % mod\n else:\n dp[p] = dp[p] * (dp[i] + 1) % mod\nprint(count)", "jacc_sim": 1.0, "nl": "You are given N robots placed on a number line. Each robot moves a specific distance when activated. Takahashi can activate robots, and if a moving robot touches another, that robot also activates. Find the number of possible sets of remaining robots after Takahashi's operations, modulo 998244353. The input format is N followed by N lines of X and D values for each robot. Output the count of possible sets.", "before_after_length": [244, 240], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u626881915", "n_user": "u626881915", "pos": "n,m,k = map(int, input().split())\n\ng = [[] for i in range(n+1)]\nf = [0]*(n+1)\nb = []\nfor i in range(m):\n u, v = map(int, input().split())\n g[u].append(v)\n g[v].append(u)\n f[u] += 1\n f[v] += 1\nfor i in range(k):\n b.append(map(int, input().split()))\ncount = 0\nrenketu_list = [-1]*(n+1)\nrenketu_size = [0]\nstack = []\nfor i in range(1, n+1):\n if renketu_list[i] == -1:\n count += 1\n renketu_list[i] = count\n renketu_size.append(1)\n while len(g[i]) > 0:\n stack.append(g[i].pop())\n while len(stack) > 0:\n v=stack.pop()\n if renketu_list[v] == -1:\n renketu_list[v] = count\n renketu_size[count] += 1\n while len(g[v])>0:\n stack.append(g[v].pop())\n\ns = [0] * (n+1)\nfor i in range(1, n+1):\n s[i] += renketu_size[renketu_list[i]] - f[i] - 1\n \nfor i in range(k):\n u, v = b[i]\n if renketu_list[u] == renketu_list[v]:\n s[u] -= 1\n s[v] -= 1\n\nprint(\" \".join(list(map(str, s[1:]))))\n \n", "neg": "n,m,k = map(int, input().split())\n\ng = [[] for i in range(n+1)]\nf = [0]*(n+1)\nb = []\nfor i in range(m):\n u, v = map(int, input().split())\n g[u].append(v)\n g[v].append(u)\n f[u] += 1\n f[v] += 1\nfor i in range(k):\n b.append(map(int, input().split()))\n\ncount = 0\nrenketu_list = [-1]*(n+1)\nrenketu_size = [0]\nstack = []\nfor i in range(1, n+1):\n if renketu_list[i] == -1:\n count += 1\n renketu_list[i] = count\n renketu_size.append(1)\n while len(g[i]) > 0:\n stack.append(g[i].pop())\n while len(stack) > 0:\n u,v=stack.pop()\n if renketu_list[v] == -1:\n renketu_list[v] = count\n renketu_size[count] += 1\n while len(g[v])>0:\n stack.append(g[v].pop())\n\ns = [0] * (n+1)\nfor i in range(1, n):\n s[i] += renketu_size[renketu_list[i]] + f[i]\n \nfor i in range(k):\n u, v = b[i]\n if renketu_list[u] == renketu_list[v]:\n s[u] -= 1\n s[v] -= 1\n\nprint(\" \".join(list(map(str, s))))\n ", "jacc_sim": 1.0, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [461, 457], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u044220565", "n_user": "u044220565", "pos": "# coding: utf-8\nimport sys\nsysread = sys.stdin.readline\nfrom collections import defaultdict\nsys.setrecursionlimit(10**7)\ndef run():\n\n N,M,K = map(int,sysread().split())\n to = [[] for _ in range(N+1)]\n n_to = [0 for _ in range(N + 1)]\n for i in range(1,M+1):\n a,b = map(int, sysread().split())\n #a,b = AB[i]\n to[a].append(b)\n n_to[a] += 1\n to[b].append(a)\n n_to[b] += 1\n\n stack = defaultdict(lambda:0)\n visited = [False] * (N+1)\n belong = [None] * (N+1)\n\n\n def dfs(n):\n _stack = [n]\n visited[n] = True\n while _stack:\n node = _stack.pop()\n stack[n] += 1\n belong[node] = n\n for next in to[node]:\n if not visited[next]:\n _stack.append(next)\n visited[next] = True\n return None\n\n\n for i in range(1,N+1):\n if not visited[i]:\n dfs(i)\n\n block = [0 for _ in range(N+1)]\n for i in range(1, K+1):\n c,d = map(int, sysread().split())\n #c, d = CD[i]\n if belong[c] == belong[d]:\n block[c] += 1\n block[d] += 1\n\n candidates = [0] * (N+1)\n\n for k in range(1,N+1):\n tr = belong[k]\n candidates[k] = stack[tr] - 1 - n_to[k] - block[k]\n\n print(' '.join(map(str, candidates[1:])))\n\nif __name__ == \"__main__\":\n run()", "neg": "# coding: utf-8\nimport sys\nsysread = sys.stdin.readline\nfrom collections import defaultdict\nsys.setrecursionlimit(10**7)\ndef run():\n N,M,K = map(int,sysread().split())\n to = [[] for _ in range(N+1)]\n n_to = [0 for _ in range(N + 1)]\n for i in range(1,M+1):\n a,b = map(int, sysread().split())\n #a,b = AB[i]\n to[a].append(b)\n n_to[a] += 1\n to[b].append(a)\n n_to[b] += 1\n\n stack = defaultdict(lambda:0)\n visited = [False] * (N+1)\n belong = [None] * (N+1)\n\n\n def dfs(n):\n _stack = [n]\n visited[n] = True\n while _stack:\n node = _stack.pop()\n stack[n] += 1\n belong[node] = n\n for next in to[node]:\n if not visited[next]:\n _stack.append(next)\n visited[next] = True\n return None\n\n\n for i in range(1,N+1):\n dfs(i)\n\n block = [0 for _ in range(N+1)]\n for i in range(1, K+1):\n c,d = map(int, sysread().split())\n #c, d = CD[i]\n if belong[c] == belong[d]:\n block[c] += 1\n block[d] += 1\n\n candidates = [0] * (N+1)\n\n for tree in stack.keys():\n for k in range(1,N+1):\n tr = belong[k]\n candidates[k] = stack[tr] - 1 - n_to[k] - block[k]\n\n print(' '.join(map(str, candidates[1:])))\n\nif __name__ == \"__main__\":\n run()", "jacc_sim": 0.9746835443037974, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [504, 504], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u347600233", "n_user": "u347600233", "pos": "# UnionFind: https://note.nkmk.me/python-union-find/\nn, m, k = map(int, input().split())\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.root = [-1] * (n + 1)\n \n def find(self, x):\n if self.root[x] < 0:\n return x\n else:\n self.root[x] = self.find(self.root[x])\n return self.root[x]\n \n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return False\n if self.root[x] > self.root[y]:\n x, y = y, x\n self.root[x] += self.root[y]\n self.root[y] = x\n \n def is_same(self, x, y):\n return self.find(x) == self.find(y)\n \n def size(self, x):\n return -self.root[self.find(x)]\n \ncandidate = [-1] * (n + 1)\nf_ship = UnionFind(n)\nfor _ in range(m):\n a, b = map(int, input().split())\n candidate[a] -= 1\n candidate[b] -= 1\n f_ship.unite(a, b)\nfor _ in range(k):\n c, d = map(int, input().split())\n if f_ship.is_same(c, d):\n candidate[c] -= 1\n candidate[d] -= 1\nfor i in range(1, n + 1):\n candidate[i] += f_ship.size(i)\nprint(*candidate[1:])", "neg": "# UnionFind: https://note.nkmk.me/python-union-find/\nn, m, k = map(int, input().split())\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n \n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return False\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \n def is_same(self, x, y):\n return self.parents[x] == self.parents[y]\n \n def size(self, x):\n return -self.parents[self.find(x)]\n \ncandidate = [-1] * n\nf_ship = UnionFind(n)\nfor _ in range(m):\n a, b = map(int, input().split())\n candidate[a - 1] -= 1\n candidate[b - 1] -= 1\n f_ship.unite(a - 1, b - 1)\nfor _ in range(k):\n c, d = map(int, input().split())\n if f_ship.is_same(c - 1, d - 1):\n candidate[c - 1] -= 1\n candidate[d - 1] -= 1\nfor i in range(n):\n candidate[i] += f_ship.size(i)\nprint(*candidate)", "jacc_sim": 0.9666666666666667, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [446, 447], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u618101737", "n_user": "u618101737", "pos": "\ndef solve():\n us = [[i] for i in range(0,n+1)]\n for i in range(1, n + 1):\n for fr in fs[i]:\n if not us[i] is us[fr]:\n if len(us[i])>len(us[fr]):\n us[i].extend(us[fr])\n for aa in us[fr]:\n us[aa] = us[i]\n else:\n us[fr].extend(us[i])\n for aa in us[i]:\n us[aa] = us[fr]\n for i in range(1, n + 1):\n frens = len(us[i]) - 1 - len(fs[i])\n for blo in bs[i]:\n if us[i] is us[blo]:\n frens -= 1\n print(frens, end=\" \")\n print()\n return\n\n\n\nn, m, k = [int(s) for s in input().split(\" \")]\n\nfs = [[] for i in range(n + 1)]\nbs = [[] for i in range(n + 1)]\nfor i in range(m):\n a, b = [int(s) for s in input().split(\" \")]\n fs[a].append(b)\n fs[b].append(a)\nfor i in range(k):\n c, d = [int(s) for s in input().split(\" \")]\n bs[c].append(d)\n bs[d].append(c)\n\n\nsolve()\n", "neg": "import time\n\n\n\ndef solve():\n print(\"a\")\n us = [[i] for i in range(0,n+1)]\n for i in range(1, n + 1):\n for fr in fs[i]:\n if not us[i] is us[fr]:\n if len(us[i])>len(us[fr]):\n us[i].extend(us[fr])\n for aa in us[fr]:\n us[aa] = us[i]\n else:\n us[fr].extend(us[i])\n for aa in us[i]:\n us[aa] = us[fr]\n for i in range(1, n + 1):\n frens = len(us[i]) - 1 - len(fs[i])\n for blo in bs[i]:\n if blo in us[i]:\n frens -= 1\n print(frens, end=\" \")\n print()\n return\n\n\nn, m, k = [int(s) for s in input().split(\" \")]\n\nfs = [[] for i in range(n + 1)]\nbs = [[] for i in range(n + 1)]\n\nfor i in range(m):\n a, b = [int(s) for s in input().split(\" \")]\n fs[a].append(b)\n fs[b].append(a)\nfor i in range(k):\n c, d = [int(s) for s in input().split(\" \")]\n bs[c].append(d)\n bs[d].append(c)\nsolve()\n", "jacc_sim": 0.96, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [379, 385], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u077141270", "n_user": "u077141270", "pos": "import sys\ninput = sys.stdin.readline\n\nclass UnionFind:\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * (n+1)\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\nN, M, K = (int(i) for i in input().split())\n\n#graph = np.zeros((N+1, N+1))\n#graph2 = [[0] * (N+1) for i in range(N+1)]\nuf = UnionFind(N)\nfblist = [0] * (N+1)\n\nfor i in range(M):\n A, B = (int(i) for i in input().split())\n uf.union(A, B)\n fblist[A] += 1\n fblist[B] += 1\n \nfor j in range(K):\n A, B = (int(i) for i in input().split())\n if uf.same(A, B):\n fblist[A] += 1\n fblist[B] += 1\n\nfor i in range(1, N+1):\n print(uf.size(i) - fblist[i] - 1, end=\" \")\n\nprint()\n", "neg": "import sys\ninput = sys.stdin.readline\nimport numpy as np\n\nclass UnionFind:\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * (n+1)\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\nN, M, K = (int(i) for i in input().split())\n\n#graph = np.zeros((N+1, N+1))\n#graph2 = [[0] * (N+1) for i in range(N+1)]\nuf = UnionFind(N)\nfblist = [0] * (N+1)\n\nfor i in range(M):\n A, B = (int(i) for i in input().split())\n uf.union(A, B)\n fblist[A] += 1\n fblist[B] += 1\n \nfor j in range(K):\n A, B = (int(i) for i in input().split())\n fblist[A] += 1\n fblist[B] += 1\n\nfor i in range(1, N+1):\n print(uf.size(i) - fblist[i] - 1, end=\" \")\n\nprint()\n", "jacc_sim": 0.9672131147540983, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [494, 487], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u747602774", "n_user": "u747602774", "pos": "import sys\nsys.setrecursionlimit(10**6)\n\nN,M,K = map(int,input().split())\n \npar = [i for i in range(N+1)]\n \n# \u6728\u306e\u6839\u3092\u6c42\u3081\u308b\ndef root(x):\n if par[x] == x:\n return x\n else:\n par[x] = root(par[x])\n return par[x]\n \n# x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u5426\u304b\ndef bool_same(x,y):\n return root(x) == root(y)\n \n# x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u3092\u4f75\u5408\ndef unite(x,y):\n x = root(x)\n y = root(y)\n if x != y:\n par[x] = y\n \nAB = [list(map(int,input().split())) for i in range(M)]\nCD = [list(map(int,input().split())) for i in range(K)]\n \nfor a,b in AB:\n unite(a,b)\n \nfor i in range(N+1):\n root(i)\n \nmember = [0 for i in range(N+1)]\n \nfor p in par:\n member[p] += 1\n \nans = [member[par[i]]-1 for i in range(N+1)]\n \nfor a,b in AB:\n if bool_same(a,b):\n ans[a] -= 1\n ans[b] -= 1\nfor c,d in CD:\n if bool_same(c,d):\n ans[c] -= 1\n ans[d] -= 1\nprint(' '.join(map(str,ans[1:])))\n ", "neg": "import sys\nsys.getrecursionlimit(10**6)\n\nN,M,K = map(int,input().split())\n\npar = [i for i in range(N+1)]\n\n# \u6728\u306e\u6839\u3092\u6c42\u3081\u308b\ndef root(x):\n if par[x] == x:\n return x\n else:\n par[x] = root(par[x])\n return par[x]\n\n# x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u5426\u304b\ndef bool_same(x,y):\n return root(x) == root(y)\n\n# x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u3092\u4f75\u5408\ndef unite(x,y):\n x = root(x)\n y = root(y)\n if x != y:\n par[x] = y\n\nAB = [list(map(int,input().split())) for i in range(M)]\nCD = [list(map(int,input().split())) for i in range(K)]\n\nfor i in range(M):\n a,b = AB[i]\n unite(a,b)\n\nmember = [0 for i in range(N+1)]\n\nfor i in range(1,N+1):\n member[root(i)] += 1\n\nans = [member[par[i]]-1 for i in range(N+1)]\n\nfor i in range(M):\n a,b = AB[i]\n if bool_same(a,b):\n ans[a] -= 1\n ans[b] -= 1\n\nfor i in range(K):\n c,d = CD[i]\n if bool_same(c,d):\n ans[c] -= 1\n ans[d] -= 1\n\nprint(*ans[1:])\n", "jacc_sim": 0.92, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [485, 489], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u590825760", "n_user": "u590825760", "pos": "class UnionFind():\n def __init__(self,n):\n self.n = n\n self.parents = [-1] * (n+1)\n\n def FindRoot(self,x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.FindRoot(self.parents[x])\n return self.parents[x]\n \n def Union(self,x,y):\n x = self.FindRoot(x)\n y = self.FindRoot(y)\n\n if x == y:\n return\n \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def isSame(self,x,y):\n return self.FindRoot(x) == self.FindRoot(y)\n\n def Size(self,x):\n return -self.parents[self.FindRoot(x)]\n\nn,m,k = [int(x) for x in input().split()]\nobj = UnionFind(n)\ncnt = [0]*(n+1)\nfor _ in range(m):\n a,b = [int(x) for x in input().split()]\n obj.Union(a,b)\n cnt[a] += 1\n cnt[b] += 1\nfor _ in range(k):\n c,d = [int(x) for x in input().split()]\n if obj.isSame(c,d):\n cnt[c] += 1\n cnt[d] += 1\nans = 0\nfor i in range(1,n+1):\n ans = obj.Size(i)-1-cnt[i]\n print(ans,end=\" \")", "neg": "class UnionFind():\n def __init__(self,n):\n self.n = n\n self.parents = [-1] * (n+1)\n\n def FindRoot(self,x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.FindRoot(self.parents[x])\n return self.parents[x]\n \n def Union(self,x,y):\n x = self.FindRoot(x)\n y = self.FindRoot(y)\n\n if x == y:\n return\n \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def isSame(self,x,y):\n return self.FindRoot(x) == self.FindRoot(y)\n\n def Size(self,x):\n return -self.parents[self.FindRoot(x)]\n\nn,m,k = [int(x) for x in input().split()]\nobj = UnionFind(n)\ncnt = [0]*(n+1)\nfor _ in range(m):\n a,b = [int(x) for x in input().split()]\n obj.Union(a,b)\n cnt[a] += 1\n cnt[b] += 1\nfor _ in range(k):\n c,d = [int(x) for x in input().split()]\n cnt[c] += 1\n cnt[d] += 1\nans = 0\nfor i in range(1,n+1):\n ans = obj.Size(i)-1-cnt[i]\n print(ans,end=\" \")", "jacc_sim": 1.0, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [441, 429], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u780475861", "n_user": "u780475861", "pos": "# https://atcoder.jp/contests/abc157/submissions/10475457\n\nimport sys\nreadline = sys.stdin.readline\n\nN, M, K = map(int, readline().split())\n\nF = [[] for _ in range(N + 1)]\nfor _ in range(M):\n a, b = map(int, readline().split())\n F[a].append(b)\n F[b].append(a)\n\nB = [[] for _ in range(N + 1)]\nfor _ in range(K):\n c, d = map(int, readline().split())\n B[c].append(d)\n B[d].append(c)\n\nseen = [-1] * (N + 1)\ngroup = 0\n\n\ndef dfs(graph, s):\n stack = [s]\n seen[s] = group\n n_connection = 1\n\n while stack:\n u = stack.pop()\n for v in graph[u]:\n if seen[v] == -1:\n n_connection += 1\n seen[v] = group\n stack.append(v)\n\n return n_connection\n\n\nunion = {}\nfor i in range(1, N + 1):\n if seen[i] == -1:\n n = dfs(F, i)\n union[group] = n\n group += 1\n\nans = []\nfor i in range(1, N + 1):\n tmp = 0\n tmp += union[seen[i]] - 1\n tmp -= len(F[i])\n for j in B[i]:\n if seen[j] == seen[i]:\n tmp -= 1\n ans.append(tmp)\n\nprint(\" \".join(map(str, ans)))\n", "neg": "# https://atcoder.jp/contests/abc157/submissions/10475457\n\nimport sys\nreadline = sys.stdin.readine\n\nN, M, K = map(int, readline().split())\n\nF = [[] for _ in range(N + 1)]\nfor _ in range(M):\n a, b = map(int, readline().split())\n F[a].append(b)\n F[b].append(a)\n\nB = [[] for _ in range(N + 1)]\nfor _ in range(K):\n c, d = map(int, readline().split())\n B[c].append(d)\n B[d].append(c)\n\nseen = [-1] * (N + 1)\ngroup = 0\n\n\ndef dfs(graph, s):\n stack = [s]\n seen[s] = group\n n_connection = 1\n\n while stack:\n u = stack.pop()\n for v in graph[u]:\n if seen[v] == -1:\n n_connection += 1\n seen[v] = group\n stack.append(v)\n\n return n_connection\n\n\nunion = {}\nfor i in range(1, N + 1):\n if seen[i] == -1:\n n = dfs(F, i)\n union[group] = n\n group += 1\n\nans = []\nfor i in range(1, N + 1):\n tmp = 0\n tmp += union[seen[i]] - 1\n tmp -= len(F[i])\n for j in B[i]:\n if seen[j] == seen[i]:\n tmp -= 1\n ans.append(tmp)\n\nprint(\" \".join(map(str, ans)))\n", "jacc_sim": 0.9859154929577465, "nl": "You are given an SNS with N users, some friendships (M) and blockships (K). A user 'a' is a friend candidate for user 'b' if four conditions are met. For each user i, find the number of friend candidates. Constraints: 2 \u2264 N \u2264 10^5, 0 \u2264 M, K \u2264 10^5, 1 \u2264 A_i, B_i, C_i, D_i \u2264 N. Input format: N M K, followed by A_i B_i and C_i D_i. Output the number of friend candidates for each user.", "before_after_length": [421, 421], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02762", "p_user": "u619819312", "n_user": "u619819312", "pos": "n,m,k=map(int,input().split())\nw=[i for i in range(n+1)]\ns=[1]*(n+1)\ng=[list(map(int,input().split()))for i in range(m)]\ndef root(x):\n if w[x]==x:\n return x\n x=w[x]\n return root(w[x])\ndef unite(x,y):\n x=root(x)\n y=root(y)\n if x!=y:\n if s[x] i:\n\t\t\tres += a * (n//k + 1)\n\t\telse:\n\t\t\tres += a * (n//k)\n\tprint( (n-1) - ((x+res)//m - x//m) )\n", "jacc_sim": 0.9210526315789473, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [135, 161], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u520276780", "n_user": "u520276780", "pos": "#>=\u306fm\u306e\u500d\u6570\u3092\u307e\u305f\u3044\u3060\u56de\u6570\nk,q = map(int, input().split( ))\nd = list(map(int, input().split( )))\nfrom collections import Counter\nfor i in range(q):\n n,x,m=map(int, input().split( ))\n dx = [di%m for di in d]\n ##\u3042\u307e\u308a0\u3092\u3042\u307e\u308am\u3067\u51e6\u7406\n for i in range(k):\n if dx[i]==0:\n dx[i]=m\n sm = x%m+sum(dx)*((n-1)//k)+sum(dx[:(n-1)%k])\n print(n-1 -sm//m)\n", "neg": "#>=\u306fm\u306e\u500d\u6570\u3092\u307e\u305f\u3044\u3060\u56de\u6570\nk,q = map(int, input().split( ))\nd = list(map(int, input().split( )))\nfrom collections import Counter\nfor i in range(q):\n n,x,m=map(int, input().split( ))\n dx = [di%m for di in d]\n ##\u3042\u307e\u308a0\u3092\u3042\u307e\u308am\u3067\u51e6\u7406\n for i in range(k):\n if dx[i]==0:\n dx[i]=m\n sm = x%m+sum(dx)*(n//k)+sum(dx[:n%k])\n print(n-1 -sm//m)\n", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [216, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u672220554", "n_user": "u672220554", "pos": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n K, Q = map(int, input().split())\n D = list(map(int, input().split()))\n\n for _ in range(Q):\n n, x, m = map(int, input().split())\n md = [D[i] % m for i in range(K)]\n smda = 0\n mda0 = 0\n for i in range((n - 1) % K):\n if md[i] == 0:\n mda0 += 1\n smda += md[i]\n smd = smda\n md0 = mda0\n for i in range((n - 1) % K, K):\n if md[i] == 0:\n md0 += 1\n smd += md[i]\n roop = (n - 1) // K\n res = n - 1 - (x % m + smd * roop + smda) // m - md0 * roop - mda0\n print(res)\n\n\nmain()\n", "neg": "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n K, Q = map(int, input().split())\n D = list(map(int, input().split()))\n\n for _ in range(Q):\n n, x, m = map(int, input().split())\n md = [D[i] % m for i in range(K)]\n smda = 0\n mda0 = 0\n for i in range((n - 1) % K):\n if md[i] == 0:\n mda0 += 1\n smda += md[i]\n smd = smda\n md0 = mda0\n for i in range((n - 1) % K, K):\n if md[i] == 0:\n md0 += 1\n smd += md[i]\n roop = (n - 1) // K\n res = n - 1 - (x % m + smd * roop + sum(md)) // m - md0 * roop - mda0\n print(res)\n\n\nmain()\n", "jacc_sim": 0.9787234042553191, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [262, 262], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u484902431", "n_user": "u484902431", "pos": "k, q = map(int, input().split())\nd = list(map(int, input().split()))\n\ndef solve():\n n, x, m = map(int, input().split())\n ans = 0\n rn = (n - 1) % k\n f = x % m\n for i in range(k):\n if d[i] % m == 0:\n continue\n if i < rn:\n c = (n - 1) // k + 1\n else:\n c = (n - 1) // k\n ans += c\n f += c * (d[i] % m)\n ans -= f // m\n print(ans)\n\nfor _ in range(q):\n solve()", "neg": "k, q = map(int, input().split())\nd = list(map(int, input().split()))\n\ndef solve():\n n, x, m = map(int, input().split())\n ans = 0\n rn = (n - 1) % k\n f = x % m\n for i in range(k):\n if d[i] % m == 0:\n continue\n if i < rn:\n c = (n - 1) // k + 1\n else:\n c = (n - 1) // k\n print(i, c)\n ans += c\n f += c * (d[i] % m)\n print(ans, f)\n ans -= f // m\n print(ans)\n\nfor _ in range(q):\n solve()", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [174, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u619819312", "n_user": "u619819312", "pos": "k,q=map(int,input().split())\nd=list(map(int,input().split()))\nfor i in range(q):\n n,x,m=map(int,input().split())\n l=[i%m if i%m!=0 else m for i in d]\n print(n-1-(x+((n-1)//k)*sum(l)+sum(l[:(n-1)%k]))//m+x//m)\n", "neg": "k,q=map(int,input().split())\nd=list(map(int,input().split()))\nfor i in range(q):\n n,x,m=map(int,input().split())\n l=[i%m if i%m!=0 else m for i in d]\n print(n-((n//k)*sum(l)+sum(l[:n%k-1]))//m)", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [114, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u671455949", "n_user": "u671455949", "pos": "import numpy as np\n\nk, q = map(int, input().split())\nd = np.array(list(map(int, input().split())))\n\nfor i in range(q):\n n, x, m = map(int, input().split())\n mod_d = d % m\n modsum_d = mod_d.cumsum()\n _q, _m = divmod(n - 1, k)\n \n ans = modsum_d[k - 1] * _q\n if _m > 0:\n ans += modsum_d[_m - 1]\n ans = n - 1 - (ans + x % m) // m - np.count_nonzero(mod_d == 0) * _q\n if _m > 0:\n ans -= np.count_nonzero(mod_d[0 : _m] == 0)\n print(ans)", "neg": "import numpy as np\n\nk, q = map(int, input().split())\nd = np.array(list(map(int, input().split())))\n\nfor i in range(q):\n n, x, m = map(int, input().split())\n mod_d = d % m\n modsum_d = mod_d.cumsum()\n _q, _m = divmod(n - 1, k)\n \n ans = modsum_d[k - 1] * _q\n if _m > 0:\n ans += modsum_d[_m - 1]\n ans = n - (ans + x % m) // m - np.count_nonzero(mod_d == 0) * _q\n if _m > 0:\n ans -= np.count_nonzero(mod_d[0 : _m] == 0)\n print(ans)", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [208, 206], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u456353530", "n_user": "u456353530", "pos": "k, q = list(map(int, input().split()))\nd = list(map(int, input().split()))\nnxm = [list(map(int, input().split())) for _ in range(q)]\n\nD = [[0] * 2 for _ in range(k)]\nfor i in range(q):\n n, x, m = nxm[i]\n D[-1] = [0, 0]\n D[0][0] = d[0] % m\n D[0][1] = 0\n\n for j in range(k):\n D[j][0] = (D[j - 1][0] + d[j] % m)\n D[j][1] = D[j - 1][1]\n if D[j - 1][0] != D[j][0]:\n D[j][1] += 1\n\n N, M = divmod(n - 1, k)\n\n ans = N * D[-1][1]\n t = N * D[-1][0] + (x % m)\n ans -= t // m\n t = t % m\n if M != 0:\n ans += D[M - 1][1]\n t += D[M - 1][0]\n ans -= t // m\n \n print(ans)\n \n\n", "neg": "k, q = list(map(int, input().split()))\nd = list(map(int, input().split()))\nnxm = [list(map(int, input().split())) for _ in range(q)]\n\nfor i in range(q):\n n, x, m = nxm[i]\n D = [[0] * 2 for _ in range(k)]\n D[0][0] = d[0] % m\n\n for j in range(k):\n D[j] = [(D[j - 1][0] + d[j] % m), D[j - 1][1]]\n if D[j - 1][0] != D[j][0]:\n D[j][1] += 1\n\n N, M = divmod(n - 1, k)\n ans = N * D[-1][1]\n t = N * D[-1][0] + x\n ans -= t // m\n t = t % m\n if M != 0:\n ans += D[M - 1][1]\n t += D[M - 1][0]\n ans -= t // m\n \n print(ans)\n \n\n", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [316, 280], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u918935103", "n_user": "u918935103", "pos": "k,q = map(int,input().split())\nd = list(map(int,input().split()))\nal = []\nfor i in range(q):\n n,x,m = map(int,input().split())\n pd = []\n count = 0\n for j in range(k):\n pd.append(d[j]%m)\n if d[j]%m == 0:\n count += 1\n a = sum(pd)\n ans = x%m\n ans += a*((n-1)//k)\n #print(pd)\n c = 0\n for j in range((n-1)%k):\n ans += pd[j]\n if pd[j] == 0:\n c += 1\n al.append(n-1-(ans//m)-count*((n-1)//k)-c)\nfor i in range(q):\n print(al[i])", "neg": "k,q = map(int,input().split())\nd = list(map(int,input().split()))\nal = []\nfor i in range(q):\n n,x,m = map(int,input().split())\n pd = []\n count = 0\n for j in range(k):\n pd.append(d[j]%m)\n if d[j]%m == 0:\n count += 1\n a = sum(pd)\n ans = x\n ans += a*((n-1)//k)\n #print(pd)\n c = 0\n for j in range((n-1)%k):\n ans += pd[j]\n if pd[j] == 0:\n c += 1\n al.append(n-1-(ans//m)-count*((n-1)//k)-c)\nfor i in range(q):\n print(al[i])", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [224, 222], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u170201762", "n_user": "u493130708", "pos": "k,q = map(int,input().split())\nd = list(map(int,input().split()))\n\ndef query(n,x,m):\n res = n-1\n n -= 1\n x %= m\n s1 = 0\n t1 = 0\n for i in range(k):\n s1 += d[i]%m\n if d[i]%m==0:\n t1 += 1\n s2 = 0\n t2 = 0\n for i in range(n%k):\n s2 += d[i]%m\n if d[i]%m==0:\n t2 += 1\n x += s1*(n//k)+s2\n res -= x//m\n res -= t1*(n//k)+t2\n return res\n\nfor i in range(q):\n n,x,m = map(int,input().split())\n print(query(n,x,m))", "neg": ",q = map(int, input().split())\nd = list(map(int, input().split()))\n\ndef query(n,x,m):\n x %= m\n ans = n-1\n n -= 1\n s1 = 0\n t1 = 0\n for i in range(k):\n s1 += d[i] % m\n if d[i] % m == 0:\n t1 += 1\n s2 = 0\n t2 = 0\n for i in range(n%k):\n s2 += d[i] % m\n if d[i] % m == 0:\n t2 += 1\n x += s1 * (n//k) + s2\n ans -= x//m\n ans -= t1 * (n//k) + t2\n \n print(ans)\n \n \n\nfor _ in range(q):\n n,x,m = map(int, input().split())\n query(n,x,m)\n", "jacc_sim": 0.9047619047619048, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [230, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u093219895", "n_user": "u093219895", "pos": "K, Q = map(int, input(\"\").split())\nd_ = list(map(int, input(\"\").split()))\nfor _ in range(Q):\n n,x,m = map(int, input(\"\").split())\n d = [0]*K;zeroes = [0]*(K+1);sum = [0]*(K+1)\n for i in range(K):d[i] = d_[i] % m\n for i in range(K):zeroes[i+1] = zeroes[i] + (d[i] == 0)\n for i in range(K):sum[i+1] = sum[i] + d[i]\n #print(zeroes, sum) \n s = (n-1)//K*sum[K] + sum[(n-1)%K]\n s += x%m\n #print(s)\n num0 = (n-1)//K*zeroes[K] + zeroes[(n-1)%K]\n print(n-1-s//m-num0)\n", "neg": "K, Q = map(int, input(\"\").split())\nd_ = list(map(int, input(\"\").split()))\nfor _ in range(Q):\n n,x,m = map(int, input(\"\").split())\n d = [0]*K;zeroes = [0]*(K+1);sum = [0]*(K+1)\n for i in range(K):d[i] = d_[i] % m\n for i in range(K):zeroes[i+1] = zeroes[i] + (d[i] == 0)\n for i in range(K):sum[i+1] = sum[i] + d[i]\n s = (n-1)//K*sum[K] + sum[(n-1)%K]\n s += x\n num0 = (n-1)//K*zeroes[K] + zeroes[(n-1)%K]\n print(n-1-s//m-num0)", "jacc_sim": 0.975, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [258, 238], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02770", "p_user": "u310678820", "n_user": "u310678820", "pos": "k, q = map(int, input().split())\nd = list(map(int, input().split()))\nfor _ in range(q):\n n, x, m = map(int, input().split())\n cum = [0]*(k+1)\n cnt = [0]*(k+1)\n for i in range(k):\n cum[i] = cum[i-1]+d[i]%m\n cnt[i] = cnt[i-1]\n if d[i]%m == 0:\n cnt[i]+=1\n res = x%m+cum[k-1]*((n-1)//k)+cum[(n-1)%k-1]\n s = res//m\n print(n-1-s-cnt[k-1]*((n-1)//k)-cnt[(n-1)%k-1])\n", "neg": "k, q = map(int, input().split())\nd = list(map(int, input().split()))\nfor _ in range(q):\n n, x, m = map(int, input().split())\n cum = [0]*(k)\n cnt = [0]*(k)\n for i in range(k):\n cum[i] = cum[i-1]+d[i]%m\n cnt[i] = cnt[i-1]\n if d[i]%m == 0:\n cnt[i]+=1\n res = x%m+cum[k-1]*(n//k)+cum[(n-1)%k]\n s = res//m\n print(n-1-s-cnt[-1]*(n//k)-cnt[(n-1)%k])\n", "jacc_sim": 1.0, "nl": "You are given a sequence of k numbers: d_0, d_1, ..., d_{k - 1}. Process q queries, each containing three integers n_i, x_i, and m_i. For each query, calculate a sequence of n_i numbers and count the occurrences where (a_j mod m_i) is less than (a_{j + 1} mod m_i). The input consists of k, q, d_i values, and n_i, x_i, m_i for each query. Output the count for each query. Constraints: 1 \u2264 k, q \u2264 5000, 0 \u2264 d_i \u2264 10^9, 2 \u2264 n_i, x_i, m_i \u2264 10^9.", "before_after_length": [213, 197], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u333700164", "n_user": "u333700164", "pos": "r1,c1,r2,c2=map(int,input().split())\nmod=10**9+7\ndef comb(n,k,mod):\n if n 0:\n if p % 2 == 0:\n n = n ** 2 % mod\n p //= 2\n else:\n res = res * n % mod\n p -= 1\n return res % mod\ndef factrial_memo(n=3*10**6+1,mod=10**9+7):\n fact = [1, 1]\n for i in range(2, n + 1):\n fact.append((fact[-1] * i) % mod)\n return fact\ndef fermat_cmb(n, r, mod=10**9+7): #needs pow,factrial_memo(only fact). return nCk\n return fact[n] * pow(fact[r],mod-2) * pow(fact[n-r],mod-2) %mod\nfact = factrial_memo()\nr1,c1,r2,c2 = r1+1,c1+1,r2+1,c2+1\nal = fermat_cmb(r2+c2,r2)\nsub_r = fermat_cmb(r1-1+c2,r1-1)\nsub_c = fermat_cmb(r2+c1-1,c1-1)\nadd_rc = fermat_cmb(r1-1+c1-1,r1-1)\n\nal -= sub_r+sub_c\nal += add_rc\n\nprint(al%mod)", "neg": "import sys\nreadline = sys.stdin.buffer.readline\nr1,c1,r2,c2 = map(int,readline().split())\nmod = 10**9+7\ndef pow(n,p,mod=10**9+7): #\u7e70\u308a\u8fd4\u3057\u4e8c\u4e57\u6cd5(n\u306ep\u4e57)\n res = 1\n while p > 0:\n if p % 2 == 0:\n n = n ** 2 % mod\n p //= 2\n else:\n res = res * n % mod\n p -= 1\n return res % mod\ndef factrial_memo(n=20**6+1,mod=10**9+7):\n fact = [1, 1]\n for i in range(2, n + 1):\n fact.append((fact[-1] * i) % mod)\n return fact\ndef fermat_cmb(n, r, mod=10**9+7): #needs pow,factrial_memo(only fact). return nCk\n return fact[n] * pow(fact[r],mod-2) * pow(fact[n-r],mod-2) %mod\nfact = factrial_memo()\nr1,c1,r2,c2 = r1+1,c1+1,r2+1,c2+1\nal = fermat_cmb(r2+c2,r2)\nsub_r = fermat_cmb(r1-1+c2,r1-1)\nsub_c = fermat_cmb(r2+c1-1,c1-1)\nadd_rc = fermat_cmb(r1-1+c1-1,r1-1)\n\nal -= sub_r+sub_c\nal += add_rc\n\nprint(al%mod)", "jacc_sim": 0.971830985915493, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [453, 451], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u492026192", "n_user": "u492026192", "pos": "r1,c1,r2,c2=map(int,input().split())\nMOD=10**9+7\nidx=r2+c2+3\nperm=[1]*(idx+1)\nfor i in range(1,idx+1):\n perm[i]=perm[i-1]*i\n perm[i]%=MOD\ndef inv_mod(a):\n return pow(a,MOD-2,MOD)\n\ndef comb(n,m,p=10**9+7):\n if n < m : return 0\n if n < 0 or m < 0:return 0\n m = min(m, n-m)\n top = bot = 1\n for i in range(m):\n top = top*(n-i) % p\n bot = bot*(i+1) % p\n bot = pow(bot, p-2, p)\n return top*bot % p\ndef g(i,j):\n return comb(i+j+2,i+1,MOD)\ndef s(n,m):\n return comb(n+m+2, m+1, MOD)\nres=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)\nres%=MOD\n\nans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)\nans %= MOD\nprint(res)", "neg": "r1,c1,r2,c2=map(int,input().split())\nMOD=10**9+7\nidx=r2+c2+3\nperm=[1]*(idx+1)\nfor i in range(1,idx+1):\n perm[i]=perm[i-1]*i\n perm[i]%=MOD\ndef inv_mod(a):\n return pow(a,MOD-2,MOD)\n\ndef comb(n,m,p=10**9+7):\n if n < m : return 0\n if n < 0 or m < 0:return 0\n m = min(m, n-m)\n top = bot = 1\n for i in range(m):\n top = top*(n-i) % p\n bot = bot*(i+1) % p\n bot = pow(bot, p-2, p)\n return top*bot % p\ndef g(i,j):\n return comb(i+j+2,i+1,mod)\ndef s(n,m):\n return comb(n+m+2, m+1, mod)\nres=g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)\n\nmod = 10**9+7\nans = s(r2,c2) - s(r2, c1-1) - s(r1-1, c2) + s(r1-1, c1-1)\nans %= mod\nprint(res)", "jacc_sim": 0.9821428571428571, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [371, 374], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u984276646", "n_user": "u984276646", "pos": "r1, c1, r2, c2 = map(int, input().split())\nmod = int(1e+9) + 7\ndef inved(x):\n a, b, c, d, k, l = 1, 0, 0, 1, x, mod\n while l != 0:\n a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)\n k, l = l, k % l\n return a % mod\nfrac = [1]\nfor i in range(r2 + c2 + 2):\n frac.append(((i+1) * frac[i]) % mod)\nfracr2c2 = frac[r2 + c2 + 2]\nfracr1c2 = frac[r1 + c2 + 1]\nfracr2c1 = frac[r2 + c1 + 1]\nfracr1c1 = frac[r1 + c1]\nfracr2 = frac[r2 + 1]\nfracr1 = frac[r1]\nfracc2 = frac[c2 + 1]\nfracc1 = frac[c1]\ng = 0\ng += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod\ng %= mod\ng += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod\ng %= mod\ng -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod\ng %= mod\ng -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod\ng %= mod\nprint(g)\n", "neg": "r1, c1, r2, c2 = map(int, input().split())\nmod = int(1e+9) + 7\ndef inved(x):\n a, b, c, d, k, l = 1, 0, 0, 1, x, mod\n while l != 0:\n a, b, c, d = c, d, a - c * (k // l), b - d * (k // l)\n k, l = l, k & l\n return a % mod\nfrac = [1]\nfor i in range(r2 + c2 + 2):\n frac.append(((i+1) * frac[i]) % mod)\nfracr2c2 = frac[r2 + c2 + 2]\nfracr1c2 = frac[r1 + c2 + 1]\nfracr2c1 = frac[r2 + c1 + 1]\nfracr1c1 = frac[r1 + c1]\nfracr2 = frac[r2 + 1]\nfracr1 = frac[r1]\nfracc2 = frac[c2 + 1]\nfracc1 = frac[c1]\ng = 0\ng += (fracr2c2 * inved(fracr2) * inved(fracc2)) % mod\ng %= mod\ng += (fracr1c1 * inved(fracr1) * inved(fracc1)) % mod\ng %= mod\ng -= (fracr1c2 * inved(fracr1) * inved(fracc2)) % mod\ng %= mod\ng -= (fracr2c1 * inved(fracr2) * inved(fracc1)) % mod\ng %= mod\nprint(g)", "jacc_sim": 0.9824561403508771, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [423, 422], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u077291787", "n_user": "u077291787", "pos": "# F - Many Many Paths\ndef get_factorials(lim: int, MOD: int) -> list:\n \"\"\"Compute a table of factorials (1-indexed).\"\"\"\n factorials = [1] * (lim + 1)\n x = 1\n for i in range(1, lim + 1):\n x = (x * i) % MOD\n factorials[i] = x\n return factorials\n\n\ndef mod_comb_with_pow(n: int, k: int, MOD: int) -> int:\n \"\"\"Compute nCr % MOD using pow(), not an inverse factorial table.\"\"\"\n return fact[n] * pow(fact[k], MOD - 2, MOD) * pow(fact[n - k], MOD - 2, MOD) % MOD\n\n\ndef main():\n global fact\n MOD = 10 ** 9 + 7\n R1, C1, R2, C2 = map(int, input().split())\n fact = get_factorials(2 * 10 ** 6 + 10, MOD)\n f = lambda x, y: mod_comb_with_pow(x, y, MOD)\n ans = (f(C1 + R1, R1) - f(C1 + R2 + 1, R2 + 1) - f(C2 + R1 + 1, R1) + f(C2 + R2 + 2, R2 + 1)) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# F - Many Many Paths\ndef get_factorials(lim: int, MOD: int) -> list:\n \"\"\"Compute a table of factorials (1-indexed).\"\"\"\n factorials = [1] * (lim + 1)\n x = 1\n for i in range(1, lim + 1):\n x *= i % MOD\n factorials[i] = x\n return factorials\n\n\ndef mod_comb_with_pow(n: int, k: int, MOD: int) -> int:\n \"\"\"Compute nCr % MOD using pow(), not an inverse factorial table.\"\"\"\n return fact[n] * pow(fact[k], MOD - 2, MOD) * pow(fact[n - k], MOD - 2, MOD) % MOD\n\n\ndef main():\n global fact\n MOD = 10 ** 9 + 7\n R1, C1, R2, C2 = map(int, input().split())\n fact = get_factorials(2 * 10 ** 6 + 10, MOD)\n f = lambda x, y: mod_comb_with_pow(x, y, MOD)\n ans = (f(C1 + R1, R1) - f(C1 + R2 + 1, R2 + 1) - f(C2 + R1 + 1, R1) + f(C2 + R2 + 2, R2 + 1)) % MOD\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 1.0, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [354, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u296518383", "n_user": "u296518383", "pos": "r1, c1, r2, c2 = map(int, input().split())\nMOD = 10 ** 9 + 7\n\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\ndef func(r, c):\n if c == 0:\n return r + 1\n return comb(r + c + 2, c + 1, MOD)\n\ndef comb(n, r, mod):\n return (g1[n] * g2[r] * g2[n - r]) % mod\n\nfor i in range(2, r2 + c2 + 10):\n g1.append((g1[-1] * i) % MOD)\n inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)\n g2.append((g2[-1] * inverse[-1]) % MOD)\n\nprint((func(r2, c2) - func(r1 - 1, c2) - func(r2, c1 - 1) + func(r1 - 1, c1 - 1)) % MOD)", "neg": "r1, c1, r2, c2 = map(int, input().split())\nMOD = 10 ** 9 + 7\n\ng1 = [1, 1]\ng2 = [1, 1]\ninverse = [0, 1]\n\ndef func(r, c):\n if r == c == 0:\n return 1\n if r == 0:\n return c + 1\n if c == 0:\n return r + 1\n return comb(r + c + 2, r + 1, MOD)\n\ndef comb(n, r, mod):\n return (g1[n] * g2[r] * g2[n - r]) % mod\n\nfor i in range(2, r2 + c2 + 10):\n g1.append((g1[-1] * i) % MOD)\n inverse.append((-inverse[MOD % i] * (MOD // i) ) % MOD)\n g2.append((g2[-1] * inverse[-1]) % MOD)\n\nprint((func(r2, c2) - func(r1 - 1, c2) - func(r2, c1 - 1) + func(r1 - 1, c1 - 1) % MOD))", "jacc_sim": 1.0, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [258, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u905582793", "n_user": "u905582793", "pos": "mod = 10**9+7\nrng = 2000100\nfctr = [1]+[0]*(rng-1)\nfor i in range(1,rng):\n fctr[i] = fctr[i-1]*i%mod\ndef finv(x):\n return pow(fctr[x],mod-2,mod)\ndef cmb(n,k):\n if n<0 or k<0:\n return 0\n else:\n return fctr[n]*finv(n-k)*finv(k)%mod\n\nx1,y1,x2,y2 = map(int,input().split())\nprint((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)", "neg": "mod = 10**9+7\nrng = 2000100\nfctr = [1]+[0]*(rng-1)\nfinv = [1]+[0]*(rng-1)\nfor i in range(1,rng):\n fctr[i] = fctr[-1]*i%mod\nfor i in range(1,rng):\n finv[i] = pow(fctr[i],mod-2,mod)\ndef cmb(n,k):\n if n<0 or k<0:\n return 0\n else:\n return fctr[n]*finv[n-k]*finv[k]%mod\n\nx1,y1,x2,y2 = map(int,input().split())\nprint((cmb(x2+y2+2,x2+1)-cmb(x2+y1+1,y1)-cmb(x1+y2+1,x1)+cmb(x1+y1,x1))%mod)", "jacc_sim": 0.9787234042553191, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [216, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p02782", "p_user": "u747220349", "n_user": "u747220349", "pos": "r1,c1,r2,c2=map(int,input().split())\na=r2-r1+1\nb=c2-c1+1\nm=max(a,b)\nn=min(a,b)\nmod=10**9+7\ndef framod(n, mod, a=1):\n for i in range(1,n+1):\n a=a * i % mod\n return a\ndef comb(n, k, mod):\n a=framod(n, mod)\n b=framod(k, mod)\n c=framod(n-k, mod)\n return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod\ndef f(x,y):\n return comb(x+y+2,y+1,mod)-1\n \nprint((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%mod)", "neg": "r1,c1,r2,c2=map(int,input().split())\na=r2-r1+1\nb=c2-c1+1\nm=max(a,b)\nn=min(a,b)\nmod=10**9+7\ndef framod(n, mod, a=1):\n for i in range(1,n+1):\n a=a * i % mod\n return a\ndef comb(n, k, mod):\n a=framod(n, mod)\n b=framod(k, mod)\n c=framod(n-k, mod)\n return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod\ndef f(x,y):\n return comb(x+y+2,y+1)-1\n \nprint((f(r2,c2)-f(r2,c1-1)-f(r1-1,c2)+f(r1-1,c1-1))%mod)", "jacc_sim": 1.0, "nl": "Snuke is positioned on a 2D plane and can move one unit in the positive x-direction or one unit in the positive y-direction. The function f(r, c) calculates the number of paths from (0, 0) to (r, c) that Snuke can trace. Given integers r1, r2, c1, and c2, find the sum of f(i, j) for all pairs (i, j) where r1 \u2264 i \u2264 r2 and c1 \u2264 j \u2264 c2, and compute this sum modulo (10^9+7). Constraints: 1 \u2264 r1 \u2264 r2 \u2264 10^6, 1 \u2264 c1 \u2264 c2 \u2264 10^6. Input format: r1 c1 r2 c2. Output: Print the sum of f(i, j) modulo (10^9+7). Example: Input: 1 1 2 2, Output: 14 (f(1,1)=2, f(1,2)=3, f(2,1)=3, f(2,2)=6, sum=14).", "before_after_length": [256, 254], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00111", "p_user": "u960312159", "n_user": "u960312159", "pos": "#! python.exe\ndic = {}\nfor idx, c in enumerate(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?\"):\n dic[c] = str(format(idx,'b').zfill(5))\n\ndecode = {\"101\" : \" \", \"0101\" : \"C\", \"0110\" : \"K\", \"00110\" : \"S\",\n \"000000\" : \"'\", \"0001\" : \"D\", \"00100\" : \"L\", \"00111\" : \"T\",\n \"000011\" : \",\", \"110\" : \"E\", \"10011001\" : \"M\", \"10011100\" : \"U\",\n \"10010001\" : \"-\", \"01001\" : \"F\", \"10011110\" : \"N\", \"10011101\" : \"V\",\n \"010001\" : \".\", \"10011011\" : \"G\", \"00101\" : \"O\", \"000010\" : \"W\",\n \"000001\" : \"?\", \"010000\" : \"H\", \"111\" : \"P\", \"10010010\" : \"X\",\n \"100101\" : \"A\", \"0111\" : \"I\", \"10011111\" : \"Q\", \"10010011\" : \"Y\",\n \"10011010\" : \"B\", \"10011000\" : \"J\", \"1000\" : \"R\", \"10010000\" : \"Z\"}\n#print(dic)\nwhile True:\n try:\n line = input()\n except:\n break\n s = \"\"\n for c in line:\n s += dic[c]\n ans = \"\"\n tmp = \"\"\n for c in s:\n tmp += c\n if tmp in decode:\n ans += decode[tmp]\n tmp = ''\n# print(ans, s)\n print(ans)", "neg": "#! python.exe\ndic = {}\nfor idx, c in enumerate(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?\"):\n dic[c] = str(format(idx,'b').zfill(5))\n\n\ndecode = {\"101\" : \" \", \"0101\" : \"C\", \"0110\" : \"K\", \"00110\" : \"S\",\n \"000000\" : \"'\", \"0001\" : \"D\", \"00100\" : \"L\", \"00111\" : \"T\",\n \"000011\" : \",\", \"110\" : \"E\", \"10011001\" : \"M\", \"10011100\" : \"U\",\n \"10010001\" : \"-\", \"01001\" : \"F\", \"10011110\" : \"N\", \"10011101\" : \"V\",\n \"010001\" : \".\", \"10011011\" : \"G\", \"00101\" : \"O\", \"000010\" : \"W\",\n \"000001\" : \"?\", \"010000\" : \"H\", \"111\" : \"P\", \"10010010\" : \"X\",\n \"100101\" : \"A\", \"0111\" : \"I\", \"10011111\" : \"Q\", \"10010011\" : \"Y\",\n \"10011010\" : \"B\", \"10011000\" : \"J\", \"1000\" : \"R\", \"10010000\" : \"Z\"}\nprint(dic)\nwhile True:\n try:\n line = input()\n except:\n break\n s = \"\"\n for c in line:\n s += dic[c]\n ans = \"\"\n while s.count(\"1\") :\n for key in decode:\n n = len(key)\n if s[0:n] == key:\n ans += decode[key]\n s = s[n:]\n break\n# print(ans, s)\n print(ans)", "jacc_sim": 0.9345794392523364, "nl": "Title: Doctor's Code\n\nDoctor: ?D-C'KOPUA\n\nPeter: What's wrong, Doctor David? I'm used to you shouting incomprehensible things, but today, you can't even form a sentence.\n\nDoctor: Look.\n\n[Image: Memorable Codes 1]\n\nPeter: What's this? This table... Oh, there was something like this in the preliminary round. Using the table to replace letters reduces the number of characters. They wouldn't be lazy enough to use the same problem in both the preliminary and final rounds, would they?\n\nDoctor: It's the opposite.\n\nPeter: The opposite? I see, this time it's a problem of restoring a shortened string to its original form. So, we use this table to replace the characters in \"?D-C'KOPUA\" with \"codes\" instead of \"letters\"... I've done it.\n\n11111 00011 11101 00010 11110 01010 01110 01111 10100 00000\n\nDoctor: Yes, now this.\n\n[Image: Memorable Codes 2]\n\nPeter: Right, there was a table like this. We use it in reverse, so we need to replace \"codes\" with \"letters.\" But, initially, \"11111\" isn't in the table, is it?\n\nDoctor: In such cases, try shortening it or connecting it to the end.\n\nPeter: Then, if I shorten it... Ah, \"111\" is there. So, initially it's \"P,\" right? Then the remaining \"11\" doesn't match exactly, so I borrow one letter from \"00011\" to make it \"110.\"\n\nDoctor: Exactly, that's \"E.\"\n\nPeter: So, what remains is \"0011,\" so I borrow from the next to make it \"00111\" to get \"T\"... I'm done. I can just discard the final \"0000,\" right?\n\nDoctor: Yes, that's right. Now this.\n\n[Image: Memorable Codes 3]\n\nDoctor: And this one.\n\n?P'QNPY?IXX?IXXK.BI -G?R'RPP'RPOVWDMW?SWUVG'-LCMGQ\n\nDoctor: Finally, this.\n\n?P'QMDUEQ GADKOQ ?SWUVG'-LCMG?X?IGX,PUL.?UL.VNQQI\n\nPeter: It's quite a hassle. Doctor, next time, please make the program yourself.\n\nSo, instead of the doctor, please create a program to replace the above text.\n\nInput:\nMultiple datasets are given. For each dataset, a single string (up to 200 characters consisting of characters in the table) is provided on a single line. Process until the end of input. The number of datasets does not exceed 200.\n\nOutput:\nFor each dataset, output the converted string on a single line.\n\nSample Input:\n?D-C'KOPUA\n\nOutput for the Sample Input:\nPETER POTTER", "before_after_length": [453, 470], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00112", "p_user": "u103916545", "n_user": "u103916545", "pos": "while True:\n n = int(input())\n t = []\n s = 0\n sum = 0\n\n if n == 0:\n break\n\n else:\n for i in range(n):\n t.append(i)\n t[i] = int(input())\n t.sort()\n\n for m in range(n):\n sum = sum + t[m]*(n-m-1)\n\n print(sum)\n\n", "neg": "n = int(input())\nt = []\ns = []\ntemp = 0\nsum = 0\nfor i in range(n+1):\n t.append(i)\n t[i] = int(input())\n if t[i] == 0:\n break\n else:\n t.sort()\nprint(t)\nfor m in range(n):\n sum = sum + t[m]*(n-m-1)\n\nprint(sum)\n\n", "jacc_sim": 0.90625, "nl": "Title: Milk Shop\n\nSuzuki has opened a new mobile milk vending shop in the Aizu region. Customers have already lined up with bottles to purchase fresh milk, and each customer will only place one order. As there is only one tap on the tank, milk must be sold to customers one by one. Suzuki wants to minimize the total waiting time for the customers in line.\n\nYou are given the number of customers and the time each customer takes to pour milk. Your task is to create a program that determines the optimal order of orders to minimize the total waiting time and output the total waiting time for that order. Each customer takes at most 60 minutes, and there are at most 10,000 customers.\n\nInput:\nMultiple datasets are provided. Each dataset is in the following format:\nn\nt1\nt2\n...\ntn\n\nThe first line contains the number of customers, n (n \u2264 10,000). The following n lines each contain an integer ti (0 \u2264 ti \u2264 60) representing the time the ith customer takes to pour milk.\n\nThe input ends with a line containing a single 0. There are at most 50 datasets.\n\nOutput:\nFor each dataset, output the total waiting time (an integer) on a single line.\n\nSample Input:\n5\n2\n6\n4\n3\n9\n0\n\nOutput for the Sample Input:\n31", "before_after_length": [112, 112], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00115", "p_user": "u300645821", "n_user": "u300645821", "pos": "#!/usr/bin/python\nfrom fractions import Fraction\nimport sys\nif sys.version_info[0]>=3: raw_input=input\n\ndef gauss(a):\n\tif not a or len(a)==0: return None\n\tn=len(a)\n\tfor i in range(n):\n\t\tif a[i][i]==0:\n\t\t\tfor j in range(i+1,n):\n\t\t\t\tif a[j][i]!=0:\n\t\t\t\t\tfor k in range(i,n+1): a[i][k]+=a[j][k]\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\treturn None\n\t\tfor j in range(n):\n\t\t\tif i!=j:\n\t\t\t\tr = Fraction(a[j][i],a[i][i])\n\t\t\t\tfor k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r\n\tfor i in range(n):\n\t\tx=Fraction(a[i][i],1)\n\t\tfor j in range(len(a[i])):\n\t\t\ta[i][j] /= x\n\treturn a\n\nuaz=list(map(int,raw_input().split()))\nenemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]\nb0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nb1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nb2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nsol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))\nprint('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')", "neg": "#!/usr/bin/python\nfrom fractions import Fraction\nimport sys\nif sys.version_info[0]>=3: raw_input=input\n\ndef gauss(a):\n\tif not a or len(a)==0: return None\n\tn=len(a)\n\tfor i in range(n):\n\t\tif a[i][i]==0:\n\t\t\tfor j in range(i+1,n):\n\t\t\t\tif a[j][i]!=0:\n\t\t\t\t\tfor k in range(i,n+1): a[i][k]+=a[j][k]\n\t\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\treturn None\n\t\tfor j in range(n):\n\t\t\tif i!=j:\n\t\t\t\tr = Fraction(a[j][i],a[i][i])\n\t\t\t\tfor k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r\n\tfor i in range(n):\n\t\tx=Fraction(a[i][i],1)\n\t\tfor j in range(len(a[i])):\n\t\t\ta[i][j] /= x\n\treturn a\n\nuaz=map(int,raw_input().split())\nenemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]\nb0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nb1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nb2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]\nsol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))\nprint('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')", "jacc_sim": 1.0, "nl": "Title: Spaceship UAZ Advance\n\nIn the year 2005.11.5, you, as the captain of the spaceship UAZ Advance, are preparing to engage in combat with an enemy spaceship. Fortunately, the enemy spaceship is still unaware of our presence and remains stationary. Moreover, the enemy's space coordinates are known, and the powerful straight beam weapon, the \"Feather Cannon,\" is ready to fire. All that remains is to give the order to fire.\n\nHowever, there is a complication. In space, there exists an energy barrier set up by the enemy. This barrier is triangular in shape and will deflect the \"Feather Cannon\" beam. If the beam hits the barrier, the enemy will become aware of our presence and may escape. Without prior confirmation of a successful hit, the firing order cannot be given.\n\nTherefore, create a program that takes the space coordinates (3D coordinates x, y, z) of the UAZ Advance, the enemy, and the barrier as input. The program should output \"HIT\" if the beam avoids the barrier and hits the enemy, and \"MISS\" if the beam hits the barrier and is deflected. If the enemy is within the barrier, output \"MISS\" as well.\n\nThe barrier is only applicable to objects that appear as triangles from the UAZ Advance, and not to those that appear as collapsed lines. Additionally, the barrier is effective even at the boundary containing the vertices of the triangular shape, deflecting the beam.\n\nInput:\nThe input data format is as follows:\n1st line: Coordinates of UAZ Advance (x, y, z) (integers, separated by a single space)\n2nd line: Coordinates of the enemy (x, y, z) (integers, separated by a single space)\n3rd line: Coordinates of the 1st vertex of the barrier (x, y, z) (integers, separated by a single space)\n4th line: Coordinates of the 2nd vertex of the barrier (x, y, z) (integers, separated by a single space)\n5th line: Coordinates of the 3rd vertex of the barrier (x, y, z) (integers, separated by a single space)\n\nOutput:\nOutput \"HIT\" or \"MISS\" on a single line.\n\nConstraints:\n-100 \u2264 x, y, z \u2264 100\nUAZ Advance and the enemy will never be in the same position.\n\nSample Input 1:\n-10 0 0\n10 0 0\n0 10 0\n0 10 10\n0 0 10\n\nOutput for the Sample Input 1:\nHIT\n\nSample Input 2:\n-10 6 6\n10 6 6\n0 10 0\n0 10 10\n0 0 10\n\nOutput for the Sample Input 2:\nMISS", "before_after_length": [497, 494], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00116", "p_user": "u319725914", "n_user": "u319725914", "pos": "# ref: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=924554#1\nfrom itertools import product\nwhile(True):\n H,W = map(int,input().split())\n if not H: break\n ma = [list(map(int,input().replace(\".\",\"1\").replace(\"*\",\"0\")))+[0] for _ in range(H)]\n for i,j in product(range(1,H),range(W)):\n if ma[i][j]: ma[i][j] += ma[i-1][j]\n ans = 0\n for i in range(H):\n stk = []\n for j in range(W+1):\n cur = ma[i][j]\n if (not stk) or stk[-1][1] < cur:\n stk.append([j,cur])\n elif stk[-1][1] > cur:\n idx = j\n while stk and stk[-1][1] >= cur:\n idx = stk[-1][0]\n ans = max(ans,stk[-1][1]*(j-stk[-1][0]))\n stk.pop()\n stk.append([idx,cur])\n print(ans)\n", "neg": "# ref: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=924554#1\nfrom itertools import product\nwhile(True):\n H,W = map(int,input().split())\n if not H: break\n ma = [list(map(int,input().replace(\".\",\"1\").replace(\"*\",\"0\")))+[0] for _ in range(H)]\n for i,j in product(range(1,H),range(W)):\n if ma[i][j]: ma[i][j] += ma[i-1][j]\n ans = 0\n for i in range(H):\n stk = []\n for j in range(W+1):\n cur = ma[i][j]\n if (not stk) or stk[-1][1] < cur:\n stk.append([j,cur])\n elif stk[-1][1] > cur:\n idx = j\n while stk and stk[-1][1] >= cur:\n ans = max(ans,stk[-1][1]*(j-stk[-1][0]))\n stk.pop()\n print(ans)\n", "jacc_sim": 1.0, "nl": "Title: Rectangle Exploration\n\nDescription:\nGiven a grid of dimensions H rows and W columns, with a total of W * H cells, some cells have marks. Create a program to read the state of marks in each cell and output the area of the largest rectangle consisting only of cells without marks.\n\nInput:\nMultiple datasets are provided. Each dataset begins with a line containing H and W separated by a space, followed by a rectangle of size H * W. H and W are both less than or equal to 500. The input ends with a line containing two zeros. The number of datasets does not exceed 20.\n\nOutput:\nFor each dataset, output the area of the largest rectangle on a single line.\n\nSample Input:\n10 10\n...*....**\n..........\n**....**..\n........*.\n..*.......\n**........\n.*........\n..........\n....*..***\n.*....*...\n10 10\n..*....*..\n.*.*...*..\n*****..*..\n*...*..*..\n*...*..*..\n..........\n****.*...*\n..*..*...*\n.*...*...*\n****..***.\n2 3\n...\n...\n0 0\n\nOutput for the Sample Input:\n28\n12\n6", "before_after_length": [312, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00124", "p_user": "u546285759", "n_user": "u546285759", "pos": "b=False\nwhile True:\n n = int(input())\n if n==0:break\n d=dict()\n if b:print()\n b=True\n for _ in range(n):\n line = input().split()\n tmp = int(line[1])*3+int(line[3]*1)\n if tmp in d:\n d[tmp].append(line[0])\n else:\n d[tmp] = []\n d[tmp].append(line[0])\n for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]:\n for v in vs:\n print('{0},{1}'.format(v, k))", "neg": "b=False\nwhile True:\n n = int(input())\n if n==0:break\n d=dict()\n if b:print()\n b=True\n for _ in range(n):\n line = input().split()\n tmp = int(line[1])*3+int(line[3]*1)\n if tmp in d:\n d[tmp].append(line[0])\n else:\n d[tmp] = []\n d[tmp].append(line[0])\n for k, vs in sorted(d.items(), key=lambda x: x[0])[::-1]:\n for v in vs:\n print('{0},{1}'.format(k, v))", "jacc_sim": 1.0, "nl": "Title: League Score Sheet\n\nIn sports tournaments, there are league and tournament matches. In soccer league matches, points are awarded for wins, losses, and draws, and teams compete for rankings based on these points. The points are as follows: win (3 points), loss (0 points), draw (1 point).\n\nCreate a program that takes the number of teams and their league match results as input, sorts them in descending order of performance (based on points earned), and outputs the team names along with their points. In case of a tie in points, output the teams in the order they were input.\n\nInput:\nMultiple datasets are provided. Each dataset is in the following format:\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n...\nnamen wn ln dn\n\nThe first line contains the number of teams, n (n \u2264 10). The following n lines contain the name of team i (up to 20 alphabetic characters), the number of wins wi, losses li, and draws di (0 \u2264 wi, li, di \u2264 9), separated by spaces.\n\nWhen the number of teams is 0, it indicates the end of input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the sorted list of teams. On the ith line, output the name of the ith team and their points separated by a comma.\n\nInsert a single empty line between datasets.\n\nSample Input:\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input:\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "before_after_length": [173, 173], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00124", "p_user": "u546285759", "n_user": "u546285759", "pos": "b = False\nwhile True:\n n = int(input())\n if n == 0:\n break\n dataset = []\n if b:\n print()\n b = True\n for _ in range(n):\n name, w, l, d = input().split()\n dataset.append((name, 3*int(w) + int(d), n-len(dataset)))\n for name, score, _ in sorted(dataset, key=lambda x: (x[1], x[2]))[::-1]:\n print(name + \",\" + str(score))", "neg": "while True:\n n = int(input())\n if n == 0:\n break\n dataset = []\n for _ in range(n):\n name, w, l, d = input().split()\n dataset.append((name, 3*int(w) + int(d), n-len(dataset)))\n for name, score, _ in sorted(dataset, key=lambda x: (x[1], x[2]))[::-1]:\n print(name + \",\" + str(score))", "jacc_sim": 0.9545454545454546, "nl": "Title: League Score Sheet\n\nIn sports tournaments, there are league and tournament matches. In soccer league matches, points are awarded for wins, losses, and draws, and teams compete for rankings based on these points. The points are as follows: win (3 points), loss (0 points), draw (1 point).\n\nCreate a program that takes the number of teams and their league match results as input, sorts them in descending order of performance (based on points earned), and outputs the team names along with their points. In case of a tie in points, output the teams in the order they were input.\n\nInput:\nMultiple datasets are provided. Each dataset is in the following format:\nn\nname1 w1 l1 d1\nname2 w2 l2 d2\n...\nnamen wn ln dn\n\nThe first line contains the number of teams, n (n \u2264 10). The following n lines contain the name of team i (up to 20 alphabetic characters), the number of wins wi, losses li, and draws di (0 \u2264 wi, li, di \u2264 9), separated by spaces.\n\nWhen the number of teams is 0, it indicates the end of input. The number of datasets does not exceed 50.\n\nOutput:\nFor each dataset, output the sorted list of teams. On the ith line, output the name of the ith team and their points separated by a comma.\n\nInsert a single empty line between datasets.\n\nSample Input:\n4\nJapan 1 0 2\nEgypt 1 2 0\nCanada 0 2 1\nSpain 2 0 1\n3\nIndia 0 2 0\nPoland 1 0 1\nItaly 1 0 1\n0\n\nOutput for the Sample Input:\nSpain,7\nJapan,5\nEgypt,3\nCanada,1\n\nPoland,4\nItaly,4\nIndia,0", "before_after_length": [136, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00127", "p_user": "u957021183", "n_user": "u957021183", "pos": "# Aizu Problem 00127: Pocket Pager Input\n#\nimport sys, math, os, copy\n\n# read input:\nPYDEV = os.environ.get('PYDEV')\nif PYDEV==\"True\":\n sys.stdin = open(\"sample-input.txt\", \"rt\")\n\n\ncode = {1: \"afkpuz\", 2: \"bglqv.\", 3: \"chmrw?\", 4: \"dinsx!\", 5: \"ejoty \"}\n\ndef pocket_pager(string):\n if len(string) % 2 == 1:\n return \"NA\"\n res = \"\"\n for k in range(len(string) // 2):\n i = int(string[2*k])\n j = int(string[2*k+1])\n if not 1 <= i <= 6 or not 1 <= j <= 5:\n return \"NA\"\n res += code[j][i-1]\n return res\n\n\nfor line in sys.stdin:\n print(pocket_pager(line.strip()))", "neg": "# Aizu Problem 00127: Pocket Pager Input\n#\nimport sys, math, os, copy\n\n# read input:\nPYDEV = os.environ.get('PYDEV')\nif PYDEV==\"True\":\n sys.stdin = open(\"sample-input.txt\", \"rt\")\n\n\ncode = {1: \"afkpuz\", 2: \"ablqv.\", 3: \"chmrw?\", 4: \"dinsx!\", 5: \"ejoty \"}\n\ndef pocket_pager(string):\n if len(string) % 2 == 1:\n return \"NA\"\n res = \"\"\n for k in range(len(string) // 2):\n i = int(string[2*k])\n j = int(string[2*k+1])\n if not 1 <= i <= 6 or not 1 <= j <= 5:\n return \"NA\"\n res += code[j][i-1]\n return res\n\n\nfor line in sys.stdin:\n print(pocket_pager(line.strip()))", "jacc_sim": 0.9733333333333334, "nl": "Title: Pocket Pager Input\n\nOne day, Tarou received a strange message containing the number \"519345213244\". It was from his cousin, who is 10 years older. When he called her, she mentioned that she sent it in a hurry using \"pocket pager input\" and abruptly ended the call. Tarou, familiar with his cousin's assertive nature, researched and found that \"pocket pager input\" is a method popular about 10 years ago.\n\nIn \"pocket pager input,\" characters are entered using two numbers based on a conversion table. For example, the string \"naruto\" is input as \"519345\". Thus, each character can be input using two numbers.\n\nDuring the time when mobile phones were not widely used, high school students used this method to send messages from public phones to their friends' pagers. There were even high school girls who could input messages at an incredible speed. Recently, due to her busy work schedule, Tarou's cousin unconsciously started typing emails using the pocket pager input method.\n\nTo help Tarou, who struggles to decipher these messages, create a program that converts messages input using pocket pager into strings. Use the conversion table in Figure 2 and consider only lowercase English letters, \".\", \"?\", \"!\", and spaces for conversion. For messages containing unconvertible characters, output \"NA\".\n\nInput:\nMultiple messages are provided. Each line contains one message (up to 200 characters). The total number of messages does not exceed 50.\n\nOutput:\nFor each message, output the converted message or \"NA\" on a single line.\n\nSample Input:\n(Provided in the original problem)\n\nSample Output:\n(Provided in the original problem)", "before_after_length": [250, 249], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00135", "p_user": "u032662562", "n_user": "u032662562", "pos": "def solve(h,m):\n dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0\n dm = m / 60.0 * 360.0\n x = abs(dh-dm)\n if x > 180:\n x = 360 - x\n if 0 <= x < 30.0:\n return(\"alert\")\n elif 90.0 <= x <= 180.0:\n return(\"safe\")\n else:\n return(\"warning\")\n\nn = int(input().strip())\nfor i in range(n):\n v = list(map(int, input().strip().split(':')))\n print(solve(v[0],v[1])) ", "neg": "def solve(h,m):\n dm = m / 60.0 * 360.0\n dh = h / 12.0 * 360.0 + 360.0/ 12.0 * m / 60.0\n print(dh, dm)\n if 0 <= abs(dh-dm) < 30.0:\n return(\"alert\")\n elif 90.0 <= abs(dh-dm) < 180.0:\n return(\"safe\")\n else:\n return(\"warning\")\n\nn = int(input().strip())\nfor i in range(n):\n v = list(map(int, input().strip().split(':')))\n print(solve(v[0],v[1])) ", "jacc_sim": 0.9607843137254902, "nl": "Title: Short and Long Hands of a Clock\n\nThe \"Akaruida\" primitive slow life organization has received a warning letter about a prank. Akaruida is known for pranks such as throwing pies at important people's faces, but recently, they have escalated to using explosives to scatter mouse fireworks at reception venues. The warning letter reads as follows:\n\n--- Stealing human time from computers. Not good.\nWhen the short and long hands of a clock meet, Akaruida will perform justice.\nSlow life is great.\n\nThough it's somewhat unclear, it seems to mean that the prank will be carried out when the short and long hands of a clock overlap.\n\nTo guard against this prank, create a program that takes the time as input and outputs \"alert\" if the short and long hands are close, \"safe\" if they are far, and \"warning\" for any other case. \"Close\" refers to an angle between the short and long hands of 0\u00b0 to less than 30\u00b0, and \"far\" refers to an angle between 90\u00b0 and 180\u00b0. The time will be between 00:00 and 11:59, inclusive.\n\nInput:\nThe input is given in the following format:\nn\nhh1:mm1\nhh2:mm2\n...\nhhn:mmn\n\nThe first line contains the number of times to be evaluated, n (1 \u2264 n \u2264 10000), and the subsequent lines contain the time hh:mm for each i-th time.\n\nOutput:\nOutput the judgment result \"safe\", \"warning\", or \"alert\" for each i-th time on separate lines.\n\nSample Input:\n4\n02:15\n06:01\n11:55\n10:40\n\nOutput for the Sample Input:\nalert\nsafe\nalert\nwarning", "before_after_length": [168, 162], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00135", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135\nWA\n\"\"\"\nimport sys\nfrom sys import stdin\nfrom math import sqrt, acos, cos, sin, radians, degrees\ninput = stdin.readline\n\n\ndef solve(time):\n # 12????????????90???\n short_hand_angle = time[1] * -6 + 90\n x_s = cos(radians(short_hand_angle))\n y_s = sin(radians(short_hand_angle))\n\n long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90\n x_l = cos(radians(long_hand_angle))\n y_l = sin(radians(long_hand_angle))\n c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))\n ans = degrees(acos(c))\n\n if ans < 30:\n return 'alert'\n elif ans >= 90:\n return 'safe'\n else:\n return 'warning'\n\n\ndef main(args):\n n = int(input())\n # n = 1\n for _ in range(n):\n time = [int(x) for x in input().split(':')]\n result = solve(time)\n print(result)\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135\nWA\n\"\"\"\nimport sys\nfrom sys import stdin\nfrom math import sqrt, acos, cos, sin, radians, degrees\ninput = stdin.readline\n\n\ndef solve(time):\n # 12????????????90???\n short_hand_angle = time[1] * -6 + 90\n x_s = cos(radians(short_hand_angle))\n y_s = sin(radians(short_hand_angle))\n\n long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90\n x_l = cos(radians(long_hand_angle))\n y_l = sin(radians(long_hand_angle))\n c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))\n ans = degrees(acos(c))\n\n if ans < 30:\n return 'alert'\n elif ans >= 90:\n return 'safe'\n else:\n return 'warning'\n\n\ndef main(args):\n # n = int(input())\n n = 1\n for _ in range(n):\n time = [int(x) for x in input().split(':')]\n result = solve(time)\n print(result)\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])", "jacc_sim": 1.0, "nl": "Title: Short and Long Hands of a Clock\n\nThe \"Akaruida\" primitive slow life organization has received a warning letter about a prank. Akaruida is known for pranks such as throwing pies at important people's faces, but recently, they have escalated to using explosives to scatter mouse fireworks at reception venues. The warning letter reads as follows:\n\n--- Stealing human time from computers. Not good.\nWhen the short and long hands of a clock meet, Akaruida will perform justice.\nSlow life is great.\n\nThough it's somewhat unclear, it seems to mean that the prank will be carried out when the short and long hands of a clock overlap.\n\nTo guard against this prank, create a program that takes the time as input and outputs \"alert\" if the short and long hands are close, \"safe\" if they are far, and \"warning\" for any other case. \"Close\" refers to an angle between the short and long hands of 0\u00b0 to less than 30\u00b0, and \"far\" refers to an angle between 90\u00b0 and 180\u00b0. The time will be between 00:00 and 11:59, inclusive.\n\nInput:\nThe input is given in the following format:\nn\nhh1:mm1\nhh2:mm2\n...\nhhn:mmn\n\nThe first line contains the number of times to be evaluated, n (1 \u2264 n \u2264 10000), and the subsequent lines contain the time hh:mm for each i-th time.\n\nOutput:\nOutput the judgment result \"safe\", \"warning\", or \"alert\" for each i-th time on separate lines.\n\nSample Input:\n4\n02:15\n06:01\n11:55\n10:40\n\nOutput for the Sample Input:\nalert\nsafe\nalert\nwarning", "before_after_length": [401, 401], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00135", "p_user": "u808429775", "n_user": "u808429775", "pos": "for _ in range(int(input())):\n hour, minute = [int(item) for item in input().split(\":\")]\n angle1 = hour * 5 * 6 + minute * 0.5\n angle2 = minute * 6\n\n subtract = min(abs(angle1 - angle2), 360 - abs(angle1 - angle2))\n\n if subtract < 30.0:\n print(\"alert\")\n elif 90.0 <= subtract:\n print(\"safe\")\n else:\n print(\"warning\")\n\n", "neg": "for _ in range(int(input())):\n hour, minute = [int(item) for item in input().split(\":\")]\n angle1 = hour * 5 * 6\n angle2 = minute * 6\n\n subtract = abs(angle1 - angle2)\n\n if subtract < 30:\n print(\"alert\")\n elif 90 <= subtract:\n print(\"safe\")\n else:\n print(\"warning\")\n\n", "jacc_sim": 0.9024390243902439, "nl": "Title: Short and Long Hands of a Clock\n\nThe \"Akaruida\" primitive slow life organization has received a warning letter about a prank. Akaruida is known for pranks such as throwing pies at important people's faces, but recently, they have escalated to using explosives to scatter mouse fireworks at reception venues. The warning letter reads as follows:\n\n--- Stealing human time from computers. Not good.\nWhen the short and long hands of a clock meet, Akaruida will perform justice.\nSlow life is great.\n\nThough it's somewhat unclear, it seems to mean that the prank will be carried out when the short and long hands of a clock overlap.\n\nTo guard against this prank, create a program that takes the time as input and outputs \"alert\" if the short and long hands are close, \"safe\" if they are far, and \"warning\" for any other case. \"Close\" refers to an angle between the short and long hands of 0\u00b0 to less than 30\u00b0, and \"far\" refers to an angle between 90\u00b0 and 180\u00b0. The time will be between 00:00 and 11:59, inclusive.\n\nInput:\nThe input is given in the following format:\nn\nhh1:mm1\nhh2:mm2\n...\nhhn:mmn\n\nThe first line contains the number of times to be evaluated, n (1 \u2264 n \u2264 10000), and the subsequent lines contain the time hh:mm for each i-th time.\n\nOutput:\nOutput the judgment result \"safe\", \"warning\", or \"alert\" for each i-th time on separate lines.\n\nSample Input:\n4\n02:15\n06:01\n11:55\n10:40\n\nOutput for the Sample Input:\nalert\nsafe\nalert\nwarning", "before_after_length": [123, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00137", "p_user": "u546285759", "n_user": "u546285759", "pos": "n = int(input())\nfor i in range(n):\n s = int(input())\n print(\"Case {}:\".format(i+1))\n for _ in range(10):\n s = int(\"{:08d}\".format(s ** 2)[2:6])\n print(s)", "neg": "n = int(input())\nfor i in range(n):\n s = int(input())\n print(\"Case {}:\".format(i+1))\n for _ in range(10):\n s = int(\"{:08d}\".format(s ** 2)[2:7])\n print(s)", "jacc_sim": 0.9333333333333333, "nl": "Title: Square Middle Method\n\nThe task is to create a program for the classical random number generation method called the Square Middle Method. This method, proposed by von Neumann in the mid-1940s, involves squaring an initial value 's', considering the result as a 2n-digit number, and taking the middle n digits as the first random number. This process is repeated to generate subsequent random numbers. For example, with an initial value of 123, the first few random numbers are generated as shown in the example.\n\nThe program should take as input the initial value 's' (a positive integer less than 10000) and generate 10 random numbers for the case when n=4.\n\nInput:\nMultiple datasets are provided. The first line contains the number of datasets, 'd' (d \u2264 10). Each dataset consists of one line with the initial value 's' (an integer, 1 \u2264 s < 10000).\n\nOutput:\nFor each dataset, output the generated random numbers in the format:\nCase x:\n1st generated random number (integer)\n2nd generated random number (integer)\n...\n10th generated random number (integer)\n\nSample Input:\n2\n123\n567\n\nOutput for the Sample Input:\nCase 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082", "before_after_length": [73, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00137", "p_user": "u314932236", "n_user": "u314932236", "pos": "import os\nimport sys\n\ndef main():\n n = int(input())\n for i in range(1,n+1):\n x = int(input())\n print(\"Case {}:\".format(i))\n for j in range(10):\n x = x**2\n out = '{0:08d}'.format(x)\n print(int(out[2:6]))\n x = int(out[2:6])\n\nmain()", "neg": "import os\nimport sys\n\ndef main():\n n = int(input())\n for i in range(1,n+1):\n x = int(input())\n print(\"Case {}:\".format(i))\n for j in range(10):\n x = x**2\n out = '{0:08d}'.format(x)\n print(out[2:6])\n x = int(out[2:6])\n\nmain()", "jacc_sim": 1.0, "nl": "Title: Square Middle Method\n\nThe task is to create a program for the classical random number generation method called the Square Middle Method. This method, proposed by von Neumann in the mid-1940s, involves squaring an initial value 's', considering the result as a 2n-digit number, and taking the middle n digits as the first random number. This process is repeated to generate subsequent random numbers. For example, with an initial value of 123, the first few random numbers are generated as shown in the example.\n\nThe program should take as input the initial value 's' (a positive integer less than 10000) and generate 10 random numbers for the case when n=4.\n\nInput:\nMultiple datasets are provided. The first line contains the number of datasets, 'd' (d \u2264 10). Each dataset consists of one line with the initial value 's' (an integer, 1 \u2264 s < 10000).\n\nOutput:\nFor each dataset, output the generated random numbers in the format:\nCase x:\n1st generated random number (integer)\n2nd generated random number (integer)\n...\n10th generated random number (integer)\n\nSample Input:\n2\n123\n567\n\nOutput for the Sample Input:\nCase 1:\n151\n228\n519\n2693\n2522\n3604\n9888\n7725\n6756\n6435\nCase 2:\n3214\n3297\n8702\n7248\n5335\n4622\n3628\n1623\n6341\n2082", "before_after_length": [110, 108], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00141", "p_user": "u352394527", "n_user": "u352394527", "pos": "vector = ((0, -1), (1, 0), (0, 1), (-1, 0))\n\ndef make_guruguru(d):\n lst = [[\"#\"] * (d + 4)]\n for _ in range(d + 2):\n lst.append([\"#\"] + [\" \"] * (d + 2) + [\"#\"])\n lst.append([\"#\"] * (d + 4))\n x, y = 2, d + 1\n lst[y][x] = \"#\"\n direct = 0\n vx, vy = vector[0]\n cnt = 1\n while True:\n while lst[y + vy * 2][x + vx * 2] == \" \":\n lst[y + vy][x + vx] = \"#\"\n y += vy\n x += vx\n cnt += 1\n if cnt <= 1:\n break\n direct = (direct + 1) % 4\n vx, vy = vector[direct]\n cnt = 0\n for y in range(2, d + 2):\n print(\"\".join(lst[y][2:-2]))\n\nn = int(input())\nmake_guruguru(int(input()))\nfor _ in range(n - 1):\n print()\n make_guruguru(int(input()))\n", "neg": "vector = ((0, -1), (1, 0), (0, 1), (-1, 0))\n\ndef make_guruguru(d):\n lst = [[\"#\"] * (d + 4)]\n for _ in range(d + 2):\n lst.append([\"#\"] + [\" \"] * (d + 2) + [\"#\"])\n lst.append([\"#\"] * (d + 4))\n x, y = 2, d + 1\n lst[y][x] = \"#\"\n direct = 0\n vx, vy = vector[0]\n cnt = 1\n while True:\n while lst[y + vy * 2][x + vx * 2] == \" \":\n lst[y + vy][x + vx] = \"#\"\n y += vy\n x += vx\n cnt += 1\n if cnt <= 1:\n break\n direct = (direct + 1) % 4\n vx, vy = vector[direct]\n cnt = 0\n for y in range(2, d + 2):\n print(\"\".join(lst[y][2:-2]))\n print()\n for line in lst:\n print(\"\".join(line))\n\nn = int(input())\nfor _ in range(n):\n d = int(input())\n make_guruguru(d)\n", "jacc_sim": 0.9777777777777777, "nl": "Title: \"Spiral Pattern\"\n\nWe are tasked with creating a program to display a \"spiral pattern.\" The pattern is defined as follows:\n\n- For a square with side length n, display an n x n grid of characters.\n- The pattern starts from the bottom-left corner and spirals clockwise.\n- Use \"#\" for the lines and \" \" for the empty spaces.\n- Place a space between adjacent lines.\n\nCreate a program that takes an integer n as input and outputs the \"spiral pattern\" for a square with side length n.\n\nInput:\nThe input is given in the following format:\nd\nn1\nn2\n...\nnd\n\nThe first line contains the number of datasets, d (d \u2264 20). The following d lines each contain the side length ni (1 \u2264 ni \u2264 100) of the spiral pattern for the ith dataset.\n\nOutput:\nFor each dataset, output the spiral pattern. Insert a blank line between datasets.\n\nSample Input:\n2\n5\n6\n\nOutput for the Sample Input:\n#####\n# #\n# # #\n# # #\n# ###\n\n######\n# #\n# ## #\n# # #\n# # #\n# ####", "before_after_length": [310, 315], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00141", "p_user": "u811733736", "n_user": "u811733736", "pos": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0141\n\n\"\"\"\nimport sys\nfrom sys import stdin\ninput = stdin.readline\nfrom itertools import cycle\n\n\ndef guruguru(n):\n line = 0\n dirs = cycle([(0, -1), (1, 0), (0, 1), (-1, 0)])\n\n M = [[' '] * n for _ in range(n)]\n cx = 0\n cy = n - 1\n\n while line < n:\n line += 1\n dx, dy = dirs.__next__()\n while True:\n M[cy][cx] = '#'\n nx = cx + dx\n ny = cy + dy\n nnx = nx + dx\n nny = ny + dy\n\n if nx < 0 or nx >= n:\n break\n if ny < 0 or ny >= n:\n break\n if nny < 0 or nny >= n or nnx < 0 or nnx >= n:\n pass\n else:\n if M[nny][nnx] != ' ':\n break\n cx = nx\n cy = ny\n\n for l in M:\n print(''.join(map(str, l)))\n\n\ndef main(args):\n n = int(input())\n for i in range(n):\n size = int(input())\n guruguru(size)\n if i != (n - 1):\n print()\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])\n ", "neg": "# -*- coding: utf-8 -*-\n\"\"\"\nhttp://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0141\n\n\"\"\"\nimport sys\nfrom sys import stdin\ninput = stdin.readline\nfrom itertools import cycle\n\n\ndef guruguru(n):\n line = 0\n dirs = cycle([(0, -1), (1, 0), (0, 1), (-1, 0)])\n\n M = [[' '] * n for _ in range(n)]\n cx = 0\n cy = n - 1\n\n while line < n:\n line += 1\n dx, dy = dirs.__next__()\n while True:\n M[cy][cx] = '#'\n nx = cx + dx\n ny = cy + dy\n nnx = nx + dx\n nny = ny + dy\n\n if nx < 0 or nx >= n:\n break\n if ny < 0 or ny >= n:\n break\n if nny < 0 or nny >= n or nnx < 0 or nnx >= n:\n pass\n else:\n if M[nny][nnx] != ' ':\n break\n cx = nx\n cy = ny\n\n for l in M:\n print(''.join(map(str, l)))\n\n\ndef main(args):\n n = int(input())\n for _ in range(n):\n size = int(input())\n guruguru(size)\n\n\nif __name__ == '__main__':\n main(sys.argv[1:])\n ", "jacc_sim": 0.9876543209876543, "nl": "Title: \"Spiral Pattern\"\n\nWe are tasked with creating a program to display a \"spiral pattern.\" The pattern is defined as follows:\n\n- For a square with side length n, display an n x n grid of characters.\n- The pattern starts from the bottom-left corner and spirals clockwise.\n- Use \"#\" for the lines and \" \" for the empty spaces.\n- Place a space between adjacent lines.\n\nCreate a program that takes an integer n as input and outputs the \"spiral pattern\" for a square with side length n.\n\nInput:\nThe input is given in the following format:\nd\nn1\nn2\n...\nnd\n\nThe first line contains the number of datasets, d (d \u2264 20). The following d lines each contain the side length ni (1 \u2264 ni \u2264 100) of the spiral pattern for the ith dataset.\n\nOutput:\nFor each dataset, output the spiral pattern. Insert a blank line between datasets.\n\nSample Input:\n2\n5\n6\n\nOutput for the Sample Input:\n#####\n# #\n# # #\n# # #\n# ###\n\n######\n# #\n# ## #\n# # #\n# # #\n# ####", "before_after_length": [398, 384], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00144", "p_user": "u352394527", "n_user": "u352394527", "pos": "from collections import deque\n\nn = int(input())\nrlst = [None] * (n + 1)\nfor _ in range(n):\n lst = list(map(int, input().split()))\n r = lst[0]\n lst = lst[2:]\n rlst[r] = lst\n\np = int(input())\n\nfor _ in range(p):\n s, d, v = map(int, input().split())\n visited = [False] * (n + 1)\n visited[s] = True\n que = deque()\n que.append((s, 0))\n while que:\n node, dist = que.popleft()\n if node == d:\n if dist < v:\n print(dist + 1)\n else:\n print(\"NA\")\n break\n for to in rlst[node]:\n if not visited[to]:\n que.append((to, dist + 1))\n visited[to] = True\n else:\n print(\"NA\")\n", "neg": "from collections import deque\nn = int(input())\nrlst = [None] * (n + 1)\n#print(rlst)\nfor _ in range(n):\n lst = list(map(int, input().split()))\n r = lst[0]\n print(r)\n lst = lst[2:]\n rlst[r] = lst\n\np = int(input())\n\nfor _ in range(p):\n s, d, v = map(int, input().split())\n visited = [False] * (n + 1)\n visited[s] = True\n que = deque()\n que.append((s, 1))\n while que:\n node, dist = que.pop()\n if node == d:\n print(dist)\n break\n if dist < v:\n for to in rlst[node]:\n if not visited[to]:\n que.append((to, dist + 1))\n else:\n print(\"NA\")\n", "jacc_sim": 0.9454545454545454, "nl": "Title: Packet Transmission\n\nIn the internet, data is divided into packets and transferred to the destination through intermediary devices called routers. Each router determines the next router to transfer the packet based on the destination specified in the packet. Additionally, to prevent infinite packet transfers between routers, a value called TTL (Time To Live) is added to each packet. The router decrements the TTL of the received packet by 1, discarding the packet if the result is 0, or forwarding it to the next router otherwise.\n\nTo assist in network design, a program needs to be created. Given the network connection information and packet transmission details as input, the program should display the minimum number of routers through which each packet reaches its destination.\n\nThe network consists of multiple routers connected by cables, with each connection being unidirectional. The network's connection information is provided as an array of router numbers. If there are multiple routes from the source to the destination, the program should output the minimum number of routers. If a packet does not reach its destination, the program should output \"NA\".\n\nThe input is provided in the following format:\n- The total number of routers, followed by each router's connection information.\n- The number of packets, followed by each packet's information, including the source router, destination router, and TTL value.\n\nFor each packet, the program should output the number of routers it passes through or \"NA\".\n\nSample Input:\n7\n1 4 2 5 4 3\n2 1 5\n3 1 6\n4 1 7\n5 2 7 6\n6 1 1\n7 0\n6\n1 2 2\n1 5 3\n1 2 1\n5 1 3\n6 3 3\n1 7 4\n\nOutput for the Sample Input:\n2\n2\nNA\n3\n3\n3", "before_after_length": [243, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00148", "p_user": "u546285759", "n_user": "u546285759", "pos": "while True:\n try:\n a = int(input())\n except:\n break\n tmp = a - (a // 39) * 39\n print(\"3C{:02d}\".format(tmp if tmp % 39 else 39))", "neg": "while True:\n try:\n a = int(input())\n except:\n break\n tmp = a - (a // 39) * 39\n print(\"3C{:02d}\".format(39 if tmp == 39 else tmp))", "jacc_sim": 0.9642857142857143, "nl": "Title: Candy and Class Flag\n\nIn class 3C, it was decided to use the \"class flag\" used in the sports festival on November 10, Heisei 19, for future class reunions. To determine the student who will store the \"class flag,\" a game using a large amount of candy provided by the teacher was devised.\n\n- Each student takes one candy in order of their student number.\n- If candy remains after one round, students continue taking candy in order from the first student number.\n- The student who takes the last candy will store the \"class flag.\"\n\nThe class consists of 39 students, numbered from 3C01 to 3C39. For example, if there are 50 candies, after each student takes their first candy, 11 candies will remain. Following the student number order, the last candy will be taken by student 3C11, who will then store the \"class flag.\"\n\nCreate a program that takes the number of candies as input and outputs the student number who will store the \"class flag.\"\n\nInput:\n- Multiple test cases are provided.\n- Each test case consists of an integer a (1 \u2264 a \u2264 10000) representing the number of candies.\n\nOutput:\n- For each test case, output the student number who will store the \"class flag\" on a single line.\n\nSample Input:\n50\n5576\n5577\n5578\n\nOutput for the Sample Input:\n3C11\n3C38\n3C39\n3C01", "before_after_length": [57, 57], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00149", "p_user": "u546285759", "n_user": "u546285759", "pos": "ld, rd = [0, 0, 0, 0], [0, 0, 0, 0]\nwhile True:\n try:\n l, r = map(float, input().split())\n if l < 0.2:\n ld[3] += 1\n elif l < 0.6:\n ld[2] += 1\n elif l < 1.1:\n ld[1] += 1\n else:\n ld[0] += 1\n\n if r < 0.2:\n rd[3] += 1\n elif r < 0.6:\n rd[2] += 1\n elif r < 1.1:\n rd[1] += 1\n else:\n rd[0] += 1\n\n except:\n break\n\nfor l, r in zip(ld, rd):\n print(l, r)", "neg": "ld, rd = [0, 0, 0, 0]. [0, 0, 0, 0]\nwhile True:\n try:\n l, r = map(float, input().split())\n if l < 0.2:\n ld[3] += 1\n elif l < 0.6:\n ld[2] += 1\n elif l < 1.1:\n ld[1] += 1\n else:\n ld[0] += 1\n\n if r < 0.2:\n rd[3] += 1\n elif r < 0.6:\n rd[2] += 1\n elif r < 1.1:\n rd[1] += 1\n else:\n rd[0] += 1\n\n except:\n break\n\nfor l, r in zip(ld, rd):\n print(l, r)", "jacc_sim": 1.0, "nl": "Title: Visual Acuity Test\n\nThe task is to create a program that takes input data from a visual acuity test and outputs the number of people falling into each category based on the visual acuity chart below, for both left and right eyes.\n\nTable:\nJudgment Visual Acuity\nA 1.1 or higher\nB 0.6 or higher, less than 1.1\nC 0.2 or higher, less than 0.6\nD Less than 0.2\n\nInput:\nThe input is given in the following format:\nl1 r1\nl2 r2\nl3 r3\n...\nEach line i contains two real numbers separated by a space, representing the left and right visual acuity of the i-th person. The visual acuity ranges from 0.1 to 2.0, given in increments of 0.1.\n\nThe number of input lines does not exceed 40.\n\nOutput:\nOutput the judgment table in the following format:\nLine 1: Number of people with A visual acuity for the left eye, Number of people with A visual acuity for the right eye (separated by a space)\nLine 2: Number of people with B visual acuity for the left eye, Number of people with B visual acuity for the right eye (separated by a space)\nLine 3: Number of people with C visual acuity for the left eye, Number of people with C visual acuity for the right eye (separated by a space)\nLine 4: Number of people with D visual acuity for the left eye, Number of people with D visual acuity for the right eye (separated by a space)\n\nSample Input:\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input:\n2 3\n2 1\n0 0\n0 0", "before_after_length": [200, 200], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00149", "p_user": "u032662562", "n_user": "u032662562", "pos": "lvl = [1.1, 0.6, 0.2, 0.0] \nrst = [[0]*4 for _ in range(2)]\neyes = []\nwhile True:\n try:\n l,r = map(float,input().strip().split())\n eyes.append([l,r])\n except EOFError:\n break\n\nfor e in eyes:\n for lr in range(2):\n for l in range(len(lvl)):\n if e[lr]>=lvl[l]: \n rst[lr][l] += 1\n break\n else:\n raise ValueError('Do not come here')\n\nfor lv in range(len(lvl)):\n print(\"%d %d\" % (rst[0][lv],rst[1][lv]))", "neg": "lvl = [1.1, 0.6, 0.2, 0.0] \nrst = [[0]*4 for _ in range(2)]\neyes = []\nwhile True:\n try:\n l,r = map(float,input().strip().split())\n eyes.append([l,r])\n except EOFError:\n break\n\nfor e in eyes:\n for lr in range(2):\n for l in range(len(lvl)):\n if e[lr]>=lvl[l]: \n rst[lr][l] += 1\n break\n else:\n raise ValueError('Do not come here')\n\nfor lv in range(len(lvl)):\n print(rst[0][lv],\" \",rst[1][lv])", "jacc_sim": 0.9629629629629629, "nl": "Title: Visual Acuity Test\n\nThe task is to create a program that takes input data from a visual acuity test and outputs the number of people falling into each category based on the visual acuity chart below, for both left and right eyes.\n\nTable:\nJudgment Visual Acuity\nA 1.1 or higher\nB 0.6 or higher, less than 1.1\nC 0.2 or higher, less than 0.6\nD Less than 0.2\n\nInput:\nThe input is given in the following format:\nl1 r1\nl2 r2\nl3 r3\n...\nEach line i contains two real numbers separated by a space, representing the left and right visual acuity of the i-th person. The visual acuity ranges from 0.1 to 2.0, given in increments of 0.1.\n\nThe number of input lines does not exceed 40.\n\nOutput:\nOutput the judgment table in the following format:\nLine 1: Number of people with A visual acuity for the left eye, Number of people with A visual acuity for the right eye (separated by a space)\nLine 2: Number of people with B visual acuity for the left eye, Number of people with B visual acuity for the right eye (separated by a space)\nLine 3: Number of people with C visual acuity for the left eye, Number of people with C visual acuity for the right eye (separated by a space)\nLine 4: Number of people with D visual acuity for the left eye, Number of people with D visual acuity for the right eye (separated by a space)\n\nSample Input:\n1.0 1.2\n0.8 1.5\n1.2 0.7\n2.0 2.0\n\nOutput for the Sample Input:\n2 3\n2 1\n0 0\n0 0", "before_after_length": [186, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p00152", "p_user": "u078042885", "n_user": "u078042885", "pos": "def score(x):\n s=0;t=1\n for _ in[0]*10:\n a=2;b=3\n if x[t]==10:a=1\n elif x[t]+x[t+1]!=10:b=2\n s+=sum(x[t:t+b]);t+=a\n return x[0],s\n\nwhile 1:\n n=int(input())\n if n==0:break\n A=sorted([score(list(map(int,input().split()))) for _ in [0]*n])\n for a,b in sorted(A,key=lambda x:-x[1]):print(a,b)", "neg": "def score(x):\n s=0;t=1\n for _ in[0]*10:\n a=2;b=3\n if x[t]==10:a=1\n elif x[t]+x[t+1]!=10:b=2\n s+=sum(x[t:t+b]);t+=a\n return x[0],s\n\nwhile 1:\n n=int(input())\n if n==0:break\n A=sorted([score(map(int,input().split())) for _ in [0]*n])\n for a,b in sorted(A,key=lambda x:-x[1]):print(a,b)", "jacc_sim": 0.9777777777777777, "nl": "Title: Bowling\n\nAs a class recreation, participants will play bowling. Create a program that takes input of each participant's bowling information and outputs the results in descending order of scores. In case of a tie, output in ascending order of student ID. The number of participants is between 3 and 40, and each participant plays one game.\n\nBowling involves rolling a ball towards 10 pins arranged in an equilateral triangle, aiming to knock them down. If all pins are knocked down on the first roll, it's called a strike, and the player moves to the next frame. If not, the remaining pins are rolled for a second time. If all pins are knocked down on the second roll, it's called a spare, and the player moves to the next frame.\n\nA game consists of 10 frames, with the first 9 frames allowing 2 rolls each. The 10th frame allows either 3 rolls for a strike or spare, or 2 rolls otherwise, ending the game.\n\nScoring:\n- If there are no spares or strikes in a frame, the score is the total number of pins knocked down in the 2 rolls.\n- If a spare is achieved, 10 points plus the number of pins knocked down in the next roll are added to the frame's score.\n- If a strike is achieved, 10 points plus the number of pins knocked down in the next 2 rolls are added to the frame's score.\n- In the 10th frame, the total number of pins knocked down in the 3 rolls (if a strike or spare) is added to the frame's score.\n- The total score of all frames is the game's score, with a maximum of 300 points.\n\nInput:\nMultiple datasets are given as input, ending with a single line containing zero. Each dataset is in the following format:\n- The number of participants, followed by the participant's information in the format: ID, followed by the number of pins knocked down in each roll.\n\nOutput:\nFor each dataset, output the student ID and score in descending order of scores (ascending order of student ID in case of a tie). Each output should contain the student ID and score separated by a single space.", "before_after_length": [169, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u162612857", "n_user": "u162612857", "pos": "k, t = list(map(int, input().split()))\nnums = list(map(int, input().split()))\n\nm = max(nums)\nrest = k - m\nif m - rest - 1 > 0:\n print(m - rest - 1)\nelse:\n print(0)\n", "neg": "k, t = list(map(int, input().split()))\nnums = list(map(int, input().split()))\n\nm = max(nums)\nrest = k - m\nif max - rest - 1 > 0:\n print(max - rest - 1)\nelse:\n print(0)\n", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [73, 73], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u548624367", "n_user": "u548624367", "pos": "K,T = map(int,input().split())\nA = list(map(int,input().split()))\nprint(max(2*max(A)-K-1,0))", "neg": "N,K = map(int,input().split())\nA = list(map(int,input().split()))\nprint(max(2*max(A)-K-1,0))", "jacc_sim": 0.9047619047619048, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [43, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u644907318", "n_user": "u107077660", "pos": "K,T = map(int,input().split())\nA = list(map(int,input().split()))\na = max(A)\nif a<=(K+1)//2:\n print(0)\nelse:\n print(2*a-K-1)", "neg": "K, T = map(int, input().split())\na = list(map(int, input().split()))\nif max(a) < (K+1)//2:\n\tprint(max(a) - (K+1)//2)\nelse:\n\tprint(0)\n", "jacc_sim": 0.9259259259259259, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [66, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u036104576", "n_user": "u036104576", "pos": "\nK, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nA = sorted(A, reverse=True)\n\nprint(max(0, A[0] - 1 - sum(A[1:])))", "neg": "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nA = sorted(A, reverse=True)\n\nprint(max(0, A[0] - 1 - sum(A[1:]))", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [61, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u201660334", "n_user": "u940102677", "pos": "k, t = map(int, input().split())\na = list(map(int, input().split()))\nnum = max(a)\nif (k + 1) // 2 >= num:\n print(0)\nelse:\n print(num * 2 - k - 1)", "neg": "k,t = map(int,input().split())\na = list(map(int,input().split()))\nif t == 1:\n print(k-1)\nelse:\n print(max(0,2*(max(a)-(k+1)//2)))", "jacc_sim": 0.9259259259259259, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [66, 65], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u813174766", "n_user": "u813174766", "pos": "n,k=map(int,input().split())\na=list(map(int,input().split()))\ns=max(a)\nprint(max(2*s-n-1,0))", "neg": "n,k=map(int,input().split())\na=list(map(int,input()split()))\ns=max(a)\nprint(max(2*s-n-1))", "jacc_sim": 0.9523809523809523, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [48, 46], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u089142196", "n_user": "u089142196", "pos": "K,T=map(int,input().split())\na=list(map(int,input().split()))\n\nmaxi=max(a)\nother = sum(a)-maxi\n#print(maxi,other)\n\nif maxi<=other:\n print(0)\nelse:\n print(maxi-other-1)\n", "neg": "K,T=map(int,input().split())\na=list(map(int,input().split()))\n\nmaxi=max(a)\nother = sum(a)-maxi\nprint(maxi,other)\n\nif maxi<=other:\n print(0)\nelse:\n print(maxi-other-1)", "jacc_sim": 0.9615384615384616, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [83, 81], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u517447467", "n_user": "u517447467", "pos": "N = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nmaxQ = max(Q)\nrest = N[0] - maxQ\nprint(max([maxQ-rest-1, 0]))", "neg": "N = list(map(int, input().split()))\nQ = list(map(int, input().split()))\nmaxQ = max(Q)\nrest = N[0] - 1\nprint(max([maxQ-rest-1, 0]))", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [59, 58], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u898967808", "n_user": "u898967808", "pos": "k,t = map(int,input().split())\nA = list(map(int,input().split()))\nprint(max(0,2*max(A) - sum(A) -1))", "neg": "k,t = map(int,input().split())\nA = list(map(int,input().split()))\nprint(max(2*max(A) - sum(A) -1))", "jacc_sim": 0.9523809523809523, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [47, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u540761833", "n_user": "u540761833", "pos": "K,T = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=1)\nif a[0] <= (K+1)//2:\n print(0)\nelse:\n print(2*a[0] - K-1)", "neg": "K,T = map(int,input().split())\na = sorted(list(map(int,input().split())),reverse=1)\nif a[0] <= (K+1)//2:\n print(0)\nelse:\n if T == 1:\n print(a[0]-1)\n else:\n print(2*a[0] - K)\n", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [71, 92], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u376099073", "n_user": "u970308980", "pos": "K,T = map(int,input().split())\na = list(map(int,input().split()))\na = sorted(a,reverse=True)\nprint(max(0,a[0] -sum(a[1:]) -1))", "neg": "K, T = map(int, input().split())\na = sorted(map(int, input().split()), reverse=True)\n\nif T == 1:\n print(K-1)\n\nprint(max(a[0]-sum(a[1:])-1,0))\n", "jacc_sim": 0.9230769230769231, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [59, 69], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u905582793", "n_user": "u905582793", "pos": "k,t=map(int,input().split())\na = list(map(int,input().split()))\nmx = max(a)\nprint(max(0,(mx-(k+1)//2)*2-1))", "neg": "k,t=map(int,input().split())\na = list(map(int,input().split()))\nsm = sum(a)\nmx = max(a)\nprint(max(0,(mx-(sm+1)//2)*2))", "jacc_sim": 0.92, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [55, 60], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u638795007", "n_user": "u638795007", "pos": "def examA():\n S = SI()\n ans = \"No\"\n flag = False\n for s in S:\n if flag:\n if s==\"F\":\n ans = \"Yes\"\n break\n else:\n if s==\"C\":\n flag = True\n print(ans)\n return\n\ndef examB():\n K, T = LI()\n A = LI(); A.sort()\n ans = max(0,A[-1]*2-sum(A)-1)\n print(ans)\n return\n\n\nimport sys,copy,bisect,itertools,heapq,math\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float('inf')\n\nif __name__ == '__main__':\n examB()\n", "neg": "def examA():\n S = SI()\n ans = \"No\"\n flag = False\n for s in S:\n if flag:\n if s==\"F\":\n ans = \"Yes\"\n break\n else:\n if s==\"C\":\n flag = True\n print(ans)\n return\n\ndef examB():\n K, T = LI()\n A = LI(); A.sort()\n ans = max(0,A[-1]*2-sum(A)-1)\n if len(A)==1:\n ans = A[0]\n print(ans)\n return\n\n\nimport sys,copy,bisect,itertools,heapq,math\nfrom heapq import heappop,heappush,heapify\nfrom collections import Counter,defaultdict,deque\ndef I(): return int(sys.stdin.readline())\ndef LI(): return list(map(int,sys.stdin.readline().split()))\ndef LSI(): return list(map(str,sys.stdin.readline().split()))\ndef LS(): return sys.stdin.readline().split()\ndef SI(): return sys.stdin.readline().strip()\nmod = 10**9 + 7\ninf = float('inf')\n\nif __name__ == '__main__':\n examB()\n", "jacc_sim": 0.9873417721518988, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [291, 309], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u503228842", "n_user": "u597374218", "pos": "K,T = map(int,input().split())\na = list(map(int,input().split()))\nma = max(a)\nprint(max(ma-1-(K-ma),0))\n", "neg": "K,T=map(int,input().split())\na=list(map(int,input().split()))\nprint(max(a)-(K-max(a))-1,0)", "jacc_sim": 0.9473684210526315, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [50, 45], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u600402037", "n_user": "u600402037", "pos": "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(max(0, max(A) - (K-max(A)+1)))", "neg": "K, T = map(int, input().split())\nA = list(map(int, input().split()))\n\nprint(max(A) - (K-max(A)+1))", "jacc_sim": 0.9473684210526315, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [48, 44], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u672220554", "n_user": "u672220554", "pos": "k,t = map(int,input().split())\na= list(map(int,input().split()))\nsa = sum(a)\nma = max(a)\n\nprint(max(ma-(sa-ma)-1,0))", "neg": "k,t = map(int,input().split())\na= list(map(int,input().split()))\nsa = sum(a)\nma = max(a)\n\nprint(max(sa-ma-1,0))", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [57, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u787456042", "n_user": "u787456042", "pos": "K,T,*A=map(int,open(0).read().split());print(max(0,(max(A)+-K//2)*2-(K+1)%2))", "neg": "K,T,*A=map(int,open(0).read().split());print(max(0,(max(A)+-K//2)*2-K%2^1))", "jacc_sim": 0.96, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [45, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u814986259", "n_user": "u814986259", "pos": "K,T = map(int,input().split())\na = list(map(int,input().split()))\n\na = sorted(a,reverse = True)\nans = a.pop(0) - sum(a) - 1\nif ans >= 0:\n print(ans)\nelse:\n print(0)", "neg": "K,T = map(int,input().split())\na = list(map(int,input().split()))\n\na = sorted(a,reverse = True)\nans = a.pop(0) - sum(a) - 1\nif a >= 0:\n print(ans)\nelse:\n print(0)", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [75, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u497046426", "n_user": "u497046426", "pos": "K, T = map(int, input().split())\n*A, = map(int, input().split())\nA = sorted(A, reverse=True)\nprint(max(A[0] - sum(A[1:]) - 1, 0))", "neg": "K, T = map(int, input().split())\n*A, = map(int, input().split())\nA = sorted(A, reverse=True)\nprint(A[0] - sum(A[1:]) - 1)", "jacc_sim": 0.96, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [58, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u729133443", "n_user": "u729133443", "pos": "k,t,*a=map(int,open(0).read().split());print(max(max(a)*2-sum(a),1)-1)", "neg": "k,t,*a=map(int,open(0).read().split());print(max(max(a)*2-sum(a),1)+1)", "jacc_sim": 0.9565217391304348, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [37, 37], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u163320134", "n_user": "u163320134", "pos": "n,m=map(int,input().split())\narr=list(map(int,input().split()))\nmaximum=max(arr)\nif (maximum-1)<=(sum(arr)-maximum):\n print(0)\nelse:\n print((maximum-1)-(sum(arr)-maximum))", "neg": "n,m=map(int,input().split())\narr=list(map(int,input().split()))\nmaximum=max(arr)\nif (maximum-1)<=(sum(arr)-maximum):\n print(0)\nelse:\n print(sum(arr)-maximum)", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [72, 67], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u047535298", "n_user": "u426108351", "pos": "K, T = map(int, input().split())\na = list(map(int, input().split()))\n\nprint(max(0, 2*max(a)-sum(a)-1))", "neg": "K, T = map(int, input().split())\na = list(map(int, input().split()))\nprint(max(a)-(sum(a)-max(a))-1, 0)", "jacc_sim": 0.9047619047619048, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [46, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u944209426", "n_user": "u268792407", "pos": "k,t=map(int,input().split())\na=list(map(int,input().split()))\nm=max(a)\nprint(max(0,m-1-(k-m)))", "neg": "k,t=map(int,input().split())\na=list(map(int,input().split()))\nm=max(a)\nn=k-m\nprint(min(m-n-1,0))", "jacc_sim": 0.9047619047619048, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [49, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u099918199", "n_user": "u099918199", "pos": "k,t = map(int, input().split())\nlist_cake = list((map(int, input().split())))\nlist_cake.sort()\nif list_cake[-1] <= k/2:\n print(0)\nelse:\n print(k - (k-list_cake[-1]) * 2 - 1)\n", "neg": "k,t = map(int, input().split())\nlist_cake = list((map(int, input().split())))\nlist_cake.sort()\nif len(list_cake) == 1:\n print(k-1)\nelif list_cake[-1] <= k/2:\n print(0)\nelse:\n print(k - (k-list_cake[-1]) * 2)\n", "jacc_sim": 0.9310344827586207, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [78, 96], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u075012704", "n_user": "u668503853", "pos": "K, T = map(int, input().split())\nA = list(map(int, input().split()))\nprint(max(0, (max(A)-1) - (K-max(A))))\n", "neg": "K,T=map(int,input().split())\nA=list(map(int,input().split()))\nM=max(A)\nprint(max(A-1-(K-A),0))", "jacc_sim": 0.9473684210526315, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [50, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u766407523", "n_user": "u766407523", "pos": "def inpl(): return list(map(int, input().split()))\nK, T = inpl()\na = inpl()\nprint(max(max(a)*2-K-1, 0))", "neg": "def inpl(): return list(map(int, input().split()))\nK, T = inpl()\na = inpl()\nprint(max(max(a)*2-n-1, 0))", "jacc_sim": 0.96, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [47, 47], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u422104747", "n_user": "u422104747", "pos": "l=list(map(int, input().split()))\nr=list(map(int, input().split()))\nprint(max(0,2*max(r)-l[0]-1))", "neg": "l=list(map(int, input().split()))\nr=list(map(int, input().split()))\nprint(2*max(r)-l[0]-1)", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [47, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03958", "p_user": "u635974378", "n_user": "u635974378", "pos": "K, T = list(map(int, input().split()))\na = list(map(int, input().split()))\n\n# def remax(seq):\n# m = max(seq)\n# for idx,i in enumerate(seq):\n# if m==i:\n# return (idx, m)\n#\n# lastK = -1\n# cnt = 0\n# for _k in range(K):\n# remax\n#\n\nprint(max(0,max(a)*2-sum(a)-1))\n", "neg": "K, T = list(map(int, input().split()))\na = list(map(int, input().split()))\n\n# def remax(seq):\n# m = max(seq)\n# for idx,i in enumerate(seq):\n# if m==i:\n# return (idx, m)\n#\n# lastK = -1\n# cnt = 0\n# for _k in range(K):\n# remax\n#\n\nprint(max(a)*2-sum(a)-1)\n", "jacc_sim": 1.0, "nl": "Mr. Takahashi wants to eat one cake per day from a collection of K cakes, each of a different type. He aims to minimize the number of consecutive days he eats the same type of cake. Given the number of cakes of each type, find the minimum number of days he eats the same type of cake as the previous day. Constraints: 1 \u2264 K \u2264 10000, 1 \u2264 T \u2264 100, 1 \u2264 a_i \u2264 100, and a_1 + a_2 + ... + a_T = K. The input is given as K T followed by a list of a_i. Output the minimum number of consecutive days with the same type of cake. Example input and output are provided.", "before_after_length": [128, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u381585104", "n_user": "u381585104", "pos": "s = input()\nn = len(s)\np = 0\nfor e in s:\n if e == 'p':\n p += 1\nprint(n//2 - p)\n", "neg": "s = input()\nn = len(s)\np = 0\nfor e in s:\n if e == 'p':\n p += 1\nprint(s//2 - p)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [44, 43], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u426764965", "n_user": "u426764965", "pos": "def abc046_d():\n s = str(input())\n n = len(s)\n if n == 1: return 0\n gc = [0] * n\n pc = [0] * n\n for i, c in enumerate(s):\n gc[i] = gc[i-1] + c.count('g')\n pc[i] = pc[i-1] + c.count('p')\n ans = (gc[-1] - pc[-1]) // 2\n return ans\n\nif __name__ == '__main__':\n print(abc046_d())", "neg": "def abc046_d():\n s = str(input())\n n = len(s)\n if n == 1: return 0\n gc = [0] * n\n pc = [0] * n\n for i, c in enumerate(s):\n gc[i] = gc[i-1] + c.count('g')\n pc[i] = pc[i-1] + c.count('p')\n print(gc)\n print(pc)\n ans = (gc[-1] - pc[-1]) // 2\n return ans\n\nif __name__ == '__main__':\n print(abc046_d())", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [142, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u308918401", "n_user": "u308918401", "pos": "s=input()\nn=len(s)\nt=0\nfor i in range(n):\n if s[i]==\"p\":\n t+=1\nprint(int(n/2)-t)\n", "neg": "s=input()\nn=len(s)\nt=0\nfor i in range(n):\n if s[i]==p:\n t+=1\nprint(int(n/2)-t)", "jacc_sim": 0.9615384615384616, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [51, 50], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u325282913", "n_user": "u325282913", "pos": "s = input()\nprint(s.count('g')-(-((-len(s))//2)))", "neg": "print(input().count('g')-(-((-len(s))//2)))", "jacc_sim": 0.9285714285714286, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [24, 19], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u863442865", "n_user": "u863442865", "pos": "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n n = len(s)\n res = 0\n for i in range(n):\n if i <= (n-1)//2:\n if s[i]=='p':\n res -= 1\n else:\n if s[i] == 'g':\n res += 1\n print(res)\n\nif __name__ == '__main__':\n main()", "neg": "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n #from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil\n #from operator import itemgetter\n\n #inf = 10**17\n #mod = 10**9 + 7\n\n s = input().rstrip()\n n = len(s)\n res = 0\n for i in range(n):\n if i <= n//2:\n if s[i]=='p':\n res -= 1\n else:\n if s[i] == 'g':\n res += 1\n print(res)\n\nif __name__ == '__main__':\n main()", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [223, 219], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u941434715", "n_user": "u941434715", "pos": "#coding: utf-8\nimport math\n\ns = input()\nans = math.floor(len(s)/2) - s.count(\"p\")\nprint(ans)", "neg": "#coding: utf-8\nimport math\n\ns = input()\nans = math.ceil(len(s)/2) - s.count(\"p\")\nprint(ans)", "jacc_sim": 0.9166666666666666, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [41, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u482982507", "n_user": "u405509847", "pos": "s = input()\np = 0\nfor i in range(len(s)):\n if s[i] == 'p': p += 1\nprint(-p + len(s) // 2)", "neg": "s=raw_input()\n\np=0\n\nfor i in range(len(s)):\n if s[i] == 'p':\n p += 1\n\nprint (len(s)//2 - p)", "jacc_sim": 0.9166666666666666, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [45, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u845536647", "n_user": "u845536647", "pos": "s=input()\ng=s.count('g')\np=s.count('p')\na=(-p+(g+p)//2)\nprint(a)", "neg": "s=input()\ng=s.count('g')\np=s.count('p')\na=g-p+(g+p)//2\nprint(a)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [41, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u097317219", "n_user": "u097317219", "pos": "s = list(input())\nn = len(s)\nans = 0\nflag = 0\nfor i in range(n):\n if s[i] == \"g\" and flag == 0:\n flag+=1\n elif s[i] == \"g\" and flag != 0:\n flag -= 1\n ans += 1\n elif s[i] == \"p\" and flag == 0:\n flag += 1\n ans -= 1\n else:\n flag -= 1\nprint(ans)", "neg": "s = list(input())\nn = len(s)\nans = 0\nfor i in range(n):\n if s[i] == \"g\" and flag == 0:\n flag+=1\n elif s[i] == \"g\" and flag != 0:\n flag -= 1\n ans += 1\n elif s[i] == \"p\" and flag == 0:\n flag += 1\n ans -= 1\n else:\n flag -= 1\nprint(ans)\n \n ", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [117, 117], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u567434159", "n_user": "u567434159", "pos": "s = input()\nscore = 0\ntoUse = 0\nfor it in s:\n if it == 'g' and toUse > 0:\n toUse -= 1\n score += 1\n continue\n if it == 'g':\n toUse += 1\n continue\n if toUse > 0:\n toUse -= 1\n else:\n toUse += 1\n score -=1\n \nprint(score)\n", "neg": "s = input()\nscore = 0\ntoUse = 0\nfor it in s:\n if it == 'g' and toUse > 0:\n toUse -= 1\n score += 1\n continue\n if it == 'g':\n continue\n if toUse > 0:\n toUse -= 1\n else:\n score -=1\n \nprint(score)\n", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [101, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u827202523", "n_user": "u827202523", "pos": "hands = input()\nans = 0\nfor i, h in enumerate(hands):\n if i % 2 == 0:\n if h == \"p\":\n ans -= 1\n else:\n if h == \"g\":\n ans += 1\n \nprint(ans)\n ", "neg": "hands = input()\nans = 0\nfor i, h in enumerate(hands):\n if i % 2 == 1:\n if h == \"p\":\n ans -= 1\n else:\n if h == \"g\":\n ans += 1\n \nprint(ans)\n ", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [68, 68], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u886274153", "n_user": "u886274153", "pos": "s = input()\nn = len(s)\n\ns = [i for i in s]\nfor i in range(n):\n if s[i] == \"p\":\n s[i] = 1\n else:\n s[i] = 0\n\nd = [0]*n\nd[0] = 0\ngc = 1\npc = 0\nfor i in range(1, n):\n if gc-1 >= pc:\n d[i] = 1\n pc += 1\n else:\n d[i] = 0\n gc += 1\n\nans = 0\nfor i in range(n):\n ans += d[i]-s[i]\n\nprint(ans)", "neg": "s = input()\nn = len(s)\n\ns = [i for i in s]\nfor i in range(n):\n if s[i] == \"p\":\n s[i] = 1\n else:\n s[i] = 0\nprint(s)\n\nd = [0]*n\nd[0] = 0\ngc = 1\npc = 0\nfor i in range(1, n):\n if gc-1 >= pc:\n d[i] = 1\n pc += 1\n else:\n d[i] = 0\n gc += 1\nprint(d)\n\nans = 0\nfor i in range(n):\n ans += d[i]-s[i]\n\nprint(ans)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [165, 175], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u060392346", "n_user": "u060392346", "pos": "s = input()\n\nscore = 0\nfor i in range(len(s)):\n if i % 2 == 0 and s[i] == \"p\":\n score -= 1\n elif i % 2 != 0 and s[i] == \"g\":\n score += 1\n\nprint(score)", "neg": "s = input()\n\nscore = 0\nfor i in range(len(s)):\n if i % 2 == 0 and s[i] = \"p\":\n score -= 1\n elif i % 2 != 0 and s[i] = \"g\":\n score += 1\n\nprint(s)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [70, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u415905784", "n_user": "u415905784", "pos": "s = input()\nprint((s.count('g') - s.count('p')) // 2)", "neg": "s = input()\nprint((s.count('p') - s.count('g')) // 2)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [23, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u729133443", "n_user": "u729133443", "pos": "s=input()\ng=p=a=0\nfor t in s:\n if t=='g':\n g+=1\n else:\n if p 0:\n\t\t\tcou -= 1\n\t\t\tans += 1\n\t\telse:\n\t\t\tcou += 1\n\telse:\n\t\tif cou > 0:\n\t\t\tcou -= 1\n\t\telse:\n\t\t\tcou += 1\n\t\t\tans -= 1\nprint(max(0,ans))\n", "neg": "lis = list(input())\ncou = 0\nans = 0\nfor i in range(len(lis)):\n\tif lis[i] == \"g\":\n if cou > 0:\n cou -= 1\n ans += 1\n else:\n cou += 1\n else:\n if cou > 0:\n cou -= 1\n else:\n cou += 1\n ans -= 1\nprint(max(0,ans))", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [122, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u743272507", "n_user": "u731368968", "pos": "s = input()\ntp = s.count(\"p\")\nprint(len(s)//2-tp)\n", "neg": "s = input()\nprint(len(s) / 2 - s.count('p'))", "jacc_sim": 0.9333333333333333, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [26, 20], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u425351967", "n_user": "u425351967", "pos": "s = input()\n\nP = 0\nfor c in s:\n if c == 'p':\n P += 1\n\nprint(len(s)//2 - P)", "neg": "s = input()\n\nP = 0\nfor c in s:\n if c == 'p':\n P += 1\n\nprint(N//2 - P)", "jacc_sim": 0.9090909090909091, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [41, 38], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03965", "p_user": "u877160719", "n_user": "u096616343", "pos": "s = input()\ng = 0\np = 0\nfor i in s:\n if i == 'g':\n g += 1\n if i == 'p':\n p += 1\nprint((g - p) // 2)", "neg": "s = input()\ng = 0\np = 0\nfor i in s:\n if i = \"g\":\n g += 1\n if i = \"p\":\n p += 1\nprint((g - p) // 2)", "jacc_sim": 1.0, "nl": "AtCoDeer and his friend TopCoDeer are playing a game with N turns. Each player chooses between Rock and Paper, following the rule that the number of times a player plays Paper is less than or equal to the number of times they play Rock. The score is calculated by the number of wins minus the number of losses. AtCoDeer can predict TopCoDeer's gestures for each turn. The task is to plan AtCoDeer's gestures to maximize his score. The input is a string s representing TopCoDeer's gestures, and the output should be AtCoDeer's maximum possible score. The constraints are 1 \u2264 N \u2264 10^5, N = |s|, and each character in s is either 'g' or 'p', satisfying the given condition. Two sample inputs and outputs are provided as examples.", "before_after_length": [54, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03968", "p_user": "u226155577", "n_user": "u226155577", "pos": "from collections import deque\nN = int(input())\nC = []\nM = {}\nfor i in range(N):\n *c, = map(int, input().split())\n c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))\n C.append(c)\n if c not in M:\n M[c] = deque([i])\n else:\n M[c].append(i)\ndef count(p, q, r, s):\n if p == q == r == s:\n return 4\n if p == r and q == s:\n return 2\n return 1\ndef solve(ci, cj, k):\n R = {}\n for l in range(4):\n # [l] [l-1]\n # [l+k] [l+k+1]\n c = ci[l], ci[l-1], cj[k-l], cj[k-l-1]\n c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))\n if c not in M:\n return 0\n R[c] = R.get(c, 0) + 1\n res = 1\n for c in R:\n m = M[c]\n cnt = len(m)\n if c == cj:\n cnt -= 1\n if cnt < R[c]:\n return 0\n k = count(*c)\n for p in range(cnt-R[c]+1, cnt+1):\n res *= p * k\n return res\n\nans = 0\nfor i in range(N):\n ci = C[i]\n q = M[ci]; q.popleft()\n if not q:\n del M[ci]\n for j in range(i+1, N):\n cj = C[j]\n for k in range(4):\n ans += solve(ci, cj, k)\nprint(ans)\n", "neg": "from collections import deque\nN = int(input())\nC = []\nM = {}\nfor i in range(N):\n *c, = 0, 0, 0, 0 #map(int, input().split())\n c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))\n C.append(c)\n if c not in M:\n M[c] = deque([i])\n else:\n M[c].append(i)\ndef count(p, q, r, s):\n if p == q == r == s:\n return 4\n if p == r and q == s:\n return 2\n return 1\ndef solve(ci, cj, k):\n R = {}\n for l in range(4):\n # [l] [l-1]\n # [l+k] [l+k+1]\n c = ci[l], ci[l-1], cj[k-l], cj[k-l-1]\n c = tuple(min(c[j:] + c[:j] for j in range(1, 5)))\n if c not in M:\n return 0\n R[c] = R.get(c, 0) + 1\n res = 1\n for c in R:\n m = M[c]\n cnt = len(m)\n if c == cj:\n cnt -= 1\n if cnt < R[c]:\n return 0\n k = count(*c)\n for p in range(cnt-R[c]+1, cnt+1):\n res *= p * k\n return res\n\nans = 0\nfor i in range(N):\n ci = C[i]\n q = M[ci]; q.popleft()\n if not q:\n del M[ci]\n for j in range(i+1, N):\n cj = C[j]\n for k in range(4):\n ans += solve(ci, cj, k)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "AtCoDeer the deer has N square tiles numbered 1 through N, with each tile having a number and corners painted in one of 1000 colors. AtCoDeer wants to construct a cube using six of these tiles, with the following conditions: each tile's number must face outward, and each vertex of the cube must have three corners of the tiles painted in the same color. The task is to find the number of different cubes that can be constructed under these conditions. Two cubes are considered different if the set of used tiles or their directions are different, even if the color formations are the same. The input format is N followed by the colors of each tile, and the output is the number of different cubes that can be constructed.", "before_after_length": [475, 483], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03972", "p_user": "u190405389", "n_user": "u190405389", "pos": "import sys\nsys.setrecursionlimit(10**7)\n\nreadline = sys.stdin.buffer.readline\ndef readstr():return readline().rstrip().decode()\ndef readstrs():return list(readline().decode().split())\ndef readint():return int(readline())\ndef readints():return list(map(int,readline().split()))\ndef printrows(x):print('\\n'.join(map(str,x)))\ndef printline(x):print(' '.join(map(str,x)))\n\nimport heapq\n\n\nw,h =readints()\np = [readint() for i in range(w)]\nq = [readint() for i in range(h)]\n\nheapq.heapify(p)\nheapq.heapify(q)\n\nedge = 0\ncost = 0\nused = [0,0]\n\nwhile edge < (h+1)*(w+1)-1:\n if p and q:\n if p[0] 0:\n a, b = b, a % b\n return b\n \ndef solve():\n X, Y = map(int, line_input())\n p = [0] * X\n q = [0] * Y\n for x in range(X): p[x] = int(single_input())\n for y in range(Y): q[y] = int(single_input())\n total_cost = sum(p) + sum(q)\n p.sort()\n total_sum_p = [0] * (X + 1)\n for x in range(X):\n total_sum_p[x+1] = p[x] + total_sum_p[x]\n for y in range(Y):\n x_smaller_than_y = bisect(p, q[y])\n total_cost += q[y] * (X - x_smaller_than_y) + total_sum_p[x_smaller_than_y]\n return total_cost\n \nif __name__ == \"__main__\":\n print(solve())", "neg": "import sys, math, collections, heapq, itertools\nfrom bisect import bisect\nF = sys.stdin\ndef single_input(): return F.readline().strip(\"\\n\")\ndef line_input(): return F.readline().strip(\"\\n\").split()\ndef gcd(a, b):\n a, b = max(a, b), min(a, b)\n while a % b > 0: a, b = b, a % b\n return b\n \ndef solve():\n X, Y = map(int, line_input())\n p = [0] * X\n q = [0] * Y\n total_cost = 0\n total_sum_p = [0] * (X + 1)\n for x in range(X): \n p[x] = int(single_input())\n total_cost += p[x]\n total_sum_p[x + 1] = total_sum_p[x] + p[x]\n p.sort()\n \n for y in range(Y): \n q[y] = int(single_input())\n total_cost += q[y]\n \n for y in range(Y):\n x_smaller_than_y = bisect(p, q[y])\n total_cost += q[y] * (X - x_smaller_than_y) + total_sum_p[x_smaller_than_y]\n return total_cost\n \nif __name__ == \"__main__\":\n print(solve())", "jacc_sim": 0.9838709677419355, "nl": "You are given an xy plane with houses at integer coordinates. Unpaved roads exist between houses. The cost of paving roads in the x and y directions varies. Find the minimum total cost to pave roads and enable travel between any two houses only on paved roads. Constraints: 1 \u2264 W, H \u2264 10^5, 1 \u2264 pi, qj \u2264 10^8, where pi and qj are integers. Input format: W H p0 ... pW-1 q0 ... qH-1. Output format: an integer representing the minimum total cost. Example inputs and outputs are provided.", "before_after_length": [348, 357], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03972", "p_user": "u476199965", "n_user": "u476199965", "pos": "w,h = list(map(int,input().split()))\npq = []\nfor i in range(w):\n pq.append((int(input()),0))\nfor i in range(h):\n pq.append((int(input()),1))\npq.sort()\nres = 0\nw+=1\nh+=1\ndic = {0:w,1:h}\n\nfor x in pq:\n res += dic[1-x[1]]*x[0]\n dic[x[1]] -= 1\n\nprint(res)\n", "neg": "w,h = list(map(int,input().split()))\npq = []\nfor i in range(w):\n pq.append((int(input()),0))\nfor i in range(h):\n pq.append((int(input()),1))\npq.sort()\nres = 0\nw+=1\nh+=1\ndic = {0:w,1:h}\n\nfor x in pq:\n print(dic[x[1]],x[0])\n res += dic[1-x[1]]*x[0]\n dic[x[1]] -= 1\n\nprint(res)\n", "jacc_sim": 1.0, "nl": "You are given an xy plane with houses at integer coordinates. Unpaved roads exist between houses. The cost of paving roads in the x and y directions varies. Find the minimum total cost to pave roads and enable travel between any two houses only on paved roads. Constraints: 1 \u2264 W, H \u2264 10^5, 1 \u2264 pi, qj \u2264 10^8, where pi and qj are integers. Input format: W H p0 ... pW-1 q0 ... qH-1. Output format: an integer representing the minimum total cost. Example inputs and outputs are provided.", "before_after_length": [135, 150], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03972", "p_user": "u591287669", "n_user": "u591287669", "pos": "w,h = map(int,input().split())\narr=[]\nfor i in range(w):\n arr.append( (int(input()),'p') )\nfor i in range(h):\n arr.append( (int(input()),'q') )\narr.sort()\n#print(arr)\nans=0\nfor a in arr:\n if a[1]=='p':\n ans+=a[0]*(h+1)\n w-=1\n else:\n ans+=a[0]*(w+1)\n h-=1\nprint(ans)\n", "neg": "w,h = map(int,input().split())\narr=[]\nfor i in range(w):\n arr.append( (int(input()),'p') )\nfor i in range(h):\n arr.append( (int(input()),'q') )\narr.sort()\nprint(arr)\nans=0\nfor a in arr:\n if a[1]=='p':\n ans+=a[0]*(h+1)\n w-=1\n else:\n ans+=a[0]*(w+1)\n h-=1\nprint(ans)\n", "jacc_sim": 0.9714285714285714, "nl": "You are given an xy plane with houses at integer coordinates. Unpaved roads exist between houses. The cost of paving roads in the x and y directions varies. Find the minimum total cost to pave roads and enable travel between any two houses only on paved roads. Constraints: 1 \u2264 W, H \u2264 10^5, 1 \u2264 pi, qj \u2264 10^8, where pi and qj are integers. Input format: W H p0 ... pW-1 q0 ... qH-1. Output format: an integer representing the minimum total cost. Example inputs and outputs are provided.", "before_after_length": [145, 144], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\na = [None]*n\nfor i in range(n):\n a[i] = int(input())\nans = a[0]-1\nprev = 1\nfor i,num in enumerate(a[1:]):\n if prev+10:\n v = (num-1)//(prev+1)\n num -= v*(prev+1)\n ans += v\n if num==prev+1:\n num = prev\n break\n prev = max(prev, num)\nprint(ans)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\nn = int(input())\na = [None]*n\nfor i in range(n):\n a[i] = int(input())\nans = a[0]-1\nprev = 1\nfor i,num in enumerate(a[1:]):\n if prev+10:\n v = (num-1)//(prev+1)\n num -= v*(prev+1)\n ans += 1\n if num==prev+1:\n num = prev\n break\n prev = max(prev, num)\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [194, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u690536347", "n_user": "u690536347", "pos": "N = int(input())\n*A, = [int(input()) for _ in range(N)]\n\nans = 0\nv = 1\n\nfor i, j in enumerate(A):\n if i==0:\n ans += j-1\n else:\n if j==v+1:\n v += 1\n ans += (j-1)//(v+1)\n\nprint(ans)\n", "neg": "N = int(input())\n*A, = [int(input()) for _ in range(N)]\n\nans = 0\nv = 0\n\nfor i, j in enumerate(A):\n if j==v+1:\n v += 1\n ans += (j-1)//(v+1)\n\nprint(ans)\n", "jacc_sim": 0.9655172413793104, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [97, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = [ir() for _ in range(N)]\nanswer = A[0] - 1\ncur_limit = 2\nfor a in A[1:]:\n if a == cur_limit:\n cur_limit += 1\n continue\n answer += -((-(a-cur_limit)) // cur_limit)\n\nprint(answer)\n# 44", "neg": "import sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = [ir() for _ in range(N)]\nanswer = A[0] - 1\ncur_limit = 2\nfor a in A[1:]:\n if a == cur_limit:\n cur_limit += 1\n continue\n answer += (a-cur_limit) // cur_limit)\n\nprint(answer)\n# 44\n", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [133, 131], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u540761833", "n_user": "u540761833", "pos": "N = int(input())\nA = [int(input()) for i in range(N)]\nnow = 2\ncount = A[0]-1\nfor i in range(1,N):\n if A[i] == now:\n now += 1\n elif A[i]%now != 0:\n count += A[i]//now\n else:\n count += (A[i]-1)//now\nprint(count)", "neg": "N = int(input())\nA = [int(input()) for i in range(N)]\nnow = 2\ncount = A[0]-1\nmaxrem = 1\nfor i in range(1,N):\n if A[i] == now:\n now += 1\n elif A[i]%now:\n count += A[i]//(now+1)\n else:\n count += A[i]//now\nprint(count)", "jacc_sim": 0.9333333333333333, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [104, 107], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u905582793", "n_user": "u905582793", "pos": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ncnt = 2\nans = a[0]-1\nfor i in range(1,n):\n if a[i] == cnt:\n cnt += 1\n else:\n ans += (a[i]-1)//cnt\nprint(ans)", "neg": "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for i in range(n)]\ncnt = 1\nans = 0\nfor i in range(n):\n if a[i] = cnt+1:\n cnt += 1\n else:\n ans += (a[i]-1)//cnt\n if cnt == 1:\n cnt += 1\nprint(ans)", "jacc_sim": 0.9354838709677419, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [94, 101], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u334712262", "n_user": "u334712262", "pos": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\nINF = 2**62-1\n\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, A):\n a = A.pop(0)\n ans = a-1\n b = 2\n for a in A:\n if b == a:\n b += 1\n c = (a-1) // b\n ans += c\n return ans\n\n\ndef main():\n N = read_int()\n A = [read_int() for _ in range(N)]\n print(slv(N, A))\n\n\nif __name__ == '__main__':\n main()\n", "neg": "# -*- coding: utf-8 -*-\nimport bisect\nimport heapq\nimport math\nimport random\nimport sys\nfrom collections import Counter, defaultdict, deque\nfrom decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal\nfrom functools import lru_cache, reduce\nfrom itertools import combinations, combinations_with_replacement, product, permutations\nfrom operator import add, mul, sub\n\nsys.setrecursionlimit(100000)\ninput = sys.stdin.readline\nINF = 2**62-1\n\ndef read_int():\n return int(input())\n\n\ndef read_int_n():\n return list(map(int, input().split()))\n\n\ndef read_float():\n return float(input())\n\n\ndef read_float_n():\n return list(map(float, input().split()))\n\n\ndef read_str():\n return input().strip()\n\n\ndef read_str_n():\n return list(map(str, input().split()))\n\n\ndef error_print(*args):\n print(*args, file=sys.stderr)\n\n\ndef mt(f):\n import time\n\n def wrap(*args, **kwargs):\n s = time.time()\n ret = f(*args, **kwargs)\n e = time.time()\n\n error_print(e - s, 'sec')\n return ret\n\n return wrap\n\n\n@mt\ndef slv(N, A):\n\n ans = 0\n b = 0\n for a in A:\n p = b + 1\n c = (a-1) // p\n ans += c\n if c == 0:\n b = a\n if b == 0:\n b = 1\n print(a, b, c, ans)\n\n return ans\n\n\ndef main():\n N = read_int()\n A = [read_int() for _ in range(N)]\n print(slv(N, A))\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9801980198019802, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [461, 481], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u423585790", "n_user": "u423585790", "pos": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef LS(): return list(map(list, input().split()))\ndef S(): return list(input().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n ans = 0\n pre = 1\n for _ in range(II()):\n a = II()\n if pre > a:\n continue\n if a % pre:\n ans += a // pre\n continue\n if pre == a:\n pre += 1\n continue\n tmp = a // pre - 1\n ans += tmp\n if pre == 1:\n pre += 1\n print(ans)\n\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "neg": "#!/usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nfrom bisect import bisect_left, bisect_right\nimport sys, random, itertools, math\nsys.setrecursionlimit(10**5)\ninput = sys.stdin.readline\nsqrt = math.sqrt\ndef LI(): return list(map(int, input().split()))\ndef LF(): return list(map(float, input().split()))\ndef LI_(): return list(map(lambda x: int(x)-1, input().split()))\ndef II(): return int(input())\ndef IF(): return float(input())\ndef LS(): return list(map(list, input().split()))\ndef S(): return list(input().rstrip())\ndef IR(n): return [II() for _ in range(n)]\ndef LIR(n): return [LI() for _ in range(n)]\ndef FR(n): return [IF() for _ in range(n)]\ndef LFR(n): return [LI() for _ in range(n)]\ndef LIR_(n): return [LI_() for _ in range(n)]\ndef SR(n): return [S() for _ in range(n)]\ndef LSR(n): return [LS() for _ in range(n)]\nmod = 1000000007\ninf = 1e10\n\n#solve\ndef solve():\n ans = 0\n pre = 1\n for _ in range(II()):\n a = II()\n if pre > a:\n continue\n if a % pre:\n ans += a // pre\n continue\n if pre == a:\n pre += 1\n continue\n tmp = a // pre - 1\n ans += tmp\n print(ans)\n\n return\n\n\n#main\nif __name__ == '__main__':\n solve()\n", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [447, 435], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u415905784", "n_user": "u415905784", "pos": "N = int(input())\nA = [0] * N\nZ = 0\ncnt = 0\nfor i in range(N):\n a = int(input())\n if a > Z + 1:\n z = (a - 1) // (Z + 1)\n cnt += z\n a = 1\n Z = max(a, Z)\nprint(cnt)", "neg": "N = int(input())\nA = [0] * N\nZ = 0\ncnt = 0\nfor i in range(N):\n a = int(input())\n if a > Z + 1:\n z = (a - 1) // (Z + 1)\n cnt += z\n else:\n Z = max(a, Z)\nprint(cnt)", "jacc_sim": 0.9666666666666667, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [87, 86], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u794173881", "n_user": "u794173881", "pos": "n = int(input())\na = [int(input()) for i in range(n)]\na = a[::-1]\n\nans = 0\nnum = 1\n\nwhile a:\n if a[-1] < num:\n del a[-1]\n elif a[-1] == num:\n num += 1\n elif a[-1] > num:\n if a[-1] % num == 0:\n ans += a[-1] // num - 1\n a[-1] = 1\n else:\n ans += a[-1] // num\n a[-1] = 1\n\nprint(ans)", "neg": "n = int(input())\na = [int(input()) for i in range(n)]\na = a[::-1]\n\nans = 0\nnum = 1\n\nwhile a:\n if a[-1] == num:\n num += 1\n elif a[-1] > num:\n if a[-1] % num == 0:\n a[-1] = a[-1] - (num + 1)\n ans += 1\n ans += a[-1] // num\n else:\n ans += a[-1] // num\n del a[-1]\n\nprint(ans)", "jacc_sim": 0.9666666666666667, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [146, 141], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u731028462", "n_user": "u731028462", "pos": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nn = int(input())\narr = []\nfor i in range(n):\n arr.append(int(input()))\ncount = max(arr[0]-1,0)\nindex = 2\nfor i in range(1,n):\n if arr[i] > index:\n count += (arr[i] - 1) // index\n if arr[i] == index:\n index += 1\nprint(count)\n", "neg": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\nn = int(input())\narr = []\nfor i in range(n):\n arr.append(int(input()))\ncount = max(arr[0]-1,0)\nindex = 2\nfor a in arr:\n if a > index:\n count += (a - 1) // index\n if a == index:\n index += 1\nprint(count)", "jacc_sim": 0.975, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [127, 113], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u657357805", "n_user": "u657357805", "pos": "N=int(input())\na=[0]*N\nfor i in range(N):\n a[i]=int(input())\n\nminimum=2\ncount=a[0]-1\na.pop(0)\nfor i in a:\n if(minimum cnt:\n\t\tif now == cnt + 1: ## 0 ni nattyau\n\t\t\tcnt += 1\n\t\telse: ## now >= cnt + 2\n\t\t\tans += now // (cnt + 1)\n\t\t\tif now % (cnt + 1) == 0:\n\t\t\t\tans -= 1\n\nprint(ans)\n", "neg": "# def makelist(n, m):\n# \treturn [[0 for i in range(m)] for j in range(n)]\n\nn = int(input())\nA = [0]*N\nfor i in range(N):\n\tA[i] = int(input())\n\nans = A[0] - 1\nA[0] = 1\n\ncnt = 1\n# yobi = 1\n\nfor i in range(1, N):\n\tnow = A[i]\n\n\tif now > cnt:\n\t\tif now == cnt + 1: ## 0 ni nattyau\n\t\t\tcnt += 1\n\t\telse: ## now >= cnt + 2\n\t\t\tans += now // (cnt + 1)\n\t\t\tif now % (cnt + 1) == 0:\n\t\t\t\tans -= 1\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [191, 191], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03973", "p_user": "u477320129", "n_user": "u045939752", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]\nans = A[0] - 1\nm = 1\nfor a in A[1:]:\n if a == m + 1:\n m += 1\n else: \n ans += (a-1) // (m + 1)\nprint(ans)\n", "neg": "N = int(input())\nA = [ int(input()) for _ in range(N) ]\n\nans = 0\nm = 0\nfor a in A:\n if a == m+1:\n m = m + 1\n else:\n ans += (a - 1) // (m+1)\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Score: 700 points\nProblem Statement\nN people are waiting in a single line in front of the Takahashi Store. The cash on hand of the i-th person from the front of the line is a positive integer A_i. Mr. Takahashi, the shop owner, has decided on the following scheme: He picks a product, sets a positive integer P indicating its price, and shows this product to customers in order, starting from the front of the line. This step is repeated as described below. At each step, when a product is shown to a customer, if price P is equal to or less than the cash held by that customer at the time, the customer buys the product and Mr. Takahashi ends the current step. That is, the cash held by the first customer in line with cash equal to or greater than P decreases by P, and the next step begins. Mr. Takahashi can set the value of positive integer P independently at each step. He would like to sell as many products as possible. However, if a customer were to end up with 0 cash on hand after a purchase, that person would not have the fare to go home. Customers not being able to go home would be a problem for Mr. Takahashi, so he does not want anyone to end up with 0 cash. Help out Mr. Takahashi by writing a program that determines the maximum number of products he can sell, when the initial cash in possession of each customer is given.\nConstraints\n1 \u2266 N \u2266 100000\n1 \u2266 A_i \u2266 10^9 (1 \u2266 i \u2266 N)\nAll inputs are integers.\nInput\nInputs are provided from Standard Inputs in the following form.\nN\nA_1\n:\nA_N\nOutput\nOutput an integer representing the maximum number of products Mr. Takahashi can sell.\nSample Input 1\n3\n3\n2\n5\nSample Output 1\n3\nAs values of P, select in order 1, 4, 1.\nSample Input 2\n15\n3\n1\n4\n1\n5\n9\n2\n6\n5\n3\n5\n8\n9\n7\n9\nSample Output 2\n18", "before_after_length": [83, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03974", "p_user": "u557523358", "n_user": "u557523358", "pos": "from array import*;R=range;T=[0]*28;N=int(input());S=[[ord(C)-95 for C in input()]for _ in[0]*N];U=N*26**2*array('i',[0]);V=N*[0];Q=int(input())\nfor X in S:\n\tP=0\n\tfor C in X:\n\t\tif T[P+C]==0:T[P+C]=len(T);T+=[0]*28\n\t\tT[P]+=1;P=T[P+C]\n\tT[P]+=1;T[P+1]=1\nfor I in R(N):\n\tP=0\n\tfor C in S[I]:\n\t\tfor A in R(26):\n\t\t\tX=T[P+A+2]\n\t\t\tif(A!=C-2)*X:U[676*I+26*A+C-2]+=T[X]\n\t\tV[I]+=T[P+1]\n\t\tP=T[P+C]\nwhile Q:\n\tK,P=input().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]\n\tfor A in R(26):\n\t\tfor B in R(A+1,26):\n\t\t\tX+=U[676*K+26*P[A]+P[B]]\n\tprint(X);Q-=1", "neg": "import array;R=range;L=input;T=[0]*28;N=int(L());S=[];U=N*26**2*array.array('i',[0]);V=N*[0];Q=int(L())\nfor I in R(N):\n\tS+=[[ord(C)-95 for C in L()]];P=0\n\tfor C in S[I]:\n\t\tif T[P+C]==0:T[P+C]=len(T);T+=[0]*28\n\t\tT[P]+=1;P=T[P+C]\n\tT[P]+=1;T[P+1]=1\nwhile N:\n\tN-=1;P=0\n\tfor C in S[N]:\n\t\tfor A in R(26):\n\t\t\tX=T[P+A+2]\n\t\t\tif(A!=C-2)*X:U[676*N+26*A+C-2]+=T[X]\n\t\tV[N]+=T[P+1]\n\t\tP=T[P+C]\nwhile Q:\n\tK,P=L().split();K=int(K)-1;P=[ord(C)-97 for C in P];X=1+V[K]\n\tfor A in R(26):\n\t\tfor B in R(A+1,26):\n\t\t\tX+=U[676*K+26*P[A]+P[B]]\n\tprint(X);Q-=1", "jacc_sim": 0.9433962264150944, "nl": "You are given N strings of lowercase alphabets. Each string is unique. For Q queries, you are provided with an integer k and a permutation of the alphabet. Output the sequence of the k-th string among the N strings in lexicographical order based on the given permutation. Constraints: 1 \u2264 N,Q \u2264 100000, 1 \u2264 |S_i| \u2264 400000, 1 \u2264 k \u2264 N, and the permutations are of length 26. The input is provided in the form of N strings, followed by Q queries. Output Q lines, each indicating the sequence of the k-th string.", "before_after_length": [355, 362], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03975", "p_user": "u399721252", "n_user": "u399721252", "pos": "n, a, b = [ int(v) for v in input().split() ]\nans_list = []\nfor i in range(n):\n v = int(input())\n if not a <= v < b:\n ans_list.append(v)\nprint(len(ans_list))", "neg": "n, a, b = [ int(v) for v in input().split() ]\nans_list = []\nfor i in range(n):\n v = int(input())\n if a <= v < b:\n ans_list.append(v)\nprint(len(ans_list))\n", "jacc_sim": 0.9615384615384616, "nl": "You, a Kyoto University student, return for the second semester and hear a rumor about a barricade being placed before the start of the A-th class and removed before the start of the B-th class. Classes during the barricade will be canceled. Given N classes, each in a different period, find the number of classes you can attend. Constraints: 1 \u2264 N \u2264 1000, 1 \u2264 A < B \u2264 10^9, 1 \u2264 t_i \u2264 10^9 (distinct). Input: N, A, B, and t_i. Output: Number of classes you can attend.", "before_after_length": [70, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03975", "p_user": "u328755070", "n_user": "u328755070", "pos": "N, A, B = list(map(int, input().split()))\nt = [int(input()) for x in range(N)]\n\nans = 0\n\nfor i in range(N):\n if t[i] < A or t[i] >= B:\n continue\n else:\n ans += 1\n \n \nprint(N - ans)\n \n\n\n", "neg": "N, A, B = list(map(int, input().split()))\nt = [int(input()) for x in range(N)]\n\nans = 0\n\nfor i in range(N):\n if t[i] < A or t[i] > B:\n continue\n else:\n ans += 1\n \n \nprint(ans)\n \n\n", "jacc_sim": 0.9705882352941176, "nl": "You, a Kyoto University student, return for the second semester and hear a rumor about a barricade being placed before the start of the A-th class and removed before the start of the B-th class. Classes during the barricade will be canceled. Given N classes, each in a different period, find the number of classes you can attend. Constraints: 1 \u2264 N \u2264 1000, 1 \u2264 A < B \u2264 10^9, 1 \u2264 t_i \u2264 10^9 (distinct). Input: N, A, B, and t_i. Output: Number of classes you can attend.", "before_after_length": [90, 87], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03975", "p_user": "u005260772", "n_user": "u005260772", "pos": "a, b, c = map(int, input().split())\nans = 0\nfor i in range(a):\n n = int(input())\n if n < b or n >= c:\n ans += 1\nprint(ans)", "neg": "a, b, c = map(int, input().split())\nans = 0\nfor i in range(a):\n n = int(input())\n if n < b:\n ans += 1\nprint ans", "jacc_sim": 0.9259259259259259, "nl": "You, a Kyoto University student, return for the second semester and hear a rumor about a barricade being placed before the start of the A-th class and removed before the start of the B-th class. Classes during the barricade will be canceled. Given N classes, each in a different period, find the number of classes you can attend. Constraints: 1 \u2264 N \u2264 1000, 1 \u2264 A < B \u2264 10^9, 1 \u2264 t_i \u2264 10^9 (distinct). Input: N, A, B, and t_i. Output: Number of classes you can attend.", "before_after_length": [55, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03976", "p_user": "u375695365", "n_user": "u375695365", "pos": "import collections \nn,k=map(int,input().split())\np=[str(input()) for _ in range(n)]\nfor i in range(n):\n p[i]=p[i][0:1]\n#print(p)\nc=collections.Counter(p)\n#print(c)\na=[]\nfor v in c.values():\n a.append(v)\n#print(a)\na.sort(reverse=True)\nans=0\n\n\n#print(a)\nwhile True:\n a.sort(reverse=True)\n if k<=len(a):\n ans+=1\n for i in range(k):\n a[i]-=1\n for i in range(k-1,-1,-1):\n #print(a[i])\n if a[i]==0:\n a.pop(i)\n #print(a)\n else:\n break\n\nprint(ans)\n", "neg": "import collections \nn,k=map(int,input().split())\np=[str(input()) for _ in range(n)]\nfor i in range(n):\n p[i]=p[i][0:1]\n#print(p)\nc=collections.Counter(p)\n#print(c)\na=[]\nfor v in c.values():\n a.append(v)\n#print(a)\na.sort(reverse=True)\nans=0\n\n\n#print(a)\nwhile True:\n a.sort(reverse=True)\n if k<=len(a):\n ans+=1\n for i in range(k):\n a[i]-=1\n for i in range(k-1,-1,-1):\n print(a[i])\n if a[i]==0:\n a.pop(i)\n #print(a)\n else:\n break\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nKyoto University Programming Contest (KUPC) is organized by students. The committee has to divide N proposed problems into KUPCs, each containing K problems. Each problem can appear only once, and the first letters of the problem names in one KUPC must be different. Find the maximum number of KUPCs that can be held this year.\nConstraints:\n1 \u2264 N \u2264 10^4\n1 \u2264 K \u2264 26\n1 \u2264 |P_i| \u2264 10\nAll characters in P_i are capital letters.\nInput:\nThe input is given in the format: N K P_1 ... P_N\nOutput:\nPrint the maximum number of KUPCs that can be held.\nSample Input 1:\n9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\nSample Output 1:\n3\nSample Input 2:\n3 2\nKU\nKYOUDAI\nKYOTOUNIV\nSample Output 2:\n0", "before_after_length": [234, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03976", "p_user": "u145950990", "n_user": "u145950990", "pos": "n,k = map(int,input().split())\np = [input()[0] for i in range(n)]\nfrom collections import Counter\nc = Counter(p)\nv = sorted(list(c.values()),reverse=True)\nans = 0\nwhile len(v)>=k:\n for i in range(k):\n v[i] -= 1\n if v[i]<0:\n print(ans)\n exit()\n ans += 1\n v = sorted(v,reverse=True)\nprint(ans)", "neg": "n,k = map(int,input().split())\np = [input()[0] for i in range(n)]\nfrom collections import Counter\nc = Counter(p)\nv = sorted(list(c.values()),reverse=True)\nans = 0\nwhile len(v)>=k:\n for i in range(k):\n v[i] -= 1\n if v[i]<0:\n print(ans)\n exit()\n ans += 1\n v = sorted(v,reverse=True)", "jacc_sim": 1.0, "nl": "Score: 100 points\nProblem Statement:\nKyoto University Programming Contest (KUPC) is organized by students. The committee has to divide N proposed problems into KUPCs, each containing K problems. Each problem can appear only once, and the first letters of the problem names in one KUPC must be different. Find the maximum number of KUPCs that can be held this year.\nConstraints:\n1 \u2264 N \u2264 10^4\n1 \u2264 K \u2264 26\n1 \u2264 |P_i| \u2264 10\nAll characters in P_i are capital letters.\nInput:\nThe input is given in the format: N K P_1 ... P_N\nOutput:\nPrint the maximum number of KUPCs that can be held.\nSample Input 1:\n9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\nSample Output 1:\n3\nSample Input 2:\n3 2\nKU\nKYOUDAI\nKYOTOUNIV\nSample Output 2:\n0", "before_after_length": [129, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03976", "p_user": "u150117535", "n_user": "u150117535", "pos": "n,K=[int(x) for x in input().split()]\nans=0\nfrom collections import defaultdict\nd=defaultdict(int)\nfor i in [0]*n:\n d[input()[0]]+=1\nwhile True:\n for j,_ in zip(sorted(d.items(),key=lambda x:x[1],reverse=True),[0]*K):\n k,v=j\n if v==0 or len(d)= k:\n ans += 1\n for h, c in heads.most_common()[:k]:\n if c==1:\n heads.pop(h)\n else:\n heads[h] -= 1\nprint(ans)", "neg": "afrom collections import Counter\nn, k = map(int, input().split())\nps = [input() for _ in range(n)]\nheads = Counter((p[0] for p in ps))\nans = 0\nwhile len(heads) >= k:\n ans += 1\n for h, c in heads.most_common()[:k]:\n if c==1:\n heads.pop(h)\n else:\n heads[h] -= 1\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "Score: 100 points\nProblem Statement:\nKyoto University Programming Contest (KUPC) is organized by students. The committee has to divide N proposed problems into KUPCs, each containing K problems. Each problem can appear only once, and the first letters of the problem names in one KUPC must be different. Find the maximum number of KUPCs that can be held this year.\nConstraints:\n1 \u2264 N \u2264 10^4\n1 \u2264 K \u2264 26\n1 \u2264 |P_i| \u2264 10\nAll characters in P_i are capital letters.\nInput:\nThe input is given in the format: N K P_1 ... P_N\nOutput:\nPrint the maximum number of KUPCs that can be held.\nSample Input 1:\n9 3\nAPPLE\nANT\nATCODER\nBLOCK\nBULL\nBOSS\nCAT\nDOG\nEGG\nSample Output 1:\n3\nSample Input 2:\n3 2\nKU\nKYOUDAI\nKYOTOUNIV\nSample Output 2:\n0", "before_after_length": [110, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03977", "p_user": "u873915460", "n_user": "u873915460", "pos": "N,T=0,0\nfor i in range(int(input())):\n N,T=map(int,input().split())\n if N&1==0:\n T^=127\n print(T+(N-1)*127)", "neg": "N,T=0,0\nfor i in range(int(input())):\n N,T=map(int,input().split())\n if N&1:\n T^=127\n print(T+(N-1)*127)", "jacc_sim": 1.0, "nl": "You are given a Cookie Breeding Machine that takes a cookie with taste x and a non-negative integer y (0 <= y <= 127) as input. It generates two cookies with tastes y and (x XOR y). Starting with one cookie of taste D, you need to find the maximum sum of tastes of N cookies after N-1 operations. For each test case, you are given the number of operations N and the initial taste D. Output the maximum sum of tastes for each test case.", "before_after_length": [61, 59], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u980205854", "n_user": "u980205854", "pos": "# B - Minimum Sum\nN = int(input())\nA = list(enumerate(list(map(int,input().split()))))\nleft = [i-1 for i in range(N)]\nright = [i+1 for i in range(N)]\nA.sort(key=lambda x:x[1],reverse=True)\nans = 0\nfor i,a in A:\n il,ir = left[i],right[i]\n ans += a*(i-il)*(ir-i)\n if ir-1:\n right[il] = ir\nprint(ans)", "neg": "# B - Minimum Sum\nN = int(input())\nA = list(enumerate(list(map(int,input().split()))))\nleft = [i-1 for i in range(N)]\nright = [i+1 for i in range(N)]\nA.sort(key=lambda x:x[1],reverse=True)\nans = 0\nfor i,a in A:\n il,ir = left[i],right[i]\n ans += a*(i-il)*(ir-i)\n if ir0:\n right[il] = ir\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [155, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u340781749", "n_user": "u340781749", "pos": "import sys\nfrom operator import itemgetter\n\nn, *aaa = map(int, sys.stdin.buffer.read().split())\naaa_with_index = list(enumerate(aaa, start=1))\naaa_with_index.sort(key=itemgetter(1), reverse=True)\nleft = list(range(-1, n + 1))\nright = list(range(1, n + 3))\nans = 0\nfor i, a in aaa_with_index:\n li = left[i]\n ri = right[i]\n ans += a * (i - li) * (ri - i)\n left[ri] = li\n right[li] = ri\n\nprint(ans)\n", "neg": "import sys\nfrom operator import itemgetter\n\nn, *aaa = map(int, sys.stdin.buffer.read().split())\naaa_with_index = list(enumerate(aaa, start=1))\naaa_with_index.sort(key=itemgetter(1), reverse=True)\nleft = list(range(n + 2))\nright = left.copy()\nans = 0\nfor i, a in aaa_with_index:\n li = left[i]\n ri = right[i]\n ans += a * (i - li + 1) * (ri - i + 1)\n left[right[i + 1]] = li\n right[left[i - 1]] = ri\n\nprint(ans)\n", "jacc_sim": 0.9375, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [165, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u476604182", "n_user": "u476604182", "pos": "class BIT:\n def __init__(self,n):\n self.N = n\n self.data = [0]*(N+1)\n def bit_add(self,i,a):\n j = i+1\n while j<=N:\n self.data[j] += a\n j += j&-j\n def bit_sum(self,i):\n m = 0\n j = i+1\n while j>0:\n m += self.data[j]\n j -= j&-j\n return m\n def bit_search(self,x):\n i = 0\n m = 0\n j = 1<<(self.N.bit_length()-1)\n while j:\n if i+j<=N and self.data[i+j]+m<=x:\n i += j\n m += self.data[i]\n j >>= 1\n return i\nN, *A = map(int, open(0).read().split())\nbit = BIT(N)\nntoi = [0]*(N+1)\nans = 0\nfor i, a in enumerate(A):\n ntoi[a] = i\nfor i in range(1,N+1):\n j = ntoi[i]\n L = bit.bit_sum(j)\n R = N-L-1\n if L!=0:\n a = bit.bit_search(L-1)\n else:\n a = -1\n if R!=0:\n b = bit.bit_search(L)\n else:\n b = N\n ans += (j-a)*(b-j)*i\n bit.bit_add(j,1)\nprint(ans)", "neg": "class BIT:\n def __init__(self,n):\n self.N = n\n self.data = [0]*(N+1)\n def bit_add(self,i,a):\n j = i+1\n while j<=N:\n self.data[j] += a\n j += j&-j\n def bit_sum(self,i):\n m = 0\n j = i+1\n while j>0:\n m += self.data[j]\n j -= j&-j\n return m\n def bit_search(self,x):\n i = 0\n m = 0\n j = 1<<(self.N.bit_length()-1)\n while j:\n if i+j<=N and self.data[i+j]+m<=x:\n i += j\n m += self.data[i]\n j >>= 1\n return i\nN, *A = map(int, open('0').read().split())\nbit = BIT(N)\nntoi = [0]*(N+1)\nans = 0\nfor i, a in enumerate(A):\n ntoi[a] = i\nfor i in range(1,N+1):\n j = ntoi[i]\n L = bit.bit_sum(j)\n R = N-L-1\n if L!=0:\n a = bit.bit_search(L-1)\n else:\n a = -1\n if R!=0:\n b = bit.bit_search(L)\n else:\n b = N\n ans += (j-a)*(b-j)*i\n bit.bit_add(j,1)\nprint(ans)", "jacc_sim": 0.9824561403508771, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [419, 419], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n n = int(input())\n a = list(map(int, input().split()))\n a = sorted(list(enumerate(a)), key=lambda x: -x[1])\n L = [i for i in range(n+2)] # \u9023\u7d50\u6210\u5206\u306e\u3046\u3061\u4e00\u756a\u5de6\u306eindex\n R = [i for i in range(n+2)] # \u9023\u7d50\u6210\u5206\u306e\u3046\u3061\u4e00\u756a\u53f3\u306eindex\n ans = 0\n for i, j in a: # 1-index\u306a\u306e\u30671\u305a\u308c\u308b\n M = R[i+1] # \u9023\u7d50\u6210\u5206\u306e\u6700\u5927\u5024\n m = L[i+1] # \u9023\u7d50\u6210\u5206\u306e\u6700\u5c0f\u5024\n ans += j*(M-i)*(i+2-m) # \u8a08\u7b97\n R[m-1] = M # \u9023\u7d50\u6210\u5206\u306e\u5de6\u7aef\u306e\u66f4\u65b0\n L[M+1] = m # \u9023\u7d50\u6210\u5206\u306e\u53f3\u7aef\u306e\u66f4\u65b0\n print(ans)\n\n\nmain()", "neg": "def main():\n n = int(input())\n a = list(map(int, input().split()))\n a = sorted(list(enumerate(a)), key=lambda x: -x[1])\n L = [i for i in range(n+2)] # \u9023\u7d50\u6210\u5206\u306e\u3046\u3061\u4e00\u756a\u5de6\u306eindex\n R = [i for i in range(n+2)] # \u9023\u7d50\u6210\u5206\u306e\u3046\u3061\u4e00\u756a\u53f3\u306eindex\n ans = 0\n for i, j in a: # 1-index\u306a\u306e\u30671\u305a\u308c\u308b\n print(L, R)\n M = R[i+1] # \u9023\u7d50\u6210\u5206\u306e\u6700\u5927\u5024\n m = L[i+1] # \u9023\u7d50\u6210\u5206\u306e\u6700\u5c0f\u5024\n ans += j*(M-i)*(i+2-m) # \u8a08\u7b97\n R[m-1] = M # \u9023\u7d50\u6210\u5206\u306e\u5de6\u7aef\u306e\u66f4\u65b0\n L[M+1] = m # \u9023\u7d50\u6210\u5206\u306e\u53f3\u7aef\u306e\u66f4\u65b0\n print(ans)\n\n\nmain()", "jacc_sim": 1.0, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [389, 397], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u029169777", "n_user": "u029169777", "pos": "N=int(input())\na=list(map(int,input().split()))\n\nl=[]\nr=[]\ns=[]\n\nfor i,x in enumerate(a):\n left=i\n while len(s)>0 and x0 and x0 and x0 and x uf[rb]:\n ra,rb = rb,ra\n uf[ra] += uf[rb]\n uf[rb] = ra\n return True\n\nans = 0\nfor i in range(n,0,-1):\n left=right=0\n ind = d[i]\n\n if ind0 and a[ind] < a[ind-1]:\n left -= uf[root(ind-1)]\n unite(ind, ind-1)\n ans += i*(left+1)*(right+1)\n\nprint(ans)", "neg": "n = int(input())\na = list(map(int, input().split()))\nd = {}\nfor i,j in enumerate(a):\n d[j] = i\n\nuf = [-1]*n\ndef root(a):\n if uf[a] < 0:\n return a\n uf[a] = root(uf[a])\n return uf[a]\ndef unite(a,b):\n ra,rb = root(a),root(b)\n if ra==rb:\n return False\n if uf[ra] > uf[rb]:\n ra,rb = rb,ra\n uf[ra] += uf[rb]\n uf[rb] = ra\n return True\n\nans = 0\nfor i in range(n,0,-1):\n left=right=0\n ind = d[i]\n\n if ind0 and a[ind] < a[ind-1]:\n left -= uf[ind-1]\n unite(ind, ind-1)\n ans += i*(left+1)*(right+1)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [317, 313], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import Counter\n\ndef main():\n N = II()\n A = LI()\n idxs = [0] * (N + 1)\n for i, a in enumerate(A):\n idxs[a] = i\n ll = list(range(N + 1))\n rr = list(range(N + 1))\n ans = 0\n for a in range(N, 0, -1):\n idx = idxs[a]\n l, r = ll[idx], rr[idx]\n ans += (idx - l + 1) * (r - idx + 1) * a\n ll[r + 1] = l\n rr[l - 1] = r\n\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import Counter\n\ndef main():\n N = II()\n A = LI()\n idxs = [0] * (N + 1)\n for i, a in enumerate(A):\n idxs[a] = i\n ll = list(range(N + 1))\n rr = list(range(N + 1))\n ans = 0\n for a in range(N, 0, -1):\n idx = idxs[a]\n l, r = ll[idx], rr[idx]\n ans += (idx - l + 1) * (r - idx + 1) * a\n ll[idx + 1] = l\n rr[idx - 1] = r\n\n return ans\n\nprint(main())", "jacc_sim": 1.0, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [306, 306], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u270681687", "n_user": "u077337864", "pos": "import heapq\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nd = {}\nfor i, a_ in enumerate(a):\n d[a_] = i\n\n\nh = []\nright = [n-1] * n\n\nfor i in range(n):\n while h and -h[0] > a[i]:\n v = -heapq.heappop(h)\n right[d[v]] = i - 1\n heapq.heappush(h, -a[i])\n\nh = []\nleft = [0] * n\n\nfor i in reversed(range(n)):\n while h and -h[0] > a[i]:\n v = -heapq.heappop(h)\n left[d[v]] = i + 1\n heapq.heappush(h, -a[i])\n\nans = 0\nfor i in range(n):\n ans += a[i] * (i - left[i] + 1) * (right[i] - i + 1)\n\nprint(ans)\n\n\n\n", "neg": "import heapq\n\nn = int(input())\nalist = list(map(int, input().split()))\n\nad = {}\nfor i, a in enumerate(alist):\n ad[a] = i\n\nh = []\nright = [n-1] * n\n\nfor i in range(n):\n while h and -h[0] > alist[i]:\n v = -heapq.heappop(h)\n right[ad[v]] = i - 1\n heapq.heappush(h, -alist[i])\n print(right, h)\n\nh = []\nleft = [0] * n\n\nfor i in reversed(range(n)):\n while h and -h[0] > alist[i]:\n v = -heapq.heappop(h)\n left[ad[v]] = i + 1\n heapq.heappush(h, -alist[i])\n print(left, h)\n\nans = 0\nfor i in range(n):\n ans += alist[i] * (i - left[i] + 1) * (right[i] - i + 1)\n print(ans)\n\nprint(ans)\n", "jacc_sim": 0.9111111111111111, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [268, 290], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03987", "p_user": "u098968285", "n_user": "u098968285", "pos": "# def makelist(n, m):\n# \treturn [[0 for i in range(m)] for j in range(n)]\n\n# a = int(input())\n# b, c = map(int, input().split())\n# s = input()\n\n\npar = [0]*202020\nsize = [0]*202020\n\ndef find(x):\n\tif par[x] == x:\n\t\treturn x\n\telse:\n\t\tpar[x] = find(par[x])\n\t\treturn par[x]\n\ndef unite(x, y):\n\tx = find(x)\n\ty = find(y)\n\tres = size[x] * size[y]\n\tsize[x] += size[y]\n\tpar[y] = x\n\treturn res\n\n# main\nn = int(input())\nfor i in range(202020):\n\tpar[i] = i\n\tsize[i] = 1\n\na = [0] + list(map(int, input().split()))\nb = [0]*(n+1)\nfor i in range(1, n+1):\n\tb[a[i]] = i\n\nans = 0\nfor j in reversed(range(1, n+1)):\n\ti = b[j]\n\tans += a[i]\n\tif i - 1 >= 1 and a[i-1] > a[i]:\n\t\tans += unite(i-1, i) * a[i]\n\tif i + 1 <= n and a[i+1] > a[i]:\n\t\tans += unite(i+1, i) * a[i]\nprint(ans)\n", "neg": "# def makelist(n, m):\n# \treturn [[0 for i in range(m)] for j in range(n)]\n\n# a = int(input())\n# b, c = map(int, input().split())\n# s = input()\n\n\npar = [0]*202020\nsize = [0]*202020\n\ndef find(x):\n\tif par[x] == x:\n\t\treturn x\n\telse:\n\t\tpar[x] = find(par[x])\n\t\treturn par[x]\n\ndef unite(x, y):\n\tx = find(x)\n\ty = find(y)\n\tres = size[x] * size[y]\n\tsize[x] += size[y]\n\tpar[y] = x\n\treturn res\n\n# main\nn = int(input())\nfor i in range(202020):\n\tpar[i] = i\n\tsize[i] = 1\n\na = [0] + list(map(int, input().split()))\nb = [0]*(n+1)\nfor i in range(1, n+1):\n\tb[a[i]] = i\n\nans = 0\nfor j in reversed(1, n+1):\n\ti = b[j]\n\tans += a[i]\n\tif i - 1 >= 1 and a[i-1] > a[i]:\n\t\tans += unite(i-1, i) * a[i]\n\tif i + 1 <= n and a[i+1] > a[i]:\n\t\tans += unite(i+1, i) * a[i]\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Score: 400 points\n\nProblem Statement:\nOne day, Snuke was given a permutation of length N, a_1, a_2, ..., a_N, from his friend. Find the following:\n\nConstraints:\n- 1 \u2266 N \u2266 200,000\n- (a_1, a_2, ..., a_N) is a permutation of (1, 2, ..., N).\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nPrint the answer.\nNote that the answer may not fit into a 32-bit integer.\n\nSample Input 1:\n3\n2 1 3\n\nSample Output 1:\n9\n\nSample Input 2:\n4\n1 3 2 4\n\nSample Output 2:\n19\n\nSample Input 3:\n8\n5 4 8 1 2 6 7 3\n\nSample Output 3:\n85", "before_after_length": [398, 395], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03988", "p_user": "u046158516", "n_user": "u046158516", "pos": "import sys\nn=int(input())\na=list(map(int,input().split()))\na.sort()\nmaxlen=a[-1]\nthing={}\nfor i in range(n):\n if a[i] in thing:\n thing[a[i]]+=1\n else:\n thing[a[i]]=1\n \nif maxlen%2==1:\n if not (maxlen+1)//2 in thing:\n print('Impossible')\n sys.exit()\n if thing[(maxlen+1)//2]!=2:\n print('Impossible')\n sys.exit()\nif maxlen%2==0:\n if not (maxlen+1)//2 in thing:\n print('Impossible')\n sys.exit()\n if thing[(maxlen+1)//2]!=1:\n print('Impossible')\n sys.exit()\nfor i in thing:\n if i==(maxlen+1)//2:\n continue\n if i<(maxlen+1)//2:\n print('Impossible')\n sys.exit()\n if thing[i]<2:\n print('Impossible')\n sys.exit()\nfor i in range((maxlen+1)//2,maxlen):\n if not i in thing:\n print('Impossible')\n sys.exit()\nprint('Possible')", "neg": "import sys\nn=int(input())\na=list(map(int,input().split()))\na.sort()\nmaxlen=a[-1]\nthing={}\nfor i in range(n):\n if a[i] in thing:\n thing[a[i]]+=1\n else:\n thing[a[i]]=1\nif maxlen%2==1:\n if not (maxlen+1)//2 in thing:\n print('Impossible')\n sys.exit()\n if thing[(maxlen+1)//2]!=2:\n print('Impossible')\n sys.exit()\nif maxlen%2==0:\n if not (maxlen+1)//2 in thing:\n print('Impossible')\n sys.exit()\n if thing[(maxlen+1)//2]!=1:\n print('Impossible')\n sys.exit()\nfor i in thing:\n if i<(maxlen+1)//2:\n print('Impossible')\n sys.exit()\n if thing[i]<2:\n print('Impossible')\n sys.exit()\nprint('Possible')", "jacc_sim": 0.9772727272727273, "nl": "Aoki loves numerical sequences and trees. Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1. Determine whether such a tree exists.\n\nConstraints:\n- 2 \u2264 N \u2264 100\n- 1 \u2264 a_i \u2264 N-1\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf there exists a tree that satisfies the condition, print \"Possible\". Otherwise, print \"Impossible\".\n\nSample Input 1:\n5\n3 2 2 3 3\n\nSample Output 1:\nPossible\n\nSample Input 2:\n3\n1 1 2\n\nSample Output 2:\nImpossible\n\nSample Input 3:\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3:\nPossible\n\nSample Input 4:\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4:\nImpossible\n\nSample Input 5:\n6\n1 1 1 1 1 5\n\nSample Output 5:\nImpossible\n\nSample Input 6:\n5\n4 3 2 3 4\n\nSample Output 6:\nPossible", "before_after_length": [334, 277], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03988", "p_user": "u169350228", "n_user": "u169350228", "pos": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n = int(ipt())\n a = [int(i) for i in ipt().split()]\n a.sort(reverse=True)\n res = []\n k = a[0]\n d = defaultdict(int)\n for i in a:\n d[i] += 1\n if k&1:\n if a[-1] <= k//2:\n print(\"Impossible\")\n exit()\n if d[k//2+1] != 2:\n print(\"Impossible\")\n exit()\n for i in range(k//2+2,k+1):\n if d[i] < 2:\n print(\"Impossible\")\n exit()\n else:\n if a[-1] < k//2:\n print(\"Impossible\")\n exit()\n if d[k//2] != 1:\n print(\"Impossible\")\n exit()\n for i in range(k//2+1,k+1):\n if d[i] < 2:\n print(\"Impossible\")\n exit()\n print(\"Possible\")\n\n\n\n return\n\nif __name__ == '__main__':\n main()\n", "neg": "import math\n#import numpy as np\nimport queue\nfrom collections import deque,defaultdict\nimport heapq as hpq\nfrom sys import stdin,setrecursionlimit\n#from scipy.sparse.csgraph import dijkstra\n#from scipy.sparse import csr_matrix\nipt = stdin.readline\nsetrecursionlimit(10**7)\n\ndef main():\n n = int(ipt())\n a = [int(i) for i in ipt().split()]\n a.sort(reverse=True)\n res = []\n k = a[0]\n if a[-1] < k//2:\n print(\"Impossible\")\n exit()\n d = defaultdict(int)\n for i in a:\n d[i] += 1\n if k&1:\n if d[k//2+1] != 2:\n print(\"Impossoble\")\n exit()\n for i in range(k//2+2,k+1):\n if d[i] < 2:\n print(\"Impossoble\")\n exit()\n else:\n if d[k//2] != 1:\n print(\"Impossible\")\n exit()\n for i in range(k//2+1,k+1):\n if d[i] < 2:\n print(\"Impossoble\")\n exit()\n print(\"Possoble\")\n\n\n\n return\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9577464788732394, "nl": "Aoki loves numerical sequences and trees. Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1. Determine whether such a tree exists.\n\nConstraints:\n- 2 \u2264 N \u2264 100\n- 1 \u2264 a_i \u2264 N-1\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf there exists a tree that satisfies the condition, print \"Possible\". Otherwise, print \"Impossible\".\n\nSample Input 1:\n5\n3 2 2 3 3\n\nSample Output 1:\nPossible\n\nSample Input 2:\n3\n1 1 2\n\nSample Output 2:\nImpossible\n\nSample Input 3:\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3:\nPossible\n\nSample Input 4:\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4:\nImpossible\n\nSample Input 5:\n6\n1 1 1 1 1 5\n\nSample Output 5:\nImpossible\n\nSample Input 6:\n5\n4 3 2 3 4\n\nSample Output 6:\nPossible", "before_after_length": [361, 350], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03988", "p_user": "u423585790", "n_user": "u423585790", "pos": "n = int(input())\na = list(map(int, input().split()))\nx = sorted(set(a))\nif (max(a) - 1) // 2 + 1 == min(a):\n if max(a) & 1:\n m = m = a.count(x[0]) != 2\n for i in range(x[0],x[-1]+1):\n if a.count(i) < 2: m = 1\n if m:\n print(\"Impossible\")\n else:\n print(\"Possible\")\n else:\n m = a.count(x[0]) != 1\n for i in range(x[0]+1,x[-1]+1):\n if a.count(i) < 2: m = 1\n if m:\n print(\"Impossible\")\n else:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "neg": "n = int(input())\na = list(map(int, input().split()))\nx = sorted(set(a))\nif (max(a) - 1) // 2 + 1 == min(a):\n if max(a) & 1:\n m = 0\n for i in range(x[0],m[-1]+1):\n if a.count(i) < 2: m = 1\n if m:\n print(\"Impossible\")\n else:\n print(\"Possible\")\n else:\n m = a.count(x[0]) != 1\n for i in range(x[0]+1,m[-1]+1):\n if a.count(i) < 2: m = 1\n if m:\n print(\"Impossible\")\n else:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "jacc_sim": 1.0, "nl": "Aoki loves numerical sequences and trees. Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1. Determine whether such a tree exists.\n\nConstraints:\n- 2 \u2264 N \u2264 100\n- 1 \u2264 a_i \u2264 N-1\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf there exists a tree that satisfies the condition, print \"Possible\". Otherwise, print \"Impossible\".\n\nSample Input 1:\n5\n3 2 2 3 3\n\nSample Output 1:\nPossible\n\nSample Input 2:\n3\n1 1 2\n\nSample Output 2:\nImpossible\n\nSample Input 3:\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3:\nPossible\n\nSample Input 4:\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4:\nImpossible\n\nSample Input 5:\n6\n1 1 1 1 1 5\n\nSample Output 5:\nImpossible\n\nSample Input 6:\n5\n4 3 2 3 4\n\nSample Output 6:\nPossible", "before_after_length": [213, 201], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03988", "p_user": "u532966492", "n_user": "u532966492", "pos": "def main():\n from collections import Counter as ct\n n = int(input())\n a = list(map(int, input().split()))\n c = ct(a)\n min_a = min(a)\n max_a = max(a)\n if min_a == 1:\n if c[min_a] == 1:\n pass\n elif a == [1, 1]:\n print(\"Possible\")\n return 0\n else:\n print(\"Impossible\")\n return 0\n if c[min_a] == 1 and (max_a+1)//2 > min_a:\n print(\"Impossible\")\n return 0\n if c[min_a] == 2 and (max_a+2)//2 > min_a:\n print(\"Impossible\")\n return 0\n if c[min_a] > 2:\n print(\"Impossible\")\n return 0\n for i in range(min_a+1, max_a+1):\n if c[i] < 2:\n print(\"Impossible\")\n return 0\n print(\"Possible\")\nmain()", "neg": "def main():\n from collections import Counter as ct\n n = int(input())\n a = list(map(int, input().split()))\n c = ct(a)\n min_a = min(a)\n max_a = max(a)\n if min_a == 1:\n if c[min_a] == 1:\n pass\n elif a == [1, 1]:\n print(\"Possible\")\n return 0\n else:\n print(\"Impossible\")\n return 0\n if c[min_a] == 1 and (max_a+1)//2 > min_a:\n print(\"Impossible\")\n return 0\n if c[min_a] == 2 and (max_a+2)//2 > min_a:\n print(\"Impossible\")\n return 0\n if c[min_a] > 2:\n print(\"Impossible\")\n return 0\n for i in range(min_a+1, max_a+1):\n if c[i] < 2:\n print(\"Impossible\")\n return 0\n print(\"Possible\")", "jacc_sim": 1.0, "nl": "Aoki loves numerical sequences and trees. Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1. Determine whether such a tree exists.\n\nConstraints:\n- 2 \u2264 N \u2264 100\n- 1 \u2264 a_i \u2264 N-1\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf there exists a tree that satisfies the condition, print \"Possible\". Otherwise, print \"Impossible\".\n\nSample Input 1:\n5\n3 2 2 3 3\n\nSample Output 1:\nPossible\n\nSample Input 2:\n3\n1 1 2\n\nSample Output 2:\nImpossible\n\nSample Input 3:\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3:\nPossible\n\nSample Input 4:\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4:\nImpossible\n\nSample Input 5:\n6\n1 1 1 1 1 5\n\nSample Output 5:\nImpossible\n\nSample Input 6:\n5\n4 3 2 3 4\n\nSample Output 6:\nPossible", "before_after_length": [267, 264], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03988", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**10\nmod = 10**9 + 7\n\ndef f():\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n i = 1\n if n > 2 and a[-1] == 1:\n return 'Impossible'\n if a[-1] != a[-2]:\n return 'Impossible'\n if a[-1] % 2 == 1:\n if a[-1] // 2 + 1 != a[0]:\n return 'Impossible'\n if a[0] != a[1]:\n return 'Impossible'\n if n > 2 and a[0] == a[2]:\n return 'Impossible'\n i = 2\n else:\n if a[-1] // 2 != a[0]:\n return 'Impossible'\n if a[0] == a[1]:\n return 'Impossible'\n c = 2\n t = a[0]\n for j in range(i,n):\n if t != a[j]:\n if c < 2:\n return 'Impossible'\n if t + 1 != a[j]:\n return 'Impossible'\n c = 0\n t = a[j]\n c += 1\n return 'Possible'\n\nprint(f())\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**10\nmod = 10**9 + 7\n\ndef f():\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n i = 1\n if a[0] < 2:\n return 'Impossible'\n if n > 2 and a[-1] == 1:\n return 'Impossible'\n if a[-1] != a[-2]:\n return 'Impossible'\n if a[-1] % 2 == 1:\n if a[-1] // 2 + 1 != a[0]:\n return 'Impossible'\n if a[0] != a[1]:\n return 'Impossible'\n i = 2\n else:\n if a[-1] // 2 != a[0]:\n return 'Impossible'\n if a[0] == a[1]:\n return 'Impossible'\n c = 2\n t = a[0]\n for j in range(i,n):\n if t != a[j]:\n if c < 2:\n return 'Impossible'\n c = 0\n t = a[j]\n c += 1\n return 'Possible'\n\nprint(f())\n", "jacc_sim": 1.0, "nl": "Aoki loves numerical sequences and trees. Takahashi gave him an integer sequence of length N, a_1, a_2, ..., a_N, which made him want to construct a tree. Aoki wants to construct a tree with N vertices numbered 1 through N, such that for each i = 1,2,...,N, the distance between vertex i and the farthest vertex from it is a_i, assuming that the length of each edge is 1. Determine whether such a tree exists.\n\nConstraints:\n- 2 \u2264 N \u2264 100\n- 1 \u2264 a_i \u2264 N-1\n\nInput:\nThe input is given from Standard Input in the following format:\nN\na_1 a_2 ... a_N\n\nOutput:\nIf there exists a tree that satisfies the condition, print \"Possible\". Otherwise, print \"Impossible\".\n\nSample Input 1:\n5\n3 2 2 3 3\n\nSample Output 1:\nPossible\n\nSample Input 2:\n3\n1 1 2\n\nSample Output 2:\nImpossible\n\nSample Input 3:\n10\n1 2 2 2 2 2 2 2 2 2\n\nSample Output 3:\nPossible\n\nSample Input 4:\n10\n1 1 2 2 2 2 2 2 2 2\n\nSample Output 4:\nImpossible\n\nSample Input 5:\n6\n1 1 1 1 1 5\n\nSample Output 5:\nImpossible\n\nSample Input 6:\n5\n4 3 2 3 4\n\nSample Output 6:\nPossible", "before_after_length": [356, 332], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u397953026", "n_user": "u397953026", "pos": "s = str(input())\nprint(s[:4]+\" \"+s[4:],sep = \"\")", "neg": "s = str(input())\nprint(s[:4]+\" \"+s[5:],sep = \"\")", "jacc_sim": 0.9375, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [24, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u290187182", "n_user": "u290187182", "pos": "import sys\nimport copy\nimport math\nimport bisect\nimport pprint\nimport bisect\nfrom functools import reduce\nfrom copy import deepcopy\nfrom collections import deque\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\nif __name__ == '__main__':\n a = [str(i) for i in input().split()]\n print(a[0][:4]+\" \"+a[0][4:])\n", "neg": "import sys\nimport copy\nimport math\nimport bisect\nimport pprint\nimport bisect\nfrom functools import reduce\nfrom copy import deepcopy\nfrom collections import deque\n\ndef lcm(x, y):\n return (x * y) // math.gcd(x, y)\n\nif __name__ == '__main__':\n a = [str(i) for i in input().split()]\n print(a[0][:4]+\" \"+a[0][5:])\n", "jacc_sim": 0.9772727272727273, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [109, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u577914737", "n_user": "u577914737", "pos": "a = input()\na_first, a_last = a[:4], a[4:]\nprint(a_first + ' ' + a_last)\n", "neg": "a = input()\na_first, a_last = s[:4], s[4:]\nprint(a_first + ' ' + a_last)", "jacc_sim": 0.9375, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [36, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u727787724", "n_user": "u727787724", "pos": "s=list(input())\na=s[0]+s[1]+s[2]+s[3]\nb=''\nfor i in range(8):\n b+=s[4+i]\nprint(a,b)\n", "neg": "s=list(input())\na=s[0]+s[1]+s[2]+s[3]\nb=''\nfor i in range(8):\n b=s[4+i]\nprint(a,b)", "jacc_sim": 1.0, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [56, 54], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u396495667", "n_user": "u396495667", "pos": "s = list(input())\nf= ''.join(s[:4])\nb=''.join(s[4:])\nprint(f,b,sep=' ')", "neg": "s = list(input())\nf= ''.join(s[:4])\nb=''.join(s[4:])\nprint(f,'',b)", "jacc_sim": 0.9444444444444444, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [38, 36], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u366959492", "n_user": "u357751375", "pos": "s=list(input())\ns.insert(4,\" \")\nprint(\"\".join(s))\n", "neg": "s = list(input())\ns = s.insert(4,' ')\nprint(''.join(s))\n", "jacc_sim": 1.0, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [23, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u921773161", "n_user": "u921773161", "pos": "a = input()\nans = a[:4] + ' ' + a[4:]\nprint(ans)\n", "neg": "a = list(input())\nans = a[:4] + ' ' + a[4:]\nprint(a)", "jacc_sim": 0.9285714285714286, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [25, 26], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u163320134", "n_user": "u163320134", "pos": "s=input()\nprint('{} {}'.format(s[:4],s[4:]))", "neg": "s=input()\nprint('{} {}'.format(s[:4],s[5:]))", "jacc_sim": 0.9411764705882353, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [21, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u185896732", "n_user": "u414458988", "pos": "s=input()\nprint(s[:4],s[4:],sep=' ')", "neg": "s=input()\nprint(s[:4],'',s[4:])", "jacc_sim": 0.9230769230769231, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [19, 18], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u667024514", "n_user": "u667024514", "pos": "s = str(input())\nprint(s[0:4] + \" \" + s[4:])\n", "neg": "s = str(input())\nprint(s[0:3] + \" \" + s[4:])", "jacc_sim": 0.9333333333333333, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [25, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u562016607", "n_user": "u503111914", "pos": "S=input()\nprint(S[:4],S[4:])\n", "neg": "S = input()\nprint(S[:3],S[4:])", "jacc_sim": 0.9166666666666666, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [17, 16], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u373026530", "n_user": "u223904637", "pos": "s = list(input())\ns = s[:4] + [' '] + s[4:]\nprint(''.join(s))\n", "neg": "s=list(input())\n\nprint(''.join(s[0:4]+' '+''.join(s[4:])", "jacc_sim": 0.9375, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [30, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u664481257", "n_user": "u664481257", "pos": "# -*- coding: utf-8 -*-\n# !/usr/bin/env python\n# vim: set fileencoding=utf-8 :\n\n\"\"\"\n#\n# Author: Noname\n# URL: https://github.com/pettan0818\n# License: MIT License\n# Created: 2016-09-28\n#\n\n# Usage\n#\n\"\"\"\nfrom __future__ import division\nfrom __future__ import unicode_literals\nfrom __future__ import print_function\nfrom __future__ import absolute_import\n\ndef input_process():\n \"\"\"Receive Inputs.\"\"\"\n return input()\n\n\ndef insert_space(target_str: str) -> str:\n \"\"\"\n >>> insert_space(\"codefestival\")\n code festival\n \"\"\"\n return target_str[0:4] + \" \" + target_str[4:]\n\nif __name__ == \"__main__\":\n target = input()\n\n print(insert_space(target))\n", "neg": "# -*- coding: utf-8 -*-\n# !/usr/bin/env python\n# vim: set fileencoding=utf-8 :\n\n\"\"\"\n#\n# Author: Noname\n# URL: https://github.com/pettan0818\n# License: MIT License\n# Created: 2016-09-28\n#\n\n# Usage\n#\n\"\"\"\nfrom __future__ import division\nfrom __future__ import unicode_literals\nfrom __future__ import print_function\nfrom __future__ import absolute_import\n\ndef input_process():\n \"\"\"Receive Inputs.\"\"\"\n return input()\n\n\ndef insert_space(target_str: str) -> str:\n \"\"\"\n >>> insert_space(\"codefestival\")\n code festival\n \"\"\"\n return target_str[0:3] + \" \" + target_str[3:]\n\nif __name__ == \"__main__\":\n target = input()\n\n print(insert_space(target))\n", "jacc_sim": 0.9696969696969697, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [234, 234], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u514051363", "n_user": "u091855288", "pos": "s = input()\nprint(\"{0} {1}\".format(s[:4], s[4:]))", "neg": "s = input()\nprint('{0] {1}'.format(s[:4],s[4:]))", "jacc_sim": 1.0, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [25, 25], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u125205981", "n_user": "u541475502", "pos": "s = str(input())\nprint(s[:4], s[4:])\n", "neg": "s = input()\nprint(s)\nprint(s[:4],s[4:])", "jacc_sim": 0.9166666666666666, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [19, 21], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u422104747", "n_user": "u422104747", "pos": "s=input()\nss=s[0:4]+\" \"+s[4:]\nprint(ss)", "neg": "s=input\nss=s[0:3]+\" \"+s[4:]\nprint(ss)", "jacc_sim": 0.9333333333333333, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [24, 23], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u635974378", "n_user": "u230180492", "pos": "s = input()\n\nprint(s[:4] + ' ' + s[4:])\n", "neg": "s=input()\ns[:4]+\" \"+s[4:]", "jacc_sim": 0.9166666666666666, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [22, 15], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u393971002", "n_user": "u282721391", "pos": "s = input()\nprint(s[:4], end=\"\")\nprint(\" \", end=\"\")\nprint(s[4:])\n", "neg": "s = input('input')\nprint(s[0:4], end=' ')\nprint(s[4:], end='')", "jacc_sim": 0.9285714285714286, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [30, 29], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u579299997", "n_user": "u842303434", "pos": "s = input()\nanswer = s[:4] + ' ' + s[4:]\nprint(answer)\n", "neg": "s = input()\ns = s[:4] + ' ' s[4:]\nprint(s)", "jacc_sim": 0.9230769230769231, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [25, 24], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03992", "p_user": "u010733367", "n_user": "u086503932", "pos": "S = input()\nprint(S[:4] + \" \" + S[4:])\n", "neg": "s = input()\nprint(S[:4]+' '+S[4:])", "jacc_sim": 0.9230769230769231, "nl": "You are given a string of 12 uppercase English letters. Output the string with a single space between the first 4 letters and the last 8 letters. For example, \"CODEFESTIVAL\" should be output as \"CODE FESTIVAL\".", "before_after_length": [21, 17], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p03995", "p_user": "u436484848", "n_user": "u436484848", "pos": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# D-Grid and Integers\n\nfrom collections import defaultdict\nimport sys\nsys.setrecursionlimit(10**6)\n\ndef ReadInput():\n\treturn [int(i) for i in input().split(\" \")]\n\n(R, C) = ReadInput()\nN = int(input())\nVectorSet = set() \nGrid = defaultdict(list)\nfor i in range(N):\n\t(r, c, a) = ReadInput()\n\tGrid[(\"R\", r)].append(((\"C\", c), a))\n\tGrid[(\"C\", c)].append(((\"R\", r), a))\n\tVectorSet.add((\"R\", r))\n\tVectorSet.add((\"C\", c))\n\ndef iteration(vector):\n\tVectorSet.discard(vector)\n\tfor (v, a) in Grid[vector]:\n\t\ttemp = a - VectorCover[vector]\n\t\tif (v in VectorCover):\n\t\t\tif(temp != VectorCover[v]):\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telse:\n\t\t\tVectorCover[v] = temp\n\t\t\titeration(v) \n\nwhile(len(VectorSet) != 0):\n\tvector = VectorSet.pop()\n\tVectorCover = dict() \n\tVectorCover[vector] = 0\n\titeration(vector)\n\tminR = min(a for (p, a) in VectorCover.items() if (p[0] == \"R\"))\n\tminC = min(a for (p, a) in VectorCover.items() if (p[0] == \"C\"))\n\tif (minR + minC < 0):\n\t\tprint(\"No\")\n\t\texit()\n\nprint(\"Yes\")", "neg": "\n#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# D-Grid and Integers\n\nfrom collections import defaultdict\n\ndef ReadInput():\n\treturn [int(i) for i in input().split(\" \")]\n\n(R, C) = ReadInput()\nN = int(input())\nVectorCover = defaultdict(int)\nVectorSet = set() \nGrid = defaultdict(list)\nfor i in range(N):\n\t(r, c, a) = ReadInput()\n\tGrid[(\"R\", r)].append(((\"C\", c), a))\n\tGrid[(\"R\", c)].append(((\"R\", r), a))\n\tVectorSet.add(('R', r))\n\tVectorSet.add(('C', c))\n\ndef iteration(vector):\n\tVectorSet.discard(vector)\n\tfor (v, a) in Grid[vector]:\n\t\ttemp = a - VectorCover[vector]\n\t\tif (v in VectorCover):\n\t\t\tif(temp is not VectorCover[v]):\n\t\t\t\tprint(\"No\")\n\t\t\t\texit()\n\t\telse:\n\t\t\tVectorCover[v] = temp\n\t\t\titeration(v) \n\nwhile(len(VectorSet) is not 0):\n\tvector = VectorSet.pop()\n\tVectorCover[vector] = 0\n\titeration(vector)\n\tminR = min(a for (p, a) in VectorCover.items() if (p[0] is \"R\"))\n\tminC = min(a for (p, a) in VectorCover.items() if (p[0] is \"C\"))\n\tif (minR + minC < 0):\n\t\tprint(\"No\")\n\t\texit()\n\t\t\nprint(\"Yes\")", "jacc_sim": 0.9125, "nl": "You are given a grid with R rows and C columns. Some cells already contain non-negative integers. You need to fill the remaining cells with non-negative integers such that for any 2x2 square formed by cells on the grid, the sum of the top left and bottom right integers equals the sum of the top right and bottom left integers. Determine if it's possible to meet these conditions. If possible, print \"Yes\"; otherwise, print \"No\".", "before_after_length": [423, 414], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u843135954", "n_user": "u843135954", "pos": "import sys\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,x = na()\na = na()\ndp = [i for i in a]\nans = sum(dp)\n\nfor i in range(1,n):\n for j in range(n):\n dp[(j+i)%n] = min(dp[(j+i)%n], a[j])\n ans = min(ans, sum(dp)+x*i)\n\nprint(ans)", "neg": "import sys\nstdin = sys.stdin\n \nni = lambda: int(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnn = lambda: list(stdin.readline().split())\nns = lambda: stdin.readline().rstrip()\n\nn,i = na()\na = na()\ndp = [i for i in a]\nans = sum(dp)\n\nfor i in range(1,n):\n for j in range(n):\n dp[(j+i)%n] = min(dp[(j+i)%n], a[j])\n ans = min(ans, sum(dp)+x*i)\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [166, 166], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u476604182", "n_user": "u476604182", "pos": "from itertools import accumulate as acc\nN, x, *A = map(int, open(0).read().split())\ndp = []\nfor i in range(N):\n dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))\n\nans = 10**60\nfor i,a in enumerate(zip(*dp)):\n ans = min(ans,i*x+sum(a))\nprint(ans)\n", "neg": "from itertools import accumulate as acc\nN, x, *A = map(int, open('0').read().split())\ndp = []\nfor i in range(N):\n dp.append(list(acc((A[(i-j)%N] for j in range(N)),min)))\n\nans = 10**10\nfor i,a in enumerate(zip(*dp)):\n ans = min(ans,i*x+sum(a))\nprint(ans)", "jacc_sim": 0.9555555555555556, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [110, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u754022296", "n_user": "u754022296", "pos": "import numpy as np\nn, x = map(int, input().split())\nA = np.array(input().split()[::-1]*2, dtype=np.int64)\nB = A.copy()[:n]\nans = float(\"inf\")\nfor k in range(n):\n t = x*k + B.sum()\n ans = min(ans, t)\n np.minimum(B, A[k+1:k+n+1], out=B)\nprint(ans)", "neg": "import numpy as np\nn, x = map(int, input().split())\nA = np.array(input().split()[::-1], dtype=np.int64)\nB = A.copy()\nans = float(\"inf\")\nfor k in range(n):\n print(B)\n t = x*k + B.sum()\n ans = min(ans, t)\n np.minimum(B, np.roll(A, -k-1), out=B)\nprint(ans)", "jacc_sim": 0.9545454545454546, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [118, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u905582793", "n_user": "u905582793", "pos": "from copy import deepcopy\nn,x = map(int,input().split())\na = list(map(int,input().split()))\na *= 2\nals = deepcopy(a[:n])\nans = [sum(als)]\nfor k in range(1,n):\n for i in range(n):\n als[i] = min(als[i],a[n+i-k])\n ans.append(sum(als)+x*k)\nprint(min(ans))", "neg": "from collections import deque\nfrom copy import deepcopy\nn,x = map(int,input().split())\na = list(map(int,input().split()))\na *= 2\nals = deepcopy(a[:n])\nans = [sum(als)]\nfor k in range(1,n):\n for i in range(n):\n als[i] = min(als[i],a[n-1+i-k])\n ans.append(sum(als)+x*k)\nprint(min(ans))", "jacc_sim": 0.9473684210526315, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [114, 121], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u163320134", "n_user": "u163320134", "pos": "n,x=map(int,input().split())\narr=list(map(int,input().split()))\ncost=[10**18]*n\nans=10**18\nfor i in range(n):\n for j in range(n):\n cost[j]=min(cost[j],arr[j-i])\n ans=min(ans,x*i+sum(cost))\nprint(ans)", "neg": "n,x=map(int,input().split())\narr=list(map(int,input().split()))\ncost=[10**10]*n\nans=10**10\nfor i in range(n):\n for j in range(n):\n cost[j]=min(cost[j],arr[j-i])\n print(cost)\n ans=min(ans,x*i+sum(cost))\nprint(ans)", "jacc_sim": 0.967741935483871, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [97, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u785578220", "n_user": "u785578220", "pos": "import numpy as np\nN, x = map(int, input().split())\na = np.array(list(map(int, input().split())))\nb = np.copy(a)\nans = float('inf') \nfor i in range(N):\n c = np.roll(a,i)\n b = np.minimum(b,c)\n ans = min(ans, sum(b)+i*x)\nprint(ans)\n", "neg": "\nimport numpy as np\nN, x = map(int, input().split())\na = np.array(map(int, input().split()))\nb = np.copy(a)\nans = float('inf') \nfor i in range(N):\n c = np.roll(a,i)\n b = np.minimum(b,c)\n ans = min(ans, sum(b)+i*x)\nprint(ans)\n", "jacc_sim": 0.972972972972973, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [106, 105], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u803848678", "n_user": "u803848678", "pos": "n, x = map(int, input().split())\na = list(map(int, input().split()))\n\nDP = a[:]\nans = sum(DP)\nfor i in range(n-1):\n new = [0]*n\n for j in range(n):\n new[j] = min(DP[j], DP[j-1])\n DP=new\n ans = min(ans, sum(DP) + (i+1)*x)\nprint(ans)", "neg": "n, x = map(int, input().split())\na = list(map(int, input().split()))\n\nDP = a[:]\nans = sum(DP)\nfor i in range(n-1):\n new = [0]*n\n for j in range(n):\n new[i] = min(DP[j], DP[j-1])\n DP=new\n ans = min(ans, sum(DP) + (i+1)*x)\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [118, 118], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u594567187", "n_user": "u594567187", "pos": "loop, magic_cost = map(int, input().split(\" \"))\ncost = [n for n in map(int, input().split(\" \"))]\nanswer = float(\"inf\")\nmin_costs = [float(\"inf\") for n in range(loop)]\nfor i in range(loop):\n for j in range(loop):\n min_costs[j] = min(min_costs[j], cost[(i - j) % loop])\n answer = min(answer, sum(min_costs) + (magic_cost * (i) ) )\nprint(answer)", "neg": "loop, magic_cost = map(int, input().split(\" \"))\ncost = [n for n in map(int, input().split(\" \"))]\nanswer = float(\"inf\")\nmin_costs = [float(inf) for n in range(loop)]\nfor i in range(loop):\n for j in range(loop):\n min_costs[j] = min(min_costs[j], cost[(i - j) % loop])\n answer = min(answer, sum(min_costs) + (magic_cost * (i) ) )\nprint(answer)", "jacc_sim": 1.0, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [137, 137], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u884982181", "n_user": "u884982181", "pos": "n,x = map(int,input().split())\na = list(map(int,input().split()))\nMIN = sum(a)\nans = MIN+0\ntori = a + [0]\ntori.pop()\nfor i in range(1,n):\n for j in range(n):\n ido = i+j\n if ido >= n:\n ido-=n\n if tori[j] > a[ido]:\n ans -= (tori[j] - a[ido])\n tori[j] = a[ido]\n MIN = min(ans + i*x,MIN)\nprint(MIN)", "neg": "n,x = map(int,input().split())\na = list(map(int,input().split()))\nMIN = sum(a)\ntori = a + [0]\ntori.pop()\nfor i in range(1,n):\n for j in range(n):\n ido = i+j\n if ido >= n:\n ido-=n\n tori[j] = min(a[ido],tori[j])\n MIN = sum(tori) + i*x\nprint(MIN)", "jacc_sim": 0.9722222222222222, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [155, 127], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u745087332", "n_user": "u745087332", "pos": "# coding:utf-8\n\nINF = float('inf')\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nN, x = inpl()\nA = inpl()\n\nmin_index = A.index(min(A))\nB = A[min_index:] + A[:min_index]\n\ncost = [B[i] for i in range(N)]\n\nans = INF\nfor magic in range(N):\n for i in range(N):\n if i - magic >= 0:\n cost[i] = min(cost[i], B[i - magic])\n\n ans = min(ans, sum(cost) + x * magic)\n\nprint(ans)\n", "neg": "# coding:utf-8\n\nINF = float('inf')\n\n\ndef inpl(): return list(map(int, input().split()))\n\n\nN, x = inpl()\nA = inpl()\n\nmin_index = A.index(min(A))\nB = A[min_index:] + A[:min_index]\n\ncost = [B[i] for i in range(N)]\n\nans = INF\nfor magic in range(N):\n for i in range(N):\n if i - magic >= 0:\n cost[i] = min(cost[i], B[i - magic])\n\n ans = min(ans, sum(B) + x * magic)\n\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [170, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u601018334", "n_user": "u601018334", "pos": "\ndef solve_():\n import itertools\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n s_cost = a.copy()\n cost = sum(s_cost)\n\n for k, i in itertools.product(range(1, N), range(N)):\n s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost[i]\n if i == N - 1 and cost > k*x + sum(s_cost):\n cost = k*x + sum(s_cost)\n\n print(cost)\n\nsolve_()", "neg": "def solve_():\n import itertools\n N, x = map(int, input().split())\n a = list(map(int, input().split()))\n s_cost = a.copy()\n cost = sum(s_cost)\n\n for k, i in itertools.product(range(1, N), range(N)):\n s_cost[i] = a[(i - k) % N] if s_cost > a[(i - k) % N] else s_cost[i]\n if i == N - 1 and cost > k*x + sum(s_cost):\n cost = k*x + sum(s_cost)\n \n print(cost)\n\nsolve()\n", "jacc_sim": 0.975609756097561, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [172, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04006", "p_user": "u637175065", "n_user": "u637175065", "pos": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\ndef f():\n n,x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n mi = a.index(min(a))\n a = a[mi:] + a[:mi]\n r = sum(a)\n for t in range(n-1):\n for i in range(n-1,0,-1):\n a[i] = min(a[i],a[i-1])\n tr = ((t+1)*x) + sum(a)\n if r > tr:\n r = tr\n else:\n break\n return r\n\nprint(f())\n", "neg": "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**9\n\ndef f():\n n,x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n mi = a.index(min(a))\n a = a[mi:] + a[:mi]\n print(\"a\",a)\n r = sum(a)\n for t in range(n-1):\n for i in range(n-1,0,-1):\n a[i] = min(a[i],a[i-1])\n tr = ((t+1)*x) + sum(a)\n if r > tr:\n r = tr\n else:\n break\n return r\n\nprint(f())\n", "jacc_sim": 0.9830508474576272, "nl": "Snuke lives in a world where people keep slimes of different colors. He aims to have slimes of all colors. He can catch a slime of a color he doesn't have or cast a spell to change the colors of the slimes he has. The objective is to find the minimum time needed for Snuke to have slimes of all colors. Constraints: 2\u2264N\u22642,000, a_i are integers, 1\u2264a_i\u226410^9, 1\u2264x\u226410^9. Input format: N x a_1 a_2 ... a_N. Output: Minimum time needed to have slimes in all N colors. Sample inputs and outputs are provided.", "before_after_length": [209, 217], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04008", "p_user": "u423585790", "n_user": "u423585790", "pos": "import sys\nsys.setrecursionlimit(10**6)\nn,k = map(int,input().split())\na = [int(i)-1 for i in input().split()]\nedg = [[] for i in range(n)]\nfor i in range(1,n):\n edg[a[i]].append(i)\nans = [0] * n\nans[0] = a[0] != 0\ndef dfs(now):\n res = 0\n for e in edg[now]:\n res = max(res, dfs(e)+1)\n if res == k - 1 and a[now] != 0:\n ans[now] = 1\n res = -1\n return res\n \ndfs(0)\nprint(sum(ans))\n", "neg": "import sys\nsys.setrecursionlimit(10**6)\nn,k = map(int,input().split())\na = [int(i)-1 for i in input().split()]\nedg = [[] for i in range(n)]\nfor i in range(1,n):\n edg[a[i]].append(i)\nans = [0] * n\nans[0] = a[0] != 0\ndef dfs(now):\n res = 0\n for e in edg[now]:\n res = max(res, dfs(e))\n if res == k - 1 and a[e] != 0 and e != 0:\n ans[e] = 1\n res = 1\n return res + 1\n \ndfs(0)\nprint(sum(ans))\n", "jacc_sim": 1.0, "nl": "In the Snuke Kingdom, there are N towns numbered from 1 to N, with town 1 as the capital. Each town has a Teleporter that instantly transports a person to another town. King Snuke wants to change the Teleporter destinations so that from any town, one can reach the capital after using the Teleporters exactly K times. Find the minimum number of Teleporters whose destinations need to be changed to satisfy the king's desire. Constraints: 2\u2264N\u226410^5, 1\u2264ai\u2264N, 1\u2264K\u226410^9. Input format: N K followed by a1 a2 ... aN. Output the minimum number of Teleporters to be changed.", "before_after_length": [182, 185], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04008", "p_user": "u693716675", "n_user": "u693716675", "pos": "#d tree\n#code\u81ea\u4f53\u306f\u3042\u3063\u3066\u3044\u308b\u3002\u305f\u3060\u3001\u305d\u3082\u305d\u3082\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u9055\u3046\u3002\n#\u4e0b\u304b\u3089\u8abf\u3079\u3066\u3044\u304b\u306a\u3044\u3068\u6700\u9069\u3067\u306a\u3044\u3002\n#Right Answer. \nimport sys\nsys.setrecursionlimit(2 * 10 ** 5 + 10)\n\nn,k = [int(i) for i in input().split()]\na = [int(i)-1 for i in input().split()]\n\n#this is directed tree so every node is not reached yet\n#return the depth from its lowest bottom\ndef dfs(u):\n global cnt\n depth = 0 #default, this value is used when bottom\n \n for v in edges[u]:\n depth = max(depth, (dfs(v)+1)%k) #apply the maximum depth\n #because the edge was alerady cut, by the following procedure\n \n if depth==k-1 and u!=0 and a[u] != 0:\n cnt += 1\n \n return depth\n\n\ncnt = 0\nif a[0]!=0:\n cnt += 1\n\nedges = [[] for _ in range(n)]\nfor i in range(1,n):\n pa = a[i]\n edges[a[i]].append(i) \n\ndfs(0) \nprint(cnt)", "neg": "#d tree\n#code\u81ea\u4f53\u306f\u3042\u3063\u3066\u3044\u308b\u3002\u305f\u3060\u3001\u305d\u3082\u305d\u3082\u30a2\u30eb\u30b4\u30ea\u30ba\u30e0\u304c\u9055\u3046\u3002\n#\u4e0b\u304b\u3089\u8abf\u3079\u3066\u3044\u304b\u306a\u3044\u3068\u6700\u9069\u3067\u306a\u3044\u3002\n#Right Answer. \nimport sys\nsys.setrecursionlimit(2 * 10 ** 5 + 10)\n\nn,k = [int(i) for i in input().split()]\na = [int(i)-1 for i in input().split()]\n\n#this is directed tree so every node is not reached yet\n#return the depth from its lowest bottom\ndef dfs(u):\n global cnt\n depth = 0 #default, this value is used when bottom\n \n for v in edges[u]:\n depth = max(depth, dfs(v)+1) #apply the maximum depth\n \n if depth>=k and u!=0:\n cnt += 1\n depth = 0\n \n return depth\n\n\ncnt = 0\nif a[0]!=0:\n cnt += 1\n\nedges = [[] for _ in range(n)]\nfor i in range(1,n):\n pa = a[i]\n edges[a[i]].append(i) \n\ndfs(0) \nprint(cnt)", "jacc_sim": 0.9130434782608695, "nl": "In the Snuke Kingdom, there are N towns numbered from 1 to N, with town 1 as the capital. Each town has a Teleporter that instantly transports a person to another town. King Snuke wants to change the Teleporter destinations so that from any town, one can reach the capital after using the Teleporters exactly K times. Find the minimum number of Teleporters whose destinations need to be changed to satisfy the king's desire. Constraints: 2\u2264N\u226410^5, 1\u2264ai\u2264N, 1\u2264K\u226410^9. Input format: N K followed by a1 a2 ... aN. Output the minimum number of Teleporters to be changed.", "before_after_length": [410, 386], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04008", "p_user": "u316386814", "n_user": "u316386814", "pos": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, K = LI()\n A = LI_()\n edges = defaultdict(list)\n for i, a in enumerate(A[1:], 1):\n edges[a].append(i)\n\n global ans\n ans = 0\n if A[0] != 0:\n ans += 1\n def DFS(v, parent):\n global ans\n height = 0\n for to in edges[v]:\n height = max(height, DFS(to, v))\n if parent != 0 and height >= K - 1:\n height = -1\n ans += 1\n return height + 1\n DFS(0, 0)\n return ans\n\nprint(main())", "neg": "import sys\nsys.setrecursionlimit(10**7)\nINF = 10 ** 18\nMOD = 10 ** 9 + 7\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef II(): return int(sys.stdin.readline())\ndef SI(): return input()\n\nfrom collections import defaultdict\n\ndef main():\n N, K = LI()\n A = LI_()\n edges = defaultdict(list)\n for i, a in enumerate(A[1:], 1):\n edges[a].append(i)\n\n ans = 0\n if A[0] != 0:\n ans += 1\n def DFS(v, parent):\n global ans\n height = 0\n for to in edges[v]:\n height = max(height, DFS(to, v) + 1)\n if parent != 0 and height > K - 1:\n height = 0\n ans += 1\n return height\n DFS(0, 0)\n return ans\n\nprint(main())", "jacc_sim": 1.0, "nl": "In the Snuke Kingdom, there are N towns numbered from 1 to N, with town 1 as the capital. Each town has a Teleporter that instantly transports a person to another town. King Snuke wants to change the Teleporter destinations so that from any town, one can reach the capital after using the Teleporters exactly K times. Find the minimum number of Teleporters whose destinations need to be changed to satisfy the king's desire. Constraints: 2\u2264N\u226410^5, 1\u2264ai\u2264N, 1\u2264K\u226410^9. Input format: N K followed by a1 a2 ... aN. Output the minimum number of Teleporters to be changed.", "before_after_length": [308, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u036104576", "n_user": "u036104576", "pos": "import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom collections import Counter\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\n\nimport sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\nN = int(input())\nS = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n return f(b, n // b) + n % b\n\nMAX = 10 ** 6\nfor b in range(2, MAX + 1):\n res = f(b, N)\n if res == S:\n print(b)\n exit()\nx = N - S\nif x < 0:\n print(-1)\nelif x == 0:\n print(N + 1)\nelse:\n ans = -1\n for p in range(1, MAX + 1):\n if x % p == 0:\n b = (x // p) + 1\n if b > MAX and N // b == p:\n ans = b\n print(ans)\n", "neg": "import sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nimport heapq\nfrom collections import defaultdict\nfrom collections import Counter\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\n\nimport sys\nimport itertools\n# import numpy as np\nimport time\nimport math\nfrom heapq import heappop, heappush\nfrom collections import defaultdict\nfrom collections import Counter\nfrom collections import deque\nsys.setrecursionlimit(10 ** 7)\n \nINF = 10 ** 18\nMOD = 10 ** 9 + 7\nread = sys.stdin.buffer.read\nreadline = sys.stdin.buffer.readline\nreadlines = sys.stdin.buffer.readlines\n\n# map(int, input().split())\nN = int(input())\nS = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n return f(b, n // b) + n % b\n\nMAX = 10 ** 6\nfor b in range(2, MAX + 1):\n res = f(b, N)\n if res == S:\n print(b)\n exit()\n\nx = N - S\nif x < 0:\n print(-1)\nelse:\n ans = INF\n for p in range(1, MAX + 1):\n if x % p == 0:\n b = (x // p) + 1\n if b >= MAX and N // b == p:\n ans = min(b, ans)\n print(ans)\n", "jacc_sim": 0.9722222222222222, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [416, 406], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u786020649", "n_user": "u786020649", "pos": "import sys\nimport math\n\ndef divlist(n):\n sl=[]\n ll=[]\n for x in range(1,int(math.sqrt(n))+1):\n if n%x==0:\n sl.append(x)\n ll.append(n//x)\n ll.reverse()\n sl.extend(ll)\n return sl\n\ndef f(b,n):\n if n n:\n print(-1)\n exit()\nif n%2 == 0 and n > s > n//2:\n print(-1)\n exit()\nif n%2 == 1 and n > s > n//2+1:\n print(-1)\n exit()\n\nans = float(\"INF\")\nfor i in range(2,int(n**0.5)+1):\n x = n\n count = 0\n while x >= i:\n count += x%i\n x //= i\n if count + x == s:\n print(i)\n exit()\nnow = 2\nli = int(n**0.5)+1\nwhile True:\n\n x = n//now\n if x < li:\n break\n count = 0\n y = n\n while y >= x:\n count += y%x\n y //= x\n count += y\n if count <= s and (s-count)%now == 0:\n z = x-n//(now+1)\n if (s-count)//now < z:\n ans = x-(s-count)//now\n now += 1\n\nif s == n:\n print(min(ans,n+1))\nelse:\n print(min(ans,n-s+1))\n", "neg": "n = int(input())\ns = int(input())\nif s == 1 and n == 1:\n print(2)\n exit()\nif n%2 == 0 and n > s > n//2:\n print(-1)\n exit()\nif n%2 == 1 and n > s > n//2+1:\n print(-1)\n exit()\n\nans = float(\"INF\")\nfor i in range(2,int(n**0.5)+1):\n x = n\n count = 0\n while x >= i:\n count += x%i\n x //= i\n if count + x == s:\n print(i)\n exit()\nnow = 2\nli = int(n**0.5)+1\nwhile True:\n\n x = n//now\n if x < li:\n break\n count = 0\n y = n\n while y >= x:\n count += y%x\n y //= x\n count += y\n if count <= s and (s-count)%now == 0:\n z = x-n//(now+1)\n if (s-count)//now < z:\n ans = x-(s-count)//now\n now += 1\n \nprint(min(ans,n-s+1))\n", "jacc_sim": 0.9772727272727273, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [349, 312], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u888100977", "n_user": "u888100977", "pos": "n = int(input())\ns = int(input())\n\nimport math\ndef f(b, n):\n # print(b, n)\n if n N:\n return -1\n elif N == S:\n return N+1\n else:\n for b in range(2, int(N**(1/2))+1):\n if f(b, N) == S:\n return b\n for p in range(int(N**(1/2)), 0, -1):\n if (N - S) % p == 0:\n b = (N - S) // p + 1\n if f(b, N) == S:\n return b\n return -1\n\nprint(solve(N, S))", "neg": "N = int(input())\nS = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, int(n/b)) + (n % b)\n\ndef solve(N, S):\n if N == S:\n return N+1\n else:\n for b in range(2, int(N**(1/2))+1):\n if f(b, N) == S:\n return b\n for p in range(1, int(N**(1/2))+1):\n b = int((N - S) / p + 1)\n if f(b, N) == S:\n return b\n return -1\n\nprint(solve(N, S))", "jacc_sim": 0.9090909090909091, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [208, 186], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u939198091", "n_user": "u939198091", "pos": "import math\n\ndef func(b,n):\n if b > n:\n return n\n else:\n return func(b, math.floor(n/b)) + (n % b)\n\ndef _func(b,n):\n x = n\n ret = 0\n while True:\n if b > x:\n return ret + x\n else:\n ret += x % b\n x = math.floor(x/b)\n\ndef solve(n,s):\n if n == s:\n return n+1\n ans = float('inf')\n for b in range(2,math.floor(math.sqrt(n))+1):\n if _func(b,n) == s:\n return b\n\n for p in range(1,math.floor(math.sqrt(n))+1):\n if (n-s) % p == 0:\n b = int((n-s)/p)+1\n if b < 2:\n continue\n if _func(b, n) == s:\n ans = min(ans, b)\n\n if ans < float('inf'):\n return ans\n else:\n return -1\n\nif __name__ == \"__main__\":\n n = int(input())\n s = int(input())\n ans = solve(n,s)\n print(ans)\n", "neg": "import math\n\ndef func(b,n):\n if b > n:\n return n\n else:\n return func(b, math.floor(n/b)) + (n % b)\n\ndef _func(b,n):\n x = n\n ret = 0\n while True:\n if b > x:\n return ret + x\n else:\n ret += x % b\n x = math.floor(x/b)\n\ndef solve(n,s):\n if n == s:\n return n+1\n ans = float('inf')\n for b in range(2,math.floor(math.sqrt(n))+1):\n if _func(b,n) == s:\n return b\n\n for p in range(1,math.floor(math.sqrt(n))+1):\n if (n-s) % p == 0:\n b = int((n-s)/p)+1\n if b < 2:\n continue\n if _func(b, n) == s:\n ans = min(ans, b)\n\n return -1\n\nif __name__ == \"__main__\":\n n = int(input())\n s = int(input())\n ans = solve(n,s)\n print(ans)\n", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [332, 314], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u547167033", "n_user": "u547167033", "pos": "n=int(input())\ns=int(input())\nif s==n:\n print(n+1)\n exit()\ndef f(x):\n m=n\n t=0\n while m:\n t+=m%x\n m//=x\n return t\nfor b in range(2,int(n**0.5)+2):\n if f(b)==s:\n print(b)\n exit()\nfor p in range(1,int(n**0.5))[::-1]:\n q=s-p\n b=(n-s)//p+1\n if 1<=p0:\n y=m%x\n t.append(y)\n m//=x\n return sum(t)\nfor b in range(2,int(n**0.5)+1):\n if f(b)==s:\n print(b)\n exit()\nfor p in range(1,int(n**0.5))[::-1]:\n q=s-p\n b=(n-s)//p+1\n if 1<=p= n\nif s == n:\n print(n+1)\nelif s > n:\n print(-1)\nelse:\n #sqrt(n)\u307e\u3067\u63a2\u7d22\n for i in range(2,int(up)+1):\n if colsum(n,i) == s:\n print(i)\n sys.exit()\n\n #2\u6841\u3057\u304b\u3042\u308a\u5f97\u306a\u3044\u5834\u5408(sqrt(n) 1:\n print(int(b))\n sys.exit()\n\n print(-1)", "neg": "import math\nimport sys\nsys.setrecursionlimit(100000)\n\nn = int(input())\ns = int(input())\n\nup = math.sqrt(n)\n\ndef colsum(num, base):\n if num < base:\n return num\n else:\n return num%base + colsum(num//base,base)\n\n#s = n(n 1:\n print(i)\n exit()\n\n\n\nprint(-1)", "jacc_sim": 0.9482758620689655, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [290, 284], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u905582793", "n_user": "u905582793", "pos": "n = int(input())\ns = int(input())\nx = int(n**0.5)+1\ndef dsum(x,t):\n ret = 0\n while x>0:\n ret += x%t\n x //= t\n return ret\nfor i in range(2,x+1):\n if dsum(n,i) == s:\n print(i)\n exit()\nfor i in range(x,0,-1):\n if (n-(s-i))%i == 0:\n digit = (n-(s-i))//i\n if 0 < i < digit and 0 <= s-i < digit:\n print((n-(s-i))//i)\n exit()\nif n == s:\n print(n+1)\n exit()\nprint(-1)", "neg": "n = int(input())\ns = int(input())\nx = int(n**0.5)+1\ndef dsum(x,t):\n ret = 0\n while x>0:\n ret += x%t\n x //= t\n return ret\nfor i in range(2,x+1):\n if dsum(n,i) == s:\n print(i)\n exit()\nfor i in range(x,0,-1):\n if (n-(s-i))%i == 0:\n print((n-(s-i))//i)\n exit()", "jacc_sim": 0.918918918918919, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [199, 145], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u627600101", "n_user": "u627600101", "pos": "n=int(input())\ns=int(input())\n\nNo=0\nif n==s:\n print(n+1)\n No =1\nelse:\n for b in range(2,int(n**0.5)+2):\n m=0\n N=n\n while N!=0:\n m+=N%b\n N=N//b\n if m>s:\n break \n if m==s:\n print(b)\n No=1\n exit()\n for p in range(int(n**0.5-1),0,-1):\n b = float(n-s)/float(p)+1.0\n if abs(b-int(b))<10**(-10)and b>0:\n b=int(b)\n m=0\n N=n\n while N!=0:\n m+=N%b\n N=N//b\n if m>s:\n break \n if m==s:\n print(b)\n No=1\n exit()\nif No==0:\n print(-1)", "neg": "n=int(input())\ns=int(input())\n\nNo=0\nif n==s:\n print(n+1)\n No =1\nelse:\n for b in range(2,int(n**0.5)+1):\n m=0\n N=n\n while N!=0:\n m+=N%b\n N=N//b\n if m>s:\n break \n if m==s:\n print(b)\n No=1\n exit()\n for p in range(int(n**0.5),-1,-1):\n b = float(n-s)/float(p)-1.0\n if abs(b-int(b))<10**(-30):\n print(int(b))\n No=1\n exit()\nif No==0:\n print(-1)", "jacc_sim": 0.9512195121951219, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [272, 209], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u989345508", "n_user": "u989345508", "pos": "import math\nn=int(input())\ns=int(input())\n\ndef f(b,n):\n m=math.floor(n/b)\n if n>=b:\n return f(b,m) + n%b\n else:\n return n\n\nif nb:\n return f(b,m) + n%b\n else:\n return n\n\nif n= 2 and func(b, n) == s:\n ans = b\nprint(ans)", "neg": "import math\n\nn = int(input())\ns = int(input())\nans = -1\n\ndef func(b, n):\n if n < b:\n return n\n else:\n return func(b, n//b) + n%b\n\nif n > s:\n ans = -1\nelif n == s:\n ans = n+1\nelse:\n for b in range(2,int(math.sqrt(n))):\n if func(b, n) == s:\n ans = b\n break\n\n if ans == -1:\n for p in range(1,int(math.sqrt(n))):\n if func((n-s)/p+1, n) == s:\n ans = int((n-s)/p+1)\nprint(ans)", "jacc_sim": 0.9722222222222222, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [200, 193], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u912115033", "n_user": "u912115033", "pos": "def f(p, q):\n if q < p:\n return q\n else:\n return f(p, q//p) + q%p\n\nn = int(input())\ns = int(input())\nflag = 0\nif n < s:\n print(-1)\n flag = 1\nif flag == 0 and n == s:\n print(n+1)\n flag = 1\nif flag == 0:\n for i in range(2, int(n**0.5)+2):\n if f(i, n) == s:\n print(i)\n flag = 1\n break\nif flag == 0:\n for i in range(int(n**0.5), 0, -1):\n if (n-s)%i == 0:\n if f((n-s)//i+1, n) == s:\n print((n-s)//i+1)\n flag = 1\n break\n\nif flag == 0:\n print(-1)", "neg": "def f(p, q):\n if q < p:\n return q\n else:\n return f(p, q//p) + q%p\n\nn = int(input())\ns = int(input())\nflag = 0\nif n < s:\n print(-1)\n flag = 1\nif flag == 0 and n == s:\n print(n+1)\n flag = 1\nif flag == 0:\n for i in range(2, int(n**0.5)+2):\n if f(i, n) == s:\n print(i)\n flag = 1\n break\nif flag == 0:\n for i in range(int(n**0.5), 1, -1):\n if (n-s)%i == 0:\n if f((n-s)//i+1, n) == s:\n print((n-s)//i+1)\n flag = 1\n break\n\nif flag == 0:\n print(-1)", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [239, 239], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u606878291", "n_user": "u606878291", "pos": "import math\n\n\ndef digit_sum(b, n):\n if b > n:\n return n\n else:\n return digit_sum(b=b, n=n // b) + n % b\n\n\ndef main(n, s):\n if s > n:\n return -1\n elif n == s:\n return n + 1\n else:\n b = 2\n while b * b <= n:\n if digit_sum(b, n) == s:\n return b\n b += 1\n\n p = 1\n b_min = -1\n while p * p <= n:\n if (n - s) % p == 0:\n b = (n - s) // p + 1\n if digit_sum(b, n) == s:\n b_min = min(b_min, b) if b_min != -1 else b\n p += 1\n return b_min\n\n\nif __name__ == '__main__':\n N = int(input())\n S = int(input())\n print(main(n=N, s=S))\n", "neg": "import math\n\n\ndef digit_sum(b, n):\n if b > n:\n return n\n else:\n return digit_sum(b=b, n=n // b) + n % b\n\n\ndef main(n, s):\n if s > n:\n return -1\n elif n == s:\n return n + 1\n else:\n b = 2\n while b * b <= n:\n if digit_sum(b, n) == s:\n return b\n\n p = 1\n b_min = -1\n while p * p <= n:\n if (n - s) % p == 0:\n b = (n - s) // p + 1\n if digit_sum(b, n) == s:\n b_min = min(b_min, b) if b_min != -1 else b\n p += 1\n return b_min\n\n\nif __name__ == '__main__':\n N = int(input())\n S = int(input())\n print(main(n=N, s=S))\n", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [266, 261], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u701199820", "n_user": "u701199820", "pos": "import math\n\nn = int(input())\ns = int(input())\nans = -1\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n%b\n\n#\nif n == s: ans = n+1\nfor i in range(2, int(math.sqrt(n))+1):\n if f(i, n) == s:\n ans = i\n break\nif ans == -1:\n for i in range(int(math.sqrt(n)), 0, -1):\n b = int((n-s) / i + 1)\n if b >= 2 and f(b,n) == s:\n ans = b\n break\n\nprint(ans)\n", "neg": "import math\n\nn = int(input())\ns = int(input())\nans = -1\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n%b\n\nif n == s: ans = n+1\nfor i in range(2, int(math.sqrt(n))+1):\n if f(i, n) == s:\n ans = i\n break\nif ans == -1:\n for i in range(int(math.sqrt(n)), 0, -1):\n b = (n-s) // i + 1\n if f(b,n) == s:\n ans = b\n break\n\nprint(ans)\n", "jacc_sim": 0.918918918918919, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [188, 180], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u924374652", "n_user": "u924374652", "pos": "import math\nn = int(input())\ns = int(input())\n\nresult = -1\nif n == s:\n result = n + 1\nelif s > n:\n pass\nelse:\n temp_sqrt_n = math.floor(math.sqrt(n))\n for b in range(2, temp_sqrt_n + 1):\n temp_n = n\n temp_b = 0\n while temp_n >= b:\n temp_b += temp_n % b\n temp_n = temp_n // b\n if temp_b + temp_n == s:\n result = b\n break\n if result == -1:\n temp_sqrt_n = math.floor(math.sqrt(n - 1))\n for quot in range(temp_sqrt_n, 0, -1):\n if n - s % quot != 0:\n b = (n - s) // quot + 1\n if quot + n % b == s:\n result = b\n break\nprint(result)", "neg": "import math\nn = int(input())\ns = int(input())\n\nresult = -1\nif n == s:\n result = n + 1\nelif s > n:\n pass\nelse:\n sqrt_n = math.floor(math.sqrt(n))\n for b in range(2, sqrt_n + 1):\n temp_n = n\n temp_b = 0\n while temp_n >= b:\n temp_b += temp_n % b\n temp_n = temp_n // b\n if temp_b + temp_n == s:\n result = b\n break\n if result == -1:\n for quot in range(sqrt_n, 0, -1):\n if n - s % quot == 0:\n b = (n - s) // quot + 1\n if quot + n % b == s:\n result = b\n break\nprint(result)", "jacc_sim": 0.925, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [245, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u404794295", "n_user": "u404794295", "pos": "n=int(input())\ns=int(input())\nans=\"-1\"\ndef f(b,n):\n if n=2:\n if f(b,n)==s:\n ans=b\n break\nprint(ans)", "neg": "n=int(input())\ns=int(input())\nans=\"-1\"\ndef f(b,n):\n if n=2:\n if f(b,n)==s:\n ans=b\n break\nprint(ans)", "jacc_sim": 0.9696969696969697, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [185, 181], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u842689614", "n_user": "u842689614", "pos": "n=int(input())\ns=int(input())\n\nb_ans=1\n\n\n\nif n==s:\n b_ans=n+1\nif b_ans==1:\n for b in range(2,int(n**0.5)+1):\n nn=n\n st=[]\n while(nn>0):\n st.append(nn%b)\n nn=(nn-st[-1])/b\n \n if sum(st)==s:\n b_ans=b\n break\n\nif b_ans==1:\n for p in range(int(n**0.5),0,-1):\n b=(n-s+p)/p\n\n if b.is_integer() and 0<=s-pn**0.5:\n b_ans=int(b)\n break\n\nif b_ans!=1:\n print(b_ans)\nelse:\n print(-1)", "neg": "n=int(input())\ns=int(input())\n\nb_ans=1\nfor b in range(2,int(n**0.5)+1):\n nn=n\n st=[]\n while(nn>0):\n st.append(nn%b)\n nn=(nn-st[-1])/b\n \n if sum(st)==s:\n b_ans=b\n break\n\n\nif b_ans==1:\n for p in range(int(n**0.5)):\n b=int(n/p)\n q=n-p*b\n if s==p+q:\n b_ans=b\n break\n\nif b_ans!=1:\n print(b_ans)\nelse:\n print(-1)", "jacc_sim": 0.9047619047619048, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [234, 190], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u511965386", "n_user": "u511965386", "pos": "n = int(input())\ns = int(input())\n\ndef f(b, n) :\n ret = 0\n while n != 0 :\n ret += n % b\n n //= b\n \n return ret\n\ndef solve(n, s) :\n if n == s :\n return n + 1\n if s > n :\n return -1\n \n b = 2\n while b * b <= n :\n if f(b, n) == s :\n return b\n b += 1\n \n p = int(-(-(n ** 0.5 - 1) // 1))\n while p > 0 :\n if (n - s) % p == 0 :\n b = 1 + (n - s) // p\n if p < b and 0 <= s - p < b :\n return b\n \n p -= 1\n \n return -1\n \nprint(solve(n, s))", "neg": "n = int(input())\ns = int(input())\n\ndef f(b, n) :\n ret = 0\n while n != 0 :\n ret += n % b\n n //= b\n \n return ret\n\ndef solve(n, s) :\n if n == s :\n return n + 1\n if s > n :\n return -1\n \n b = 2\n while b * b < n :\n if f(b, n) == s :\n return b\n b += 1\n \n p = -(-(n ** 0.5 - 1) // 1)\n while p > 0 :\n if (n - s) % p == 0 :\n b = 1 + (n - s) // p\n if p < b and 0 <= s - p < b :\n return b\n \n p -= 1\n \n return -1\n \nprint(solve(n, s))", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [224, 223], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u163320134", "n_user": "u163320134", "pos": "import sys\nsys.setrecursionlimit(10**8)\n\ndef f(b,n):\n if b>n:\n return n\n else:\n return f(b,n//b)+n%b\n\nn=int(input())\ns=int(input())\nif s>n:\n print(-1)\nelif s==n:\n print(n+1)\nelse:\n ans=10**18\n for i in range(2,int(n**0.5)+1):\n if f(i,n)==s:\n ans=i\n break\n if ans!=10**18:\n print(ans)\n else:\n for i in range(1,int(n**0.5)+1):\n tb=(n-s)//i+1\n if tb==1:\n continue\n if f(tb,n)==s:\n ans=min(ans,tb)\n if ans!=10**18:\n print(ans)\n else:\n print(-1)", "neg": "import sys\nsys.setrecursionlimit(10**8)\n\ndef f(b,n):\n if b>n:\n return n\n else:\n return f(b,n//b)+n%b\n\nn=int(input())\ns=int(input())\nif s>n:\n print(-1)\nelif s==n:\n print(n+1)\nelse:\n ans=10**18\n for i in range(2,int(n**0.5)+1):\n if f(i,n)==s:\n ans=i\n break\n else:\n for i in range(1,int(n**0.5)+1):\n tb=(n-s)//i+1\n if tb==1:\n continue\n if f(tb,n)==s:\n ans=min(ans,tb)\n if ans!=0:\n print(ans)\n else:\n print(-1)", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [251, 233], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u619458041", "n_user": "u619458041", "pos": "import sys\n\ndef f(b, n):\n if b < 2:\n return -1 \n\n if b > n:\n return n\n\n return f(b, n//b) + n % b\n\n\ndef main():\n input = sys.stdin.readline\n n = int(input())\n s = int(input())\n\n if s > n:\n return -1\n\n if s == n:\n return n+1\n\n for i in range(2, int(n**0.5)):\n if f(i, n) == s:\n return i\n\n for p in range(int(n**0.5) + 1, 0, -1):\n if (n - s) % p != 0:\n continue\n\n b = (n - s) // p + 1\n if f(b, n) == s:\n return b\n\n return -1\n\n\nif __name__ == '__main__':\n print(main())\n", "neg": "import sys\n\ndef f(b, n):\n if b > n:\n return n\n\n return f(b, n//b) + n % b\n\n\ndef main():\n input = sys.stdin.readline\n n = int(input())\n s = int(input())\n\n if s == n:\n return n+1\n\n for i in range(2, int(n**0.5)):\n if f(i, n) == s:\n return i\n\n b = (n - s) // p + 1\n if f(b, n) == s:\n return b\n else:\n return -1\n\n\nif __name__ == '__main__':\n print(main())\n", "jacc_sim": 0.9069767441860465, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [241, 177], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u425287928", "n_user": "u425287928", "pos": "n=int(input())\ns=int(input())\n\ndef f(b,n):\n\tif b < 2:\n\t\treturn 0\n\tif n < b:\n\t\treturn n\n\telse:\n\t\treturn f(b,n//b)+n%b\n\nans=-1\nif s==n:\n\tans=n+1\nelse:\n\tfor _b in range(2,int(n**0.5)+1):\n\t\tif f(_b,n)==s:\n\t\t\tans=_b\n\t\t\tbreak\n\tif ans==-1:\n\t\tfor _p in range(int(n**0.5),0,-1):\n\t\t\t_b = (n-s)//_p+1\n\t\t\tif f(_b,n)==s:\n\t\t\t\tans=_b\n\t\t\t\tbreak\nprint(ans)", "neg": "n=int(input())\ns=int(input())\n\ndef f(b,n):\n\tif b < 2:\n\t\treturn 0\n\tif n < b:\n\t\treturn n\n\telse:\n\t\treturn f(b,n//b)+n%b\n\nans=-1\nif s==n:\n\tans=n+1\nelse:\n\tfor _b in range(2,int(n**0.5)+1):\n\t\tif f(_b,n)==s:\n\t\t\tans=_b\n\t\t\tbreak\n\tfor _p in range(1,int(n**0.5)+1):\n\t\t_b = (n-s)//_p+1\n\t\tif f(_b,n)==s:\n\t\t\tans=_b\n\t\t\tbreak\nprint(ans)", "jacc_sim": 1.0, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [205, 195], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u281303342", "n_user": "u281303342", "pos": "N = int(input())\nS = int(input())\n\ndef f(b,n):\n if n//b==0:\n return n\n else:\n return n%b + f(b,n//b)\n\nans = -1\nif S==N:\n ans = N+1\nelse:\n for b in range(2,int(N**.5)+1):\n if f(b,N)==S:\n ans = b\n break\n\nif ans == -1:\n for i in range(int(N**.5)+1,0,-1):\n b = (N-S)//i + 1\n if b>1:\n if f(b,N)==S:\n ans = b\n break\n\nprint(ans)", "neg": "N = int(input())\nS = int(input())\n\ndef f(b,n):\n if n//b==0:\n return n\n else:\n return n%b + f(b,n//b)\n\nans = -1\nlimN = int(N**.5)+1\nfor b in range(2,limN):\n if f(b,N)==S:\n ans = b\n break\n\nprint(ans)", "jacc_sim": 0.9142857142857143, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [189, 109], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u604896914", "n_user": "u604896914", "pos": "import math\n\ndef gcd(a,b):\n \"\"\"Compute the greatest common divisor of a and b\"\"\"\n while b > 0:\n a, b = b, a % b\n return a\n \ndef lcm(a, b):\n \"\"\"Compute the lowest common multiple of a and b\"\"\"\n return a * b / gcd(a, b)\n \n\ndef f(b,n):\n\tif n < b:\n\t\treturn n\n\treturn f(b, n//b) + n%b\n \nN = int(input())\nS = int(input())\n\nif N == S:\n\tprint(N+1)\n\texit()\n\nif N < S:\n\tprint(-1)\n\texit()\n\nfor B in range(2, int(math.sqrt(N))+1):\n\tif(f(B,N)==S):\n\t\tprint(B)\n\t\texit()\n\n\nfor p in range(int(math.sqrt(N))+1, 0, -1):\n\tB = (N-S)/p + 1\n\tif(B==int(B) and f(int(B),N)==S):\n\t\tprint(int(B))\n\t\texit()\n\n\nprint(-1)", "neg": "import math,sys\n\n\nsys.setrecursionlimit(1500)\n\n\ndef gcd(a,b):\n \"\"\"Compute the greatest common divisor of a and b\"\"\"\n while b > 0:\n a, b = b, a % b\n return a\n \ndef lcm(a, b):\n \"\"\"Compute the lowest common multiple of a and b\"\"\"\n return a * b / gcd(a, b)\n \n\ndef f(b,n):\n\tif n < b:\n\t\treturn n\n\treturn f(b, n//b) + n%b\n \nN = int(input())\nS = int(input())\n\nif N == S:\n\tprint(N)\n\texit()\n\nif N < S:\n\tprint(-1)\n\texit()\n\nfor B in range(2, int(math.sqrt(N))+1):\n\tif(f(B,N)==S):\n\t\tprint(B)\n\t\texit()\n\n\nfor p in range(int(math.sqrt(N)),0,-1):\n\tB = (N-S)/p + 1\n\tif(B==int(B) and f(int(B),N)):\n\t\tprint(B)\n\t\texit()\n\n\nprint(-1)", "jacc_sim": 0.9433962264150944, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [297, 304], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u170201762", "n_user": "u170201762", "pos": "from math import floor,ceil\ndef f(b,n):\n if n < b:\n return n\n else:\n return f(b,floor(n/b))+n%b\nn = int(input())\ns = int(input())\n\nfor b in range(2,320000):\n if f(b,n)==s:\n print(b)\n exit()\n\nif n==s:\n print(s+1)\n exit()\n\nd = {}\nfor i in range(1,ceil(n**0.5)):\n m = f(n//i,n)\n if n//i==n//(i+1):\n d[i] = (m,m)\n else:\n M = f(n//(i+1)+1,n)\n d[i] = (m,M)\n\nfor i in range(ceil(n**0.5)-1,0,-1):\n m,M = d[i]\n if m<=s<=M and (s-m)%i==0:\n print(n//i-(s-m)//i)\n exit()\n\nprint(-1)", "neg": "rom math import floor,ceil\ndef f(b,n):\n if n < b:\n return n\n else:\n return f(b,floor(n/b))+n%b\nn = int(input())\ns = int(input())\n\nfor b in range(2,320000):\n if f(b,n)==s:\n print(b)\n exit()\n\nif n==s:\n print(s+1)\n exit()\n\nd = {}\nfor i in range(1,ceil(n**0.5)):\n m = f(n//i,n)\n if n//i==n//(i+1):\n d[i] = (m,m)\n else:\n M = f(n//(i+1)+1,n)\n d[i] = (m,M)\n\nfor i in range(ceil(n**0.5)-1,0,-1):\n m,M = d[i]\n if m<=s<=M and (s-m)%i==0:\n print(n//i-(s-m)//i)\n exit()\n\nprint(-1)", "jacc_sim": 0.9574468085106383, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [289, 289], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u419686324", "n_user": "u419686324", "pos": "import math\nn = int(input())\ns = int(input())\n\ndef c(b):\n cur = n\n acc = 0\n while cur != 0:\n div, mod = divmod(cur, b)\n acc += mod\n cur = div\n return acc\n\ndef g(b):\n if b > n: return n\n return sum(divmod(n,b))\n\ndef f():\n if n == s:\n return (n + 1)\n if n < s:\n return -1\n rt = math.ceil(math.sqrt(n))\n for b in range(2, rt + 1):\n if c(b) == s: return b\n for p in range(rt - 1, 0, -1):\n q = s - p\n x = n - q\n b = x // p\n if g(b) == s:\n return b\n return -1\n \nprint(f())", "neg": "import math\nn = int(input())\ns = int(input())\n\ndef c(b):\n cur = n\n acc = 0\n while cur != 0:\n div, mod = divmod(cur, b)\n acc += mod\n cur = div\n return acc\n\ndef f():\n if n == s:\n return (n + 1)\n if n < s:\n return -1\n rt = math.ceil(math.sqrt(n))\n for b in range(2, rt + 1):\n if c(b) == s: return b\n for p in range(rt, 0, -1):\n q = s - p\n x = n - q\n b = x // p\n if x % p == 0 and b > q and b > p: return b\n return -1\n \nprint(f())", "jacc_sim": 0.9148936170212766, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [229, 204], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u232852711", "n_user": "u232852711", "pos": "from math import sqrt\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b)+(n%b)\n\ndef solve(n, s):\n if s == n:\n print(n+1)\n return\n elif s > n:\n print(-1)\n return\n else:\n for i in range(2, int(sqrt(n))+1):\n if f(i, n) == s:\n print(i)\n return\n \n for i in range(int(sqrt(n)), 0, -1):\n b = (n-s)/i+1\n if b == int(b) and f(int(b), n) == s:\n print(int(b))\n return\n\n print(-1)\n return\n\nsolve(n, s)", "neg": "from math import sqrt\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b)+(n%b)\n\ndef solve(n, s):\n if s == n:\n print(n+1)\n return\n elif n < s:\n ans = -1\n else:\n for i in range(2, int(sqrt(n))+1):\n if f(i, n) == s:\n print(i)\n return\n \n for i in range(int(sqrt(n)), 0, -1):\n b = (n-s)/i+1\n if b == int(b) and f(int(b), n) == s:\n print(int(b))\n return\n\n print(-1)\n return\n\nsolve(n, s)\n\n\n\n\n \n", "jacc_sim": 0.9459459459459459, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [228, 232], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u729707098", "n_user": "u729707098", "pos": "from math import sqrt\nn = int(input())\ns = int(input())\ndef f(x,y):\n\tif y 0:\n c += k % i\n k //= i\n if c == s:\n f = i\n break\nif f is None:\n for i in range(int(math.sqrt(n)), 1, -1):\n b = n // i\n k = n\n c = 0\n while k > 0:\n c += k % b\n k //= b\n if s >= c and (s - c) % i == 0 and b - (s - c) // i > n // (i + 1):\n f = b - (s - c) // i\n break\nif f is None:\n if s == n: f = n + 1\n elif s <= (n + 1) // 2: f = n - s + 1\n elif s == 1: f = n\nif f is None: print(-1)\nelse: print(f)\n", "neg": "import math\n\nn = int(input())\ns = int(input())\nf = None\nfor i in range(2, math.ceil(math.sqrt(n))):\n c = 0\n k = n\n while k > 0:\n c += k % i\n k //= i\n if c == s:\n f = i\n break\nif f is None:\n for i in range(int(math.sqrt(n)), 1, -1):\n b = n // i\n k = n\n c = 0\n while k > 0:\n c += k % b\n k //= b\n if (s - c) % i == 0 and b + (s - c) // i < n // (i - 1):\n f = b + (s - c) // i\n break\nif f is None and s <= n // 2:\n f = n - s + 1\nif f is None and s == 1:\n f = n\nif f is None and s == n:\n f = n + 1\nif f is None: print(-1)\nelse: print(f)\n", "jacc_sim": 0.975, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [266, 267], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u343675824", "n_user": "u343675824", "pos": "import sys\nn = int(input())\ns = int(input())\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n % b\n\nif s == n:\n print(n+1)\n sys.exit(0)\nif n < s:\n print(-1)\n sys.exit(0)\n \nans = None\nfor i in range(2, n):\n if i * i > n:\n break\n if f(i, n) == s:\n ans = i\n break\n\nfor i in range(1, n):\n if i * i > n:\n break\n if (n - s) % i == 0:\n b = (n - s) // i + 1\n if f(b, n) == s:\n if ans is None:\n ans = (n - s) // i + 1\n else:\n ans = min((ans, (n - s) // i + 1))\n\nif ans is None:\n print(-1)\nelse:\n print(ans)\n", "neg": "import sys\nn = int(input())\ns = int(input())\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n % b\n\nif s == n:\n print(n+1)\n sys.exit(0)\nif n < s:\n print(-1)\n sys.exit(0)\n \nans = None\nfor i in range(2, n):\n if i * i > n:\n break\n if f(i, n) == s:\n ans = i\n break\nfor i in range(1, n):\n if i * i > n:\n break\n if (n - s) % i == 0:\n ans = (n - s) // i + 1\n break\nif ans is None:\n print(-1)\nelse:\n print(ans)\n", "jacc_sim": 0.9743589743589743, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [271, 218], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u614550445", "n_user": "u614550445", "pos": "\nimport math\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n%b\n\nif n == s:\n print(n+1)\n exit()\n\nfor b in range(2, int(math.sqrt(n))+1):\n if f(b, n) == s:\n print(b)\n exit()\n\nfor p in list(range(1, min(int(math.sqrt(n))+1, s+1)))[::-1]:\n q = s - p\n b = (n - q) // p\n if b >= 2 and f(b, n) == s:\n print(b)\n exit()\n\nprint(-1)", "neg": "\nimport math\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, n//b) + n%b\n\nif n == s:\n print(n+1)\n exit()\n\nfor b in range(2, int(math.sqrt(n))+1):\n if f(b, n) == s:\n print(b)\n exit()\n\nfor p in list(range(1, min(int(math.sqrt(n))+1, s+1)))[::-1]:\n q = s - p\n if (n - q) % p == 0:\n b = (n - q) // p\n print(b)\n exit()\n\nprint(-1)", "jacc_sim": 0.925, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [201, 198], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04014", "p_user": "u333917945", "n_user": "u333917945", "pos": "import math, sys\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, math.floor(n/b)) + n % b\n\nif s == n:\n print(n+1)\n sys.exit()\n\n#print(2, math.ceil(math.sqrt(n)))\nfor b in range(2, math.floor(math.sqrt(n))+1):\n #print(b)\n if(f(b, n) == s):\n print(b)\n sys.exit()\n\n#print(math.floor(math.sqrt(n))-1)\nfor p in range(1, math.floor(math.sqrt(n))+1):\n #print(p)\n _p = math.floor(math.sqrt(n))+1-p\n b = int((n-s)/_p) + 1\n if(b >= 2 and f(b, n) == s):\n print(b)\n sys.exit()\n\nprint(\"-1\")", "neg": "import math, sys\n\nn = int(input())\ns = int(input())\n\ndef f(b, n):\n if n < b:\n return n\n else:\n return f(b, math.floor(n/b)) + n % b\n\nif s == n:\n print(n+1)\n sys.exit()\n\nprint(2, math.ceil(math.sqrt(n)))\nfor b in range(2, math.floor(math.sqrt(n))+1):\n #print(b)\n if(f(b, n) == s):\n print(b)\n sys.exit()\n\nprint(math.floor(math.sqrt(n))-1)\nfor p in range(1, math.ceil(math.sqrt(n))):\n #print(p)\n b = int((n-s)/p) + 1\n if(b >= 2 and f(b, n) == s):\n print(b)\n sys.exit()\n\nprint(\"-1\")\n", "jacc_sim": 0.975, "nl": "You are given two integers, n and s. Define the function f(b, n) as follows: f(b, n) = n when n < b, and f(b, n) = f(b, floor(n / b)) + (n mod b) when n \u2265 b. Determine if there exists an integer b (b \u2265 2) such that f(b, n) = s. If so, find the smallest such b. If no such b exists, print -1. Constraints: 1 \u2264 n \u2264 10^11, 1 \u2264 s \u2264 10^11. Input is given as n and s. Output the smallest b if it exists, otherwise output -1. Example: Input: 87654, 30 Output: 10. Input: 87654, 138 Output: 100. Input: 87654, 45678 Output: -1. Input: 31415926535, 1 Output: 31415926535. Input: 1, 31415926535 Output: -1.", "before_after_length": [275, 251], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u648315264", "n_user": "u648315264", "pos": "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\nMOD = 10**9 + 7\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nimport bisect\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\n\ndef main():\n n,a = i_map()\n x = i_list()\n x.insert(0,0)\n\n dp = [[[0]*(n*a+1) for _ in range(n+1)] for _ in range(n+1)]\n for i in range(n+1):\n dp[i][0][0] = 1\n\n for i in range(1, n+1):\n for j in range(1, n+1):\n for k in range(1, n*a + 1):\n dp[i][j][k] = dp[i - 1][j][k]\n if k >= x[i]:\n dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, n+1):\n ans += dp[n][j][a*j]\n print(ans)\n\n \n\nif __name__==\"__main__\":\n main()\n\n ", "neg": "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\nMOD = 10**9 + 7\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nimport bisect\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\n\ndef main():\n n,a = i_map()\n x = i_list()\n x.insert(0,0)\n\n dp = [[[0]*(n*a+1) for _ in range(n+1)] for _ in range(n+1)]\n for i in range(n+1):\n dp[i][0][0] = 1\n\n for i in range(1, n+1):\n for j in range(1, n+1):\n for k in range(1, n*a + 1):\n dp[i][j][k] = dp[i - 1][j][j]\n if k >= x[i]:\n dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, n+1):\n ans += dp[n][j][a*j]\n print(ans)\n\n \n\nif __name__==\"__main__\":\n main()\n\n ", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [488, 488], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u539969758", "n_user": "u539969758", "pos": "N , A = map(int, input().split())\nx = [0] + list((map(int, input().split())))\n\nans = 0\n\ndp = [[[0 for _ in range(N*A + 1)] for _ in range(N+1)] for _ in range(N+1)] # dp[i][num][j] : i\u3053\u76ee\u307e\u3067\u307f\u3066num\u500b\u9078\u3093\u3067j\u3092\u3064\u304f\u308b\u65b9\u6cd5\ndp[0][0][0] = 1\nfor i in range(1, N+1):\n for num in range(i+1):\n for j in range(N * A+1):\n dp[i][num][j] += dp[i-1][num][j]\n if j >= x[i]:\n dp[i][num][j] += dp[i-1][num-1][j-x[i]]\n\nfor num in range(1, N+1):\n ans += dp[N][num][num * A]\n\nprint(ans)", "neg": "N , A = map(int, input().split())\nx = [0] + list((map(int, input().split())))\n\nans = 0\n\ndp = [[[0 for _ in range(N*A + 1)] for _ in range(N+1)] for _ in range(N+1)] # dp[i][num][j] : i\u3053\u76ee\u307e\u3067\u307f\u3066num\u500b\u9078\u3093\u3067j\u3092\u3064\u304f\u308b\u65b9\u6cd5\ndp[0][0][0] = 1\nfor i in range(1, N+1):\n for num in range(i+1):\n for j in range(num * A+1):\n dp[i][num][j] += dp[i-1][num][j]\n if j >= x[i]:\n dp[i][num][j] += dp[i-1][num-1][j-x[i]]\n\nfor num in range(1, N+1):\n ans += dp[N][num][num * A]\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [269, 269], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u511824539", "n_user": "u511824539", "pos": "N, A = map(int, input().split())\nX = list(map(lambda x: int(x)-A, input().split()))\nX_MAX = max(max(X), -min(X))\nNX = N * X_MAX\ndp = [[0] * (X_MAX * (N+1) * 2 + 1) for i in range(N+1)]\ndp [0][NX] = 1\nfor i in range(1, N+1):\n for j in range(NX*2+1):\n dp[i][j] += dp[i-1][j]\n dp[i][j] += dp[i-1][j-X[i-1]]\n\nprint(dp[N][NX]-1)", "neg": "N, A = map(int, input().split())\nX = list(map(lambda x: int(x)-A, input().split()))\nX_MAX = max(max(X), -min(X))\nNX = N * X_MAX\ndp = [[0] * (X_MAX * (N+1) * 2 + 1) for i in range(N+1)]\ndp [0][0] = 1\nfor i in range(1, N+1):\n for j in range(NX*2+1):\n dp[i][j] += dp[i-1][j]\n dp[i][j] += dp[i-1][j-X[i-1]]\n\nprint(dp[N][NX]-1)", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [176, 176], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u036104576", "n_user": "u036104576", "pos": "N, A = map(int, input().split())\nX = list(map(int, input().split()))\nY = [x - A for x in X]\n\ndp = [0] * 5010\ndp[2500] = 1\n\nfor y in Y:\n r = []\n if y >= 0:\n r = range(5009, -1, -1)\n else:\n r = range(5010)\n for i in r:\n if i - y < 0 or i - y >= 5010:\n continue\n dp[i] += dp[i - y]\nprint(dp[2500] - 1)\n", "neg": "N, A = map(int, input().split())\nX = list(map(int, input().split()))\nY = [x - A for x in X]\n\ndp = [0] * 5010\ndp[2500] = 1\n\nfor y in Y:\n for i in range(5009, -1, -1):\n if i - y < 0 or i - y >= 5010:\n dp[i] = 0\n else:\n dp[i] += dp[i - y]\nprint(dp[2500] - 1)\n", "jacc_sim": 0.95, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [154, 132], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u046158516", "n_user": "u046158516", "pos": "n,a=map(int,input().split())\nx=list(map(int,input().split()))\ndic={}\ndic2=dic.copy()\nfor i in range(n):\n for j in dic:\n if j+x[i]-a in dic2:\n dic2[j+x[i]-a]+=dic[j]\n else:\n dic2[j+x[i]-a]=dic[j]\n if x[i]-a in dic2:\n dic2[x[i]-a]+=1\n else:\n dic2[x[i]-a]=1\n dic=dic2.copy()\nif 0 in dic:\n print(dic[0])\nelse:\n print(0)", "neg": "n,a=map(int,input().split())\nx=list(map(int,input().split()))\ndic={}\ndic2=dic.copy()\nfor i in range(n):\n for j in dic:\n if j+x[i]-a in dic2:\n dic2[j+x[i]-a]+=dic[j]\n else:\n dic2[j+x[i]-a]=dic[j]\n if x[i]-a in dic:\n dic2[x[i]-a]+=1\n else:\n dic2[x[i]-a]=1\n dic=dic2.copy()\nprint(dic[0])", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [186, 169], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u222668979", "n_user": "u434966508", "pos": "from collections import defaultdict\n\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\ny = [xi - a for xi in x]\n\n# \u89e3\u8aacAC\ndp = [defaultdict(int) for i in range(n + 1)]\ndp[0][0] = 1\nfor i in range(n):\n for j in dp[i]:\n dp[i + 1][j + y[i]] += dp[i][j]\n dp[i + 1][j] += dp[i][j]\nprint(dp[n][0] - 1)\n", "neg": "from collections import defaultdict\n\nn, a = map(int, input().split())\nx = list(map(int, input().split()))\ny = [xi - a for xi in x]\n\n# \u89e3\u8aacAC\ndp = [defaultdict(int) for i in range(n + 1)]\ndp[0][0] = 1\n\nfor i in range(n):\n for j in dp[i]:\n dp[i + 1][j + y[i]] += dp[i][j]\n dp[i + 1][j] += dp[i][j]\n print(dp[i][j],dp[i+1][j+y[i]],dp[i + 1][j])\nprint(dp[n][0] - 1)\n", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [150, 182], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u630941334", "n_user": "u630941334", "pos": "def main():\n N, A = map(int, input().split())\n x = [0]\n x.extend(list(map(int, input().split())))\n\n dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]\n for i in range(N + 1):\n dp[i][0][0] = 1\n\n for i in range(1, N + 1):\n for j in range(1, i + 1):\n for k in range(1, N * A + 1):\n if k < x[i]:\n dp[i][j][k] = dp[i - 1][j][k]\n else:\n dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, N + 1):\n ans += dp[N][j][A * j]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "neg": "def main():\n N, A = map(int, input().split())\n x = [0].extend(list(map(int, input().split())))\n\n dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]\n for i in range(N + 1):\n dp[i][0][0] = 1\n\n for i in range(1, N + 1):\n for j in range(1, i + 1):\n for k in range(1, N * A + 1):\n if k < x[k]:\n dp[i][j][k] = dp[i - 1][j][k]\n else:\n dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]\n\n ans = 0\n for j in range(1, N + 1):\n ans += dp[N][j][A * j]\n\n print(ans)\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [272, 268], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u994521204", "n_user": "u994521204", "pos": "n,a=map(int,input().split())\nX=list(map(int,input().split()))\ndp=[[[0]*55 for _ in range(2555)] for _ in range(55)]\nans=0\ndp[0][0][0]=1\nfor i in range(n):\n for j in range(52+50*i):\n for k in range(n):\n ni=i+1\n nj=j+X[i]\n nk=k+1\n dp[ni][nj][nk]+=dp[i][j][k]\n dp[ni][j][k]+=dp[i][j][k]\nans=0\nfor i in range(1,n+1):\n ans+=dp[n][i*a][i]\nprint(ans)", "neg": "%time\nn,a=map(int,input().split())\nX=list(map(int,input().split()))\ndp=[[[0]*55 for _ in range(2555)] for _ in range(55)]\nans=0\ndp[0][0][0]=1\nfor i in range(n):\n for j in range(52+50*i):\n for k in range(n):\n ni=i+1\n nj=j+X[i]\n nk=k+1\n dp[ni][nj][nk]+=dp[i][j][k]\n dp[ni][j][k]+=dp[i][j][k]\nans=0\nfor i in range(1,n+1):\n ans+=dp[n][i*a][i]\nprint(ans)", "jacc_sim": 0.9487179487179487, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [193, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u670180528", "n_user": "u670180528", "pos": "n,a,*x=map(int,open(0).read().split());dp={0:1}\nfor i in x:\n\tfor k,v in set(dp.items()):\n\t\tdp[i+k-a]=dp.get(i+k-a,0)+v\nprint(dp[0]-1)", "neg": "n,a,*x=map(int,open(0).read().split());dp={0:1}\nfor i in x:\n\tfor k,v in dp.items():\n\t\tdp[i+k-a]=dp.get(i+k-a,0)+v\nprint(dp[0]-1)", "jacc_sim": 0.9705882352941176, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [80, 77], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u285443936", "n_user": "u285443936", "pos": "N, A = map(int, input().split())\nx= [int(i) for i in input().split()]\nX = max(x)\ndp = [[[0]*(X*N+1) for i in range(N+1)] for j in range(N+1)]\ndp[0][0][0] = 1\nans = 0\n\nfor j in range(1,N+1):\n for k in range(j+1):\n for s in range(X*N+1):\n dp[j][k][s] = dp[j-1][k][s]\n if s >= x[j-1]:\n dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]\n \nfor i in range(N+1):\n ans += dp[-1][i][i*A]\n if (i+1)*A > X*N:\n break\nprint(ans-1)", "neg": "N, A = map(int, input().split())\nx= [int(i) for i in input().split()]\nX = max(x)\ndp = [[[0]*(X*N+1) for i in range(N+1)] for j in range(N+1)]\ndp[0][0][0] = 1\nans = 0\n\nfor j in range(1,N+1):\n for k in range(j+1):\n for s in range(X*N+1):\n dp[j][k][s] = dp[j-1][k][s]\n if s >= x[j-1]:\n dp[j][k][s] += dp[j-1][k-1][s-x[j-1]]\n \nfor i in range(1,N+1):\n ans += dp[-1][i][i*A]\n if (i+1)*A >= X*N:\n break\nprint(ans)", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [230, 230], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u077291787", "n_user": "u077291787", "pos": "# ABC044C - \u9ad8\u6a4b\u541b\u3068\u30ab\u30fc\u30c9 / Tak and Cards (ARC060C)\nfrom collections import defaultdict\n\n\ndef main():\n N, A = tuple(map(int, input().split()))\n X = tuple(map(lambda x: int(x) - A, input().split()))\n D = defaultdict(int)\n D[0] = 1\n for i in X:\n for j, k in list(D.items()):\n D[i + j] += k\n print(D[0] - 1)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "# ABC044C - \u9ad8\u6a4b\u541b\u3068\u30ab\u30fc\u30c9 / Tak and Cards (ARC060C)\nfrom collections import defaultdict\n\n\ndef main():\n N, A = tuple(map(int, input().split()))\n X = tuple(map(int, input().split()))\n Y = [i - A for i in X]\n D = defaultdict(int)\n D[0] = 1\n for i in Y:\n for j, k in D.items():\n D[i + j] += k\n print(D[0] - 1)\n\n\nif __name__ == \"__main__\":\n main()", "jacc_sim": 0.9285714285714286, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [166, 167], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u977193988", "n_user": "u977193988", "pos": "n,a=map(int,input().split())\nX=[int(i)-a for i in input().split()]\n\nmemo={0:1}\nfor x in X:\n for k,v in list(memo.items()):\n memo[x+k]=memo.get(x+k,0)+v\nprint(memo[0]-1)\n\n", "neg": "n,a=map(int,input().split())\nX=[int(i)-a for i in input().split()]\n\nmemo={0:1}\nfor x in X:\n for k,v in list(memo.items()):\n memo[x+k]=memo.get(x+k,0)+v\n print(memo)\nprint(memo[0]-1)\n", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [88, 93], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u190405389", "n_user": "u190405389", "pos": "n,a = map(int, input().split())\nx = list(map(int, input().split()))\n\n# dp[i][k][j]\n# i\u679a\u306e\u4e2d\u304b\u3089\u3001k\u679a\u9078\u3093\u3067\u3001\u548c\u304cj\ndp = [[[0 for j in range(2501)]for k in range(n+1)] for i in range(n+1)]\n\nfor i in range(n+1):\n dp[i][0][0]=1\n\nfor i in range(1,n+1):\n for k in range(1,n+1):\n for j in range(2501):\n if j-x[i-1]>=0:\n dp[i][k][j]=dp[i-1][k-1][j-x[i-1]]+dp[i-1][k][j]\n else:\n dp[i][k][j]=dp[i-1][k][j]\n\nans = 0\nfor i in range(1,n+1):\n ans += dp[n][i][i*a]\n\n\nprint(ans)", "neg": "n,a = map(int, input().split())\nx = list(map(int, input().split()))\n\n# dp[i][k][j]\n# i\u679a\u306e\u4e2d\u304b\u3089\u3001k\u679a\u9078\u3093\u3067\u3001\u548c\u304cj\ndp = [[[0 for j in range(2501)]for k in range(n+1)] for i in range(n+1)]\n\ndp[0][0][0]=1\n\nfor i in range(1,n+1):\n for k in range(1,n+1):\n for j in range(2501):\n if j-x[i-1]>=0:\n dp[i][k][j]=dp[i-1][k-1][j-x[i-1]]+dp[i-1][k][j]\n else:\n dp[i][k][j]=dp[i-1][k][j]\n\nans = 0\nfor i in range(1,n+1):\n ans += dp[n][i][i*a]\n\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [290, 279], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u310678820", "n_user": "u310678820", "pos": "n, a =map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nmemo=[[-1]*6000 for i in range(60)]\ndef dp(k, value):\n if k==n:\n if value==0:\n return 1\n else:\n return 0\n if memo[k][value]>=0:\n return memo[k][value]\n memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)\n return memo[k][value]\nprint(dp(0, 0)-1)", "neg": "n, a =map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nmemo=[[-1]*110 for i in range(60)]\ndef dp(k, value):\n if k==n:\n if value==0:\n return 1\n else:\n return 0\n if memo[k][value]>0:\n return memo[k][value]\n memo[k][value]=dp(k+1, value+x[k])+dp(k+1, value)\n print(memo[k][value], k, value)\n return memo[k][value]\nprint(dp(0, 0)-1)", "jacc_sim": 0.9473684210526315, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [158, 170], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u649373416", "n_user": "u649373416", "pos": "import numpy as np\nhi = np.zeros((5000,60),np.int64)\nhi[0,0]=1\nn,a = [int(it) for it in input().split()]\nli = [int(it) for it in input().split()]\nfor i in li:\n hi_ = hi.copy()\n hi[i:-1,1:]+=hi_[:-1-i,:-1]\ns = 0\nfor i in range(n):\n s+=hi[(i+1)*a,i+1]\nprint (s)\n", "neg": "import numpy as np\nhi = np.zeros((5000,60),np.int64)\nhi[0,0]=1\nn,a = [int(it) for it in input().split()]\nli = [int(it) for it in input().split()]\nfor i in li:\n \u3000hi_ = hi.copy()\n hi[i:-1,1:]+=hi_[:-1-i,:-1]\ns = 0\nfor i in range(n):\n s+=hi[(i+1)*a,i+1]\nprint (s)\n", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [140, 143], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u371763408", "n_user": "u371763408", "pos": "n,a=map(int,input().split())\nX=list(map(int,input().split()))\n\ndp=[[[0]*(sum(X)+1) for _ in range(n+1)] for _ in range(n+1)]\n\ndp[0][0][0]=1\n\nfor i in range(1,n+1): #x_1,x_2...x_n\n for k in range(i): #k\u679a\u6570\u9078\u3076\n for s in range(sum(X)+1): #\u5408\u8a08\n if dp[i-1][k][s]:\n dp[i][k+1][s+X[i-1]]+=dp[i-1][k][s] #1\u679a\u9078\u629e\u80a2\u304c\u5897\u3048\u305f\u6642\u306e\u3001\u305d\u306e\u30ab\u30fc\u30c9\u3092\u52a0\u3048\u305f\u7d50\u679c\u3092\u52a0\u7b97\n dp[i][k][s]+=dp[i-1][k][s]\nans=0\nfor i in range(1,n+1):\n for j in range(1,sum(X)+1):\n if j == i*a: #\u5408\u8a08\u304c\u5e73\u5747\u306ei\u500d\u306e\u6642\u306b\u52a0\u3048\u308b\n ans+=dp[n][i][j]\n\nprint(ans)", "neg": "n,a=map(int,input().split())\nX=list(map(int,input().split()))\n\ndp=[[[0]*(sum(X)+1) for _ in range(n+1)] for _ in range(n+1)]\n\ndp[0][0][0]=1\n\nfor i in range(1,n+1): #x_1,x_2...x_n\n for k in range(i): #k\u679a\u6570\u9078\u3076\n for s in range(sum(X)+1): #\u5408\u8a08\n if dp[i-1][k][s]:\n dp[i][k+1][s+X[i-1]]+=dp[i-1][k][s] #1\u679a\u9078\u629e\u80a2\u304c\u5897\u3048\u305f\u6642\u306e\u3001\u305d\u306e\u30ab\u30fc\u30c9\u3092\u52a0\u3048\u305f\u7d50\u679c\u3092\u52a0\u7b97\n dp[i][k][s]+=dp[i-1][k][s]\nans=0\nfor i in range(1,n):\n for j in range(1,sum(X)+1):\n if j == i*a: #\u5408\u8a08\u304c\u5e73\u5747\u306ei\u500d\u306e\u6642\u306b\u52a0\u3048\u308b\n ans+=dp[n][i][j]\n\nprint(ans)", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [380, 378], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u856232850", "n_user": "u371467115", "pos": "n,a = map(int, input().split())\nx = list(map(int,input().split()))\nx = [i-a for i in x]\n\nd = {}\nd[0] = 1\nfor i in x:\n for j,k in list(d.items()):\n d[j+i] = d.get(j+i,0)+k\nprint(d[0]-1)", "neg": "n,a=map(int, input().split())\nx=list(map(int, input().split()))\nx=[i-a for i in x]\nd={0:0}\nfor i in x:\n for j,k in list(d.items()):\n d[i+j]=d.get(i+j,0)+k\nprint(d[0]-1)\n#sample code.", "jacc_sim": 0.9117647058823529, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [100, 99], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u030726788", "n_user": "u030726788", "pos": "n,a=map(int,input().split())\nx=list(map(int,input().split()))\ny=[]\nfor i in x:\n y.append(i-a)\ns=2*n*a\ndp=[[0 for i in range(s+1)] for j in range(n+1)]\ndp[0][n*a]=1\nfor i in range(n):\n for j in range(s+1):\n x=j-y[i]\n if(0<=x and x<=2*n*a):\n dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]\n else:\n dp[i+1][j]=dp[i][j]\n\nprint(dp[n][n*a]-1)", "neg": "n,a=map(int,input().split())\nx=list(map(int,input().split()))\ny=[]\nfor i in x:\n y.append(i-a)\ns=2*n*a\ndp=[[0 for i in range(s+1)] for j in range(n+1)]\ndp[0][n*a]=1\nfor i in range(n):\n for j in range(s+1):\n x=j-y[i]\n if(0<=x and x<=2*n*a):\n dp[i+1][j]=dp[i][j-y[i]]+dp[i][j]\n else:\n dp[i+1][j]=dp[i][j]\n\nprint(dp[n][n*a])", "jacc_sim": 1.0, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [199, 196], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04015", "p_user": "u862517767", "n_user": "u862517767", "pos": "n,a=map(int,input().split())\nx=[0]+[i-a for i in map(int,input().split())]\nd={}\ndef f(i):\n if i==n+1:\n return {0:1}\n if i in d:\n return d[i]\n d[i]={}\n for j in range(i+1,n+2):\n for k,v in f(j).items():\n d[i].setdefault(x[i]+k,0)\n d[i][x[i]+k]+=v\n return d[i]\nprint(f(0)[0]-1)", "neg": "n,a=map(int,input().split())\nx=[0]+[i-a for i in map(int,input().split())]\nd={}\ndef f(i):\n if i==n+1:\n return c([0])\n if i in d:\n return d[i]\n d[i]={}\n for j in range(i+1,n+2):\n for k,v in f(j).items():\n d[i].setdefault(x[i]+k,0)\n d[i][x[i]+k]+=v\n return d[i]\nprint(f(0)[0]-1)", "jacc_sim": 0.9736842105263158, "nl": "You have a set of N cards, each with an integer written on it. You need to select one or more cards so that the average of the integers on the selected cards is exactly A. How many ways can you make this selection? Constraints: 1 \u2264 N \u2264 50, 1 \u2264 A \u2264 50, 1 \u2264 xi \u2264 50. Input format: N A followed by the integers on the cards. Output the number of ways to select cards such that the average of the integers is exactly A.", "before_after_length": [158, 157], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04017", "p_user": "u803848678", "n_user": "u803848678", "pos": "import sys\ninput = sys.stdin.readline\n\nfrom bisect import bisect\n\nn = int(input())\nx = list(map(int, input().split()))\nl = int(input())\n\nm = 20\npar = [[-1]*n for i in range(m)]\n\nfor i in range(n):\n j = bisect(x, x[i]+l)-1\n par[0][i] = j\n\nfor i in range(m-1):\n for j in range(n):\n par[i+1][j]=par[i][par[i][j]]\n\ndef hoge(x, y):\n k = 0\n for i in range(m)[::-1]:\n if par[i][x] < y:\n k += 1< b:\n a,b = b,a\n print(hoge(a,b))", "neg": "import sys\ninput = sys.stdin.readline\n\nfrom bisect import bisect\n\nn = int(input())\nx = list(map(int, input().split()))\nl = int(input())\n\nm = 20\npar = [[-1]*n for i in range(m)]\n\nfor i in range(n):\n j = bisect(x, x[i]+l)-1\n par[0][i] = j\n\nfor i in range(m-1):\n for j in range(n):\n par[i+1][j]=par[i][par[i][j]]\n\ndef hoge(x, y):\n k = 0\n for i in range(m)[::-1]:\n if par[i][x] < y:\n k += 1<= y:\n k += 1< b:\n a,b = b,a\n print(hoge(a,b))", "jacc_sim": 0.96, "nl": "You are given the locations of N hotels on a straight line. A traveler has two principles: not traveling more than a distance L in a day and not sleeping in the open. For Q queries, find the minimum days needed for the traveler to move from the a-th to the b-th hotel. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 L \u2264 10^9, 1 \u2264 Q \u2264 10^5, 1 \u2264 xi < x2 < ... < xN \u2264 10^9, xi+1 - xi \u2264 L, 1 \u2264 aj, bj \u2264 N, aj \u2260 bj. The input format is N, followed by the hotel locations, L, Q, and the queries. Output the minimum days for each query.", "before_after_length": [280, 301], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04017", "p_user": "u333945892", "n_user": "u333945892", "pos": "from collections import defaultdict,deque\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\n\nN = int(input())\nxx = inpl()\nL = int(input())\n\nK = N.bit_length()\ndb_r = [[0]*K for i in range(N)]\nfor i,x in enumerate(xx):\n ind = bisect.bisect_right(xx,x+L)\n db_r[i][0] = ind-1\n\nfor k in range(1,K):\n for i in range(N):\n db_r[i][k] = db_r[db_r[i][k-1]][k-1]\n\ndef check(a,b,d):\n L = d.bit_length()\n for k in range(L):\n if d & (1<= b\n\nQ = int(input())\nfor i in range(Q):\n a,b = inpl()\n a -= 1\n b -= 1\n a,b = min(a,b),max(a,b)\n OK = N\n NG = 0\n while OK-NG>1:\n mid = (OK+NG)//2\n if check(a,b,mid): OK = mid\n else: NG = mid\n print(OK)\n", "neg": "from collections import defaultdict,deque\nimport sys,heapq,bisect,math,itertools,string,queue,datetime\nsys.setrecursionlimit(10**8)\nINF = float('inf')\nmod = 10**9+7\ndef inpl(): return list(map(int, input().split()))\ndef inpls(): return list(input().split())\n\nN = int(input())\nxx = inpl()\nL = int(input())\n\nK = N.bit_length()\ndb_r = [[0]*K for i in range(N)]\nfor i,x in enumerate(xx):\n ind = bisect.bisect_right(xx,x+L)\n db_r[i][0] = ind-1\n\nfor k in range(1,K):\n for i in range(N):\n db_r[i][k] = db_r[db_r[i][k-1]][k-1]\n\nprint(db_r[0])\n\ndef check(a,b,d):\n L = d.bit_length()\n for k in range(L):\n if d & (1<= b\n\nQ = int(input())\nfor i in range(Q):\n a,b = inpl()\n a -= 1\n b -= 1\n a,b = min(a,b),max(a,b)\n OK = N\n NG = 0\n while OK-NG>1:\n mid = (OK+NG)//2\n if check(a,b,mid): OK = mid\n else: NG = mid\n print(OK)\n", "jacc_sim": 1.0, "nl": "You are given the locations of N hotels on a straight line. A traveler has two principles: not traveling more than a distance L in a day and not sleeping in the open. For Q queries, find the minimum days needed for the traveler to move from the a-th to the b-th hotel. Constraints: 2 \u2264 N \u2264 10^5, 1 \u2264 L \u2264 10^9, 1 \u2264 Q \u2264 10^5, 1 \u2264 xi < x2 < ... < xN \u2264 10^9, xi+1 - xi \u2264 L, 1 \u2264 aj, bj \u2264 N, aj \u2260 bj. The input format is N, followed by the hotel locations, L, Q, and the queries. Output the minimum days for each query.", "before_after_length": [394, 404], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04018", "p_user": "u378667182", "n_user": "u378667182", "pos": "w=list(input())\nn=len(w)\nt=-1\ndef Z(s):\n m=len(s);z=[0]*m;c=0;f=[1]*m;\n for i in range(1,m):\n if i+z[i-c]2:\n ans += a//2-1\n a = 2\n\n if a!= 0:\n A.append(a)\n elif A:\n ans += max(f(A), f(A[::-1]))\n A = []\n else:\n continue\nelse:\n ans += max(f(A), f(A[::-1]))\nprint(ans)\n\n", "neg": "n = int(input())\n\n\ndef f(lst):\n res = 0\n ex = 0\n for a in lst:\n ex += a\n res += ex//2\n ex %= 2\n return res\n\nA = []\nans = 0\nfor _ in range(n):\n a = int(input())\n if a%2:\n a = 1\n else:\n a = min(a, 2)\n\n if a!= 0:\n A.append(a)\n elif A:\n ans += max(f(A), f(A[::-1]))\n else:\n continue\nprint(ans)", "jacc_sim": 0.9512195121951219, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [200, 155], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u010090035", "n_user": "u010090035", "pos": "n=int(input())\na=[]\nans=0\nfor i in range(n):\n a.append(int(input()))\n if(i>0 and a[-2]==1 and a[-1]>0):\n ans+=1\n a[-2]-=1\n a[-1]-=1\n ans+=a[-1]//2\n a[-1]=a[-1]%2\n if(i>0 and a[-2]==1 and a[-1]==1):\n ans+=1\n a[-2]-=1\n a[-1]-=1\n\nprint(ans)\n", "neg": "n=int(input())\na=[]\nans=0\nfor i in range(n):\n a.append(int(input()))\n ans+=a[-1]//2\n a[-1]//=2\n if(i>0 and a[-2]==1 and a[-1]==1):\n ans+=1\n a[-2]-=1\n a[-1]-=1\n\nprint(ans)\n", "jacc_sim": 0.9642857142857143, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [156, 106], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u503228842", "n_user": "u503228842", "pos": "N = int(input())\nans = 0\nprev_A = -10\nprev_card_num = 0\nfor i in range(1,N+1):\n A = int(input())\n ans += (prev_card_num + A)//2\n if prev_card_num == 1 and A == 0:\n prev_card_num = 0\n elif (prev_card_num+A)%2 == 1:\n prev_card_num = 1\n prev_A = i\n else:\n prev_card_num = 0\n prev_A = i\nprint(ans)", "neg": "N = int(input())\nans = 0\nprev_A = -10\nprev_card_num = 0\nfor i in range(1,N+1):\n A = int(input())\n ans += (prev_card_num + A)//2\n if prev_A == i-1 and (prev_card_num+A)%2 == 1:\n prev_card_num = 1\n prev_A = i\n elif prev_A == i-1 and (prev_card_num+A)%2 == 0:\n prev_card_num = 0\n else:\n prev_card_num = 1\n prev_A = i\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [142, 160], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u708255304", "n_user": "u572144347", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]+[0]\n\nans = 0\nfor i in range(N):\n if A[i] % 2 == 0:\n ans += A[i]//2\n A[i] = 0\n else:\n ans += A[i]//2\n if A[i+1] > 0:\n ans += 1\n A[i+1] -= 1\n A[i] = 0\nprint(ans)\n", "neg": "N=int(input())\nA=[int(input()) for _ in range(N)]\n \nans=0\nfor i in range(1,N+1):\n if A[i-1]>=A[i]:\n ans+=A[i]\n ans+=(A[i-1]-A[i])//2\n A[i]=0\n else:\n ans+=A[i-1]\n ans+=(A[i]-A[i-1])//2\n A[i]-=A[i-1]\n \nprint(ans)", "jacc_sim": 0.9285714285714286, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [123, 142], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u905582793", "n_user": "u905582793", "pos": "n=int(input())\na = [int(input()) for i in range(n)]\na.append(0)\nans = 0\ntmp = 0\nfor i in range(n+1):\n if a[i]!=0:\n tmp += a[i]\n else:\n ans += tmp//2\n tmp = 0\nprint(ans)", "neg": "n=int(input())\na = [int(input()) for i in range(n)]\na.append(0)\nans = 0\nfor i in range(n+1):\n if a[i]!=0:\n tmp += a[i]\n else:\n ans += tmp//2\n tmp = 0\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [86, 82], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u518042385", "n_user": "u518042385", "pos": "n=int(input())\nl=[]\nfor i in range(n):\n l.append(int(input()))\ncount=0\nfor i in range(n-1):\n if l[i]%2==1 and l[i+1]>0:\n count+=1\n l[i]=l[i]-1\n l[i+1]=l[i+1]-1\nfor i in range(n):\n count+=l[i]//2\nprint(count)", "neg": "n=int(input())\nl=[0]\nfor i in range(n):\n l.append(int(input()))\ncount=0\nfor i in range(n-1):\n if l[i]%2==1 and l[i+1]>0:\n count+=1\n l[i]-=1\n l[i+1]-=1\nfor i in range(n):\n count+=l[i]//2\nprint(count)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [124, 115], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u623687794", "n_user": "u623687794", "pos": "n=int(input())\nans=0\ncheck=0\nfor i in range(n):\n s=int(input())\n if i==n-1:\n check+=s\n ans+=check//2\n elif s!=0:\n check+=s\n else:\n ans+=check//2\n check=0\nprint(ans)\n", "neg": "n=int(input())\nans=0\ncheck=0\nfor i in range(n):\n s=int(input())\n if i==n-1:\n check+=s\n ans+=check//2\n elif s!=0:\n check+=s\n else:\n ans+=check//2\n check=0\nprint(check)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [90, 89], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u312025627", "n_user": "u312025627", "pos": "def main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n ans = 0\n for i in range(n):\n if a[i] == 0:\n continue\n ans += a[i]//2\n if i != n-1 and a[i]&1 and a[i+1] != 0:\n ans += 1\n a[i+1] -= 1\n print(ans)\nif __name__ == \"__main__\":\n main()", "neg": "def main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n ans = 0\n for i in range(n):\n if a[i] == 0:\n continue\n ans = a[i]//2\n if i != n-1 and a[i]&1 and a[i+1] != 0:\n ans += 1\n a[i+1] -= 1\n print(ans)\nif __name__ == \"__main__\":\n main()", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [124, 124], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u798818115", "n_user": "u798818115", "pos": "N=int(input())\nl=[]\n\nfor i in range(N):\n l.append(int(input()))\n\nans=0\n \nfor i in range(N-1):\n ans+=(l[i]-l[i]%2)/2\n l[i]=(l[i]%2)\n if l[i+1]!=0:\n ans+=l[i]\n l[i+1]-=l[i]\nans+=(l[-1]-l[-1]%2)/2\nprint(int(ans))\n ", "neg": "N=int(input())\nl=[]\n\nfor i in range(N):\n l.append(int(input()))\n\nans=0\n \nfor i in range(N-1):\n ans+=(l[i]-l[i]%2)/2\n l[i]=l[i]%2\n if l[i+1]!=0:\n ans+=l[i]\n l[i+1]-=l[i]\nprint(ans)\n \n ", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [141, 123], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u585482323", "n_user": "u585482323", "pos": "#!usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\n#A\ndef A():\n\n return\n\n#B\ndef B():\n n = I()\n a = IR(n)\n ans = 0\n b = [0]*(n+1)\n for i in range(n):\n ans += (a[i]+b[i])>>1\n if (a[i]%2)^(b[i]%2) and a[i]:\n b[i+1] += 1\n print(ans)\n return\n\n#C\ndef C():\n\n return\n\n#D\ndef D():\n\n return\n\n#E\ndef E():\n\n return\n\n#F\ndef F():\n\n return\n\n#Solve\nif __name__ == \"__main__\":\n B()\n", "neg": "#!usr/bin/env python3\nfrom collections import defaultdict,deque\nfrom heapq import heappush, heappop\nimport sys\nimport math\nimport bisect\nimport random\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\n#A\ndef A():\n\n return\n\n#B\ndef B():\n n = I()\n a = IR(n)\n ans = 0\n b = [0]*(n+1)\n for i in range(n):\n ans += (a[i]+b[i])>>1\n if (a[i]%2)^(b[i]%2):\n b[i+1] += 1\n print(ans)\n return\n\n#C\ndef C():\n\n return\n\n#D\ndef D():\n\n return\n\n#E\ndef E():\n\n return\n\n#F\ndef F():\n\n return\n\n#Solve\nif __name__ == \"__main__\":\n B()\n", "jacc_sim": 0.9873417721518988, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [422, 417], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u497046426", "n_user": "u497046426", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]\nans = A[0] // 2\nA[0] = A[0] % 2\nfor i in range(1, N):\n if A[i-1] > 0 and A[i-1] + A[i] >= 2:\n ans += 1; A[i] -= 1\n q, r = divmod(A[i], 2); A[i] = r\n ans += q\nprint(ans)", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\nans = A[0] // 2\nA[0] = A[0] % 2\nfor i in range(1, N):\n if A[i-1] + A[i] >= 2:\n ans += 1; A[i] -= 1\n q, r = divmod(A[i], 2); A[i] = r\n ans += q\nprint(ans)", "jacc_sim": 0.96875, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [120, 111], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u879870653", "n_user": "u879870653", "pos": "N = int(input())\nA = [int(input()) for i in range(N)]\n\nans = 0\ncnt = 0\n\nfor a in A :\n ans += (a+cnt) // 2\n if a == 0 :\n cnt = 0\n else :\n cnt = (a+cnt) % 2\n\nprint(ans)\n", "neg": "N = int(input())\nA = [int(input()) for i in range(N)]\n\nans = 0\ncnt = 0\n\nfor a in A :\n ans += (a+cnt) // 2\n cnt = (a+cnt) % 2\n\nprint(ans)\n", "jacc_sim": 0.92, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [82, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u379692329", "n_user": "u379692329", "pos": "N = int(input())\nA = [int(input()) for _ in range(N)]\nans = 0\ntmp = 0\n\nfor i in A:\n if i != 0:\n tmp += i\n else:\n ans += tmp//2\n tmp = 0\n\nans += tmp//2\n\nprint(ans)", "neg": "N = int(input())\nA = [int(input()) for _ in range(N)]\nans = 0\ntmp = 0\n\nfor i in A:\n if i != 0:\n tmp += i\n else:\n ans += tmp//2\n tmp = 0\n\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [77, 70], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u375616706", "n_user": "u375616706", "pos": "# -*- coding: utf-8 -*-\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN = int(input())\nL = [int(input()) for _ in range(N)]\nans = 0\nprev = 0\nfor a in L:\n if a == 0:\n prev = 0\n continue\n\n a += prev\n ans += a//2\n prev = a % 2\nprint(ans)\n", "neg": "# -*- coding: utf-8 -*-\n# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\nN = int(input())\nL = [int(input()) for _ in range(N)]\nans = 0\nprev = 0\nfor a in L:\n a += prev\n ans += a//2\n prev = a % 2\nprint(ans)\n", "jacc_sim": 0.9523809523809523, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [120, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u969190727", "n_user": "u969190727", "pos": "n=int(input())\nans=0\nres=0\nfor i in range(n):\n a=int(input())\n if res==1:\n if a==0:\n res=0\n elif a%2==0:\n ans+=a//2\n res=1\n else:\n ans+=(a+1)//2\n res=0\n else:\n ans+=a//2\n if a%2==1:\n res=1\nprint(ans)\n", "neg": "n=int(input())\nans=0\nres=0\nfor i in range(n):\n a=int(input())\n if res==1:\n a+=1\n res=0\n ans+=a//2\n if a%2==1:\n res=1\nprint(ans)", "jacc_sim": 0.9166666666666666, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [123, 75], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u572144347", "n_user": "u572144347", "pos": "N=int(input())\nA=[int(input()) for _ in range(N)]\n\nans=0\nidx=[]\nfor i in range(N):\n if A[i]==0:\n idx.append(i+1)\nn=0\nidx.append(N)\nfor iidx in idx:\n ans+=sum(A[n:iidx])//2\n n=iidx\nprint(ans)", "neg": "N=int(input())\nA=[int(input()) for _ in range(N)]\n \nans=0\nfor i in range(N):\n if A[i]==0:\n idx.append(i+1)\n \nn=0\nfor iidx in idx:\n ans+=sum(A[n:iidx])//2\n n=iidx\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [102, 94], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u375616706", "n_user": "u375616706", "pos": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\nA.append(0)\n\n\nans = 0\ntmp = 0\nfor a in A:\n if a == 0:\n ans += tmp//2\n tmp = 0\n else:\n tmp += a\nprint(ans)\n", "neg": "# python template for atcoder1\nimport sys\nsys.setrecursionlimit(10**9)\ninput = sys.stdin.readline\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\n\nans = 0\ntmp = 0\nfor a in A:\n if a == 0:\n ans += tmp//2\n tmp = 0\n else:\n tmp += a\nprint(ans)\n", "jacc_sim": 0.9736842105263158, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [110, 103], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u729133443", "n_user": "u729133443", "pos": "s=t=0\nfor _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(a>0)\nprint(s)", "neg": "s=t=0\nfor _ in[0]*int(input()):a=int(input());s+=(a+t)//2;t=(a+t)%2&(i>0)\nprint(s)", "jacc_sim": 0.96, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [52, 52], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u884982181", "n_user": "u884982181", "pos": "n = int(input())\nmoto =[]\na = []\nfor _ in range(n):\n b = int(input())\n moto.append(b)\n if b%2 == 1:\n a.append(1)\n elif b:\n a.append(2)\n else:\n a.append(0)\nfor i in range(n-1):\n if a[i]%2 == 1:\n if a[i+1]:\n a[i+1] += 1\n a[i+1] %=2\n a[i]-=1\nfor i in range(n):\n a[i] %=2\nprint((sum(moto)-sum(a))//2)", "neg": "n = int(input())\nmoto =[]\na = []\nfor _ in range(n):\n b = int(input())\n moto.append(b)\n if b%2 == 1:\n a.append(1)\n elif b:\n a.append(2)\n else:\n a.append(0)\nfor i in range(n-1):\n if a[i]%2 == 1:\n a[i+1] += 1\n a[i+1] %=2\n a[i] = 0\nprint((sum(moto)-sum(a))//2)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [173, 147], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u667024514", "n_user": "u667024514", "pos": "n = int(input())\nlis = [int(input()) for i in range(n)]\ncou = 0\nnum = 0\nfor i in range(n):\n if lis[i] == 0:\n cou += (num // 2)\n num = 0\n else:\n num += lis[i]\ncou += (num // 2)\nprint(cou)", "neg": "n = int(input())\nlis = [int(input()) for i in range(n)]\ncou = 0\nnum = 0\nfor i in range(n):\n if lis[i] == 0:\n cou += (num // 2)\n num = 0\n else:\n num += lis[i]\nprint(cou)", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [93, 84], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u729133443", "n_user": "u729133443", "pos": "t=c=0\nfor _ in[0]*int(input()):i=int(input());c+=(i+t)//2;t=(i+t)%2&(i>0)\nprint(c)", "neg": "t=c=0\nfor _ in[0]*input():i=input();c+=(i+t)/2;t=i%2&(i>0)\nprint c", "jacc_sim": 0.9583333333333334, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [52, 41], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u536113865", "n_user": "u652081898", "pos": "n = int(input())\na = [int(input()) for _ in range(n)]\nans = a[0]//2\nfor i in range(1,n):\n if a[i]:\n a[i] += a[i-1]%2\n ans += a[i]//2\nprint(ans)", "neg": "n = int(input())\na = [int(input()) for _ in range(n)]\nans = 0\n\nfor i in range(n-1):\n ans += a[i]//2\n if a[i]%2 == 1 and a[i+1] == 1:\n a[i+1] -= 1\n ans += 1\nprint(ans)\n", "jacc_sim": 0.9259259259259259, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [77, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04020", "p_user": "u548624367", "n_user": "u623819879", "pos": "n = int(input())\ntmp,ans = 0,0\nfor i in range(n):\n\ta = int(input())\n\tif a == 0:\n\t\tans += tmp//2\n\t\ttmp = 0\n\telse:\n\t\ttmp += a\nelse:\n\tans += tmp//2\nprint(ans)", "neg": "n=int(input())\ntmp, ans=0,0\nfor i in range(n):\n a=int(input())\n if a=0:\n ans+=tmp//2\n tmp=0\n else:\n tmp+=a\nprint(ans)\n", "jacc_sim": 1.0, "nl": "Snuke has a collection of cards, each with an integer between 1 and N. He has Ai cards with the integer i. Two cards can form a pair if the absolute difference of the integers on them is at most 1. Snuke wants to create the maximum number of pairs without using a card in multiple pairs. Find the maximum number of pairs he can create. Constraints: 1 \u2264 N \u2264 10^5, 0 \u2264 Ai \u2264 10^9 (1 \u2264 i \u2264 N). Input format: N, A1, ..., AN. Output: Print the maximum number of pairs Snuke can create. Example: Input: 4, 4, 0, 3, 2. Output: 4. Example pairs: (1,1), (1,1), (3,4), (3,4).", "before_after_length": [76, 66], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u225388820", "n_user": "u225388820", "pos": "from collections import Counter\nn=int(input())\na=[int(input()) for i in range(n)]\nb=Counter(a[::2])\na.sort()\nc=Counter(a[::2])\n\nans=0\nfor i in b:\n\tif i in c:\n\t\tans+=abs(b[i]-c[i])\n\telse:\n\t\tans+=b[i]\nprint(ans)", "neg": "from collections import Counter\nn=int(input())\na=[int(input()) for i in range(n)]\nb=Counter(a[::2])\na.sort()\nc=Counter(a[::2])\n\nans=0\nfor i in b:\n\tif i in c:\n\t\tans+=abs(b[i])-c[i])\n\telse:\n\t\tans+=b[i]\nprint(ans)", "jacc_sim": 1.0, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [104, 104], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u818349438", "n_user": "u818349438", "pos": "n=int(input())\na =[int(input()) for i in range(n)]\nres = [[a[i],i]for i in range(n)]\nres.sort()\nret =0\nfor i in range(n):\n if res[i][1]%2 != i%2:ret+=1\nprint(ret//2)\n", "neg": "n=int(input())\na =[int(input()) for i in range(n)]\nres = [[a[i],i]for i in range(n)]\nres.sort()\nret =0\nfor i in range(n):\n if res[i][1]%2 != i%2:ret+=1\nprint(ret)", "jacc_sim": 0.9642857142857143, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [83, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u535803878", "n_user": "u535803878", "pos": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\n\nn = int(input())\na = [None] * n\nfor i in range(n):\n a[i] = (i,int(input()))\n \na.sort(key=lambda x: x[1])\nans = 0\nfor i in range(n):\n if a[i][0]%2 != i%2:\n ans += 1\nprint(ans//2)", "neg": "import sys\ninput = lambda : sys.stdin.readline().rstrip()\nsys.setrecursionlimit(max(1000, 10**9))\nwrite = lambda x: sys.stdout.write(x+\"\\n\")\n\nn = int(input())\na = [None] * n\nfor i in range(n):\n a[i] = (i,int(input()))\n \na.sort()\nans = 0\nfor i in range(n):\n if a[i][0]%2 != i%2:\n ans += 1\nprint(ans)", "jacc_sim": 0.9565217391304348, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [145, 133], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u067983636", "n_user": "u067983636", "pos": "import sys\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n# mod = 10 ** 9 + 7\nmod = 998244353\n\n\ndef read_values():\n return map(int, input().split())\n\n\ndef read_index():\n return map(lambda x: int(x) - 1, input().split())\n\n\ndef read_list():\n return list(read_values())\n\n\ndef read_lists(N):\n return [read_list() for n in range(N)]\n\n\nclass V:\n def __init__(self, f, v=None):\n self.f = f\n self.v = v\n\n def __str__(self):\n return str(self.v)\n\n def ud(self, n):\n if n is None:\n return\n\n if self.v is None:\n self.v = n\n return\n self.v = self.f(self.v, n)\n\n\ndef main():\n N = int(input())\n A = [(int(input()), n % 2) for n in range(N)]\n A.sort()\n\n res = 0\n for i, (_, j) in enumerate(A):\n if i % 2 != j:\n res += 1\n\n print(res // 2)\n\n\nif __name__ == \"__main__\":\n main()\n", "neg": "import sys\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n# mod = 10 ** 9 + 7\nmod = 998244353\n\n\ndef read_values():\n return map(int, input().split())\n\n\ndef read_index():\n return map(lambda x: int(x) - 1, input().split())\n\n\ndef read_list():\n return list(read_values())\n\n\ndef read_lists(N):\n return [read_list() for n in range(N)]\n\n\nclass V:\n def __init__(self, f, v=None):\n self.f = f\n self.v = v\n\n def __str__(self):\n return str(self.v)\n\n def ud(self, n):\n if n is None:\n return\n\n if self.v is None:\n self.v = n\n return\n self.v = self.f(self.v, n)\n\n\ndef main():\n N = int(input())\n A = [(int(input()), n % 2) for n in range(N)]\n\n print(A)\n res = 0\n t = 0\n for i, (_, j) in enumerate(A):\n if j == 0:\n res += abs(i - (t * 2))\n t += 1\n\n print(res)\n\n\nif __name__ == \"__main__\":\n main()\n", "jacc_sim": 0.9315068493150684, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [341, 355], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u984276646", "n_user": "u984276646", "pos": "N = int(input())\nA = [int(input()) * N + i for i in range(N)]\nA.sort()\ncnt = 0\nfor i in range(N):\n d = (A[i] % N) % 2\n if d % 2 != i % 2:\n cnt += 1\nprint(cnt//2)", "neg": "N = int(input())\nA = [int(input()) * N + i for i in range(N)]\nA.sort()\ncnt = 0\nfor i in range(N):\n d = (A[i] % N) % 2\n if d % 2 == i % 2:\n cnt += 1\nprint(cnt//2)", "jacc_sim": 0.9642857142857143, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [79, 79], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u606045429", "n_user": "u606045429", "pos": "N, *A = map(int, open(0))\nprint(len(set(A[1::2]) & set(sorted(A)[::2])))", "neg": "N, *A = map(int, open(0))\nprint(len(set(A[1::2] + sorted(A)[::2])))", "jacc_sim": 0.9090909090909091, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [37, 35], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u600402037", "n_user": "u600402037", "pos": "import sys\n#import numpy as np\n\nstdin = sys.stdin\n\nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ri()\nA = [ri() for _ in range(N)]\nx_to_i = {x:i for i, x in enumerate(sorted(A))}\nrank = [x_to_i[x] for x in A]\nanswer = sum(i&1 and (i^x)&1 for i,x in enumerate(rank))\nprint(answer)\n", "neg": "import sys\n#import numpy as np\n\nstdin = sys.stdin\n\nri = lambda: int(rs())\nrl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only\nrs = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ri()\nA = [ri() for _ in range(N)]\nx_to_i = {x:i for i, x in enumerate(sorted(A))}\nrank = [x_to_i[x] for x in A]\nanswer = sum((i^x)&1 for i,x in enumerate(rank)) // 2\nprint(B)\n", "jacc_sim": 0.9285714285714286, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [157, 154], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u413165887", "n_user": "u413165887", "pos": "def main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n b = sorted(a)\n c = b[::2]\n d = a[::2]\n set_c = set(c)\n set_d = set(d)\n print(len(set_c - set_d))\nmain()", "neg": "def main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n b = sorted(a)\n c = b[::2]\n d = a[::2]\n set_c = set(c)\n set_d = set(d)\n print(len(set_c & set_d))\n\nmain()", "jacc_sim": 0.9285714285714286, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [90, 91], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u298297089", "n_user": "u298297089", "pos": "n = int(input())\na = [[int(input()),i] for i in range(n)]\na.sort()\nans = 0\nfor i,tmp in enumerate(a):\n x,j = tmp\n ans += abs(i-j) % 2\nprint(ans//2)\n#print(a)\n", "neg": "n = int(input())\na = [[int(input()),i] for i in range(n)]\na.sort()\nans = 0\nfor i,tmp in enumerate(a):\n x,j = tmp\n ans += abs(i-j) % 2\nprint(ans-1)\n#print(a)\n", "jacc_sim": 0.9375, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [76, 76], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u803848678", "n_user": "u520276780", "pos": "n = int(input())\na = [(int(input()), i) for i in range(n)]\na.sort()\nans = 0\nfor i in range(n):\n if (i-a[i][1])%2:\n ans += 1\nprint(ans//2)", "neg": "n=int(input())\na=[(int(input()),i) for i in range(n)]\n#print(a)\na.sort()\n#print(a)\nans=0\n\nfor i in range(n):\n ans+=(a[i][1]-i)%2\nprint(ans,ans//2)\n", "jacc_sim": 0.9285714285714286, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [69, 80], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u227082700", "n_user": "u227082700", "pos": "a=sorted([[int(input()),i]for i in range(int(input()))]);print(sum([(a[i][1]-i)%2for i in range(len(a))])//2)", "neg": "a=sorted([[int(input()),i]for i in range(int(input()))]);print(sum([(a[i][1]-i)%2for i in range(len(a))]))", "jacc_sim": 0.9166666666666666, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [52, 49], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u360090862", "n_user": "u360090862", "pos": "N=int(input())\nA=[]\nB=[]\nfor i in range(N):\n\tif i%2==0:\n\t\tA.append(int(input()))\n\telse:\n\t\tB.append(int(input()))\n\t\t\nA=sorted(A)\nB=sorted(B)\nC=sorted(A+B)\n#\u3053\u3053\u307e\u3067NlogN\nc=0\nj=0\nfor i in range(N):\n\tif j>=len(A):\n\t\tbreak\n\tif A[j]==C[i]:\n\t\tif i%2==1:\n\t\t\tc+=1\n\t\tj+=1\nprint(c)", "neg": "N=int(input())\nA=[]\nB=[]\nfor i in range(N):\n\tif i%2==0:\n\t\tA.append(int(input()))\n\telse:\n\t\tB.append(int(input()))\n\t\t\nA=sorted(A)\nB=sorted(B)\nC=sorted(A+B)\n#\u3053\u3053\u307e\u3067NlogN\nc=0\nj=0\nfor i in range(C):\n\tif A[j]==C[i]:\n\t\tif i%2==1:\n\t\t\tc+=1\n\t\tj+=1\nprint(c)", "jacc_sim": 0.918918918918919, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [172, 158], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04021", "p_user": "u619819312", "n_user": "u619819312", "pos": "from collections import defaultdict as d\na=[int(input()) for i in range(int(input()))]\nb=sorted(a)\nc=d(int)\ne=0\nfor i in b[::2]:\n c[i]=1\nfor i in a[1::2]:\n e+=c[i]\nprint(e)", "neg": "from collections import defaultdict as d\na=[int(input()) for i in range(int(input()))]\nb=sorted(a)\nc=d(int)\ne=0\nfor i in range(0,n,2):\n d[b[i]]=1\nfor i in a[1::2]:\n e+=d[i]\nprint(e)", "jacc_sim": 0.9333333333333333, "nl": "Snuke received an integer sequence of length N as a birthday present from his mother. He wants to sort the sequence in increasing order. He can perform two operations: Operation 1 reverses the order of 2 consecutive elements, and Operation 2 reverses the order of 3 consecutive elements. Snuke prefers Operation 2 over Operation 1. The task is to find the minimum number of times Operation 1 needs to be performed to sort the sequence in increasing order. The constraints are 1 \u2264 N \u2264 10^5, 0 \u2264 A_i \u2264 10^9, A_i \u2260 A_j if i \u2260 j, and all input values are integers. The input is given in the format N followed by the elements of the sequence. The output should be the minimum number of times Operation 1 needs to be performed. Two sample inputs and their corresponding outputs are provided.", "before_after_length": [83, 88], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04022", "p_user": "u467736898", "n_user": "u467736898", "pos": "import sys\nfrom subprocess import Popen, PIPE\nfrom itertools import groupby\nfrom collections import Counter\n\ndef main():\n sys.stdin.readline()\n S = sys.stdin.read().split()\n T = []\n inv_dict = {}\n Factors = Popen([\"factor\"] + S, stdout=PIPE).communicate()[0].split(b\"\\n\")\n for factors in Factors[:-1]:\n factors = map(int, factors.split()[1:])\n t = 1\n t_inv = 1\n for f, group in groupby(factors):\n n = len(list(group)) % 3\n if n == 1:\n t *= f\n elif n == 2:\n t_inv *= f\n t, t_inv = t * t_inv * t_inv, t * t * t_inv\n T.append(t)\n inv_dict[t] = t_inv\n\n counter_T = Counter(T)\n ans = 0\n for t, t_cnt in counter_T.items():\n if t == 1:\n ans += 1\n continue\n t_inv = inv_dict[t]\n t_inv_cnt = counter_T[t_inv]\n if t_cnt > t_inv_cnt or (t_cnt == t_inv_cnt and t > t_inv):\n ans += t_cnt\n print(ans)\n\nmain()\n", "neg": "import sys\nfrom subprocess import Popen, PIPE\nfrom itertools import groupby\nfrom collections import Counter\n\ndef main():\n sys.stdin.readline()\n S = sys.stdin.read()\n T = []\n inv_dict = {}\n Factors = Popen(\"factor \" + S, stdout=PIPE).communicate()[0].split(b\"\\n\")\n for factors in Factors:\n factors = map(int, factors.split()[1:])\n t = 1\n t_inv = 1\n for f, group in groupby(factors):\n n = len(list(group)) % 3\n if n == 1:\n t *= f\n elif n == 2:\n t_inv *= f\n t, t_inv = t * t_inv * t_inv, t * t * t_inv\n T.append(t)\n inv_dict[t] = t_inv\n\n counter_T = Counter(T)\n ans = 0\n for t, t_cnt in counter_T.items():\n if t == 1:\n ans += 1\n continue\n t_inv = inv_dict[t]\n t_inv_cnt = counter_T[t_inv]\n if t_cnt > t_inv_cnt or (t_cnt == t_inv_cnt and t > t_inv):\n ans += t_cnt\n print(ans)\n\nmain()\n", "jacc_sim": 0.9855072463768116, "nl": "Snuke received positive integers \\( s_1, ..., s_N \\) as a birthday present. He wants to circle some of these integers, ensuring that if both \\( s_i \\) and \\( s_j \\) are circled, the product \\( s_i \\times s_j \\) is not a perfect cube. The task is to find the maximum number of integers that Snuke can circle. Constraints: \\( 1 \\leq N \\leq 10^5 \\), \\( 1 \\leq s_i \\leq 10^{10} \\). The input is given in the format: \\( N \\), \\( s_1, ..., s_N \\). Output the maximum number of integers that Snuke can circle.", "before_after_length": [342, 336], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04027", "p_user": "u368780724", "n_user": "u368780724", "pos": "import sys\nfrom itertools import accumulate\nreadline = sys.stdin.readline\nMOD = 10**9+7\n\nN, C = map(int, readline().split())\nA = [0] + list(map(int, readline().split()))\nB = [0] + list(map(int, readline().split()))\n\nacsq = []\nlb = max(B)+1\nfor j in range(C+1):\n ac = [0]*lb\n ac[0] = 1\n for i in range(1, lb):\n ac[i] = (ac[i-1] + pow(i, j, MOD)) % MOD\n acsq.append(ac)\ndp = [[0]*(C+1) for _ in range(N+1)]\ndp[0][0] = 1\nfor i in range(1, N+1):\n a, b = A[i], B[i]\n for c in range(C+1):\n res = 0\n for j in range(c+1):\n res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD\n dp[i][c] = res\nprint(dp[N][C])", "neg": "for _ in range(test_case):\nimport sys\nfrom itertools import accumulate\nreadline = sys.stdin.readline\nMOD = 10**9+7\n\nN, C = map(int, readline().split())\nA = [0] + list(map(int, readline().split()))\nB = [0] + list(map(int, readline().split()))\n\nacsq = [list(accumulate([pow(i, j, MOD) for i in range(max(B)+1)])) for j in range(C+1)]\ndp = [[0]*(C+1) for _ in range(N+1)]\ndp[0][0] = 1\nfor i in range(1, N+1):\n a, b = A[i], B[i]\n for c in range(C+1):\n res = 0\n for j in range(c+1):\n res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD\n dp[i][c] = res\nprint(dp[N][C])", "jacc_sim": 0.9230769230769231, "nl": "In AtCoder Kindergarten, there are N children numbered 1 through N. Mr. Evi will distribute C indistinguishable candies to the children. Each child's happiness is determined by the number of candies they receive, based on their excitement level. The activity level of the kindergarten is the product of the happiness of all N children. The task is to calculate the sum of the activity levels for all possible ways to distribute C candies. The input consists of N, C, and arrays A and B. The output should be the value of a specific function modulo 10^9+7. The constraints are 1\u2264N\u2264400, 1\u2264C\u2264400, and 1\u2264A_i\u2264B_i\u2264400 (1\u2264i\u2264N). The problem has a partial score of 400 points for passing the test set satisfying A_i=B_i (1\u2264i\u2264N). The input format is N C A_1 A_2 ... A_N B_1 B_2 ... B_N, and the output is the value of a specific function modulo 10^9+7. The problem also includes sample inputs and outputs for illustration.", "before_after_length": [301, 266], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04027", "p_user": "u077337864", "n_user": "u077337864", "pos": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\nMOD = pow(10, 9) + 7\n\ndef main():\n n, c = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n \n pow_table = [[0 for _ in range(401)] for _ in range(401)]\n # pow_table[i][j]: i^j\n for i in range(1, 401):\n pow_table[i][0] = 1\n \n for i in range(1, 401):\n for j in range(1, 401):\n pow_table[i][j] = pow_table[i][j-1] * i % MOD\n for i in range(1, 401):\n for j in range(401):\n pow_table[i][j] += pow_table[i-1][j]\n if pow_table[i][j] >= MOD:\n pow_table[i][j] -= MOD\n \n dp = [[0 for _ in range(c+1)] for _ in range(n+1)]\n dp[0][0] = 1\n for i in range(1, n+1):\n for j in range(c+1):\n for k in range(j+1):\n ab = pow_table[b[i-1]][k] - pow_table[a[i-1]-1][k]\n if ab < 0:\n ab += MOD\n dp[i][j] += dp[i-1][j-k] * ab % MOD\n if dp[i][j] >= MOD:\n dp[i][j] -= MOD\n\n print(dp[n][c])\n\n\nif __name__ == '__main__':\n main()\n", "neg": "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(pow(10, 6))\n\nMOD = pow(10, 9) + 7\n\ndef main():\n n, c = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n assert(a==b)\n dp = [[0 for _ in range(c+1)] for _ in range(n+1)]\n for i in range(n+1):\n dp[i][0] = 1\n pow_table = [[1 for _ in range(401)] for _ in range(n)]\n for i in range(1, 401):\n for j in range(n):\n pow_table[j][i] = pow_table[j][i-1]*a[j]%MOD\n \n for i in range(1, n+1):\n for j in range(1, c+1):\n for k in range(j+1):\n dp[i][j] += dp[i-1][j-k] * pow_table[i-1][k] % MOD\n if dp[i][j] >= MOD:\n dp[i][j] -= MOD\n print(dp[n][c])\n\n\nif __name__ == '__main__':\n main()\n", "jacc_sim": 0.9122807017543859, "nl": "In AtCoder Kindergarten, there are N children numbered 1 through N. Mr. Evi will distribute C indistinguishable candies to the children. Each child's happiness is determined by the number of candies they receive, based on their excitement level. The activity level of the kindergarten is the product of the happiness of all N children. The task is to calculate the sum of the activity levels for all possible ways to distribute C candies. The input consists of N, C, and arrays A and B. The output should be the value of a specific function modulo 10^9+7. The constraints are 1\u2264N\u2264400, 1\u2264C\u2264400, and 1\u2264A_i\u2264B_i\u2264400 (1\u2264i\u2264N). The problem has a partial score of 400 points for passing the test set satisfying A_i=B_i (1\u2264i\u2264N). The input format is N C A_1 A_2 ... A_N B_1 B_2 ... B_N, and the output is the value of a specific function modulo 10^9+7. The problem also includes sample inputs and outputs for illustration.", "before_after_length": [451, 327], "pos_test_status": 1, "neg_test_status": 0} {"problem_id": "p04027", "p_user": "u052499405", "n_user": "u052499405", "pos": "MOD = 10**9 + 7\nn, m = [int(item) for item in input().split()]\na = [int(item) for item in input().split()]\nb = [int(item) for item in input().split()]\n\ncumsum = [[1] * 410 for _ in range(410)]\nfor order in range(405):\n for i in range(1, 405):\n cumsum[order][i] = pow(i, order, MOD) + cumsum[order][i-1]\n cumsum[order][i] %= MOD\n\ndp = [[0] * (m + 1) for _ in range(n + 1)]\ndp[0][0] = 1\nfor i in range(1, n+1):\n for j in range(0, m+1):\n for k in range(j+1):\n l = a[i - 1]\n r = b[i - 1]\n x = (cumsum[j-k][r] - cumsum[j-k][l-1] + MOD) % MOD\n dp[i][j] += dp[i-1][k] * x \n dp[i][j] %= MOD\n\nprint(dp[-1][-1])", "neg": "MOD = 10**9 + 7\nn, m = [int(item) for item in input().split()]\na = [int(item) for item in input().split()]\nb = [int(item) for item in input().split()]\n\ncumsum = [[1] * 410 for _ in range(410)]\nfor order in range(405):\n for i in range(1, 405):\n cumsum[order][i] = pow(i, order, MOD) + cumsum[order][i-1]\n cumsum[order][i] %= MOD\n\ndp = [[0] * (m + 1) for _ in range(n + 1)]\ndp[0][0] = 1\nfor i in range(n):\n dp[i+1][0] = b[i] - a[i] + 1\nfor i in range(1, n+1):\n for j in range(1, m+1):\n for k in range(j+1):\n l = a[i - 1]\n r = b[i - 1]\n # print(j-k)\n x = (cumsum[j-k][r] - cumsum[j-k][l-1] + MOD) % MOD\n dp[i][j] += dp[i-1][k] * x \n dp[i][j] %= MOD\n\nprint(dp[-1][-1])", "jacc_sim": 0.9772727272727273, "nl": "In AtCoder Kindergarten, there are N children numbered 1 through N. Mr. Evi will distribute C indistinguishable candies to the children. Each child's happiness is determined by the number of candies they receive, based on their excitement level. The activity level of the kindergarten is the product of the happiness of all N children. The task is to calculate the sum of the activity levels for all possible ways to distribute C candies. The input consists of N, C, and arrays A and B. The output should be the value of a specific function modulo 10^9+7. The constraints are 1\u2264N\u2264400, 1\u2264C\u2264400, and 1\u2264A_i\u2264B_i\u2264400 (1\u2264i\u2264N). The problem has a partial score of 400 points for passing the test set satisfying A_i=B_i (1\u2264i\u2264N). The input format is N C A_1 A_2 ... A_N B_1 B_2 ... B_N, and the output is the value of a specific function modulo 10^9+7. The problem also includes sample inputs and outputs for illustration.", "before_after_length": [290, 329], "pos_test_status": 1, "neg_test_status": 0}